diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f4735f7792..ad31bb4e36 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1733,6 +1733,7 @@ BattleScript_EffectHitSwitchTarget: resultmessage waitmessage B_WAIT_TIME_LONG tryfaintmon BS_TARGET + moveendcase MOVEEND_MAGICIAN @ possibly others? jumpifability BS_TARGET, ABILITY_SUCTION_CUPS, BattleScript_AbilityPreventsPhasingOut jumpifstatus3 BS_TARGET, STATUS3_ROOTED, BattleScript_PrintMonIsRooted tryhitswitchtarget BattleScript_EffectHitSwitchTargetMoveEnd @@ -9337,3 +9338,8 @@ BattleScript_NeutralizingGasExitsLoop: jumpifbytenotequal gBattlerTarget, sByteFour, BattleScript_NeutralizingGasExitsLoop @ SOMEHOW, comparing to gBattlersCount is problematic. restoretarget return + +BattleScript_MagicianActivates:: + call BattleScript_AbilityPopUp + call BattleScript_ItemSteal + return diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 415eaa6bb4..6f8b0d4243 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -415,5 +415,6 @@ extern const u8 BattleScript_AttackerFormChangeMoveEffect[]; extern const u8 BattleScript_BothCanNoLongerEscape[]; extern const u8 BattleScript_OctolockEndTurn[]; extern const u8 BattleScript_NeutralizingGasExits[]; +extern const u8 BattleScript_MagicianActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 6d1b62d44e..767ae88a68 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -290,15 +290,16 @@ #define MOVEEND_UPDATE_LAST_MOVES 19 #define MOVEEND_MIRROR_MOVE 20 #define MOVEEND_NEXT_TARGET 21 // Everything up until here is handled for each strike of a multi-hit move -#define MOVEEND_EJECT_BUTTON 22 -#define MOVEEND_RED_CARD 23 -#define MOVEEND_EJECT_PACK 24 -#define MOVEEND_LIFEORB_SHELLBELL 25 // Includes shell bell, throat spray, etc -#define MOVEEND_PICKPOCKET 26 -#define MOVEEND_DANCER 27 -#define MOVEEND_EMERGENCY_EXIT 28 -#define MOVEEND_CLEAR_BITS 29 -#define MOVEEND_COUNT 30 +#define MOVEEND_MAGICIAN 22 // Occurs after final multi-hit strike, and after other items/abilities would activate +#define MOVEEND_EJECT_BUTTON 23 +#define MOVEEND_RED_CARD 24 +#define MOVEEND_EJECT_PACK 25 +#define MOVEEND_LIFEORB_SHELLBELL 26 // Includes shell bell, throat spray, etc +#define MOVEEND_PICKPOCKET 27 +#define MOVEEND_DANCER 28 +#define MOVEEND_EMERGENCY_EXIT 29 +#define MOVEEND_CLEAR_BITS 30 +#define MOVEEND_COUNT 31 // switch cases #define B_SWITCH_NORMAL 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 3cf660a814..b088d16a72 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5290,6 +5290,29 @@ static void Cmd_moveend(void) } gBattleScripting.moveendState++; break; + case MOVEEND_MAGICIAN: + if (GetBattlerAbility(gBattlerAttacker) == ABILITY_MAGICIAN + && gCurrentMove != MOVE_FLING && gCurrentMove != MOVE_NATURAL_GIFT + && gBattleMons[gBattlerAttacker].item == ITEM_NONE + && gBattleMons[gBattlerTarget].item != ITEM_NONE + && IsBattlerAlive(gBattlerAttacker) + && TARGET_TURN_DAMAGED + && CanStealItem(gBattlerAttacker, gBattlerTarget, gBattleMons[gBattlerTarget].item) + && !gSpecialStatuses[gBattlerAttacker].gemBoost // In base game, gems are consumed after magician would activate. + && !(gWishFutureKnock.knockedOffMons[GetBattlerSide(gBattlerTarget)] & gBitTable[gBattlerPartyIndexes[gBattlerTarget]]) + && !DoesSubstituteBlockMove(gBattlerAttacker, gBattlerTarget, gCurrentMove) + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && (GetBattlerAbility(gBattlerTarget) != ABILITY_STICKY_HOLD || !IsBattlerAlive(gBattlerTarget))) + { + StealTargetItem(gBattlerAttacker, gBattlerTarget); + gBattleScripting.battler = gBattlerAbility = gBattlerAttacker; + gEffectBattler = gBattlerTarget; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_MagicianActivates; + effect = TRUE; + } + gBattleScripting.moveendState++; + break; case MOVEEND_NEXT_TARGET: // For moves hitting two opposing Pokemon. // Set a flag if move hits either target (for throat spray that can't check damage) if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE)