Add some battle frontier constant usage

This commit is contained in:
GriffinR 2022-06-06 15:15:46 -04:00
parent 78b0c20738
commit 7143865f6f
21 changed files with 189 additions and 143 deletions

View File

@ -1,6 +1,8 @@
#ifndef GUARD_CONSTANTS_BATTLE_FRONTIER_H #ifndef GUARD_CONSTANTS_BATTLE_FRONTIER_H
#define GUARD_CONSTANTS_BATTLE_FRONTIER_H #define GUARD_CONSTANTS_BATTLE_FRONTIER_H
#include "constants/pokemon.h"
#define FRONTIER_CHALLENGE(facility, mode) ((facility << 8) + mode) #define FRONTIER_CHALLENGE(facility, mode) ((facility << 8) + mode)
// Battle Frontier facility ids. // Battle Frontier facility ids.
@ -46,6 +48,14 @@
#define MAX_BATTLE_FRONTIER_POINTS 9999 #define MAX_BATTLE_FRONTIER_POINTS 9999
#define MAX_STREAK 9999 #define MAX_STREAK 9999
#define FRONTIER_MAX_LEVEL_50 50
#define FRONTIER_MIN_LEVEL_OPEN 60
#define FRONTIER_MAX_LEVEL_OPEN MAX_LEVEL
// This is the default number of battles (or floors, in Battle Pyramid) per challenge.
// There are 2 facilities that differ: Battle Dome (DOME_ROUNDS_COUNT) and Battle Pike (NUM_PIKE_ROOMS).
#define FRONTIER_STAGES_PER_CHALLENGE 7
// These sets of facility ids would be redundant if the order was consistent // These sets of facility ids would be redundant if the order was consistent
// The order is important for this set so that all the non-link records can be continuous // The order is important for this set so that all the non-link records can be continuous
#define RANKING_HALL_TOWER_SINGLES 0 #define RANKING_HALL_TOWER_SINGLES 0

View File

@ -1,6 +1,8 @@
#ifndef GUARD_CONSTANTS_BATTLE_PIKE_H #ifndef GUARD_CONSTANTS_BATTLE_PIKE_H
#define GUARD_CONSTANTS_BATTLE_PIKE_H #define GUARD_CONSTANTS_BATTLE_PIKE_H
#define NUM_PIKE_ROOMS 14
#define PIKE_ROOM_SINGLE_BATTLE 0 #define PIKE_ROOM_SINGLE_BATTLE 0
#define PIKE_ROOM_HEAL_FULL 1 #define PIKE_ROOM_HEAL_FULL 1
#define PIKE_ROOM_NPC 2 #define PIKE_ROOM_NPC 2

View File

@ -14,6 +14,13 @@
#define HINT_EXIT_FAR_REMAINING_TRAINERS 7 #define HINT_EXIT_FAR_REMAINING_TRAINERS 7
#define HINT_EXIT_FAR_REMAINING_ITEMS 8 #define HINT_EXIT_FAR_REMAINING_ITEMS 8
#define MAX_PYRAMID_TRAINERS 8
// Each floor of the Battle Pyramid is 32x32 metatiles, subdivided into a 4x4 grid of 8x8 metatile squares
#define PYRAMID_FLOOR_SQUARES_WIDE 4
#define PYRAMID_FLOOR_SQUARES_HIGH 4
#define NUM_PYRAMID_FLOOR_SQUARES (PYRAMID_FLOOR_SQUARES_WIDE * PYRAMID_FLOOR_SQUARES_HIGH)
#define OBJ_TRAINERS 0 #define OBJ_TRAINERS 0
#define OBJ_ITEMS 1 #define OBJ_ITEMS 1

View File

@ -1,6 +1,12 @@
#ifndef GUARD_CONSTANTS_BATTLE_TENT_H #ifndef GUARD_CONSTANTS_BATTLE_TENT_H
#define GUARD_CONSTANTS_BATTLE_TENT_H #define GUARD_CONSTANTS_BATTLE_TENT_H
#define TENT_MIN_LEVEL 30
// The number of battles in each Battle Tent challenge.
// Battle Tent equivalent of FRONTIER_STAGES_PER_CHALLENGE.
#define TENT_STAGES_PER_CHALLENGE 3
#define VERDANTURF_TENT_FUNC_INIT 0 #define VERDANTURF_TENT_FUNC_INIT 0
#define VERDANTURF_TENT_FUNC_GET_PRIZE 1 #define VERDANTURF_TENT_FUNC_GET_PRIZE 1
#define VERDANTURF_TENT_FUNC_SET_PRIZE 2 #define VERDANTURF_TENT_FUNC_SET_PRIZE 2

View File

@ -11,6 +11,8 @@
#define UNION_ROOM_SPAWN_IN 1 #define UNION_ROOM_SPAWN_IN 1
#define UNION_ROOM_SPAWN_OUT 2 #define UNION_ROOM_SPAWN_OUT 2
#define UNION_ROOM_MAX_LEVEL 30
#define ACTIVITY_NONE 0 #define ACTIVITY_NONE 0
#define ACTIVITY_BATTLE_SINGLE 1 #define ACTIVITY_BATTLE_SINGLE 1
#define ACTIVITY_BATTLE_DOUBLE 2 #define ACTIVITY_BATTLE_DOUBLE 2

View File

@ -409,7 +409,7 @@ struct BattleFrontier
/*0xE1A*/ u16 pyramidWinStreaks[FRONTIER_LVL_MODE_COUNT]; /*0xE1A*/ u16 pyramidWinStreaks[FRONTIER_LVL_MODE_COUNT];
/*0xE1E*/ u16 pyramidRecordStreaks[FRONTIER_LVL_MODE_COUNT]; /*0xE1E*/ u16 pyramidRecordStreaks[FRONTIER_LVL_MODE_COUNT];
/*0xE22*/ u16 pyramidRandoms[4]; /*0xE22*/ u16 pyramidRandoms[4];
/*0xE2A*/ u8 pyramidTrainerFlags; /*0xE2A*/ u8 pyramidTrainerFlags; // 1 bit for each trainer (MAX_PYRAMID_TRAINERS)
/*0xE2C*/ struct PyramidBag pyramidBag; /*0xE2C*/ struct PyramidBag pyramidBag;
/*0xE68*/ u8 pyramidLightRadius; /*0xE68*/ u8 pyramidLightRadius;
/*0xE6A*/ u16 verdanturfTentPrize; /*0xE6A*/ u16 verdanturfTentPrize;

View File

@ -5847,7 +5847,7 @@ static void InitRandomTourneyTreeResults(void)
DOME_TRAINERS[i].forfeited = FALSE; DOME_TRAINERS[i].forfeited = FALSE;
} }
monLevel = 50; monLevel = FRONTIER_MAX_LEVEL_50;
for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++) for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
{ {
monTypesBits = 0; monTypesBits = 0;

View File

@ -12,15 +12,15 @@
#include "constants/battle_factory.h" #include "constants/battle_factory.h"
#include "constants/battle_frontier.h" #include "constants/battle_frontier.h"
#include "constants/battle_frontier_mons.h" #include "constants/battle_frontier_mons.h"
#include "constants/battle_tent.h"
#include "constants/frontier_util.h" #include "constants/frontier_util.h"
#include "constants/layouts.h" #include "constants/layouts.h"
#include "constants/trainers.h" #include "constants/trainers.h"
#include "constants/moves.h" #include "constants/moves.h"
#include "constants/items.h"
// IWRAM bss
static bool8 sPerformedRentalSwap; static bool8 sPerformedRentalSwap;
// This file's functions.
static void InitFactoryChallenge(void); static void InitFactoryChallenge(void);
static void GetBattleFactoryData(void); static void GetBattleFactoryData(void);
static void SetBattleFactoryData(void); static void SetBattleFactoryData(void);
@ -212,7 +212,7 @@ static void InitFactoryChallenge(void)
} }
sPerformedRentalSwap = FALSE; sPerformedRentalSwap = FALSE;
for (i = 0; i < 6; i++) for (i = 0; i < ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons); i++)
gSaveBlock2Ptr->frontier.rentalMons[i].monId = 0xFFFF; gSaveBlock2Ptr->frontier.rentalMons[i].monId = 0xFFFF;
for (i = 0; i < FRONTIER_PARTY_SIZE; i++) for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
gFrontierTempParty[i] = 0xFFFF; gFrontierTempParty[i] = 0xFFFF;
@ -310,11 +310,12 @@ static void GenerateOpponentMons(void)
u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
u32 winStreak = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode]; u32 winStreak = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode];
u32 challengeNum = winStreak / 7; u32 challengeNum = winStreak / FRONTIER_STAGES_PER_CHALLENGE;
gFacilityTrainers = gBattleFrontierTrainers; gFacilityTrainers = gBattleFrontierTrainers;
do do
{ {
// Choose a random trainer, ensuring no repeats in this challenge
trainerId = GetRandomScaledFrontierTrainerId(challengeNum, gSaveBlock2Ptr->frontier.curChallengeBattleNum); trainerId = GetRandomScaledFrontierTrainerId(challengeNum, gSaveBlock2Ptr->frontier.curChallengeBattleNum);
for (i = 0; i < gSaveBlock2Ptr->frontier.curChallengeBattleNum; i++) for (i = 0; i < gSaveBlock2Ptr->frontier.curChallengeBattleNum; i++)
{ {
@ -324,27 +325,32 @@ static void GenerateOpponentMons(void)
} while (i != gSaveBlock2Ptr->frontier.curChallengeBattleNum); } while (i != gSaveBlock2Ptr->frontier.curChallengeBattleNum);
gTrainerBattleOpponent_A = trainerId; gTrainerBattleOpponent_A = trainerId;
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 6) if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < FRONTIER_STAGES_PER_CHALLENGE - 1)
gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = trainerId; gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = trainerId;
i = 0; i = 0;
while (i != FRONTIER_PARTY_SIZE) while (i != FRONTIER_PARTY_SIZE)
{ {
u16 monId = GetFactoryMonId(lvlMode, challengeNum, FALSE); u16 monId = GetFactoryMonId(lvlMode, challengeNum, FALSE);
// Unown (FRONTIER_MON_UNOWN) is forbidden on opponent Factory teams.
if (gFacilityTrainerMons[monId].species == SPECIES_UNOWN) if (gFacilityTrainerMons[monId].species == SPECIES_UNOWN)
continue; continue;
for (j = 0; j < 6; j++) // Ensure none of the opponent's pokemon are the same as the potential rental pokemon for the player
for (j = 0; j < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons); j++)
{ {
if (gFacilityTrainerMons[monId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.rentalMons[j].monId].species) if (gFacilityTrainerMons[monId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.rentalMons[j].monId].species)
break; break;
} }
if (j != 6) if (j != (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons))
continue; continue;
// "High tier" pokemon are only allowed on open level mode
if (lvlMode == FRONTIER_LVL_50 && monId > FRONTIER_MONS_HIGH_TIER) if (lvlMode == FRONTIER_LVL_50 && monId > FRONTIER_MONS_HIGH_TIER)
continue; continue;
// Ensure this species hasn't already been chosen for the opponent
for (k = firstMonId; k < firstMonId + i; k++) for (k = firstMonId; k < firstMonId + i; k++)
{ {
if (species[k] == gFacilityTrainerMons[monId].species) if (species[k] == gFacilityTrainerMons[monId].species)
@ -353,14 +359,16 @@ static void GenerateOpponentMons(void)
if (k != firstMonId + i) if (k != firstMonId + i)
continue; continue;
// Ensure held items don't repeat on the opponent's team
for (k = firstMonId; k < firstMonId + i; k++) for (k = firstMonId; k < firstMonId + i; k++)
{ {
if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]) if (heldItems[k] != ITEM_NONE && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId])
break; break;
} }
if (k != firstMonId + i) if (k != firstMonId + i)
continue; continue;
// Successful selection
species[i] = gFacilityTrainerMons[monId].species; species[i] = gFacilityTrainerMons[monId].species;
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]; heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId];
gFrontierTempParty[i] = monId; gFrontierTempParty[i] = monId;
@ -406,15 +414,15 @@ static void SetPlayerAndOpponentParties(void)
if (gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_TENT) if (gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_TENT)
{ {
gFacilityTrainerMons = gSlateportBattleTentMons; gFacilityTrainerMons = gSlateportBattleTentMons;
monLevel = 30; monLevel = TENT_MIN_LEVEL;
} }
else else
{ {
gFacilityTrainerMons = gBattleFrontierMons; gFacilityTrainerMons = gBattleFrontierMons;
if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50) if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50)
monLevel = 100; monLevel = FRONTIER_MAX_LEVEL_OPEN;
else else
monLevel = 50; monLevel = FRONTIER_MAX_LEVEL_50;
} }
if (gSpecialVar_0x8005 < 2) if (gSpecialVar_0x8005 < 2)
@ -618,9 +626,9 @@ static void GetOpponentMostCommonMonType(void)
// Determine which are the two most-common types. // Determine which are the two most-common types.
// The second most-common type is only updated if // The second most-common type is only updated if
// its count is equal to the most-common type. // its count is equal to the most-common type.
mostCommonTypes[0] = TYPE_NORMAL; mostCommonTypes[0] = 0;
mostCommonTypes[1] = TYPE_NORMAL; mostCommonTypes[1] = 0;
for (i = TYPE_FIGHTING; i < NUMBER_OF_MON_TYPES; i++) for (i = 1; i < NUMBER_OF_MON_TYPES; i++)
{ {
if (typeCounts[mostCommonTypes[0]] < typeCounts[i]) if (typeCounts[mostCommonTypes[0]] < typeCounts[i])
mostCommonTypes[0] = i; mostCommonTypes[0] = i;
@ -765,15 +773,15 @@ void FillFactoryBrainParty(void)
if (gFacilityTrainerMons[monId].species == SPECIES_UNOWN) if (gFacilityTrainerMons[monId].species == SPECIES_UNOWN)
continue; continue;
if (monLevel == 50 && monId > FRONTIER_MONS_HIGH_TIER) if (monLevel == FRONTIER_MAX_LEVEL_50 && monId > FRONTIER_MONS_HIGH_TIER)
continue; continue;
for (j = 0; j < 6; j++) for (j = 0; j < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons); j++)
{ {
if (monId == gSaveBlock2Ptr->frontier.rentalMons[j].monId) if (monId == gSaveBlock2Ptr->frontier.rentalMons[j].monId)
break; break;
} }
if (j != 6) if (j != (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons))
continue; continue;
for (k = 0; k < i; k++) for (k = 0; k < i; k++)
@ -786,7 +794,7 @@ void FillFactoryBrainParty(void)
for (k = 0; k < i; k++) for (k = 0; k < i; k++)
{ {
if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]) if (heldItems[k] != ITEM_NONE && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId])
break; break;
} }
if (k != i) if (k != i)

View File

@ -684,7 +684,7 @@ static void SetBattlePikeData(void)
static void IsNextRoomFinal(void) static void IsNextRoomFinal(void)
{ {
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum > 14) if (gSaveBlock2Ptr->frontier.curChallengeBattleNum > NUM_PIKE_ROOMS)
gSpecialVar_Result = TRUE; gSpecialVar_Result = TRUE;
else else
gSpecialVar_Result = FALSE; gSpecialVar_Result = FALSE;
@ -1117,20 +1117,20 @@ bool32 TryGenerateBattlePikeWildMon(bool8 checkKeenEyeIntimidate)
if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50) if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50)
{ {
monLevel = GetHighestLevelInPlayerParty(); monLevel = GetHighestLevelInPlayerParty();
if (monLevel < 60) if (monLevel < FRONTIER_MIN_LEVEL_OPEN)
{ {
monLevel = 60; monLevel = FRONTIER_MIN_LEVEL_OPEN;
} }
else else
{ {
monLevel -= wildMons[headerId][pikeMonId].levelDelta; monLevel -= wildMons[headerId][pikeMonId].levelDelta;
if (monLevel < 60) if (monLevel < FRONTIER_MIN_LEVEL_OPEN)
monLevel = 60; monLevel = FRONTIER_MIN_LEVEL_OPEN;
} }
} }
else else
{ {
monLevel = 50 - wildMons[headerId][pikeMonId].levelDelta; monLevel = FRONTIER_MAX_LEVEL_50 - wildMons[headerId][pikeMonId].levelDelta;
} }
if (checkKeenEyeIntimidate == TRUE && !CanEncounterWildMon(monLevel)) if (checkKeenEyeIntimidate == TRUE && !CanEncounterWildMon(monLevel))
@ -1395,7 +1395,7 @@ static void PrepareOneTrainer(bool8 difficult)
battleNum = 6; battleNum = 6;
lvlMode = gSaveBlock2Ptr->frontier.lvlMode; lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / 14; challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / NUM_PIKE_ROOMS;
do do
{ {
trainerId = GetRandomScaledFrontierTrainerId(challengeNum, battleNum); trainerId = GetRandomScaledFrontierTrainerId(challengeNum, battleNum);
@ -1409,7 +1409,7 @@ static void PrepareOneTrainer(bool8 difficult)
gTrainerBattleOpponent_A = trainerId; gTrainerBattleOpponent_A = trainerId;
gFacilityTrainers = gBattleFrontierTrainers; gFacilityTrainers = gBattleFrontierTrainers;
SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0); SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0);
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 14) if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < NUM_PIKE_ROOMS)
gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1] = gTrainerBattleOpponent_A; gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1] = gTrainerBattleOpponent_A;
} }
@ -1418,7 +1418,7 @@ static void PrepareTwoTrainers(void)
int i; int i;
u16 trainerId; u16 trainerId;
u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
u16 challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / 14; u16 challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / NUM_PIKE_ROOMS;
gFacilityTrainers = gBattleFrontierTrainers; gFacilityTrainers = gBattleFrontierTrainers;
do do
@ -1433,7 +1433,7 @@ static void PrepareTwoTrainers(void)
gTrainerBattleOpponent_A = trainerId; gTrainerBattleOpponent_A = trainerId;
SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0); SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0);
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum <= 14) if (gSaveBlock2Ptr->frontier.curChallengeBattleNum <= NUM_PIKE_ROOMS)
gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1] = gTrainerBattleOpponent_A; gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1] = gTrainerBattleOpponent_A;
do do
@ -1448,7 +1448,7 @@ static void PrepareTwoTrainers(void)
gTrainerBattleOpponent_B = trainerId; gTrainerBattleOpponent_B = trainerId;
SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_B, 1); SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_B, 1);
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 14) if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < NUM_PIKE_ROOMS)
gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum - 2] = gTrainerBattleOpponent_B; gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum - 2] = gTrainerBattleOpponent_B;
} }
@ -1456,7 +1456,7 @@ static void ClearPikeTrainerIds(void)
{ {
u8 i; u8 i;
for (i = 0; i < 14; i++) for (i = 0; i < NUM_PIKE_ROOMS; i++)
gSaveBlock2Ptr->frontier.trainerIds[i] = 0xFFFF; gSaveBlock2Ptr->frontier.trainerIds[i] = 0xFFFF;
} }

View File

@ -279,9 +279,9 @@ static const u8 sPyramidFloorTemplateOptions[][2] =
{100, 15} {100, 15}
}; };
static const u8 sFloorTemplateOffsets[] = static const u8 sFloorTemplateOffsets[FRONTIER_STAGES_PER_CHALLENGE] =
{ {
0, 4, 9, 14, 19, 24, 29, 0 0, 4, 9, 14, 19, 24, 29
}; };
static const u16 sPickupItemsLvl50[TOTAL_ROUNDS][PICKUP_ITEMS_PER_ROUND] = static const u16 sPickupItemsLvl50[TOTAL_ROUNDS][PICKUP_ITEMS_PER_ROUND] =
@ -406,7 +406,7 @@ static const u8 sPickupItemSlots[][2] =
{100, 9}, {100, 9},
}; };
static const u8 sPickupItemOffsets[] = {0, 9, 18, 27, 36, 45, 54}; static const u8 sPickupItemOffsets[FRONTIER_STAGES_PER_CHALLENGE] = {0, 9, 18, 27, 36, 45, 54};
static const struct PyramidTrainerEncounterMusic sTrainerClassEncounterMusic[54] = static const struct PyramidTrainerEncounterMusic sTrainerClassEncounterMusic[54] =
{ {
@ -963,7 +963,7 @@ static void SeedPyramidFloor(void)
{ {
int i; int i;
for (i = 0; i < 4; i++) for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.pyramidRandoms); i++)
gSaveBlock2Ptr->frontier.pyramidRandoms[i] = Random(); gSaveBlock2Ptr->frontier.pyramidRandoms[i] = Random();
gSaveBlock2Ptr->frontier.pyramidTrainerFlags = 0; gSaveBlock2Ptr->frontier.pyramidTrainerFlags = 0;
@ -977,7 +977,7 @@ static void SetPickupItem(void)
u8 id; u8 id;
u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
u32 floor = gSaveBlock2Ptr->frontier.curChallengeBattleNum; u32 floor = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
u32 round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / 7) % TOTAL_ROUNDS; u32 round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / FRONTIER_STAGES_PER_CHALLENGE) % TOTAL_ROUNDS;
if (round >= TOTAL_ROUNDS) if (round >= TOTAL_ROUNDS)
round = TOTAL_ROUNDS - 1; round = TOTAL_ROUNDS - 1;
@ -1016,8 +1016,8 @@ static void HidePyramidItem(void)
{ {
// Rather than using event flags to hide the item object event, // Rather than using event flags to hide the item object event,
// it moves them far off the map bounds. // it moves them far off the map bounds.
events[i].x = 0x7FFF; events[i].x = SHRT_MAX;
events[i].y = 0x7FFF; events[i].y = SHRT_MAX;
break; break;
} }
i++; i++;
@ -1063,7 +1063,7 @@ static void ShowPostBattleHintText(void)
case HINT_REMAINING_ITEMS: case HINT_REMAINING_ITEMS:
for (i = 0; i < GetNumBattlePyramidObjectEvents(); i++) for (i = 0; i < GetNumBattlePyramidObjectEvents(); i++)
{ {
if (events[i].graphicsId == OBJ_EVENT_GFX_ITEM_BALL && events[i].x != 0x7FFF && events[i].y != 0x7FFF) if (events[i].graphicsId == OBJ_EVENT_GFX_ITEM_BALL && events[i].x != SHRT_MAX && events[i].y != SHRT_MAX)
textIndex++; textIndex++;
} }
i = 1; i = 1;
@ -1071,7 +1071,7 @@ static void ShowPostBattleHintText(void)
case HINT_REMAINING_TRAINERS: case HINT_REMAINING_TRAINERS:
id = GetPyramidFloorTemplateId(); id = GetPyramidFloorTemplateId();
textIndex = sPyramidFloorTemplates[id].numTrainers; textIndex = sPyramidFloorTemplates[id].numTrainers;
for (i = 0; i < 8; i++) for (i = 0; i < MAX_PYRAMID_TRAINERS; i++)
{ {
if (gBitTable[i] & gSaveBlock2Ptr->frontier.pyramidTrainerFlags) if (gBitTable[i] & gSaveBlock2Ptr->frontier.pyramidTrainerFlags)
textIndex--; textIndex--;
@ -1326,7 +1326,7 @@ static void MarkPyramidTrainerAsBattled(u16 trainerId)
{ {
int i; int i;
for (i = 0; i < 8; i++) for (i = 0; i < MAX_PYRAMID_TRAINERS; i++)
{ {
if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId) if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId)
gSaveBlock2Ptr->frontier.pyramidTrainerFlags |= gBitTable[i]; gSaveBlock2Ptr->frontier.pyramidTrainerFlags |= gBitTable[i];
@ -1345,7 +1345,7 @@ void GenerateBattlePyramidWildMon(void)
const struct PyramidWildMon *wildMons; const struct PyramidWildMon *wildMons;
u32 id; u32 id;
u32 lvl = gSaveBlock2Ptr->frontier.lvlMode; u32 lvl = gSaveBlock2Ptr->frontier.lvlMode;
u16 round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvl] / 7) % TOTAL_ROUNDS; u16 round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvl] / FRONTIER_STAGES_PER_CHALLENGE) % TOTAL_ROUNDS;
if (round >= TOTAL_ROUNDS) if (round >= TOTAL_ROUNDS)
round = TOTAL_ROUNDS - 1; round = TOTAL_ROUNDS - 1;
@ -1488,13 +1488,13 @@ static u16 GetUniqueTrainerId(u8 objectEventId)
int i; int i;
u16 trainerId; u16 trainerId;
u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
u32 challengeNum = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / 7; u32 challengeNum = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / FRONTIER_STAGES_PER_CHALLENGE;
u32 battleNum = gSaveBlock2Ptr->frontier.curChallengeBattleNum; u32 floor = gSaveBlock2Ptr->frontier.curChallengeBattleNum;
if (battleNum == 7) if (floor == FRONTIER_STAGES_PER_CHALLENGE)
{ {
do do
{ {
trainerId = GetRandomScaledFrontierTrainerId(challengeNum + 1, battleNum); trainerId = GetRandomScaledFrontierTrainerId(challengeNum + 1, floor);
for (i = 0; i < objectEventId; i++) for (i = 0; i < objectEventId; i++)
{ {
if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId) if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId)
@ -1506,7 +1506,7 @@ static u16 GetUniqueTrainerId(u8 objectEventId)
{ {
do do
{ {
trainerId = GetRandomScaledFrontierTrainerId(challengeNum, battleNum); trainerId = GetRandomScaledFrontierTrainerId(challengeNum, floor);
for (i = 0; i < objectEventId; i++) for (i = 0; i < objectEventId; i++)
{ {
if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId) if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId)
@ -1523,11 +1523,11 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
int y, x; int y, x;
int i; int i;
u8 entranceSquareId, exitSquareId; u8 entranceSquareId, exitSquareId;
u8 *floorLayoutOffsets = AllocZeroed(16); u8 *floorLayoutOffsets = AllocZeroed(NUM_PYRAMID_FLOOR_SQUARES);
GetPyramidFloorLayoutOffsets(floorLayoutOffsets); GetPyramidFloorLayoutOffsets(floorLayoutOffsets);
GetPyramidEntranceAndExitSquareIds(&entranceSquareId, &exitSquareId); GetPyramidEntranceAndExitSquareIds(&entranceSquareId, &exitSquareId);
for (i = 0; i < 16; i++) for (i = 0; i < NUM_PYRAMID_FLOOR_SQUARES; i++)
{ {
u16 *map; u16 *map;
int yOffset, xOffset; int yOffset, xOffset;
@ -1535,11 +1535,11 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
const u16 *layoutMap = mapLayout->map; const u16 *layoutMap = mapLayout->map;
gBackupMapLayout.map = backupMapData; gBackupMapLayout.map = backupMapData;
gBackupMapLayout.width = mapLayout->width * 4 + MAP_OFFSET_W; gBackupMapLayout.width = mapLayout->width * PYRAMID_FLOOR_SQUARES_WIDE + MAP_OFFSET_W;
gBackupMapLayout.height = mapLayout->height * 4 + MAP_OFFSET_H; gBackupMapLayout.height = mapLayout->height * PYRAMID_FLOOR_SQUARES_HIGH + MAP_OFFSET_H;
map = backupMapData; map = backupMapData;
yOffset = ((i / 4 * mapLayout->height) + MAP_OFFSET) * gBackupMapLayout.width; yOffset = ((i / PYRAMID_FLOOR_SQUARES_WIDE * mapLayout->height) + MAP_OFFSET) * gBackupMapLayout.width;
xOffset = (i % 4 * mapLayout->width) + MAP_OFFSET; xOffset = (i % PYRAMID_FLOOR_SQUARES_WIDE * mapLayout->width) + MAP_OFFSET;
map += yOffset + xOffset; map += yOffset + xOffset;
for (y = 0; y < mapLayout->height; y++) for (y = 0; y < mapLayout->height; y++)
{ {
@ -1553,8 +1553,8 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
{ {
if (i == entranceSquareId && setPlayerPosition == FALSE) if (i == entranceSquareId && setPlayerPosition == FALSE)
{ {
gSaveBlock1Ptr->pos.x = (mapLayout->width * (i % 4)) + x; gSaveBlock1Ptr->pos.x = (mapLayout->width * (i % PYRAMID_FLOOR_SQUARES_WIDE)) + x;
gSaveBlock1Ptr->pos.y = (mapLayout->height * (i / 4)) + y; gSaveBlock1Ptr->pos.y = (mapLayout->height * (i / PYRAMID_FLOOR_SQUARES_WIDE)) + y;
} }
map[x] = (layoutMap[x] & (MAPGRID_ELEVATION_MASK | MAPGRID_COLLISION_MASK)) | METATILE_BattlePyramid_Floor; map[x] = (layoutMap[x] & (MAPGRID_ELEVATION_MASK | MAPGRID_COLLISION_MASK)) | METATILE_BattlePyramid_Floor;
} }
@ -1563,7 +1563,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
map[x] = layoutMap[x]; map[x] = layoutMap[x];
} }
} }
map += MAP_OFFSET_W + (mapLayout->width * 4); map += MAP_OFFSET_W + (mapLayout->width * PYRAMID_FLOOR_SQUARES_WIDE);
layoutMap += mapLayout->width; layoutMap += mapLayout->width;
} }
} }
@ -1577,7 +1577,7 @@ void LoadBattlePyramidObjectEventTemplates(void)
u8 id; u8 id;
u8 entranceSquareId, exitSquareId; u8 entranceSquareId, exitSquareId;
for (i = 0; i < 8; i++) for (i = 0; i < MAX_PYRAMID_TRAINERS; i++)
gSaveBlock2Ptr->frontier.trainerIds[i] = 0xFFFF; gSaveBlock2Ptr->frontier.trainerIds[i] = 0xFFFF;
id = GetPyramidFloorTemplateId(); id = GetPyramidFloorTemplateId();
@ -1633,13 +1633,13 @@ void LoadBattlePyramidFloorObjectEventScripts(void)
static void GetPyramidEntranceAndExitSquareIds(u8 *entranceSquareId, u8 *exitSquareId) static void GetPyramidEntranceAndExitSquareIds(u8 *entranceSquareId, u8 *exitSquareId)
{ {
*entranceSquareId = gSaveBlock2Ptr->frontier.pyramidRandoms[3] % 16; *entranceSquareId = gSaveBlock2Ptr->frontier.pyramidRandoms[3] % NUM_PYRAMID_FLOOR_SQUARES;
*exitSquareId = gSaveBlock2Ptr->frontier.pyramidRandoms[0] % 16; *exitSquareId = gSaveBlock2Ptr->frontier.pyramidRandoms[0] % NUM_PYRAMID_FLOOR_SQUARES;
if (*entranceSquareId == *exitSquareId) if (*entranceSquareId == *exitSquareId)
{ {
*entranceSquareId = (gSaveBlock2Ptr->frontier.pyramidRandoms[3] + 1 ) % 16; *entranceSquareId = (gSaveBlock2Ptr->frontier.pyramidRandoms[3] + 1 ) % NUM_PYRAMID_FLOOR_SQUARES;
*exitSquareId = (gSaveBlock2Ptr->frontier.pyramidRandoms[0] + 15) % 16; *exitSquareId = (gSaveBlock2Ptr->frontier.pyramidRandoms[0] + NUM_PYRAMID_FLOOR_SQUARES - 1) % NUM_PYRAMID_FLOOR_SQUARES;
} }
} }
@ -1651,10 +1651,10 @@ static void SetPyramidObjectPositionsUniformly(u8 objType)
int squareId; int squareId;
u32 bits = 0; u32 bits = 0;
u8 id = GetPyramidFloorTemplateId(); u8 id = GetPyramidFloorTemplateId();
u8 *floorLayoutOffsets = AllocZeroed(16); u8 *floorLayoutOffsets = AllocZeroed(NUM_PYRAMID_FLOOR_SQUARES);
GetPyramidFloorLayoutOffsets(floorLayoutOffsets); GetPyramidFloorLayoutOffsets(floorLayoutOffsets);
squareId = gSaveBlock2Ptr->frontier.pyramidRandoms[2] % 16; squareId = gSaveBlock2Ptr->frontier.pyramidRandoms[2] % NUM_PYRAMID_FLOOR_SQUARES;
if (objType == OBJ_TRAINERS) if (objType == OBJ_TRAINERS)
{ {
numObjects = sPyramidFloorTemplates[id].numTrainers; numObjects = sPyramidFloorTemplates[id].numTrainers;
@ -1682,10 +1682,10 @@ static void SetPyramidObjectPositionsUniformly(u8 objType)
if (gBitTable[squareId] & gSaveBlock2Ptr->frontier.pyramidRandoms[3]) if (gBitTable[squareId] & gSaveBlock2Ptr->frontier.pyramidRandoms[3])
bits |= 2; bits |= 2;
} }
if (++squareId >= 16) if (++squareId >= NUM_PYRAMID_FLOOR_SQUARES)
squareId = 0; squareId = 0;
if (squareId == gSaveBlock2Ptr->frontier.pyramidRandoms[2] % 16) if (squareId == gSaveBlock2Ptr->frontier.pyramidRandoms[2] % NUM_PYRAMID_FLOOR_SQUARES)
{ {
if (bits & 1) if (bits & 1)
bits |= 6; bits |= 6;
@ -1709,7 +1709,7 @@ static bool8 SetPyramidObjectPositionsInAndNearSquare(u8 objType, u8 squareId)
int numPlacedObjects = 0; int numPlacedObjects = 0;
int numObjects; int numObjects;
u8 id = GetPyramidFloorTemplateId(); u8 id = GetPyramidFloorTemplateId();
u8 *floorLayoutOffsets = AllocZeroed(16); u8 *floorLayoutOffsets = AllocZeroed(NUM_PYRAMID_FLOOR_SQUARES);
GetPyramidFloorLayoutOffsets(floorLayoutOffsets); GetPyramidFloorLayoutOffsets(floorLayoutOffsets);
if (objType == OBJ_TRAINERS) if (objType == OBJ_TRAINERS)
@ -1775,7 +1775,7 @@ static bool8 SetPyramidObjectPositionsNearSquare(u8 objType, u8 squareId)
int r8 = 0; int r8 = 0;
int numObjects; int numObjects;
u8 id = GetPyramidFloorTemplateId(); u8 id = GetPyramidFloorTemplateId();
u8 *floorLayoutOffsets = AllocZeroed(16); u8 *floorLayoutOffsets = AllocZeroed(NUM_PYRAMID_FLOOR_SQUARES);
GetPyramidFloorLayoutOffsets(floorLayoutOffsets); GetPyramidFloorLayoutOffsets(floorLayoutOffsets);
if (objType == OBJ_TRAINERS) if (objType == OBJ_TRAINERS)
@ -1900,7 +1900,7 @@ static void GetPyramidFloorLayoutOffsets(u8 *layoutOffsets)
int rand = (gSaveBlock2Ptr->frontier.pyramidRandoms[0]) | (gSaveBlock2Ptr->frontier.pyramidRandoms[1] << 16); int rand = (gSaveBlock2Ptr->frontier.pyramidRandoms[0]) | (gSaveBlock2Ptr->frontier.pyramidRandoms[1] << 16);
u8 id = GetPyramidFloorTemplateId(); u8 id = GetPyramidFloorTemplateId();
for (i = 0; i < 16; i++) for (i = 0; i < NUM_PYRAMID_FLOOR_SQUARES; i++)
{ {
layoutOffsets[i] = sPyramidFloorTemplates[id].layoutOffsets[rand & 0x7]; layoutOffsets[i] = sPyramidFloorTemplates[id].layoutOffsets[rand & 0x7];
rand >>= 3; rand >>= 3;
@ -1931,7 +1931,7 @@ u8 GetNumBattlePyramidObjectEvents(void)
u8 i; u8 i;
struct ObjectEventTemplate *events = gSaveBlock1Ptr->objectEventTemplates; struct ObjectEventTemplate *events = gSaveBlock1Ptr->objectEventTemplates;
for (i = 0; i < 16; i++) for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{ {
if (events[i].localId == 0) if (events[i].localId == 0)
break; break;
@ -1959,7 +1959,7 @@ u16 GetBattlePyramidPickupItemId(void)
int rand; int rand;
u32 i; u32 i;
u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; u32 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
int round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / 7); int round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / FRONTIER_STAGES_PER_CHALLENGE);
if (round >= TOTAL_ROUNDS) if (round >= TOTAL_ROUNDS)
round = TOTAL_ROUNDS - 1; round = TOTAL_ROUNDS - 1;

View File

@ -1410,7 +1410,7 @@ void TryStoreHeldItemsInPyramidBag(void)
memcpy(newItems, gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode], PYRAMID_BAG_ITEMS_COUNT * sizeof(u16)); memcpy(newItems, gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode], PYRAMID_BAG_ITEMS_COUNT * sizeof(u16));
memcpy(newQuantities, gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode], PYRAMID_BAG_ITEMS_COUNT * sizeof(u8)); memcpy(newQuantities, gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode], PYRAMID_BAG_ITEMS_COUNT * sizeof(u8));
for (i = 0; i < 3; i++) for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{ {
heldItem = GetMonData(&party[i], MON_DATA_HELD_ITEM); heldItem = GetMonData(&party[i], MON_DATA_HELD_ITEM);
if (heldItem != ITEM_NONE && !AddBagItem(heldItem, 1)) if (heldItem != ITEM_NONE && !AddBagItem(heldItem, 1))
@ -1426,10 +1426,8 @@ void TryStoreHeldItemsInPyramidBag(void)
} }
heldItem = ITEM_NONE; heldItem = ITEM_NONE;
for (i = 0; i < 3; i++) for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
{
SetMonData(&party[i], MON_DATA_HELD_ITEM, &heldItem); SetMonData(&party[i], MON_DATA_HELD_ITEM, &heldItem);
}
gSpecialVar_Result = 0; gSpecialVar_Result = 0;
Free(newItems); Free(newItems);
Free(newQuantities); Free(newQuantities);

View File

@ -56,10 +56,8 @@ static void GenerateInitialRentalMons(void);
* *
*/ */
// IWRAM bss static u16 sRandMonId;
static u16 sRandMonSetId;
// const rom data
void static (*const sVerdanturfTentFuncs[])(void) = void static (*const sVerdanturfTentFuncs[])(void) =
{ {
[VERDANTURF_TENT_FUNC_INIT] = InitVerdanturfTentChallenge, [VERDANTURF_TENT_FUNC_INIT] = InitVerdanturfTentChallenge,
@ -357,7 +355,7 @@ static void GenerateOpponentMons(void)
const u16 *monSet; const u16 *monSet;
u16 species[FRONTIER_PARTY_SIZE]; u16 species[FRONTIER_PARTY_SIZE];
u16 heldItems[FRONTIER_PARTY_SIZE]; u16 heldItems[FRONTIER_PARTY_SIZE];
s32 monId = 0; s32 numMons = 0;
gFacilityTrainers = gSlateportBattleTentTrainers; gFacilityTrainers = gSlateportBattleTentTrainers;
gFacilityTrainerMons = gSlateportBattleTentMons; gFacilityTrainerMons = gSlateportBattleTentMons;
@ -366,6 +364,7 @@ static void GenerateOpponentMons(void)
{ {
do do
{ {
// Choose a random trainer, ensuring no repeats in this challenge
trainerId = Random() % NUM_BATTLE_TENT_TRAINERS; trainerId = Random() % NUM_BATTLE_TENT_TRAINERS;
for (i = 0; i < gSaveBlock2Ptr->frontier.curChallengeBattleNum; i++) for (i = 0; i < gSaveBlock2Ptr->frontier.curChallengeBattleNum; i++)
{ {
@ -376,48 +375,53 @@ static void GenerateOpponentMons(void)
gTrainerBattleOpponent_A = trainerId; gTrainerBattleOpponent_A = trainerId;
monSet = gFacilityTrainers[gTrainerBattleOpponent_A].monSet; monSet = gFacilityTrainers[gTrainerBattleOpponent_A].monSet;
while (monSet[monId] != 0xFFFF) while (monSet[numMons] != 0xFFFF)
monId++; numMons++;
if (monId > 8) if (numMons > 8)
break; break;
monId = 0; numMons = 0;
} }
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 2) if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < TENT_STAGES_PER_CHALLENGE - 1)
gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = gTrainerBattleOpponent_A; gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = gTrainerBattleOpponent_A;
monSet = gFacilityTrainers[gTrainerBattleOpponent_A].monSet; monSet = gFacilityTrainers[gTrainerBattleOpponent_A].monSet;
i = 0; i = 0;
while (i != FRONTIER_PARTY_SIZE) while (i != FRONTIER_PARTY_SIZE)
{ {
sRandMonSetId = monSet[Random() % monId]; sRandMonId = monSet[Random() % numMons];
for (j = 0; j < 6; j++)
// Ensure none of the opponent's pokemon are the same as the potential rental pokemon for the player
for (j = 0; j < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons); j++)
{ {
if (gFacilityTrainerMons[sRandMonSetId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.rentalMons[j].monId].species) if (gFacilityTrainerMons[sRandMonId].species == gFacilityTrainerMons[gSaveBlock2Ptr->frontier.rentalMons[j].monId].species)
break; break;
} }
if (j != 6) if (j != (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.rentalMons))
continue; continue;
// Ensure this species hasn't already been chosen for the opponent
for (k = 0; k < i; k++) for (k = 0; k < i; k++)
{ {
if (species[k] == gFacilityTrainerMons[sRandMonSetId].species) if (species[k] == gFacilityTrainerMons[sRandMonId].species)
break; break;
} }
if (k != i) if (k != i)
continue; continue;
// Ensure held items don't repeat on the opponent's team
for (k = 0; k < i; k++) for (k = 0; k < i; k++)
{ {
if (heldItems[k] != 0 && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonSetId].itemTableId]) if (heldItems[k] != ITEM_NONE && heldItems[k] == gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonId].itemTableId])
break; break;
} }
if (k != i) if (k != i)
continue; continue;
species[i] = gFacilityTrainerMons[sRandMonSetId].species; // Successful selection
heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonSetId].itemTableId]; species[i] = gFacilityTrainerMons[sRandMonId].species;
gFrontierTempParty[i] = sRandMonSetId; heldItems[i] = gBattleFrontierHeldItems[gFacilityTrainerMons[sRandMonId].itemTableId];
gFrontierTempParty[i] = sRandMonId;
i++; i++;
} }
} }

View File

@ -27,6 +27,7 @@
#include "constants/battle_dome.h" #include "constants/battle_dome.h"
#include "constants/battle_frontier.h" #include "constants/battle_frontier.h"
#include "constants/battle_frontier_mons.h" #include "constants/battle_frontier_mons.h"
#include "constants/battle_tent.h"
#include "constants/battle_tent_mons.h" #include "constants/battle_tent_mons.h"
#include "constants/battle_tent_trainers.h" #include "constants/battle_tent_trainers.h"
#include "constants/battle_tower.h" #include "constants/battle_tower.h"
@ -1060,7 +1061,7 @@ static void SetNextFacilityOpponent(void)
u16 id; u16 id;
u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); u32 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
u16 winStreak = GetCurrentFacilityWinStreak(); u16 winStreak = GetCurrentFacilityWinStreak();
u32 challengeNum = winStreak / 7; u32 challengeNum = winStreak / FRONTIER_STAGES_PER_CHALLENGE;
SetFacilityPtrsGetLevel(); SetFacilityPtrsGetLevel();
if (battleMode == FRONTIER_MODE_MULTIS || battleMode == FRONTIER_MODE_LINK_MULTIS) if (battleMode == FRONTIER_MODE_MULTIS || battleMode == FRONTIER_MODE_LINK_MULTIS)
@ -1095,7 +1096,7 @@ static void SetNextFacilityOpponent(void)
gTrainerBattleOpponent_A = id; gTrainerBattleOpponent_A = id;
SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0); SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0);
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum + 1 < 7) if (gSaveBlock2Ptr->frontier.curChallengeBattleNum + 1 < FRONTIER_STAGES_PER_CHALLENGE)
gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = gTrainerBattleOpponent_A; gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = gTrainerBattleOpponent_A;
} }
} }
@ -1107,7 +1108,7 @@ u16 GetRandomScaledFrontierTrainerId(u8 challengeNum, u8 battleNum)
if (challengeNum <= 7) if (challengeNum <= 7)
{ {
if (battleNum == 6) if (battleNum == FRONTIER_STAGES_PER_CHALLENGE - 1)
{ {
// The last battle in each challenge has a jump in difficulty, pulls from a table with higher ranges // The last battle in each challenge has a jump in difficulty, pulls from a table with higher ranges
trainerId = (sFrontierTrainerIdRangesHard[challengeNum][1] - sFrontierTrainerIdRangesHard[challengeNum][0]) + 1; trainerId = (sFrontierTrainerIdRangesHard[challengeNum][1] - sFrontierTrainerIdRangesHard[challengeNum][0]) + 1;
@ -1136,7 +1137,7 @@ static void GetRandomScaledFrontierTrainerIdRange(u8 challengeNum, u8 battleNum,
if (challengeNum <= 7) if (challengeNum <= 7)
{ {
if (battleNum == 6) if (battleNum == FRONTIER_STAGES_PER_CHALLENGE - 1)
{ {
// The last battle in each challenge has a jump in difficulty, pulls from a table with higher ranges // The last battle in each challenge has a jump in difficulty, pulls from a table with higher ranges
range = (sFrontierTrainerIdRangesHard[challengeNum][1] - sFrontierTrainerIdRangesHard[challengeNum][0]) + 1; range = (sFrontierTrainerIdRangesHard[challengeNum][1] - sFrontierTrainerIdRangesHard[challengeNum][0]) + 1;
@ -1691,7 +1692,10 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount)
while (i != monCount) while (i != monCount)
{ {
u16 monId = monSet[Random() % bfMonCount]; u16 monId = monSet[Random() % bfMonCount];
if ((level == 50 || level == 20) && monId > FRONTIER_MONS_HIGH_TIER)
// "High tier" pokemon are only allowed on open level mode
// 20 is not a possible value for level here
if ((level == FRONTIER_MAX_LEVEL_50 || level == 20) && monId > FRONTIER_MONS_HIGH_TIER)
continue; continue;
// Ensure this pokemon species isn't a duplicate. // Ensure this pokemon species isn't a duplicate.
@ -1767,9 +1771,9 @@ static void Unused_CreateApprenticeMons(u16 trainerId, u8 firstMonId)
fixedIV = 9; fixedIV = 9;
if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50) if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50)
level = 100; level = FRONTIER_MAX_LEVEL_OPEN;
else else
level = 50; level = FRONTIER_MAX_LEVEL_50;
for (i = 0; i != 3; i++) for (i = 0; i != 3; i++)
{ {
@ -1802,8 +1806,10 @@ u16 GetRandomFrontierMonFromSet(u16 trainerId)
do do
{ {
// "High tier" pokemon are only allowed on open level mode
// 20 is not a possible value for level here
monId = monSet[Random() % numMons]; monId = monSet[Random() % numMons];
} while((level == 50 || level == 20) && monId > FRONTIER_MONS_HIGH_TIER); } while((level == FRONTIER_MAX_LEVEL_50 || level == 20) && monId > FRONTIER_MONS_HIGH_TIER);
return monId; return monId;
} }
@ -1831,11 +1837,11 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId)
u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
// By mistake Battle Tower's Level 50 challenge number is used to determine the IVs for Battle Factory. // By mistake Battle Tower's Level 50 challenge number is used to determine the IVs for Battle Factory.
#ifdef BUGFIX #ifdef BUGFIX
u8 challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / 7; u8 challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE;
#else #else
u8 challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][FRONTIER_LVL_50] / 7; u8 challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][FRONTIER_LVL_50] / FRONTIER_STAGES_PER_CHALLENGE;
#endif #endif
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < 6) if (gSaveBlock2Ptr->frontier.curChallengeBattleNum < FRONTIER_STAGES_PER_CHALLENGE - 1)
fixedIV = GetFactoryMonFixedIV(challengeNum, FALSE); fixedIV = GetFactoryMonFixedIV(challengeNum, FALSE);
else else
fixedIV = GetFactoryMonFixedIV(challengeNum, TRUE); // Last trainer in challenge uses higher IVs fixedIV = GetFactoryMonFixedIV(challengeNum, TRUE); // Last trainer in challenge uses higher IVs
@ -1882,7 +1888,7 @@ static void FillFactoryTentTrainerParty(u16 trainerId, u8 firstMonId)
{ {
u8 i, j; u8 i, j;
u8 friendship; u8 friendship;
u8 level = 30; u8 level = TENT_MIN_LEVEL;
u8 fixedIV = 0; u8 fixedIV = 0;
u32 otID = T1_READ_32(gSaveBlock2Ptr->playerTrainerId); u32 otID = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
@ -2043,7 +2049,7 @@ void DoSpecialTrainerBattle(void)
break; break;
case SPECIAL_BATTLE_EREADER: case SPECIAL_BATTLE_EREADER:
ZeroEnemyPartyMons(); ZeroEnemyPartyMons();
for (i = 0; i < 3; i++) for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.ereaderTrainer.party); i++)
CreateBattleTowerMon(&gEnemyParty[i], &gSaveBlock2Ptr->frontier.ereaderTrainer.party[i]); CreateBattleTowerMon(&gEnemyParty[i], &gSaveBlock2Ptr->frontier.ereaderTrainer.party[i]);
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_EREADER_TRAINER; gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_EREADER_TRAINER;
gTrainerBattleOpponent_A = 0; gTrainerBattleOpponent_A = 0;
@ -2189,7 +2195,7 @@ static void SaveTowerChallenge(void)
{ {
u16 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; u16 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
u16 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); u16 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
s32 challengeNum = (signed)(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7); s32 challengeNum = (signed)(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE);
if (gSpecialVar_0x8005 == 0 && (challengeNum > 1 || gSaveBlock2Ptr->frontier.curChallengeBattleNum != 0)) if (gSpecialVar_0x8005 == 0 && (challengeNum > 1 || gSaveBlock2Ptr->frontier.curChallengeBattleNum != 0))
SaveBattleTowerRecord(); SaveBattleTowerRecord();
@ -2279,7 +2285,7 @@ static void LoadMultiPartnerCandidatesData(void)
objEventTemplates = gSaveBlock1Ptr->objectEventTemplates; objEventTemplates = gSaveBlock1Ptr->objectEventTemplates;
lvlMode = gSaveBlock2Ptr->frontier.lvlMode; lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE); battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7; challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE;
species1 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL); species1 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL);
species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL); species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL);
level = SetFacilityPtrsGetLevel(); level = SetFacilityPtrsGetLevel();
@ -2338,7 +2344,7 @@ static void LoadMultiPartnerCandidatesData(void)
for (i = 0; i < APPRENTICE_COUNT; i++) for (i = 0; i < APPRENTICE_COUNT; i++)
{ {
if (gSaveBlock2Ptr->apprentices[i].lvlMode != 0 if (gSaveBlock2Ptr->apprentices[i].lvlMode != 0
&& sApprenticeChallengeThreshold[gSaveBlock2Ptr->apprentices[i].numQuestions] / 7 <= challengeNum && sApprenticeChallengeThreshold[gSaveBlock2Ptr->apprentices[i].numQuestions] / FRONTIER_STAGES_PER_CHALLENGE <= challengeNum
&& gSaveBlock2Ptr->apprentices[i].lvlMode - 1 == lvlMode) && gSaveBlock2Ptr->apprentices[i].lvlMode - 1 == lvlMode)
{ {
k = 0; k = 0;
@ -2377,7 +2383,7 @@ static void LoadMultiPartnerCandidatesData(void)
checksum += record[j]; checksum += record[j];
} }
if (gSaveBlock2Ptr->frontier.towerRecords[i].winStreak / 7 <= challengeNum if (gSaveBlock2Ptr->frontier.towerRecords[i].winStreak / FRONTIER_STAGES_PER_CHALLENGE <= challengeNum
&& gSaveBlock2Ptr->frontier.towerRecords[i].lvlMode == lvlMode && gSaveBlock2Ptr->frontier.towerRecords[i].lvlMode == lvlMode
&& recordHasData && recordHasData
&& gSaveBlock2Ptr->frontier.towerRecords[i].checksum == checksum) && gSaveBlock2Ptr->frontier.towerRecords[i].checksum == checksum)
@ -2458,7 +2464,7 @@ static void ShowPartnerCandidateMessage(void)
s32 monId; s32 monId;
s32 level = SetFacilityPtrsGetLevel(); s32 level = SetFacilityPtrsGetLevel();
u16 winStreak = GetCurrentFacilityWinStreak(); u16 winStreak = GetCurrentFacilityWinStreak();
s32 challengeNum = winStreak / 7; s32 challengeNum = winStreak / FRONTIER_STAGES_PER_CHALLENGE;
s32 k = gSpecialVar_LastTalked - 2; s32 k = gSpecialVar_LastTalked - 2;
s32 trainerId = gSaveBlock2Ptr->frontier.trainerIds[k]; s32 trainerId = gSaveBlock2Ptr->frontier.trainerIds[k];
@ -2517,7 +2523,7 @@ static void ShowPartnerCandidateMessage(void)
gSaveBlock2Ptr->frontier.trainerIds[18] = gFrontierTempParty[0]; gSaveBlock2Ptr->frontier.trainerIds[18] = gFrontierTempParty[0];
gSaveBlock2Ptr->frontier.trainerIds[19] = gFrontierTempParty[1]; gSaveBlock2Ptr->frontier.trainerIds[19] = gFrontierTempParty[1];
} }
for (k = 0; k < 14; k++) for (k = 0; k < FRONTIER_STAGES_PER_CHALLENGE * 2; k++)
{ {
while (1) while (1)
{ {
@ -2576,7 +2582,7 @@ static void LoadLinkMultiOpponentsData(void)
case 0: case 0:
if (battleMode == FRONTIER_MODE_LINK_MULTIS) if (battleMode == FRONTIER_MODE_LINK_MULTIS)
{ {
challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7; challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE;
if (IsLinkTaskFinished()) if (IsLinkTaskFinished())
{ {
SendBlock(BitmaskAllOtherLinkPlayers(), &challengeNum, sizeof(challengeNum)); SendBlock(BitmaskAllOtherLinkPlayers(), &challengeNum, sizeof(challengeNum));
@ -2596,7 +2602,7 @@ static void LoadLinkMultiOpponentsData(void)
challengeNum = gBlockRecvBuffer[0][0]; challengeNum = gBlockRecvBuffer[0][0];
else else
challengeNum = gBlockRecvBuffer[1][0]; challengeNum = gBlockRecvBuffer[1][0];
for (i = 0; i < 14; i++) for (i = 0; i < FRONTIER_STAGES_PER_CHALLENGE * 2; i++)
{ {
do do
{ {
@ -2840,7 +2846,7 @@ static void FillEReaderTrainerWithPlayerData(void)
ereaderTrainer->winStreak = 1; ereaderTrainer->winStreak = 1;
j = 7; j = 7;
for (i = 0; i < 6; i++) for (i = 0; i < EASY_CHAT_BATTLE_WORDS_COUNT; i++)
{ {
ereaderTrainer->greeting[i] = gSaveBlock1Ptr->easyChatBattleStart[i]; ereaderTrainer->greeting[i] = gSaveBlock1Ptr->easyChatBattleStart[i];
ereaderTrainer->farewellPlayerLost[i] = j; ereaderTrainer->farewellPlayerLost[i] = j;
@ -2848,7 +2854,7 @@ static void FillEReaderTrainerWithPlayerData(void)
j++; j++;
} }
for (i = 0; i < 3; i++) for (i = 0; i < (int)ARRAY_COUNT(ereaderTrainer->party); i++)
ConvertPokemonToBattleTowerPokemon(&gPlayerParty[i], &ereaderTrainer->party[i]); ConvertPokemonToBattleTowerPokemon(&gPlayerParty[i], &ereaderTrainer->party[i]);
SetEReaderTrainerChecksum(ereaderTrainer); SetEReaderTrainerChecksum(ereaderTrainer);
@ -3246,12 +3252,12 @@ u8 GetFrontierEnemyMonLevel(u8 lvlMode)
{ {
default: default:
case FRONTIER_LVL_50: case FRONTIER_LVL_50:
level = 50; level = FRONTIER_MAX_LEVEL_50;
break; break;
case FRONTIER_LVL_OPEN: case FRONTIER_LVL_OPEN:
level = GetHighestLevelInPlayerParty(); level = GetHighestLevelInPlayerParty();
if (level < 60) if (level < FRONTIER_MIN_LEVEL_OPEN)
level = 60; level = FRONTIER_MIN_LEVEL_OPEN;
break; break;
} }
@ -3321,7 +3327,7 @@ static u16 GetBattleTentTrainerId(void)
static u8 SetTentPtrsGetLevel(void) static u8 SetTentPtrsGetLevel(void)
{ {
u8 level = 30; u8 level = TENT_MIN_LEVEL;
u32 facility = VarGet(VAR_FRONTIER_FACILITY); u32 facility = VarGet(VAR_FRONTIER_FACILITY);
if (facility == FRONTIER_FACILITY_FACTORY) if (facility == FRONTIER_FACILITY_FACTORY)
@ -3346,8 +3352,8 @@ static u8 SetTentPtrsGetLevel(void)
} }
level = GetHighestLevelInPlayerParty(); level = GetHighestLevelInPlayerParty();
if (level < 30) if (level < TENT_MIN_LEVEL)
level = 30; level = TENT_MIN_LEVEL;
return level; return level;
} }
@ -3369,7 +3375,7 @@ static void SetNextBattleTentOpponent(void)
gTrainerBattleOpponent_A = trainerId; gTrainerBattleOpponent_A = trainerId;
SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0); SetBattleFacilityTrainerGfxId(gTrainerBattleOpponent_A, 0);
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum + 1 < 3) if (gSaveBlock2Ptr->frontier.curChallengeBattleNum + 1 < TENT_STAGES_PER_CHALLENGE)
gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = gTrainerBattleOpponent_A; gSaveBlock2Ptr->frontier.trainerIds[gSaveBlock2Ptr->frontier.curChallengeBattleNum] = gTrainerBattleOpponent_A;
} }

View File

@ -1038,7 +1038,7 @@ static const struct PyramidWildMon sOpenLevelWildMons_Round20[] =
} }
}; };
static const struct PyramidWildMon *const sOpenLevelWildMonPointers[] = static const struct PyramidWildMon *const sOpenLevelWildMonPointers[TOTAL_ROUNDS] =
{ {
sOpenLevelWildMons_Round1, sOpenLevelWildMons_Round1,
sOpenLevelWildMons_Round2, sOpenLevelWildMons_Round2,

View File

@ -29,6 +29,7 @@
#include "load_save.h" #include "load_save.h"
#include "battle_dome.h" #include "battle_dome.h"
#include "constants/battle_frontier.h" #include "constants/battle_frontier.h"
#include "constants/battle_pike.h"
#include "constants/frontier_util.h" #include "constants/frontier_util.h"
#include "constants/trainers.h" #include "constants/trainers.h"
#include "constants/game_stat.h" #include "constants/game_stat.h"
@ -968,7 +969,7 @@ static void PrintHyphens(s32 y)
s32 i; s32 i;
u8 text[37]; u8 text[37];
for (i = 0; i < 36; i++) for (i = 0; i < (int)ARRAY_COUNT(text) - 1; i++)
text[i] = CHAR_HYPHEN; text[i] = CHAR_HYPHEN;
text[i] = EOS; text[i] = EOS;
@ -1860,25 +1861,25 @@ static void GiveBattlePoints(void)
switch (facility) switch (facility)
{ {
case FRONTIER_FACILITY_TOWER: case FRONTIER_FACILITY_TOWER:
challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7; challengeNum = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE;
break; break;
case FRONTIER_FACILITY_DOME: case FRONTIER_FACILITY_DOME:
challengeNum = gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode]; challengeNum = gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode];
break; break;
case FRONTIER_FACILITY_PALACE: case FRONTIER_FACILITY_PALACE:
challengeNum = gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode] / 7; challengeNum = gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE;
break; break;
case FRONTIER_FACILITY_ARENA: case FRONTIER_FACILITY_ARENA:
challengeNum = gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] / 7; challengeNum = gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] / FRONTIER_STAGES_PER_CHALLENGE;
break; break;
case FRONTIER_FACILITY_FACTORY: case FRONTIER_FACILITY_FACTORY:
challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / 7; challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / FRONTIER_STAGES_PER_CHALLENGE;
break; break;
case FRONTIER_FACILITY_PIKE: case FRONTIER_FACILITY_PIKE:
challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / 14; challengeNum = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] / NUM_PIKE_ROOMS;
break; break;
case FRONTIER_FACILITY_PYRAMID: case FRONTIER_FACILITY_PYRAMID:
challengeNum = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / 7; challengeNum = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] / FRONTIER_STAGES_PER_CHALLENGE;
break; break;
} }
@ -1982,7 +1983,7 @@ static void AppendIfValid(u16 species, u16 heldItem, u16 hp, u8 lvlMode, u8 monL
if (gFrontierBannedSpecies[i] != 0xFFFF) if (gFrontierBannedSpecies[i] != 0xFFFF)
return; return;
if (lvlMode == FRONTIER_LVL_50 && monLevel > 50) if (lvlMode == FRONTIER_LVL_50 && monLevel > FRONTIER_MAX_LEVEL_50)
return; return;
for (i = 0; i < *count && speciesArray[i] != species; i++) for (i = 0; i < *count && speciesArray[i] != species; i++)

View File

@ -12,6 +12,7 @@
#include "string_util.h" #include "string_util.h"
#include "task.h" #include "task.h"
#include "text.h" #include "text.h"
#include "constants/battle_frontier.h"
#include "constants/layouts.h" #include "constants/layouts.h"
#include "constants/region_map_sections.h" #include "constants/region_map_sections.h"
#include "constants/weather.h" #include "constants/weather.h"
@ -185,7 +186,7 @@ static const u8 sText_PyramidFloor6[] = _("PYRAMID FLOOR 6");
static const u8 sText_PyramidFloor7[] = _("PYRAMID FLOOR 7"); static const u8 sText_PyramidFloor7[] = _("PYRAMID FLOOR 7");
static const u8 sText_Pyramid[] = _("PYRAMID"); static const u8 sText_Pyramid[] = _("PYRAMID");
static const u8 * const sBattlePyramid_MapHeaderStrings[] = static const u8 * const sBattlePyramid_MapHeaderStrings[FRONTIER_STAGES_PER_CHALLENGE + 1] =
{ {
sText_PyramidFloor1, sText_PyramidFloor1,
sText_PyramidFloor2, sText_PyramidFloor2,
@ -309,7 +310,7 @@ static void ShowMapNamePopUpWindow(void)
if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_TOP) if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_TOP)
{ {
withoutPrefixPtr = &(mapDisplayHeader[3]); withoutPrefixPtr = &(mapDisplayHeader[3]);
mapDisplayHeaderSource = sBattlePyramid_MapHeaderStrings[7]; mapDisplayHeaderSource = sBattlePyramid_MapHeaderStrings[FRONTIER_STAGES_PER_CHALLENGE];
} }
else else
{ {

View File

@ -202,7 +202,7 @@ static u32 Client_Run(struct MysteryGiftClient * client)
MysteryGiftLink_InitSend(&client->link, MG_LINKID_GAME_DATA, client->sendBuffer, sizeof(struct MysteryGiftLinkGameData)); MysteryGiftLink_InitSend(&client->link, MG_LINKID_GAME_DATA, client->sendBuffer, sizeof(struct MysteryGiftLinkGameData));
break; break;
case CLI_LOAD_TOSS_RESPONSE: case CLI_LOAD_TOSS_RESPONSE:
// param here is set by MG_STATE_LINK_ASK_TOSS or MG_STATE_LINK_ASK_TOSS_UNRECEIVED // param here is set by MG_STATE_CLIENT_ASK_TOSS or MG_STATE_CLIENT_ASK_TOSS_UNRECEIVED
MysteryGiftClient_InitSendWord(client, MG_LINKID_RESPONSE, client->param); MysteryGiftClient_InitSendWord(client, MG_LINKID_RESPONSE, client->param);
break; break;
case CLI_SAVE_CARD: case CLI_SAVE_CARD:

View File

@ -5647,11 +5647,11 @@ static u8 GetBattleEntryLevelCap(void)
case FACILITY_MULTI_OR_EREADER: case FACILITY_MULTI_OR_EREADER:
return MAX_LEVEL; return MAX_LEVEL;
case FACILITY_UNION_ROOM: case FACILITY_UNION_ROOM:
return 30; return UNION_ROOM_MAX_LEVEL;
default: // Battle Frontier default: // Battle Frontier
if (gSpecialVar_0x8004 == FRONTIER_LVL_50) if (gSpecialVar_0x8004 == FRONTIER_LVL_50)
return 50; return FRONTIER_MAX_LEVEL_50;
return MAX_LEVEL; return FRONTIER_MAX_LEVEL_OPEN;
} }
} }

View File

@ -2464,7 +2464,7 @@ void CreateBattleTowerMon_HandleLevel(struct Pokemon *mon, struct BattleTowerPok
if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50) if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50)
level = GetFrontierEnemyMonLevel(gSaveBlock2Ptr->frontier.lvlMode); level = GetFrontierEnemyMonLevel(gSaveBlock2Ptr->frontier.lvlMode);
else if (lvl50) else if (lvl50)
level = 50; level = FRONTIER_MAX_LEVEL_50;
else else
level = src->level; level = src->level;

View File

@ -42,9 +42,10 @@
#include "text_window.h" #include "text_window.h"
#include "trainer_card.h" #include "trainer_card.h"
#include "window.h" #include "window.h"
#include "constants/songs.h"
#include "union_room.h" #include "union_room.h"
#include "constants/battle_frontier.h"
#include "constants/rgb.h" #include "constants/rgb.h"
#include "constants/songs.h"
// Menu actions // Menu actions
enum enum
@ -138,7 +139,7 @@ static bool8 FieldCB_ReturnToFieldStartMenu(void);
static const struct WindowTemplate sSafariBallsWindowTemplate = {0, 1, 1, 9, 4, 0xF, 8}; static const struct WindowTemplate sSafariBallsWindowTemplate = {0, 1, 1, 9, 4, 0xF, 8};
static const u8* const sPyramidFloorNames[] = static const u8* const sPyramidFloorNames[FRONTIER_STAGES_PER_CHALLENGE + 1] =
{ {
gText_Floor1, gText_Floor1,
gText_Floor2, gText_Floor2,
@ -392,7 +393,7 @@ static void ShowSafariBallsWindow(void)
static void ShowPyramidFloorWindow(void) static void ShowPyramidFloorWindow(void)
{ {
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum == 7) if (gSaveBlock2Ptr->frontier.curChallengeBattleNum == FRONTIER_STAGES_PER_CHALLENGE)
sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_1); sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_1);
else else
sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_2); sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_2);

View File

@ -4318,7 +4318,7 @@ static bool32 HasAtLeastTwoMonsOfLevel30OrLower(void)
for (i = 0; i < gPlayerPartyCount; i++) for (i = 0; i < gPlayerPartyCount; i++)
{ {
if (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) <= 30 if (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) <= UNION_ROOM_MAX_LEVEL
&& GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG)
count++; count++;
} }