Switch AI hitsToKO considers one shot prevention (#5371)
* One shot prevention effects * I'm bad at brackets
This commit is contained in:
parent
551c558186
commit
e13f399a67
1 changed files with 5 additions and 1 deletions
|
@ -1609,7 +1609,7 @@ static u32 GetSwitchinHitsToKO(s32 damageTaken, u32 battler)
|
|||
u16 maxHP = AI_DATA->switchinCandidate.battleMon.maxHP, item = AI_DATA->switchinCandidate.battleMon.item, heldItemEffect = ItemId_GetHoldEffect(item);
|
||||
u8 weatherDuration = gWishFutureKnock.weatherDuration, holdEffectParam = ItemId_GetHoldEffectParam(item);
|
||||
u32 opposingBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(battler)));
|
||||
u32 opposingAbility = gBattleMons[opposingBattler].ability;
|
||||
u32 opposingAbility = gBattleMons[opposingBattler].ability, ability = AI_DATA->switchinCandidate.battleMon.ability;
|
||||
bool32 usedSingleUseHealingItem = FALSE;
|
||||
s32 currentHP = startingHP;
|
||||
|
||||
|
@ -1631,6 +1631,10 @@ static u32 GetSwitchinHitsToKO(s32 damageTaken, u32 battler)
|
|||
// Take attack damage for the turn
|
||||
currentHP = currentHP - damageTaken;
|
||||
|
||||
// One shot prevention effects
|
||||
if (damageTaken >= maxHP && currentHP == maxHP && (heldItemEffect == HOLD_EFFECT_FOCUS_SASH || (B_STURDY >= GEN_5 && ability == ABILITY_STURDY)))
|
||||
currentHP = 1;
|
||||
|
||||
// If mon is still alive, apply weather impact first, as it might KO the mon before it can heal with its item (order is weather -> item -> status)
|
||||
if (currentHP != 0)
|
||||
currentHP = currentHP - weatherImpact;
|
||||
|
|
Loading…
Reference in a new issue