Fix GetSwitchinHitsToKO one shot heal calcs (#7502)
This commit is contained in:
parent
e778d3cdfe
commit
6158d21448
@ -1807,13 +1807,13 @@ static u32 GetSwitchinHitsToKO(s32 damageTaken, u32 battler)
|
||||
u32 recurringDamage = GetSwitchinRecurringDamage();
|
||||
u32 recurringHealing = GetSwitchinRecurringHealing();
|
||||
u32 statusDamage = GetSwitchinStatusDamage(battler);
|
||||
u32 hitsToKO = 0, singleUseItemHeal = 0;
|
||||
u32 hitsToKO = 0;
|
||||
u16 maxHP = gAiLogicData->switchinCandidate.battleMon.maxHP, item = gAiLogicData->switchinCandidate.battleMon.item, heldItemEffect = GetItemHoldEffect(item);
|
||||
u8 weatherDuration = gWishFutureKnock.weatherDuration, holdEffectParam = GetItemHoldEffectParam(item);
|
||||
u32 opposingBattler = GetOppositeBattler(battler);
|
||||
u32 opposingAbility = gAiLogicData->abilities[opposingBattler], ability = gAiLogicData->switchinCandidate.battleMon.ability;
|
||||
bool32 usedSingleUseHealingItem = FALSE, opponentCanBreakMold = IsMoldBreakerTypeAbility(opposingBattler, opposingAbility);
|
||||
s32 currentHP = startingHP;
|
||||
s32 currentHP = startingHP, singleUseItemHeal = 0;
|
||||
|
||||
// No damage being dealt
|
||||
if ((damageTaken + statusDamage + recurringDamage <= recurringHealing) || damageTaken + statusDamage + recurringDamage == 0)
|
||||
@ -1838,11 +1838,11 @@ static u32 GetSwitchinHitsToKO(s32 damageTaken, u32 battler)
|
||||
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)
|
||||
if (currentHP > 0)
|
||||
currentHP = currentHP - weatherImpact;
|
||||
|
||||
// Check if we're at a single use healing item threshold
|
||||
if (gAiLogicData->switchinCandidate.battleMon.ability != ABILITY_KLUTZ && usedSingleUseHealingItem == FALSE
|
||||
if (currentHP > 0 && gAiLogicData->switchinCandidate.battleMon.ability != ABILITY_KLUTZ && usedSingleUseHealingItem == FALSE
|
||||
&& !(opposingAbility == ABILITY_UNNERVE && GetItemPocket(item) == POCKET_BERRIES))
|
||||
{
|
||||
switch (heldItemEffect)
|
||||
@ -1885,7 +1885,7 @@ static u32 GetSwitchinHitsToKO(s32 damageTaken, u32 battler)
|
||||
}
|
||||
|
||||
// Healing from items occurs before status so we can do the rest in one line
|
||||
if (currentHP >= 0)
|
||||
if (currentHP > 0)
|
||||
currentHP = currentHP + recurringHealing - recurringDamage - statusDamage;
|
||||
|
||||
// Recalculate toxic damage if needed
|
||||
@ -1900,7 +1900,7 @@ static u32 GetSwitchinHitsToKO(s32 damageTaken, u32 battler)
|
||||
}
|
||||
|
||||
// Disguise will always add an extra hit to KO
|
||||
if (opponentCanBreakMold && gAiLogicData->switchinCandidate.battleMon.species == SPECIES_MIMIKYU_DISGUISED)
|
||||
if (!opponentCanBreakMold && gAiLogicData->switchinCandidate.battleMon.species == SPECIES_MIMIKYU_DISGUISED)
|
||||
hitsToKO++;
|
||||
|
||||
// If mon had a hypothetical status from TSpikes, clear it
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user