mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
remove more of gActiveBattler
This commit is contained in:
parent
156aa59f18
commit
0381ccdf32
@ -53,10 +53,10 @@ void SpriteCB_TrainerThrowObject(struct Sprite *sprite);
|
||||
void AnimSetCenterToCornerVecX(struct Sprite *sprite);
|
||||
void BeginBattleIntroDummy(void);
|
||||
void BeginBattleIntro(void);
|
||||
void SwitchInClearSetData(void);
|
||||
void FaintClearSetData(void);
|
||||
void SwitchInClearSetData(u32 battler);
|
||||
void FaintClearSetData(u32 battler);
|
||||
void BattleTurnPassed(void);
|
||||
u8 IsRunningFromBattleImpossible(void);
|
||||
u8 IsRunningFromBattleImpossible(u32 battler);
|
||||
void SwitchPartyOrder(u8 battlerId);
|
||||
void SwapTurnOrder(u8 id1, u8 id2);
|
||||
u32 GetBattlerTotalSpeedStat(u8 battlerId);
|
||||
|
@ -100,7 +100,7 @@ static void TryDoEventsBeforeFirstTurn(void);
|
||||
static void HandleTurnActionSelectionState(void);
|
||||
static void RunTurnActionsFunctions(void);
|
||||
static void SetActionsAndBattlersTurnOrder(void);
|
||||
static void UpdateBattlerPartyOrdersOnSwitch(void);
|
||||
static void UpdateBattlerPartyOrdersOnSwitch(u32 battler);
|
||||
static bool8 AllAtActionConfirmed(void);
|
||||
static void TryChangeTurnOrder(void);
|
||||
static void CheckChosenMoveForEffectsBeforeTurnStarts(void);
|
||||
@ -3132,21 +3132,21 @@ static void BattleStartClearSetData(void)
|
||||
gSelectedMonPartyId = PARTY_SIZE; // Revival Blessing
|
||||
}
|
||||
|
||||
void SwitchInClearSetData(void)
|
||||
void SwitchInClearSetData(u32 battler)
|
||||
{
|
||||
s32 i;
|
||||
struct DisableStruct disableStructCopy = gDisableStructs[gActiveBattler];
|
||||
struct DisableStruct disableStructCopy = gDisableStructs[battler];
|
||||
|
||||
ClearIllusionMon(gActiveBattler);
|
||||
ClearIllusionMon(battler);
|
||||
if (gBattleMoves[gCurrentMove].effect != EFFECT_BATON_PASS)
|
||||
{
|
||||
for (i = 0; i < NUM_BATTLE_STATS; i++)
|
||||
gBattleMons[gActiveBattler].statStages[i] = DEFAULT_STAT_STAGE;
|
||||
gBattleMons[battler].statStages[i] = DEFAULT_STAT_STAGE;
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].battlerPreventingEscape == gActiveBattler)
|
||||
if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].battlerPreventingEscape == battler)
|
||||
gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION;
|
||||
if ((gStatuses3[i] & STATUS3_ALWAYS_HITS) && gDisableStructs[i].battlerWithSureHit == gActiveBattler)
|
||||
if ((gStatuses3[i] & STATUS3_ALWAYS_HITS) && gDisableStructs[i].battlerWithSureHit == battler)
|
||||
{
|
||||
gStatuses3[i] &= ~STATUS3_ALWAYS_HITS;
|
||||
gDisableStructs[i].battlerWithSureHit = 0;
|
||||
@ -3155,96 +3155,96 @@ void SwitchInClearSetData(void)
|
||||
}
|
||||
if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS)
|
||||
{
|
||||
gBattleMons[gActiveBattler].status2 &= (STATUS2_CONFUSION | STATUS2_FOCUS_ENERGY | STATUS2_SUBSTITUTE | STATUS2_ESCAPE_PREVENTION | STATUS2_CURSED);
|
||||
gStatuses3[gActiveBattler] &= (STATUS3_LEECHSEED_BATTLER | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED
|
||||
gBattleMons[battler].status2 &= (STATUS2_CONFUSION | STATUS2_FOCUS_ENERGY | STATUS2_SUBSTITUTE | STATUS2_ESCAPE_PREVENTION | STATUS2_CURSED);
|
||||
gStatuses3[battler] &= (STATUS3_LEECHSEED_BATTLER | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED
|
||||
| STATUS3_GASTRO_ACID | STATUS3_EMBARGO | STATUS3_TELEKINESIS | STATUS3_MAGNET_RISE | STATUS3_HEAL_BLOCK
|
||||
| STATUS3_AQUA_RING | STATUS3_POWER_TRICK);
|
||||
gStatuses4[gActiveBattler] &= (STATUS4_MUD_SPORT | STATUS4_WATER_SPORT | STATUS4_INFINITE_CONFUSION);
|
||||
gStatuses4[battler] &= (STATUS4_MUD_SPORT | STATUS4_WATER_SPORT | STATUS4_INFINITE_CONFUSION);
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (GetBattlerSide(gActiveBattler) != GetBattlerSide(i)
|
||||
if (GetBattlerSide(battler) != GetBattlerSide(i)
|
||||
&& (gStatuses3[i] & STATUS3_ALWAYS_HITS) != 0
|
||||
&& (gDisableStructs[i].battlerWithSureHit == gActiveBattler))
|
||||
&& (gDisableStructs[i].battlerWithSureHit == battler))
|
||||
{
|
||||
gStatuses3[i] &= ~STATUS3_ALWAYS_HITS;
|
||||
gStatuses3[i] |= STATUS3_ALWAYS_HITS_TURN(2);
|
||||
}
|
||||
}
|
||||
if (gStatuses3[gActiveBattler] & STATUS3_POWER_TRICK)
|
||||
SWAP(gBattleMons[gActiveBattler].attack, gBattleMons[gActiveBattler].defense, i);
|
||||
if (gStatuses3[battler] & STATUS3_POWER_TRICK)
|
||||
SWAP(gBattleMons[battler].attack, gBattleMons[battler].defense, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleMons[gActiveBattler].status2 = 0;
|
||||
gStatuses3[gActiveBattler] = 0;
|
||||
gStatuses4[gActiveBattler] = 0;
|
||||
gBattleMons[battler].status2 = 0;
|
||||
gStatuses3[battler] = 0;
|
||||
gStatuses4[battler] = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBattler))
|
||||
gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(gActiveBattler);
|
||||
if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == gActiveBattler)
|
||||
if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(battler))
|
||||
gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(battler);
|
||||
if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == battler)
|
||||
gBattleMons[i].status2 &= ~STATUS2_WRAPPED;
|
||||
}
|
||||
|
||||
gActionSelectionCursor[gActiveBattler] = 0;
|
||||
gMoveSelectionCursor[gActiveBattler] = 0;
|
||||
gActionSelectionCursor[battler] = 0;
|
||||
gMoveSelectionCursor[battler] = 0;
|
||||
|
||||
memset(&gDisableStructs[gActiveBattler], 0, sizeof(struct DisableStruct));
|
||||
memset(&gDisableStructs[battler], 0, sizeof(struct DisableStruct));
|
||||
|
||||
if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS)
|
||||
{
|
||||
gDisableStructs[gActiveBattler].substituteHP = disableStructCopy.substituteHP;
|
||||
gDisableStructs[gActiveBattler].battlerWithSureHit = disableStructCopy.battlerWithSureHit;
|
||||
gDisableStructs[gActiveBattler].perishSongTimer = disableStructCopy.perishSongTimer;
|
||||
gDisableStructs[gActiveBattler].battlerPreventingEscape = disableStructCopy.battlerPreventingEscape;
|
||||
gDisableStructs[battler].substituteHP = disableStructCopy.substituteHP;
|
||||
gDisableStructs[battler].battlerWithSureHit = disableStructCopy.battlerWithSureHit;
|
||||
gDisableStructs[battler].perishSongTimer = disableStructCopy.perishSongTimer;
|
||||
gDisableStructs[battler].battlerPreventingEscape = disableStructCopy.battlerPreventingEscape;
|
||||
}
|
||||
|
||||
gMoveResultFlags = 0;
|
||||
gDisableStructs[gActiveBattler].isFirstTurn = 2;
|
||||
gDisableStructs[gActiveBattler].truantSwitchInHack = disableStructCopy.truantSwitchInHack;
|
||||
gLastMoves[gActiveBattler] = MOVE_NONE;
|
||||
gLastLandedMoves[gActiveBattler] = MOVE_NONE;
|
||||
gLastHitByType[gActiveBattler] = 0;
|
||||
gLastResultingMoves[gActiveBattler] = MOVE_NONE;
|
||||
gLastPrintedMoves[gActiveBattler] = MOVE_NONE;
|
||||
gLastHitBy[gActiveBattler] = 0xFF;
|
||||
gDisableStructs[battler].isFirstTurn = 2;
|
||||
gDisableStructs[battler].truantSwitchInHack = disableStructCopy.truantSwitchInHack;
|
||||
gLastMoves[battler] = MOVE_NONE;
|
||||
gLastLandedMoves[battler] = MOVE_NONE;
|
||||
gLastHitByType[battler] = 0;
|
||||
gLastResultingMoves[battler] = MOVE_NONE;
|
||||
gLastPrintedMoves[battler] = MOVE_NONE;
|
||||
gLastHitBy[battler] = 0xFF;
|
||||
|
||||
gBattleStruct->lastTakenMove[gActiveBattler] = 0;
|
||||
gBattleStruct->sameMoveTurns[gActiveBattler] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][0] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][1] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][2] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0;
|
||||
gBattleStruct->lastMoveFailed &= ~(gBitTable[gActiveBattler]);
|
||||
gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]);
|
||||
gBattleStruct->lastTakenMove[battler] = 0;
|
||||
gBattleStruct->sameMoveTurns[battler] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[battler][0] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[battler][1] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[battler][2] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[battler][3] = 0;
|
||||
gBattleStruct->lastMoveFailed &= ~(gBitTable[battler]);
|
||||
gBattleStruct->palaceFlags &= ~(gBitTable[battler]);
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(gSideTimers); i++)
|
||||
{
|
||||
// Switched into sticky web user slot, so reset stored battler ID
|
||||
if (gSideTimers[i].stickyWebBattlerId == gActiveBattler)
|
||||
if (gSideTimers[i].stickyWebBattlerId == battler)
|
||||
gSideTimers[i].stickyWebBattlerId = 0xFF;
|
||||
}
|
||||
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (i != gActiveBattler && GetBattlerSide(i) != GetBattlerSide(gActiveBattler))
|
||||
if (i != battler && GetBattlerSide(i) != GetBattlerSide(battler))
|
||||
gBattleStruct->lastTakenMove[i] = MOVE_NONE;
|
||||
|
||||
gBattleStruct->lastTakenMoveFrom[i][gActiveBattler] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[i][battler] = 0;
|
||||
}
|
||||
|
||||
gBattleStruct->choicedMove[gActiveBattler] = MOVE_NONE;
|
||||
gBattleResources->flags->flags[gActiveBattler] = 0;
|
||||
gBattleStruct->choicedMove[battler] = MOVE_NONE;
|
||||
gBattleResources->flags->flags[battler] = 0;
|
||||
gCurrentMove = MOVE_NONE;
|
||||
gBattleStruct->arenaTurnCounter = 0xFF;
|
||||
|
||||
// Reset damage to prevent things like red card activating if the switched-in mon is holding it
|
||||
gSpecialStatuses[gActiveBattler].physicalDmg = 0;
|
||||
gSpecialStatuses[gActiveBattler].specialDmg = 0;
|
||||
gSpecialStatuses[battler].physicalDmg = 0;
|
||||
gSpecialStatuses[battler].specialDmg = 0;
|
||||
|
||||
gBattleStruct->overwrittenAbilities[gActiveBattler] = ABILITY_NONE;
|
||||
gBattleStruct->overwrittenAbilities[battler] = ABILITY_NONE;
|
||||
|
||||
// Clear selected party ID so Revival Blessing doesn't get confused.
|
||||
gSelectedMonPartyId = PARTY_SIZE;
|
||||
@ -3252,126 +3252,126 @@ void SwitchInClearSetData(void)
|
||||
// Allow for illegal abilities within tests.
|
||||
if (gTestRunnerEnabled)
|
||||
{
|
||||
u32 side = GetBattlerSide(gActiveBattler);
|
||||
u32 partyIndex = gBattlerPartyIndexes[gActiveBattler];
|
||||
u32 side = GetBattlerSide(battler);
|
||||
u32 partyIndex = gBattlerPartyIndexes[battler];
|
||||
if (TestRunner_Battle_GetForcedAbility(side, partyIndex))
|
||||
gBattleMons[i].ability = gBattleStruct->overwrittenAbilities[i] = TestRunner_Battle_GetForcedAbility(side, partyIndex);
|
||||
}
|
||||
|
||||
Ai_UpdateSwitchInData(gActiveBattler);
|
||||
Ai_UpdateSwitchInData(battler);
|
||||
}
|
||||
|
||||
void FaintClearSetData(void)
|
||||
void FaintClearSetData(u32 battler)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < NUM_BATTLE_STATS; i++)
|
||||
gBattleMons[gActiveBattler].statStages[i] = DEFAULT_STAT_STAGE;
|
||||
gBattleMons[battler].statStages[i] = DEFAULT_STAT_STAGE;
|
||||
|
||||
gBattleMons[gActiveBattler].status2 = 0;
|
||||
gStatuses3[gActiveBattler] = 0;
|
||||
gStatuses4[gActiveBattler] = 0;
|
||||
gBattleMons[battler].status2 = 0;
|
||||
gStatuses3[battler] = 0;
|
||||
gStatuses4[battler] = 0;
|
||||
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].battlerPreventingEscape == gActiveBattler)
|
||||
if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].battlerPreventingEscape == battler)
|
||||
gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION;
|
||||
if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBattler))
|
||||
gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(gActiveBattler);
|
||||
if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == gActiveBattler)
|
||||
if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(battler))
|
||||
gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(battler);
|
||||
if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == battler)
|
||||
gBattleMons[i].status2 &= ~STATUS2_WRAPPED;
|
||||
}
|
||||
|
||||
gActionSelectionCursor[gActiveBattler] = 0;
|
||||
gMoveSelectionCursor[gActiveBattler] = 0;
|
||||
gActionSelectionCursor[battler] = 0;
|
||||
gMoveSelectionCursor[battler] = 0;
|
||||
|
||||
memset(&gDisableStructs[gActiveBattler], 0, sizeof(struct DisableStruct));
|
||||
memset(&gDisableStructs[battler], 0, sizeof(struct DisableStruct));
|
||||
|
||||
gProtectStructs[gActiveBattler].protected = FALSE;
|
||||
gProtectStructs[gActiveBattler].spikyShielded = FALSE;
|
||||
gProtectStructs[gActiveBattler].kingsShielded = FALSE;
|
||||
gProtectStructs[gActiveBattler].banefulBunkered = FALSE;
|
||||
gProtectStructs[gActiveBattler].quash = FALSE;
|
||||
gProtectStructs[gActiveBattler].obstructed = FALSE;
|
||||
gProtectStructs[gActiveBattler].silkTrapped = FALSE;
|
||||
gProtectStructs[gActiveBattler].endured = FALSE;
|
||||
gProtectStructs[gActiveBattler].noValidMoves = FALSE;
|
||||
gProtectStructs[gActiveBattler].helpingHand = FALSE;
|
||||
gProtectStructs[gActiveBattler].bounceMove = FALSE;
|
||||
gProtectStructs[gActiveBattler].stealMove = FALSE;
|
||||
gProtectStructs[gActiveBattler].prlzImmobility = FALSE;
|
||||
gProtectStructs[gActiveBattler].confusionSelfDmg = FALSE;
|
||||
gProtectStructs[gActiveBattler].targetAffected = FALSE;
|
||||
gProtectStructs[gActiveBattler].chargingTurn = FALSE;
|
||||
gProtectStructs[gActiveBattler].fleeType = 0;
|
||||
gProtectStructs[gActiveBattler].usedImprisonedMove = FALSE;
|
||||
gProtectStructs[gActiveBattler].loveImmobility = FALSE;
|
||||
gProtectStructs[gActiveBattler].usedDisabledMove = FALSE;
|
||||
gProtectStructs[gActiveBattler].usedTauntedMove = FALSE;
|
||||
gProtectStructs[gActiveBattler].flag2Unknown = FALSE;
|
||||
gProtectStructs[gActiveBattler].flinchImmobility = FALSE;
|
||||
gProtectStructs[gActiveBattler].notFirstStrike = FALSE;
|
||||
gProtectStructs[gActiveBattler].usedHealBlockedMove = FALSE;
|
||||
gProtectStructs[gActiveBattler].usesBouncedMove = FALSE;
|
||||
gProtectStructs[gActiveBattler].usedGravityPreventedMove = FALSE;
|
||||
gProtectStructs[gActiveBattler].usedThroatChopPreventedMove = FALSE;
|
||||
gProtectStructs[gActiveBattler].statRaised = FALSE;
|
||||
gProtectStructs[gActiveBattler].statFell = FALSE;
|
||||
gProtectStructs[gActiveBattler].pranksterElevated = FALSE;
|
||||
gProtectStructs[battler].protected = FALSE;
|
||||
gProtectStructs[battler].spikyShielded = FALSE;
|
||||
gProtectStructs[battler].kingsShielded = FALSE;
|
||||
gProtectStructs[battler].banefulBunkered = FALSE;
|
||||
gProtectStructs[battler].quash = FALSE;
|
||||
gProtectStructs[battler].obstructed = FALSE;
|
||||
gProtectStructs[battler].silkTrapped = FALSE;
|
||||
gProtectStructs[battler].endured = FALSE;
|
||||
gProtectStructs[battler].noValidMoves = FALSE;
|
||||
gProtectStructs[battler].helpingHand = FALSE;
|
||||
gProtectStructs[battler].bounceMove = FALSE;
|
||||
gProtectStructs[battler].stealMove = FALSE;
|
||||
gProtectStructs[battler].prlzImmobility = FALSE;
|
||||
gProtectStructs[battler].confusionSelfDmg = FALSE;
|
||||
gProtectStructs[battler].targetAffected = FALSE;
|
||||
gProtectStructs[battler].chargingTurn = FALSE;
|
||||
gProtectStructs[battler].fleeType = 0;
|
||||
gProtectStructs[battler].usedImprisonedMove = FALSE;
|
||||
gProtectStructs[battler].loveImmobility = FALSE;
|
||||
gProtectStructs[battler].usedDisabledMove = FALSE;
|
||||
gProtectStructs[battler].usedTauntedMove = FALSE;
|
||||
gProtectStructs[battler].flag2Unknown = FALSE;
|
||||
gProtectStructs[battler].flinchImmobility = FALSE;
|
||||
gProtectStructs[battler].notFirstStrike = FALSE;
|
||||
gProtectStructs[battler].usedHealBlockedMove = FALSE;
|
||||
gProtectStructs[battler].usesBouncedMove = FALSE;
|
||||
gProtectStructs[battler].usedGravityPreventedMove = FALSE;
|
||||
gProtectStructs[battler].usedThroatChopPreventedMove = FALSE;
|
||||
gProtectStructs[battler].statRaised = FALSE;
|
||||
gProtectStructs[battler].statFell = FALSE;
|
||||
gProtectStructs[battler].pranksterElevated = FALSE;
|
||||
|
||||
gDisableStructs[gActiveBattler].isFirstTurn = 2;
|
||||
gDisableStructs[battler].isFirstTurn = 2;
|
||||
|
||||
gLastMoves[gActiveBattler] = MOVE_NONE;
|
||||
gLastLandedMoves[gActiveBattler] = MOVE_NONE;
|
||||
gLastHitByType[gActiveBattler] = 0;
|
||||
gLastResultingMoves[gActiveBattler] = MOVE_NONE;
|
||||
gLastPrintedMoves[gActiveBattler] = MOVE_NONE;
|
||||
gLastHitBy[gActiveBattler] = 0xFF;
|
||||
gLastMoves[battler] = MOVE_NONE;
|
||||
gLastLandedMoves[battler] = MOVE_NONE;
|
||||
gLastHitByType[battler] = 0;
|
||||
gLastResultingMoves[battler] = MOVE_NONE;
|
||||
gLastPrintedMoves[battler] = MOVE_NONE;
|
||||
gLastHitBy[battler] = 0xFF;
|
||||
|
||||
gBattleStruct->choicedMove[gActiveBattler] = MOVE_NONE;
|
||||
gBattleStruct->sameMoveTurns[gActiveBattler] = 0;
|
||||
gBattleStruct->lastTakenMove[gActiveBattler] = MOVE_NONE;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][0] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][1] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][2] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0;
|
||||
gBattleStruct->choicedMove[battler] = MOVE_NONE;
|
||||
gBattleStruct->sameMoveTurns[battler] = 0;
|
||||
gBattleStruct->lastTakenMove[battler] = MOVE_NONE;
|
||||
gBattleStruct->lastTakenMoveFrom[battler][0] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[battler][1] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[battler][2] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[battler][3] = 0;
|
||||
|
||||
gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]);
|
||||
gBattleStruct->palaceFlags &= ~(gBitTable[battler]);
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(gSideTimers); i++)
|
||||
{
|
||||
// User of sticky web fainted, so reset the stored battler ID
|
||||
if (gSideTimers[i].stickyWebBattlerId == gActiveBattler)
|
||||
if (gSideTimers[i].stickyWebBattlerId == battler)
|
||||
gSideTimers[i].stickyWebBattlerId = 0xFF;
|
||||
}
|
||||
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (i != gActiveBattler && GetBattlerSide(i) != GetBattlerSide(gActiveBattler))
|
||||
if (i != battler && GetBattlerSide(i) != GetBattlerSide(battler))
|
||||
gBattleStruct->lastTakenMove[i] = MOVE_NONE;
|
||||
|
||||
gBattleStruct->lastTakenMoveFrom[i][gActiveBattler] = 0;
|
||||
gBattleStruct->lastTakenMoveFrom[i][battler] = 0;
|
||||
}
|
||||
|
||||
gBattleResources->flags->flags[gActiveBattler] = 0;
|
||||
gBattleResources->flags->flags[battler] = 0;
|
||||
|
||||
gBattleMons[gActiveBattler].type1 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
|
||||
gBattleMons[gActiveBattler].type2 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
|
||||
gBattleMons[gActiveBattler].type3 = TYPE_MYSTERY;
|
||||
gBattleMons[battler].type1 = gSpeciesInfo[gBattleMons[battler].species].types[0];
|
||||
gBattleMons[battler].type2 = gSpeciesInfo[gBattleMons[battler].species].types[1];
|
||||
gBattleMons[battler].type3 = TYPE_MYSTERY;
|
||||
|
||||
Ai_UpdateFaintData(gActiveBattler);
|
||||
TryBattleFormChange(gActiveBattler, FORM_CHANGE_FAINT);
|
||||
Ai_UpdateFaintData(battler);
|
||||
TryBattleFormChange(battler, FORM_CHANGE_FAINT);
|
||||
|
||||
gBattleStruct->overwrittenAbilities[gActiveBattler] = ABILITY_NONE;
|
||||
gBattleStruct->overwrittenAbilities[battler] = ABILITY_NONE;
|
||||
|
||||
// If the fainted mon was involved in a Sky Drop
|
||||
if (gBattleStruct->skyDropTargets[gActiveBattler] != 0xFF)
|
||||
if (gBattleStruct->skyDropTargets[battler] != 0xFF)
|
||||
{
|
||||
// Get battler id of the other Pokemon involved in this Sky Drop
|
||||
u8 otherSkyDropper = gBattleStruct->skyDropTargets[gActiveBattler];
|
||||
u8 otherSkyDropper = gBattleStruct->skyDropTargets[battler];
|
||||
|
||||
// Clear Sky Drop data
|
||||
gBattleStruct->skyDropTargets[gActiveBattler] = 0xFF;
|
||||
gBattleStruct->skyDropTargets[battler] = 0xFF;
|
||||
gBattleStruct->skyDropTargets[otherSkyDropper] = 0xFF;
|
||||
|
||||
// If the other Pokemon involved in this Sky Drop was the target, not the attacker
|
||||
@ -3405,7 +3405,7 @@ void FaintClearSetData(void)
|
||||
|
||||
// Clear Z-Move data
|
||||
gBattleStruct->zmove.active = FALSE;
|
||||
gBattleStruct->zmove.toBeUsed[gActiveBattler] = MOVE_NONE;
|
||||
gBattleStruct->zmove.toBeUsed[battler] = MOVE_NONE;
|
||||
gBattleStruct->zmove.effect = EFFECT_HIT;
|
||||
}
|
||||
|
||||
@ -3975,23 +3975,23 @@ void BattleTurnPassed(void)
|
||||
BattleScriptExecute(i == 1 ? BattleScript_TrainerASlideMsgEnd2 : BattleScript_TrainerBSlideMsgEnd2);
|
||||
}
|
||||
|
||||
u8 IsRunningFromBattleImpossible(void)
|
||||
u8 IsRunningFromBattleImpossible(u32 battler)
|
||||
{
|
||||
u32 holdEffect, i;
|
||||
|
||||
if (gBattleMons[gActiveBattler].item == ITEM_ENIGMA_BERRY_E_READER)
|
||||
holdEffect = gEnigmaBerries[gActiveBattler].holdEffect;
|
||||
if (gBattleMons[battler].item == ITEM_ENIGMA_BERRY_E_READER)
|
||||
holdEffect = gEnigmaBerries[battler].holdEffect;
|
||||
else
|
||||
holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item);
|
||||
holdEffect = ItemId_GetHoldEffect(gBattleMons[battler].item);
|
||||
|
||||
gPotentialItemEffectBattler = gActiveBattler;
|
||||
gPotentialItemEffectBattler = battler;
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE) // Cannot ever run from saving Birch's battle.
|
||||
{
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_DONT_LEAVE_BIRCH;
|
||||
return BATTLE_RUN_FORBIDDEN;
|
||||
}
|
||||
if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT && WILD_DOUBLE_BATTLE
|
||||
if (GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT && WILD_DOUBLE_BATTLE
|
||||
&& IsBattlerAlive(GetBattlerAtPosition(B_POSITION_PLAYER_LEFT))) // The second pokemon cannot run from a double wild battle, unless it's the only alive mon.
|
||||
{
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CANT_ESCAPE;
|
||||
@ -4001,15 +4001,15 @@ u8 IsRunningFromBattleImpossible(void)
|
||||
if (holdEffect == HOLD_EFFECT_CAN_ALWAYS_RUN)
|
||||
return BATTLE_RUN_SUCCESS;
|
||||
#if B_GHOSTS_ESCAPE >= GEN_6
|
||||
if (IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_GHOST))
|
||||
if (IS_BATTLER_OF_TYPE(battler, TYPE_GHOST))
|
||||
return BATTLE_RUN_SUCCESS;
|
||||
#endif
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
|
||||
return BATTLE_RUN_SUCCESS;
|
||||
if (GetBattlerAbility(gActiveBattler) == ABILITY_RUN_AWAY)
|
||||
if (GetBattlerAbility(battler) == ABILITY_RUN_AWAY)
|
||||
return BATTLE_RUN_SUCCESS;
|
||||
|
||||
if ((i = IsAbilityPreventingEscape(gActiveBattler)))
|
||||
if ((i = IsAbilityPreventingEscape(battler)))
|
||||
{
|
||||
gBattleScripting.battler = i - 1;
|
||||
gLastUsedAbility = gBattleMons[i - 1].ability;
|
||||
@ -4017,7 +4017,7 @@ u8 IsRunningFromBattleImpossible(void)
|
||||
return BATTLE_RUN_FAILURE;
|
||||
}
|
||||
|
||||
if (!CanBattlerEscape(gActiveBattler))
|
||||
if (!CanBattlerEscape(battler))
|
||||
{
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CANT_ESCAPE;
|
||||
return BATTLE_RUN_FORBIDDEN;
|
||||
@ -4313,7 +4313,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
BattleScriptExecute(BattleScript_PrintCantRunFromTrainer);
|
||||
gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
|
||||
}
|
||||
else if (IsRunningFromBattleImpossible() != BATTLE_RUN_SUCCESS
|
||||
else if (IsRunningFromBattleImpossible(gActiveBattler) != BATTLE_RUN_SUCCESS
|
||||
&& gBattleResources->bufferB[gActiveBattler][1] == B_ACTION_RUN)
|
||||
{
|
||||
gSelectionBattleScripts[gActiveBattler] = BattleScript_PrintCantEscapeFromBattle;
|
||||
@ -4347,7 +4347,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
return;
|
||||
case 15:
|
||||
gChosenActionByBattler[gActiveBattler] = B_ACTION_SWITCH;
|
||||
UpdateBattlerPartyOrdersOnSwitch();
|
||||
UpdateBattlerPartyOrdersOnSwitch(gActiveBattler);
|
||||
return;
|
||||
default:
|
||||
RecordedBattle_CheckMovesetChanges(B_RECORD_MODE_PLAYBACK);
|
||||
@ -4403,7 +4403,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateBattlerPartyOrdersOnSwitch();
|
||||
UpdateBattlerPartyOrdersOnSwitch(gActiveBattler);
|
||||
gBattleCommunication[gActiveBattler]++;
|
||||
}
|
||||
break;
|
||||
@ -4573,20 +4573,20 @@ static bool8 AllAtActionConfirmed(void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void UpdateBattlerPartyOrdersOnSwitch(void)
|
||||
static void UpdateBattlerPartyOrdersOnSwitch(u32 battler)
|
||||
{
|
||||
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = gBattleResources->bufferB[gActiveBattler][1];
|
||||
RecordedBattle_SetBattlerAction(gActiveBattler, gBattleResources->bufferB[gActiveBattler][1]);
|
||||
gBattleStruct->monToSwitchIntoId[battler] = gBattleResources->bufferB[battler][1];
|
||||
RecordedBattle_SetBattlerAction(battler, gBattleResources->bufferB[battler][1]);
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI)
|
||||
{
|
||||
*(gActiveBattler * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 0) &= 0xF;
|
||||
*(gActiveBattler * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 0) |= (gBattleResources->bufferB[gActiveBattler][2] & 0xF0);
|
||||
*(gActiveBattler * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 1) = gBattleResources->bufferB[gActiveBattler][3];
|
||||
*(battler * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 0) &= 0xF;
|
||||
*(battler * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 0) |= (gBattleResources->bufferB[battler][2] & 0xF0);
|
||||
*(battler * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 1) = gBattleResources->bufferB[battler][3];
|
||||
|
||||
*((BATTLE_PARTNER(gActiveBattler)) * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 0) &= (0xF0);
|
||||
*((BATTLE_PARTNER(gActiveBattler)) * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 0) |= (gBattleResources->bufferB[gActiveBattler][2] & 0xF0) >> 4;
|
||||
*((BATTLE_PARTNER(gActiveBattler)) * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 2) = gBattleResources->bufferB[gActiveBattler][3];
|
||||
*((BATTLE_PARTNER(battler)) * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 0) &= (0xF0);
|
||||
*((BATTLE_PARTNER(battler)) * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 0) |= (gBattleResources->bufferB[battler][2] & 0xF0) >> 4;
|
||||
*((BATTLE_PARTNER(battler)) * 3 + (u8 *)(gBattleStruct->battlerPartyOrders) + 2) = gBattleResources->bufferB[battler][3];
|
||||
}
|
||||
}
|
||||
|
||||
@ -4943,35 +4943,35 @@ static void TurnValuesCleanUp(bool8 var0)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
if (var0)
|
||||
{
|
||||
gProtectStructs[gActiveBattler].protected = FALSE;
|
||||
gProtectStructs[gActiveBattler].spikyShielded = FALSE;
|
||||
gProtectStructs[gActiveBattler].kingsShielded = FALSE;
|
||||
gProtectStructs[gActiveBattler].banefulBunkered = FALSE;
|
||||
gProtectStructs[gActiveBattler].quash = FALSE;
|
||||
gProtectStructs[i].protected = FALSE;
|
||||
gProtectStructs[i].spikyShielded = FALSE;
|
||||
gProtectStructs[i].kingsShielded = FALSE;
|
||||
gProtectStructs[i].banefulBunkered = FALSE;
|
||||
gProtectStructs[i].quash = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&gProtectStructs[gActiveBattler], 0, sizeof(struct ProtectStruct));
|
||||
memset(&gProtectStructs[i], 0, sizeof(struct ProtectStruct));
|
||||
|
||||
if (gDisableStructs[gActiveBattler].isFirstTurn)
|
||||
gDisableStructs[gActiveBattler].isFirstTurn--;
|
||||
if (gDisableStructs[i].isFirstTurn)
|
||||
gDisableStructs[i].isFirstTurn--;
|
||||
|
||||
if (gDisableStructs[gActiveBattler].rechargeTimer)
|
||||
if (gDisableStructs[i].rechargeTimer)
|
||||
{
|
||||
gDisableStructs[gActiveBattler].rechargeTimer--;
|
||||
if (gDisableStructs[gActiveBattler].rechargeTimer == 0)
|
||||
gBattleMons[gActiveBattler].status2 &= ~STATUS2_RECHARGE;
|
||||
gDisableStructs[i].rechargeTimer--;
|
||||
if (gDisableStructs[i].rechargeTimer == 0)
|
||||
gBattleMons[i].status2 &= ~STATUS2_RECHARGE;
|
||||
}
|
||||
}
|
||||
|
||||
if (gDisableStructs[gActiveBattler].substituteHP == 0)
|
||||
gBattleMons[gActiveBattler].status2 &= ~STATUS2_SUBSTITUTE;
|
||||
if (gDisableStructs[i].substituteHP == 0)
|
||||
gBattleMons[i].status2 &= ~STATUS2_SUBSTITUTE;
|
||||
|
||||
gSpecialStatuses[gActiveBattler].parentalBondState = PARENTAL_BOND_OFF;
|
||||
gSpecialStatuses[i].parentalBondState = PARENTAL_BOND_OFF;
|
||||
}
|
||||
|
||||
gSideStatuses[B_SIDE_PLAYER] &= ~(SIDE_STATUS_QUICK_GUARD | SIDE_STATUS_WIDE_GUARD | SIDE_STATUS_CRAFTY_SHIELD | SIDE_STATUS_MAT_BLOCK);
|
||||
@ -5327,7 +5327,7 @@ static void HandleEndTurn_MonFled(void)
|
||||
|
||||
static void HandleEndTurn_FinishBattle(void)
|
||||
{
|
||||
u32 i;
|
||||
u32 i, battler;
|
||||
|
||||
if (gCurrentActionFuncId == B_ACTION_TRY_FINISH || gCurrentActionFuncId == B_ACTION_FINISHED)
|
||||
{
|
||||
@ -5339,19 +5339,19 @@ static void HandleEndTurn_FinishBattle(void)
|
||||
| BATTLE_TYPE_WALLY_TUTORIAL
|
||||
| BATTLE_TYPE_FRONTIER)))
|
||||
{
|
||||
for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++)
|
||||
for (battler = 0; battler < gBattlersCount; battler++)
|
||||
{
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
|
||||
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
{
|
||||
if (gBattleResults.playerMon1Species == SPECIES_NONE)
|
||||
{
|
||||
gBattleResults.playerMon1Species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES, NULL);
|
||||
GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_NICKNAME, gBattleResults.playerMon1Name);
|
||||
gBattleResults.playerMon1Species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES, NULL);
|
||||
GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_NICKNAME, gBattleResults.playerMon1Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleResults.playerMon2Species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES, NULL);
|
||||
GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_NICKNAME, gBattleResults.playerMon2Name);
|
||||
gBattleResults.playerMon2Species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES, NULL);
|
||||
GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_NICKNAME, gBattleResults.playerMon2Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3870,7 +3870,7 @@ static void Cmd_cleareffectsonfaint(void)
|
||||
MarkBattlerForControllerExec(battler);
|
||||
}
|
||||
|
||||
FaintClearSetData(); // Effects like attractions, trapping, etc.
|
||||
FaintClearSetData(battler); // Effects like attractions, trapping, etc.
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
}
|
||||
}
|
||||
@ -6203,7 +6203,7 @@ static void Cmd_switchindataupdate(void)
|
||||
gBattleMons[battler].status2 = oldData.status2;
|
||||
}
|
||||
|
||||
SwitchInClearSetData();
|
||||
SwitchInClearSetData(battler);
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_PALACE
|
||||
&& gBattleMons[battler].maxHP / 2 >= gBattleMons[battler].hp
|
||||
@ -8873,7 +8873,7 @@ static void Cmd_various(void)
|
||||
case VARIOUS_IS_RUNNING_IMPOSSIBLE:
|
||||
{
|
||||
VARIOUS_ARGS();
|
||||
gBattleCommunication[0] = IsRunningFromBattleImpossible();
|
||||
gBattleCommunication[0] = IsRunningFromBattleImpossible(battler);
|
||||
break;
|
||||
}
|
||||
case VARIOUS_GET_MOVE_TARGET:
|
||||
@ -9096,7 +9096,7 @@ static void Cmd_various(void)
|
||||
gBattleMons[battler].hp = 0;
|
||||
SetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP, &gBattleMons[battler].hp);
|
||||
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[battler]);
|
||||
FaintClearSetData();
|
||||
FaintClearSetData(battler);
|
||||
}
|
||||
else if (GetBattlerSide(battler) == B_SIDE_PLAYER)
|
||||
{
|
||||
|
@ -849,7 +849,6 @@ void HandleAction_ActionFinished(void)
|
||||
gLastHitByType[gBattlerAttacker] = 0;
|
||||
gBattleStruct->dynamicMoveType = 0;
|
||||
gBattleScripting.moveendState = 0;
|
||||
gBattleScripting.moveendState = 0;
|
||||
gBattleCommunication[3] = 0;
|
||||
gBattleCommunication[4] = 0;
|
||||
gBattleScripting.multihitMoveEffect = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user