Skip to content

Commit

Permalink
Fix Magician Life orb recoil when stealing (#3753)
Browse files Browse the repository at this point in the history
* Fix Magician Life orb recoil

* get rid of unneeded assume
  • Loading branch information
DizzyEggg committed Dec 17, 2023
1 parent 5d2efbe commit 76a7513
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,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.
};

struct SideTimer
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 @@ -5719,6 +5719,7 @@ static void Cmd_moveend(void)
gEffectBattler = gBattlerTarget;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MagicianActivates;
gSpecialStatuses[gBattlerAttacker].magicianStolen = TRUE;
effect = TRUE;
}
gBattleScripting.moveendState++;
Expand Down Expand Up @@ -6081,6 +6082,7 @@ static void Cmd_moveend(void)
gStatuses3[gBattlerAttacker] &= ~STATUS3_ME_FIRST;
gSpecialStatuses[gBattlerAttacker].gemBoost = FALSE;
gSpecialStatuses[gBattlerAttacker].damagedMons = 0;
gSpecialStatuses[gBattlerAttacker].magicianStolen = 0;
gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
gBattleScripting.moveEffect = 0;
// clear attacker z move data
Expand Down
1 change: 1 addition & 0 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7697,6 +7697,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].damagedMons)
{
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 10;
Expand Down
29 changes: 29 additions & 0 deletions test/battle/ability/magician.c
Original file line number Diff line number Diff line change
@@ -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!");
}
}

0 comments on commit 76a7513

Please sign in to comment.