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

Fixes Purifying Salt not halving dmg for dynamic move types #5145

Merged
merged 2 commits into from
Aug 12, 2024
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
11 changes: 7 additions & 4 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -8257,6 +8257,8 @@ u32 GetMoveTarget(u16 move, u8 setTarget)
{
u8 targetBattler = 0;
u32 moveTarget, side;
u32 moveType;
GET_MOVE_TYPE(move, moveType);

if (setTarget != NO_TARGET_OVERRIDE)
moveTarget = setTarget - 1;
Expand All @@ -8274,15 +8276,15 @@ u32 GetMoveTarget(u16 move, u8 setTarget)
else
{
targetBattler = SetRandomTarget(gBattlerAttacker);
if (gMovesInfo[move].type == TYPE_ELECTRIC
if (moveType == TYPE_ELECTRIC
&& IsAbilityOnOpposingSide(gBattlerAttacker, ABILITY_LIGHTNING_ROD)
&& GetBattlerAbility(targetBattler) != ABILITY_LIGHTNING_ROD)
{
targetBattler ^= BIT_FLANK;
RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability);
gSpecialStatuses[targetBattler].lightningRodRedirected = TRUE;
}
else if (gMovesInfo[move].type == TYPE_WATER
else if (moveType == TYPE_WATER
&& IsAbilityOnOpposingSide(gBattlerAttacker, ABILITY_STORM_DRAIN)
&& GetBattlerAbility(targetBattler) != ABILITY_STORM_DRAIN)
{
Expand Down Expand Up @@ -9771,7 +9773,7 @@ static inline u32 CalcDefenseStat(u32 move, u32 battlerAtk, u32 battlerDef, u32
modifier = uq4_12_multiply_half_down(modifier, UQ_4_12(1.5));
break;
case ABILITY_PURIFYING_SALT:
if (gMovesInfo[move].type == TYPE_GHOST)
if (moveType == TYPE_GHOST)
modifier = uq4_12_multiply_half_down(modifier, UQ_4_12(2.0));
break;
}
Expand Down Expand Up @@ -10467,7 +10469,8 @@ uq4_12_t CalcTypeEffectivenessMultiplier(u32 move, u32 moveType, u32 battlerAtk,
uq4_12_t CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u16 abilityDef)
{
uq4_12_t modifier = UQ_4_12(1.0);
u8 moveType = gMovesInfo[move].type;
u32 moveType;
GET_MOVE_TYPE(move, moveType);

if (move != MOVE_STRUGGLE && moveType != TYPE_MYSTERY)
{
Expand Down
18 changes: 18 additions & 0 deletions test/battle/ability/purifying_salt.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ SINGLE_BATTLE_TEST("Purifying Salt halves damage from Ghost-type moves", s16 dam
}
}

SINGLE_BATTLE_TEST("Purifying Salt halves damage from dynamic Ghost-type moves", s16 damage)
{
u16 ability;
PARAMETRIZE { ability = ABILITY_STURDY; }
PARAMETRIZE { ability = ABILITY_PURIFYING_SALT; }
GIVEN {
ASSUME(gMovesInfo[MOVE_TERA_BLAST].effect == EFFECT_TERA_BLAST);
PLAYER(SPECIES_WOBBUFFET) { TeraType(TYPE_GHOST); }
OPPONENT(SPECIES_GARGANACL) { Ability(ability); }
} WHEN {
TURN { MOVE(player, MOVE_TERA_BLAST, gimmick: GIMMICK_TERA); }
} SCENE {
HP_BAR(opponent, captureDamage: &results[i].damage);
} FINALLY {
EXPECT_MUL_EQ(results[0].damage, UQ_4_12(0.5), results[1].damage);
}
}

SINGLE_BATTLE_TEST("Purifying Salt makes Rest fail")
{
GIVEN {
Expand Down
Loading