From 66152538ec15770713bc9b4ba97f94cfd33f2323 Mon Sep 17 00:00:00 2001 From: Evan Date: Fri, 13 Nov 2020 13:42:49 -0700 Subject: [PATCH] add back accidentally deleted item theft battle type checks --- include/battle_util.h | 1 + src/battle_script_commands.c | 4 ++-- src/battle_util.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index 4623cff263..3b049be568 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -133,5 +133,6 @@ u8 GetBattleMoveSplit(u32 moveId); void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast); bool32 TestSheerForceFlag(u8 battler, u16 move); void TryRestoreStolenItems(void); +bool8 CanStealItem(u8 battlerId, u16 item); #endif // GUARD_BATTLE_UTIL_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 676fe31e7d..faee7ec671 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2951,7 +2951,7 @@ void SetMoveEffect(bool32 primary, u32 certain) break; case MOVE_EFFECT_STEAL_ITEM: { - if (!CanBattlerGetOrLoseItem(gBattlerAttacker, gBattleMons[gBattlerTarget].item)) + if (!CanStealItem(gBattlerAttacker, gBattleMons[gBattlerTarget].item)) { gBattlescriptCurrInstr++; break; @@ -5032,7 +5032,7 @@ static void Cmd_moveend(void) && !DoesSubstituteBlockMove(gCurrentMove, gBattlerAttacker, battler) //subsitute unaffected && IsBattlerAlive(battler) //battler must be alive to be pickpocketed && gBattleMons[battler].item == ITEM_NONE //pickpocketer can't have an item already - && CanBattlerGetOrLoseItem(battler, gBattleMons[gBattlerAttacker].item)) //cannot steal plates, mega stones, etc + && CanStealItem(battler, gBattleMons[gBattlerAttacker].item)) //cannot steal plates, mega stones, etc { gBattlerTarget = gBattlerAbility = battler; BattleScriptPushCursor(); diff --git a/src/battle_util.c b/src/battle_util.c index 00aa19f8c2..4d38adc043 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7826,3 +7826,36 @@ void TryRestoreStolenItems(void) } } +bool8 CanStealItem(u8 battlerId, u16 item) +{ + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL) + return FALSE; + + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT + && !(gBattleTypeFlags & + (BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_FRONTIER + | BATTLE_TYPE_LINK + | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_SECRET_BASE + #if B_TRAINERS_STEAL_ITEMS + | BATTLE_TYPE_TRAINER + #endif + ))) + { + return FALSE; + } + else if (!(gBattleTypeFlags & + (BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_FRONTIER + | BATTLE_TYPE_LINK + | BATTLE_TYPE_x2000000 + | BATTLE_TYPE_SECRET_BASE)) + && (gWishFutureKnock.knockedOffMons[GetBattlerSide(gBattlerAttacker)] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]])) + { + return FALSE; + } + + return CanBattlerGetOrLoseItem(battlerId, item); +} +