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 Life Orb + Eject Pack / Red Card interaction #4038

Merged
merged 2 commits into from
Jan 20, 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
2 changes: 1 addition & 1 deletion include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions test/battle/hold_effect/eject_pack.c
Original file line number Diff line number Diff line change
@@ -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, player);
MESSAGE("Wobbuffet is switched out with the Eject Pack!");
MESSAGE("Go! Wynaut!");
NOT MESSAGE("Wynaut was hurt by its Life Orb!");
}
}
17 changes: 17 additions & 0 deletions test/battle/hold_effect/red_card.c
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Loading