Tidy up CanTargetFaintAiWithMod and CanTargetMoveFaintAi (#7693)
Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
This commit is contained in:
parent
1e6a533131
commit
6e18c2f06e
@ -1559,7 +1559,8 @@ bool32 CanTargetMoveFaintAi(u32 move, u32 battlerDef, u32 battlerAtk, u32 nHits)
|
||||
u32 indexSlot = GetMoveSlot(GetMovesArray(battlerDef), move);
|
||||
if (indexSlot < MAX_MON_MOVES)
|
||||
{
|
||||
if (GetNoOfHitsToKO(AI_GetDamage(battlerDef, battlerAtk, indexSlot, AI_DEFENDING, gAiLogicData), gBattleMons[battlerAtk].hp) <= nHits)
|
||||
u32 hitsToKO = GetNoOfHitsToKO(AI_GetDamage(battlerDef, battlerAtk, indexSlot, AI_DEFENDING, gAiLogicData), gBattleMons[battlerAtk].hp);
|
||||
if (hitsToKO <= nHits && hitsToKO != 0 && !(CanEndureHit(battlerDef, battlerAtk, move) && hitsToKO == 1))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@ -1588,8 +1589,15 @@ bool32 CanTargetFaintAiWithMod(u32 battlerDef, u32 battlerAtk, s32 hpMod, s32 dm
|
||||
if (dmgMod)
|
||||
dmg *= dmgMod;
|
||||
|
||||
if (dmg >= hpCheck)
|
||||
// Applies modified HP percent to AI data for consideration when running CanEndureHit
|
||||
gAiLogicData->hpPercents[battlerAtk] = (hpCheck/gBattleMons[battlerAtk].maxHP)*100;
|
||||
|
||||
if (dmg >= hpCheck && !(CanEndureHit(battlerDef, battlerAtk, moves[moveIndex]) && (dmgMod <= 1)))
|
||||
{
|
||||
gAiLogicData->hpPercents[battlerAtk] = (gBattleMons[battlerAtk].hp / gBattleMons[battlerAtk].maxHP) * 100;
|
||||
return TRUE;
|
||||
}
|
||||
gAiLogicData->hpPercents[battlerAtk] = (gBattleMons[battlerAtk].hp / gBattleMons[battlerAtk].maxHP) * 100;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user