Skip to content

Commit

Permalink
Fixes Purifying Salt not halving dmg for dynamic move types (#5145)
Browse files Browse the repository at this point in the history
* Fixes Purifying Salt not halving dmg for dynamic move types

* forgot to add
  • Loading branch information
AlexOn1ine authored Aug 12, 2024
1 parent ba1512f commit a8cd459
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
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

0 comments on commit a8cd459

Please sign in to comment.