eject pack

This commit is contained in:
Evan 2021-01-07 21:11:56 -07:00
parent 0118723a9c
commit 2bd5167a6c
5 changed files with 57 additions and 2 deletions

View File

@ -7850,3 +7850,15 @@ BattleScript_EjectButtonActivates::
switchineffects BS_SCRIPTING
BattleScript_EjectButtonEnd:
return
BattleScript_EjectPackActivate_Ret::
goto BattleScript_EjectButtonActivates
BattleScript_EjectPackActivate_End2::
call BattleScript_EjectPackActivate_Ret
end2
BattleScript_EjectPackActivates::
jumpifcantswitch BS_SCRIPTING, BattleScript_EjectButtonEnd
goto BattleScript_EjectPackActivate_Ret

View File

@ -148,6 +148,7 @@ struct ProtectStruct
struct SpecialStatus
{
u8 statFell:1;
u8 statLowered:1;
u8 lightningRodRedirected:1;
u8 restoredBattlerSprite: 1;

View File

@ -354,5 +354,8 @@ extern const u8 BattleScript_AnnounceAirLockCloudNine[];
extern const u8 BattleScript_AttackerItemStatRaise[];
extern const u8 BattleScript_RedCardActivates[];
extern const u8 BattleScript_EjectButtonActivates[];
extern const u8 BattleScript_EjectPackActivate_Ret[];
extern const u8 BattleScript_EjectPackActivate_End2[];
extern const u8 BattleScript_EjectPackActivates[];
#endif // GUARD_BATTLE_SCRIPTS_H

View File

@ -5027,7 +5027,7 @@ static void Cmd_moveend(void)
&& GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_EJECT_BUTTON
&& !DoesSubstituteBlockMove(gCurrentMove, gBattlerAttacker, battler)
&& (gSpecialStatuses[battler].physicalDmg != 0 || gSpecialStatuses[battler].specialDmg != 0)
&& CountUsablePartyMons(battler) > 0)
&& CountUsablePartyMons(battler) > 0) // has mon to switch into
{
gActiveBattler = gBattleScripting.battler = battler;
gLastUsedItem = gBattleMons[battler].item;
@ -5061,7 +5061,7 @@ static void Cmd_moveend(void)
&& !DoesSubstituteBlockMove(gCurrentMove, gBattlerAttacker, battler)
&& GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_RED_CARD
&& (gSpecialStatuses[battler].physicalDmg != 0 || gSpecialStatuses[battler].specialDmg != 0)
&& CountUsablePartyMons(battler) > 0)
&& CountUsablePartyMons(battler) > 0) // has mon to switch into
{
gLastUsedItem = gBattleMons[battler].item;
gActiveBattler = gBattleScripting.battler = battler; // battler with red card
@ -5078,6 +5078,27 @@ static void Cmd_moveend(void)
gBattleScripting.moveendState++;
break;
case MOVEEND_EJECT_PACK:
{
u8 battlers[4] = {0, 1, 2, 3};
SortBattlersBySpeed(battlers, FALSE);
for (i = 0; i < gBattlersCount; i++)
{
u8 battler = battlers[i];
if (IsBattlerAlive(battler)
&& gSpecialStatuses[battler].statFell
&& GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_EJECT_PACK
&& CountUsablePartyMons(battler) > 0) // has mon to switch into
{
gSpecialStatuses[battler].statFell = FALSE;
gActiveBattler = gBattleScripting.battler = battler;
gLastUsedItem = gBattleMons[battler].item;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_EjectPackActivates;
effect = TRUE;
break; // only fastest eject pack activates
}
}
}
gBattleScripting.moveendState++;
break;
case MOVEEND_LIFE_ORB:
@ -9095,6 +9116,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
index++;
gBattleTextBuff2[index] = B_BUFF_EOS;
gSpecialStatuses[gActiveBattler].statFell = TRUE; // for eject pack
if (gBattleMons[gActiveBattler].statStages[statId] == MIN_STAT_STAGE)
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
else

View File

@ -5357,6 +5357,23 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
}
break;
case HOLD_EFFECT_EJECT_PACK:
if (gSpecialStatuses[battlerId].statFell)
{
gSpecialStatuses[battlerId].statFell = FALSE;
gActiveBattler = gBattleScripting.battler = battlerId;
effect = ITEM_STATS_CHANGE;
if (moveTurn)
{
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_EjectPackActivate_Ret;
}
else
{
BattleScriptExecute(BattleScript_EjectPackActivate_End2);
}
}
break;
}
if (effect)