update semi invulnerable state check

This commit is contained in:
Evan 2021-02-12 08:57:57 -07:00
parent 1405f04e1e
commit 4782f713f2
3 changed files with 17 additions and 9 deletions

View File

@ -115,6 +115,7 @@ bool32 IsStatLoweringEffect(u16 effect);
bool32 IsStatRaisingEffect(u16 effect);
bool32 IsAttackBoostMoveEffect(u16 effect);
bool32 IsUngroundingEffect(u16 effect);
bool32 IsSemiInvulnerable(u8 battlerDef, u16 move);
// status checks
bool32 CanBeBurned(u8 battler, u16 ability);

View File

@ -547,7 +547,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
}
// check off screen
if (gStatuses3[battlerDef] & STATUS3_SEMI_INVULNERABLE && GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) != 1)
if (IsSemiInvulnerable(battlerDef, move) && effect != EFFECT_SEMI_INVULNERABLE && GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) != 1)
RETURN_SCORE_MINUS(20); // if target off screen and we go first, don't use move
// check if negates type

View File

@ -1339,16 +1339,23 @@ u32 AI_GetMoveAccuracy(u8 battlerAtk, u8 battlerDef, u16 atkAbility, u16 defAbil
return calc;
}
bool32 IsSemiInvulnerable(u8 battlerDef, u16 move)
{
if (gStatuses3[battlerDef] & STATUS3_PHANTOM_FORCE)
return TRUE;
else if (!TestMoveFlags(move, FLAG_HIT_IN_AIR) && gStatuses3[battlerDef] & STATUS3_ON_AIR)
return TRUE;
else if (!TestMoveFlags(move, FLAG_DMG_UNDERWATER) && gStatuses3[battlerDef] & STATUS3_UNDERWATER)
return TRUE;
else if (!TestMoveFlags(move, FLAG_DMG_UNDERGROUND) && gStatuses3[battlerDef] & STATUS3_UNDERGROUND)
return TRUE;
else
return FALSE;
}
bool32 IsMoveEncouragedToHit(u8 battlerAtk, u8 battlerDef, u16 move)
{
// never hits
if (gStatuses3[battlerDef] & (STATUS3_SEMI_INVULNERABLE))
return FALSE;
if ((gStatuses3[battlerDef] & STATUS3_PHANTOM_FORCE)
|| (!TestMoveFlags(move, FLAG_HIT_IN_AIR) && gStatuses3[battlerDef] & STATUS3_ON_AIR)
|| (!TestMoveFlags(move, FLAG_DMG_UNDERGROUND) && gStatuses3[battlerDef] & STATUS3_UNDERGROUND)
|| (!TestMoveFlags(move, FLAG_DMG_UNDERWATER) && gStatuses3[battlerDef] & STATUS3_UNDERWATER))
if (IsSemiInvulnerable(battlerDef, move))
return FALSE;
//TODO - anticipate protect move?