From b447d582cd6f929acc7aaeba3eb313dfe7df3891 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 13 Oct 2021 09:04:03 -0400 Subject: [PATCH] fix terrain timer decrementing and bg changing with anims disabled --- src/battle_script_commands.c | 31 ++++++++++++++++--------------- src/battle_util.c | 6 +++--- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2c017b2df..6852dee1e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4527,12 +4527,13 @@ static void Cmd_endselectionscript(void) static void Cmd_playanimation(void) { const u16* argumentPtr; + u8 animId = gBattlescriptCurrInstr[2]; gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); argumentPtr = T2_READ_PTR(gBattlescriptCurrInstr + 3); #if B_TERRAIN_BG_CHANGE == FALSE - if (gBattlescriptCurrInstr[2] == B_ANIM_RESTORE_BG) + if (animId == B_ANIM_RESTORE_BG) { // workaround for .if not working gBattlescriptCurrInstr += 7; @@ -4540,28 +4541,28 @@ static void Cmd_playanimation(void) } #endif - if (gBattlescriptCurrInstr[2] == B_ANIM_STATS_CHANGE - || gBattlescriptCurrInstr[2] == B_ANIM_SNATCH_MOVE - || gBattlescriptCurrInstr[2] == B_ANIM_MEGA_EVOLUTION - || gBattlescriptCurrInstr[2] == B_ANIM_ILLUSION_OFF - || gBattlescriptCurrInstr[2] == B_ANIM_FORM_CHANGE - || gBattlescriptCurrInstr[2] == B_ANIM_SUBSTITUTE_FADE) + if (animId == B_ANIM_STATS_CHANGE + || animId == B_ANIM_SNATCH_MOVE + || animId == B_ANIM_MEGA_EVOLUTION + || animId == B_ANIM_ILLUSION_OFF + || animId == B_ANIM_FORM_CHANGE + || animId == B_ANIM_SUBSTITUTE_FADE) { - BtlController_EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); + BtlController_EmitBattleAnimation(0, animId, *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 7; } - else if (gHitMarker & HITMARKER_NO_ANIMATIONS) + else if (gHitMarker & HITMARKER_NO_ANIMATIONS && animId != B_ANIM_RESTORE_BG) { BattleScriptPush(gBattlescriptCurrInstr + 7); gBattlescriptCurrInstr = BattleScript_Pausex20; } - else if (gBattlescriptCurrInstr[2] == B_ANIM_RAIN_CONTINUES - || gBattlescriptCurrInstr[2] == B_ANIM_SUN_CONTINUES - || gBattlescriptCurrInstr[2] == B_ANIM_SANDSTORM_CONTINUES - || gBattlescriptCurrInstr[2] == B_ANIM_HAIL_CONTINUES) + else if (animId == B_ANIM_RAIN_CONTINUES + || animId == B_ANIM_SUN_CONTINUES + || animId == B_ANIM_SANDSTORM_CONTINUES + || animId == B_ANIM_HAIL_CONTINUES) { - BtlController_EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); + BtlController_EmitBattleAnimation(0, animId, *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 7; } @@ -4571,7 +4572,7 @@ static void Cmd_playanimation(void) } else { - BtlController_EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); + BtlController_EmitBattleAnimation(0, animId, *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 7; } diff --git a/src/battle_util.c b/src/battle_util.c index 68e787698..68e52f49d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2234,7 +2234,7 @@ u8 DoFieldEndTurnEffects(void) break; case ENDTURN_ELECTRIC_TERRAIN: if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN - && ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.electricTerrainTimer == 0)) + && (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.electricTerrainTimer == 0)) { gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT); BattleScriptExecute(BattleScript_ElectricTerrainEnds); @@ -2244,7 +2244,7 @@ u8 DoFieldEndTurnEffects(void) break; case ENDTURN_MISTY_TERRAIN: if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN - && ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.mistyTerrainTimer == 0)) + && (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.mistyTerrainTimer == 0)) { gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN); BattleScriptExecute(BattleScript_MistyTerrainEnds); @@ -2266,7 +2266,7 @@ u8 DoFieldEndTurnEffects(void) break; case ENDTURN_PSYCHIC_TERRAIN: if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN - && ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.psychicTerrainTimer == 0)) + && (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.psychicTerrainTimer == 0)) { gFieldStatuses &= ~(STATUS_FIELD_PSYCHIC_TERRAIN); BattleScriptExecute(BattleScript_PsychicTerrainEnds);