Add failsafe to AI_DecideHoldEffectForTurn (#7849)

This commit is contained in:
Alex 2025-10-05 23:15:30 +02:00 committed by GitHub
parent 1529adba9b
commit 6cfdfd091f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1673,7 +1673,10 @@ s32 AI_DecideKnownAbilityForTurn(u32 battlerId)
enum ItemHoldEffect AI_DecideHoldEffectForTurn(u32 battlerId)
{
enum ItemHoldEffect holdEffect;
enum ItemHoldEffect holdEffect = HOLD_EFFECT_NONE;
if (gBattleMons[battlerId].item == ITEM_NONE) // Failsafe for when user recorded an item but it was consumed
return holdEffect;
if (!IsAiBattlerAware(battlerId))
holdEffect = gAiPartyData->mons[GetBattlerSide(battlerId)][gBattlerPartyIndexes[battlerId]].heldEffect;