Fixes Defog used by the wrong side when there is a Substitue and Screen (#5381)

This commit is contained in:
Alex 2024-09-14 08:16:20 +02:00 committed by GitHub
parent 9bdc9e5dab
commit fbea1e7e7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -8637,6 +8637,10 @@ static void RemoveAllTerrains(void)
BattleScriptPushCursor(); \
gBattlescriptCurrInstr = battlescript; \
} \
else \
{ \
gBattlerAttacker = saveBattler; \
} \
return TRUE; \
} \
}
@ -8651,9 +8655,9 @@ static bool32 TryDefogClear(u32 battlerAtk, bool32 clear)
struct SideTimer *sideTimer = &gSideTimers[i];
u32 *sideStatuses = &gSideStatuses[i];
gBattlerAttacker = i; // For correct battle string. Ally's / Foe's
if (GetBattlerSide(battlerAtk) != i)
{
gBattlerAttacker = i; // For correct battle string. Ally's / Foe's
DEFOG_CLEAR(SIDE_STATUS_REFLECT, reflectTimer, BattleScript_SideStatusWoreOffReturn, MOVE_REFLECT);
DEFOG_CLEAR(SIDE_STATUS_LIGHTSCREEN, lightscreenTimer, BattleScript_SideStatusWoreOffReturn, MOVE_LIGHT_SCREEN);
DEFOG_CLEAR(SIDE_STATUS_MIST, mistTimer, BattleScript_SideStatusWoreOffReturn, MOVE_MIST);
@ -8662,6 +8666,7 @@ static bool32 TryDefogClear(u32 battlerAtk, bool32 clear)
}
if (B_DEFOG_EFFECT_CLEARING >= GEN_6)
{
gBattlerAttacker = i; // For correct battle string. Ally's / Foe's
DEFOG_CLEAR(SIDE_STATUS_SPIKES, spikesAmount, BattleScript_SpikesDefog, 0);
DEFOG_CLEAR(SIDE_STATUS_STEALTH_ROCK, stealthRockAmount, BattleScript_StealthRockDefog, 0);
DEFOG_CLEAR(SIDE_STATUS_TOXIC_SPIKES, toxicSpikesAmount, BattleScript_ToxicSpikesDefog, 0);

View file

@ -383,3 +383,21 @@ DOUBLE_BATTLE_TEST("Defog lowers evasiveness by 1 and removes everything it can"
}
}
}
SINGLE_BATTLE_TEST("Defog is used on the correct side if opposing mon is behind a substitute with Screen up")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_LIGHT_SCREEN); }
TURN { MOVE(opponent, MOVE_SUBSTITUTE); MOVE(player, MOVE_DEFOG); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_LIGHT_SCREEN, opponent);
ANIMATION(ANIM_TYPE_MOVE, MOVE_SUBSTITUTE, opponent);
MESSAGE("Wobbuffet used Defog!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_DEFOG, player);
MESSAGE("Foe Wobbuffet's evasiveness fell!");
MESSAGE("Foe's Light Screen wore off!");
}
}