Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Serene Grace checks in AI_CheckViability #2218

Merged
merged 2 commits into from
Sep 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2976,6 +2976,8 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
u16 predictedMove = AI_DATA->predictedMoves[battlerDef];
bool32 isDoubleBattle = IsValidDoubleBattle(battlerAtk);
u32 i;
// We only check for moves that have a 20% chance or more for their secondary effect to happen because moves with a smaller chance are rather worthless. We don't want the AI to use those.
bool32 sereneGraceBoost = (AI_DATA->abilities[battlerAtk] == ABILITY_SERENE_GRACE && (gBattleMoves[move].secondaryEffectChance >= 20 && gBattleMoves[move].secondaryEffectChance < 100));

// Targeting partner, check benefits of doing that instead
if (IsTargetingPartner(battlerAtk, battlerDef))
Expand Down Expand Up @@ -3434,7 +3436,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score += 2;
break;
case EFFECT_CONFUSE_HIT:
if (AI_DATA->abilities[battlerAtk] == ABILITY_SERENE_GRACE)
if (sereneGraceBoost)
score++;
//fallthrough
case EFFECT_CONFUSE:
Expand All @@ -3453,20 +3455,18 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_SPECIAL_DEFENSE_DOWN_HIT:
case EFFECT_ACCURACY_DOWN_HIT:
case EFFECT_EVASION_DOWN_HIT:
if (AI_DATA->abilities[battlerAtk] == ABILITY_SERENE_GRACE && AI_DATA->abilities[battlerDef] != ABILITY_CONTRARY)
if (sereneGraceBoost && AI_DATA->abilities[battlerDef] != ABILITY_CONTRARY)
score += 2;
break;
case EFFECT_SPEED_DOWN_HIT:
if (WillAIStrikeFirst())
score -= 2;
else if (!AI_RandLessThan(70))
score++;
if (AI_DATA->abilities[battlerAtk] == ABILITY_SERENE_GRACE && AI_DATA->abilities[battlerDef] != ABILITY_CONTRARY)
score++;
if (ShouldLowerSpeed(battlerAtk, battlerDef, AI_DATA->abilities[battlerDef]))
{
if (AI_DATA->abilities[battlerAtk] == ABILITY_SERENE_GRACE && AI_DATA->abilities[battlerDef] != ABILITY_CONTRARY)
score += 4;
if (sereneGraceBoost && AI_DATA->abilities[battlerDef] != ABILITY_CONTRARY)
score += 5;
else
score += 2;
}
Expand Down Expand Up @@ -3597,7 +3597,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score++;
break;
case EFFECT_SPEED_UP_HIT:
if (AI_DATA->abilities[battlerAtk] == ABILITY_SERENE_GRACE && AI_DATA->abilities[battlerDef] != ABILITY_CONTRARY && !WillAIStrikeFirst())
if (sereneGraceBoost && AI_DATA->abilities[battlerDef] != ABILITY_CONTRARY && !WillAIStrikeFirst())
score += 3;
break;
case EFFECT_DESTINY_BOND:
Expand Down Expand Up @@ -3841,7 +3841,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
}
break;
case EFFECT_ATTACK_UP_HIT:
if (AI_DATA->abilities[battlerAtk] == ABILITY_SERENE_GRACE)
if (sereneGraceBoost)
IncreaseStatUpScore(battlerAtk, battlerDef, STAT_ATK, &score);
break;
case EFFECT_FELL_STINGER:
Expand Down