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 Eject Items causing wrong pokemon to take damage from entry hazards #4465

Merged
merged 3 commits into from
Apr 29, 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
15 changes: 15 additions & 0 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -6281,6 +6281,21 @@ BattleScript_DmgHazardsOnTargetFainted::
moveendall
goto BattleScript_HandleFaintedMon

BattleScript_DmgHazardsOnBattlerScripting::
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE
healthbarupdate BS_SCRIPTING
datahpupdate BS_SCRIPTING
call BattleScript_PrintHurtByDmgHazards
tryfaintmon BS_SCRIPTING
tryfaintmon_spikes BS_SCRIPTING, BattleScript_DmgHazardsOnBattlerScriptingFainted
return

BattleScript_DmgHazardsOnBattlerScriptingFainted::
setbyte sGIVEEXP_STATE, 0
getexp BS_SCRIPTING
moveendall
goto BattleScript_HandleFaintedMon

BattleScript_DmgHazardsOnFaintedBattler::
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE
healthbarupdate BS_FAINTED
Expand Down
1 change: 1 addition & 0 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ extern const u8 BattleScript_EncoredNoMore[];
extern const u8 BattleScript_DestinyBondTakesLife[];
extern const u8 BattleScript_DmgHazardsOnAttacker[];
extern const u8 BattleScript_DmgHazardsOnTarget[];
extern const u8 BattleScript_DmgHazardsOnBattlerScripting[];
extern const u8 BattleScript_DmgHazardsOnFaintedBattler[];
extern const u8 BattleScript_PerishSongTakesLife[];
extern const u8 BattleScript_PerishSongCountGoesDown[];
Expand Down
2 changes: 2 additions & 0 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -7040,6 +7040,8 @@ static void SetDmgHazardsBattlescript(u8 battler, u8 multistringId)
gBattlescriptCurrInstr = BattleScript_DmgHazardsOnTarget;
else if (gBattlescriptCurrInstr[1] == BS_ATTACKER)
gBattlescriptCurrInstr = BattleScript_DmgHazardsOnAttacker;
else if (gBattlescriptCurrInstr[1] == BS_SCRIPTING)
gBattlescriptCurrInstr = BattleScript_DmgHazardsOnBattlerScripting;
else
gBattlescriptCurrInstr = BattleScript_DmgHazardsOnFaintedBattler;
}
Expand Down
43 changes: 43 additions & 0 deletions test/battle/move_effect/stealth_rock.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,46 @@ SINGLE_BATTLE_TEST("Stealth Rock damage on switch in based on typing")
HP_BAR(opponent, damage: maxHP / divisor);
}
}

SINGLE_BATTLE_TEST("Stealth Rock damages the correct pokemon when Eject Button is triggered")
{
GIVEN {
PLAYER(SPECIES_METAPOD) { Item(ITEM_EJECT_BUTTON); }
PLAYER(SPECIES_METAPOD);
OPPONENT(SPECIES_JOLTEON);
} WHEN {
TURN { MOVE(opponent, MOVE_STEALTH_ROCK); MOVE(player, MOVE_HARDEN); }
TURN { MOVE(opponent, MOVE_QUICK_ATTACK); MOVE(player, MOVE_HARDEN); SEND_OUT(player, 1); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_STEALTH_ROCK, opponent);
ANIMATION(ANIM_TYPE_MOVE, MOVE_HARDEN, player);
ANIMATION(ANIM_TYPE_MOVE, MOVE_QUICK_ATTACK, opponent);
NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_HARDEN, player);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Go! Metapod!");
HP_BAR(player);
} THEN {
EXPECT_EQ(opponent->hp, opponent->maxHP);
}
}

DOUBLE_BATTLE_TEST("Stealth Rock damages the correct pokemon when Eject Button is triggered in double battle")
{
GIVEN {
PLAYER(SPECIES_METAPOD) { Item(ITEM_EJECT_BUTTON); }
PLAYER(SPECIES_METAPOD) { Item(ITEM_EJECT_BUTTON); }
PLAYER(SPECIES_METAPOD);
OPPONENT(SPECIES_JOLTEON);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponentLeft, MOVE_STEALTH_ROCK); MOVE(opponentRight, MOVE_TACKLE, target: playerLeft); SEND_OUT(playerLeft, 2); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_STEALTH_ROCK, opponentLeft);
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentRight);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerLeft);
MESSAGE("Go! Metapod!");
HP_BAR(playerLeft);
} THEN {
EXPECT_EQ(opponentLeft->hp, opponentLeft->maxHP);
}
}
Loading