Fix Magician Life orb recoil when stealing (#3753)

* Fix Magician Life orb recoil

* get rid of unneeded assume
This commit is contained in:
DizzyEggg 2023-12-17 19:50:43 +01:00 committed by GitHub
parent 5d2efbe1a2
commit 76a7513dcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 0 deletions

View file

@ -197,6 +197,7 @@ struct SpecialStatus
// End of byte // End of byte
u8 emergencyExited:1; u8 emergencyExited:1;
u8 afterYou:1; u8 afterYou:1;
u8 magicianStolen:1; // So that Life Orb doesn't activate after Magician steals it.
}; };
struct SideTimer struct SideTimer

View file

@ -5719,6 +5719,7 @@ static void Cmd_moveend(void)
gEffectBattler = gBattlerTarget; gEffectBattler = gBattlerTarget;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MagicianActivates; gBattlescriptCurrInstr = BattleScript_MagicianActivates;
gSpecialStatuses[gBattlerAttacker].magicianStolen = TRUE;
effect = TRUE; effect = TRUE;
} }
gBattleScripting.moveendState++; gBattleScripting.moveendState++;
@ -6081,6 +6082,7 @@ static void Cmd_moveend(void)
gStatuses3[gBattlerAttacker] &= ~STATUS3_ME_FIRST; gStatuses3[gBattlerAttacker] &= ~STATUS3_ME_FIRST;
gSpecialStatuses[gBattlerAttacker].gemBoost = FALSE; gSpecialStatuses[gBattlerAttacker].gemBoost = FALSE;
gSpecialStatuses[gBattlerAttacker].damagedMons = 0; gSpecialStatuses[gBattlerAttacker].damagedMons = 0;
gSpecialStatuses[gBattlerAttacker].magicianStolen = 0;
gSpecialStatuses[gBattlerTarget].berryReduced = FALSE; gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
gBattleScripting.moveEffect = 0; gBattleScripting.moveEffect = 0;
// clear attacker z move data // clear attacker z move data

View file

@ -7697,6 +7697,7 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
if (IsBattlerAlive(gBattlerAttacker) if (IsBattlerAlive(gBattlerAttacker)
&& !(TestSheerForceFlag(gBattlerAttacker, gCurrentMove)) && !(TestSheerForceFlag(gBattlerAttacker, gCurrentMove))
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD
&& !gSpecialStatuses[gBattlerAttacker].magicianStolen
&& gSpecialStatuses[gBattlerAttacker].damagedMons) && gSpecialStatuses[gBattlerAttacker].damagedMons)
{ {
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 10; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 10;

View file

@ -0,0 +1,29 @@
#include "global.h"
#include "test/battle.h"
SINGLE_BATTLE_TEST("Magician does not get self-damage recoil after stealing Life Orb")
{
GIVEN {
ASSUME(gItems[ITEM_LIFE_ORB].holdEffect == HOLD_EFFECT_LIFE_ORB);
ASSUME(gBattleMoves[MOVE_TACKLE].power != 0);
PLAYER(SPECIES_DELPHOX) { Ability(ABILITY_MAGICIAN); Item(ITEM_NONE); }
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_LIFE_ORB); }
} WHEN {
TURN { MOVE(player, MOVE_TACKLE); }
TURN { MOVE(player, MOVE_TACKLE); }
} SCENE {
// 1st turn
MESSAGE("Delphox used Tackle!");
ABILITY_POPUP(player, ABILITY_MAGICIAN);
MESSAGE("Delphox stole Foe Wobbuffet's Life Orb!");
NONE_OF {
HP_BAR(player);
MESSAGE("Delphox was hurt by its Life Orb!");
}
// 2nd turn - Life Orb recoil happens now
MESSAGE("Delphox used Tackle!");
HP_BAR(player);
MESSAGE("Delphox was hurt by its Life Orb!");
}
}