Fix switchin KO threshold logic (#8370)
Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
This commit is contained in:
parent
d9aac4f12a
commit
f42117a9d8
@ -2240,7 +2240,7 @@ static u32 GetBestMonIntegrated(struct Pokemon *party, int firstId, int lastId,
|
||||
|
||||
// Check if current mon can revenge kill in some capacity
|
||||
// If AI mon can one shot
|
||||
if (damageDealt > playerMonHP)
|
||||
if (damageDealt >= playerMonHP)
|
||||
{
|
||||
if (canSwitchinWin1v1)
|
||||
{
|
||||
@ -2252,7 +2252,7 @@ static u32 GetBestMonIntegrated(struct Pokemon *party, int firstId, int lastId,
|
||||
}
|
||||
|
||||
// If AI mon can two shot
|
||||
if (damageDealt > playerMonHP / 2)
|
||||
if (damageDealt >= (playerMonHP / 2 + playerMonHP % 2)) // Modulo to handle odd numbers in non-decimal division
|
||||
{
|
||||
if (canSwitchinWin1v1)
|
||||
{
|
||||
|
||||
@ -1459,3 +1459,23 @@ AI_SINGLE_BATTLE_TEST("AI_FLAG_SMART_MON_CHOICES: AI will consider choice-locked
|
||||
TURN { MOVE(player, MOVE_MIGHTY_CLEAVE); EXPECT_MOVE(opponent, MOVE_TACKLE); item == ITEM_NONE ? EXPECT_SEND_OUT(opponent, 1) : EXPECT_SEND_OUT(opponent, 2); }
|
||||
}
|
||||
}
|
||||
|
||||
AI_SINGLE_BATTLE_TEST("AI_FLAG_SMART_MON_CHOICES: AI considers both meeting and exceeding KO thresholds correctly")
|
||||
{
|
||||
u32 hp;
|
||||
PARAMETRIZE { hp = 40; }
|
||||
PARAMETRIZE { hp = 80; }
|
||||
PARAMETRIZE { hp = 79; }
|
||||
PARAMETRIZE { hp = 81; }
|
||||
GIVEN {
|
||||
ASSUME(GetMoveEffect(MOVE_DRAGON_RAGE) == EFFECT_FIXED_HP_DAMAGE);
|
||||
ASSUME(GetMoveFixedHPDamage(MOVE_DRAGON_RAGE) == 40);
|
||||
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_TRY_TO_FAINT | AI_FLAG_CHECK_VIABILITY | AI_FLAG_SMART_SWITCHING | AI_FLAG_SMART_MON_CHOICES | AI_FLAG_OMNISCIENT);
|
||||
PLAYER(SPECIES_ZIGZAGOON) { Speed(5); HP(hp); Moves(MOVE_PROTECT, MOVE_TACKLE); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Speed(6); Moves(MOVE_EXPLOSION); }
|
||||
OPPONENT(SPECIES_ZIGZAGOON) { Speed(6); Moves(MOVE_DRAGON_RAGE); }
|
||||
OPPONENT(SPECIES_BELDUM) { Speed(4); Moves(MOVE_TACKLE); }
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_PROTECT); EXPECT_MOVE(opponent, MOVE_EXPLOSION); hp > 80 ? EXPECT_SEND_OUT(opponent, 2) : EXPECT_SEND_OUT(opponent, 1); }
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user