More missing AI logic (#5279)

* More missing AI logic

* Update battle_ai_switch_items.c

* Update battle_ai_main.c
This commit is contained in:
kittenchilly 2024-08-28 15:15:09 -05:00 committed by GitHub
parent aebbe448b8
commit f07189b1be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 6 deletions

View file

@ -857,6 +857,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
case EFFECT_COUNTER:
case EFFECT_MIRROR_COAT:
case EFFECT_METAL_BURST:
case EFFECT_FINAL_GAMBIT:
case EFFECT_GUARDIAN_OF_ALOLA:
break;
default:
RETURN_SCORE_MINUS(10);
@ -1828,6 +1830,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
break;
case EFFECT_TRICK:
case EFFECT_KNOCK_OFF:
case EFFECT_CORROSIVE_GAS:
if (aiData->abilities[battlerDef] == ABILITY_STICKY_HOLD)
ADJUST_SCORE(-10);
break;
@ -2176,6 +2179,17 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
else if (IsAbilityOfRating(aiData->abilities[battlerAtk], 5))
ADJUST_SCORE(-4);
break;
case EFFECT_DOODLE: // Same as Role Play, but also check if the partner's ability should be replaced
if (aiData->abilities[battlerAtk] == aiData->abilities[battlerDef]
|| aiData->abilities[BATTLE_PARTNER(battlerAtk)] == aiData->abilities[battlerDef]
|| aiData->abilities[battlerDef] == ABILITY_NONE
|| gAbilitiesInfo[aiData->abilities[battlerAtk]].cantBeSuppressed
|| gAbilitiesInfo[aiData->abilities[BATTLE_PARTNER(battlerAtk)]].cantBeSuppressed
|| gAbilitiesInfo[aiData->abilities[battlerDef]].cantBeCopied)
ADJUST_SCORE(-10);
else if (IsAbilityOfRating(aiData->abilities[battlerAtk], 5) || IsAbilityOfRating(aiData->abilities[BATTLE_PARTNER(battlerAtk)], 5))
ADJUST_SCORE(-4);
break;
case EFFECT_WISH:
if (gWishFutureKnock.wishCounter[battlerAtk] != 0)
ADJUST_SCORE(-10);
@ -2889,7 +2903,7 @@ static s32 AI_DoubleBattle(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
switch (atkPartnerAbility)
{
case ABILITY_ANGER_POINT:
if (gMovesInfo[move].alwaysCriticalHit == TRUE
if (gMovesInfo[move].alwaysCriticalHit == TRUE
&& BattlerStatCanRise(battlerAtkPartner, atkPartnerAbility, STAT_ATK)
&& AI_IsFaster(battlerAtk, battlerAtkPartner, move)
&& !CanIndexMoveFaintTarget(battlerAtk, battlerAtkPartner, AI_THINKING_STRUCT->movesetIndex, 1))
@ -3498,6 +3512,7 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
break;
case EFFECT_MULTI_HIT:
case EFFECT_TRIPLE_KICK:
case EFFECT_POPULATION_BOMB:
if (AI_MoveMakesContact(aiData->abilities[battlerAtk], aiData->holdEffects[battlerAtk], move)
&& aiData->abilities[battlerAtk] != ABILITY_MAGIC_GUARD
&& aiData->holdEffects[battlerDef] == HOLD_EFFECT_ROCKY_HELMET)
@ -4098,11 +4113,27 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
}
}
break;
case EFFECT_CORROSIVE_GAS:
if (CanKnockOffItem(battlerDef, aiData->items[battlerDef]))
{
switch (aiData->holdEffects[battlerDef])
{
case HOLD_EFFECT_IRON_BALL:
if (HasMoveEffect(battlerDef, EFFECT_FLING))
ADJUST_SCORE(DECENT_EFFECT);
break;
case HOLD_EFFECT_LAGGING_TAIL:
case HOLD_EFFECT_STICKY_BARB:
break;
default:
ADJUST_SCORE(DECENT_EFFECT);
break;
}
}
break;
case EFFECT_ROLE_PLAY:
if (!gAbilitiesInfo[aiData->abilities[battlerAtk]].cantBeSuppressed
&& !gAbilitiesInfo[aiData->abilities[battlerDef]].cantBeCopied
&& !IsAbilityOfRating(aiData->abilities[battlerAtk], 5)
&& IsAbilityOfRating(aiData->abilities[battlerDef], 5))
case EFFECT_DOODLE:
if (IsAbilityOfRating(aiData->abilities[battlerDef], 5))
ADJUST_SCORE(DECENT_EFFECT);
break;
case EFFECT_INGRAIN:

View file

@ -2002,7 +2002,7 @@ static u32 GetBestMonIntegrated(struct Pokemon *party, int firstId, int lastId,
}
// If ace mon is the last available Pokemon and U-Turn/Volt Switch was used - switch to the mon.
if (aceMonId != PARTY_SIZE
&& (gMovesInfo[gLastUsedMove].effect == EFFECT_HIT_ESCAPE || gMovesInfo[gLastUsedMove].effect == EFFECT_PARTING_SHOT || gMovesInfo[gLastUsedMove].effect == EFFECT_BATON_PASS || gMovesInfo[gLastUsedMove].effect == EFFECT_CHILLY_RECEPTION))
&& (gMovesInfo[gLastUsedMove].effect == EFFECT_HIT_ESCAPE || gMovesInfo[gLastUsedMove].effect == EFFECT_PARTING_SHOT || gMovesInfo[gLastUsedMove].effect == EFFECT_BATON_PASS || gMovesInfo[gLastUsedMove].effect == EFFECT_CHILLY_RECEPTION || gMovesInfo[gLastUsedMove].effect == EFFECT_SHED_TAIL))
return aceMonId;
return PARTY_SIZE;