Fix AI wrongly thinking it strikes first with priority even if player is using priority themselves (#6274)
This commit is contained in:
parent
b1c597495b
commit
7cd614a0cd
@ -1094,8 +1094,15 @@ s32 AI_WhoStrikesFirst(u32 battlerAI, u32 battler, u32 moveConsidered)
|
||||
u32 abilityAI = AI_DATA->abilities[battlerAI];
|
||||
u32 abilityPlayer = AI_DATA->abilities[battler];
|
||||
|
||||
if (GetMovePriority(battlerAI, moveConsidered) > 0)
|
||||
u32 predictedMove = AI_DATA->lastUsedMove[battler]; // TODO update for move prediction
|
||||
|
||||
s8 aiPriority = GetMovePriority(battlerAI, moveConsidered);
|
||||
s8 playerPriority = GetMovePriority(battler, predictedMove);
|
||||
|
||||
if (aiPriority > playerPriority)
|
||||
return AI_IS_FASTER;
|
||||
else if (aiPriority < playerPriority)
|
||||
return AI_IS_SLOWER;
|
||||
|
||||
speedBattlerAI = GetBattlerTotalSpeedStatArgs(battlerAI, abilityAI, holdEffectAI);
|
||||
speedBattler = GetBattlerTotalSpeedStatArgs(battler, abilityPlayer, holdEffectPlayer);
|
||||
|
||||
@ -831,3 +831,17 @@ AI_SINGLE_BATTLE_TEST("AI stays choice locked into moves in spite of the player'
|
||||
TURN { EXPECT_MOVE(opponent, aiMove); }
|
||||
}
|
||||
}
|
||||
|
||||
AI_SINGLE_BATTLE_TEST("AI won't use Sucker Punch if it expects a move of the same priority bracket and the opponent is faster")
|
||||
{
|
||||
GIVEN {
|
||||
ASSUME(gMovesInfo[MOVE_QUICK_ATTACK].priority == 1);
|
||||
ASSUME(gMovesInfo[MOVE_SUCKER_PUNCH].priority == 1);
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT);
|
||||
PLAYER(SPECIES_WOBBUFFET) { Speed(300); Moves(MOVE_QUICK_ATTACK); }
|
||||
OPPONENT(SPECIES_WOBBUFFET) { Speed(100); Moves(MOVE_SUCKER_PUNCH, MOVE_TACKLE); }
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_QUICK_ATTACK); EXPECT_MOVE(opponent, MOVE_SUCKER_PUNCH); }
|
||||
TURN { MOVE(player, MOVE_QUICK_ATTACK); EXPECT_MOVE(opponent, MOVE_TACKLE); }
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user