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 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
4 changes: 4 additions & 0 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,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 @@ -224,15 +224,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
8 changes: 4 additions & 4 deletions src/battle_anim.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets)
{
case MOVE_TARGET_FOES_AND_ALLY:
if (IS_ALIVE_AND_PRESENT(BATTLE_PARTNER(BATTLE_OPPOSITE(battler)))) {
targets[idx++] = BATTLE_PARTNER(BATTLE_OPPOSITE(battler));
targets[idx++] = BATTLE_PARTNER(BATTLE_OPPOSITE(battler));
numTargets++;
}
// fallthrough
Expand All @@ -455,7 +455,7 @@ static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets)
if (IS_ALIVE_AND_PRESENT(battler)) {
targets[idx++] = battler;
numTargets++;
}
}
break;
default:
targets[0] = gBattleAnimArgs[battlerArgIndex]; // original
Expand Down Expand Up @@ -548,7 +548,7 @@ static void CreateSpriteOnTargets(const struct SpriteTemplate *template, u8 argV
ntargets = GetBattleAnimMoveTargets(battlerArgIndex, targets);
if (ntargets == 0)
return;

for (i = 0; i < ntargets; i++) {

if (overwriteAnimTgt)
Expand Down Expand Up @@ -675,7 +675,7 @@ static void Cmd_createvisualtaskontargets(void)
numArgs = GetBattleAnimMoveTargets(battlerArgIndex, targets);
if (numArgs == 0)
return;

for (i = 0; i < numArgs; i++)
{
gBattleAnimArgs[battlerArgIndex] = targets[i];
Expand Down
4 changes: 2 additions & 2 deletions src/battle_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ static const u8 sText_ShieldedFromCriticalHits[] = _("The {B_CURRENT_MOVE} shiel
static const u8 sText_SwitchedAtkAndSpAtk[] = _("{B_ATK_NAME_WITH_PREFIX} switched all its\nchanges to its Attack and\pSp. Atk with the target!");
static const u8 sText_SwitchedDefAndSpDef[] = _("{B_ATK_NAME_WITH_PREFIX} switched all its\nchanges to its Defense and\pSp. Def with the target!");
static const u8 sText_PkmnAcquiredAbility[] = _("{B_DEF_NAME_WITH_PREFIX} acquired\n{B_DEF_ABILITY}!");
static const u8 sText_PoisonSpikesScattered[] = _("Poison Spikes were scattered all\naround the opposing team's feet!");
static const u8 sText_PoisonSpikesScattered[] = _("Poison Spikes were scattered all\naround {B_DEF_TEAM2} team's feet!");
static const u8 sText_PkmnSwitchedStatChanges[] = _("{B_ATK_NAME_WITH_PREFIX} switched stat changes\nwith the target!");
static const u8 sText_PkmnSurroundedWithVeilOfWater[] = _("{B_ATK_NAME_WITH_PREFIX} surrounded itself\nwith a veil of water!");
static const u8 sText_PkmnLevitatedOnElectromagnetism[] = _("{B_ATK_NAME_WITH_PREFIX} levitated on\nelectromagnetism!");
Expand Down Expand Up @@ -627,7 +627,7 @@ static const u8 sText_MagicBounceActivates[] = _("The {B_DEF_NAME_WITH_PREFIX} b
static const u8 sText_ProteanTypeChange[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY} transformed\nit into the {B_BUFF1} type!");
static const u8 sText_SymbiosisItemPass[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} passed its {B_LAST_ITEM}\nto {B_ATK_NAME_WITH_PREFIX} through {B_LAST_ABILITY}!");
static const u8 sText_StealthRockDmg[] = _("Pointed stones dug into\n{B_SCR_ACTIVE_NAME_WITH_PREFIX}!");
static const u8 sText_ToxicSpikesAbsorbed[] = _("The poison spikes disappeared\nfrom around the opposing team's feet!");
static const u8 sText_ToxicSpikesAbsorbed[] = _("The poison spikes disappeared\nfrom around {B_DEF_TEAM2} team's feet!");
static const u8 sText_ToxicSpikesPoisoned[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} was poisoned!");
static const u8 sText_StickyWebSwitchIn[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} was\ncaught in a Sticky Web!");
static const u8 sText_HealingWishCameTrue[] = _("The healing wish came true\nfor {B_ATK_NAME_WITH_PREFIX}!");
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 @@ -3773,7 +3773,6 @@ static void Cmd_tryfaintmon(void)
{
BattleScriptPop();
gBattlescriptCurrInstr = cmd->instr;
gSideStatuses[GetBattlerSide(battler)] &= ~(SIDE_STATUS_SPIKES_DAMAGED | SIDE_STATUS_TOXIC_SPIKES_DAMAGED | SIDE_STATUS_STEALTH_ROCK_DAMAGED | SIDE_STATUS_STICKY_WEB_DAMAGED);
}
else
{
Expand Down Expand Up @@ -6880,7 +6879,7 @@ static void Cmd_switchineffects(void)
gBattleStruct->storedLunarDance &= ~(gBitTable[battler]);
}
}
else if (!(gSideStatuses[GetBattlerSide(battler)] & SIDE_STATUS_SPIKES_DAMAGED)
else if (!(gDisableStructs[battler].spikesDone)
&& (gSideStatuses[GetBattlerSide(battler)] & SIDE_STATUS_SPIKES)
&& GetBattlerAbility(battler) != ABILITY_MAGIC_GUARD
&& IsBattlerAffectedByHazards(battler, FALSE)
Expand All @@ -6891,25 +6890,25 @@ static void Cmd_switchineffects(void)
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;

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

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

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

for (i = 0; i < gBattlersCount; i++)
{
Expand Down
56 changes: 54 additions & 2 deletions test/battle/hold_effect/cure_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,16 @@ SINGLE_BATTLE_TEST("Berry hold effect cures status if a pokemon enters a battle"
}
}

SINGLE_BATTLE_TEST("Pokemon can be further poisoned with Toxic spikes after a status healing hold effect was previously used")
SINGLE_BATTLE_TEST("Opponent Pokemon can be further poisoned with Toxic spikes after a status healing hold effect was previously used")
{
u16 item;

PARAMETRIZE { item = ITEM_PECHA_BERRY; }
PARAMETRIZE { item = ITEM_LUM_BERRY; }

KNOWN_FAILING;
GIVEN {
ASSUME(gItems[ITEM_PECHA_BERRY].holdEffect == HOLD_EFFECT_CURE_PSN);
ASSUME(gItems[ITEM_LUM_BERRY].holdEffect == HOLD_EFFECT_CURE_STATUS);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WYNAUT) { Item(item); }
Expand All @@ -204,12 +204,64 @@ SINGLE_BATTLE_TEST("Pokemon can be further poisoned with Toxic spikes after a st
TURN { SWITCH(opponent, 1); }
TURN { SWITCH(opponent, 0); }
} SCENE {
MESSAGE("Wobbuffet used Toxic Spikes!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TOXIC_SPIKES, player);
MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
// 1st switch-in
MESSAGE("2 sent out Wynaut!");
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_PSN, opponent);
STATUS_ICON(opponent, poison: TRUE);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
if (item == ITEM_PECHA_BERRY) {
MESSAGE("Foe Wynaut's Pecha Berry cured poison!");
} else {
MESSAGE("Foe Wynaut's Lum Berry cured its poison problem!");
}
STATUS_ICON(opponent, poison: FALSE);
// 2nd switch-in
MESSAGE("2 sent out Wobbuffet!");
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_PSN, opponent);
STATUS_ICON(opponent, poison: TRUE);
}
}

// Basically same as above, but with the sides reversed.
SINGLE_BATTLE_TEST("Player Pokemon can be further poisoned with Toxic spikes after a status healing hold effect was previously used")
{
u16 item;

PARAMETRIZE { item = ITEM_PECHA_BERRY; }
PARAMETRIZE { item = ITEM_LUM_BERRY; }

GIVEN {
ASSUME(gItems[ITEM_PECHA_BERRY].holdEffect == HOLD_EFFECT_CURE_PSN);
ASSUME(gItems[ITEM_LUM_BERRY].holdEffect == HOLD_EFFECT_CURE_STATUS);
PLAYER(SPECIES_WOBBUFFET);
PLAYER(SPECIES_WOBBUFFET) {Item(item); }
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 your 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);
if (item == ITEM_PECHA_BERRY) {
MESSAGE("Wobbuffet's Pecha Berry cured poison!");
} else {
MESSAGE("Wobbuffet's Lum Berry cured its poison problem!");
}
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);
}
}
32 changes: 32 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,35 @@ 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 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 your 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