- 3
- Posts
- 3
- Years
- Seen Jul 1, 2023
Hi folks! I'm having a very specific problem here:
I'm using rh-hideout's pokeemerald-expansion (along with a couple of other merges/rebases that shouldn't affect the battle system). I have a Nuzleaf with Sunny Day and Grassy Terrain for playtesting purposes, and I noticed that under a specific set of conditions, having Nuzleaf use Sunny Day followed immediately by Grassy Terrain crashes the game (after the text about setting the terrain, and before the background successfully changes). It looks like the crash occurs while the game is trying to apply the animation for changing the background to reflect the new terrain.
I believe I've traced the crash to the function Cmd_playanimation in src/battle_script_commands.c, called by BattleScript_EffectGrassyTerrain in the file data/battle_scripts_1.s. Specifically, removing the line "MarkBattlerForControllerExec(gActiveBattler);" from the last "else" clause of this function causes the crash not to occur (and also causes the terrain background not to appear, of course). I don't have the familiarity to trace what happens beyond that, and that's my main question: how do I find the places in the code that actually activate the terrain-changing animation, and what part of that could possibly be affected by having used a weather-setting move?
Some additional details revealed via testing:
-The crash persists when Sunny Day is replaced with a different weather-setting move (e.g. Sandstorm)
-The crash persists when Grassy Terrain is replaced with a different terrain-setting move (e.g. Electric Terrain)
-The crash persists even when the weather move fails (for example, if I'd used sunny day previously or sent out a Pokemon with drought beforehand), but can only trigger when a weather move was attempted (not from e.g. Drought + Grassy Terrain alone)
-The crash seems to not occur if Nuzleaf uses a damaging move like Razor Leaf between Sunny Day and Grassy Terrain, but this doesn't apply if the move didn't trigger an animation (e.g. the opponent used Protect), and it doesn't seem to apply to Nature Power
-The crash does not occur if Nuzleaf is confused, or if, in a double battle, Nuzleaf's partner is switched out on the same turn
-The crash does not depend on Nuzleaf's ability (I checked)
-The crash persists when I remove the line "BtlController_EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr);" before the previously mentioned line. Notably, while removing this line (and not the one after it) disables the terrain animation, it does not seem to make the game crash on its own without a weather-setting move having been used first.
If anyone happens to know how to resolve this, I would really appreciate any enlightenment!
EDIT: More observations:
-The weather and terrain moves don't have to be used by the same Pokemon. If they're used by different Pokemon, they can be used on the same turn, or multiple turns apart (as long as they aren't interrupted by certain moves, which seem so far to be damaging moves).
I'm using rh-hideout's pokeemerald-expansion (along with a couple of other merges/rebases that shouldn't affect the battle system). I have a Nuzleaf with Sunny Day and Grassy Terrain for playtesting purposes, and I noticed that under a specific set of conditions, having Nuzleaf use Sunny Day followed immediately by Grassy Terrain crashes the game (after the text about setting the terrain, and before the background successfully changes). It looks like the crash occurs while the game is trying to apply the animation for changing the background to reflect the new terrain.
I believe I've traced the crash to the function Cmd_playanimation in src/battle_script_commands.c, called by BattleScript_EffectGrassyTerrain in the file data/battle_scripts_1.s. Specifically, removing the line "MarkBattlerForControllerExec(gActiveBattler);" from the last "else" clause of this function causes the crash not to occur (and also causes the terrain background not to appear, of course). I don't have the familiarity to trace what happens beyond that, and that's my main question: how do I find the places in the code that actually activate the terrain-changing animation, and what part of that could possibly be affected by having used a weather-setting move?
Some additional details revealed via testing:
-The crash persists when Sunny Day is replaced with a different weather-setting move (e.g. Sandstorm)
-The crash persists when Grassy Terrain is replaced with a different terrain-setting move (e.g. Electric Terrain)
-The crash persists even when the weather move fails (for example, if I'd used sunny day previously or sent out a Pokemon with drought beforehand), but can only trigger when a weather move was attempted (not from e.g. Drought + Grassy Terrain alone)
-The crash seems to not occur if Nuzleaf uses a damaging move like Razor Leaf between Sunny Day and Grassy Terrain, but this doesn't apply if the move didn't trigger an animation (e.g. the opponent used Protect), and it doesn't seem to apply to Nature Power
-The crash does not occur if Nuzleaf is confused, or if, in a double battle, Nuzleaf's partner is switched out on the same turn
-The crash does not depend on Nuzleaf's ability (I checked)
-The crash persists when I remove the line "BtlController_EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr);" before the previously mentioned line. Notably, while removing this line (and not the one after it) disables the terrain animation, it does not seem to make the game crash on its own without a weather-setting move having been used first.
If anyone happens to know how to resolve this, I would really appreciate any enlightenment!
EDIT: More observations:
-The weather and terrain moves don't have to be used by the same Pokemon. If they're used by different Pokemon, they can be used on the same turn, or multiple turns apart (as long as they aren't interrupted by certain moves, which seem so far to be damaging moves).
Last edited: