Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ion Deluge interaction with VoltAbsorb/LightRod #3764

Merged
merged 4 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 5 additions & 40 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
65 changes: 65 additions & 0 deletions test/battle/move_effect/ion_deluge.c
Original file line number Diff line number Diff line change
@@ -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.
}
}
Loading