summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_dome.c2
-rw-r--r--src/battle_pike.c26
-rw-r--r--src/battle_tower.c53
-rw-r--r--src/frontier_util.c6
-rw-r--r--src/hall_of_fame.c8
-rwxr-xr-xsrc/party_menu.c10
-rw-r--r--src/pokemon.c6
-rw-r--r--src/union_room_battle.c6
8 files changed, 59 insertions, 58 deletions
diff --git a/src/battle_dome.c b/src/battle_dome.c
index 746d195d9..e4947825d 100644
--- a/src/battle_dome.c
+++ b/src/battle_dome.c
@@ -2578,7 +2578,7 @@ static void CreateDomeOpponentMons(u16 tournamentTrainerId)
// Create mon if it was selected, starting from back
for (i = FRONTIER_PARTY_SIZE - 1; i >= 0; i--)
{
- if (selectedMonBits & 4)
+ if (selectedMonBits & (1 << (FRONTIER_PARTY_SIZE - 1)))
{
CreateDomeOpponentMon(monsCount, tournamentTrainerId, i, otId);
monsCount++;
diff --git a/src/battle_pike.c b/src/battle_pike.c
index 9bc7254ec..6b31419a5 100644
--- a/src/battle_pike.c
+++ b/src/battle_pike.c
@@ -874,20 +874,20 @@ static bool8 TryInflictRandomStatus(void)
{
u8 j, i;
u8 count;
- u8 indices[3];
+ u8 indices[FRONTIER_PARTY_SIZE];
u32 status;
u16 species;
bool8 statusChosen;
struct Pokemon *mon;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
indices[i] = i;
for (j = 0; j < 10; j++)
{
u8 temp, id;
- i = Random() % 3;
- id = Random() % 3;
+ i = Random() % FRONTIER_PARTY_SIZE;
+ id = Random() % FRONTIER_PARTY_SIZE;
SWAP(indices[i], indices[id], temp);
}
@@ -921,7 +921,7 @@ static bool8 TryInflictRandomStatus(void)
{
status = sStatusFlags;
j = 0;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
mon = &gPlayerParty[indices[i]];
if (GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)) == AILMENT_NONE
@@ -963,7 +963,7 @@ static bool8 TryInflictRandomStatus(void)
}
j = 0;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
mon = &gPlayerParty[indices[i]];
if (GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)) == AILMENT_NONE
@@ -995,7 +995,7 @@ static bool8 AtLeastOneHealthyMon(void)
count = 3;
healthyMonsCount = 0;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
struct Pokemon *mon = &gPlayerParty[i];
if (GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)) == AILMENT_NONE
@@ -1262,23 +1262,23 @@ static void Task_DoStatusInflictionScreenFlash(u8 taskId)
static void TryHealMons(u8 healCount)
{
u8 j, i, k;
- u8 indices[3];
+ u8 indices[FRONTIER_PARTY_SIZE];
if (healCount == 0)
return;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
indices[i] = i;
for (k = 0; k < 10; k++)
{
u8 temp;
- i = Random() % 3;
- j = Random() % 3;
+ i = Random() % FRONTIER_PARTY_SIZE;
+ j = Random() % FRONTIER_PARTY_SIZE;
SWAP(indices[i], indices[j], temp);
}
- for (i = 0; i < 3; i++)
+ for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
bool32 canBeHealed = FALSE;
struct Pokemon *mon = &gPlayerParty[indices[i]];
@@ -1483,7 +1483,7 @@ static bool8 AtLeastTwoAliveMons(void)
mon = &gPlayerParty[0];
countDead = 0;
- for (i = 0; i < 3; i++, mon++)
+ for (i = 0; i < FRONTIER_PARTY_SIZE; i++, mon++)
{
if (GetMonData(mon, MON_DATA_HP) == 0)
countDead++;
diff --git a/src/battle_tower.c b/src/battle_tower.c
index 4890e7a05..4695d9aa0 100644
--- a/src/battle_tower.c
+++ b/src/battle_tower.c
@@ -24,6 +24,7 @@
#include "tv.h"
#include "battle_factory.h"
#include "constants/apprentice.h"
+#include "constants/battle_dome.h"
#include "constants/battle_frontier.h"
#include "constants/battle_frontier_mons.h"
#include "constants/battle_tent_mons.h"
@@ -2054,7 +2055,7 @@ void DoSpecialTrainerBattle(void)
if (VarGet(VAR_FRONTIER_BATTLE_MODE) == FRONTIER_MODE_DOUBLES)
gBattleTypeFlags |= BATTLE_TYPE_DOUBLE;
if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN)
- FillFrontierTrainerParty(2);
+ FillFrontierTrainerParty(DOME_BATTLE_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1);
sub_806E694(0);
BattleTransition_StartOnField(sub_80B100C(3));
@@ -2211,12 +2212,12 @@ static void nullsub_116(void)
static void GetApprenticeMultiPartnerParty(u16 trainerId)
{
s32 i, count;
- u32 validSpecies[3];
+ u32 validSpecies[MULTI_PARTY_SIZE];
u16 species1 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL);
u16 species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL);
count = 0;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < MULTI_PARTY_SIZE; i++)
{
u16 apprenticeSpecies = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].party[i].species;
if (apprenticeSpecies != species1 && apprenticeSpecies != species2)
@@ -2340,7 +2341,7 @@ static void LoadMultiPartnerCandidatesData(void)
&& gSaveBlock2Ptr->apprentices[i].lvlMode - 1 == lvlMode)
{
k = 0;
- for (j = 0; j < 3; j++)
+ for (j = 0; j < MULTI_PARTY_SIZE; j++)
{
if (species1 != gSaveBlock2Ptr->apprentices[i].party[j].species
&& species2 != gSaveBlock2Ptr->apprentices[i].party[j].species)
@@ -2948,26 +2949,26 @@ static void FillPartnerParty(u16 trainerId)
if (trainerId == TRAINER_STEVEN_PARTNER)
{
- for (i = 0; i < 3; i++)
+ for (i = 0; i < MULTI_PARTY_SIZE; i++)
{
do
{
j = Random32();
} while (IsShinyOtIdPersonality(STEVEN_OTID, j) || sStevenMons[i].nature != GetNatureFromPersonality(j));
- CreateMon(&gPlayerParty[3 + i],
+ CreateMon(&gPlayerParty[MULTI_PARTY_SIZE + i],
sStevenMons[i].species,
sStevenMons[i].level,
sStevenMons[i].fixedIV,
TRUE, i, // BUG: personality was stored in the 'j' variable. As a result, Steven's pokemon do not have the intended natures.
OT_ID_PRESET, STEVEN_OTID);
for (j = 0; j < PARTY_SIZE; j++)
- SetMonData(&gPlayerParty[3 + i], MON_DATA_HP_EV + j, &sStevenMons[i].evs[j]);
+ SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_HP_EV + j, &sStevenMons[i].evs[j]);
for (j = 0; j < MAX_MON_MOVES; j++)
- SetMonMoveSlot(&gPlayerParty[3 + i], sStevenMons[i].moves[j], j);
- SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_NAME, gTrainers[TRAINER_STEVEN].trainerName);
+ SetMonMoveSlot(&gPlayerParty[MULTI_PARTY_SIZE + i], sStevenMons[i].moves[j], j);
+ SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_NAME, gTrainers[TRAINER_STEVEN].trainerName);
j = MALE;
- SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_GENDER, &j);
- CalculateMonStats(&gPlayerParty[3 + i]);
+ SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_GENDER, &j);
+ CalculateMonStats(&gPlayerParty[MULTI_PARTY_SIZE + i]);
}
}
else if (trainerId == TRAINER_EREADER)
@@ -2980,10 +2981,10 @@ static void FillPartnerParty(u16 trainerId)
level = SetFacilityPtrsGetLevel();
ivs = GetFrontierTrainerFixedIvs(trainerId);
otID = Random32();
- for (i = 0; i < 2; i++)
+ for (i = 0; i < FRONTIER_MULTI_PARTY_SIZE; i++)
{
monId = gSaveBlock2Ptr->frontier.trainerIds[i + 18];
- CreateMonWithEVSpreadNatureOTID(&gPlayerParty[3 + i],
+ CreateMonWithEVSpreadNatureOTID(&gPlayerParty[MULTI_PARTY_SIZE + i],
gFacilityTrainerMons[monId].species,
level,
gFacilityTrainerMons[monId].nature,
@@ -2993,23 +2994,23 @@ static void FillPartnerParty(u16 trainerId)
friendship = MAX_FRIENDSHIP;
for (j = 0; j < MAX_MON_MOVES; j++)
{
- SetMonMoveSlot(&gPlayerParty[3 + i], gFacilityTrainerMons[monId].moves[j], j);
+ SetMonMoveSlot(&gPlayerParty[MULTI_PARTY_SIZE + i], gFacilityTrainerMons[monId].moves[j], j);
if (gFacilityTrainerMons[monId].moves[j] == MOVE_FRUSTRATION)
friendship = 0;
}
- SetMonData(&gPlayerParty[3 + i], MON_DATA_FRIENDSHIP, &friendship);
- SetMonData(&gPlayerParty[3 + i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]);
+ SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_FRIENDSHIP, &friendship);
+ SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]);
for (j = 0; j < PLAYER_NAME_LENGTH + 1; j++)
trainerName[j] = gFacilityTrainers[trainerId].trainerName[j];
- SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_NAME, &trainerName);
+ SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_NAME, &trainerName);
j = IsFrontierTrainerFemale(trainerId);
- SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_GENDER, &j);
+ SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_GENDER, &j);
}
}
else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE)
{
trainerId -= TRAINER_RECORD_MIXING_FRIEND;
- for (i = 0; i < 2; i++)
+ for (i = 0; i < FRONTIER_MULTI_PARTY_SIZE; i++)
{
struct EmeraldBattleTowerRecord *record = &gSaveBlock2Ptr->frontier.towerRecords[trainerId];
struct BattleTowerPokemon monData = record->party[gSaveBlock2Ptr->frontier.trainerIds[18 + i]];
@@ -3027,20 +3028,20 @@ static void FillPartnerParty(u16 trainerId)
if (monData.nickname[0] == EXT_CTRL_CODE_BEGIN && monData.nickname[1] == EXT_CTRL_CODE_JPN)
trainerName[5] = EOS;
}
- CreateBattleTowerMon2(&gPlayerParty[3 + i], &monData, TRUE);
- SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_NAME, trainerName);
+ CreateBattleTowerMon2(&gPlayerParty[MULTI_PARTY_SIZE + i], &monData, TRUE);
+ SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_NAME, trainerName);
j = IsFrontierTrainerFemale(trainerId + TRAINER_RECORD_MIXING_FRIEND);
- SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_GENDER, &j);
+ SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_GENDER, &j);
}
}
else
{
trainerId -= TRAINER_RECORD_MIXING_APPRENTICE;
- for (i = 0; i < 2; i++)
+ for (i = 0; i < FRONTIER_MULTI_PARTY_SIZE; i++)
{
- CreateApprenticeMon(&gPlayerParty[3 + i], &gSaveBlock2Ptr->apprentices[trainerId], gSaveBlock2Ptr->frontier.trainerIds[18 + i]);
+ CreateApprenticeMon(&gPlayerParty[MULTI_PARTY_SIZE + i], &gSaveBlock2Ptr->apprentices[trainerId], gSaveBlock2Ptr->frontier.trainerIds[18 + i]);
j = IsFrontierTrainerFemale(trainerId + TRAINER_RECORD_MIXING_APPRENTICE);
- SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_GENDER, &j);
+ SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_GENDER, &j);
}
}
}
@@ -3351,7 +3352,7 @@ static void SetNextBattleTentOpponent(void)
static void FillTentTrainerParty_(u16 trainerId, u8 firstMonId, u8 monCount)
{
s32 i, j;
- u16 chosenMonIndices[4];
+ u16 chosenMonIndices[MAX_FRONTIER_PARTY_SIZE];
u8 friendship;
u8 level = SetTentPtrsGetLevel();
u8 fixedIV = 0;
diff --git a/src/frontier_util.c b/src/frontier_util.c
index f46c60391..668771375 100644
--- a/src/frontier_util.c
+++ b/src/frontier_util.c
@@ -94,7 +94,7 @@ static const u8 sFrontierBrainStreakAppearances[NUM_FRONTIER_FACILITIES][4] =
[FRONTIER_FACILITY_PYRAMID] = {21, 70, 35, 0},
};
-static const struct FrontierBrainMon sFrontierBrainsMons[][2][3] =
+static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZE] =
{
[FRONTIER_FACILITY_TOWER] =
{
@@ -1778,9 +1778,9 @@ void ResetWinStreaks(void)
s32 battleMode, lvlMode;
gSaveBlock2Ptr->frontier.winStreakActiveFlags = 0;
- for (battleMode = 0; battleMode < 4; battleMode++)
+ for (battleMode = 0; battleMode < FRONTIER_MODE_COUNT; battleMode++)
{
- for (lvlMode = 0; lvlMode < 2; lvlMode++)
+ for (lvlMode = 0; lvlMode < FRONTIER_LVL_TENT; lvlMode++)
{
gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] = 0;
if (battleMode < FRONTIER_MODE_MULTIS)
diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c
index 065d25582..05e4ed0aa 100644
--- a/src/hall_of_fame.c
+++ b/src/hall_of_fame.c
@@ -155,7 +155,7 @@ static const struct CompressedSpritePalette sHallOfFame_ConfettiSpritePalette[]
{},
};
-static const s16 sHallOfFame_MonFullTeamPositions[6][4] =
+static const s16 sHallOfFame_MonFullTeamPositions[PARTY_SIZE][4] =
{
{120, 210, 120, 40},
{326, 220, 56, 40},
@@ -165,7 +165,7 @@ static const s16 sHallOfFame_MonFullTeamPositions[6][4] =
{310, -92, 40, 88}
};
-static const s16 sHallOfFame_MonHalfTeamPositions[3][4] =
+static const s16 sHallOfFame_MonHalfTeamPositions[PARTY_SIZE / 2][4] =
{
{120, 234, 120, 64},
{326, 244, 56, 64},
@@ -544,7 +544,7 @@ static void Task_Hof_DisplayMon(u8 taskId)
u16 currMonId = gTasks[taskId].tDisplayedMonId;
struct HallofFameMon* currMon = &sHofMonPtr->mon[currMonId];
- if (gTasks[taskId].tMonNumber > 3)
+ if (gTasks[taskId].tMonNumber > PARTY_SIZE / 2)
{
xPos = sHallOfFame_MonFullTeamPositions[currMonId][0];
yPos = sHallOfFame_MonFullTeamPositions[currMonId][1];
@@ -893,7 +893,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId)
u16 spriteId;
s16 posX, posY;
- if (gTasks[taskId].tMonNo > 3)
+ if (gTasks[taskId].tMonNo > PARTY_SIZE / 2)
{
posX = sHallOfFame_MonFullTeamPositions[i][2];
posY = sHallOfFame_MonFullTeamPositions[i][3];
diff --git a/src/party_menu.c b/src/party_menu.c
index 0a119f03d..43bdc46ec 100755
--- a/src/party_menu.c
+++ b/src/party_menu.c
@@ -152,7 +152,7 @@ EWRAM_DATA u8 gSelectedMonPartyId = 0;
EWRAM_DATA MainCallback gPostMenuFieldCallback = NULL;
static EWRAM_DATA u16 *sSlot1TilemapBuffer = 0; // for switching party slots
static EWRAM_DATA u16 *sSlot2TilemapBuffer = 0; //
-EWRAM_DATA u8 gSelectedOrderFromParty[4] = {0};
+EWRAM_DATA u8 gSelectedOrderFromParty[MAX_FRONTIER_PARTY_SIZE] = {0};
static EWRAM_DATA u16 sPartyMenuItemId = 0;
static EWRAM_DATA u16 sUnused_0203CEFE = 0;
EWRAM_DATA u8 gBattlePartyCurrentOrder[PARTY_SIZE / 2] = {0}; // bits 0-3 are the current pos of Slot 1, 4-7 are Slot 2, and so on
@@ -5624,9 +5624,9 @@ static u8 GetMaxBattleEntries(void)
switch (VarGet(VAR_FRONTIER_FACILITY))
{
case FACILITY_MULTI_OR_EREADER:
- return 3;
+ return MULTI_PARTY_SIZE;
case FACILITY_UNION_ROOM:
- return 2;
+ return UNION_ROOM_PARTY_SIZE;
default: // Battle Frontier
return gSpecialVar_0x8005;
}
@@ -5639,7 +5639,7 @@ static u8 GetMinBattleEntries(void)
case FACILITY_MULTI_OR_EREADER:
return 1;
case FACILITY_UNION_ROOM:
- return 2;
+ return UNION_ROOM_PARTY_SIZE;
default: // Battle Frontier
return gSpecialVar_0x8005;
}
@@ -6074,7 +6074,7 @@ static void Task_MultiPartnerPartySlideIn(u8 taskId)
SlideMultiPartyMenuBoxSpritesOneStep(taskId);
if (tXPos == 0)
{
- for (i = 3; i < PARTY_SIZE; i++)
+ for (i = MULTI_PARTY_SIZE; i < PARTY_SIZE; i++)
{
if (gMultiPartnerParty[i - MULTI_PARTY_SIZE].species != SPECIES_NONE)
AnimateSelectedPartyIcon(sPartyMenuBoxes[i].monSpriteId, 0);
diff --git a/src/pokemon.c b/src/pokemon.c
index ec29af02d..87ea2551f 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -4394,7 +4394,7 @@ u8 CalculatePlayerPartyCount(void)
{
gPlayerPartyCount = 0;
- while (gPlayerPartyCount < 6
+ while (gPlayerPartyCount < PARTY_SIZE
&& GetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_SPECIES, NULL) != SPECIES_NONE)
{
gPlayerPartyCount++;
@@ -4407,7 +4407,7 @@ u8 CalculateEnemyPartyCount(void)
{
gEnemyPartyCount = 0;
- while (gEnemyPartyCount < 6
+ while (gEnemyPartyCount < PARTY_SIZE
&& GetMonData(&gEnemyParty[gEnemyPartyCount], MON_DATA_SPECIES, NULL) != SPECIES_NONE)
{
gEnemyPartyCount++;
@@ -4494,7 +4494,7 @@ void CreateSecretBaseEnemyParty(struct SecretBase *secretBaseRecord)
SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBattleResources->secretBase->party.heldItems[i]);
- for (j = 0; j < 6; j++)
+ for (j = 0; j < NUM_STATS; j++)
SetMonData(&gEnemyParty[i], MON_DATA_HP_EV + j, &gBattleResources->secretBase->party.EVs[i]);
for (j = 0; j < MAX_MON_MOVES; j++)
diff --git a/src/union_room_battle.c b/src/union_room_battle.c
index c80340da3..18dd7c320 100644
--- a/src/union_room_battle.c
+++ b/src/union_room_battle.c
@@ -451,15 +451,15 @@ void sub_801AAD4(void)
{
s32 i;
sub_8014210(10);
- for (i = 0; i < 2; i++)
+ for (i = 0; i < UNION_ROOM_PARTY_SIZE; i++)
{
gEnemyParty[i] = gPlayerParty[gSelectedOrderFromParty[i] - 1];
}
- for (i = 0; i < 6; i++)
+ for (i = 0; i < PARTY_SIZE; i++)
{
ZeroMonData(&gPlayerParty[i]);
}
- for (i = 0; i < 2; i++)
+ for (i = 0; i < UNION_ROOM_PARTY_SIZE; i++)
{
gPlayerParty[i] = gEnemyParty[i];
}