diff --git a/include/code_80A26CC.h b/include/code_80A26CC.h index 48293736b..67602310c 100644 --- a/include/code_80A26CC.h +++ b/include/code_80A26CC.h @@ -1,12 +1,14 @@ #ifndef GUARD_CODE_80A26CC_H #define GUARD_CODE_80A26CC_H +#include "constants/script_dungeon_id.h" + // size: 0x14 typedef struct DungeonInfo { /* 0x0 */ s16 unk0; - /* 0x2 */ s16 unk2; - /* 0x4 */ s16 unk4; + /* 0x2 */ s16 unk2; // See enum "GroundMapID" + /* 0x4 */ s16 unk4; // See enum "GroundMapID" /* 0x6 */ s16 unk6; /* 0x8 */ s16 unk8; /* 0xA */ s16 unkA; @@ -17,7 +19,7 @@ typedef struct DungeonInfo /* 0x11 */ u8 unk11; } DungeonInfo; -const DungeonInfo *GetDungeonInfo_80A2608(s32 index); +const DungeonInfo *GetDungeonInfo_80A2608(s32 scriptDungeon_); s16 sub_80A2654(s16 index); s16 sub_80A2668(s16); s16 sub_80A2688(u8); diff --git a/include/constants/dungeon.h b/include/constants/dungeon.h index 2451d872e..1692607a9 100644 --- a/include/constants/dungeon.h +++ b/include/constants/dungeon.h @@ -105,6 +105,14 @@ enum DungeonID DUNGEON_INVALID, // 99 }; +enum PrefightKind +{ + PREFIGHT_NONE, + PREFIGHT_SKARMORY_ATTEMPT1, + PREFIGHT_SKARMORY_ATTEMPT2, + PREFIGHT_SKARMORY_GONE, +}; + #define DUNGEON_FIRST_MAZE DUNGEON_NORMAL_MAZE_2 #define DUNGEON_LAST_MAZE DUNGEON_RESCUE_TEAM_MAZE #define DUNGEON_LAST_BASIC_MAZE DUNGEON_STEEL_MAZE diff --git a/include/constants/event_flag.h b/include/constants/event_flag.h index 93cd1c0aa..c8f30f013 100644 --- a/include/constants/event_flag.h +++ b/include/constants/event_flag.h @@ -1,7 +1,68 @@ #ifndef GUARD_CONSTANTS_EVENT_FLAG_H #define GUARD_CONSTANTS_EVENT_FLAG_H -enum FlagCalcOperation { +enum MainQuest +{ + // SCENARIO_MAIN: + + QUEST_SET_TEAM_NAME, + QUEST_UNK1, // Rescue dungeon related. For some reason it scans all rescue dungeons. + QUEST_CAN_ACCESS_JOBS, + QUEST_CAN_RECRUIT, + QUEST_SQUARE_ASLEEP, + QUEST_UNK5, // Run away related? It disallows "friend rescue" features. + QUEST_REACHED_POSTGAME, + QUEST_UNLOCKED_EVOLUTIONS, + QUEST_CAN_CHANGE_LEADER, + QUEST_CAN_DEPOSIT_PARTNER, + QUEST_UNK10, // Dojo-related + QUEST_UNK11, + QUEST_UNK12, // Music-related + QUEST_IN_WORLD_CALAMITY, + QUEST_MAZE_14, + QUEST_MAZE_15, + QUEST_LEGEND_ZAPDOS, + QUEST_LEGEND_MOLTRES, + QUEST_LEGEND_ARTICUNO, + QUEST_LEGEND_GROUDON, + QUEST_LEGEND_RAYQUAZA, + + // SCENARIO_SUB2: + + QUEST_LEGEND_KYOGRE, + QUEST_LEGEND_LUGIA, + + // SCENARIO_SUB3: + + QUEST_LEGEND_DEOXYS, + + // SCENARIO_SUB4: + + QUEST_LEGEND_HO_OH, + + // SCENARIO_SUB5: + + QUEST_LEGEND_MEWTWO, + + // SCENARIO_SUB7: + + QUEST_LEGEND_MEW, + + // RESCUE_SCENARIO_CONQUEST_LIST: + + QUEST_LEGEND_CELEBI, + + // Special check: + + QUEST_LUCARIO_RANK, + + // TRAINING_CONQUEST_LIST: + + QUEST_COMPLETED_ALL_MAZES, +}; + +enum FlagCalcOperation +{ CALC_SET, CALC_SUB, CALC_ADD, @@ -16,7 +77,8 @@ enum FlagCalcOperation { CALC_RANDOM, }; -enum FlagJudgeOperation { +enum FlagJudgeOperation +{ JUDGE_TRUE, JUDGE_FALSE, JUDGE_EQ, @@ -30,7 +92,8 @@ enum FlagJudgeOperation { JUDGE_BIT_SET, }; -enum ScriptVarId { +enum ScriptVarId +{ /* 0x00 */ VERSION, /* 0x01 */ CONDITION, /* 0x02 */ SCENARIO_SELECT, diff --git a/include/constants/fixed_rooms.h b/include/constants/fixed_rooms.h index 42dfbeef2..825dbed91 100644 --- a/include/constants/fixed_rooms.h +++ b/include/constants/fixed_rooms.h @@ -4,7 +4,8 @@ enum FixedRoomID { // floorwide fixed rooms - FIXED_ROOM_MT_STEEL_SKARMORY = 1, + FIXED_ROOM_NONE, + FIXED_ROOM_MT_STEEL_SKARMORY, FIXED_ROOM_SINISTER_WOODS_TEAM_MEANIES, FIXED_ROOM_MT_THUNDER_PEAK_ZAPDOS, FIXED_ROOM_MT_BLAZE_PEAK_MOLTRES, @@ -30,6 +31,7 @@ enum FixedRoomID FIXED_ROOM_HOWLING_FOREST_SMEARGLE, FIXED_ROOM_PURITY_FOREST_CELEBI, FIXED_ROOM_WISH_CAVE_MEDICHAM, + // Mazes FIXED_ROOM_NORMAL_MAZE_BOSS, FIXED_ROOM_FIRE_MAZE_BOSS, FIXED_ROOM_WATER_MAZE_BOSS, @@ -53,7 +55,7 @@ enum FixedRoomID FIXED_ROOM_TEAM_RUMBLEROCK_BOSS, FIXED_ROOM_RESCUE_TEAM_2_BOSS, FIXED_ROOM_RESCUE_TEAM_MAZE_BOSS, - // non-floorwide fixed rooms + // Non-floorwide fixed rooms FIXED_ROOM_WYVERN_HILL_HM_FLY, FIXED_ROOM_SOLAR_CAVE_HM_DIVE, FIXED_ROOM_SOLAR_CAVE_HM_WATERFALL, diff --git a/include/constants/ground_map.h b/include/constants/ground_map.h index 387ff99bb..fc1b2db25 100644 --- a/include/constants/ground_map.h +++ b/include/constants/ground_map.h @@ -1,7 +1,8 @@ #ifndef GUARD_CONSTANTS_GROUND_MAP_H #define GUARD_CONSTANTS_GROUND_MAP_H -enum { +enum GroundMapID +{ MAP_SQUARE, MAP_POKEMON_SQUARE, MAP_WHISCASH_POND, diff --git a/include/dungeon_cutscene.h b/include/dungeon_cutscene.h index 6fc6af005..88601c927 100644 --- a/include/dungeon_cutscene.h +++ b/include/dungeon_cutscene.h @@ -75,6 +75,6 @@ void sub_8086A3C(Entity *pokemon); void sub_8086A54(Entity *pokemon); void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex); void sub_8086AC0(void); -u8 sub_8086AE4(s16 _index); +bool8 sub_8086AE4(s16 _index); -#endif +#endif // GUARD_DUNGEON_CUTSCENE_H diff --git a/include/dungeon_exit.h b/include/dungeon_exit.h index 62a472113..1cd17bc7a 100644 --- a/include/dungeon_exit.h +++ b/include/dungeon_exit.h @@ -6,6 +6,6 @@ void SetUpDungeonExitData(s16 dungeonExitReason, Entity *target, Entity *entity); bool8 IsUnsuccessfulDungeonExit(void); bool8 sub_8083C50(void); -bool8 sub_8083C88(u8 param_1); +bool8 sub_8083C88(u8 dungeonMissionKind); #endif // GUARD_DUNGEON_EXIT_H diff --git a/include/event_flag.h b/include/event_flag.h index 249a24cca..624835a95 100644 --- a/include/event_flag.h +++ b/include/event_flag.h @@ -34,7 +34,8 @@ void UpdateScriptVarWithVar(u8 *localVarBuf, s16 dstVarId, s16 srcVarId, enum Fl bool8 FlagJudge(s32 r0, s32 r1, enum FlagJudgeOperation operation); bool8 JudgeVarWithImmediate(u8 *localVarBuf, s16 varId, s32 val, enum FlagJudgeOperation operation); bool8 JudgeVarWithVar(u8 *localVarBuf, s16 varId1, s16 varId2, enum FlagJudgeOperation operation); -bool8 sub_80023E4(u32 param_1); // some kind of helper for predefined scenario checks +// See enum "MainQuest" +bool8 CheckQuest(s32 questID); u8 MapIdToFriendAreaId(s16 mapId_); // map -> friend area lookup s16 FriendAreaIdToMapId(u8 friendAreaId); // friend area -> map lookup bool8 sub_80026CC(s16 r0); diff --git a/include/pokemon_summary_window.h b/include/pokemon_summary_window.h index 89f45cd5b..b6d9a6035 100644 --- a/include/pokemon_summary_window.h +++ b/include/pokemon_summary_window.h @@ -14,6 +14,8 @@ enum SUB_WINDOW_INFO, }; +#define MON_SUMMARY_UNK58_COUNT 12 + struct MonSummaryInfo { // size: 0x64 @@ -45,7 +47,7 @@ struct MonSummaryInfo u8 tactic; u8 fill55[1]; s16 unk56; - u8 unk58[12]; + u8 unk58[MON_SUMMARY_UNK58_COUNT]; }; struct UnkInfoTabStruct @@ -55,6 +57,6 @@ struct UnkInfoTabStruct }; void ShowPokemonSummaryWindow(s32 which, s32 currSubWindowId, struct MonSummaryInfo *monInfo, struct UnkInfoTabStruct *param_4, u32 windowId); -void SetMonSummaryInfo(struct MonSummaryInfo *dst, struct Pokemon *pokemon, bool8 param_3); +void SetMonSummaryInfo(struct MonSummaryInfo *dst, struct Pokemon *pokemon, bool8 unlockedEvolutions); #endif // GUARD_POKEMON_SUMMARY_WINDOW_H diff --git a/include/post_office_guide2.h b/include/post_office_guide2.h index 41f947314..f028b922a 100644 --- a/include/post_office_guide2.h +++ b/include/post_office_guide2.h @@ -8,14 +8,14 @@ typedef struct unkStruct_203B330 { /* 0x0 */ TouchScreenMenuInput input; - u8 unkC; + u8 dungeonMissionKind; // See enum "DungeonMissionKind" /* 0xD */ u8 dungeonIndex; u32 unk10; WindowTemplate *unk14; WindowTemplates unk18; } unkStruct_203B330; -bool8 sub_80319A4(u8, u8 dungeon, s32); +bool8 sub_80319A4(u8 dungeonMissionKind, u8 dungeon, s32); u32 sub_80319F8(void); void sub_8031A3C(void); diff --git a/include/rescue_scenario.h b/include/rescue_scenario.h index df71f2175..5609f68b8 100644 --- a/include/rescue_scenario.h +++ b/include/rescue_scenario.h @@ -1,6 +1,7 @@ #ifndef GUARD_RESCUE_SCENARIO_H #define GUARD_RESCUE_SCENARIO_H +#include "constants/rescue_dungeon_id.h" #include "structs/str_wonder_mail.h" void sub_80972F4(void); @@ -9,7 +10,7 @@ bool8 sub_8097318(s16 param_1); void sub_809733C(s16 param_1, u32 param_2); bool8 sub_8097384(s32 param_1); void sub_80973A8(s32 param_1, u32 param_2); -bool8 RescueScenarioConquered(s32 param_1); +bool8 RescueScenarioConquered(s32 rescueDungeonID_); void sub_8097418(s32 index, bool32); const u8 *GetRescueDungeonName(s16 rescueDungeonId); const u8 *GetCurrentMissionText(s16 index); diff --git a/include/run_dungeon.h b/include/run_dungeon.h index c6f8e90ac..f648742a9 100644 --- a/include/run_dungeon.h +++ b/include/run_dungeon.h @@ -17,7 +17,7 @@ struct UnkStruct_203B414 extern struct UnkStruct_203B414 *gUnknown_203B414; extern Dungeon *gDungeon; -void RunDungeon_Async(DungeonSetupStruct *r8); +void RunDungeon_Async(DungeonSetupStruct *setupPtr); bool8 sub_8043CE4(s32 dungeonId); u8 GetFloorType(void); void sub_8043D50(s32 *a0, s32 *a1); diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index d81270463..a4656e984 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -238,6 +238,14 @@ struct MinMaxPosition s32 maxY; }; +enum DungeonMissionKind +{ + DUNGEON_MISSION_UNK0, + DUNGEON_MISSION_OUTONRESCUE, + DUNGEON_MISSION_ACCEPTEDJOB_RELATED, + DUNGEON_MISSION_UNK3, +}; + // size: 0x58 typedef struct unkDungeon644 { @@ -247,10 +255,10 @@ typedef struct unkDungeon644 /* 0x10 */ u8 unk10; /* 0x11 */ u8 fill11[3]; /* 0x14 */ bool8 canRecruit; - /* 0x15 */ u8 unk15; - /* 0x16 */ u8 unk16; + /* 0x15 */ bool8 canRecruitRescueTeamMazeBosses; + /* 0x16 */ bool8 unlockedEvolutions; /* 0x17 */ bool8 hasInventory; - /* 0x18 */ u8 unk18; + /* 0x18 */ bool8 canChangeLeader; /* 0x19 */ u8 unk19; /* 0x1A */ u8 fill1A[2]; /* 0x1C */ s16 fractionalTurn; // Handles turn order when Pokémon have different movement speeds. @@ -271,7 +279,7 @@ typedef struct unkDungeon644 /* 0x31 */ u8 unk31; /* 0x32 */ bool8 itemHoldersIdentified; /* 0x33 */ u8 unk33; - /* 0x34 */ u8 unk34; + /* 0x34 */ u8 missionKind; // See enum "DungeonMissionKind" /* 0x35 */ u8 emptyBellyAlert; // which alert message to show when belly gets empty. /* 0x36 */ u8 windPhase; /* 0x37 */ s8 unk37; @@ -422,7 +430,7 @@ typedef struct Dungeon /* 0x3A0A */ bool8 unk3A0A; /* 0x3A0B */ bool8 unk3A0B; /* 0x3A0C */ u8 monsterHouseRoom; // room index of monster house - /* 0x3A0D */ u8 unk3A0D; + /* 0x3A0D */ u8 prefight; // See enum "PrefightKind" /* 0x3A0E */ s16 tileset; /* 0x3A10 */ s16 unk3A10; /* 0x3A12 */ s16 unk3A12; diff --git a/include/structs/str_dungeon_setup.h b/include/structs/str_dungeon_setup.h index 78bd6559e..ef11e61ff 100644 --- a/include/structs/str_dungeon_setup.h +++ b/include/structs/str_dungeon_setup.h @@ -12,13 +12,13 @@ typedef struct DungeonSetupSubstruct { DungeonLocation unk0; u8 unk4; - u8 unk5; - u8 unk6; - u8 unk7; - u8 unk8; - u8 unk9; + /* 0x5 */ bool8 canChangeLeader; + /* 0x6 */ bool8 canRecruit; + /* 0x7 */ bool8 canRecruitRescueTeamMazeBosses; + /* 0x8 */ bool8 unlockedEvolutions; + /* 0x9 */ bool8 hasInventory; u8 unkA; - u8 unkB; + /* 0xB */ u8 missionKind; // See enum "DungeonMissionKind" u8 unkC; u8 unkD; } DungeonSetupSubstruct; @@ -30,7 +30,7 @@ typedef struct DungeonSetupInfo Pokemon mon; u8 *unk74; Dungeon *dungeon; - s16 unk7C; // Set to 5 if the dungeon was skipped (quicksave read failed) + s16 unk7C; // 4 = OutOnRescue related ... 5 = dungeon was skipped (quicksave read failed) u8 unk7E; DungeonLocation unk80; DungeonMailSeed unk84; diff --git a/include/world_map.h b/include/world_map.h index 3c42be4ff..07079c768 100644 --- a/include/world_map.h +++ b/include/world_map.h @@ -40,10 +40,10 @@ struct WorldMap struct WorldMapInfo { - DungeonLocation startLocation; + /* 0x0 */ DungeonLocation startLocation; DungeonSetupSubstruct unk4; - Pokemon mon; - u8 unk6C; + /* 0x14 */ Pokemon mon; + /* 0x6C */ bool8 canChangeLeader; u8 unk6D[WORLD_MAP_UNK_6D_COUNT]; }; diff --git a/src/code_801D014.c b/src/code_801D014.c index 7b36fb649..c37229d9a 100644 --- a/src/code_801D014.c +++ b/src/code_801D014.c @@ -304,7 +304,7 @@ static void sub_801D4C0(void) sUnknown_203B250->unk68[loopMax].menuAction = 4; loopMax++; - if (sub_80023E4(2)) { + if (CheckQuest(QUEST_CAN_ACCESS_JOBS)) { sUnknown_203B250->unk68[loopMax].text = sJobList; sUnknown_203B250->unk68[loopMax].menuAction = 9; if (HasNoAcceptedJobs()) diff --git a/src/code_8024458.c b/src/code_8024458.c index f265ff922..49189284f 100644 --- a/src/code_8024458.c +++ b/src/code_8024458.c @@ -98,5 +98,5 @@ static void sub_8024604(void) CreateMenuOnWindow(&sUnknown_203B2AC->input, 3, 1, sUnknown_203B2AC->unkE0); iVar3 = &sUnknown_203B2AC->unk4C; pokeStruct = &gRecruitedPokemonRef->pokemon[sUnknown_203B2AC->speciesNum]; - SetMonSummaryInfo(iVar3, pokeStruct, sub_80023E4(7)); + SetMonSummaryInfo(iVar3, pokeStruct, CheckQuest(QUEST_UNLOCKED_EVOLUTIONS)); } diff --git a/src/code_803C1B4.c b/src/code_803C1B4.c index 0fe615b57..2d3103d83 100644 --- a/src/code_803C1B4.c +++ b/src/code_803C1B4.c @@ -244,7 +244,7 @@ bool8 sub_803C580(WonderMail *param_1) counter = 0; ptr = gUnknown_80E8180; - if (!sub_80023E4(6)) + if (!CheckQuest(QUEST_REACHED_POSTGAME)) return FALSE; for (id = 0; id < ARRAY_COUNT_INT(gUnknown_80E8180); ptr++, id++) { diff --git a/src/code_80958E8.c b/src/code_80958E8.c index 4185a68b2..b291c62c9 100644 --- a/src/code_80958E8.c +++ b/src/code_80958E8.c @@ -574,7 +574,7 @@ bool8 sub_80961D8(void) if(!gUnknown_203B490->PKMNNewsReceived[0x35]) if(!sub_8096E80(0x35)) floor = 0x35; } - if(sub_80023E4(0xF)) + if(CheckQuest(QUEST_MAZE_15)) { if(!gUnknown_203B490->PKMNNewsReceived[0x34]) if(!sub_8096E80(0x34)) floor = 0x34; @@ -589,7 +589,7 @@ bool8 sub_80961D8(void) if(!gUnknown_203B490->PKMNNewsReceived[0x36]) if(!sub_8096E80(0x36)) floor = 0x36; } - if(sub_80023E4(6)) + if(CheckQuest(QUEST_REACHED_POSTGAME)) { if(!gUnknown_203B490->PKMNNewsReceived[0x37]) if(!sub_8096E80(0x37)) floor = 0x37; @@ -598,7 +598,7 @@ bool8 sub_80961D8(void) if(floor != 0x38) goto _slot; if(num > index) goto _08096392; floor = sub_8096E2C(); - if(!sub_80023E4(0xE) && (floor > 2)) goto _0809638E; + if(!CheckQuest(QUEST_MAZE_14) && (floor > 2)) goto _0809638E; if (floor > 0x31) goto _0809638E; _slot: slot = GetMailboxSlotInfo(num); @@ -653,7 +653,7 @@ bool8 sub_80963B4(void) floor = sub_8096E2C(); num = CountFilledMailboxSlots(); if(num >= NUM_MAILBOX_SLOTS) return FALSE; - if(sub_80023E4(0xE)) + if(CheckQuest(QUEST_MAZE_14)) { if(floor < 0x32) { diff --git a/src/code_80A26CC.c b/src/code_80A26CC.c index 828261598..aa7dd56df 100644 --- a/src/code_80A26CC.c +++ b/src/code_80A26CC.c @@ -4,7 +4,6 @@ #include "code_80A26CC.h" #include "event_flag.h" #include "constants/dungeon.h" -#include "constants/script_dungeon_id.h" #include "constants/rescue_dungeon_id.h" static const DungeonInfo gUnknown_81168A8[SCRIPT_DUNGEON_COUNT] = { @@ -1147,10 +1146,10 @@ static const s16 sRescueToScriptDungeonIdTable[RESCUE_DUNGEON_COUNT] = { [RESCUE_DUNGEON_FANTASY_STRAIT] = SCRIPT_DUNGEON_FANTASY_STRAIT, }; -const DungeonInfo *GetDungeonInfo_80A2608(s32 _index) +const DungeonInfo *GetDungeonInfo_80A2608(s32 scriptDungeon_) { - s32 index = (s16) _index; - return &gUnknown_81168A8[index]; + s32 scriptDungeon = (s16)scriptDungeon_; + return &gUnknown_81168A8[scriptDungeon]; } static const DungeonInfo *GetRescueDungeonInfo(s16 rescueDungeonId) @@ -1267,11 +1266,11 @@ s16 sub_80A2750(s16 r0) temp = GetDungeonInfo_80A2608(temp_2); if (temp->unkE == -1) return 1; - if (sub_80023E4(5)) + if (CheckQuest(QUEST_UNK5)) return 1; - if (!RescueScenarioConquered((s16) temp->unkE)) + if (!RescueScenarioConquered((s16)temp->unkE)) return 1; - if (!sub_80023E4(1)) + if (!CheckQuest(QUEST_UNK1)) return 1; return 2; } @@ -1284,11 +1283,11 @@ bool8 IsRescueDungeonAvailable(s16 _rescueDungeonId) if (GetRescueDungeonInfo(_rescueDungeonId)->unk0 == -1) return FALSE; - if (sub_80023E4(5)) + if (CheckQuest(QUEST_UNK5)) return FALSE; if (sub_8097384(_rescueDungeonId)) return TRUE; - if (!sub_80023E4(1)) + if (!CheckQuest(QUEST_UNK1)) return FALSE; if (!RescueScenarioConquered((s16) rescueDungeonId)) return FALSE; @@ -1300,10 +1299,10 @@ bool8 sub_80A2824(u8 index) s32 i; const DungeonInfo *temp; - if (sub_80023E4(5)) + if (CheckQuest(QUEST_UNK5)) return FALSE; - if (sub_80023E4(1)) { + if (CheckQuest(QUEST_UNK1)) { for (i = 0; i < RESCUE_DUNGEON_COUNT; i++) { temp = GetRescueDungeonInfo(i); @@ -1405,7 +1404,7 @@ UNUSED static s32 sub_80A293C(u8 *param_1) s32 sub_80A29B0(u8 *param_1) { - u8 *pcVar2; + bool8 *pcVar2; const DungeonInfo *iVar3; s32 index; s32 counter; @@ -1413,29 +1412,29 @@ s32 sub_80A29B0(u8 *param_1) u8 *local2; u8 *local3; u8 *local4; - u8 local_68[0x40]; - u8 zero; + bool8 local_68[0x40]; + bool8 zero; counter = 0; local1 = &local_68[43]; local2 = &local_68[44]; local3 = &local_68[45]; local4 = &local_68[46]; - zero = 0; + zero = FALSE; pcVar2 = &local_68[62]; do { *pcVar2 = zero; - pcVar2 = pcVar2 + -1; + pcVar2--; } while ((int)pcVar2 >= (int)local_68); - if (sub_80023E4(1)) { + if (CheckQuest(QUEST_UNK1)) { for (index = 0; index < RESCUE_DUNGEON_COUNT; index++) { iVar3 = GetRescueDungeonInfo(index); if (iVar3->unk11 != 0 && RescueScenarioConquered((s16) index)) - local_68[iVar3->dungeonIndex] = 1; + local_68[iVar3->dungeonIndex] = TRUE; } } @@ -1445,7 +1444,7 @@ s32 sub_80A29B0(u8 *param_1) *local4 = 0; for (index = 0; index < 63; index++) { - if (local_68[index] != 0) { + if (local_68[index]) { param_1[counter] = index; counter++; } @@ -1472,7 +1471,7 @@ UNUSED static s32 sub_80A2A5C(u8 *param_1) pcVar2--; } while ((s32)pcVar2 >= (s32)local_58); - if (sub_80023E4(1)) { + if (CheckQuest(QUEST_UNK1)) { for (index = 0; index < RESCUE_DUNGEON_COUNT; index++) { iVar3 = GetRescueDungeonInfo(index); diff --git a/src/data/ground/ground_data_b01p01a_station.h b/src/data/ground/ground_data_b01p01a_station.h index 0671570fb..b0632d1d3 100644 --- a/src/data/ground/ground_data_b01p01a_station.h +++ b/src/data/ground/ground_data_b01p01a_station.h @@ -1,145 +1,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static const struct ScriptCommand s_gs9_g0_s0_station_sref_script[] = { /* 0x819ad18 */ DEBUGINFO_O(144), SELECT_MAP(MAP_TEAM_BASE), @@ -381,7 +240,7 @@ static const struct ScriptCommand s_gs9_g0_s0_station_sref_script[] = { /* 0x819 BGM_SWITCH(1), JUMP_SCRIPT(COMMON_ENTER), LABEL(53), /* = 0x35 */ - JUMPIF_SCENARIOCHECK(8, /* to label */ 57), + JUMPIF_SCENARIOCHECK(QUEST_CAN_CHANGE_LEADER, /* to label */ 57), CJUMP_VAR(DUNGEON_ENTER), COND_EQUAL(1, /* to label */ 58), COND_EQUAL(2, /* to label */ 59), @@ -441,7 +300,7 @@ static const struct ScriptRef s_gs9_g0_s0_evt0_sref = { 357, 2, NULL /* GETOUT_N static const struct ScriptCommand s_gs9_g0_s0_evt1_sref_script[] = { /* 0x819bf50 */ DEBUGINFO_O(442), JUMPIF_SCENE_LT(SCENARIO_MAIN, 4, 3, /* to label */ 0), - JUMPIF_SCENARIOCHECK(4, /* to label */ 1), + JUMPIF_SCENARIOCHECK(QUEST_SQUARE_ASLEEP, /* to label */ 1), LABEL(2), /* = 0x02 */ { 0x3b, 0x12, 0x0000, 0x00000000, 0x00000000, NULL }, COND_EQUAL(1, /* to label */ 3), @@ -554,7 +413,7 @@ static const struct ScriptCommand s_gs9_g0_s0_obj2_dlg2[] = { /* 0x819c748 */ WAIT(1), MSG_INSTANT(_("\n ← Friend Areas")), TEXTBOX_CLEAR, - JUMPIF_SCENARIOCHECK(4, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_SQUARE_ASLEEP, /* to label */ 0), LABEL(1), /* = 0x01 */ SPECIAL_TEXT(SPECIAL_TEXT_FRIEND_AREA_SELECT, 0, 0), COND_EQUAL(-2, /* to label */ 2), @@ -577,7 +436,7 @@ static const struct ScriptCommand s_gs9_g0_s0_obj2_dlg2[] = { /* 0x819c748 */ static const struct ScriptCommand s_gs9_g0_s0_obj3_dlg0[] = { /* 0x819c8f4 */ DEBUGINFO_O(579), - JUMPIF_SCENARIOCHECK(29, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_COMPLETED_ALL_MAZES, /* to label */ 0), JUMPIF_ARRAY(EVENT_B01P01, 2, /* to label */ 0), END_DELETE, LABEL(0), /* = 0x00 */ @@ -1179,7 +1038,7 @@ static const struct ScriptCommand s_gs9_g5_s0_station_sref_script[] = { /* 0x819 SET_DUNGEON_RES(/* result */ 0, /* enter */ -1), UPDATE_VARINT(CALC_SET, GROUND_ENTER, MAP_TEAM_BASE), UPDATE_VARINT(CALC_SET, GROUND_GETOUT, MAP_TEAM_BASE_INSIDE), - JUMPIF_SCENARIOCHECK(8, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_CAN_CHANGE_LEADER, /* to label */ 0), UPDATE_VARINT(CALC_SET, PARTNER1_KIND, 2), UPDATE_VARINT(CALC_SET, PARTNER2_KIND, 0), SELECT_MAP(MAP_TEAM_BASE), @@ -1301,7 +1160,7 @@ static const struct ScriptCommand s_gs9_g7_s0_station_sref_script[] = { /* 0x819 SET_DUNGEON_RES(/* result */ 0, /* enter */ -1), UPDATE_VARINT(CALC_SET, GROUND_ENTER, MAP_TEAM_BASE), UPDATE_VARINT(CALC_SET, GROUND_GETOUT, MAP_TEAM_BASE_INSIDE), - JUMPIF_SCENARIOCHECK(8, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_CAN_CHANGE_LEADER, /* to label */ 0), UPDATE_VARINT(CALC_SET, PARTNER1_KIND, 2), UPDATE_VARINT(CALC_SET, PARTNER2_KIND, 0), SELECT_MAP(MAP_TEAM_BASE), diff --git a/src/data/ground/ground_data_d08p01_station.h b/src/data/ground/ground_data_d08p01_station.h index a1cd5c454..487012094 100644 --- a/src/data/ground/ground_data_d08p01_station.h +++ b/src/data/ground/ground_data_d08p01_station.h @@ -1,17 +1,7 @@ - - - - - - - - - - static const struct ScriptCommand s_gs193_g0_s0_station_sref_script[] = { /* 0x8242bb8 */ DEBUGINFO_O(13), - JUMPIF_SCENARIOCHECK(5, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_UNK5, /* to label */ 0), EXECUTE_STATION(12, 0, 0), LABEL(0), /* = 0x00 */ SELECT_MAP(MAP_LAPIS_CAVE_ENTRY), diff --git a/src/data/ground/ground_data_d09p01_station.h b/src/data/ground/ground_data_d09p01_station.h index 62e19e1bf..a6073fc37 100644 --- a/src/data/ground/ground_data_d09p01_station.h +++ b/src/data/ground/ground_data_d09p01_station.h @@ -1,25 +1,7 @@ - - - - - - - - - - - - - - - - - - static const struct ScriptCommand s_gs195_g0_s0_station_sref_script[] = { /* 0x8245cc8 */ DEBUGINFO_O(21), - JUMPIF_SCENARIOCHECK(5, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_UNK5, /* to label */ 0), EXECUTE_STATION(12, 0, 0), LABEL(0), /* = 0x00 */ SELECT_MAP(195), diff --git a/src/data/ground/ground_data_d09p02_station.h b/src/data/ground/ground_data_d09p02_station.h index 90f562784..e39055347 100644 --- a/src/data/ground/ground_data_d09p02_station.h +++ b/src/data/ground/ground_data_d09p02_station.h @@ -66,7 +66,7 @@ static const struct ScriptRef s_gs196_g0_s0_evt0_sref = { 357, 2, NULL /* GETOUT static const struct ScriptCommand s_gs196_g0_s0_evt1_sref_script[] = { /* 0x8248db4 */ DEBUGINFO_O(68), - JUMPIF_SCENARIOCHECK(5, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_UNK5, /* to label */ 0), ASK1(FALSE, /*default*/ 0, /* speaker */ -1, _("Return to the rescue team base?")), CHOICE(/* label */ 1, _("Yes.")), CHOICE(/* label */ 2, _("*No.")), diff --git a/src/data/ground/ground_data_d10p01_station.h b/src/data/ground/ground_data_d10p01_station.h index 85d7d6299..8345f9ef4 100644 --- a/src/data/ground/ground_data_d10p01_station.h +++ b/src/data/ground/ground_data_d10p01_station.h @@ -1,15 +1,7 @@ - - - - - - - - static const struct ScriptCommand s_gs198_g0_s0_station_sref_script[] = { /* 0x824bbfc */ DEBUGINFO_O(11), - JUMPIF_SCENARIOCHECK(5, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_UNK5, /* to label */ 0), EXECUTE_STATION(12, 0, 0), LABEL(0), /* = 0x00 */ SELECT_MAP(MAP_FROSTY_FOREST_ENTRY), diff --git a/src/data/ground/ground_data_d10p02_station.h b/src/data/ground/ground_data_d10p02_station.h index 098b76900..d07fd12ec 100644 --- a/src/data/ground/ground_data_d10p02_station.h +++ b/src/data/ground/ground_data_d10p02_station.h @@ -66,7 +66,7 @@ static const struct ScriptRef s_gs199_g0_s0_evt0_sref = { 357, 2, NULL /* GETOUT static const struct ScriptCommand s_gs199_g0_s0_evt1_sref_script[] = { /* 0x824ea74 */ DEBUGINFO_O(68), - JUMPIF_SCENARIOCHECK(5, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_UNK5, /* to label */ 0), ASK1(FALSE, /*default*/ 0, /* speaker */ -1, _("Return to the rescue team base?")), CHOICE(/* label */ 1, _("Yes.")), CHOICE(/* label */ 2, _("*No.")), diff --git a/src/data/ground/ground_data_d11p01_station.h b/src/data/ground/ground_data_d11p01_station.h index 656765528..7cc92d404 100644 --- a/src/data/ground/ground_data_d11p01_station.h +++ b/src/data/ground/ground_data_d11p01_station.h @@ -1,16 +1,7 @@ - - - - - - - - - static const struct ScriptCommand s_gs201_g0_s0_station_sref_script[] = { /* 0x8251f44 */ DEBUGINFO_O(12), - JUMPIF_SCENARIOCHECK(5, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_UNK5, /* to label */ 0), EXECUTE_STATION(12, 0, 0), LABEL(0), /* = 0x00 */ SELECT_MAP(MAP_MT_FREEZE_ENTRY), diff --git a/src/data/ground/ground_data_d11p02_station.h b/src/data/ground/ground_data_d11p02_station.h index 294c20726..dbc4e6158 100644 --- a/src/data/ground/ground_data_d11p02_station.h +++ b/src/data/ground/ground_data_d11p02_station.h @@ -73,7 +73,7 @@ static const struct ScriptRef s_gs202_g0_s0_evt0_sref = { 357, 2, NULL /* GETOUT static const struct ScriptCommand s_gs202_g0_s0_evt1_sref_script[] = { /* 0x8255a70 */ DEBUGINFO_O(75), - JUMPIF_SCENARIOCHECK(5, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_UNK5, /* to label */ 0), ASK1(FALSE, /*default*/ 0, /* speaker */ -1, _("Return to the rescue team base?")), CHOICE(/* label */ 1, _("Yes.")), CHOICE(/* label */ 2, _("*No.")), diff --git a/src/data/ground/ground_data_t01p02a_station.h b/src/data/ground/ground_data_t01p02a_station.h index 7df1b9050..a56ae706b 100644 --- a/src/data/ground/ground_data_t01p02a_station.h +++ b/src/data/ground/ground_data_t01p02a_station.h @@ -158,7 +158,7 @@ static const struct ScriptCommand s_gs2_g0_s0_station_sref_script[] = { /* 0x817 JUMP_LABEL(30), LABEL(30), /* = 0x1e */ BGM_SWITCH(8), - JUMPIF_SCENARIOCHECK(6, /* to label */ 31), + JUMPIF_SCENARIOCHECK(QUEST_REACHED_POSTGAME, /* to label */ 31), JUMP_LABEL(32), LABEL(31), /* = 0x1f */ SELECT_EVENTS(0, 2), diff --git a/src/data/ground/ground_data_t01p05_station.h b/src/data/ground/ground_data_t01p05_station.h index 91d1a0794..b78760c45 100644 --- a/src/data/ground/ground_data_t01p05_station.h +++ b/src/data/ground/ground_data_t01p05_station.h @@ -110,7 +110,7 @@ static const struct ScriptRef s_gs6_g0_s3_evt0_sref = { 357, 2, NULL /* GETOUT_N static const struct ScriptCommand s_gs6_g1_s0_station_sref_script[] = { /* 0x8199310 */ DEBUGINFO_O(112), - JUMPIF_SCENARIOCHECK(10, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_UNK10, /* to label */ 0), CANCEL_EVENTS(-1, -1), SELECT_ENTITIES(-1, 1), RET_DIRECT, @@ -144,7 +144,7 @@ static const struct ScriptCommand s_gs6_g1_s0_lives0_dlg2[] = { /* 0x81993dc */ static const struct ScriptCommand s_gs6_g1_s0_lives0_dlg3[] = { /* 0x819947c */ DEBUGINFO_O(145), CALL_SCRIPT(INIT_PLAZA_SLEEP_TALK_FUNC), - JUMPIF_SCENARIOCHECK(4, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_SQUARE_ASLEEP, /* to label */ 0), { 0x8e, 0x00, 0x0000, 0x00000000, 0x00000000, NULL }, LABEL(0), /* = 0x00 */ { 0x8d, 0x01, 0x0000, 0x00000000, 0x00000000, NULL }, diff --git a/src/data/ground/ground_event_data.h b/src/data/ground/ground_event_data.h index 2cbaa1fae..c7c453999 100644 --- a/src/data/ground/ground_event_data.h +++ b/src/data/ground/ground_event_data.h @@ -494,7 +494,7 @@ static const struct ScriptCommand s_script_MOVE_PLAZA_SLEEP[] = { /* 0x8120590 * static const struct ScriptCommand s_script_INIT_PLAZA_SLEEP_STAY_FUNC[] = { /* 0x81205f0 */ DEBUGINFO_O(496), - JUMPIF_SCENARIOCHECK(4, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_SQUARE_ASLEEP, /* to label */ 0), { 0x54, 0x00, 0x0300, 0x00000000, 0x00000000, NULL }, SELECT_ANIMATION(4), RET_DIRECT, @@ -505,7 +505,7 @@ static const struct ScriptCommand s_script_INIT_PLAZA_SLEEP_STAY_FUNC[] = { /* 0 static const struct ScriptCommand s_script_INIT_PLAZA_SLEEP_TALK_FUNC[] = { /* 0x8120670 */ DEBUGINFO_O(507), - JUMPIF_SCENARIOCHECK(4, /* to label */ 0), + JUMPIF_SCENARIOCHECK(QUEST_SQUARE_ASLEEP, /* to label */ 0), SELECT_ANIMATION(2), RET_DIRECT, LABEL(0), /* = 0x00 */ diff --git a/src/dungeon_action_handler.c b/src/dungeon_action_handler.c index ca19263b2..e426902f1 100644 --- a/src/dungeon_action_handler.c +++ b/src/dungeon_action_handler.c @@ -656,7 +656,7 @@ static void sub_8067558(Entity *entity, Entity *targetEntity, s32 a2) else if (info2->joinedAt.id == DUNGEON_RESCUE_TEAM_BASE) { speciesId = MONSTER_DECOY; } - else if (info2->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER && !gDungeon->unk644.unk18) { + else if (info2->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER && !gDungeon->unk644.canChangeLeader) { r6 = TRUE; } diff --git a/src/dungeon_cutscene.c b/src/dungeon_cutscene.c index 04e147019..6ed978ca1 100644 --- a/src/dungeon_cutscene.c +++ b/src/dungeon_cutscene.c @@ -55,15 +55,15 @@ extern void sub_8088EE8(void); extern void sub_8088848(void); extern void sub_808A718(void); -struct unkData_8107234 +typedef struct FixedRoomPrefightData { - u8 unk0; - u8 unk1; - u8 unk2; - u8 unk3; - u8 unk4; - u8 unk5; -}; + u8 fixedRoomNumber; // See enum "FixedRoomID" + u8 prefight1; // See enum "PrefightKind" + u8 unk2; // 64 is a special value... + u8 prefight3; // See enum "PrefightKind" + u8 unk4; // 64 is a special value... + u8 prefight5; // See enum "PrefightKind" +} FixedRoomPrefightData; // size: 0x8 typedef struct unkStruct_202F3D0 @@ -76,40 +76,40 @@ typedef struct unkStruct_202F3D0 u8 unk5; } unkStruct_202F3D0; -static void sub_8084854(const struct unkData_8107234 *); +static void sub_8084854(const FixedRoomPrefightData *); static void sub_8085764(void); static void sub_80857B8(void); static void sub_80861EC(Entity *); -static const struct unkData_8107234 gUnknown_8107234[28] = { - [0] = {1, 1, 0, 2, 1, 3}, - [1] = {2, 4, 2, 5, 3, 6}, - [2] = {3, 7, 4, 8, 5, 9}, - [3] = {4, 0xA, 6, 0xB, 7, 0xC}, - [4] = {5, 0xD, 8, 0xE, 9, 0xF}, - [5] = {6, 0x10, 0xA, 0x11, 0xA, 0x11}, - [6] = {7, 0x12, 0xB, 0x13, 0xC, 0x14}, - [7] = {0x14, 0x15, 0xD, 0x16, 0xD, 0x16}, - [8] = {8, 0x17, 0xE, 0x18, 0xF, 0x19}, - [9] = {0xB, 0x1A, 0x10, 0x1B, 0x11, 0x1C}, - [10] = {9, 0x1D, 0x12, 0x1E, 0x13, 0x1F}, - [11] = {0xC, 0x20, 0x14, 0x21, 0x15, 0x22}, - [12] = {0xD, 0x23, 0x16, 0x24, 0x17, 0x25}, - [13] = {0xE, 0x26, 0x18, 0x27, 0x19, 0x28}, - [14] = {0xF, 0x29, 0x40, 0x29, 0x1A, 0x2A}, - [15] = {0x10, 0x2B, 0x1B, 0x2C, 0x1C, 0x2D}, - [16] = {0x11, 0x2E, 0x40, 0x2E, 0x40, 0x2E}, - [17] = {0x12, 0x2F, 0x40, 0x2F, 0x40, 0x2F}, - [18] = {0x13, 0x30, 0x40, 0x30, 0x40, 0x30}, - [19] = {0xA, 0x31, 0x40, 0x31, 0x1E, 0x32}, - [20] = {0x15, 0x33, 0x40, 0x33, 0x40, 0x33}, - [21] = {0x16, 0x34, 0x40, 0x34, 0x40, 0x34}, - [22] = {0x17, 0x35, 0x40, 0x35, 0x40, 0x35}, - [23] = {0x19, 0x36, 0x40, 0x36, 0x40, 0x36}, - [24] = {0x1B, 0x37, 0x40, 0x37, 0x40, 0x37}, - [25] = {0x1A, 0x38, 0x20, 0x39, 0x20, 0x39}, - [26] = {0x18, 0x3A, 0x21, 0x3B, 0x21, 0x3B}, - [27] = {0}, +static const FixedRoomPrefightData sFixedRoomPrefightLookup[] = { + { FIXED_ROOM_MT_STEEL_SKARMORY, PREFIGHT_SKARMORY_ATTEMPT1, 0, PREFIGHT_SKARMORY_ATTEMPT2, 1, PREFIGHT_SKARMORY_GONE }, + { FIXED_ROOM_SINISTER_WOODS_TEAM_MEANIES, 4, 2, 5, 3, 6 }, + { FIXED_ROOM_MT_THUNDER_PEAK_ZAPDOS, 7, 4, 8, 5, 9 }, + { FIXED_ROOM_MT_BLAZE_PEAK_MOLTRES, 0xA, 6, 0xB, 7, 0xC }, + { FIXED_ROOM_FROSTY_GROTTO_ARTICUNO, 0xD, 8, 0xE, 9, 0xF }, + { FIXED_ROOM_MT_FREEZE_PEAK_NINETALES, 0x10, 0xA, 0x11, 0xA, 0x11 }, + { FIXED_ROOM_MAGMA_CAVERN_PIT_GROUDON, 0x12, 0xB, 0x13, 0xC, 0x14 }, + { FIXED_ROOM_MAGMA_CAVERN_PIT_TYRANITAR_ALAKAZAM, 0x15, 0xD, 0x16, 0xD, 0x16 }, + { FIXED_ROOM_SKY_TOWER_SUMMIT_RAYQUAZA, 0x17, 0xE, 0x18, 0xF, 0x19 }, + { FIXED_ROOM_UPROAR_FOREST_MANKEY, 0x1A, 0x10, 0x1B, 0x11, 0x1C }, + { FIXED_ROOM_WESTERN_CAVE_MEWTWO, 0x1D, 0x12, 0x1E, 0x13, 0x1F }, + { FIXED_ROOM_FIERY_FIELD_ENTEI, 0x20, 0x14, 0x21, 0x15, 0x22 }, + { FIXED_ROOM_LIGHTNING_FIELD_RAIKOU, 0x23, 0x16, 0x24, 0x17, 0x25 }, + { FIXED_ROOM_NORTHWIND_FIELD_SUICUNE, 0x26, 0x18, 0x27, 0x19, 0x28 }, + { FIXED_ROOM_MT_FARAWAY_HO_OH, 0x29, 64, 0x29, 0x1A, 0x2A }, + { FIXED_ROOM_NORTHERN_RANGE_LATIOS, 0x2B, 0x1B, 0x2C, 0x1C, 0x2D }, + { FIXED_ROOM_BURIED_RELIC_REGIROCK, 0x2E, 64, 0x2E, 64, 0x2E }, + { FIXED_ROOM_BURIED_RELIC_REGICE, 0x2F, 64, 0x2F, 64, 0x2F }, + { FIXED_ROOM_BURIED_RELIC_REGISTEEL, 0x30, 64, 0x30, 64, 0x30 }, + { FIXED_ROOM_WISH_CAVE_JIRACHI, 0x31, 64, 0x31, 0x1E, 0x32 }, + { FIXED_ROOM_SILVER_TRENCH_LUGIA, 0x33, 64, 0x33, 64, 0x33 }, + { FIXED_ROOM_STORMY_SEA_KYOGRE, 0x34, 64, 0x34, 64, 0x34 }, + { FIXED_ROOM_METEOR_CAVE_DEOXYS, 0x35, 64, 0x35, 64, 0x35 }, + { FIXED_ROOM_PURITY_FOREST_CELEBI, 0x36, 64, 0x36, 64, 0x36 }, + { FIRST_DOJO_MAZE_BOSS_ROOM, 0x37, 64, 0x37, 64, 0x37 }, + { FIXED_ROOM_WISH_CAVE_MEDICHAM, 0x38, 0x20, 0x39, 0x20, 0x39 }, + { FIXED_ROOM_HOWLING_FOREST_SMEARGLE, 0x3A, 0x21, 0x3B, 0x21, 0x3B }, + { FIXED_ROOM_NONE, 0, 0, 0, 0, 0 }, }; static const s32 gUnknown_8107314[] = { @@ -123,41 +123,41 @@ EWRAM_DATA static unkStruct_202F3D0 gUnknown_202F3D0 = {0}; void sub_80847D4(void) { u32 fixedRoomNumber; - s32 index; + s32 i; - gDungeon->unk3A0D = 0; + gDungeon->prefight = PREFIGHT_NONE; gDungeon->unk1356C = 0; UpdateMinimap(); - for(index = 0; index < 0x3e7 && gUnknown_8107234[index].unk0 != 0; index++) { + for (i = 0; i < 999 && sFixedRoomPrefightLookup[i].fixedRoomNumber != FIXED_ROOM_NONE; i++) { fixedRoomNumber = gDungeon->fixedRoomNumber; // Dojo maze bosses all use the same cutscene data - if (fixedRoomNumber - (FIRST_DOJO_MAZE_BOSS_ROOM+1) < NUM_MAZE_BOSS_ROOMS) { + if (fixedRoomNumber - (FIRST_DOJO_MAZE_BOSS_ROOM + 1) < NUM_MAZE_BOSS_ROOMS) { fixedRoomNumber = FIRST_DOJO_MAZE_BOSS_ROOM; } - if (fixedRoomNumber == gUnknown_8107234[index].unk0) + if (fixedRoomNumber == sFixedRoomPrefightLookup[i].fixedRoomNumber) { - sub_8084854(&gUnknown_8107234[index]); + sub_8084854(&sFixedRoomPrefightLookup[i]); break; } } sub_8097FF8(); } -static void sub_8084854(const struct unkData_8107234 *param_1) +static void sub_8084854(const FixedRoomPrefightData *a0) { - if (gDungeon->unk644.unk34 != 0) { - gDungeon->unk3A0D = param_1->unk5; + if (gDungeon->unk644.missionKind != DUNGEON_MISSION_UNK0) { + gDungeon->prefight = a0->prefight5; } - else if (sub_8098100(param_1->unk4) != 0) { - gDungeon->unk3A0D = param_1->unk5; + else if (sub_8098100(a0->unk4)) { + gDungeon->prefight = a0->prefight5; } - else if (sub_8098100(param_1->unk2) != 0) { - gDungeon->unk3A0D = param_1->unk3; + else if (sub_8098100(a0->unk2)) { + gDungeon->prefight = a0->prefight3; } else { - gDungeon->unk3A0D = param_1->unk1; - if (param_1->unk2 != 0x40) { - sub_8097FA8(param_1->unk2); + gDungeon->prefight = a0->prefight1; + if (a0->unk2 != 64) { + sub_8097FA8(a0->unk2); } } @@ -173,16 +173,16 @@ bool8 ShouldShowDungeonBanner(void) void sub_80848F0(void) { gDungeon->unk1356C = 1; - switch(gDungeon->unk3A0D) { - case 0: + switch(gDungeon->prefight) { + case PREFIGHT_NONE: case 0x3c: gDungeon->unk1356C = 0; break; - case 1: - case 2: + case PREFIGHT_SKARMORY_ATTEMPT1: + case PREFIGHT_SKARMORY_ATTEMPT2: sub_8086B14(); break; - case 3: + case PREFIGHT_SKARMORY_GONE: sub_8086B94(); break; case 4: @@ -345,16 +345,16 @@ void sub_80848F0(void) void DisplayPreFightDialogue(void) { - switch(gDungeon->unk3A0D) { - case 0: + switch(gDungeon->prefight) { + case PREFIGHT_NONE: break; - case 1: + case PREFIGHT_SKARMORY_ATTEMPT1: SkarmoryPreFightDialogue(); break; - case 2: + case PREFIGHT_SKARMORY_ATTEMPT2: SkarmoryReFightDialogue(); break; - case 3: + case PREFIGHT_SKARMORY_GONE: sub_8086E40(); break; case 4: @@ -535,102 +535,102 @@ void DisplayPreFightDialogue(void) void sub_8084E00(Entity *entity, u8 param_2, bool8 param_3) { if (param_2 != 0) { - switch(gDungeon->unk3A0D) { - case 0: + switch(gDungeon->prefight) { + case PREFIGHT_NONE: break; - case 1: - case 2: - sub_8086BDC(param_2,gDungeon->unk3A0D); + case PREFIGHT_SKARMORY_ATTEMPT1: + case PREFIGHT_SKARMORY_ATTEMPT2: + sub_8086BDC(param_2, gDungeon->prefight); break; case 4: case 5: - sub_8086F54(param_2,gDungeon->unk3A0D); + sub_8086F54(param_2, gDungeon->prefight); break; case 7: case 8: case 9: - sub_8087334(param_2,gDungeon->unk3A0D); + sub_8087334(param_2,gDungeon->prefight); break; case 10: case 0xb: case 0xc: - sub_80878F4(param_2,gDungeon->unk3A0D); + sub_80878F4(param_2,gDungeon->prefight); break; case 0xd: case 0xe: case 0xf: - sub_8088088(param_2,gDungeon->unk3A0D); + sub_8088088(param_2,gDungeon->prefight); break; case 0x12: case 0x13: case 0x14: - sub_8088818(param_2,gDungeon->unk3A0D); + sub_8088818(param_2,gDungeon->prefight); break; case 0x17: case 0x18: case 0x19: - sub_80893B4(param_2,gDungeon->unk3A0D); + sub_80893B4(param_2,gDungeon->prefight); break; case 0x1a: case 0x1b: - sub_8089788(entity,param_2,gDungeon->unk3A0D); + sub_8089788(entity,param_2,gDungeon->prefight); break; case 0x1d: case 0x1e: case 0x1f: - sub_8089A00(param_2,gDungeon->unk3A0D); + sub_8089A00(param_2,gDungeon->prefight); break; case 0x20: case 0x21: case 0x22: - sub_8089CFC(param_2,gDungeon->unk3A0D); + sub_8089CFC(param_2,gDungeon->prefight); break; case 0x23: case 0x24: case 0x25: - sub_8089FF0(param_2,gDungeon->unk3A0D); + sub_8089FF0(param_2,gDungeon->prefight); break; case 0x26: case 0x27: case 0x28: - sub_808A36C(param_2,gDungeon->unk3A0D); + sub_808A36C(param_2,gDungeon->prefight); break; case 0x29: case 0x2a: - sub_808A6E8(param_2,gDungeon->unk3A0D); + sub_808A6E8(param_2,gDungeon->prefight); break; case 0x2b: case 0x2c: case 0x2d: - sub_808AAF0(param_2,gDungeon->unk3A0D); + sub_808AAF0(param_2,gDungeon->prefight); break; case 0x2e: - sub_808AE54(param_2,gDungeon->unk3A0D,&entity->pos); + sub_808AE54(param_2,gDungeon->prefight,&entity->pos); break; case 0x2f: - sub_808AEC8(param_2,gDungeon->unk3A0D,&entity->pos); + sub_808AEC8(param_2,gDungeon->prefight,&entity->pos); break; case 0x30: - sub_808AF3C(param_2,gDungeon->unk3A0D,&entity->pos); + sub_808AF3C(param_2,gDungeon->prefight,&entity->pos); break; case 0x31: case 0x32: - sub_808B3E4(param_2,gDungeon->unk3A0D,param_3); + sub_808B3E4(param_2,gDungeon->prefight,param_3); break; case 0x33: - sub_808BE70(param_2,gDungeon->unk3A0D,param_3); + sub_808BE70(param_2,gDungeon->prefight,param_3); break; case 0x34: - sub_808C1A4(param_2,gDungeon->unk3A0D,param_3); + sub_808C1A4(param_2,gDungeon->prefight,param_3); break; case 0x35: - sub_808C414(param_2,gDungeon->unk3A0D,param_3); + sub_808C414(param_2,gDungeon->prefight,param_3); break; case 0x36: - nullsub_100(param_2,gDungeon->unk3A0D,param_3); + nullsub_100(param_2,gDungeon->prefight,param_3); break; case 0x37: - sub_808C948(entity,gDungeon->unk3A0D); + sub_808C948(entity,gDungeon->prefight); break; case 0x38: case 0x39: @@ -647,21 +647,21 @@ void sub_8084E00(Entity *entity, u8 param_2, bool8 param_3) void sub_8085140(void) { - switch(gDungeon->unk3A0D) { + switch (gDungeon->prefight) { // NOTE: shortcut way to generate all cases from 0 - 0x3C properly default: - case 0: - case 1: + case PREFIGHT_NONE: + case PREFIGHT_SKARMORY_ATTEMPT1: case 0x3C: break; case 0x2e: - sub_808AFB0(gDungeon->unk3A0D); + sub_808AFB0(gDungeon->prefight); break; case 0x2f: - sub_808B030(gDungeon->unk3A0D); + sub_808B030(gDungeon->prefight); break; case 0x30: - sub_808B0B0(gDungeon->unk3A0D); + sub_808B0B0(gDungeon->prefight); break; } } @@ -760,7 +760,7 @@ void sub_8085374(void) } } - if (leaderEntity == NULL || partnerEntity != NULL || gDungeon->unk644.unk18 != 0) + if (leaderEntity == NULL || partnerEntity != NULL || gDungeon->unk644.canChangeLeader) return; j = 0; @@ -1364,7 +1364,7 @@ void sub_8085F44(s32 param_1) void sub_8085F78(void) { - switch(gDungeon->unk3A0D) { + switch(gDungeon->prefight) { case 0x12: case 0x13: case 0x14: @@ -1377,7 +1377,7 @@ void sub_8085F78(void) case 0x2A: sub_808A718(); break; - case 0: + case PREFIGHT_NONE: case 0x3C: default: break; @@ -1981,12 +1981,12 @@ void sub_8086AC0(void) sub_8097FF8(); } -u8 sub_8086AE4(s16 _index) +bool8 sub_8086AE4(s16 _index) { s32 pokeIndex = _index; - if(gDungeon->unk644.unk18 == 0) - return 1; + if (!gDungeon->unk644.canChangeLeader) + return TRUE; else return HasRecruitedMon(pokeIndex); } diff --git a/src/dungeon_cutscene_skarmory.c b/src/dungeon_cutscene_skarmory.c index dfbaf6d50..1f7fdf923 100644 --- a/src/dungeon_cutscene_skarmory.c +++ b/src/dungeon_cutscene_skarmory.c @@ -71,9 +71,9 @@ void sub_8086B94(void) sub_8085860(leaderEntity->pos.x,leaderEntity->pos.y); } -void sub_8086BDC(u8 param_1, u8 param_2) +void sub_8086BDC(u8 param_1, u8 prefight) { - if ((param_2 == 1 || param_2 == 2) && param_1 == 3) { + if ((prefight == PREFIGHT_SKARMORY_ATTEMPT1 || prefight == PREFIGHT_SKARMORY_ATTEMPT2) && param_1 == 3) { sub_8097FA8(1); gDungeon->unk2 = 1; } diff --git a/src/dungeon_cutscene_zapdos.c b/src/dungeon_cutscene_zapdos.c index bd587214b..151d98ea0 100644 --- a/src/dungeon_cutscene_zapdos.c +++ b/src/dungeon_cutscene_zapdos.c @@ -74,7 +74,7 @@ void sub_808729C(void) sub_80854D4(); sub_8085930(4); sub_80855E4(sub_8086A3C); - if (sub_8086AE4(0x91) != 0) { + if (sub_8086AE4(MONSTER_ZAPDOS)) { HandleFaint(zapdosEntity,DUNGEON_EXIT_DELETED_FOR_EVENT,0); } else { diff --git a/src/dungeon_damage.c b/src/dungeon_damage.c index 13bced3a3..d10f93525 100644 --- a/src/dungeon_damage.c +++ b/src/dungeon_damage.c @@ -478,7 +478,7 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc } else { DungeonMon *recruitedMon = &gRecruitedPokemonRef->dungeonTeam[targetData->teamIndex]; - if (targetData->isTeamLeader || (targetData->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER && gDungeon->unk644.unk18 == 0)) { + if (targetData->isTeamLeader || (targetData->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER && !gDungeon->unk644.canChangeLeader)) { DisplayDungeonLoggableMessageTrue(attacker, gUnknown_80F9CEC[r8]); } else if (IsExperienceLocked(targetData->joinedAt.id)) { diff --git a/src/dungeon_exit.c b/src/dungeon_exit.c index 8283fcd7b..6024c86c0 100644 --- a/src/dungeon_exit.c +++ b/src/dungeon_exit.c @@ -90,11 +90,11 @@ bool8 sub_8083C50(void) return FALSE; } -bool8 sub_8083C88(u8 param_1) +bool8 sub_8083C88(u8 dungeonMissionKind) { DungeonExitSummary *exitSummary = &gDungeon->exitSummary; - if ((!HasCheckpoint(gDungeon->unk644.dungeonLocation.id) && (gDungeon->unk644.unk18 != 0 || param_1 != 0)) + if ((!HasCheckpoint(gDungeon->unk644.dungeonLocation.id) && (gDungeon->unk644.canChangeLeader || dungeonMissionKind != DUNGEON_MISSION_UNK0)) || exitSummary->exitReason != DUNGEON_EXIT_CLEARED_DUNGEON) { return TRUE; } diff --git a/src/dungeon_generation.c b/src/dungeon_generation.c index bf247b6f9..77af4aa22 100644 --- a/src/dungeon_generation.c +++ b/src/dungeon_generation.c @@ -4288,7 +4288,7 @@ static void SpawnNonEnemies(FloorProperties *floorProps, bool8 isEmptyMonsterHou // Spawn an item tile->spawnOrVisibilityFlags.spawn |= SPAWN_FLAG_ITEM; } - else if (gDungeon->unk644.unk18) { + else if (gDungeon->unk644.canChangeLeader) { tile->spawnOrVisibilityFlags.spawn |= SPAWN_FLAG_TRAP; } diff --git a/src/dungeon_item_action.c b/src/dungeon_item_action.c index 93404fcda..7bec635db 100644 --- a/src/dungeon_item_action.c +++ b/src/dungeon_item_action.c @@ -756,7 +756,7 @@ bool8 sub_8048A68(Entity *param_1,Item *item) } else { - if (gDungeon->unk644.unk18 == 0) { + if (!gDungeon->unk644.canChangeLeader) { DisplayDungeonMessage(0,gUnknown_80F9BD8,1); return FALSE; } diff --git a/src/dungeon_jobs.c b/src/dungeon_jobs.c index d3c0054ca..90c8342cd 100644 --- a/src/dungeon_jobs.c +++ b/src/dungeon_jobs.c @@ -23,7 +23,7 @@ void sub_80842F0(void) gDungeon->unk644.unk33 = 0; gDungeon->unk644.unk46 = 0; - if (gDungeon->unk644.unk34 != 2) + if (gDungeon->unk644.missionKind != DUNGEON_MISSION_ACCEPTEDJOB_RELATED) return; for (i = 0; i < MAX_ACCEPTED_JOBS; i++) { diff --git a/src/dungeon_leveling.c b/src/dungeon_leveling.c index 304bffda6..147ce0c8d 100644 --- a/src/dungeon_leveling.c +++ b/src/dungeon_leveling.c @@ -263,7 +263,7 @@ static void sub_807218C(Entity *pokemon) } else if(info->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) { - if(gDungeon->unk644.unk18 == 0) + if (!gDungeon->unk644.canChangeLeader) r3 = 1; } sub_806A3D4(buffer, r1, 3, r3); diff --git a/src/dungeon_menu_others.c b/src/dungeon_menu_others.c index 75c990a82..c7be13387 100644 --- a/src/dungeon_menu_others.c +++ b/src/dungeon_menu_others.c @@ -417,7 +417,7 @@ static void ShowQuickSaveGiveUpMenu(void) static void ShowMissionObjectivesMenu(void) { - sub_80319A4(gDungeon->unk644.unk34, gDungeon->unk644.dungeonLocation.id, 0); + sub_80319A4(gDungeon->unk644.missionKind, gDungeon->unk644.dungeonLocation.id, 0); do { DungeonRunFrameActions(0x47); } while (sub_80319F8() == 0); diff --git a/src/dungeon_menu_team.c b/src/dungeon_menu_team.c index 080bd3586..f921a5db6 100644 --- a/src/dungeon_menu_team.c +++ b/src/dungeon_menu_team.c @@ -360,7 +360,7 @@ static void AddTeamSubMenuOptions(struct UnkFieldTeamMenuStruct *a0) AddActionToDungeonSubMenu(ACTION_CHECK_SUMMARY, 0); AddActionToDungeonSubMenu(ACTION_CHECK_MOVES, 0); if (!monInfo->isTeamLeader) { - if (!gDungeon->unk644.unk19 && (monInfo->joinedAt.id != DUNGEON_JOIN_LOCATION_PARTNER || gDungeon->unk644.unk18)) { + if (!gDungeon->unk644.unk19 && (monInfo->joinedAt.id != DUNGEON_JOIN_LOCATION_PARTNER || gDungeon->unk644.canChangeLeader)) { AddActionToDungeonSubMenu(0x34, 0); } AddActionToDungeonSubMenu(ACTION_TALK_MENU, 0); @@ -369,7 +369,7 @@ static void AddTeamSubMenuOptions(struct UnkFieldTeamMenuStruct *a0) if (!monInfo->isTeamLeader) { AddActionToDungeonSubMenu(ACTION_CHANGE_TACTICS, 0); } - if (!monInfo->isTeamLeader && gDungeon->unk644.unk18 && CanLeaderSwitch(gDungeon->unk644.dungeonLocation.id)) { + if (!monInfo->isTeamLeader && gDungeon->unk644.canChangeLeader && CanLeaderSwitch(gDungeon->unk644.dungeonLocation.id)) { bool32 r5; AddActionToDungeonSubMenu(0x3B, 0); diff --git a/src/dungeon_message.c b/src/dungeon_message.c index 4934b5fbe..3f59c7cdc 100644 --- a/src/dungeon_message.c +++ b/src/dungeon_message.c @@ -735,7 +735,7 @@ void sub_8052FB8(const u8 *str) const u8 *GetCurrentDungeonName(void) { - if (gDungeon->unk644.unk34 == 1) { + if (gDungeon->unk644.missionKind == DUNGEON_MISSION_OUTONRESCUE) { return GetDungeonName1(DUNGEON_OUT_ON_RESCUE); } else { diff --git a/src/dungeon_misc.c b/src/dungeon_misc.c index 9274e7af1..aadcc6b19 100644 --- a/src/dungeon_misc.c +++ b/src/dungeon_misc.c @@ -486,7 +486,7 @@ void HandleFaint(Entity *entity, s32 dungeonExitReason_, Entity *param_3) entity->isVisible = FALSE; gLeaderPointer = NULL; joinId = entInfo->joinedAt.id; - if (joinId == DUNGEON_JOIN_LOCATION_PARTNER && gDungeon->unk644.unk18 == 0) { + if (joinId == DUNGEON_JOIN_LOCATION_PARTNER && !gDungeon->unk644.canChangeLeader) { gDungeon->unk10 = 1; entInfo->HP = 0; SubstitutePlaceholderStringTags(gDungeon->faintStringBuffer,entity,0); @@ -505,9 +505,9 @@ void HandleFaint(Entity *entity, s32 dungeonExitReason_, Entity *param_3) && dungeonExitReason != DUNGEON_EXIT_DELETED_FOR_EVENT && dungeonExitReason != DUNGEON_EXIT_FAILED_TO_PROTECT_CLIENT && dungeonExitReason != DUNGEON_EXIT_BLOWN_OUT_UNSEEN_FORCE - && gDungeon->unk3A0D == 0 + && gDungeon->prefight == PREFIGHT_NONE && gDungeon->unk644.unk37 >= 0 - && gDungeon->unk644.unk34 != TRUE) + && gDungeon->unk644.missionKind != DUNGEON_MISSION_OUTONRESCUE) { if (gDungeon->unk644.unk37 > 0) { if (DisplayDungeonYesNoMessage(NULL,gUnknown_80FE268,1) == 1) { @@ -605,7 +605,7 @@ void HandleFaint(Entity *entity, s32 dungeonExitReason_, Entity *param_3) if (entInfo->isTeamLeader) { uVar10 = TRUE; } - if (gDungeon->unk644.unk18 == 0 && entInfo->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) { + if (!gDungeon->unk644.canChangeLeader && entInfo->joinedAt.id == DUNGEON_JOIN_LOCATION_PARTNER) { uVar10 = TRUE; } @@ -846,7 +846,7 @@ void SetMonSummaryInfoFromEntity(struct MonSummaryInfo *param_1, Entity *target) param_1->unk44[0].level = 0; param_1->unk44[1].level = 0; param_1->IQSkills = info->IQSkillMenuFlags; - if (gDungeon->unk644.unk16 != 0) { + if (gDungeon->unk644.unlockedEvolutions) { param_1->evoStringId = sub_806A4DC(info); } else { @@ -1352,6 +1352,7 @@ bool8 sub_806A458(Entity *pokemon) return (count > 1); } +// Evolution string related s32 sub_806A4DC(EntityInfo *info) { Pokemon pokemon; diff --git a/src/dungeon_mon_recruit.c b/src/dungeon_mon_recruit.c index e0bf3e86c..c6bfffce3 100644 --- a/src/dungeon_mon_recruit.c +++ b/src/dungeon_mon_recruit.c @@ -48,16 +48,14 @@ bool8 TryRecruitMonster(Entity *attacker, Entity *target) if (gDungeon->fixedRoomNumber != FIXED_ROOM_FROSTY_GROTTO_ARTICUNO && gDungeon->fixedRoomNumber != FIXED_ROOM_MT_BLAZE_PEAK_MOLTRES && gDungeon->fixedRoomNumber != FIXED_ROOM_WESTERN_CAVE_MEWTWO - && gDungeon->fixedRoomNumber != FIXED_ROOM_MT_FARAWAY_HO_OH - ) { - if (gDungeon->fixedRoomNumber >= FIXED_ROOM_TEAM_SHIFTY_BOSS - && gDungeon->fixedRoomNumber <= FIXED_ROOM_RESCUE_TEAM_2_BOSS - ) { - if (gDungeon->unk644.unk18 == 0) + && gDungeon->fixedRoomNumber != FIXED_ROOM_MT_FARAWAY_HO_OH) { + + if (gDungeon->fixedRoomNumber >= FIXED_ROOM_TEAM_SHIFTY_BOSS && gDungeon->fixedRoomNumber <= FIXED_ROOM_RESCUE_TEAM_2_BOSS) { + if (!gDungeon->unk644.canChangeLeader) return FALSE; } else if (gDungeon->fixedRoomNumber == FIXED_ROOM_RESCUE_TEAM_MAZE_BOSS) { - if (gDungeon->unk644.unk15 == 0) + if (!gDungeon->unk644.canRecruitRescueTeamMazeBosses) return FALSE; if (!sub_8097900(MONSTER_DEOXYS_NORMAL)) return FALSE; @@ -85,8 +83,7 @@ bool8 TryRecruitMonster(Entity *attacker, Entity *target) targetInfo->id == MONSTER_REGIROCK || targetInfo->id == MONSTER_REGICE || targetInfo->id == MONSTER_REGISTEEL) - && HasRecruitedMon(targetInfo->id)) - { + && HasRecruitedMon(targetInfo->id)) { return FALSE; } @@ -107,9 +104,9 @@ bool8 TryRecruitMonster(Entity *attacker, Entity *target) if (recruitRate == -999) return FALSE; - if (HasHeldItem(attacker, ITEM_FRIEND_BOW)) { + if (HasHeldItem(attacker, ITEM_FRIEND_BOW)) recruitRate += gFriendBowRecruitRateUpValue; - } + recruitRate += gRecruitRateByLevel[attackerInfo->level]; if (rand >= recruitRate) return FALSE; @@ -194,7 +191,7 @@ bool8 IsMonsterRecruitable(s32 species) else if (!sub_808529C(id)) { return FALSE; } - else if (id == MONSTER_MEW && gDungeon->unk644.unk34 == 1) { + else if (id == MONSTER_MEW && gDungeon->unk644.missionKind == DUNGEON_MISSION_OUTONRESCUE) { return FALSE; } else if (id == MONSTER_LATIAS) { diff --git a/src/dungeon_mon_spawn.c b/src/dungeon_mon_spawn.c index 5c2547a64..1b881003c 100644 --- a/src/dungeon_mon_spawn.c +++ b/src/dungeon_mon_spawn.c @@ -255,7 +255,7 @@ void sub_806B168(void) } } - if (gDungeon->unk644.unk18 == 0) { + if (!gDungeon->unk644.canChangeLeader) { for (i = 0; i < MAX_TEAM_MEMBERS; i++) { DungeonMon *currMonPtr = monPtrs[i]; if (currMonPtr != NULL && currMonPtr->dungeonLocation.id == DUNGEON_JOIN_LOCATION_PARTNER) { diff --git a/src/dungeon_recruit_release_menu.c b/src/dungeon_recruit_release_menu.c index aa6de89d4..55018b45f 100644 --- a/src/dungeon_recruit_release_menu.c +++ b/src/dungeon_recruit_release_menu.c @@ -418,7 +418,7 @@ static void ShowPokemonSummary(Pokemon *a0) ResetTouchScreenMenuInput(&gDungeonMenu.touchScreen); DungeonShowWindows(&winTemplates, 1); - SetMonSummaryInfo(&unkStruct, a0, gDungeon->unk644.unk16); + SetMonSummaryInfo(&unkStruct, a0, gDungeon->unk644.unlockedEvolutions); ShowPokemonSummaryWindow(spF8[r7], r7, &unkStruct, &var_C8, 0); gDungeonMenu.leftRightArrowsPos.x = (gWindows[0].x + 15) * 8; diff --git a/src/dungeon_serializer.c b/src/dungeon_serializer.c index ec7530bd5..57c2d21db 100644 --- a/src/dungeon_serializer.c +++ b/src/dungeon_serializer.c @@ -403,7 +403,7 @@ static void WriteDungeonFloor(DataSerializer *seri) WriteBool8(seri, gDungeon->unk3A0A); WriteBool8(seri, gDungeon->unk3A0B); WriteU8(seri, gDungeon->monsterHouseRoom); - WriteU8(seri, gDungeon->unk3A0D); + WriteU8(seri, gDungeon->prefight); WriteS16(seri, gDungeon->tileset); WriteS16(seri,gDungeon->unk3A10); WriteS16(seri, gDungeon->unk3A12); @@ -765,7 +765,7 @@ static void ReadDungeonFloor(DataSerializer *seri) gDungeon->unk3A0A = ReadBool8(seri); gDungeon->unk3A0B = ReadBool8(seri); gDungeon->monsterHouseRoom = ReadU8(seri); - gDungeon->unk3A0D = ReadU8(seri); + gDungeon->prefight = ReadU8(seri); gDungeon->tileset = ReadS16(seri); gDungeon->unk3A10 = ReadS16(seri); gDungeon->unk3A12 = ReadS16(seri); diff --git a/src/event_flag.c b/src/event_flag.c index c376dc932..6e2486f64 100644 --- a/src/event_flag.c +++ b/src/event_flag.c @@ -529,14 +529,14 @@ bool8 ScriptVarScenarioEqual(s16 varId,u32 pMain,s32 pSub) } // arm9.bin::0200F1d8 -bool8 ScriptVarScenarioAfter(s16 varId,u32 pMain,s32 pSub) +bool8 ScriptVarScenarioAfter(s16 varId, u32 pMain, s32 pSub) { s32 sMain; s32 sSub; sMain = GetScriptVarArrayValue(NULL, varId, 0); sSub = GetScriptVarArrayValue(NULL, varId, 1); - if (sMain == 0x3a) { + if (sMain == 58) { // DS: Assert(FALSE, "debug mode scenario comp %3d %3d %3d", varId, pMain, pSub) return FALSE; } else if (sMain > pMain) { @@ -816,69 +816,68 @@ UNUSED static const u8 *sub_80023C4(u32 param_1) #endif // arm9.bin::0200E654 -// 6 checks for post game being reached -bool8 sub_80023E4(u32 param_1) +bool8 CheckQuest(s32 questID) { - switch(param_1) { - case 0: - return ScriptVarScenarioAfter(SCENARIO_MAIN,2,-1); - case 1: - return ScriptVarScenarioAfter(SCENARIO_MAIN,3,3); - case 2: - return ScriptVarScenarioAfter(SCENARIO_MAIN,4,3); - case 3: - return ScriptVarScenarioAfter(SCENARIO_MAIN,5,0); - case 4: - return (ScriptVarScenarioAfter(SCENARIO_MAIN,0xb,0) && ScriptVarScenarioBefore(SCENARIO_MAIN,0xd,0)); - case 5: - return (ScriptVarScenarioAfter(SCENARIO_MAIN,0xb,3) && ScriptVarScenarioBefore(SCENARIO_MAIN,0xf,0)); - case 6: - return ScriptVarScenarioAfter(SCENARIO_MAIN,0x11,-1); - case 7: - return ScriptVarScenarioAfter(SCENARIO_MAIN,0x12,2); - case 8: - return ScriptVarScenarioAfter(SCENARIO_MAIN,0x12,3); - case 9: - return ScriptVarScenarioAfter(SCENARIO_MAIN,0x12,-1); - case 10: - return ScriptVarScenarioAfter(SCENARIO_MAIN,5,4); - case 0xb: - return ScriptVarScenarioAfter(SCENARIO_MAIN,5,4); - case 0xc: - return (!ScriptVarScenarioEqual(SCENARIO_MAIN,0xb,2) && !ScriptVarScenarioEqual(SCENARIO_MAIN,0xb,3)); - case 0xd: - return ScriptVarScenarioEqual(SCENARIO_MAIN,0x10,2); - case 0xe: - return !ScriptVarScenarioBefore(SCENARIO_MAIN,5,7); - case 0xf: - return !ScriptVarScenarioBefore(SCENARIO_MAIN,0xf,0); - case 0x10: - return ScriptVarScenarioAfter(SCENARIO_MAIN,7,-1); - case 0x11: - return ScriptVarScenarioAfter(SCENARIO_MAIN,0xc,-1); - case 0x12: - return ScriptVarScenarioAfter(SCENARIO_MAIN,0xd,-1); - case 0x13: - return ScriptVarScenarioAfter(SCENARIO_MAIN,0xf,-1); - case 0x14: - return ScriptVarScenarioAfter(SCENARIO_MAIN,0x10,-1); - case 0x15: - return ScriptVarScenarioAfter(SCENARIO_SUB2,0x21,-1); - case 0x16: - return ScriptVarScenarioAfter(SCENARIO_SUB2,0x22,-1); - case 0x17: - return ScriptVarScenarioAfter(SCENARIO_SUB3,0x24,-1); - case 0x18: - return ScriptVarScenarioAfter(SCENARIO_SUB4,0x2a,-1); - case 0x19: - return ScriptVarScenarioAfter(SCENARIO_SUB5,0x2c,-1); - case 0x1a: - return ScriptVarScenarioAfter(SCENARIO_SUB7,0x31,-1); - case 0x1b: - return RescueScenarioConquered(0x29); - case 0x1c: + switch (questID) { + case QUEST_SET_TEAM_NAME: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 2, -1); + case QUEST_UNK1: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 3, 3); + case QUEST_CAN_ACCESS_JOBS: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 4, 3); + case QUEST_CAN_RECRUIT: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 5, 0); + case QUEST_SQUARE_ASLEEP: + return (ScriptVarScenarioAfter(SCENARIO_MAIN, 11, 0) && ScriptVarScenarioBefore(SCENARIO_MAIN, 13, 0)); + case QUEST_UNK5: + return (ScriptVarScenarioAfter(SCENARIO_MAIN, 11, 3) && ScriptVarScenarioBefore(SCENARIO_MAIN, 15, 0)); + case QUEST_REACHED_POSTGAME: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 17, -1); + case QUEST_UNLOCKED_EVOLUTIONS: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 18, 2); + case QUEST_CAN_CHANGE_LEADER: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 18, 3); + case QUEST_CAN_DEPOSIT_PARTNER: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 18, -1); + case QUEST_UNK10: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 5, 4); + case QUEST_UNK11: // Never checked? Same as above. + return ScriptVarScenarioAfter(SCENARIO_MAIN, 5, 4); + case QUEST_UNK12: + return (!ScriptVarScenarioEqual(SCENARIO_MAIN, 11, 2) && !ScriptVarScenarioEqual(SCENARIO_MAIN, 11, 3)); + case QUEST_IN_WORLD_CALAMITY: + return ScriptVarScenarioEqual(SCENARIO_MAIN, 16, 2); + case QUEST_MAZE_14: + return !ScriptVarScenarioBefore(SCENARIO_MAIN, 5, 7); + case QUEST_MAZE_15: + return !ScriptVarScenarioBefore(SCENARIO_MAIN, 15, 0); + case QUEST_LEGEND_ZAPDOS: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 7, -1); + case QUEST_LEGEND_MOLTRES: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 12, -1); + case QUEST_LEGEND_ARTICUNO: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 13, -1); + case QUEST_LEGEND_GROUDON: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 15, -1); + case QUEST_LEGEND_RAYQUAZA: + return ScriptVarScenarioAfter(SCENARIO_MAIN, 16, -1); + case QUEST_LEGEND_KYOGRE: + return ScriptVarScenarioAfter(SCENARIO_SUB2, 33, -1); + case QUEST_LEGEND_LUGIA: + return ScriptVarScenarioAfter(SCENARIO_SUB2, 34, -1); + case QUEST_LEGEND_DEOXYS: + return ScriptVarScenarioAfter(SCENARIO_SUB3, 36, -1); + case QUEST_LEGEND_HO_OH: + return ScriptVarScenarioAfter(SCENARIO_SUB4, 42, -1); + case QUEST_LEGEND_MEWTWO: + return ScriptVarScenarioAfter(SCENARIO_SUB5, 44, -1); + case QUEST_LEGEND_MEW: + return ScriptVarScenarioAfter(SCENARIO_SUB7, 49, -1); + case QUEST_LEGEND_CELEBI: + return RescueScenarioConquered(RESCUE_DUNGEON_PURITY_FOREST); + case QUEST_LUCARIO_RANK: // Never checked? return GetRescueTeamRank() == LUCARIO_RANK; - case 0x1d: + case QUEST_COMPLETED_ALL_MAZES: return HasCompletedAllMazes(); default: return FALSE; diff --git a/src/exclusive_pokemon.c b/src/exclusive_pokemon.c index e8faf27e2..8cc86c727 100644 --- a/src/exclusive_pokemon.c +++ b/src/exclusive_pokemon.c @@ -75,6 +75,7 @@ void sub_80980B4(s16 pokeID) { s32 pokeID_s32 = pokeID; s32 pokeID_s32_1 = pokeID_s32; + if (pokeID_s32 == MONSTER_DECOY) return; if (pokeID_s32 == MONSTER_STATUE) @@ -87,13 +88,10 @@ void sub_80980B4(s16 pokeID) bool8 sub_8098100(u8 param_1) { - if (param_1 > 0x3f) { + if (param_1 >= 64) return FALSE; - } - else - { - return (gUnknown_203B498->unk3C[param_1 / 32] & (1 << (param_1 % 32))) != 0; - } + + return (gUnknown_203B498->unk3C[param_1 / 32] & (1 << (param_1 % 32))) != 0; } bool8 sub_8098134(s16 pokeID) @@ -103,7 +101,7 @@ bool8 sub_8098134(s16 pokeID) pokeID_s32 = pokeID; pokeID_s32_1 = pokeID_s32; - return ((gUnknown_203B498->unk4[pokeID_s32 / 32] & (1 << (s16)(pokeID_s32_1 % 32))) != 0); + return (gUnknown_203B498->unk4[pokeID_s32 / 32] & (1 << (s16)(pokeID_s32_1 % 32))) != 0; } void SetTutorialFlag(s32 index) @@ -113,12 +111,10 @@ void SetTutorialFlag(s32 index) bool32 GetTutorialFlag(s32 index) { - if (index > 0x1e) { + if (index >= 31) return FALSE; - } - else { - return (((gUnknown_203B498->unk54[index / 32]) & (1 << (index % 32))) != 0); - } + + return ((gUnknown_203B498->unk54[index / 32]) & (1 << (index % 32))) != 0; } bool8 IsExclusivePokemonUnlocked(s32 pokeID) diff --git a/src/friend_area_action_menu.c b/src/friend_area_action_menu.c index 606f0db88..1ee8272bb 100644 --- a/src/friend_area_action_menu.c +++ b/src/friend_area_action_menu.c @@ -250,7 +250,7 @@ void CreateFriendActionMenu(void) sUnknown_203B2BC->unk16C[loopMax] = 1; } loopMax += 1; - if(sub_80023E4(8) && !pokeStruct->isTeamLeader) + if(CheckQuest(QUEST_CAN_CHANGE_LEADER) && !pokeStruct->isTeamLeader) { sUnknown_203B2BC->menuItems[loopMax].text = sMakeLeader; sUnknown_203B2BC->menuItems[loopMax].menuAction = FRIEND_AREA_ACTION_MENU_ACTION_MAKE_LEADER; @@ -702,7 +702,7 @@ bool8 sub_8027D9C(Pokemon *pokeStruct) var1 = 1; if(var1 != 0) { - if(!sub_80023E4(8)) + if(!CheckQuest(QUEST_CAN_CHANGE_LEADER)) return FALSE; } } @@ -723,7 +723,7 @@ bool8 sub_8027DCC(Pokemon *pokeStruct) var1 = 1; if(var1 != 0) { - if(sub_80023E4(8)) + if(CheckQuest(QUEST_CAN_CHANGE_LEADER)) goto check; } else diff --git a/src/friend_list.c b/src/friend_list.c index 7c026a854..5f2c5d3c6 100644 --- a/src/friend_list.c +++ b/src/friend_list.c @@ -86,7 +86,7 @@ bool8 FriendList_Init(u32 r5, u32 windowId, DungeonPos *pos, u32 r10) case 4: sFriendList->unk18 = 1; sFriendList->unk15 = 1; - if (!sub_80023E4(9)) { + if (!CheckQuest(QUEST_CAN_DEPOSIT_PARTNER)) { sFriendList->unk16 = 1; } break; @@ -365,7 +365,7 @@ bool8 sub_8024108(s32 param_1) } else if (param_1 == 4) { if (pokeStruct->isTeamLeader) continue; - if (!sub_80023E4(9)) { + if (!CheckQuest(QUEST_CAN_DEPOSIT_PARTNER)) { if (!IsMonPartner(pokeStruct)) return FALSE; if (PokemonFlag2(pokeStruct)) continue; } diff --git a/src/friend_list_menu.c b/src/friend_list_menu.c index e7a47c7d3..9672c5f7a 100644 --- a/src/friend_list_menu.c +++ b/src/friend_list_menu.c @@ -705,7 +705,7 @@ static bool8 FriendListMenu_isOnTeam(Pokemon *pokeStruct) if (pokeStruct->isTeamLeader) return FALSE; - if (IsMonPartner(pokeStruct) && !sub_80023E4(8)) + if (IsMonPartner(pokeStruct) && !CheckQuest(QUEST_CAN_CHANGE_LEADER)) return FALSE; return TRUE; diff --git a/src/ground_lives.c b/src/ground_lives.c index 5e80ad4dd..6ebaf460e 100644 --- a/src/ground_lives.c +++ b/src/ground_lives.c @@ -485,7 +485,7 @@ static s32 sub_80A7B94(s16 *a0) return -1; } - if (sub_80023E4(9)) { + if (CheckQuest(QUEST_CAN_DEPOSIT_PARTNER)) { val = sub_808D6A4(sp); } else { @@ -505,7 +505,7 @@ static s32 sub_80A7B94(s16 *a0) GetFriendAreaCapacity2(map, &fAreaCapacity, FALSE, FALSE); if (id < fAreaCapacity.maxPokemon) { Pokemon *monStrPtr = &gRecruitedPokemonRef->pokemon[fAreaCapacity.unk8 + id]; - if (sub_80023E4(9)) { + if (CheckQuest(QUEST_CAN_DEPOSIT_PARTNER)) { if (PokemonExists(monStrPtr) && !monStrPtr->isTeamLeader) { return -1; } @@ -561,7 +561,7 @@ s32 sub_80A7DDC(s16 *a0, s16 *speciesDst) return -1; } - if (sub_80023E4(9)) { + if (CheckQuest(QUEST_CAN_DEPOSIT_PARTNER)) { val = sub_808D6A4(sp); } else { @@ -583,7 +583,7 @@ s32 sub_80A7DDC(s16 *a0, s16 *speciesDst) GetFriendAreaCapacity2(map, &fAreaCapacity, FALSE, FALSE); if (id < fAreaCapacity.maxPokemon) { Pokemon *monStrPtr = &gRecruitedPokemonRef->pokemon[fAreaCapacity.unk8 + id]; - if (sub_80023E4(9)) { + if (CheckQuest(QUEST_CAN_DEPOSIT_PARTNER)) { if (PokemonExists(monStrPtr) && !monStrPtr->isTeamLeader) { *speciesDst = monStrPtr->speciesNum; return -1; @@ -1283,7 +1283,7 @@ Pokemon *sub_80A8D54(s32 a0) if (sub_8098F88()) return NULL; - if (sub_80023E4(9)) { + if (CheckQuest(QUEST_CAN_DEPOSIT_PARTNER)) { val = sub_808D6A4(spArray); } else { @@ -1310,7 +1310,7 @@ Pokemon *sub_80A8D54(s32 a0) return NULL; monPtr = &gRecruitedPokemonRef->pokemon[fAreaCapacity.unk8 + id]; - if (sub_80023E4(9)) { + if (CheckQuest(QUEST_CAN_DEPOSIT_PARTNER)) { if (PokemonExists(monPtr) && !monPtr->isTeamLeader) { return monPtr; } diff --git a/src/ground_main.c b/src/ground_main.c index 093c5c70f..d3e6e2fdd 100644 --- a/src/ground_main.c +++ b/src/ground_main.c @@ -63,7 +63,6 @@ extern void sub_8095494(DungeonMailSeed *param_1, u8 index); // TODO: Move these externs to headers extern s16 sub_80A2654(s16 r0); extern bool8 sub_80048BC(void); -extern u8 sub_80023E4(u32); extern bool8 sub_8099B94(void); extern void sub_8099768(void); extern void sub_809975C(void); @@ -127,7 +126,7 @@ u32 xxx_script_related_8098468(s32 param_1) break; } ResetSoundEffectCounters(); - if (gUnknown_20398B9 == 0 && !sub_80023E4(0xd)) { + if (gUnknown_20398B9 == 0 && !CheckQuest(QUEST_IN_WORLD_CALAMITY)) { FadeOutAllMusic(0x10); } gUnknown_2026E4E = 0x808; @@ -521,7 +520,7 @@ bool8 sub_8098D80(u32 speed) gUnknown_20398AC = 1; gUnknown_20398B0 = speed; sub_809C730(); - if(!sub_80023E4(0xD)) + if(!CheckQuest(QUEST_IN_WORLD_CALAMITY)) { FadeOutAllMusic(speed); } @@ -538,7 +537,7 @@ bool8 sub_8098DCC(u32 speed) gUnknown_20398AC = 1; gUnknown_20398B0 = speed; sub_809C730(); - if(!sub_80023E4(0xD)) + if(!CheckQuest(QUEST_IN_WORLD_CALAMITY)) { FadeOutAllMusic(speed); } @@ -636,40 +635,47 @@ const char *GetCurrentGroundPlaceName(void) return GetGroundPlaceName(GetScriptVarValue(NULL, GROUND_PLACE)); } +// Returns an enum GroundMapID static s16 sub_8098FCC(u32 unused) { - s32 iVar4; - s32 iVar5; - s32 iVar6; - const DungeonInfo *iVar3; + s32 scriptDungeon; + s32 scriptDungeon__; + s32 scriptDungeon_; + const DungeonInfo *di; - iVar5 = (s16)GetScriptVarValue(NULL,DUNGEON_ENTER); - iVar6 = iVar5; - if (iVar5 == -1) return 0xC; + scriptDungeon__ = (s16)GetScriptVarValue(NULL,DUNGEON_ENTER); + scriptDungeon_ = scriptDungeon__; + if (scriptDungeon__ == -1) + return MAP_TEAM_BASE_INSIDE; - if (iVar5 == 0x51) - iVar4 = (s16)GetScriptVarValue(NULL,DUNGEON_ENTER_INDEX); - else - iVar4 = iVar6; + if (scriptDungeon__ == SCRIPT_DUNGEON_81) + scriptDungeon = (s16)GetScriptVarValue(NULL, DUNGEON_ENTER_INDEX); + else + scriptDungeon = scriptDungeon_; - iVar3 = GetDungeonInfo_80A2608(iVar4); - if (gUnknown_20398B4 == 9) { - return iVar3->unk2; - } - switch((s16)(iVar3->unk4 - 0xb2)) { - case 0: - if (ScriptVarScenarioAfter(SCENARIO_MAIN,2,-1) != 0) return 0xc; - break; - case 0xf: - case 0x11: - case 0x14: - case 0x17: - if (!sub_80023E4(5)) return 0xC; - break; - default: - break; - } - return iVar3->unk4; + di = GetDungeonInfo_80A2608(scriptDungeon); + if (gUnknown_20398B4 == 9) + return di->unk2; + + switch (di->unk4) { + case MAP_TINY_WOODS_ENTRY: { + if (ScriptVarScenarioAfter(SCENARIO_MAIN, 2, -1)) + return MAP_TEAM_BASE_INSIDE; + break; + } + case MAP_LAPIS_CAVE_ENTRY: + case MAP_MT_BLAZE_ENTRY: + case MAP_FROSTY_FOREST_ENTRY: + case MAP_MT_FREEZE_ENTRY: { + if (!CheckQuest(QUEST_UNK5)) + return MAP_TEAM_BASE_INSIDE; + break; + } + default: + break; + } + + return di->unk4; } UNUSED static const char *sub_80990B8(void) @@ -686,7 +692,7 @@ UNUSED static const char *sub_80990B8(void) static inline bool8 sub_80990EC_sub(struct DungeonSetupInfo *iVar1, u32 iVar2) { bool8 flag = FALSE; - iVar1->sub0.unkB = 0; + iVar1->sub0.missionKind = DUNGEON_MISSION_UNK0; if ((u16)(iVar2 - 0x25) < 3) flag = TRUE; @@ -737,10 +743,10 @@ u8 sub_80990EC(struct DungeonSetupInfo *param_1, s32 param_2) } break; case 4: - param_1->sub0.unkB = 0; + param_1->sub0.missionKind = DUNGEON_MISSION_UNK0; break; case 2: - param_1->sub0.unkB = 2; + param_1->sub0.missionKind = DUNGEON_MISSION_ACCEPTEDJOB_RELATED; break; } param_1->sub0.unk4 = 0; @@ -785,7 +791,7 @@ void sub_809927C(u8 param_1) SetScriptVarValue(0x0,DUNGEON_ENTER,0x50); SetScriptVarValue(0x0,DUNGEON_ENTER_INDEX,gUnknown_2039950); sub_8095494(&gUnknown_20398C8.dungeonSeed,param_1); - gUnknown_20398C8.sub0.unkB = 1; + gUnknown_20398C8.sub0.missionKind = DUNGEON_MISSION_OUTONRESCUE; gUnknown_20398C8.sub0.unkC = 0; gUnknown_20398C8.sub0.unk4 = 0; gUnknown_20398C8.sub0.unkD = 0; diff --git a/src/ground_map.c b/src/ground_map.c index 0de14f94b..7ef9bb35f 100644 --- a/src/ground_map.c +++ b/src/ground_map.c @@ -372,7 +372,7 @@ s16 GetAdjustedGroundMap(s32 mapId) retMapId = (s16)(retMapId + ((GetScriptVarValue(NULL, BASE_KIND) * TEAM_BASE_MAPS_PER_SPECIES) + GetScriptVarValue(NULL, BASE_LEVEL))); break; case MAP_WHISCASH_POND: - if (sub_80023E4(6)) { + if (CheckQuest(QUEST_REACHED_POSTGAME)) { retMapId = MAP_WHISCASH_POND_OPEN; } break; diff --git a/src/ground_script.c b/src/ground_script.c index c8af437df..e850fbe6f 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -943,7 +943,7 @@ s16 HandleAction(Action *action, const DebugLocation *debug) if (sub_80990EC(&unkStruct, dungeonEnter)) { s32 val; sub_8099220(&unkStruct, dungeonEnter); - val = sub_80023E4(6); + val = CheckQuest(QUEST_REACHED_POSTGAME); res = BufferDungeonRequirementsText(unkStruct.sub0.unk0.id, 0, gUnknown_203B4B0, val, FALSE); gUnknown_2039DA4 = res; switch (res) { @@ -985,7 +985,7 @@ s16 HandleAction(Action *action, const DebugLocation *debug) s32 val; u32 res; ret = GetMailatIndex(GetScriptVarValue(NULL, 20)); - val = sub_80023E4(6); + val = CheckQuest(QUEST_REACHED_POSTGAME); res = BufferDungeonRequirementsText(ret->dungeonSeed.location.id, 0, gUnknown_203B4B0, val, TRUE); gUnknown_2039DA4 = res; switch (res) { @@ -2641,14 +2641,14 @@ static s32 ExecuteScriptCommand(Action *action) } break; } - case 0xba: { + case 0xba: { // JUMPIF_SCENE_GT if (ScriptVarScenarioAfter(curCmd.argShort, curCmd.arg1, curCmd.arg2)) { scriptData->script.ptr = FindLabel(action, (u8)curCmd.argByte); } break; } - case 0xbb: { - if (sub_80023E4(curCmd.argShort)) { + case 0xbb: { // JUMPIF_SCENARIOCHECK + if (CheckQuest(curCmd.argShort)) { scriptData->script.ptr = FindLabel(action, (u8)curCmd.argByte); } break; @@ -3014,7 +3014,7 @@ static s32 sub_80A14E8(Action *action, u8 idx, u32 r2, s32 r3) case 9: { u8 var; - if (sub_80023E4(8) == 0) { + if (CheckQuest(QUEST_CAN_CHANGE_LEADER) == 0) { var = sub_808D4B0(); } else { @@ -3936,9 +3936,9 @@ static u32 sub_80A25AC(u16 param_1) return param_1; if (param_1 == 50) return 50; - if (!sub_80023E4(12)) + if (!CheckQuest(QUEST_UNK12)) return 999; - if (sub_80023E4(13)) + if (CheckQuest(QUEST_IN_WORLD_CALAMITY)) return 19; if (param_1 != 1) return param_1; diff --git a/src/load_screen.c b/src/load_screen.c index 83236c094..d28ff8c37 100644 --- a/src/load_screen.c +++ b/src/load_screen.c @@ -25,10 +25,10 @@ #include "text_3.h" #include "text_util.h" +// Size: 0x27C struct LoadScreen { - // size: 0x27c - u32 currMenu; + /* 0x000 */ u32 currMenu; MenuStruct unk4[4]; WindowTemplates unk144; /* 0x1A4 */ u8 formattedTeamName[0x24]; @@ -45,26 +45,26 @@ extern unkStruct_203B484 *gUnknown_203B484; u8 IsQuickSave(void); void DrawLoadScreenText(void); -void sub_80397B4(void); +static void DrawQuestIcons(void); extern void sub_80920D8(u8 *); const WindowTemplate gUnknown_80E75F8 = { - 0, - 0x03, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - NULL + 0, + 0x03, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + NULL }; const WindowTemplate gUnknown_80E7610 = { - 0, - 0x03, - 0x02, 0x02, - 0x1A, 0x0B, - 0x0B, 0x00, - NULL + 0, + 0x03, + 0x02, 0x02, + 0x1A, 0x0B, + 0x0B, 0x00, + NULL }; EWRAM_INIT MenuItem gUnknown_203B378[2] = { @@ -78,16 +78,30 @@ EWRAM_INIT MenuItem gUnknown_203B378[2] = { } }; -EWRAM_INIT u32 gUnknown_203B388[12] = {0xC, 0xC, 0xE, 0xE, 0xD, 0xE, 0xC, 0xD, 0xD, 0xB, 0xB, 0xB}; -EWRAM_INIT u32 gUnknown_203B3B8[12] = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x1A, 0x18, 0x1B, 0x16, 0x19, 0x17}; +EWRAM_INIT u32 gUnknown_203B388[12] = { 0xC, 0xC, 0xE, 0xE, 0xD, 0xE, 0xC, 0xD, 0xD, 0xB, 0xB, 0xB }; + +static EWRAM_INIT u32 sLegendaryQuestIDs[12] = { + QUEST_LEGEND_ZAPDOS, + QUEST_LEGEND_MOLTRES, + QUEST_LEGEND_ARTICUNO, + QUEST_LEGEND_GROUDON, + QUEST_LEGEND_RAYQUAZA, + QUEST_LEGEND_KYOGRE, + QUEST_LEGEND_MEW, + QUEST_LEGEND_HO_OH, + QUEST_LEGEND_CELEBI, + QUEST_LEGEND_LUGIA, + QUEST_LEGEND_MEWTWO, + QUEST_LEGEND_DEOXYS, +}; const WindowTemplate gUnknown_80E762C = { - 0, - 0x03, - 0x02, 0x0F, - 0x13, 0x03, - 0x03, 0x00, - NULL + 0, + 0x03, + 0x02, 0x0F, + 0x13, 0x03, + 0x03, 0x00, + NULL }; const MenuItem gResumeQuicksaveMenuItems[3] = @@ -279,7 +293,7 @@ void DrawLoadScreenText(void) PrintStringOnWindow(8,60,gHelperHeadingText,0,0); // Helper: // Draw Team Name - if (sub_80023E4(0)) { + if (CheckQuest(QUEST_SET_TEAM_NAME)) { sub_80920D8(teamNameBuffer); } else { @@ -362,7 +376,7 @@ void DrawLoadScreenText(void) } PrintStringOnWindow(64,60,gLoadScreen->formattedHelperInfo,0,0); - sub_80397B4(); // Draw event icons?? + DrawQuestIcons(); sub_80073E0(0); } @@ -373,32 +387,31 @@ struct ClmkFileData /* 0x4 */ RGB *palette; }; -void sub_80397B4(void) +static void DrawQuestIcons(void) { - OpenedFile *clmkFile; - s32 index; - s32 x; - s32 y; + OpenedFile *clmkFile; + s32 i; + s32 x; + s32 y; - clmkFile = OpenFileAndGetFileDataPtr(gClmkpatFileName,&gTitleMenuFileArchive); // clmkpat + clmkFile = OpenFileAndGetFileDataPtr(gClmkpatFileName, &gTitleMenuFileArchive); // clmkpat - for(index = 0; index < 64; index++) - { - SetBGPaletteBufferColorArray(index + 176, &((struct ClmkFileData *)(clmkFile->data))->palette[index]); - } - - x = 8; - y = 0x49; - - // Draw the 12 legendary icons - for(index = 0; index < 12; index++) - { - if (sub_80023E4(gUnknown_203B3B8[index])) { - sub_8007E20(0,x,y,0x10,0x10,(&((struct ClmkFileData *)(clmkFile->data))->pics[index * 32]), gUnknown_203B388[index]); - x += 16; + for (i = 0; i < 64; i++) { + SetBGPaletteBufferColorArray(i + 176, &((struct ClmkFileData *)(clmkFile->data))->palette[i]); } - } - CloseFile(clmkFile); + + x = 8; + y = 73; + + // Draw the 12 legendary icons + for (i = 0; i < ARRAY_COUNT_INT(sLegendaryQuestIDs); i++) { + if (CheckQuest(sLegendaryQuestIDs[i])) { + sub_8007E20(0, x, y, 16, 16, (&((struct ClmkFileData *)(clmkFile->data))->pics[i * 32]), gUnknown_203B388[i]); + x += 16; + } + } + + CloseFile(clmkFile); } bool8 IsQuickSave(void) diff --git a/src/main_loops.c b/src/main_loops.c index 86793c6df..6a43a7f21 100644 --- a/src/main_loops.c +++ b/src/main_loops.c @@ -593,7 +593,7 @@ static u32 RunGameMode_Async(u32 a0) friendAreasSetup.friendAreasMapPtr = MemoryAlloc(sizeof(*friendAreasSetup.friendAreasMapPtr),8); friendAreasSetup.startingFriendAreaId = friendAreaId; - friendAreasSetup.unk5 = sub_80023E4(9); + friendAreasSetup.unk5 = CheckQuest(QUEST_CAN_DEPOSIT_PARTNER); ShowFriendAreasMap_Async(&friendAreasSetup); MemoryFree(friendAreasSetup.friendAreasMapPtr); if (friendAreasSetup.chosenAreaId != NUM_FRIEND_AREAS) { @@ -627,7 +627,7 @@ static u32 RunGameMode_Async(u32 a0) worldMapSetup.info.startLocation.id = DUNGEON_OUT_ON_RESCUE; sub_80011CC(&worldMapSetup.info.unk4, dungeonId); - worldMapSetup.info.unk6C = worldMapSetup.info.unk4.unk5; + worldMapSetup.info.canChangeLeader = worldMapSetup.info.unk4.canChangeLeader; switch ((s16) sub_80A2750(scriptDungeonId)) { case 1: if (sub_80990EC(&dungeonSetup.info, scriptDungeonId)) { @@ -722,7 +722,7 @@ static u32 RunGameMode_Async(u32 a0) if (var == 0xF1207) { dungeonSetup.info.sub0.unkD = 1; dungeonSetup.info.sub0.unk4 = 1; - dungeonSetup.info.sub0.unkB = 0; + dungeonSetup.info.sub0.missionKind = DUNGEON_MISSION_UNK0; if (gUnknown_203B484->unk4.speciesNum != 0) { dungeonSetup.info.sub0.unkC = 1; dungeonSetup.info.mon = gUnknown_203B484->unk4; @@ -1036,7 +1036,7 @@ static void sub_80011CC(DungeonSetupSubstruct *info, u8 dungId) sub_80011E8(info); - info->unkB = 0; + info->missionKind = DUNGEON_MISSION_UNK0; info->unk4 = 0; info->unkC = 0; info->unkD = 0; @@ -1045,16 +1045,16 @@ static void sub_80011CC(DungeonSetupSubstruct *info, u8 dungId) // arm9.bin::0200CD1C static void sub_80011E8(DungeonSetupSubstruct *info) { - info->unk5 = sub_80023E4(8); - info->unk6 = sub_80023E4(3); - info->unk8 = sub_80023E4(7); - info->unk9 = sub_80023E4(0); - info->unkA = sub_80023E4(5); + info->canChangeLeader = CheckQuest(QUEST_CAN_CHANGE_LEADER); + info->canRecruit = CheckQuest(QUEST_CAN_RECRUIT); + info->unlockedEvolutions = CheckQuest(QUEST_UNLOCKED_EVOLUTIONS); + info->hasInventory = CheckQuest(QUEST_SET_TEAM_NAME); + info->unkA = CheckQuest(QUEST_UNK5); - if (sub_80023E4(24) && sub_80023E4(25) && sub_80023E4(26)) - info->unk7 = 1; + if (CheckQuest(QUEST_LEGEND_HO_OH) && CheckQuest(QUEST_LEGEND_MEWTWO) && CheckQuest(QUEST_LEGEND_MEW)) + info->canRecruitRescueTeamMazeBosses = TRUE; else - info->unk7 = 0; + info->canRecruitRescueTeamMazeBosses = FALSE; } // arm9.bin::0200CC4C diff --git a/src/party_list_menu.c b/src/party_list_menu.c index 7a49148b1..0dc2a081b 100644 --- a/src/party_list_menu.c +++ b/src/party_list_menu.c @@ -393,7 +393,7 @@ static void PartyListMenu_CreateMenu1(void) } loopMax += 1; - if(sub_80023E4(8) && !pokeStruct->isTeamLeader) + if(CheckQuest(QUEST_CAN_CHANGE_LEADER) && !pokeStruct->isTeamLeader) { sUnknown_203B2B8->unk16C[loopMax].text = sPartyMenuMakeLeader; sUnknown_203B2B8->unk16C[loopMax].menuAction = PARTY_LIST_MENU_MAKE_LEADER; @@ -860,7 +860,7 @@ static bool8 sub_8026E88(Pokemon *r0) { flag = (r0->dungeonLocation.id == DUNGEON_JOIN_LOCATION_PARTNER); if(flag) - if(!sub_80023E4(0x8)) + if(!CheckQuest(QUEST_CAN_CHANGE_LEADER)) return FALSE; } else @@ -878,7 +878,7 @@ static bool8 sub_8026EB8(Pokemon *r0) flag = (r0->dungeonLocation.id == DUNGEON_JOIN_LOCATION_PARTNER); if(flag) { - if(sub_80023E4(0x8)) + if(CheckQuest(QUEST_CAN_CHANGE_LEADER)) goto check; } else diff --git a/src/pokemon_mail.c b/src/pokemon_mail.c index b720bb476..6576353c4 100644 --- a/src/pokemon_mail.c +++ b/src/pokemon_mail.c @@ -416,7 +416,7 @@ bool8 sub_803C110(s16 index) if (!sub_8098134(index) || index != GetBaseSpecies(index) || !sub_803C0DC(index)) return FALSE; - if (!sub_80023E4(6)) { + if (!CheckQuest(QUEST_REACHED_POSTGAME)) { psVar5 = &gUnknown_80E8126[0]; // TODO: Un-ugly this if (*psVar5 != MONSTER_NONE) { psVar6 = &gUnknown_80E8126[0]; diff --git a/src/pokemon_summary_window.c b/src/pokemon_summary_window.c index ddca7da7e..7ee1592c2 100644 --- a/src/pokemon_summary_window.c +++ b/src/pokemon_summary_window.c @@ -234,7 +234,7 @@ void ShowPokemonSummaryWindow(s32 which, s32 currSubWindowId, struct MonSummaryI sub_80073E0(windowId); } -void SetMonSummaryInfo(struct MonSummaryInfo *dst, struct Pokemon *pokemon, bool8 param_3) +void SetMonSummaryInfo(struct MonSummaryInfo *dst, struct Pokemon *pokemon, bool8 unlockedEvolutions) { s32 index; @@ -284,15 +284,13 @@ void SetMonSummaryInfo(struct MonSummaryInfo *dst, struct Pokemon *pokemon, bool dst->unk44[0] = pokemon->unkC[0]; dst->unk44[1] = pokemon->unkC[1]; dst->IQSkills = pokemon->IQSkills; - if (param_3) { - dst->evoStringId = GetMonSummaryScreenEvoStringId(pokemon); - } - else { - dst->evoStringId = EVO_STRING_EMPTY; - } - for(index = 0; index < 0xC; index++) - { + if (unlockedEvolutions) + dst->evoStringId = GetMonSummaryScreenEvoStringId(pokemon); + else + dst->evoStringId = EVO_STRING_EMPTY; + + for (index = 0; index < MON_SUMMARY_UNK58_COUNT; index++) { dst->unk58[index] = 0; } } diff --git a/src/post_office_guide2.c b/src/post_office_guide2.c index 99ad55e6b..f7e5fcca7 100644 --- a/src/post_office_guide2.c +++ b/src/post_office_guide2.c @@ -30,10 +30,10 @@ static void DisplayMissionObjectives(void); static void sub_8031A2C(void); static void sub_8031A84(void); -bool8 sub_80319A4(u8 param_1, u8 dungeon, s32 param_3) +bool8 sub_80319A4(u8 dungeonMissionKind, u8 dungeon, s32 param_3) { sUnknown_203B330 = MemoryAlloc(sizeof(unkStruct_203B330), 8); - sUnknown_203B330->unkC = param_1; + sUnknown_203B330->dungeonMissionKind = dungeonMissionKind; sUnknown_203B330->dungeonIndex = dungeon; ResetTouchScreenMenuInput(&sUnknown_203B330->input); sUnknown_203B330->unk10 = param_3; @@ -80,7 +80,7 @@ static void sub_8031A84(void) RestoreSavedWindows(&sUnknown_203B330->unk18); sUnknown_203B330->unk18.id[sUnknown_203B330->unk10] = sUnknown_80E1F18; - if (sUnknown_203B330->unkC == 2) { + if (sUnknown_203B330->dungeonMissionKind == DUNGEON_MISSION_ACCEPTEDJOB_RELATED) { jobs = CountJobsinDungeon(sUnknown_203B330->dungeonIndex); if (jobs == 0) jobs = 1; @@ -94,23 +94,16 @@ static void sub_8031A84(void) static void DisplayMissionObjectives(void) { - s32 yCoord; - s32 jobSlotIdx; - unkStruct_203B480 *mail; - WonderMail *jobInfo; - u8 buffer[100]; - volatile u8 local_94; - u8 buffer1[100]; - s16 auStack44; - s16 missionIndex; - u8 local_test; - sub_80073B8(sUnknown_203B330->unk10); // Objectives PrintStringOnWindow(10, 0, sObjectives, sUnknown_203B330->unk10, 0); - switch (sUnknown_203B330->unkC) { - case 1: + switch (sUnknown_203B330->dungeonMissionKind) { + case DUNGEON_MISSION_OUTONRESCUE: { + unkStruct_203B480 *mail; + u8 buffer[100]; + volatile u8 local_94; + sub_8099394((u8*)&local_94); mail = GetMailatIndex(local_94); sub_803B6B0(10, 16, 3, sUnknown_203B330->unk10); @@ -121,15 +114,18 @@ static void DisplayMissionObjectives(void) sprintfStatic(buffer,sFmtRescue,GetMonSpecies(mail->clientSpecies)); PrintStringOnWindow(40, 16, buffer, sUnknown_203B330->unk10, 0); break; - case 2: + } + case DUNGEON_MISSION_ACCEPTEDJOB_RELATED: { if (CountJobsinDungeon(sUnknown_203B330->dungeonIndex) == 0) PrintStringOnWindow(10, 16, sJustGo, sUnknown_203B330->unk10, 0); else { - yCoord = 16; + s32 yCoord = 16; + s32 jobSlotIdx; + u8 buffer1[100]; // 8 Job Slots... check each of them for (jobSlotIdx = 0; jobSlotIdx < MAX_ACCEPTED_JOBS; jobSlotIdx++) { - jobInfo = GetJobSlotInfo(jobSlotIdx); + WonderMail *jobInfo = GetJobSlotInfo(jobSlotIdx); if (jobInfo->dungeonSeed.location.id == sUnknown_203B330->dungeonIndex && jobInfo->mailType != 0 @@ -168,9 +164,14 @@ static void DisplayMissionObjectives(void) } } break; - case 3: - case 0: - default: + } + case DUNGEON_MISSION_UNK3: + case DUNGEON_MISSION_UNK0: + default: { + s16 auStack44; + s16 missionIndex; + u8 local_test; + if (sub_80992E0(&auStack44, &missionIndex)) PrintStringOnWindow(10, 16, GetCurrentMissionText(missionIndex), sUnknown_203B330->unk10, 0); else if (sub_8099360(&local_test) != 0) @@ -178,6 +179,7 @@ static void DisplayMissionObjectives(void) else PrintStringOnWindow(10, 16, sRedQuestionMarks, sUnknown_203B330->unk10, 0); break; + } } sub_80073E0(sUnknown_203B330->unk10); diff --git a/src/rescue_scenario.c b/src/rescue_scenario.c index 1746637d1..6ff9d5d12 100644 --- a/src/rescue_scenario.c +++ b/src/rescue_scenario.c @@ -6,7 +6,6 @@ #include "exclusive_pokemon.h" #include "code_80958E8.h" #include "code_80A26CC.h" -#include "constants/rescue_dungeon_id.h" // size: 0x8 typedef struct MissionText @@ -134,16 +133,14 @@ void sub_80973A8(s32 param_1, u32 param_2) } } -bool8 RescueScenarioConquered(s32 param_1) +bool8 RescueScenarioConquered(s32 rescueDungeonID_) { - s32 param1 = (s16) param_1; + s32 rescueDungeonID = (s16) rescueDungeonID_; - if (param1 == RESCUE_DUNGEON_DUMMY) { + if (rescueDungeonID == RESCUE_DUNGEON_DUMMY) return FALSE; - } - else { - return (GetScriptVarArrayValue(NULL, RESCUE_SCENARIO_CONQUEST_LIST, (u16) param1) != FALSE); - } + + return (GetScriptVarArrayValue(NULL, RESCUE_SCENARIO_CONQUEST_LIST, (u16)rescueDungeonID) != FALSE); } void sub_8097418(s32 index, bool32 param_2) diff --git a/src/rescue_team_info.c b/src/rescue_team_info.c index 25ebc8d81..3f511fa9d 100644 --- a/src/rescue_team_info.c +++ b/src/rescue_team_info.c @@ -127,7 +127,7 @@ u32 SaveRescueTeamInfo(u8 *param_1, u32 size) InitBitWriter(&auStack36, param_1, size); WriteBits(&auStack36, gRescueTeamInfoRef->teamName, 0x58); WriteBits(&auStack36, (u8 *)&gRescueTeamInfoRef->teamRankPts, 0x20); - gRescueTeamInfoRef->isTeamRenamed = sub_80023E4(0); + gRescueTeamInfoRef->isTeamRenamed = CheckQuest(QUEST_SET_TEAM_NAME); if (gRescueTeamInfoRef->isTeamRenamed) { diff --git a/src/run_dungeon.c b/src/run_dungeon.c index b95c39e0b..1ab27a76a 100644 --- a/src/run_dungeon.c +++ b/src/run_dungeon.c @@ -132,7 +132,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr) gPlayerDotMapPosition.x = 100; if (!r6) { - gDungeon->unk644.unk34 = setupPtr->info.sub0.unkB; + gDungeon->unk644.missionKind = setupPtr->info.sub0.missionKind; gDungeon->unk644.dungeonSeed = setupPtr->info.dungeonSeed; gDungeon->unk644.windTurns = GetTurnLimit(setupPtr->info.sub0.unk0.id); gDungeon->unk644.windPhase = 0; @@ -140,11 +140,11 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr) } gDungeon->unk644.unk54 = 0; gDungeon->unk644.unk55 = 0; - gDungeon->unk644.unk18 = setupPtr->info.sub0.unk5; - gDungeon->unk644.unk16 = setupPtr->info.sub0.unk8; - gDungeon->unk644.canRecruit = setupPtr->info.sub0.unk6; - gDungeon->unk644.unk15 = setupPtr->info.sub0.unk7; - gDungeon->unk644.hasInventory = setupPtr->info.sub0.unk9; + gDungeon->unk644.canChangeLeader = setupPtr->info.sub0.canChangeLeader; + gDungeon->unk644.unlockedEvolutions = setupPtr->info.sub0.unlockedEvolutions; + gDungeon->unk644.canRecruit = setupPtr->info.sub0.canRecruit; + gDungeon->unk644.canRecruitRescueTeamMazeBosses = setupPtr->info.sub0.canRecruitRescueTeamMazeBosses; + gDungeon->unk644.hasInventory = setupPtr->info.sub0.hasInventory; gDungeon->unk644.unk19 = setupPtr->info.sub0.unkA; StopDungeonBGM(); sub_803D4AC(); @@ -174,7 +174,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr) if (!r6) { gDungeon->unk181e8.allTilesRevealed = 1; gDungeon->unk181e8.unk1820C = 1; - if (gDungeon->unk644.unk34 == 1) { + if (gDungeon->unk644.missionKind == DUNGEON_MISSION_OUTONRESCUE) { gDungeon->unk644.dungeonLocation.id = setupPtr->info.dungeonSeed.location.id; gDungeon->unk644.dungeonLocation.floor = 1; } @@ -186,7 +186,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr) EnforceMaxItemsAndMoney(); } if (!r6) { - if (gDungeon->unk644.unk34 == 1) { + if (gDungeon->unk644.missionKind == DUNGEON_MISSION_OUTONRESCUE) { gDungeon->unk644.unk38 = setupPtr->info.dungeonSeed.seed; } else { @@ -223,7 +223,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr) } OpenDungeonPaletteFile(); - if (!r6 && gDungeon->unk644.unk34 == 1) { + if (!r6 && gDungeon->unk644.missionKind == DUNGEON_MISSION_OUTONRESCUE) { if (sub_8099394(&sp)) { unkStruct_203B480 *mailStr = GetMailatIndex(sp); if (mailStr->rescuesAllowed) { @@ -565,7 +565,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr) SetUpDungeonExitData(var, NULL, GetLeader()); check = TRUE; } - else if (gDungeon->unk644.unk34 == 1 && GetFloorType() == FLOOR_TYPE_RESCUE && gDungeon->unk644.unk10 == 2) { + else if (gDungeon->unk644.missionKind == DUNGEON_MISSION_OUTONRESCUE && GetFloorType() == FLOOR_TYPE_RESCUE && gDungeon->unk644.unk10 == 2) { SetUpDungeonExitData(DUNGEON_EXIT_SUCCEEDED_IN_RESCUE_MISSION, NULL, GetLeader()); if (gDungeon->unk644.stoleFromKecleon != 0) { IncrementThievingSuccesses(); @@ -612,7 +612,7 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr) sub_80095CC(1, 0x14); sub_803E13C(); sub_800CDA8(4); - if (gDungeon->unk6 == 0 && sub_8083C88(gDungeon->unk644.unk34)) { + if (gDungeon->unk6 == 0 && sub_8083C88(gDungeon->unk644.missionKind)) { ShowDungeonClearedWindow(); } @@ -630,10 +630,10 @@ void RunDungeon_Async(DungeonSetupStruct *setupPtr) } } else if (sub_8083C50()) { - if (gDungeon->unk644.unk34 == 1) { + if (gDungeon->unk644.missionKind == DUNGEON_MISSION_OUTONRESCUE) { setupPtr->info.unk7C = 4; } - else if (gDungeon->unk644.unk34 == 0) { + else if (gDungeon->unk644.missionKind == DUNGEON_MISSION_UNK0) { setupPtr->info.unk7C = 1; sub_8084424(); } @@ -689,7 +689,7 @@ bool8 sub_8043CE4(s32 dungeonId) u8 GetFloorType(void) { - if (gDungeon->unk644.unk34 == 1 && gDungeon->unk644.dungeonSeed.location.floor == gDungeon->unk644.dungeonLocation.floor) + if (gDungeon->unk644.missionKind == DUNGEON_MISSION_OUTONRESCUE && gDungeon->unk644.dungeonSeed.location.floor == gDungeon->unk644.dungeonLocation.floor) return FLOOR_TYPE_RESCUE; else if (IsFloorwideFixedRoom()) return FLOOR_TYPE_FIXED; diff --git a/src/string_format.c b/src/string_format.c index dec496ada..328cdfb41 100644 --- a/src/string_format.c +++ b/src/string_format.c @@ -713,7 +713,7 @@ const u8 *FormatString(const u8 *str, u8 *dst, u8 *dstMax, u16 flags) break; case 't': str++; - if (sub_80023E4(0)) { + if (CheckQuest(QUEST_SET_TEAM_NAME)) { sub_80920D8(sFormatBuffer_TeamName); } else { diff --git a/src/textbox.c b/src/textbox.c index 433da7dfd..656dba3a4 100644 --- a/src/textbox.c +++ b/src/textbox.c @@ -1556,7 +1556,7 @@ static bool8 sub_809B648(void) FinishWriteSavePak(); return 0; case 0x10: { - bool8 unkBool = (sub_80023E4(4) != 0); + bool8 unkBool = (CheckQuest(QUEST_SQUARE_ASLEEP) != FALSE); ResetTextbox(); if (CreateKangaskhanStorage(unkBool)) { sTextbox->unk418 = &gUnknown_81161C8; @@ -1569,7 +1569,7 @@ static bool8 sub_809B648(void) sTextbox->unk418 = &gUnknown_81161D8; return 1; case 0x13: { - bool8 unkBool = (sub_80023E4(4) != 0); + bool8 unkBool = (CheckQuest(QUEST_SQUARE_ASLEEP) != FALSE); ResetTextbox(); if (CreateFelicityBank(unkBool)) { sTextbox->unk418 = &gUnknown_81161E8; @@ -1583,7 +1583,7 @@ static bool8 sub_809B648(void) case 0x17: case 0x18: { u8 var; - bool8 unkBool = sub_80023E4(4); + bool8 unkBool = CheckQuest(QUEST_SQUARE_ASLEEP); ResetTextbox(); if (sTextbox->unk414 == 0x17) { var = (unkBool == 0) ? 0 : 1; @@ -1605,7 +1605,7 @@ static bool8 sub_809B648(void) } } case 0x19: { - bool8 unkBool = (sub_80023E4(4) != 0); + bool8 unkBool = (CheckQuest(QUEST_SQUARE_ASLEEP) != FALSE); ResetTextbox(); if (sub_801FB50(unkBool)) { sTextbox->unk418 = &gUnknown_8116208; @@ -1646,7 +1646,7 @@ static bool8 sub_809B648(void) } return 0; case 0x1b: { - bool8 unk = (sub_80023E4(4) != 0); + bool8 unk = (CheckQuest(QUEST_SQUARE_ASLEEP) != FALSE); ResetTextbox(); if (CreateWigglytuffShop(unk)) { sTextbox->unk418 = &gUnknown_8116218; @@ -1739,7 +1739,7 @@ static bool8 sub_809B648(void) } case 0x24: if (sTextbox->unk420 == 1) { - u32 uVar19 = sub_80023E4(4) == 0 ? 0 : 4; + u32 uVar19 = CheckQuest(QUEST_SQUARE_ASLEEP) == FALSE ? 0 : 4; ResetTextbox(); if (MakuhitaDojo_New(uVar19)) { return 1; @@ -1770,7 +1770,7 @@ static bool8 sub_809B648(void) return 0; case 0x25: { s32 var = 1; - if (sub_80023E4(4)) { + if (CheckQuest(QUEST_SQUARE_ASLEEP)) { var = 5; } ResetTextbox(); @@ -1785,7 +1785,7 @@ static bool8 sub_809B648(void) } case 0x26: { s32 var = 2; - if (sub_80023E4(4)) { + if (CheckQuest(QUEST_SQUARE_ASLEEP)) { var = 6; } ResetTextbox(); @@ -1800,7 +1800,7 @@ static bool8 sub_809B648(void) } case 0x27: { s32 var = 3; - if (sub_80023E4(4)) { + if (CheckQuest(QUEST_SQUARE_ASLEEP)) { var = 7; } ResetTextbox(); diff --git a/src/training_maze.c b/src/training_maze.c index 894265c99..e397028dd 100644 --- a/src/training_maze.c +++ b/src/training_maze.c @@ -23,7 +23,7 @@ UNUSED static void nullsub_208(void) bool8 sub_8097504(s16 mazeIndex) { - s32 uVar3; + s32 questID; s32 mazeIndex_ = Self_s16(mazeIndex); // Needed to match if (mazeIndex < 17) { switch (mazeIndex) { @@ -31,7 +31,7 @@ bool8 sub_8097504(s16 mazeIndex) case 10: case 11: case 12: - uVar3 = 14; + questID = QUEST_MAZE_14; break; case 0: case 1: @@ -39,7 +39,7 @@ bool8 sub_8097504(s16 mazeIndex) case 7: case 9: case 14: - uVar3 = 15; + questID = QUEST_MAZE_15; break; case 3: case 4: @@ -47,7 +47,7 @@ bool8 sub_8097504(s16 mazeIndex) case 8: return TRUE; case 13: - uVar3 = 6; + questID = QUEST_REACHED_POSTGAME; break; default: return TRUE; @@ -57,15 +57,13 @@ bool8 sub_8097504(s16 mazeIndex) if (mazeIndex_ > 22) return FALSE; if (mazeIndex_ == 22) return FALSE; if (mazeIndex_ == 21) return FALSE; - uVar3 = 6; + questID = QUEST_REACHED_POSTGAME; } - if (!sub_80023E4(uVar3)) { + if (!CheckQuest(questID)) return FALSE; - } - else { - return TRUE; - } + + return TRUE; } bool8 IsMazeCompleted(s16 mazeIndex) diff --git a/src/wigglytuff_shop1.c b/src/wigglytuff_shop1.c index 548a49e7e..d324fa48e 100644 --- a/src/wigglytuff_shop1.c +++ b/src/wigglytuff_shop1.c @@ -198,7 +198,7 @@ static s32 sub_8021664(void) counter++; break; case UNLOCK_SHOP_POST_GAME: - if (sub_80023E4(6)) { + if (CheckQuest(QUEST_REACHED_POSTGAME)) { sWigglytuffShop1Work->friendAreas[counter] = i; counter++; } @@ -233,7 +233,7 @@ bool8 sub_8021700(u32 kind) case UNLOCK_SHOP_STORY: return FALSE; case UNLOCK_SHOP_POST_GAME: - if (sub_80023E4(6)) + if (CheckQuest(QUEST_REACHED_POSTGAME)) return FALSE; break; } diff --git a/src/wigglytuff_shop3.c b/src/wigglytuff_shop3.c index 37ef5acde..0d9863480 100644 --- a/src/wigglytuff_shop3.c +++ b/src/wigglytuff_shop3.c @@ -279,7 +279,7 @@ static void UpdateWigglytuffDialogue(void) else { switch (GetFriendAreaUnlockCondition(sWigglytuffShop3Work->chosenFriendArea)) { case UNLOCK_SHOP_POST_GAME: - if (sub_80023E4(6) != 0) + if (CheckQuest(QUEST_REACHED_POSTGAME)) sWigglytuffShop3Work->fallbackState = WIGGLYTUFF_CHECK_AGAIN; else sWigglytuffShop3Work->fallbackState = WIGGLYTUFF_CHECK_POST_GAME; diff --git a/src/wonder_mail_2.c b/src/wonder_mail_2.c index e9c7e81e8..f492a5900 100644 --- a/src/wonder_mail_2.c +++ b/src/wonder_mail_2.c @@ -145,7 +145,7 @@ void sub_802B3E0(void) switch(sUnknown_203B2C8->currState) { case INIT_STATE: - if (sub_80023E4(0)) { + if (CheckQuest(QUEST_SET_TEAM_NAME)) { // Copy Team Name to buffer sub_80920D8(teamNameBuffer); } diff --git a/src/world_map.c b/src/world_map.c index f1af558cd..ba6372b32 100644 --- a/src/world_map.c +++ b/src/world_map.c @@ -98,7 +98,7 @@ void ShowWorldMap_Async(struct WorldMapSetupStruct *setupPtr) speciesId = 0; } - dungeonEnter = BufferDungeonRequirementsText(setupPtr->info.unk4.unk0.id, speciesId, text, setupPtr->info.unk6C, FALSE); + dungeonEnter = BufferDungeonRequirementsText(setupPtr->info.unk4.unk0.id, speciesId, text, setupPtr->info.canChangeLeader, FALSE); if (dungeonEnter == DUNGEON_REQUIREMENTS_PASS) { setupPtr->dungeonEntered = TRUE; } diff --git a/src/world_map_sound.c b/src/world_map_sound.c index 932784d84..e145660a9 100644 --- a/src/world_map_sound.c +++ b/src/world_map_sound.c @@ -9,15 +9,15 @@ void PlayFriendAreasMapBGM(void) { - if (sub_80023E4(13)) + if (CheckQuest(QUEST_IN_WORLD_CALAMITY)) StartNewBGM(MUS_WORLD_CALAMITY); - else if (sub_80023E4(12)) + else if (CheckQuest(QUEST_UNK12)) StartNewBGM(MUS_POKEMON_SQUARE); } void PlayWorldMapBGM(void) { - if (sub_80023E4(13)) + if (CheckQuest(QUEST_IN_WORLD_CALAMITY)) StartNewBGM(MUS_WORLD_CALAMITY); else StartNewBGM(MUS_POKEMON_SQUARE); @@ -25,7 +25,7 @@ void PlayWorldMapBGM(void) void FadeOutFriendAreasMapBGM(void) { - if (!sub_80023E4(13)) + if (!CheckQuest(QUEST_IN_WORLD_CALAMITY)) FadeOutBGM(30); }