From c0946152e91e57cb931f800a5443ecab2859cb20 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 20 Jan 2024 18:30:08 +0100 Subject: [PATCH 1/2] Fixes Life Orb + Eject Pack / Red Card interaction --- include/battle.h | 2 +- src/battle_script_commands.c | 6 ++++-- src/battle_util.c | 2 +- test/battle/hold_effect/eject_pack.c | 26 ++++++++++++++++++++++++++ test/battle/hold_effect/red_card.c | 17 +++++++++++++++++ 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 test/battle/hold_effect/eject_pack.c diff --git a/include/battle.h b/include/battle.h index ea710ed79779..21b3727ec347 100644 --- a/include/battle.h +++ b/include/battle.h @@ -208,7 +208,7 @@ struct SpecialStatus // End of byte u8 emergencyExited:1; u8 afterYou:1; - u8 magicianStolen:1; // So that Life Orb doesn't activate after Magician steals it. + u8 preventLifeOrbDamage:1; // So that Life Orb doesn't activate various effects. }; struct SideTimer diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e9fd422e20a6..cc7dd6ac9289 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5711,7 +5711,7 @@ static void Cmd_moveend(void) gEffectBattler = gBattlerTarget; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MagicianActivates; - gSpecialStatuses[gBattlerAttacker].magicianStolen = TRUE; + gSpecialStatuses[gBattlerAttacker].preventLifeOrbDamage = TRUE; effect = TRUE; } gBattleScripting.moveendState++; @@ -5898,6 +5898,7 @@ static void Cmd_moveend(void) gBattlescriptCurrInstr = BattleScript_MoveEnd; // Prevent user switch-in selection BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_RedCardActivates; + gSpecialStatuses[gBattlerAttacker].preventLifeOrbDamage = TRUE; effect = TRUE; break; // Only fastest red card activates } @@ -5924,6 +5925,7 @@ static void Cmd_moveend(void) gLastUsedItem = gBattleMons[battler].item; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_EjectPackActivates; + gSpecialStatuses[gBattlerAttacker].preventLifeOrbDamage = TRUE; effect = TRUE; break; // Only fastest eject pack activates } @@ -6076,7 +6078,7 @@ static void Cmd_moveend(void) gStatuses3[gBattlerAttacker] &= ~STATUS3_ME_FIRST; gSpecialStatuses[gBattlerAttacker].gemBoost = FALSE; gSpecialStatuses[gBattlerAttacker].damagedMons = 0; - gSpecialStatuses[gBattlerAttacker].magicianStolen = 0; + gSpecialStatuses[gBattlerAttacker].preventLifeOrbDamage = 0; gSpecialStatuses[gBattlerTarget].berryReduced = FALSE; gBattleScripting.moveEffect = 0; // clear attacker z move data diff --git a/src/battle_util.c b/src/battle_util.c index 81a5c82d8ca7..5f633fc1e4f6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7775,7 +7775,7 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn) if (IsBattlerAlive(gBattlerAttacker) && !(TestSheerForceFlag(gBattlerAttacker, gCurrentMove)) && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD - && !gSpecialStatuses[gBattlerAttacker].magicianStolen + && !gSpecialStatuses[gBattlerAttacker].preventLifeOrbDamage && gSpecialStatuses[gBattlerAttacker].damagedMons) { gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 10; diff --git a/test/battle/hold_effect/eject_pack.c b/test/battle/hold_effect/eject_pack.c new file mode 100644 index 000000000000..6e5d44cf4455 --- /dev/null +++ b/test/battle/hold_effect/eject_pack.c @@ -0,0 +1,26 @@ +#include "global.h" +#include "test/battle.h" + +ASSUMPTIONS +{ + ASSUME(gItems[ITEM_EJECT_PACK].holdEffect == HOLD_EFFECT_EJECT_PACK); +} + +SINGLE_BATTLE_TEST("Eject Pack does not cause the new pokemon to lose hp due to it's held Life Orb") +{ + GIVEN { + ASSUME(gItems[ITEM_LIFE_ORB].holdEffect == HOLD_EFFECT_LIFE_ORB); + PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_EJECT_PACK); } + PLAYER(SPECIES_WYNAUT) { Item(ITEM_LIFE_ORB); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_OVERHEAT); SEND_OUT(player, 1); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_OVERHEAT, player); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent); + MESSAGE("Wobbuffet is switched out with the Eject Pack!"); + MESSAGE("Go! Wynaut!"); + NOT MESSAGE("Wynaut was hurt by its Life Orb!"); + } +} diff --git a/test/battle/hold_effect/red_card.c b/test/battle/hold_effect/red_card.c index 0f80dd176c1a..79db49fabd02 100644 --- a/test/battle/hold_effect/red_card.c +++ b/test/battle/hold_effect/red_card.c @@ -430,4 +430,21 @@ SINGLE_BATTLE_TEST("Red Card is consumed after dragged out replacement has its S } } +SINGLE_BATTLE_TEST("Red Card does not cause the dragged out mon to lose hp due to it's held Life Orb") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WYNAUT) { Item(ITEM_LIFE_ORB); } + OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_RED_CARD); } + } WHEN { + TURN { MOVE(player, MOVE_TACKLE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent); + MESSAGE("Foe Wobbuffet held up its Red Card against Wobbuffet!"); + MESSAGE("Wynaut was dragged out!"); + NOT MESSAGE("Wynaut was hurt by its Life Orb!"); + } +} + // SINGLE_BATTLE_TEST("Red Card activates but fails if the attacker has Dynamaxed") From 9ed7b4d4c40f789ca9b706cb48d731a09e14424d Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 20 Jan 2024 19:34:00 +0100 Subject: [PATCH 2/2] fix test --- test/battle/hold_effect/eject_pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/battle/hold_effect/eject_pack.c b/test/battle/hold_effect/eject_pack.c index 6e5d44cf4455..4f58a1477e9c 100644 --- a/test/battle/hold_effect/eject_pack.c +++ b/test/battle/hold_effect/eject_pack.c @@ -18,7 +18,7 @@ SINGLE_BATTLE_TEST("Eject Pack does not cause the new pokemon to lose hp due to } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_OVERHEAT, player); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); - ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); MESSAGE("Wobbuffet is switched out with the Eject Pack!"); MESSAGE("Go! Wynaut!"); NOT MESSAGE("Wynaut was hurt by its Life Orb!");