Fixed Comatose AI checks

This commit is contained in:
Eduardo Quezada 2023-03-27 09:19:48 -03:00
parent 8d8819b797
commit 0b8285737a
3 changed files with 10 additions and 4 deletions

View File

@ -144,6 +144,7 @@ bool32 AnyPartyMemberStatused(u8 battlerId, bool32 checkSoundproof);
u32 ShouldTryToFlinch(u8 battlerAtk, u8 battlerDef, u16 atkAbility, u16 defAbility, u16 move);
bool32 ShouldTrap(u8 battlerAtk, u8 battlerDef, u16 move);
bool32 IsWakeupTurn(u8 battler);
bool32 AI_IsBattlerAsleepOrComatose(u8 battlerId);
// partner logic
u16 GetAllyChosenMove(u8 battlerId);

View File

@ -974,7 +974,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
}
break;
case EFFECT_DREAM_EATER:
if (!(gBattleMons[battlerDef].status1 & STATUS1_SLEEP) || AI_DATA->abilities[battlerDef] == ABILITY_COMATOSE)
if (!AI_IsBattlerAsleepOrComatose(battlerDef))
score -= 8;
else if (effectiveness == AI_EFFECTIVENESS_x0)
score -= 10;
@ -1453,7 +1453,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break;
case EFFECT_SNORE:
case EFFECT_SLEEP_TALK:
if (IsWakeupTurn(battlerAtk) || (!(gBattleMons[battlerAtk].status1 & STATUS1_SLEEP) || AI_DATA->abilities[battlerAtk] != ABILITY_COMATOSE))
if (IsWakeupTurn(battlerAtk) || !AI_IsBattlerAsleepOrComatose(battlerAtk))
score -= 10; // if mon will wake up, is not asleep, or is not comatose
break;
case EFFECT_MEAN_LOOK:
@ -1463,7 +1463,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_NIGHTMARE:
if (gBattleMons[battlerDef].status2 & STATUS2_NIGHTMARE)
score -= 10;
else if (!(gBattleMons[battlerDef].status1 & STATUS1_SLEEP) || AI_DATA->abilities[battlerDef] == ABILITY_COMATOSE)
else if (!AI_IsBattlerAsleepOrComatose(battlerDef))
score -= 8;
else if (DoesPartnerHaveSameMoveEffect(BATTLE_PARTNER(battlerAtk), battlerDef, move, AI_DATA->partnerMove))
score -= 10;
@ -3780,7 +3780,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_NIGHTMARE:
if (AI_DATA->abilities[battlerDef] != ABILITY_MAGIC_GUARD
&& !(gBattleMons[battlerDef].status2 & STATUS2_NIGHTMARE)
&& (AI_DATA->abilities[battlerDef] == ABILITY_COMATOSE || gBattleMons[battlerDef].status1 & STATUS1_SLEEP))
&& AI_IsBattlerAsleepOrComatose(battlerDef))
{
score += 5;
if (IsBattlerTrapped(battlerDef, TRUE))

View File

@ -3749,3 +3749,8 @@ bool32 ShouldUseZMove(u8 battlerAtk, u8 battlerDef, u16 chosenMove)
return FALSE;
}
bool32 AI_IsBattlerAsleepOrComatose(u8 battlerId)
{
return (gBattleMons[battlerId].status1 & STATUS1_SLEEP) || AI_DATA->abilities[battlerId] == ABILITY_COMATOSE;
}