• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Other] Adding a Trick Room ability in pokeemerald

20
Posts
298
Days
  • Hello All, I am running into an issue and I cannot figure out how to implement an ability into pokeemerald that would automatically set trick room up on switch in, any help would be appreciated
     
    14
    Posts
    127
    Days
    • Seen Feb 25, 2024
    Hello All, I am running into an issue and I cannot figure out how to implement an ability into pokeemerald that would automatically set trick room up on switch in, any help would be appreciated
    Are you talking about the brail rocks cave or a programming/coding trigger?
     

    Lunos

    Random Uruguayan User
    3,115
    Posts
    15
    Years
  • Hello All, I am running into an issue and I cannot figure out how to implement an ability into pokeemerald that would automatically set trick room up on switch in, any help would be appreciated
    Assuming that you're using the Pokeemerald-expansion (because otherwise you'll have to implement Trick Room in its entirety), you'd do something like this:
    Diff:
    diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s
    index 18e7f6f61..995879e0e 100644
    --- a/data/battle_scripts_1.s
    +++ b/data/battle_scripts_1.s
    @@ -10380,3 +10380,8 @@ BattleScript_EffectSnow::
         call BattleScript_CheckPrimalWeather
         setsnow
         goto BattleScript_MoveWeatherChange
    +
    +BattleScript_TrickRealmActivates::
    +    printstring STRINGID_PKMNTWISTEDDIMENSIONS
    +    waitmessage B_WAIT_TIME_LONG
    +    end3
    diff --git a/include/battle_scripts.h b/include/battle_scripts.h
    index c1da89443..4795bfea4 100644
    --- a/include/battle_scripts.h
    +++ b/include/battle_scripts.h
    @@ -490,6 +490,7 @@ extern const u8 BattleScript_TheRainbowDisappeared[];
     extern const u8 BattleScript_HurtByTheSeaOfFire[];
     extern const u8 BattleScript_TheSeaOfFireDisappeared[];
     extern const u8 BattleScript_TheSwampDisappeared[];
    +extern const u8 BattleScript_TrickRealmActivates[];
     
     // zmoves
     extern const u8 BattleScript_ZMoveActivateDamaging[];
    diff --git a/include/constants/abilities.h b/include/constants/abilities.h
    index 3cced68bb..42f387bb1 100644
    --- a/include/constants/abilities.h
    +++ b/include/constants/abilities.h
    @@ -339,6 +339,10 @@
     
     #define ABILITIES_COUNT_GEN9 311
     
    -#define ABILITIES_COUNT ABILITIES_COUNT_GEN9
    +// Custom
    +#define ABILITY_TRICK_REALM 312
    +#define ABILITIES_COUNT_CUSTOM 313
    +
    +#define ABILITIES_COUNT ABILITIES_COUNT_CUSTOM
     
     #endif  // GUARD_CONSTANTS_ABILITIES_H
    diff --git a/src/battle_util.c b/src/battle_util.c
    index e056fcd6e..f62ada33a 100644
    --- a/src/battle_util.c
    +++ b/src/battle_util.c
    @@ -4644,6 +4644,13 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
                     effect++;
                 }
                 break;
    +        case ABILITY_TRICK_REALM:
    +            if (TryChangeBattleTerrain(battler, STATUS_FIELD_TRICK_ROOM, &gFieldTimers.trickRoomTimer))
    +            {
    +                BattleScriptPushCursorAndCallback(BattleScript_TrickRealmActivates);
    +                effect++;
    +            }
    +            break;
             }
             break;
         case ABILITYEFFECT_ENDTURN: // 1
    diff --git a/src/data/abilities.h b/src/data/abilities.h
    index 81bfc995a..99b9d0b3b 100644
    --- a/src/data/abilities.h
    +++ b/src/data/abilities.h
    @@ -2599,4 +2599,11 @@ const struct Ability gAbilities[ABILITIES_COUNT] =
             .cantBeSwapped = TRUE,
             .cantBeTraced = TRUE,
         },
    +
    +    [ABILITY_TRICK_REALM] =
    +    {
    +        .name = _("Trick Realm"),
    +        .description = COMPOUND_STRING("Field becomes weird."),
    +        .aiRating = 8,
    +    },
     };

    Depending on how out of date and/or what base branch of the Pokeemerald-expansion you use there may be subtle differences such as abilities' name and description strings being in src/data/text/abilities.h, but the underlying concept doesn't really change.
    You define your new ability like every other in the codebase, fill in the basic parameters such as name and description, add a new case for it in the case ABILITYEFFECT_ON_SWITCHIN of AbilityBattleEffects with code you can copy-paste-modify from any other field terrain-changing ability effect such as Grassy Surge's, a battle script to activate a nice message like Trick Room does when you use it, and that's pretty much it.
     
    20
    Posts
    298
    Days
  • Assuming that you're using the Pokeemerald-expansion (because otherwise you'll have to implement Trick Room in its entirety), you'd do something like this:
    Diff:
    diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s
    index 18e7f6f61..995879e0e 100644
    --- a/data/battle_scripts_1.s
    +++ b/data/battle_scripts_1.s
    @@ -10380,3 +10380,8 @@ BattleScript_EffectSnow::
         call BattleScript_CheckPrimalWeather
         setsnow
         goto BattleScript_MoveWeatherChange
    +
    +BattleScript_TrickRealmActivates::
    +    printstring STRINGID_PKMNTWISTEDDIMENSIONS
    +    waitmessage B_WAIT_TIME_LONG
    +    end3
    diff --git a/include/battle_scripts.h b/include/battle_scripts.h
    index c1da89443..4795bfea4 100644
    --- a/include/battle_scripts.h
    +++ b/include/battle_scripts.h
    @@ -490,6 +490,7 @@ extern const u8 BattleScript_TheRainbowDisappeared[];
     extern const u8 BattleScript_HurtByTheSeaOfFire[];
     extern const u8 BattleScript_TheSeaOfFireDisappeared[];
     extern const u8 BattleScript_TheSwampDisappeared[];
    +extern const u8 BattleScript_TrickRealmActivates[];
     
     // zmoves
     extern const u8 BattleScript_ZMoveActivateDamaging[];
    diff --git a/include/constants/abilities.h b/include/constants/abilities.h
    index 3cced68bb..42f387bb1 100644
    --- a/include/constants/abilities.h
    +++ b/include/constants/abilities.h
    @@ -339,6 +339,10 @@
     
     #define ABILITIES_COUNT_GEN9 311
     
    -#define ABILITIES_COUNT ABILITIES_COUNT_GEN9
    +// Custom
    +#define ABILITY_TRICK_REALM 312
    +#define ABILITIES_COUNT_CUSTOM 313
    +
    +#define ABILITIES_COUNT ABILITIES_COUNT_CUSTOM
     
     #endif  // GUARD_CONSTANTS_ABILITIES_H
    diff --git a/src/battle_util.c b/src/battle_util.c
    index e056fcd6e..f62ada33a 100644
    --- a/src/battle_util.c
    +++ b/src/battle_util.c
    @@ -4644,6 +4644,13 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
                     effect++;
                 }
                 break;
    +        case ABILITY_TRICK_REALM:
    +            if (TryChangeBattleTerrain(battler, STATUS_FIELD_TRICK_ROOM, &gFieldTimers.trickRoomTimer))
    +            {
    +                BattleScriptPushCursorAndCallback(BattleScript_TrickRealmActivates);
    +                effect++;
    +            }
    +            break;
             }
             break;
         case ABILITYEFFECT_ENDTURN: // 1
    diff --git a/src/data/abilities.h b/src/data/abilities.h
    index 81bfc995a..99b9d0b3b 100644
    --- a/src/data/abilities.h
    +++ b/src/data/abilities.h
    @@ -2599,4 +2599,11 @@ const struct Ability gAbilities[ABILITIES_COUNT] =
             .cantBeSwapped = TRUE,
             .cantBeTraced = TRUE,
         },
    +
    +    [ABILITY_TRICK_REALM] =
    +    {
    +        .name = _("Trick Realm"),
    +        .description = COMPOUND_STRING("Field becomes weird."),
    +        .aiRating = 8,
    +    },
     };

    Depending on how out of date and/or what base branch of the Pokeemerald-expansion you use there may be subtle differences such as abilities' name and description strings being in src/data/text/abilities.h, but the underlying concept doesn't really change.
    You define your new ability like every other in the codebase, fill in the basic parameters such as name and description, add a new case for it in the case ABILITYEFFECT_ON_SWITCHIN of AbilityBattleEffects with code you can copy-paste-modify from any other field terrain-changing ability effect such as Grassy Surge's, a battle script to activate a nice message like Trick Room does when you use it, and that's pretty much it.
    Thank you so much
     
    20
    Posts
    298
    Days
  • Assuming that you're using the Pokeemerald-expansion (because otherwise you'll have to implement Trick Room in its entirety), you'd do something like this:
    Diff:
    diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s
    index 18e7f6f61..995879e0e 100644
    --- a/data/battle_scripts_1.s
    +++ b/data/battle_scripts_1.s
    @@ -10380,3 +10380,8 @@ BattleScript_EffectSnow::
         call BattleScript_CheckPrimalWeather
         setsnow
         goto BattleScript_MoveWeatherChange
    +
    +BattleScript_TrickRealmActivates::
    +    printstring STRINGID_PKMNTWISTEDDIMENSIONS
    +    waitmessage B_WAIT_TIME_LONG
    +    end3
    diff --git a/include/battle_scripts.h b/include/battle_scripts.h
    index c1da89443..4795bfea4 100644
    --- a/include/battle_scripts.h
    +++ b/include/battle_scripts.h
    @@ -490,6 +490,7 @@ extern const u8 BattleScript_TheRainbowDisappeared[];
     extern const u8 BattleScript_HurtByTheSeaOfFire[];
     extern const u8 BattleScript_TheSeaOfFireDisappeared[];
     extern const u8 BattleScript_TheSwampDisappeared[];
    +extern const u8 BattleScript_TrickRealmActivates[];
     
     // zmoves
     extern const u8 BattleScript_ZMoveActivateDamaging[];
    diff --git a/include/constants/abilities.h b/include/constants/abilities.h
    index 3cced68bb..42f387bb1 100644
    --- a/include/constants/abilities.h
    +++ b/include/constants/abilities.h
    @@ -339,6 +339,10 @@
     
     #define ABILITIES_COUNT_GEN9 311
     
    -#define ABILITIES_COUNT ABILITIES_COUNT_GEN9
    +// Custom
    +#define ABILITY_TRICK_REALM 312
    +#define ABILITIES_COUNT_CUSTOM 313
    +
    +#define ABILITIES_COUNT ABILITIES_COUNT_CUSTOM
     
     #endif  // GUARD_CONSTANTS_ABILITIES_H
    diff --git a/src/battle_util.c b/src/battle_util.c
    index e056fcd6e..f62ada33a 100644
    --- a/src/battle_util.c
    +++ b/src/battle_util.c
    @@ -4644,6 +4644,13 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
                     effect++;
                 }
                 break;
    +        case ABILITY_TRICK_REALM:
    +            if (TryChangeBattleTerrain(battler, STATUS_FIELD_TRICK_ROOM, &gFieldTimers.trickRoomTimer))
    +            {
    +                BattleScriptPushCursorAndCallback(BattleScript_TrickRealmActivates);
    +                effect++;
    +            }
    +            break;
             }
             break;
         case ABILITYEFFECT_ENDTURN: // 1
    diff --git a/src/data/abilities.h b/src/data/abilities.h
    index 81bfc995a..99b9d0b3b 100644
    --- a/src/data/abilities.h
    +++ b/src/data/abilities.h
    @@ -2599,4 +2599,11 @@ const struct Ability gAbilities[ABILITIES_COUNT] =
             .cantBeSwapped = TRUE,
             .cantBeTraced = TRUE,
         },
    +
    +    [ABILITY_TRICK_REALM] =
    +    {
    +        .name = _("Trick Realm"),
    +        .description = COMPOUND_STRING("Field becomes weird."),
    +        .aiRating = 8,
    +    },
     };

    Depending on how out of date and/or what base branch of the Pokeemerald-expansion you use there may be subtle differences such as abilities' name and description strings being in src/data/text/abilities.h, but the underlying concept doesn't really change.
    You define your new ability like every other in the codebase, fill in the basic parameters such as name and description, add a new case for it in the case ABILITYEFFECT_ON_SWITCHIN of AbilityBattleEffects with code you can copy-paste-modify from any other field terrain-changing ability effect such as Grassy Surge's, a battle script to activate a nice message like Trick Room does when you use it, and that's pretty much it.
    really dumb question, where is the data surrounding the choice scarf located in expansion? My first thoughts would be battle_util or battle_setup, but it wasn't in either of those places (I want to add a slight speed buff on the flame orb item and I figured I could more or less copy-paste the speed up effect wherever scarf applies it)
     
    Last edited:

    Lunos

    Random Uruguayan User
    3,115
    Posts
    15
    Years
  • really dumb question, where is the data surrounding the choice scarf located in expansion? My first thoughts would be battle_util or battle_setup, but it wasn't in either of those places (I want to add a slight speed buff on the flame orb item and I figured I could more or less copy-paste the speed up effect wherever scarf applies it)
    You can use git grep inside your terminal or an equivalent such as Visual Studio Code's folder-wide search to look up words or sentences in the project's folder.
    The main parameters of each item are inside src/data/items.h (git grep "Choice Scarf").
    If you look up the Choice Scarf's hold effect label using git grep, you'll find out that the function of code that use it for the item's effect is located in src/battle_main.c.
     
    20
    Posts
    298
    Days
  • You can use git grep inside your terminal or an equivalent such as Visual Studio Code's folder-wide search to look up words or sentences in the project's folder.
    The main parameters of each item are inside src/data/items.h (git grep "Choice Scarf").
    If you look up the Choice Scarf's hold effect label using git grep, you'll find out that the function of code that use it for the item's effect is located in src/battle_main.c.
    Thank you, I had no idea these were a thing, now it makes sense why I can never find other users questioning where specific bits of code are
     
    Back
    Top