From c4ce4c150dbe2c7d67d4bc0ecb2000909fd1f26f Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 14 Sep 2021 15:38:16 -0400 Subject: [PATCH] fix eject pack --- include/battle.h | 1 + src/battle_script_commands.c | 5 ++++- src/battle_util.c | 7 +++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/battle.h b/include/battle.h index 43a941737..36646c9fe 100644 --- a/include/battle.h +++ b/include/battle.h @@ -145,6 +145,7 @@ struct ProtectStruct u32 micle:1; u32 custap:1; // also quick claw u32 touchedProtectLike:1; + u32 disableEjectPack:1; u32 physicalDmg; u32 specialDmg; u8 physicalBattlerId; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b3f528a00..7146840da 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5171,6 +5171,7 @@ static void Cmd_moveend(void) if (IsBattlerAlive(battler) && gSpecialStatuses[battler].statFell && GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_EJECT_PACK + && !(gCurrentMove == MOVE_PARTING_SHOT && CanBattlerSwitch(gBattlerAttacker)) // Does not activate if attacker used Parting Shot and can switch out && CountUsablePartyMons(battler) > 0) // Has mon to switch into { gSpecialStatuses[battler].statFell = FALSE; @@ -9288,7 +9289,9 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr } else { - gSpecialStatuses[gActiveBattler].statFell = TRUE; // For eject pack + // Check eject pack. disableEjectPack set for edge cases (e.g. attacking weak armor'd eject pack holder with u-turn) + if (gProtectStructs[gActiveBattler].disableEjectPack == 0) + gSpecialStatuses[gActiveBattler].statFell = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); // B_MSG_ATTACKER_STAT_FELL or B_MSG_DEFENDER_STAT_FELL } } diff --git a/src/battle_util.c b/src/battle_util.c index 4cec2160a..7edc4eadc 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -557,7 +557,6 @@ void HandleAction_UseItem(void) } break; case AI_ITEM_X_STAT: - // TODO Contrary check gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STAT_ROSE_ITEM; if (*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1)) & (1 << AI_DIRE_HIT)) { @@ -4645,6 +4644,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move && (CompareStat(battler, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN) // Don't activate if speed cannot be raised || CompareStat(battler, STAT_DEF, MIN_STAT_STAGE, CMP_GREATER_THAN))) // Don't activate if defense cannot be lowered { + if (gBattleMoves[gCurrentMove].effect == EFFECT_HIT_ESCAPE && CanBattlerSwitch(gBattlerAttacker)) + gProtectStructs[battler].disableEjectPack = 1; // Set flag for target + BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_WeakArmorActivates; effect++; @@ -5851,7 +5853,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } break; case HOLD_EFFECT_EJECT_PACK: - if (gSpecialStatuses[battlerId].statFell) + if (gSpecialStatuses[battlerId].statFell + && !(gCurrentMove == MOVE_PARTING_SHOT && CanBattlerSwitch(gBattlerAttacker))) // Does not activate if attacker used Parting Shot and can switch out { gSpecialStatuses[battlerId].statFell = FALSE; gActiveBattler = gBattleScripting.battler = battlerId;