Convert commandingDondozo to BattlerSet

This commit is contained in:
Martin Griffin 2025-01-02 10:05:55 +00:00
parent a1269e3cc2
commit bd69437b53
5 changed files with 8 additions and 8 deletions

View file

@ -814,7 +814,7 @@ struct BattleStruct
u8 speedTieBreaks; // MAX_BATTLERS_COUNT! values. u8 speedTieBreaks; // MAX_BATTLERS_COUNT! values.
u8 boosterEnergyActivates; u8 boosterEnergyActivates;
u8 categoryOverride; // for Z-Moves and Max Moves u8 categoryOverride; // for Z-Moves and Max Moves
u8 commandingDondozo; struct BattlerSet commandingDondozo;
u16 commanderActive[MAX_BATTLERS_COUNT]; u16 commanderActive[MAX_BATTLERS_COUNT];
u32 stellarBoostFlags[NUM_BATTLE_SIDES]; // stored as a bitfield of flags for all types for each side u32 stellarBoostFlags[NUM_BATTLE_SIDES]; // stored as a bitfield of flags for all types for each side
u8 redCardActivates:1; u8 redCardActivates:1;

View file

@ -734,7 +734,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
if (IsTwoTurnNotSemiInvulnerableMove(battlerAtk, move) && CanTargetFaintAi(battlerDef, battlerAtk)) if (IsTwoTurnNotSemiInvulnerableMove(battlerAtk, move) && CanTargetFaintAi(battlerDef, battlerAtk))
RETURN_SCORE_MINUS(10); RETURN_SCORE_MINUS(10);
if (gBattleStruct->commandingDondozo & (1u << battlerDef)) if (BattlerSetContains(&gBattleStruct->commandingDondozo, battlerDef))
RETURN_SCORE_MINUS(20); RETURN_SCORE_MINUS(20);
// check if negates type // check if negates type

View file

@ -430,7 +430,7 @@ bool32 IsDamageMoveUnusable(u32 battlerAtk, u32 battlerDef, u32 move, u32 moveTy
if (battlerDef == BATTLE_PARTNER(battlerAtk)) if (battlerDef == BATTLE_PARTNER(battlerAtk))
battlerDefAbility = aiData->abilities[battlerDef]; battlerDefAbility = aiData->abilities[battlerDef];
if (gBattleStruct->commandingDondozo & (1u << battlerDef)) if (BattlerSetContains(&gBattleStruct->commandingDondozo, battlerDef))
return TRUE; return TRUE;
if (CanAbilityBlockMove(battlerAtk, battlerDef, move, aiData->abilities[battlerDef])) if (CanAbilityBlockMove(battlerAtk, battlerDef, move, aiData->abilities[battlerDef]))
@ -1510,7 +1510,7 @@ bool32 IsSemiInvulnerable(u32 battlerDef, u32 move)
{ {
if (gStatuses3[battlerDef] & STATUS3_PHANTOM_FORCE) if (gStatuses3[battlerDef] & STATUS3_PHANTOM_FORCE)
return TRUE; return TRUE;
else if (gBattleStruct->commandingDondozo & (1u << battlerDef)) else if (BattlerSetContains(&gBattleStruct->commandingDondozo, battlerDef))
return TRUE; return TRUE;
else if (!MoveDamagesAirborne(move) && gStatuses3[battlerDef] & STATUS3_ON_AIR) else if (!MoveDamagesAirborne(move) && gStatuses3[battlerDef] & STATUS3_ON_AIR)
return TRUE; return TRUE;

View file

@ -4265,7 +4265,7 @@ static void HandleTurnActionSelectionState(void)
|| gBattleStruct->absentBattlerFlags & (1u << GetBattlerAtPosition(BATTLE_PARTNER(position))) || gBattleStruct->absentBattlerFlags & (1u << GetBattlerAtPosition(BATTLE_PARTNER(position)))
|| gBattleCommunication[GetBattlerAtPosition(BATTLE_PARTNER(position))] == STATE_WAIT_ACTION_CONFIRMED) || gBattleCommunication[GetBattlerAtPosition(BATTLE_PARTNER(position))] == STATE_WAIT_ACTION_CONFIRMED)
{ {
if ((gBattleStruct->absentBattlerFlags & (1u << battler)) || (gBattleStruct->commandingDondozo & (1u << battler))) if ((gBattleStruct->absentBattlerFlags & (1u << battler)) || BattlerSetContains(&gBattleStruct->commandingDondozo, battler))
{ {
gChosenActionByBattler[battler] = B_ACTION_NOTHING_FAINTED; gChosenActionByBattler[battler] = B_ACTION_NOTHING_FAINTED;
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
@ -5189,7 +5189,7 @@ static void TurnValuesCleanUp(bool8 var0)
gBattleMons[i].status2 &= ~STATUS2_SUBSTITUTE; gBattleMons[i].status2 &= ~STATUS2_SUBSTITUTE;
if (!(gStatuses3[i] & STATUS3_COMMANDER)) if (!(gStatuses3[i] & STATUS3_COMMANDER))
gBattleStruct->commandingDondozo &= ~(1u << i); BattlerSetRemove(&gBattleStruct->commandingDondozo, i);
gSpecialStatuses[i].parentalBondState = PARENTAL_BOND_OFF; gSpecialStatuses[i].parentalBondState = PARENTAL_BOND_OFF;
} }

View file

@ -137,7 +137,7 @@ void HandleAction_UseMove(void)
gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber]; gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber];
if (gBattleStruct->absentBattlerFlags & (1u << gBattlerAttacker) if (gBattleStruct->absentBattlerFlags & (1u << gBattlerAttacker)
|| gBattleStruct->commandingDondozo & (1u << gBattlerAttacker) || BattlerSetContains(&gBattleStruct->commandingDondozo, gBattlerAttacker)
|| !IsBattlerAlive(gBattlerAttacker)) || !IsBattlerAlive(gBattlerAttacker))
{ {
gCurrentActionFuncId = B_ACTION_FINISHED; gCurrentActionFuncId = B_ACTION_FINISHED;
@ -5242,7 +5242,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
SaveBattlerAttacker(gBattlerAttacker); SaveBattlerAttacker(gBattlerAttacker);
gSpecialStatuses[battler].switchInAbilityDone = TRUE; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
gBattlerAttacker = partner; gBattlerAttacker = partner;
gBattleStruct->commandingDondozo |= 1u << battler; BattlerSetAdd(&gBattleStruct->commandingDondozo, battler);
gBattleStruct->commanderActive[partner] = gBattleMons[battler].species; gBattleStruct->commanderActive[partner] = gBattleMons[battler].species;
gStatuses3[battler] |= STATUS3_COMMANDER; gStatuses3[battler] |= STATUS3_COMMANDER;
if (gBattleMons[battler].status2 & STATUS2_CONFUSION if (gBattleMons[battler].status2 & STATUS2_CONFUSION