From c360900a5b19e63d89f2fa44f927a485e4b68bbf Mon Sep 17 00:00:00 2001 From: surskitty Date: Sat, 5 Jul 2025 07:46:23 -0400 Subject: [PATCH] Renaming STATUS1_REFRESH and adding more constants for common STATUS1 checks. (#7284) --- include/constants/battle.h | 5 ++++- src/battle_ai_main.c | 10 +++++----- src/battle_ai_switch_items.c | 5 ++--- src/battle_ai_util.c | 4 ++-- src/battle_script_commands.c | 6 +++--- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/constants/battle.h b/include/constants/battle.h index 2ebf99ebce..e785498489 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -132,7 +132,10 @@ enum BattlerId #define STATUS1_PSN_ANY (STATUS1_POISON | STATUS1_TOXIC_POISON) #define STATUS1_ANY (STATUS1_SLEEP | STATUS1_POISON | STATUS1_BURN | STATUS1_FREEZE | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON | STATUS1_FROSTBITE) -#define STATUS1_REFRESH (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON | STATUS1_FROSTBITE) +#define STATUS1_CAN_MOVE (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON | STATUS1_FROSTBITE) +#define STATUS1_INCAPACITATED (STATUS1_SLEEP | STATUS1_FREEZE) +#define STATUS1_ICY_ANY (STATUS1_FREEZE | STATUS1_FROSTBITE) +#define STATUS1_DAMAGING (STATUS1_PSN_ANY | STATUS1_BURN | STATUS1_FROSTBITE) enum VolatileFlags { diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 78693b1950..751402af43 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -1059,7 +1059,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) } // Don't use anything but super effective thawing moves if target is frozen if any other attack available - if (((GetMoveType(move) == TYPE_FIRE && GetMovePower(move) != 0) || CanBurnHitThaw(move)) && effectiveness < UQ_4_12(2.0) && (gBattleMons[battlerDef].status1 & (STATUS1_FROSTBITE | STATUS1_FREEZE))) + if (((GetMoveType(move) == TYPE_FIRE && GetMovePower(move) != 0) || CanBurnHitThaw(move)) && effectiveness < UQ_4_12(2.0) && (gBattleMons[battlerDef].status1 & STATUS1_ICY_ANY)) { u32 aiMove; for (i = 0; i < MAX_MON_MOVES; i++) @@ -2029,7 +2029,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) ADJUST_SCORE(-10); break; case EFFECT_REFRESH: - if (!(gBattleMons[battlerDef].status1 & (STATUS1_PSN_ANY | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_FROSTBITE))) + if (!(gBattleMons[battlerDef].status1 & STATUS1_CAN_MOVE)) ADJUST_SCORE(-10); break; case EFFECT_PSYCHO_SHIFT: @@ -2085,7 +2085,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) case EFFECT_BIDE: if (!HasDamagingMove(battlerDef) || aiData->hpPercents[battlerAtk] < 30 //Close to death - || gBattleMons[battlerDef].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) //No point in biding if can't take damage + || gBattleMons[battlerDef].status1 & STATUS1_INCAPACITATED) //No point in biding if can't take damage ADJUST_SCORE(-10); break; case EFFECT_HIT_SWITCH_TARGET: @@ -2565,7 +2565,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) && GetMoveEffect(aiData->partnerMove) == EFFECT_PLEDGE && move != aiData->partnerMove) // Different pledge moves { - if (gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) + if (gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & STATUS1_INCAPACITATED) // && gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 != 1) // Will wake up this turn - how would AI know ADJUST_SCORE(-10); // Don't use combo move if your partner will cause failure } @@ -3835,7 +3835,7 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move) ADJUST_SCORE(10); // check thawing moves - if ((gBattleMons[battlerAtk].status1 & (STATUS1_FREEZE | STATUS1_FROSTBITE)) && MoveThawsUser(move)) + if (gBattleMons[battlerAtk].status1 & STATUS1_ICY_ANY && MoveThawsUser(move)) ADJUST_SCORE(10); // check burn / frostbite diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index dde7434155..550a2f91f7 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -2395,12 +2395,11 @@ static bool32 ShouldUseItem(u32 battler) case EFFECT_ITEM_CURE_STATUS: if (itemEffects[3] & ITEM3_SLEEP && gBattleMons[battler].status1 & STATUS1_SLEEP) shouldUse = TRUE; - if (itemEffects[3] & ITEM3_POISON && (gBattleMons[battler].status1 & STATUS1_POISON - || gBattleMons[battler].status1 & STATUS1_TOXIC_POISON)) + if (itemEffects[3] & ITEM3_POISON && gBattleMons[battler].status1 & STATUS1_PSN_ANY) shouldUse = TRUE; if (itemEffects[3] & ITEM3_BURN && gBattleMons[battler].status1 & STATUS1_BURN) shouldUse = TRUE; - if (itemEffects[3] & ITEM3_FREEZE && (gBattleMons[battler].status1 & STATUS1_FREEZE || gBattleMons[battler].status1 & STATUS1_FROSTBITE)) + if (itemEffects[3] & ITEM3_FREEZE && gBattleMons[battler].status1 & STATUS1_ICY_ANY) shouldUse = TRUE; if (itemEffects[3] & ITEM3_PARALYSIS && gBattleMons[battler].status1 & STATUS1_PARALYSIS) shouldUse = TRUE; diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 88b4e3b065..645a34beba 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -1870,7 +1870,7 @@ bool32 ShouldSetSnow(u32 battler, u32 ability, enum ItemHoldEffect holdEffect) bool32 IsBattlerDamagedByStatus(u32 battler) { - return gBattleMons[battler].status1 & (STATUS1_BURN | STATUS1_FROSTBITE | STATUS1_POISON | STATUS1_TOXIC_POISON) + return gBattleMons[battler].status1 & STATUS1_DAMAGING || gBattleMons[battler].status2 & (STATUS2_WRAPPED | STATUS2_NIGHTMARE | STATUS2_CURSED) || gStatuses3[battler] & (STATUS3_PERISH_SONG | STATUS3_LEECHSEED) || gStatuses4[battler] & (STATUS4_SALT_CURE) @@ -4809,7 +4809,7 @@ u32 IncreaseSubstituteMoveScore(u32 battlerAtk, u32 battlerDef, u32 move) if (gBattleMons[battlerDef].status1 & STATUS1_SLEEP) scoreIncrease += GOOD_EFFECT; - else if (gBattleMons[battlerDef].status1 & (STATUS1_BURN | STATUS1_PSN_ANY | STATUS1_FROSTBITE)) + else if (gBattleMons[battlerDef].status1 & STATUS1_DAMAGING) scoreIncrease += DECENT_EFFECT; if (IsBattlerPredictedToSwitch(battlerDef)) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e49d824d75..7138ad9803 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -14687,7 +14687,7 @@ static void Cmd_curestatuswithmove(void) u32 shouldHeal; if (GetMoveEffect(gCurrentMove) == EFFECT_REFRESH) - shouldHeal = gBattleMons[gBattlerAttacker].status1 & STATUS1_REFRESH; + shouldHeal = gBattleMons[gBattlerAttacker].status1 & STATUS1_CAN_MOVE; else // Take Heart shouldHeal = gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY; @@ -15871,9 +15871,9 @@ static void Cmd_handleballthrow(void) * (gBattleMons[gBattlerTarget].maxHP * 3 - gBattleMons[gBattlerTarget].hp * 2) / (3 * gBattleMons[gBattlerTarget].maxHP); - if (gBattleMons[gBattlerTarget].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) + if (gBattleMons[gBattlerTarget].status1 & STATUS1_INCAPACITATED) odds *= 2; - if (gBattleMons[gBattlerTarget].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON | STATUS1_FROSTBITE)) + if (gBattleMons[gBattlerTarget].status1 & STATUS1_CAN_MOVE) odds = (odds * 15) / 10; if (gBattleResults.catchAttempts[ballId] < 255)