Fixed an issue related to same turn Encore targeting (#8230)

Co-authored-by: LinathanZel <LinathanZel@github.com>
This commit is contained in:
Linathan 2025-11-13 05:37:17 -05:00 committed by GitHub
parent db9460c670
commit 8c83a25676
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

5
include/battle.h Normal file → Executable file
View File

@ -1249,4 +1249,9 @@ static inline bool32 IsBattlerInvalidForSpreadMove(u32 battlerAtk, u32 battlerDe
|| (battlerDef == BATTLE_PARTNER(battlerAtk) && (moveTarget == MOVE_TARGET_BOTH));
}
static inline u32 GetChosenMoveFromPosition(u32 battler)
{
return gBattleMons[battler].moves[gBattleStruct->chosenMovePositions[battler]];
}
#endif // GUARD_BATTLE_H

View File

@ -11519,6 +11519,13 @@ static void Cmd_trysetencore(void)
{
gDisableStructs[gBattlerTarget].encoredMove = gBattleMons[gBattlerTarget].moves[i];
gDisableStructs[gBattlerTarget].encoredMovePos = i;
// If the target's selected move is not the same as the move being Encored into,
// the target will select a random opposing target
// Redirection such as Follow Me is already covered in HandleAction_UseMove of battle_util.c
if (gDisableStructs[gBattlerTarget].encoredMove != GetChosenMoveFromPosition(gBattlerTarget))
gBattleStruct->moveTarget[gBattlerTarget] = SetRandomTarget(gBattlerTarget);
// Encore always lasts 3 turns, but we need to account for a scenario where Encore changes the move during the same turn.
if (HasBattlerActedThisTurn(gBattlerTarget))
gDisableStructs[gBattlerTarget].encoreTimer = 4;