Merge pull request #1855 from ghoulslash/be/abilityonside
AI versions of CanPoisonType, CanBePoisoned and IsAbilityOnSide
This commit is contained in:
commit
5eb8f1c158
3 changed files with 33 additions and 11 deletions
|
@ -54,6 +54,7 @@ bool32 IsRecycleEncouragedItem(u16 item);
|
|||
bool32 CanKnockOffItem(u8 battler, u16 item);
|
||||
bool32 IsAbilityOfRating(u16 ability, s8 rating);
|
||||
s8 GetAbilityRating(u16 ability);
|
||||
bool32 AI_IsAbilityOnSide(u32 battlerId, u32 ability);
|
||||
|
||||
// stat stage checks
|
||||
bool32 AnyStatIsRaised(u8 battlerId);
|
||||
|
@ -120,7 +121,6 @@ bool32 IsSemiInvulnerable(u8 battlerDef, u16 move);
|
|||
|
||||
// status checks
|
||||
bool32 AI_CanBeBurned(u8 battler, u16 ability);
|
||||
bool32 AI_CanBePoisoned(u8 battler, u16 ability);
|
||||
bool32 AI_CanBeConfused(u8 battler, u16 ability);
|
||||
bool32 AI_CanSleep(u8 battler, u16 ability);
|
||||
bool32 IsBattlerIncapacitated(u8 battler, u16 ability);
|
||||
|
|
|
@ -3999,7 +3999,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
|||
score += 2;
|
||||
break;
|
||||
case HOLD_EFFECT_TOXIC_ORB:
|
||||
if (!ShouldPoisonSelf(battlerAtk, AI_DATA->atkAbility) && AI_CanBePoisoned(battlerDef, AI_DATA->defAbility))
|
||||
if (!ShouldPoisonSelf(battlerAtk, AI_DATA->atkAbility))
|
||||
score += 2;
|
||||
break;
|
||||
case HOLD_EFFECT_FLAME_ORB:
|
||||
|
|
|
@ -1082,6 +1082,16 @@ bool32 CanTargetFaintAiWithMod(u8 battlerDef, u8 battlerAtk, s32 hpMod, s32 dmgM
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 AI_IsAbilityOnSide(u32 battlerId, u32 ability)
|
||||
{
|
||||
if (IsBattlerAlive(battlerId) && AI_GetAbility(battlerId) == ability)
|
||||
return TRUE;
|
||||
else if (IsBattlerAlive(BATTLE_PARTNER(battlerId)) && AI_GetAbility(BATTLE_PARTNER(battlerId)) == ability)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// does NOT include ability suppression checks
|
||||
s32 AI_GetAbility(u32 battlerId)
|
||||
{
|
||||
|
@ -2629,20 +2639,32 @@ bool32 AI_CanPutToSleep(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 AI_CanBePoisoned(u8 battler, u16 ability)
|
||||
static bool32 AI_CanPoisonType(u8 battlerAttacker, u8 battlerTarget)
|
||||
{
|
||||
if (ability == ABILITY_IMMUNITY
|
||||
|| IsAbilityOnSide(battler, ABILITY_PASTEL_VEIL)
|
||||
|| gBattleMons[battler].status1 & STATUS1_ANY
|
||||
|| IsAbilityStatusProtected(battler)
|
||||
|| gSideStatuses[GetBattlerSide(battler)] & SIDE_STATUS_SAFEGUARD)
|
||||
return ((AI_GetAbility(battlerAttacker) == ABILITY_CORROSION && gBattleMoves[gCurrentMove].split == SPLIT_STATUS)
|
||||
|| !(IS_BATTLER_OF_TYPE(battlerTarget, TYPE_POISON) || IS_BATTLER_OF_TYPE(battlerTarget, TYPE_STEEL)));
|
||||
}
|
||||
|
||||
static bool32 AI_CanBePoisoned(u8 battlerAtk, u8 battlerDef)
|
||||
{
|
||||
u16 ability = AI_GetAbility(battlerDef);
|
||||
|
||||
if (!(AI_CanPoisonType(battlerAtk, battlerDef))
|
||||
|| gSideStatuses[GetBattlerSide(battlerDef)] & SIDE_STATUS_SAFEGUARD
|
||||
|| gBattleMons[battlerDef].status1 & STATUS1_ANY
|
||||
|| ability == ABILITY_IMMUNITY
|
||||
|| ability == ABILITY_COMATOSE
|
||||
|| AI_IsAbilityOnSide(battlerDef, ABILITY_PASTEL_VEIL)
|
||||
|| gBattleMons[battlerDef].status1 & STATUS1_ANY
|
||||
|| IsAbilityStatusProtected(battlerDef)
|
||||
|| AI_IsTerrainAffected(battlerDef, STATUS_FIELD_MISTY_TERRAIN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool32 ShouldPoisonSelf(u8 battler, u16 ability)
|
||||
{
|
||||
if (AI_CanBePoisoned(battler, ability) && (
|
||||
if (AI_CanBePoisoned(battler, battler) && (
|
||||
ability == ABILITY_MARVEL_SCALE
|
||||
|| ability == ABILITY_POISON_HEAL
|
||||
|| ability == ABILITY_QUICK_FEET
|
||||
|
@ -2657,7 +2679,7 @@ bool32 ShouldPoisonSelf(u8 battler, u16 ability)
|
|||
|
||||
bool32 AI_CanPoison(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u16 partnerMove)
|
||||
{
|
||||
if (!AI_CanBePoisoned(battlerDef, defAbility)
|
||||
if (!AI_CanBePoisoned(battlerAtk, battlerDef)
|
||||
|| AI_GetMoveEffectiveness(move, battlerAtk, battlerDef) == AI_EFFECTIVENESS_x0
|
||||
|| DoesSubstituteBlockMove(battlerAtk, battlerDef, move)
|
||||
|| PartnerMoveEffectIsStatusSameTarget(BATTLE_PARTNER(battlerAtk), battlerDef, partnerMove))
|
||||
|
@ -2760,7 +2782,7 @@ bool32 AI_CanBeInfatuated(u8 battlerAtk, u8 battlerDef, u16 defAbility, u8 atkGe
|
|||
|| atkGender == defGender
|
||||
|| atkGender == MON_GENDERLESS
|
||||
|| defGender == MON_GENDERLESS
|
||||
|| IsAbilityOnSide(battlerDef, ABILITY_AROMA_VEIL))
|
||||
|| AI_IsAbilityOnSide(battlerDef, ABILITY_AROMA_VEIL))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue