|
|
|
|
@@ -323,7 +323,7 @@ void HandleAction_UseMove(void)
|
|
|
|
|
{
|
|
|
|
|
gCurrentMove = gBattleStruct->zmove.toBeUsed[gBattlerAttacker];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
moveTarget = GetBattlerMoveTargetType(gBattlerAttacker, gCurrentMove);
|
|
|
|
|
|
|
|
|
|
if (gBattleMons[gBattlerAttacker].hp != 0)
|
|
|
|
|
@@ -909,9 +909,8 @@ void HandleAction_NothingIsFainted(void)
|
|
|
|
|
void HandleAction_ActionFinished(void)
|
|
|
|
|
{
|
|
|
|
|
#if B_RECALC_TURN_AFTER_ACTIONS >= GEN_8
|
|
|
|
|
u8 i, j;
|
|
|
|
|
u8 battler1 = 0;
|
|
|
|
|
u8 battler2 = 0;
|
|
|
|
|
u32 i, j;
|
|
|
|
|
bool32 afterYouActive = gSpecialStatuses[gBattlerByTurnOrder[gCurrentTurnActionNumber + 1]].afterYou;
|
|
|
|
|
#endif
|
|
|
|
|
*(gBattleStruct->monToSwitchIntoId + gBattlerByTurnOrder[gCurrentTurnActionNumber]) = PARTY_SIZE;
|
|
|
|
|
gCurrentTurnActionNumber++;
|
|
|
|
|
@@ -938,29 +937,32 @@ void HandleAction_ActionFinished(void)
|
|
|
|
|
gBattleResources->battleScriptsStack->size = 0;
|
|
|
|
|
|
|
|
|
|
#if B_RECALC_TURN_AFTER_ACTIONS >= GEN_8
|
|
|
|
|
// i starts at `gCurrentTurnActionNumber` because we don't want to recalculate turn order for mon that have already
|
|
|
|
|
// taken action. It's been previously increased, which we want in order to not recalculate the turn of the mon that just finished its action
|
|
|
|
|
for (i = gCurrentTurnActionNumber; i < gBattlersCount - 1; i++)
|
|
|
|
|
if (!afterYouActive)
|
|
|
|
|
{
|
|
|
|
|
for (j = i + 1; j < gBattlersCount; j++)
|
|
|
|
|
// i starts at `gCurrentTurnActionNumber` because we don't want to recalculate turn order for mon that have already
|
|
|
|
|
// taken action. It's been previously increased, which we want in order to not recalculate the turn of the mon that just finished its action
|
|
|
|
|
for (i = gCurrentTurnActionNumber; i < gBattlersCount - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
u8 battler1 = gBattlerByTurnOrder[i];
|
|
|
|
|
u8 battler2 = gBattlerByTurnOrder[j];
|
|
|
|
|
|
|
|
|
|
if (gProtectStructs[battler1].quash || gProtectStructs[battler2].quash)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// We recalculate order only for action of the same priority. If any action other than switch/move has been taken, they should
|
|
|
|
|
// have been executed before. The only recalculation needed is for moves/switch. Mega evolution is handled in src/battle_main.c/TryChangeOrder
|
|
|
|
|
if((gActionsByTurnOrder[i] == B_ACTION_USE_MOVE && gActionsByTurnOrder[j] == B_ACTION_USE_MOVE))
|
|
|
|
|
for (j = i + 1; j < gBattlersCount; j++)
|
|
|
|
|
{
|
|
|
|
|
if (GetWhoStrikesFirst(battler1, battler2, FALSE))
|
|
|
|
|
SwapTurnOrder(i, j);
|
|
|
|
|
}
|
|
|
|
|
else if ((gActionsByTurnOrder[i] == B_ACTION_SWITCH && gActionsByTurnOrder[j] == B_ACTION_SWITCH))
|
|
|
|
|
{
|
|
|
|
|
if (GetWhoStrikesFirst(battler1, battler2, TRUE)) // If the actions chosen are switching, we recalc order but ignoring the moves
|
|
|
|
|
SwapTurnOrder(i, j);
|
|
|
|
|
u8 battler1 = gBattlerByTurnOrder[i];
|
|
|
|
|
u8 battler2 = gBattlerByTurnOrder[j];
|
|
|
|
|
|
|
|
|
|
if (gProtectStructs[battler1].quash || gProtectStructs[battler2].quash)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// We recalculate order only for action of the same priority. If any action other than switch/move has been taken, they should
|
|
|
|
|
// have been executed before. The only recalculation needed is for moves/switch. Mega evolution is handled in src/battle_main.c/TryChangeOrder
|
|
|
|
|
if((gActionsByTurnOrder[i] == B_ACTION_USE_MOVE && gActionsByTurnOrder[j] == B_ACTION_USE_MOVE))
|
|
|
|
|
{
|
|
|
|
|
if (GetWhoStrikesFirst(battler1, battler2, FALSE))
|
|
|
|
|
SwapTurnOrder(i, j);
|
|
|
|
|
}
|
|
|
|
|
else if ((gActionsByTurnOrder[i] == B_ACTION_SWITCH && gActionsByTurnOrder[j] == B_ACTION_SWITCH))
|
|
|
|
|
{
|
|
|
|
|
if (GetWhoStrikesFirst(battler1, battler2, TRUE)) // If the actions chosen are switching, we recalc order but ignoring the moves
|
|
|
|
|
SwapTurnOrder(i, j);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|