- 20
- Posts
- 1
- Years
- United States
- Seen Feb 16, 2025
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?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
I don't know where the braille rocks cave comes into this, I just want to add an ability for pokemon to set the field effect of trick room when they switch in, similar to drizzle, grassy surge, etc.Are you talking about the brail rocks cave or a programming/coding trigger?
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: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
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,
+ },
};
src/data/text/abilities.h
, but the underlying concept doesn't really change.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 muchAssuming 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 insrc/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 newcase
for it in thecase ABILITYEFFECT_ON_SWITCHIN
ofAbilityBattleEffects
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)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 insrc/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 newcase
for it in thecase ABILITYEFFECT_ON_SWITCHIN
ofAbilityBattleEffects
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.
You can usereally 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)
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.src/data/items.h
(git grep "Choice Scarf"
).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 areYou can usegit 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 insidesrc/data/items.h
(git grep "Choice Scarf"
).
If you look up the Choice Scarf's hold effect label usinggit grep
, you'll find out that the function of code that use it for the item's effect is located insrc/battle_main.c
.