diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e1b396aa702d..a0bb282c8ccb 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8307,42 +8307,7 @@ static bool32 IsRototillerAffected(u32 battler) return TRUE; } - -static bool32 IsAbilityRodAffected(void) -{ - u32 moveType; - - if (gBattleStruct->dynamicMoveType == 0) - moveType = gBattleMoves[gCurrentMove].type; - else if (!(gBattleStruct->dynamicMoveType & F_DYNAMIC_TYPE_IGNORE_PHYSICALITY)) - moveType = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK; - else - moveType = gBattleMoves[gCurrentMove].type; - - if (moveType == TYPE_ELECTRIC && GetBattlerAbility(gBattlerTarget) == ABILITY_LIGHTNING_ROD) - return TRUE; - else - return FALSE; -} - -static bool32 IsAbilityMotorAffected(void) -{ - u32 moveType; - - if (gBattleStruct->dynamicMoveType == 0) - moveType = gBattleMoves[gCurrentMove].type; - else if (!(gBattleStruct->dynamicMoveType & F_DYNAMIC_TYPE_IGNORE_PHYSICALITY)) - moveType = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK; - else - moveType = gBattleMoves[gCurrentMove].type; - - if (moveType == TYPE_ELECTRIC && GetBattlerAbility(gBattlerTarget) == ABILITY_MOTOR_DRIVE) - return TRUE; - else - return FALSE; -} - -static bool32 IsAbilityAbsorbAffected(void) +static bool32 IsElectricAbilityAffected(u32 ability) { u32 moveType; @@ -8353,7 +8318,7 @@ static bool32 IsAbilityAbsorbAffected(void) else moveType = gBattleMoves[gCurrentMove].type; - if (moveType == TYPE_ELECTRIC && GetBattlerAbility(gBattlerTarget) == ABILITY_VOLT_ABSORB) + if (moveType == TYPE_ELECTRIC && GetBattlerAbility(gBattlerTarget) == ability) return TRUE; else return FALSE; @@ -16098,7 +16063,7 @@ void BS_JumpIfEmergencyExited(void) void BS_JumpIfRod(void) { NATIVE_ARGS(const u8 *jumpInstr); - if (IsAbilityRodAffected()) + if (IsElectricAbilityAffected(ABILITY_LIGHTNING_ROD)) gBattlescriptCurrInstr = cmd->jumpInstr; else gBattlescriptCurrInstr = cmd->nextInstr; @@ -16107,7 +16072,7 @@ void BS_JumpIfRod(void) void BS_JumpIfAbsorb(void) { NATIVE_ARGS(const u8 *jumpInstr); - if (IsAbilityAbsorbAffected()) + if (IsElectricAbilityAffected(ABILITY_VOLT_ABSORB)) gBattlescriptCurrInstr = cmd->jumpInstr; else gBattlescriptCurrInstr = cmd->nextInstr; @@ -16116,7 +16081,7 @@ void BS_JumpIfAbsorb(void) void BS_JumpIfMotor(void) { NATIVE_ARGS(const u8 *jumpInstr); - if (IsAbilityMotorAffected()) + if (IsElectricAbilityAffected(ABILITY_MOTOR_DRIVE)) gBattlescriptCurrInstr = cmd->jumpInstr; else gBattlescriptCurrInstr = cmd->nextInstr; diff --git a/src/battle_util.c b/src/battle_util.c index 8ab84fb762cf..a92de0e30120 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5071,7 +5071,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 switch (gLastUsedAbility) { case ABILITY_VOLT_ABSORB: - if (moveType == TYPE_ELECTRIC) + if (moveType == TYPE_ELECTRIC && gBattleMoves[move].target != MOVE_TARGET_ALL_BATTLERS) effect = 1; break; case ABILITY_WATER_ABSORB: @@ -5080,11 +5080,11 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 effect = 1; break; case ABILITY_MOTOR_DRIVE: - if (moveType == TYPE_ELECTRIC) + if (moveType == TYPE_ELECTRIC && gBattleMoves[move].target != MOVE_TARGET_ALL_BATTLERS) effect = 2, statId = STAT_SPEED; break; case ABILITY_LIGHTNING_ROD: - if (moveType == TYPE_ELECTRIC) + if (moveType == TYPE_ELECTRIC && gBattleMoves[move].target != MOVE_TARGET_ALL_BATTLERS) effect = 2, statId = STAT_SPATK; break; case ABILITY_STORM_DRAIN: diff --git a/test/battle/move_effect/ion_deluge.c b/test/battle/move_effect/ion_deluge.c new file mode 100644 index 000000000000..20181fb75c3d --- /dev/null +++ b/test/battle/move_effect/ion_deluge.c @@ -0,0 +1,65 @@ +#include "global.h" +#include "test/battle.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_ION_DELUGE].effect == EFFECT_ION_DELUGE); +} + +// For some reason SINGLE_BATTLE_TEST didn't catch these two issues. +WILD_BATTLE_TEST("Ion Deluge works the same way as always when used by a mon with Volt Absorb") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_LANTURN) { Ability(ABILITY_VOLT_ABSORB); HP(1); } + } WHEN { + TURN { MOVE(opponent, MOVE_ION_DELUGE); } + } SCENE { + MESSAGE("Wild Lanturn used Ion Deluge!"); + NONE_OF { + ABILITY_POPUP(opponent, ABILITY_VOLT_ABSORB); + HP_BAR(opponent); + MESSAGE("Wild Lanturn restored HP using its Volt Absorb!"); + } + MESSAGE("A deluge of ions showers the battlefield!"); + } +} + +WILD_BATTLE_TEST("Ion Deluge works the same way as always when used by a mon with Lightning Rod / Motor Drive") +{ + u16 ability; + PARAMETRIZE { ability = ABILITY_LIGHTNING_ROD; } + PARAMETRIZE { ability = ABILITY_MOTOR_DRIVE; } + + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_ZEBSTRIKA) { Ability(ability); } + } WHEN { + TURN { MOVE(opponent, MOVE_ION_DELUGE); } + } SCENE { + MESSAGE("Wild Zebstrika used Ion Deluge!"); + NONE_OF { + ABILITY_POPUP(opponent, ability); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); + MESSAGE("Wild Zebstrika's Sp.Atk rose!"); + MESSAGE("Wild Zebstrika's Speed rose!"); + } + MESSAGE("A deluge of ions showers the battlefield!"); + } +} + +SINGLE_BATTLE_TEST("Ion Deluge makes Normal type moves Electric type") +{ + GIVEN { + ASSUME(gBattleMoves[MOVE_TACKLE].type == TYPE_NORMAL); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_GOLBAT); + } WHEN { + TURN { MOVE(opponent, MOVE_ION_DELUGE); MOVE(player, MOVE_TACKLE); } + } SCENE { + MESSAGE("Foe Golbat used Ion Deluge!"); + MESSAGE("A deluge of ions showers the battlefield!"); + MESSAGE("Wobbuffet used Tackle!"); + MESSAGE("It's super effective!"); // Because Tackle is now electric type. + } +}