From a26a47cab870ec90319c27c70dd75da30aa836f1 Mon Sep 17 00:00:00 2001 From: hedara90 <90hedara@gmail.com> Date: Tue, 11 Mar 2025 13:58:49 +0100 Subject: [PATCH] Fixed AI_FLAG_CHECK_VIABILITY changing the toxic counter in some cases (#6402) Co-authored-by: Hedara --- src/battle_ai_util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index f7b5ab9c64..60b707808f 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -2634,12 +2634,13 @@ static u32 GetPoisonDamage(u32 battlerId) } else if (gBattleMons[battlerId].status1 & STATUS1_TOXIC_POISON) { + u32 status1Temp = gBattleMons[battlerId].status1; damage = gBattleMons[battlerId].maxHP / 16; if (damage == 0) damage = 1; - if ((gBattleMons[battlerId].status1 & STATUS1_TOXIC_COUNTER) != STATUS1_TOXIC_TURN(15)) // not 16 turns - gBattleMons[battlerId].status1 += STATUS1_TOXIC_TURN(1); - damage *= (gBattleMons[battlerId].status1 & STATUS1_TOXIC_COUNTER) >> 8; + if ((status1Temp & STATUS1_TOXIC_COUNTER) != STATUS1_TOXIC_TURN(15)) // not 16 turns + status1Temp += STATUS1_TOXIC_TURN(1); + damage *= (status1Temp & STATUS1_TOXIC_COUNTER) >> 8; } return damage; }