From 6daab7a5c93a9080734aedf49195b4333230cd41 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 11 Apr 2020 12:02:51 +0200 Subject: [PATCH] Fix Damp loop --- data/battle_scripts_1.s | 5 ++++- src/battle_script_commands.c | 41 +++++++++++++++--------------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0ec6fb236..994679d83 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2169,6 +2169,7 @@ BattleScript_ExplosionLoop: moveendto MOVEEND_NEXT_TARGET jumpifnexttargetvalid BattleScript_ExplosionLoop tryfaintmon BS_ATTACKER, FALSE, NULL + moveendcase MOVEEND_CLEAR_BITS end BattleScript_ExplosionMissed: effectivenesssound @@ -6457,7 +6458,9 @@ BattleScript_DampStopsExplosion:: call BattleScript_AbilityPopUp printstring STRINGID_PKMNPREVENTSUSAGE pause 0x40 - goto BattleScript_MoveEnd + moveendto MOVEEND_NEXT_TARGET + moveendcase MOVEEND_CLEAR_BITS + end BattleScript_MoveHPDrain_PPLoss:: ppreduce diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a08781409..d637cd3be 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7850,33 +7850,26 @@ static void Cmd_faintifabilitynotdamp(void) if (gBattleControllerExecFlags) return; - for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) - { - if (gBattleMons[gBattlerTarget].ability == ABILITY_DAMP) - break; - } - - if (gBattlerTarget == gBattlersCount) - { - gActiveBattler = gBattlerAttacker; - gBattleMoveDamage = gBattleMons[gActiveBattler].hp; - BtlController_EmitHealthBarUpdate(0, INSTANT_HP_BAR_DROP); - MarkBattlerForControllerExec(gActiveBattler); - gBattlescriptCurrInstr++; - - for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) - { - if (gBattlerTarget == gBattlerAttacker) - continue; - if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget])) - break; - } - } - else + if ((gBattlerTarget = IsAbilityOnField(ABILITY_DAMP))) { gLastUsedAbility = ABILITY_DAMP; - RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability); + RecordAbilityBattle(--gBattlerTarget, ABILITY_DAMP); gBattlescriptCurrInstr = BattleScript_DampStopsExplosion; + return; + } + + gActiveBattler = gBattlerAttacker; + gBattleMoveDamage = gBattleMons[gActiveBattler].hp; + BtlController_EmitHealthBarUpdate(0, INSTANT_HP_BAR_DROP); + MarkBattlerForControllerExec(gActiveBattler); + gBattlescriptCurrInstr++; + + for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) + { + if (gBattlerTarget == gBattlerAttacker) + continue; + if (IsBattlerAlive(gBattlerTarget)) + break; } }