Shed Shell

This commit is contained in:
DizzyEggg 2020-04-28 11:14:20 +02:00
parent 7b4ccbc6bc
commit 36b52eb063
4 changed files with 14 additions and 12 deletions

View File

@ -84,6 +84,7 @@ u32 IsAbilityOnOpposingSide(u32 battlerId, u32 ability);
u32 IsAbilityOnField(u32 ability);
u32 IsAbilityOnFieldExcept(u32 battlerId, u32 ability);
u32 IsAbilityPreventingEscape(u32 battlerId);
bool32 CanBattlerEscape(u32 battlerId); // no ability check
void BattleScriptExecute(const u8* BS_ptr);
void BattleScriptPushCursorAndCallback(const u8* BS_ptr);
u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn);

View File

@ -3690,9 +3690,7 @@ u8 IsRunningFromBattleImpossible(void)
return 2;
}
if ((gBattleMons[gActiveBattler].status2 & (STATUS2_ESCAPE_PREVENTION | STATUS2_WRAPPED))
|| (gStatuses3[gActiveBattler] & STATUS3_ROOTED)
|| gFieldStatuses & STATUS_FIELD_FAIRY_LOCK)
if (!CanBattlerEscape(gActiveBattler))
{
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
return 1;
@ -3868,10 +3866,8 @@ static void HandleTurnActionSelectionState(void)
break;
case B_ACTION_SWITCH:
*(gBattleStruct->field_58 + gActiveBattler) = gBattlerPartyIndexes[gActiveBattler];
if (gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)
|| gBattleTypeFlags & BATTLE_TYPE_ARENA
|| gFieldStatuses & STATUS_FIELD_FAIRY_LOCK
|| gStatuses3[gActiveBattler] & STATUS3_ROOTED)
if (gBattleTypeFlags & BATTLE_TYPE_ARENA
|| !CanBattlerEscape(gActiveBattler))
{
BtlController_EmitChoosePokemon(0, PARTY_ACTION_CANT_SWITCH, PARTY_SIZE, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]);
}
@ -5553,8 +5549,7 @@ static void HandleAction_Run(void)
}
else
{
if (gBattleMons[gBattlerAttacker].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)
|| gFieldStatuses & STATUS_FIELD_FAIRY_LOCK)
if (!CanBattlerEscape(gBattlerAttacker))
{
gBattleCommunication[MULTISTRING_CHOOSER] = 4;
gBattlescriptCurrInstr = BattleScript_PrintFailedToRunString;

View File

@ -5115,9 +5115,7 @@ static void Cmd_jumpifcantswitch(void)
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(SWITCH_IGNORE_ESCAPE_PREVENTION));
if (!(gBattlescriptCurrInstr[1] & SWITCH_IGNORE_ESCAPE_PREVENTION)
&& ((gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION))
|| (gFieldStatuses & STATUS_FIELD_FAIRY_LOCK)
|| (gStatuses3[gActiveBattler] & STATUS3_ROOTED)))
&& !CanBattlerEscape(gActiveBattler))
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2);
}

View File

@ -4077,6 +4077,14 @@ u32 IsAbilityPreventingEscape(u32 battlerId)
return 0;
}
bool32 CanBattlerEscape(u32 battlerId) // no ability check
{
return (GetBattlerHoldEffect(battlerId, TRUE) == HOLD_EFFECT_SHED_SHELL
|| !((gBattleMons[battlerId].status2 & (STATUS2_ESCAPE_PREVENTION | STATUS2_WRAPPED))
|| (gStatuses3[battlerId] & STATUS3_ROOTED)
|| gFieldStatuses & STATUS_FIELD_FAIRY_LOCK));
}
void BattleScriptExecute(const u8 *BS_ptr)
{
gBattlescriptCurrInstr = BS_ptr;