Renaming STATUS1_REFRESH and adding more constants for common STATUS1 checks. (#7284)

This commit is contained in:
surskitty 2025-07-05 07:46:23 -04:00 committed by GitHub
parent c6a62758a2
commit c360900a5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 14 deletions

View File

@ -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
{

View File

@ -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

View File

@ -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;

View File

@ -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))

View File

@ -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)