diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 027c344b2d..a17c54c7e3 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2401,7 +2401,6 @@ BattleScript_EffectHealingWish:: storehealingwish BS_ATTACKER .if B_HEALING_WISH_SWITCH <= GEN_4 openpartyscreen BS_ATTACKER, BattleScript_EffectHealingWishEnd - switchoutabilities BS_ATTACKER waitstate switchhandleorder BS_ATTACKER, 2 returnatktoball @@ -5764,7 +5763,6 @@ BattleScript_PrintFullBox:: BattleScript_ActionSwitch:: hpthresholds2 BS_ATTACKER - saveattacker printstring STRINGID_RETURNMON jumpifbattletype BATTLE_TYPE_DOUBLE, BattleScript_PursuitSwitchDmgSetMultihit setmultihit 1 @@ -5782,7 +5780,6 @@ BattleScript_DoSwitchOut:: switchoutabilities BS_ATTACKER updatedynamax waitstate - restoreattacker returnatktoball waitstate drawpartystatussummary BS_ATTACKER @@ -9602,7 +9599,9 @@ BattleScript_EjectButtonActivates:: removeitem BS_SCRIPTING makeinvisible BS_SCRIPTING openpartyscreen BS_SCRIPTING, BattleScript_EjectButtonEnd + copybyte sSAVED_BATTLER, sBATTLER switchoutabilities BS_SCRIPTING + copybyte sBATTLER, sSAVED_BATTLER waitstate switchhandleorder BS_SCRIPTING 0x2 returntoball BS_SCRIPTING, FALSE @@ -9699,6 +9698,7 @@ BattleScript_PastelVeilEnd: end3 BattleScript_NeutralizingGasExits:: + saveattacker savetarget pause B_WAIT_TIME_SHORT printstring STRINGID_NEUTRALIZINGGASOVER @@ -9708,6 +9708,7 @@ BattleScript_NeutralizingGasExitsLoop: switchinabilities BS_TARGET addbyte gBattlerTarget, 1 jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_NeutralizingGasExitsLoop + restoreattacker restoretarget return diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c373778b68..b1dbcc6106 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3976,6 +3976,15 @@ static void Cmd_tryfaintmon(void) } else { + if (gBattleMons[battler].ability == ABILITY_NEUTRALIZING_GAS + && !(gAbsentBattlerFlags & (1u << battler)) + && !IsBattlerAlive(battler)) + { + gBattleMons[battler].ability = ABILITY_NONE; + BattleScriptPush(gBattlescriptCurrInstr); + gBattlescriptCurrInstr = BattleScript_NeutralizingGasExits; + return; + } if (cmd->battler == BS_ATTACKER) { destinyBondBattler = gBattlerTarget; @@ -14763,7 +14772,7 @@ static void Cmd_switchoutabilities(void) MarkBattlerForControllerExec(battler); break; case ABILITY_REGENERATOR: - gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 3; + gBattleMoveDamage = GetNonDynamaxMaxHP(battler) / 3; gBattleMoveDamage += gBattleMons[battler].hp; if (gBattleMoveDamage > gBattleMons[battler].maxHP) gBattleMoveDamage = gBattleMons[battler].maxHP; diff --git a/test/battle/ability/intimidate.c b/test/battle/ability/intimidate.c index d2d7bc4af7..a7776dabff 100644 --- a/test/battle/ability/intimidate.c +++ b/test/battle/ability/intimidate.c @@ -246,7 +246,7 @@ DOUBLE_BATTLE_TEST("Intimidate is not going to trigger if a mon switches out thr } } -SINGLE_BATTLE_TEST("Intimidate activates when it's no longer effected by Neutralizing Gas") +SINGLE_BATTLE_TEST("Intimidate activates when it's no longer effected by Neutralizing Gas - switching out") { GIVEN { PLAYER(SPECIES_WEEZING) { Ability(ABILITY_NEUTRALIZING_GAS); } @@ -263,3 +263,91 @@ SINGLE_BATTLE_TEST("Intimidate activates when it's no longer effected by Neutral SEND_IN_MESSAGE("Wobbuffet"); } } + +SINGLE_BATTLE_TEST("Intimidate activates when it's no longer affected by Neutralizing Gas - switching moves") +{ + u32 move; + PARAMETRIZE { move = MOVE_U_TURN; } + PARAMETRIZE { move = MOVE_HEALING_WISH; } + PARAMETRIZE { move = MOVE_BATON_PASS; } + GIVEN { + ASSUME(gMovesInfo[MOVE_U_TURN].effect == EFFECT_HIT_ESCAPE); + ASSUME(gMovesInfo[MOVE_HEALING_WISH].effect == EFFECT_HEALING_WISH); + ASSUME(gMovesInfo[MOVE_BATON_PASS].effect == EFFECT_BATON_PASS); + PLAYER(SPECIES_WEEZING) { Ability(ABILITY_NEUTRALIZING_GAS); } + PLAYER(SPECIES_WOBBUFFET) { HP(1); } + OPPONENT(SPECIES_ARBOK) { Ability(ABILITY_INTIMIDATE); } + } WHEN { + TURN { MOVE(player, move); SEND_OUT(player, 1); } + } SCENE { + ABILITY_POPUP(player, ABILITY_NEUTRALIZING_GAS); + MESSAGE("Neutralizing Gas filled the area!"); + ANIMATION(ANIM_TYPE_MOVE, move, player); + MESSAGE("The effects of Neutralizing Gas wore off!"); + ABILITY_POPUP(opponent, ABILITY_INTIMIDATE); + SEND_IN_MESSAGE("Wobbuffet"); + } THEN { + if (move == MOVE_HEALING_WISH) + EXPECT_EQ(player->hp, player->maxHP); + } +} + +SINGLE_BATTLE_TEST("Intimidate activates when it's no longer affected by Neutralizing Gas - opponent caused switches") +{ + u32 move, item; + PARAMETRIZE { move = MOVE_TACKLE; item = ITEM_EJECT_BUTTON; } + PARAMETRIZE { move = MOVE_GROWL; item = ITEM_EJECT_PACK; } + PARAMETRIZE { move = MOVE_ROAR; item = ITEM_NONE; } + PARAMETRIZE { move = MOVE_DRAGON_TAIL; item = ITEM_NONE; } + GIVEN { + ASSUME(gItemsInfo[ITEM_EJECT_BUTTON].holdEffect == HOLD_EFFECT_EJECT_BUTTON); + ASSUME(gItemsInfo[ITEM_EJECT_PACK].holdEffect == HOLD_EFFECT_EJECT_PACK); + ASSUME(gMovesInfo[MOVE_GROWL].effect == EFFECT_ATTACK_DOWN); + ASSUME(gMovesInfo[MOVE_ROAR].effect == EFFECT_ROAR); + ASSUME(gMovesInfo[MOVE_DRAGON_TAIL].effect == EFFECT_HIT_SWITCH_TARGET); + PLAYER(SPECIES_WEEZING) { Ability(ABILITY_NEUTRALIZING_GAS); Item(item); } + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_ARBOK) { Ability(ABILITY_INTIMIDATE); } + } WHEN { + if (item != ITEM_NONE) { + TURN { MOVE(opponent, move); SEND_OUT(player, 1); } + } else { + TURN { MOVE(opponent, move); } + } + } SCENE { + ABILITY_POPUP(player, ABILITY_NEUTRALIZING_GAS); + MESSAGE("Neutralizing Gas filled the area!"); + ANIMATION(ANIM_TYPE_MOVE, move, opponent); + if (item != ITEM_NONE) + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); + MESSAGE("The effects of Neutralizing Gas wore off!"); + ABILITY_POPUP(opponent, ABILITY_INTIMIDATE); + if (item != ITEM_NONE) { + SEND_IN_MESSAGE("Wobbuffet"); + } else { + MESSAGE("Wobbuffet was dragged out!"); + } + } +} + +SINGLE_BATTLE_TEST("Intimidate activates when it's no longer affected by Neutralizing Gas - fainted") +{ + GIVEN { + ASSUME(gMovesInfo[MOVE_FELL_STINGER].effect == EFFECT_FELL_STINGER); + PLAYER(SPECIES_WEEZING) { Ability(ABILITY_NEUTRALIZING_GAS); HP(1); } + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_ARBOK) { Ability(ABILITY_INTIMIDATE); } + } WHEN { + TURN { MOVE(opponent, MOVE_FELL_STINGER); SEND_OUT(player, 1); } + } SCENE { + ABILITY_POPUP(player, ABILITY_NEUTRALIZING_GAS); + MESSAGE("Neutralizing Gas filled the area!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_FELL_STINGER, opponent); + MESSAGE("The effects of Neutralizing Gas wore off!"); + ABILITY_POPUP(opponent, ABILITY_INTIMIDATE); + MESSAGE("Weezing fainted!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); + SEND_IN_MESSAGE("Wobbuffet"); + } +} +