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 entry hazards switch in issue #3207 #3316

Merged
merged 3 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ struct DisableStruct
u8 tarShot:1;
u8 octolock:1;
u8 cudChew:1;
u8 spikesDone:1;
u8 toxicSpikesDone:1;
u8 stickyWebDone:1;
u8 stealthRockDone:1;
};

struct ProtectStruct
Expand Down
6 changes: 2 additions & 4 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,13 @@
#define SIDE_STATUS_SAFEGUARD (1 << 5)
#define SIDE_STATUS_FUTUREATTACK (1 << 6)
#define SIDE_STATUS_MIST (1 << 8)
#define SIDE_STATUS_SPIKES_DAMAGED (1 << 9)
// (1 << 9) previously was SIDE_STATUS_SPIKES_DAMAGED
#define SIDE_STATUS_TAILWIND (1 << 10)
#define SIDE_STATUS_AURORA_VEIL (1 << 11)
#define SIDE_STATUS_LUCKY_CHANT (1 << 12)
#define SIDE_STATUS_TOXIC_SPIKES (1 << 13)
#define SIDE_STATUS_STEALTH_ROCK (1 << 14)
#define SIDE_STATUS_STEALTH_ROCK_DAMAGED (1 << 15)
#define SIDE_STATUS_TOXIC_SPIKES_DAMAGED (1 << 16)
#define SIDE_STATUS_STICKY_WEB_DAMAGED (1 << 17)
// Missing flags previously were SIDE_STATUS_TOXIC_SPIKES_DAMAGED, SIDE_STATUS_STEALTH_ROCK_DAMAGED, SIDE_STATUS_STICKY_WEB_DAMAGED
#define SIDE_STATUS_QUICK_GUARD (1 << 18)
#define SIDE_STATUS_WIDE_GUARD (1 << 19)
#define SIDE_STATUS_CRAFTY_SHIELD (1 << 20)
Expand Down
22 changes: 12 additions & 10 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -3991,7 +3991,6 @@ static void Cmd_tryfaintmon(void)

BattleScriptPop();
gBattlescriptCurrInstr = instr;
gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~(SIDE_STATUS_SPIKES_DAMAGED | SIDE_STATUS_TOXIC_SPIKES_DAMAGED | SIDE_STATUS_STEALTH_ROCK_DAMAGED | SIDE_STATUS_STICKY_WEB_DAMAGED);
}
else
{
Expand Down Expand Up @@ -7152,7 +7151,7 @@ static void Cmd_switchineffects(void)
gBattleStruct->storedLunarDance &= ~(gBitTable[gActiveBattler]);
}
}
else if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES_DAMAGED)
else if (!(gDisableStructs[gActiveBattler].spikesDone)
&& (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES)
&& GetBattlerAbility(gActiveBattler) != ABILITY_MAGIC_GUARD
&& IsBattlerAffectedByHazards(gActiveBattler, FALSE)
Expand All @@ -7163,25 +7162,25 @@ static void Cmd_switchineffects(void)
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;

gSideStatuses[GetBattlerSide(gActiveBattler)] |= SIDE_STATUS_SPIKES_DAMAGED;
gDisableStructs[gActiveBattler].spikesDone = TRUE;
SetDmgHazardsBattlescript(gActiveBattler, B_MSG_PKMNHURTBYSPIKES);
}
else if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_STEALTH_ROCK_DAMAGED)
else if (!(gDisableStructs[gActiveBattler].stealthRockDone)
&& (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_STEALTH_ROCK)
&& IsBattlerAffectedByHazards(gActiveBattler, FALSE)
&& GetBattlerAbility(gActiveBattler) != ABILITY_MAGIC_GUARD)
{
gSideStatuses[GetBattlerSide(gActiveBattler)] |= SIDE_STATUS_STEALTH_ROCK_DAMAGED;
gDisableStructs[gActiveBattler].stealthRockDone = TRUE;
gBattleMoveDamage = GetStealthHazardDamage(gBattleMoves[MOVE_STEALTH_ROCK].type, gActiveBattler);

if (gBattleMoveDamage != 0)
SetDmgHazardsBattlescript(gActiveBattler, B_MSG_STEALTHROCKDMG);
}
else if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_TOXIC_SPIKES_DAMAGED)
else if (!(gDisableStructs[gActiveBattler].toxicSpikesDone)
&& (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_TOXIC_SPIKES)
&& IsBattlerGrounded(gActiveBattler))
{
gSideStatuses[GetBattlerSide(gActiveBattler)] |= SIDE_STATUS_TOXIC_SPIKES_DAMAGED;
gDisableStructs[gActiveBattler].toxicSpikesDone = TRUE;
if (IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_POISON)) // Absorb the toxic spikes.
{
gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~SIDE_STATUS_TOXIC_SPIKES;
Expand Down Expand Up @@ -7212,12 +7211,12 @@ static void Cmd_switchineffects(void)
}
}
}
else if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_STICKY_WEB_DAMAGED)
else if (!(gDisableStructs[gActiveBattler].stickyWebDone)
&& (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_STICKY_WEB)
&& IsBattlerAffectedByHazards(gActiveBattler, FALSE)
&& IsBattlerGrounded(gActiveBattler))
{
gSideStatuses[GetBattlerSide(gActiveBattler)] |= SIDE_STATUS_STICKY_WEB_DAMAGED;
gDisableStructs[gActiveBattler].stickyWebDone = TRUE;
gBattleScripting.battler = gActiveBattler;
SET_STATCHANGER(STAT_SPEED, 1, TRUE);
BattleScriptPushCursor();
Expand Down Expand Up @@ -7256,7 +7255,10 @@ static void Cmd_switchineffects(void)
return;
}

gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~(SIDE_STATUS_SPIKES_DAMAGED | SIDE_STATUS_TOXIC_SPIKES_DAMAGED | SIDE_STATUS_STEALTH_ROCK_DAMAGED | SIDE_STATUS_STICKY_WEB_DAMAGED);
gDisableStructs[gActiveBattler].stickyWebDone = FALSE;
gDisableStructs[gActiveBattler].spikesDone = FALSE;
gDisableStructs[gActiveBattler].toxicSpikesDone = FALSE;
gDisableStructs[gActiveBattler].stealthRockDone = FALSE;

for (i = 0; i < gBattlersCount; i++)
{
Expand Down
1 change: 0 additions & 1 deletion test/battle/hold_effect/cure_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ SINGLE_BATTLE_TEST("Pokemon can be further poisoned with Toxic spikes after a st
PARAMETRIZE { item = ITEM_PECHA_BERRY; }
PARAMETRIZE { item = ITEM_LUM_BERRY; }

KNOWN_FAILING;
GIVEN {
ASSUME(gItems[ITEM_PECHA_BERRY].holdEffect == HOLD_EFFECT_CURE_PSN);
PLAYER(SPECIES_WOBBUFFET);
Expand Down
62 changes: 62 additions & 0 deletions test/battle/move_effect/toxic_spikes.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,65 @@ SINGLE_BATTLE_TEST("Toxic Spikes are removed by Poison-types affected by Magnet
NOT STATUS_ICON(opponent, poison: TRUE);
}
}

SINGLE_BATTLE_TEST("Toxic Spikes inflicts poison on switch in after Pecha Berry's activation") // #3207
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved
{
GIVEN {
ASSUME(gItems[ITEM_PECHA_BERRY].holdEffect == HOLD_EFFECT_CURE_PSN);
PLAYER(SPECIES_WOBBUFFET);
PLAYER(SPECIES_WOBBUFFET) {Item(ITEM_PECHA_BERRY); }
PLAYER(SPECIES_WYNAUT);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_TOXIC_SPIKES); }
TURN { SWITCH(player, 1); }
TURN { SWITCH(player, 2); }
} SCENE {
MESSAGE("Foe Wobbuffet used Toxic Spikes!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TOXIC_SPIKES, opponent);
MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
// 1st switch-in
MESSAGE("Go! Wobbuffet!");
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_PSN, player);
STATUS_ICON(player, poison: TRUE);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet's Pecha Berry cured poison!");
STATUS_ICON(player, poison: FALSE);
// 2nd switch-in
MESSAGE("Go! Wynaut!");
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_PSN, player);
STATUS_ICON(player, poison: TRUE);
}
}

SINGLE_BATTLE_TEST("Toxic Spikes inflicts poison on switch in after Primal Reversed mon fainted") // Oddly specific, but encountered during testing
{
GIVEN {
ASSUME(gBattleMoves[MOVE_MEMENTO].effect == EFFECT_MEMENTO); // Faints the user.
PLAYER(SPECIES_WOBBUFFET) {Speed(5); }
PLAYER(SPECIES_GROUDON) { Item(ITEM_RED_ORB); Speed(1); }
PLAYER(SPECIES_WYNAUT) {Speed(5); }
OPPONENT(SPECIES_WOBBUFFET) {Speed(15); }
} WHEN {
TURN { MOVE(opponent, MOVE_TOXIC_SPIKES); }
TURN { SWITCH(player, 1); }
TURN { MOVE(player, MOVE_MEMENTO); SEND_OUT(player, 2); }
} SCENE {
MESSAGE("Foe Wobbuffet used Toxic Spikes!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TOXIC_SPIKES, opponent);
MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
// Switch in
MESSAGE("Go! Groudon!");
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_PSN, player);
STATUS_ICON(player, poison: TRUE);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_PRIMAL_REVERSION, player);
MESSAGE("Groudon's Primal Reversion! It reverted to its primal form!");
// Memento
MESSAGE("Groudon used Memento!");
MESSAGE("Groudon fainted!");
// 2nd switch-in
MESSAGE("Go! Wynaut!");
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_PSN, player);
STATUS_ICON(player, poison: TRUE);
}
}
Loading