Fix After You for gen8 (#2646)

Fix After You
This commit is contained in:
DizzyEggg 2023-02-16 21:59:36 +01:00 committed by GitHub
parent 6b08120d5f
commit d637ee3b13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 26 deletions

View File

@ -191,6 +191,7 @@ struct SpecialStatus
u8 weatherAbilityDone:1;
u8 terrainAbilityDone:1;
u8 emergencyExited:1;
u8 afterYou:1;
};
struct SideTimer

View File

@ -9394,7 +9394,7 @@ static void Cmd_various(void)
break;
case VARIOUS_AFTER_YOU:
if (GetBattlerTurnOrderNum(gBattlerAttacker) > GetBattlerTurnOrderNum(gBattlerTarget)
|| GetBattlerTurnOrderNum(gBattlerAttacker) == GetBattlerTurnOrderNum(gBattlerTarget) + 1)
|| GetBattlerTurnOrderNum(gBattlerAttacker) + 1 == GetBattlerTurnOrderNum(gBattlerTarget))
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
}
@ -9419,6 +9419,7 @@ static void Cmd_various(void)
gBattlerByTurnOrder[2] = gBattlerTarget;
gBattlerByTurnOrder[3] = data[2];
}
gSpecialStatuses[gBattlerTarget].afterYou = 1;
gBattlescriptCurrInstr += 7;
}
return;

View File

@ -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,6 +937,8 @@ void HandleAction_ActionFinished(void)
gBattleResources->battleScriptsStack->size = 0;
#if B_RECALC_TURN_AFTER_ACTIONS >= GEN_8
if (!afterYouActive)
{
// 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++)
@ -964,6 +965,7 @@ void HandleAction_ActionFinished(void)
}
}
}
}
#endif
}

View File

@ -8,7 +8,6 @@ ASSUMPTIONS
DOUBLE_BATTLE_TEST("After You makes the target move after user")
{
if (B_RECALC_TURN_AFTER_ACTIONS >= GEN_8) KNOWN_FAILING; // #2615.
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Speed(4); }
PLAYER(SPECIES_WYNAUT) { Speed(1); }