Updated AI scores for Status moves that Dynamax Pokemon are immune to (#4523)

* Update IsDamageMoveUsable to check for Steel Roller viability

* Condense terrain flag checks and renamed IsDamageMoveUsable

IsDamageMoveUsable is now named IsDamageMoveUnusable to more accurately reflect the boolean it returns.

* Made the AI aware of when more moves will fail against Dynamax Pokemon

Turns out Dynamax Pokemon are immune to quite a few moves. The AI is only aware of one of these at present--the Low Kick/Grass Knot effect, which I learned when the AI tried to Heavy Slam my Dynamaxed Pokemon. These additional cases should prevent the AI from selecting moves that have no effect against Dynamax Pokemon, though it may still select moves whose secondary effect won't work on Dynamaxed Pokemon (such as Fake Out or Circle Throw).

* Update battle_ai_util.c

Now handles damaging moves that Dynamax Pokemon are immune to

* Update scores for Status moves Dynamax Pokemon are immune to

* Extra parentheses oops

* Update pokemon.h

Added "doesntAffectDynamax" flag to MoveInfo

* Update pokemon.h

Replaced comma with semicolon (I'm using the online editor for this lol, sorry for all the commits)

* Update moves_info.h

Set the "doesntAffectDynamax" flag to TRUE for moves that have no effect on Dynamaxed targets.

* Update battle_dynamax.c

IsMoveBlockedByDynamax now simply returns the move's "doesntAffectDynamax" flag.

* Revert "Update pokemon.h"

This reverts commit 7edde776f8fcb5aee81cd76279ceaf29b55337ff.

Revert "Update pokemon.h"

This reverts commit ed01b18d750124422702974a7c8065f5cd541644.

Revert "Update moves_info.h"

This reverts commit bc42e7bccf3294244377281e51d2a061eeb97cad.

Revert "Update battle_dynamax.c"

This reverts commit 29dbdce850f232a23cdc3024dc558bd0d8a2881a.

* Update battle_ai_main.c

Made the new conditions consistent as separate checks.

* Update battle_ai_main.c

Whitespace formatting fixes. Sorry, lost track of what I'd changed and what I hadn't.
This commit is contained in:
WillKolada 2024-05-13 04:27:17 -05:00 committed by GitHub
parent eae221b9cf
commit fdd0063b6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1418,6 +1418,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
ADJUST_SCORE(-10);
else if (aiData->abilities[battlerDef] == ABILITY_SUCTION_CUPS)
ADJUST_SCORE(-10);
else if (IsDynamaxed(battlerDef))
ADJUST_SCORE(-10);
break;
case EFFECT_TOXIC_THREAD:
if (!ShouldLowerStat(battlerDef, aiData->abilities[battlerDef], STAT_SPEED))
@ -1449,6 +1451,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
return 0;
if (!ShouldTryOHKO(battlerAtk, battlerDef, aiData->abilities[battlerAtk], aiData->abilities[battlerDef], move))
ADJUST_SCORE(-10);
else if (IsDynamaxed(battlerDef))
ADJUST_SCORE(-10);
break;
case EFFECT_MIST:
if (gSideStatuses[GetBattlerSide(battlerAtk)] & SIDE_STATUS_MIST
@ -1486,7 +1490,9 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
ADJUST_SCORE(-3);
break;
case EFFECT_DISABLE:
if (gDisableStructs[battlerDef].disableTimer == 0
if (IsDynamaxed(battlerDef))
ADJUST_SCORE(-10);
else if (gDisableStructs[battlerDef].disableTimer == 0
&& (B_MENTAL_HERB < GEN_5 || aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB)
&& !PartnerHasSameMoveEffectWithoutTarget(BATTLE_PARTNER(battlerAtk), move, aiData->partnerMove))
{
@ -1506,7 +1512,9 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
}
break;
case EFFECT_ENCORE:
if (gDisableStructs[battlerDef].encoreTimer == 0
if (IsDynamaxed(battlerDef))
ADJUST_SCORE(-10);
else if (gDisableStructs[battlerDef].encoreTimer == 0
&& (B_MENTAL_HERB < GEN_5 || aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB)
&& !DoesPartnerHaveSameMoveEffect(BATTLE_PARTNER(battlerAtk), battlerDef, move, aiData->partnerMove))
{
@ -1720,7 +1728,9 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
}
break;
case EFFECT_TORMENT:
if (gBattleMons[battlerDef].status2 & STATUS2_TORMENT
if (IsDynamaxed(battlerDef))
ADJUST_SCORE(-10);
else if (gBattleMons[battlerDef].status2 & STATUS2_TORMENT
|| DoesPartnerHaveSameMoveEffect(BATTLE_PARTNER(battlerAtk), battlerDef, move, aiData->partnerMove))
{
ADJUST_SCORE(-10);
@ -1923,6 +1933,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
case EFFECT_DESTINY_BOND:
if (gBattleMons[battlerDef].status2 & STATUS2_DESTINY_BOND)
ADJUST_SCORE(-10);
else if (IsDynamaxed(battlerDef))
ADJUST_SCORE(-10);
break;
case EFFECT_HEAL_BELL:
if (!AnyPartyMemberStatused(battlerAtk, gMovesInfo[move].soundMove) || PartnerHasSameMoveEffectWithoutTarget(BATTLE_PARTNER(battlerAtk), move, aiData->partnerMove))
@ -2119,6 +2131,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|| gAbilitiesInfo[aiData->abilities[battlerDef]].cantBeSwapped
|| aiData->holdEffects[battlerDef] == HOLD_EFFECT_ABILITY_SHIELD)
ADJUST_SCORE(-10);
else if (IsDynamaxed(battlerDef))
ADJUST_SCORE(-10);
break;
case EFFECT_WORRY_SEED:
if (aiData->abilities[battlerDef] == ABILITY_INSOMNIA
@ -2137,6 +2151,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|| gAbilitiesInfo[aiData->abilities[battlerDef]].cantBeOverwritten
|| aiData->holdEffects[battlerAtk] == HOLD_EFFECT_ABILITY_SHIELD)
ADJUST_SCORE(-10);
else if (IsDynamaxed(battlerDef))
ADJUST_SCORE(-10);
break;
case EFFECT_SIMPLE_BEAM:
if (aiData->abilities[battlerDef] == ABILITY_SIMPLE
@ -2463,6 +2479,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
{
ADJUST_SCORE(-10);
}
else if (IsDynamaxed(battlerDef))
ADJUST_SCORE(-10);
else if (isDoubleBattle)
{
if (!IS_TARGETING_PARTNER(battlerAtk, battlerDef))
@ -3344,7 +3362,7 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
if (gBattleMons[battlerDef].statStages[STAT_EVASION] < 7 || aiData->abilities[battlerAtk] == ABILITY_NO_GUARD)
ADJUST_SCORE(-2);
break;
case EFFECT_BIDE:
case EFFECT_BIDE:
if (aiData->hpPercents[battlerAtk] < 90)
ADJUST_SCORE(-2); // Should be either removed or turned into increasing score
case EFFECT_ACUPRESSURE:
@ -3365,7 +3383,10 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
score += AI_TryToClearStats(battlerAtk, battlerDef, isDoubleBattle);
break;
case EFFECT_ROAR:
if ((gMovesInfo[move].soundMove && aiData->abilities[battlerDef] == ABILITY_SOUNDPROOF) || aiData->abilities[battlerDef] == ABILITY_SUCTION_CUPS)
if ((gMovesInfo[move].soundMove && aiData->abilities[battlerDef] == ABILITY_SOUNDPROOF)
|| aiData->abilities[battlerDef] == ABILITY_SUCTION_CUPS)
break;
else if (IsDynamaxed(battlerDef))
break;
score += AI_TryToClearStats(battlerAtk, battlerDef, isDoubleBattle);
break;
@ -3450,7 +3471,9 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
}
break;
case EFFECT_OHKO:
if (gStatuses3[battlerAtk] & STATUS3_ALWAYS_HITS)
if (IsDynamaxed(battlerDef))
break;
else if (gStatuses3[battlerAtk] & STATUS3_ALWAYS_HITS)
ADJUST_SCORE(BEST_EFFECT);
break;
case EFFECT_MEAN_LOOK:
@ -3545,7 +3568,9 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
ADJUST_SCORE(BEST_EFFECT);
break;
case EFFECT_DISABLE:
if (gDisableStructs[battlerDef].disableTimer == 0
if (IsDynamaxed(battlerDef))
break;
else if (gDisableStructs[battlerDef].disableTimer == 0
&& (gLastMoves[battlerDef] != MOVE_NONE)
&& (gLastMoves[battlerDef] != 0xFFFF)
&& (B_MENTAL_HERB < GEN_5 || aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB)
@ -3556,7 +3581,9 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
}
break;
case EFFECT_ENCORE:
if (gDisableStructs[battlerDef].encoreTimer == 0
if (IsDynamaxed(battlerDef))
break;
else if (gDisableStructs[battlerDef].encoreTimer == 0
&& (B_MENTAL_HERB < GEN_5 || aiData->holdEffects[battlerDef] != HOLD_EFFECT_MENTAL_HERB)
&& (gBattleMoveEffects[gMovesInfo[gLastMoves[battlerDef]].effect].encourageEncore))
ADJUST_SCORE(BEST_EFFECT);
@ -3573,7 +3600,9 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
ADJUST_SCORE(GOOD_EFFECT);
break;
case EFFECT_DESTINY_BOND:
if (AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_FASTER && CanTargetFaintAi(battlerDef, battlerAtk))
if (IsDynamaxed(battlerDef))
break;
else if (AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_FASTER && CanTargetFaintAi(battlerDef, battlerAtk))
ADJUST_SCORE(GOOD_EFFECT);
break;
case EFFECT_SPITE:
@ -4019,7 +4048,9 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
ADJUST_SCORE(DECENT_EFFECT);
break;
case EFFECT_SKILL_SWAP:
if (gAbilitiesInfo[aiData->abilities[battlerDef]].aiRating > gAbilitiesInfo[aiData->abilities[battlerAtk]].aiRating)
if (IsDynamaxed(battlerDef))
break;
else if (gAbilitiesInfo[aiData->abilities[battlerDef]].aiRating > gAbilitiesInfo[aiData->abilities[battlerAtk]].aiRating)
ADJUST_SCORE(DECENT_EFFECT);
break;
case EFFECT_WORRY_SEED:
@ -4029,7 +4060,9 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
ADJUST_SCORE(DECENT_EFFECT);
break;
case EFFECT_ENTRAINMENT:
if ((IsAbilityOfRating(aiData->abilities[battlerDef], 5) || gAbilitiesInfo[aiData->abilities[battlerAtk]].aiRating <= 0)
if (IsDynamaxed(battlerDef))
break;
else if ((IsAbilityOfRating(aiData->abilities[battlerDef], 5) || gAbilitiesInfo[aiData->abilities[battlerAtk]].aiRating <= 0)
&& (aiData->abilities[battlerDef] != aiData->abilities[battlerAtk] && !(gStatuses3[battlerDef] & STATUS3_GASTRO_ACID)))
ADJUST_SCORE(DECENT_EFFECT);
break;