Add missing use of ALL_MOVES_MASK

This commit is contained in:
GriffinR 2023-05-23 13:07:52 -04:00
parent 10a10e914b
commit aca7998b93
7 changed files with 12 additions and 11 deletions

View File

@ -80,6 +80,7 @@
#define TRAINER_ID_LENGTH 4
#define MAX_MON_MOVES 4
#define ALL_MOVES_MASK ((1 << MAX_MON_MOVES) - 1)
#define CONTESTANT_COUNT 4
#define CONTEST_CATEGORY_COOL 0

View File

@ -478,9 +478,9 @@ static u8 ChooseMoveOrAction_Doubles(void)
else
{
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
BattleAI_SetupAIData(gBattleStruct->palaceFlags >> 4);
BattleAI_SetupAIData(gBattleStruct->palaceFlags >> MAX_BATTLERS_COUNT);
else
BattleAI_SetupAIData((1 << MAX_MON_MOVES) - 1);
BattleAI_SetupAIData(ALL_MOVES_MASK);
gBattlerTarget = i;

View File

@ -1555,7 +1555,7 @@ static void OpponentHandleChooseMove(void)
if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER))
{
BattleAI_SetupAIData(0xF);
BattleAI_SetupAIData(ALL_MOVES_MASK);
chosenMoveId = BattleAI_ChooseMoveOrAction();
switch (chosenMoveId)

View File

@ -1515,7 +1515,7 @@ static void PlayerPartnerHandleChooseMove(void)
u8 chosenMoveId;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct *)(&gBattleBufferA[gActiveBattler][4]);
BattleAI_SetupAIData(0xF);
BattleAI_SetupAIData(ALL_MOVES_MASK);
chosenMoveId = BattleAI_ChooseMoveOrAction();
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_USER_OR_SELECTED))

View File

@ -157,8 +157,10 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
// Pass selected moves to AI, pick one
if (selectedMoves != 0)
{
gBattleStruct->palaceFlags &= 0xF;
gBattleStruct->palaceFlags |= (selectedMoves << 4);
// Lower 4 bits of palaceFlags are flags for each battler.
// Clear the rest of palaceFlags, then set the selected moves in the upper 4 bits.
gBattleStruct->palaceFlags &= (1 << MAX_BATTLERS_COUNT) - 1;
gBattleStruct->palaceFlags |= (selectedMoves << MAX_BATTLERS_COUNT);
BattleAI_SetupAIData(selectedMoves);
chosenMoveId = BattleAI_ChooseMoveOrAction();
}
@ -168,7 +170,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
// If a move is chosen this way, there's a 50% chance that it will be unable to use it anyway
if (chosenMoveId == -1)
{
if (unusableMovesBits != 0xF)
if (unusableMovesBits != ALL_MOVES_MASK)
{
validMoveFlags = 0, numValidMoveGroups = 0;

View File

@ -8179,7 +8179,7 @@ static void Cmd_trychoosesleeptalkmove(void)
}
unusableMovesBits = CheckMoveLimitations(gBattlerAttacker, unusableMovesBits, ~MOVE_LIMITATION_PP);
if (unusableMovesBits == (1 << MAX_MON_MOVES) - 1) // all 4 moves cannot be chosen
if (unusableMovesBits == ALL_MOVES_MASK) // all 4 moves cannot be chosen
{
gBattlescriptCurrInstr += 5;
}

View File

@ -1110,7 +1110,6 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check)
return unusableMoves;
}
#define ALL_MOVES_MASK ((1 << MAX_MON_MOVES) - 1)
bool8 AreAllMovesUnusable(void)
{
u8 unusable = CheckMoveLimitations(gActiveBattler, 0, MOVE_LIMITATIONS_ALL);
@ -1127,7 +1126,6 @@ bool8 AreAllMovesUnusable(void)
return (unusable == ALL_MOVES_MASK);
}
#undef ALL_MOVES_MASK
u8 GetImprisonedMovesCount(u8 battlerId, u16 move)
{
@ -3954,7 +3952,7 @@ u8 IsMonDisobedient(void)
if (calc < obedienceLevel)
{
calc = CheckMoveLimitations(gBattlerAttacker, gBitTable[gCurrMovePos], MOVE_LIMITATIONS_ALL);
if (calc == 0xF) // all moves cannot be used
if (calc == ALL_MOVES_MASK) // all moves cannot be used
{
// Randomly select, then print a disobedient string
// B_MSG_LOAFING, B_MSG_WONT_OBEY, B_MSG_TURNED_AWAY, or B_MSG_PRETEND_NOT_NOTICE