From 7fefe757b868e15dad292088c711a634345b59c3 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Tue, 14 May 2024 16:16:20 +0200 Subject: [PATCH] Adds AI_GetBattlerAbility (#4555) * Adds AI_GetBattlerAbility * Update src/battle_ai_util.c Co-authored-by: sneed <56992013+Sneed69@users.noreply.github.com> --------- Co-authored-by: sneed <56992013+Sneed69@users.noreply.github.com> --- src/battle_ai_util.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index aa73a7f3e7..b81705a366 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -274,7 +274,7 @@ bool32 IsBattlerTrapped(u32 battler, bool32 checkSwitch) return FALSE; if (checkSwitch && holdEffect == HOLD_EFFECT_SHED_SHELL) return FALSE; - else if (!checkSwitch && GetBattlerAbility(battler) == ABILITY_RUN_AWAY) + else if (!checkSwitch && AI_DATA->abilities[battler] == ABILITY_RUN_AWAY) return FALSE; else if (!checkSwitch && holdEffect == HOLD_EFFECT_CAN_ALWAYS_RUN) return FALSE; @@ -1107,10 +1107,26 @@ bool32 AI_IsAbilityOnSide(u32 battlerId, u32 ability) return FALSE; } +u32 AI_GetBattlerAbility(u32 battler) +{ + if (gAbilitiesInfo[gBattleMons[battler].ability].cantBeSuppressed) + return gBattleMons[battler].ability; + + if (gStatuses3[battler] & STATUS3_GASTRO_ACID) + return ABILITY_NONE; + + if (IsNeutralizingGasOnField() + && gBattleMons[battler].ability != ABILITY_NEUTRALIZING_GAS + && GetBattlerHoldEffectIgnoreAbility(battler, TRUE) != HOLD_EFFECT_ABILITY_SHIELD) + return ABILITY_NONE; + + return gBattleMons[battler].ability; +} + // does NOT include ability suppression checks s32 AI_DecideKnownAbilityForTurn(u32 battlerId) { - u32 knownAbility = GetBattlerAbility(battlerId); + u32 knownAbility = AI_GetBattlerAbility(battlerId); // We've had ability overwritten by e.g. Worry Seed. It is not part of AI_PARTY in case of switching if (gBattleStruct->overwrittenAbilities[battlerId])