Merge pull request #1678 from GriffinRichards/const-frontier

Add some battle frontier constant usage
This commit is contained in:
GriffinR 2022-06-18 10:22:58 -04:00 committed by GitHub
commit 57222323c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 394 additions and 326 deletions

View File

@ -22,18 +22,20 @@ BattleFrontier_Lounge2_EventScript_AlreadyMetManiac::
end end
BattleFrontier_Lounge2_EventScript_GiveAdvice:: BattleFrontier_Lounge2_EventScript_GiveAdvice::
call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 0, BattleFrontier_Lounge2_EventScript_BufferSingle call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_TOWER_SINGLES, BattleFrontier_Lounge2_EventScript_BufferSingle
call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 1, BattleFrontier_Lounge2_EventScript_BufferDouble call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_TOWER_DOUBLES, BattleFrontier_Lounge2_EventScript_BufferDouble
call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 2, BattleFrontier_Lounge2_EventScript_BufferMulti call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_TOWER_MULTIS, BattleFrontier_Lounge2_EventScript_BufferMulti
call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 3, BattleFrontier_Lounge2_EventScript_BufferMultiLink call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_TOWER_LINK, BattleFrontier_Lounge2_EventScript_BufferMultiLink
call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 4, BattleFrontier_Lounge2_EventScript_BufferBattleDome call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_DOME, BattleFrontier_Lounge2_EventScript_BufferBattleDome
call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 5, BattleFrontier_Lounge2_EventScript_BufferBattleFactory call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_FACTORY, BattleFrontier_Lounge2_EventScript_BufferBattleFactory
call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 6, BattleFrontier_Lounge2_EventScript_BufferBattlePalace call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_PALACE, BattleFrontier_Lounge2_EventScript_BufferBattlePalace
call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 7, BattleFrontier_Lounge2_EventScript_BufferBattleArena call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_ARENA, BattleFrontier_Lounge2_EventScript_BufferBattleArena
call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 8, BattleFrontier_Lounge2_EventScript_BufferBattlePike call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_PIKE, BattleFrontier_Lounge2_EventScript_BufferBattlePike
call_if_eq VAR_FRONTIER_MANIAC_FACILITY, 9, BattleFrontier_Lounge2_EventScript_BufferBattlePyramid call_if_eq VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_PYRAMID, BattleFrontier_Lounge2_EventScript_BufferBattlePyramid
call_if_le VAR_FRONTIER_MANIAC_FACILITY, 3, BattleFrontier_Lounge2_EventScript_BattleTowerNews @ <= FRONTIER_MANIAC_TOWER_LINK is any Battle Tower mode
call_if_ge VAR_FRONTIER_MANIAC_FACILITY, 4, BattleFrontier_Lounge2_EventScript_FacilityNews call_if_le VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_TOWER_LINK, BattleFrontier_Lounge2_EventScript_BattleTowerNews
@ >= FRONTIER_MANIAC_DOME is any facility other than Battle Tower
call_if_ge VAR_FRONTIER_MANIAC_FACILITY, FRONTIER_MANIAC_DOME, BattleFrontier_Lounge2_EventScript_FacilityNews
special ShowFrontierManiacMessage special ShowFrontierManiacMessage
waitmessage waitmessage
waitbuttonpress waitbuttonpress

View File

@ -166,7 +166,7 @@ BattleFrontier_BattleTowerLobby_Text_LookingForwardToNextBattle::
.string "I'll be looking forward to your\n" .string "I'll be looking forward to your\n"
.string "next battle!$" .string "next battle!$"
gTVBravoTrainerBattleTowerText00:: BravoTrainerBattleTower_Text_Intro::
.string "Yeah!\n" .string "Yeah!\n"
.string "It's BRAVO TRAINER time!\p" .string "It's BRAVO TRAINER time!\p"
.string "Today, we're going to profile {STR_VAR_1},\n" .string "Today, we're going to profile {STR_VAR_1},\n"
@ -174,12 +174,12 @@ gTVBravoTrainerBattleTowerText00::
.string "For the challenge, {STR_VAR_1} entered\n" .string "For the challenge, {STR_VAR_1} entered\n"
.string "one wicked {STR_VAR_2}.$" .string "one wicked {STR_VAR_2}.$"
gTVBravoTrainerBattleTowerText01:: BravoTrainerBattleTower_Text_NewRecord::
.string "The pair set a new record of {STR_VAR_2} wins\n" .string "The pair set a new record of {STR_VAR_2} wins\n"
.string "in a row in {STR_VAR_1} competition!\l" .string "in a row in {STR_VAR_1} competition!\l"
.string "Bravo, TRAINER!$" .string "Bravo, TRAINER!$"
gTVBravoTrainerBattleTowerText02:: BravoTrainerBattleTower_Text_Lost::
.string "The twosome finally succumbed to\n" .string "The twosome finally succumbed to\n"
.string "{STR_VAR_1} in match number {STR_VAR_2}.\l" .string "{STR_VAR_1} in match number {STR_VAR_2}.\l"
.string "Nice try, TRAINER!\p" .string "Nice try, TRAINER!\p"
@ -188,7 +188,7 @@ gTVBravoTrainerBattleTowerText02::
.string "We asked the TRAINER for impressions\n" .string "We asked the TRAINER for impressions\n"
.string "on the match with {STR_VAR_1}.$" .string "on the match with {STR_VAR_1}.$"
gTVBravoTrainerBattleTowerText03:: BravoTrainerBattleTower_Text_Won::
.string "The twosome won it all by defeating\n" .string "The twosome won it all by defeating\n"
.string "{STR_VAR_1}'s {STR_VAR_2} thoroughly.\l" .string "{STR_VAR_1}'s {STR_VAR_2} thoroughly.\l"
.string "Bravo, TRAINER!\p" .string "Bravo, TRAINER!\p"
@ -197,7 +197,7 @@ gTVBravoTrainerBattleTowerText03::
.string "We asked the TRAINER for impressions\n" .string "We asked the TRAINER for impressions\n"
.string "on the moment of glory.$" .string "on the moment of glory.$"
gTVBravoTrainerBattleTowerText04:: BravoTrainerBattleTower_Text_LostFinal::
.string "After a string of wins, the pair finally\n" .string "After a string of wins, the pair finally\n"
.string "succumbed to {STR_VAR_1}'s {STR_VAR_2},\l" .string "succumbed to {STR_VAR_1}'s {STR_VAR_2},\l"
.string "their final hurdle.\p" .string "their final hurdle.\p"
@ -208,7 +208,7 @@ gTVBravoTrainerBattleTowerText04::
.string "We asked the TRAINER for impressions\n" .string "We asked the TRAINER for impressions\n"
.string "on battling the celebrity pair.$" .string "on battling the celebrity pair.$"
gTVBravoTrainerBattleTowerText05:: BravoTrainerBattleTower_Text_Satisfied::
.string "This is what the TRAINER had to say:\n" .string "This is what the TRAINER had to say:\n"
.string "“I'm satisfied!”\p" .string "“I'm satisfied!”\p"
.string "Now isn't that a refreshing reply?\n" .string "Now isn't that a refreshing reply?\n"
@ -218,7 +218,7 @@ gTVBravoTrainerBattleTowerText05::
.string "I found out exactly how satisfied\n" .string "I found out exactly how satisfied\n"
.string "when I heard the TRAINER say this:$" .string "when I heard the TRAINER say this:$"
gTVBravoTrainerBattleTowerText06:: BravoTrainerBattleTower_Text_Unsatisfied::
.string "This is what the TRAINER had to say:\n" .string "This is what the TRAINER had to say:\n"
.string "“I'm not satisfied…”\p" .string "“I'm not satisfied…”\p"
.string "Our TRAINER was obviously a little down\n" .string "Our TRAINER was obviously a little down\n"
@ -228,22 +228,22 @@ gTVBravoTrainerBattleTowerText06::
.string "Anyway, I found out how dissatisfied\n" .string "Anyway, I found out how dissatisfied\n"
.string "our TRAINER was when I heard this:$" .string "our TRAINER was when I heard this:$"
gTVBravoTrainerBattleTowerText07:: BravoTrainerBattleTower_Text_None1::
.string "None$" .string "None$"
gTVBravoTrainerBattleTowerText08:: BravoTrainerBattleTower_Text_None2::
.string "None$" .string "None$"
gTVBravoTrainerBattleTowerText09:: BravoTrainerBattleTower_Text_None3::
.string "None$" .string "None$"
gTVBravoTrainerBattleTowerText10:: BravoTrainerBattleTower_Text_None4::
.string "None$" .string "None$"
gTVBravoTrainerBattleTowerText11:: BravoTrainerBattleTower_Text_Response::
.string "{STR_VAR_1}.”$" .string "{STR_VAR_1}.”$"
gTVBravoTrainerBattleTowerText12:: BravoTrainerBattleTower_Text_ResponseSatisfied::
.string "{STR_VAR_1}.”\n" .string "{STR_VAR_1}.”\n"
.string "Now isn't that great?\p" .string "Now isn't that great?\p"
.string "It really expresses {STR_VAR_2}'s joy,\n" .string "It really expresses {STR_VAR_2}'s joy,\n"
@ -252,7 +252,7 @@ gTVBravoTrainerBattleTowerText12::
.string "end… It really was what you'd call\l" .string "end… It really was what you'd call\l"
.string "{STR_VAR_1}”!$" .string "{STR_VAR_1}”!$"
gTVBravoTrainerBattleTowerText13:: BravoTrainerBattleTower_Text_ResponseUnsatisfied::
.string "{STR_VAR_1}.”\n" .string "{STR_VAR_1}.”\n"
.string "Now isn't that fitting?\p" .string "Now isn't that fitting?\p"
.string "That battle with {STR_VAR_3} at the\n" .string "That battle with {STR_VAR_3} at the\n"
@ -261,7 +261,7 @@ gTVBravoTrainerBattleTowerText13::
.string "{STR_VAR_2}'s disappointment comes across\n" .string "{STR_VAR_2}'s disappointment comes across\n"
.string "loud and clear, I'd say!$" .string "loud and clear, I'd say!$"
gTVBravoTrainerBattleTowerText14:: BravoTrainerBattleTower_Text_Outro::
.string "Bravo, {STR_VAR_1}!\n" .string "Bravo, {STR_VAR_1}!\n"
.string "Bravo, {STR_VAR_2}!\p" .string "Bravo, {STR_VAR_2}!\p"
.string "I hope we can count on seeing\n" .string "I hope we can count on seeing\n"

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

@ -274,4 +274,21 @@
#define SMARTSHOPPER_NUM_ITEMS 3 #define SMARTSHOPPER_NUM_ITEMS 3
// TV Show states for Bravo Trainer's Battle Tower interview
#define BRAVOTOWER_STATE_INTRO 0
#define BRAVOTOWER_STATE_NEW_RECORD 1
#define BRAVOTOWER_STATE_LOST 2
#define BRAVOTOWER_STATE_WON 3
#define BRAVOTOWER_STATE_LOST_FINAL 4
#define BRAVOTOWER_STATE_SATISFIED 5
#define BRAVOTOWER_STATE_UNSATISFIED 6
#define BRAVOTOWER_STATE_UNUSED_1 7
#define BRAVOTOWER_STATE_UNUSED_2 8
#define BRAVOTOWER_STATE_UNUSED_3 9
#define BRAVOTOWER_STATE_UNUSED_4 10
#define BRAVOTOWER_STATE_RESPONSE 11
#define BRAVOTOWER_STATE_RESPONSE_SATISFIED 12
#define BRAVOTOWER_STATE_RESPONSE_UNSATISFIED 13
#define BRAVOTOWER_STATE_OUTRO 14
#endif //GUARD_CONSTANTS_TV_H #endif //GUARD_CONSTANTS_TV_H

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

@ -21,21 +21,21 @@ extern const u8 gTVBravoTrainerText05[];
extern const u8 gTVBravoTrainerText06[]; extern const u8 gTVBravoTrainerText06[];
extern const u8 gTVBravoTrainerText07[]; extern const u8 gTVBravoTrainerText07[];
extern const u8 gTVBravoTrainerText08[]; extern const u8 gTVBravoTrainerText08[];
extern const u8 gTVBravoTrainerBattleTowerText00[]; extern const u8 BravoTrainerBattleTower_Text_Intro[];
extern const u8 gTVBravoTrainerBattleTowerText01[]; extern const u8 BravoTrainerBattleTower_Text_NewRecord[];
extern const u8 gTVBravoTrainerBattleTowerText02[]; extern const u8 BravoTrainerBattleTower_Text_Lost[];
extern const u8 gTVBravoTrainerBattleTowerText03[]; extern const u8 BravoTrainerBattleTower_Text_Won[];
extern const u8 gTVBravoTrainerBattleTowerText04[]; extern const u8 BravoTrainerBattleTower_Text_LostFinal[];
extern const u8 gTVBravoTrainerBattleTowerText05[]; extern const u8 BravoTrainerBattleTower_Text_Satisfied[];
extern const u8 gTVBravoTrainerBattleTowerText06[]; extern const u8 BravoTrainerBattleTower_Text_Unsatisfied[];
extern const u8 gTVBravoTrainerBattleTowerText07[]; extern const u8 BravoTrainerBattleTower_Text_None1[];
extern const u8 gTVBravoTrainerBattleTowerText08[]; extern const u8 BravoTrainerBattleTower_Text_None2[];
extern const u8 gTVBravoTrainerBattleTowerText09[]; extern const u8 BravoTrainerBattleTower_Text_None3[];
extern const u8 gTVBravoTrainerBattleTowerText10[]; extern const u8 BravoTrainerBattleTower_Text_None4[];
extern const u8 gTVBravoTrainerBattleTowerText11[]; extern const u8 BravoTrainerBattleTower_Text_Response[];
extern const u8 gTVBravoTrainerBattleTowerText12[]; extern const u8 BravoTrainerBattleTower_Text_ResponseSatisfied[];
extern const u8 gTVBravoTrainerBattleTowerText13[]; extern const u8 BravoTrainerBattleTower_Text_ResponseUnsatisfied[];
extern const u8 gTVBravoTrainerBattleTowerText14[]; extern const u8 BravoTrainerBattleTower_Text_Outro[];
extern const u8 gTVFanClubOpinionsText00[]; extern const u8 gTVFanClubOpinionsText00[];
extern const u8 gTVFanClubOpinionsText01[]; extern const u8 gTVFanClubOpinionsText01[];
extern const u8 gTVFanClubOpinionsText02[]; extern const u8 gTVFanClubOpinionsText02[];

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

@ -5863,7 +5863,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))
@ -1158,11 +1158,11 @@ u8 GetBattlePikeWildMonHeaderId(void)
u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode; u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
u16 winStreak = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode]; u16 winStreak = gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode];
if (winStreak <= 280) if (winStreak <= 20 * NUM_PIKE_ROOMS)
headerId = 0; headerId = 0;
else if (winStreak <= 560) else if (winStreak <= 40 * NUM_PIKE_ROOMS)
headerId = 1; headerId = 1;
else if (winStreak <= 840) else if (winStreak <= 60 * NUM_PIKE_ROOMS)
headerId = 2; headerId = 2;
else else
headerId = 3; headerId = 3;
@ -1392,10 +1392,10 @@ static void PrepareOneTrainer(bool8 difficult)
if (!difficult) if (!difficult)
battleNum = 1; battleNum = 1;
else else
battleNum = 6; battleNum = FRONTIER_STAGES_PER_CHALLENGE - 1;
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;
@ -1326,19 +1327,19 @@ void PutNewBattleTowerRecord(struct EmeraldBattleTowerRecord *newRecordEm)
if (gSaveBlock2Ptr->frontier.towerRecords[i].trainerId[j] != newRecord->trainerId[j]) if (gSaveBlock2Ptr->frontier.towerRecords[i].trainerId[j] != newRecord->trainerId[j])
break; break;
} }
if (j == 4) if (j == TRAINER_ID_LENGTH)
{ {
for (k = 0; k < PLAYER_NAME_LENGTH; k++) for (k = 0; k < PLAYER_NAME_LENGTH; k++)
{ {
#ifdef BUGFIX // Incorrect index being used
if (gSaveBlock2Ptr->frontier.towerRecords[i].name[k] != newRecord->name[k]) #ifdef BUGFIX
#define INDEX k
#else
#define INDEX j
#endif
if (gSaveBlock2Ptr->frontier.towerRecords[i].name[INDEX] != newRecord->name[INDEX])
break; break;
if (newRecord->name[k] == EOS) if (newRecord->name[INDEX] == EOS)
#else
if (gSaveBlock2Ptr->frontier.towerRecords[i].name[j] != newRecord->name[j])
break;
if (newRecord->name[j] == EOS)
#endif
{ {
k = PLAYER_NAME_LENGTH; k = PLAYER_NAME_LENGTH;
break; break;
@ -1634,7 +1635,7 @@ static void FillTentTrainerParty(u8 monsCount)
static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount) static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount)
{ {
s32 i, j; s32 i, j;
u16 chosenMonIndices[4]; u16 chosenMonIndices[MAX_FRONTIER_PARTY_SIZE];
u8 friendship = MAX_FRIENDSHIP; u8 friendship = MAX_FRIENDSHIP;
u8 level = SetFacilityPtrsGetLevel(); u8 level = SetFacilityPtrsGetLevel();
u8 fixedIV = 0; u8 fixedIV = 0;
@ -1650,7 +1651,7 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount)
} }
else if (trainerId == TRAINER_EREADER) else if (trainerId == TRAINER_EREADER)
{ {
for (i = firstMonId; i < firstMonId + 3; i++) for (i = firstMonId; i < firstMonId + FRONTIER_PARTY_SIZE; i++)
CreateBattleTowerMon(&gEnemyParty[i], &gSaveBlock2Ptr->frontier.ereaderTrainer.party[i - firstMonId]); CreateBattleTowerMon(&gEnemyParty[i], &gSaveBlock2Ptr->frontier.ereaderTrainer.party[i - firstMonId]);
return; return;
} }
@ -1675,7 +1676,7 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount)
else else
{ {
// Apprentice. // Apprentice.
for (i = firstMonId; i < firstMonId + 3; i++) for (i = firstMonId; i < firstMonId + FRONTIER_PARTY_SIZE; i++)
CreateApprenticeMon(&gEnemyParty[i], &gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE], i - firstMonId); CreateApprenticeMon(&gEnemyParty[i], &gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE], i - firstMonId);
return; return;
} }
@ -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,11 +1771,11 @@ 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 != FRONTIER_PARTY_SIZE; i++)
{ {
CreateMonWithEVSpread(&gEnemyParty[firstMonId + i], apprentice->party[i].species, level, fixedIV, 8); CreateMonWithEVSpread(&gEnemyParty[firstMonId + i], apprentice->party[i].species, level, fixedIV, 8);
friendship = MAX_FRIENDSHIP; friendship = MAX_FRIENDSHIP;
@ -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,18 +1837,18 @@ 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
} }
else if (trainerId == TRAINER_EREADER) else if (trainerId == TRAINER_EREADER)
{ {
for (i = firstMonId; i < firstMonId + 3; i++) for (i = firstMonId; i < firstMonId + FRONTIER_PARTY_SIZE; i++)
CreateBattleTowerMon(&gEnemyParty[i], &gSaveBlock2Ptr->frontier.ereaderTrainer.party[i - firstMonId]); CreateBattleTowerMon(&gEnemyParty[i], &gSaveBlock2Ptr->frontier.ereaderTrainer.party[i - firstMonId]);
return; return;
} }
@ -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
{ {
@ -2737,8 +2743,8 @@ u16 GetCurrentBattleTowerWinStreak(u8 lvlMode, u8 battleMode)
{ {
u16 winStreak = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode]; u16 winStreak = gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode];
if (winStreak > 9999) if (winStreak > MAX_STREAK)
return 9999; return MAX_STREAK;
else else
return winStreak; return winStreak;
} }
@ -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

@ -1492,7 +1492,7 @@ void ShowEasyChatScreen(void)
displayedPersonType = EASY_CHAT_PERSON_REPORTER_MALE; displayedPersonType = EASY_CHAT_PERSON_REPORTER_MALE;
break; break;
case EASY_CHAT_TYPE_BATTLE_TOWER_INTERVIEW: case EASY_CHAT_TYPE_BATTLE_TOWER_INTERVIEW:
words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.words18; words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainerTower.words;
displayedPersonType = EASY_CHAT_PERSON_REPORTER_FEMALE; displayedPersonType = EASY_CHAT_PERSON_REPORTER_FEMALE;
break; break;
case EASY_CHAT_TYPE_GOOD_SAYING: case EASY_CHAT_TYPE_GOOD_SAYING:

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"
@ -499,94 +500,94 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZ
static const u8 sBattlePointAwards[][NUM_FRONTIER_FACILITIES][FRONTIER_MODE_COUNT] = static const u8 sBattlePointAwards[][NUM_FRONTIER_FACILITIES][FRONTIER_MODE_COUNT] =
{ {
{ {
{1, 2, 3, 3}, {1, 1, 0, 0}, {4, 5, 0, 0}, {1, 0, 0, 0}, {3, 4, 0, 0}, {1, 0, 0, 0}, {5, 0, 0, 0} {1, 2, 3, 3}, {1, 1}, {4, 5}, {1}, {3, 4}, {1}, {5}
}, },
{ {
{2, 3, 4, 4}, {1, 1, 0, 0}, {4, 5, 0, 0}, {1, 0, 0, 0}, {3, 4, 0, 0}, {1, 0, 0, 0}, {5, 0, 0, 0} {2, 3, 4, 4}, {1, 1}, {4, 5}, {1}, {3, 4}, {1}, {5}
}, },
{ {
{3, 4, 5, 5}, {2, 2, 0, 0}, {5, 6, 0, 0}, {1, 0, 0, 0}, {4, 5, 0, 0}, {2, 0, 0, 0}, {6, 0, 0, 0} {3, 4, 5, 5}, {2, 2}, {5, 6}, {1}, {4, 5}, {2}, {6}
}, },
{ {
{4, 5, 6, 6}, {2, 2, 0, 0}, {5, 6, 0, 0}, {2, 0, 0, 0}, {4, 5, 0, 0}, {2, 0, 0, 0}, {6, 0, 0, 0} {4, 5, 6, 6}, {2, 2}, {5, 6}, {2}, {4, 5}, {2}, {6}
}, },
{ {
{5, 6, 7, 7}, {3, 3, 0, 0}, {6, 7, 0, 0}, {2, 0, 0, 0}, {5, 6, 0, 0}, {2, 0, 0, 0}, {7, 0, 0, 0} {5, 6, 7, 7}, {3, 3}, {6, 7}, {2}, {5, 6}, {2}, {7}
}, },
{ {
{6, 7, 8, 8}, {3, 3, 0, 0}, {6, 7, 0, 0}, {2, 0, 0, 0}, {5, 6, 0, 0}, {4, 0, 0, 0}, {7, 0, 0, 0} {6, 7, 8, 8}, {3, 3}, {6, 7}, {2}, {5, 6}, {4}, {7}
}, },
{ {
{7, 8, 9, 9}, {4, 4, 0, 0}, {7, 8, 0, 0}, {3, 0, 0, 0}, {6, 7, 0, 0}, {4, 0, 0, 0}, {8, 0, 0, 0} {7, 8, 9, 9}, {4, 4}, {7, 8}, {3}, {6, 7}, {4}, {8}
}, },
{ {
{8, 9, 10, 10}, {4, 4, 0, 0}, {7, 8, 0, 0}, {3, 0, 0, 0},{6, 7, 0, 0}, {4, 0, 0, 0}, {8, 0, 0, 0} {8, 9, 10, 10}, {4, 4}, {7, 8}, {3},{6, 7}, {4}, {8}
}, },
{ {
{9, 10, 11, 11}, {5, 5, 0, 0}, {8, 9, 0, 0}, {4, 0, 0, 0}, {7, 8, 0, 0}, {8, 0, 0, 0}, {9, 0, 0, 0} {9, 10, 11, 11}, {5, 5}, {8, 9}, {4}, {7, 8}, {8}, {9}
}, },
{ {
{10, 11, 12, 12}, {5, 5, 0, 0}, {8, 9, 0, 0}, {4, 0, 0, 0}, {7, 8, 0, 0}, {8, 0, 0, 0}, {9, 0, 0, 0} {10, 11, 12, 12}, {5, 5}, {8, 9}, {4}, {7, 8}, {8}, {9}
}, },
{ {
{11, 12, 13, 13}, {6, 6, 0, 0}, {9, 10, 0, 0}, {5, 0, 0,0}, {8, 9, 0, 0}, {8, 0, 0, 0}, {10, 0, 0, 0} {11, 12, 13, 13}, {6, 6}, {9, 10}, {5,0}, {8, 9}, {8}, {10}
}, },
{ {
{12, 13, 14, 14}, {6, 6, 0, 0}, {9, 10, 0, 0}, {6, 0, 0,0}, {8, 9, 0, 0}, {8, 0, 0, 0}, {10, 0, 0, 0} {12, 13, 14, 14}, {6, 6}, {9, 10}, {6,0}, {8, 9}, {8}, {10}
}, },
{ {
{13, 14, 15, 15}, {7, 7, 0, 0}, {10, 11, 0, 0}, {7, 0, 0, 0}, {9, 10, 0, 0}, {10, 0, 0, 0}, {11, 0, 0, 0} {13, 14, 15, 15}, {7, 7}, {10, 11}, {7}, {9, 10}, {10}, {11}
}, },
{ {
{14, 15, 15, 15}, {7, 7, 0, 0}, {10, 11, 0, 0}, {8, 0, 0, 0}, {9, 10, 0, 0}, {10, 0, 0, 0}, {11, 0, 0, 0} {14, 15, 15, 15}, {7, 7}, {10, 11}, {8}, {9, 10}, {10}, {11}
}, },
{ {
{15, 15, 15, 15}, {8, 8, 0, 0}, {11, 12, 0, 0}, {9, 0, 0, 0}, {10, 11, 0, 0}, {10, 0, 0, 0}, {12, 0, 0, 0} {15, 15, 15, 15}, {8, 8}, {11, 12}, {9}, {10, 11}, {10}, {12}
}, },
{ {
{15, 15, 15, 15}, {8, 8, 0, 0}, {11, 12, 0, 0}, {10, 0, 0, 0}, {10, 11, 0, 0}, {10, 0, 0, 0}, {12, 0, 0, 0} {15, 15, 15, 15}, {8, 8}, {11, 12}, {10}, {10, 11}, {10}, {12}
}, },
{ {
{15, 15, 15, 15}, {9, 9, 0, 0}, {12, 13, 0, 0}, {11, 0, 0, 0}, {11, 12, 0, 0}, {12, 0, 0, 0}, {13, 0, 0, 0} {15, 15, 15, 15}, {9, 9}, {12, 13}, {11}, {11, 12}, {12}, {13}
}, },
{ {
{15, 15, 15, 15}, {9, 9, 0, 0}, {12, 13, 0, 0}, {12, 0, 0, 0}, {11, 12, 0, 0}, {12, 0, 0, 0}, {13, 0, 0, 0} {15, 15, 15, 15}, {9, 9}, {12, 13}, {12}, {11, 12}, {12}, {13}
}, },
{ {
{15, 15, 15, 15}, {10, 10, 0, 0}, {13, 14, 0, 0}, {13, 0, 0, 0}, {12, 13, 0, 0}, {12, 0, 0, 0}, {14, 0, 0, 0} {15, 15, 15, 15}, {10, 10}, {13, 14}, {13}, {12, 13}, {12}, {14}
}, },
{ {
{15, 15, 15, 15}, {10, 10, 0, 0}, {13, 14, 0, 0}, {14, 0, 0, 0}, {12, 13, 0, 0}, {12, 0, 0, 0}, {14, 0, 0, 0} {15, 15, 15, 15}, {10, 10}, {13, 14}, {14}, {12, 13}, {12}, {14}
}, },
{ {
{15, 15, 15, 15}, {11, 11, 0, 0}, {14, 15, 0, 0}, {15, 0, 0, 0}, {13, 14, 0, 0}, {12, 0, 0, 0}, {15, 0, 0, 0} {15, 15, 15, 15}, {11, 11}, {14, 15}, {15}, {13, 14}, {12}, {15}
}, },
{ {
{15, 15, 15, 15}, {11, 11, 0, 0}, {14, 15, 0, 0}, {15, 0, 0, 0}, {13, 14, 0, 0}, {14, 0, 0, 0}, {15, 0, 0, 0} {15, 15, 15, 15}, {11, 11}, {14, 15}, {15}, {13, 14}, {14}, {15}
}, },
{ {
{15, 15, 15, 15}, {12, 12, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {14, 15, 0, 0}, {14, 0, 0, 0}, {15, 0, 0, 0} {15, 15, 15, 15}, {12, 12}, {15, 15}, {15}, {14, 15}, {14}, {15}
}, },
{ {
{15, 15, 15, 15}, {12, 12, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {14, 15, 0, 0}, {14, 0, 0, 0}, {15, 0, 0, 0} {15, 15, 15, 15}, {12, 12}, {15, 15}, {15}, {14, 15}, {14}, {15}
}, },
{ {
{15, 15, 15, 15}, {13, 13, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {14, 0, 0, 0}, {15, 0, 0, 0} {15, 15, 15, 15}, {13, 13}, {15, 15}, {15}, {15, 15}, {14}, {15}
}, },
{ {
{15, 15, 15, 15}, {13, 13, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 0, 0, 0} {15, 15, 15, 15}, {13, 13}, {15, 15}, {15}, {15, 15}, {15}, {15}
}, },
{ {
{15, 15, 15, 15}, {14, 14, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 0, 0, 0} {15, 15, 15, 15}, {14, 14}, {15, 15}, {15}, {15, 15}, {15}, {15}
}, },
{ {
{15, 15, 15, 15}, {14, 14, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 0, 0, 0} {15, 15, 15, 15}, {14, 14}, {15, 15}, {15}, {15, 15}, {15}, {15}
}, },
{ {
{15, 15, 15, 15}, {15, 15, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 0, 0, 0} {15, 15, 15, 15}, {15, 15}, {15, 15}, {15}, {15, 15}, {15}, {15}
}, },
{ {
{15, 15, 15, 15}, {15, 15, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 15, 0, 0}, {15, 0, 0, 0}, {15, 0, 0, 0} {15, 15, 15, 15}, {15, 15}, {15, 15}, {15}, {15, 15}, {15}, {15}
}, },
}; };
@ -594,13 +595,13 @@ static const u8 sBattlePointAwards[][NUM_FRONTIER_FACILITIES][FRONTIER_MODE_COUN
// First bit is has battled them before and not won yet, second bit is has battled them and won (obtained a Symbol) // First bit is has battled them before and not won yet, second bit is has battled them and won (obtained a Symbol)
static const u16 sBattledBrainBitFlags[NUM_FRONTIER_FACILITIES][2] = static const u16 sBattledBrainBitFlags[NUM_FRONTIER_FACILITIES][2] =
{ {
[FRONTIER_FACILITY_TOWER] = {0x0001, 0x0002}, [FRONTIER_FACILITY_TOWER] = {1 << 0, 1 << 1},
[FRONTIER_FACILITY_DOME] = {0x0004, 0x0008}, [FRONTIER_FACILITY_DOME] = {1 << 2, 1 << 3},
[FRONTIER_FACILITY_PALACE] = {0x0010, 0x0020}, [FRONTIER_FACILITY_PALACE] = {1 << 4, 1 << 5},
[FRONTIER_FACILITY_ARENA] = {0x0040, 0x0080}, [FRONTIER_FACILITY_ARENA] = {1 << 6, 1 << 7},
[FRONTIER_FACILITY_FACTORY] = {0x0100, 0x0200}, [FRONTIER_FACILITY_FACTORY] = {1 << 8, 1 << 9},
[FRONTIER_FACILITY_PIKE] = {0x0400, 0x0800}, [FRONTIER_FACILITY_PIKE] = {1 << 10, 1 << 11},
[FRONTIER_FACILITY_PYRAMID] = {0x1000, 0x2000}, [FRONTIER_FACILITY_PYRAMID] = {1 << 12, 1 << 13},
}; };
static void (* const sFrontierUtilFuncs[])(void) = static void (* const sFrontierUtilFuncs[])(void) =
@ -635,8 +636,8 @@ static const struct WindowTemplate sFrontierResultsWindowTemplate =
.bg = 0, .bg = 0,
.tilemapLeft = 1, .tilemapLeft = 1,
.tilemapTop = 1, .tilemapTop = 1,
.width = 0x1c, .width = 28,
.height = 0x12, .height = 18,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 1 .baseBlock = 1
}; };
@ -646,7 +647,7 @@ static const struct WindowTemplate sLinkContestResultsWindowTemplate =
.bg = 0, .bg = 0,
.tilemapLeft = 2, .tilemapLeft = 2,
.tilemapTop = 2, .tilemapTop = 2,
.width = 0x1a, .width = 26,
.height = 15, .height = 15,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 1 .baseBlock = 1
@ -657,7 +658,7 @@ static const struct WindowTemplate sRankingHallRecordsWindowTemplate =
.bg = 0, .bg = 0,
.tilemapLeft = 2, .tilemapLeft = 2,
.tilemapTop = 1, .tilemapTop = 1,
.width = 0x1a, .width = 26,
.height = 17, .height = 17,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 1 .baseBlock = 1
@ -958,7 +959,7 @@ static bool8 IsWinStreakActive(u32 challenge)
static void PrintAligned(const u8 *str, s32 y) static void PrintAligned(const u8 *str, s32 y)
{ {
s32 x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 224); s32 x = GetStringCenterAlignXOffset(FONT_NORMAL, str, DISPLAY_WIDTH - 16);
y = (y * 8) + 1; y = (y * 8) + 1;
AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x, y, TEXT_SKIP_DRAW, NULL); AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x, y, TEXT_SKIP_DRAW, NULL);
} }
@ -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++)
@ -2344,7 +2345,7 @@ static void PrintHallRecords(s32 hallFacilityId, s32 lvlMode)
StringCopy(gStringVar1, sRecordsWindowChallengeTexts[hallFacilityId][0]); StringCopy(gStringVar1, sRecordsWindowChallengeTexts[hallFacilityId][0]);
StringExpandPlaceholders(gStringVar4, sRecordsWindowChallengeTexts[hallFacilityId][1]); StringExpandPlaceholders(gStringVar4, sRecordsWindowChallengeTexts[hallFacilityId][1]);
AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL); AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL);
x = GetStringRightAlignXOffset(FONT_NORMAL, sLevelModeText[lvlMode], 0xD0); x = GetStringRightAlignXOffset(FONT_NORMAL, sLevelModeText[lvlMode], DISPLAY_WIDTH - 32);
AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, sLevelModeText[lvlMode], x, 1, TEXT_SKIP_DRAW, NULL); AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, sLevelModeText[lvlMode], x, 1, TEXT_SKIP_DRAW, NULL);
if (hallFacilityId == RANKING_HALL_TOWER_LINK) if (hallFacilityId == RANKING_HALL_TOWER_LINK)
{ {

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

@ -33,6 +33,13 @@
#include "constants/songs.h" #include "constants/songs.h"
#include "constants/trainers.h" #include "constants/trainers.h"
// In this file only the values normally associated with Battle Pike and Factory are swapped.
// Note that this is *not* a bug, because they are properly swapped consistently in this file.
// There would only be an issue if anything in this file interacted with something expecting
// the usual value order, or vice versa.
#define MATCH_CALL_FACTORY FRONTIER_FACILITY_PIKE
#define MATCH_CALL_PIKE FRONTIER_FACILITY_FACTORY
// Each match call message has variables that can be populated randomly or // Each match call message has variables that can be populated randomly or
// dependent on the trainer. The below are IDs for how to populate the vars // dependent on the trainer. The below are IDs for how to populate the vars
// in a given message. // in a given message.
@ -1590,6 +1597,7 @@ static const struct MatchCallText *GetGeneralMatchCallText(int matchCallId, u8 *
rand = Random(); rand = Random();
if (!(rand & 1)) if (!(rand & 1))
{ {
// Count the number of facilities with a win streak
for (count = 0, i = 0; i < NUM_FRONTIER_FACILITIES; i++) for (count = 0, i = 0; i < NUM_FRONTIER_FACILITIES; i++)
{ {
if (GetFrontierStreakInfo(i, &topic) > 1) if (GetFrontierStreakInfo(i, &topic) > 1)
@ -1598,6 +1606,8 @@ static const struct MatchCallText *GetGeneralMatchCallText(int matchCallId, u8 *
if (count) if (count)
{ {
// At least one facility with a win streak
// Randomly choose one to have a call about
count = Random() % count; count = Random() % count;
for (i = 0; i < NUM_FRONTIER_FACILITIES; i++) for (i = 0; i < NUM_FRONTIER_FACILITIES; i++)
{ {
@ -1807,15 +1817,15 @@ static void PopulateSpeciesFromTrainerParty(int matchCallId, u8 *destStr)
StringCopy(destStr, speciesName); StringCopy(destStr, speciesName);
} }
static const u8 *const sBattleFrontierFacilityNames[] = static const u8 *const sBattleFrontierFacilityNames[NUM_FRONTIER_FACILITIES] =
{ {
gText_BattleTower2, [FRONTIER_FACILITY_TOWER] = gText_BattleTower2,
gText_BattleDome, [FRONTIER_FACILITY_DOME] = gText_BattleDome,
gText_BattlePalace, [FRONTIER_FACILITY_PALACE] = gText_BattlePalace,
gText_BattleArena, [FRONTIER_FACILITY_ARENA] = gText_BattleArena,
gText_BattlePike, [MATCH_CALL_PIKE] = gText_BattlePike,
gText_BattleFactory, [MATCH_CALL_FACTORY] = gText_BattleFactory,
gText_BattlePyramid, [FRONTIER_FACILITY_PYRAMID] = gText_BattlePyramid,
}; };
static void PopulateBattleFrontierFacilityName(int matchCallId, u8 *destStr) static void PopulateBattleFrontierFacilityName(int matchCallId, u8 *destStr)
@ -1899,7 +1909,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId)
switch (facilityId) switch (facilityId)
{ {
case FRONTIER_FACILITY_DOME: case FRONTIER_FACILITY_DOME:
for (i = 0; i < 2; i++) for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.domeRecordWinStreaks); i++)
{ {
for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++)
{ {
@ -1909,11 +1919,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId)
} }
*topicTextId = GEN_TOPIC_B_DOME - 1; *topicTextId = GEN_TOPIC_B_DOME - 1;
break; break;
#ifdef BUGFIX case MATCH_CALL_PIKE:
case FRONTIER_FACILITY_PIKE:
#else
case FRONTIER_FACILITY_FACTORY:
#endif
for (i = 0; i < FRONTIER_LVL_MODE_COUNT; i++) for (i = 0; i < FRONTIER_LVL_MODE_COUNT; i++)
{ {
if (streak < gSaveBlock2Ptr->frontier.pikeRecordStreaks[i]) if (streak < gSaveBlock2Ptr->frontier.pikeRecordStreaks[i])
@ -1922,7 +1928,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId)
*topicTextId = GEN_TOPIC_B_PIKE - 1; *topicTextId = GEN_TOPIC_B_PIKE - 1;
break; break;
case FRONTIER_FACILITY_TOWER: case FRONTIER_FACILITY_TOWER:
for (i = 0; i < 4; i++) for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.towerRecordWinStreaks); i++)
{ {
for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++)
{ {
@ -1933,7 +1939,7 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId)
*topicTextId = GEN_TOPIC_STREAK_RECORD - 1; *topicTextId = GEN_TOPIC_STREAK_RECORD - 1;
break; break;
case FRONTIER_FACILITY_PALACE: case FRONTIER_FACILITY_PALACE:
for (i = 0; i < 2; i++) for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.palaceRecordWinStreaks); i++)
{ {
for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++)
{ {
@ -1943,12 +1949,8 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId)
} }
*topicTextId = GEN_TOPIC_STREAK_RECORD - 1; *topicTextId = GEN_TOPIC_STREAK_RECORD - 1;
break; break;
#ifdef BUGFIX case MATCH_CALL_FACTORY:
case FRONTIER_FACILITY_FACTORY: for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock2Ptr->frontier.factoryRecordWinStreaks); i++)
#else
case FRONTIER_FACILITY_PIKE:
#endif
for (i = 0; i < 2; i++)
{ {
for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++) for (j = 0; j < FRONTIER_LVL_MODE_COUNT; j++)
{ {

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

111
src/tv.c
View File

@ -373,21 +373,21 @@ static const u8 *const sTV3CheersForPokeblocksTextGroup[] = {
}; };
static const u8 *const sTVBravoTrainerBattleTowerTextGroup[] = { static const u8 *const sTVBravoTrainerBattleTowerTextGroup[] = {
gTVBravoTrainerBattleTowerText00, [BRAVOTOWER_STATE_INTRO] = BravoTrainerBattleTower_Text_Intro,
gTVBravoTrainerBattleTowerText01, [BRAVOTOWER_STATE_NEW_RECORD] = BravoTrainerBattleTower_Text_NewRecord,
gTVBravoTrainerBattleTowerText02, [BRAVOTOWER_STATE_LOST] = BravoTrainerBattleTower_Text_Lost,
gTVBravoTrainerBattleTowerText03, [BRAVOTOWER_STATE_WON] = BravoTrainerBattleTower_Text_Won,
gTVBravoTrainerBattleTowerText04, [BRAVOTOWER_STATE_LOST_FINAL] = BravoTrainerBattleTower_Text_LostFinal,
gTVBravoTrainerBattleTowerText05, [BRAVOTOWER_STATE_SATISFIED] = BravoTrainerBattleTower_Text_Satisfied,
gTVBravoTrainerBattleTowerText06, [BRAVOTOWER_STATE_UNSATISFIED] = BravoTrainerBattleTower_Text_Unsatisfied,
gTVBravoTrainerBattleTowerText07, [BRAVOTOWER_STATE_UNUSED_1] = BravoTrainerBattleTower_Text_None1,
gTVBravoTrainerBattleTowerText08, [BRAVOTOWER_STATE_UNUSED_2] = BravoTrainerBattleTower_Text_None2,
gTVBravoTrainerBattleTowerText09, [BRAVOTOWER_STATE_UNUSED_3] = BravoTrainerBattleTower_Text_None3,
gTVBravoTrainerBattleTowerText10, [BRAVOTOWER_STATE_UNUSED_4] = BravoTrainerBattleTower_Text_None4,
gTVBravoTrainerBattleTowerText11, [BRAVOTOWER_STATE_RESPONSE] = BravoTrainerBattleTower_Text_Response,
gTVBravoTrainerBattleTowerText12, [BRAVOTOWER_STATE_RESPONSE_SATISFIED] = BravoTrainerBattleTower_Text_ResponseSatisfied,
gTVBravoTrainerBattleTowerText13, [BRAVOTOWER_STATE_RESPONSE_UNSATISFIED] = BravoTrainerBattleTower_Text_ResponseUnsatisfied,
gTVBravoTrainerBattleTowerText14 [BRAVOTOWER_STATE_OUTRO] = BravoTrainerBattleTower_Text_Outro
}; };
static const u8 *const sTVContestLiveUpdatesTextGroup[] = { static const u8 *const sTVContestLiveUpdatesTextGroup[] = {
@ -1490,9 +1490,9 @@ static void InterviewAfter_BravoTrainerBattleTowerProfile(void)
show->bravoTrainerTower.numFights = GetCurrentBattleTowerWinStreak(gSaveBlock2Ptr->frontier.towerLvlMode, 0); show->bravoTrainerTower.numFights = GetCurrentBattleTowerWinStreak(gSaveBlock2Ptr->frontier.towerLvlMode, 0);
show->bravoTrainerTower.wonTheChallenge = gSaveBlock2Ptr->frontier.towerBattleOutcome; show->bravoTrainerTower.wonTheChallenge = gSaveBlock2Ptr->frontier.towerBattleOutcome;
if (gSaveBlock2Ptr->frontier.towerLvlMode == FRONTIER_LVL_50) if (gSaveBlock2Ptr->frontier.towerLvlMode == FRONTIER_LVL_50)
show->bravoTrainerTower.btLevel = 50; show->bravoTrainerTower.btLevel = FRONTIER_MAX_LEVEL_50;
else else
show->bravoTrainerTower.btLevel = 100; show->bravoTrainerTower.btLevel = FRONTIER_MAX_LEVEL_OPEN;
show->bravoTrainerTower.interviewResponse = gSpecialVar_0x8004; show->bravoTrainerTower.interviewResponse = gSpecialVar_0x8004;
StorePlayerIdInNormalShow(show); StorePlayerIdInNormalShow(show);
show->bravoTrainerTower.language = gGameLanguage; show->bravoTrainerTower.language = gGameLanguage;
@ -4371,6 +4371,9 @@ static void DoTVShowBravoTrainerPokemonProfile(void)
ShowFieldMessage(sTVBravoTrainerTextGroup[state]); ShowFieldMessage(sTVBravoTrainerTextGroup[state]);
} }
// This is the TV show triggered by accepting the reporter's interview in the lobby of Battle Tower.
// The reporter had asked the player if they were satisfied or not with the challenge, and then asked
// for a one word Easy Chat description of their feelings about the challenge.
static void DoTVShowBravoTrainerBattleTower(void) static void DoTVShowBravoTrainerBattleTower(void)
{ {
TVShow *show; TVShow *show;
@ -4381,85 +4384,83 @@ static void DoTVShowBravoTrainerBattleTower(void)
state = sTVShowState; state = sTVShowState;
switch(state) switch(state)
{ {
case 0: case BRAVOTOWER_STATE_INTRO:
TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language);
StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.species]); StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.species]);
if (show->bravoTrainerTower.numFights >= 7) if (show->bravoTrainerTower.numFights >= FRONTIER_STAGES_PER_CHALLENGE)
sTVShowState = 1; sTVShowState = BRAVOTOWER_STATE_NEW_RECORD;
else else
sTVShowState = 2; sTVShowState = BRAVOTOWER_STATE_LOST;
break; break;
case 1: case BRAVOTOWER_STATE_NEW_RECORD:
if (show->bravoTrainerTower.btLevel == 50) // The TV show states a "new record" was achieved as long as all the battles in the challenge were attempted,
{ // regardless of any previous records or whether the final battle was won or lost.
if (show->bravoTrainerTower.btLevel == FRONTIER_MAX_LEVEL_50)
StringCopy(gStringVar1, gText_Lv50); StringCopy(gStringVar1, gText_Lv50);
}
else else
{
StringCopy(gStringVar1, gText_OpenLevel); StringCopy(gStringVar1, gText_OpenLevel);
}
ConvertIntToDecimalString(1, show->bravoTrainerTower.numFights); ConvertIntToDecimalString(1, show->bravoTrainerTower.numFights);
if (show->bravoTrainerTower.wonTheChallenge == TRUE) if (show->bravoTrainerTower.wonTheChallenge == TRUE)
sTVShowState = 3; sTVShowState = BRAVOTOWER_STATE_WON;
else else
sTVShowState = 4; sTVShowState = BRAVOTOWER_STATE_LOST_FINAL;
break; break;
case 2: case BRAVOTOWER_STATE_LOST:
TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage);
ConvertIntToDecimalString(1, show->bravoTrainerTower.numFights + 1); ConvertIntToDecimalString(1, show->bravoTrainerTower.numFights + 1);
if (show->bravoTrainerTower.interviewResponse == 0) if (show->bravoTrainerTower.interviewResponse == 0)
sTVShowState = 5; sTVShowState = BRAVOTOWER_STATE_SATISFIED;
else else
sTVShowState = 6; sTVShowState = BRAVOTOWER_STATE_UNSATISFIED;
break; break;
case 3: case BRAVOTOWER_STATE_WON:
TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage);
StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.defeatedSpecies]); StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.defeatedSpecies]);
if (show->bravoTrainerTower.interviewResponse == 0) if (show->bravoTrainerTower.interviewResponse == 0)
sTVShowState = 5; sTVShowState = BRAVOTOWER_STATE_SATISFIED;
else else
sTVShowState = 6; sTVShowState = BRAVOTOWER_STATE_UNSATISFIED;
break; break;
case 4: case BRAVOTOWER_STATE_LOST_FINAL:
TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage);
StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.defeatedSpecies]); StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.defeatedSpecies]);
if (show->bravoTrainerTower.interviewResponse == 0) if (show->bravoTrainerTower.interviewResponse == 0)
sTVShowState = 5; sTVShowState = BRAVOTOWER_STATE_SATISFIED;
else else
sTVShowState = 6; sTVShowState = BRAVOTOWER_STATE_UNSATISFIED;
break; break;
case 5: case BRAVOTOWER_STATE_SATISFIED:
TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage);
sTVShowState = 11; sTVShowState = BRAVOTOWER_STATE_RESPONSE;
break; break;
case 6: case BRAVOTOWER_STATE_UNSATISFIED:
TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage);
sTVShowState = 11; sTVShowState = BRAVOTOWER_STATE_RESPONSE;
break; break;
case 7: case BRAVOTOWER_STATE_UNUSED_1:
sTVShowState = 11; sTVShowState = BRAVOTOWER_STATE_RESPONSE;
break; break;
case 8: case BRAVOTOWER_STATE_UNUSED_2:
case 9: case BRAVOTOWER_STATE_UNUSED_3:
case 10: case BRAVOTOWER_STATE_UNUSED_4:
TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language);
sTVShowState = 11; sTVShowState = BRAVOTOWER_STATE_RESPONSE;
break; break;
case 11: case BRAVOTOWER_STATE_RESPONSE:
CopyEasyChatWord(gStringVar1, show->bravoTrainerTower.words[0]); CopyEasyChatWord(gStringVar1, show->bravoTrainerTower.words[0]);
if (show->bravoTrainerTower.interviewResponse == 0) if (show->bravoTrainerTower.interviewResponse == 0)
sTVShowState = 12; sTVShowState = BRAVOTOWER_STATE_RESPONSE_SATISFIED;
else else
sTVShowState = 13; sTVShowState = BRAVOTOWER_STATE_RESPONSE_UNSATISFIED;
break; break;
case 12: case BRAVOTOWER_STATE_RESPONSE_SATISFIED:
case 13: case BRAVOTOWER_STATE_RESPONSE_UNSATISFIED:
CopyEasyChatWord(gStringVar1, show->bravoTrainerTower.words[0]); CopyEasyChatWord(gStringVar1, show->bravoTrainerTower.words[0]);
TVShowConvertInternationalString(gStringVar2, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); TVShowConvertInternationalString(gStringVar2, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language);
TVShowConvertInternationalString(gStringVar3, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); TVShowConvertInternationalString(gStringVar3, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage);
sTVShowState = 14; sTVShowState = BRAVOTOWER_STATE_OUTRO;
break; break;
case 14: case BRAVOTOWER_STATE_OUTRO:
TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language);
StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.species]); StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.species]);
TVShowDone(); TVShowDone();

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++;
} }