From 97bbb326b8c94e0fc90bceb4e5dea1b80f86822f Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Sat, 20 Oct 2018 19:53:41 -0500 Subject: GameClear nonsense --- src/load_save.c | 2 +- src/post_battle_event_funcs.c | 88 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/post_battle_event_funcs.c (limited to 'src') diff --git a/src/load_save.c b/src/load_save.c index 005af7c42..45b4d200b 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -144,7 +144,7 @@ void ClearSecretBase2Field_9(void) gSaveBlock2Ptr->specialSaveWarp &= ~1; } -void sub_8076D48(void) +void SetSecretBase2Field_9(void) { gSaveBlock2Ptr->specialSaveWarp |= 1; } diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c new file mode 100644 index 000000000..8df702570 --- /dev/null +++ b/src/post_battle_event_funcs.c @@ -0,0 +1,88 @@ +#include "global.h" +#include "main.h" +#include "credits.h" +#include "event_data.h" +#include "hall_of_fame.h" +#include "load_save.h" +#include "overworld.h" +#include "script_pokemon_util_80F87D8.h" +#include "tv.h" +#include "constants/heal_locations.h" +#include "constants/flags.h" + +int GameClear(void) +{ + int i; + bool32 ribbonGet; + struct RibbonCounter { + u8 partyIndex; + u8 count; + } ribbonCounts[6]; + s8 val; + + HealPlayerParty(); + + if (FlagGet(FLAG_SYS_GAME_CLEAR) == TRUE) + { + gHasHallOfFameRecords = TRUE; + } + else + { + gHasHallOfFameRecords = FALSE; + FlagSet(FLAG_SYS_GAME_CLEAR); + } + + if (GetGameStat(GAME_STAT_FIRST_HOF_PLAY_TIME) == 0) + SetGameStat(GAME_STAT_FIRST_HOF_PLAY_TIME, (gSaveBlock2Ptr->playTimeHours << 16) | (gSaveBlock2Ptr->playTimeMinutes << 8) | gSaveBlock2Ptr->playTimeSeconds); + + SetSecretBase2Field_9(); + + if (gSaveBlock2Ptr->playerGender == MALE) + sub_8084F6C(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F); + else + sub_8084F6C(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F); + + ribbonGet = FALSE; + + for (i = 0; i < 6; i++) + { + struct Pokemon *mon = &gPlayerParty[i]; + + ribbonCounts[i].partyIndex = i; + ribbonCounts[i].count = 0; + + if (GetMonData(mon, MON_DATA_SANITY_BIT2) + && !GetMonData(mon, MON_DATA_SANITY_BIT3) + && !GetMonData(mon, MON_DATA_CHAMPION_RIBBON)) + { + val = TRUE; + SetMonData(mon, MON_DATA_CHAMPION_RIBBON, &val); + ribbonCounts[i].count = GetRibbonCount(mon); + ribbonGet = TRUE; + } + } + + if (ribbonGet == TRUE) + { + IncrementGameStat(GAME_STAT_RECEIVED_RIBBONS); + FlagSet(FLAG_SYS_RIBBON_GET); + + for (i = 1; i < 6; i++) + { + if (ribbonCounts[0].count > ribbonCounts[i].count) + { + struct RibbonCounter prevBest = ribbonCounts[0]; + ribbonCounts[0] = ribbonCounts[i]; + ribbonCounts[i] = prevBest; + } + } + + if (ribbonCounts[0].count > 4) + { + sub_80EE4DC(&gPlayerParty[ribbonCounts[0].partyIndex], MON_DATA_CHAMPION_RIBBON); + } + } + + SetMainCallback2(CB2_DoHallOfFameScreen); + return 0; +} -- cgit v1.2.3 From 32d2640dc728055923b0e6120277093fcae5e9c3 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Sun, 21 Oct 2018 16:24:43 -0500 Subject: Match GameClear (thanks Egg) --- src/post_battle_event_funcs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c index 8df702570..f15396102 100644 --- a/src/post_battle_event_funcs.c +++ b/src/post_battle_event_funcs.c @@ -55,8 +55,8 @@ int GameClear(void) && !GetMonData(mon, MON_DATA_SANITY_BIT3) && !GetMonData(mon, MON_DATA_CHAMPION_RIBBON)) { - val = TRUE; - SetMonData(mon, MON_DATA_CHAMPION_RIBBON, &val); + u8 val[1] = {TRUE}; + SetMonData(mon, MON_DATA_CHAMPION_RIBBON, val); ribbonCounts[i].count = GetRibbonCount(mon); ribbonGet = TRUE; } @@ -69,7 +69,7 @@ int GameClear(void) for (i = 1; i < 6; i++) { - if (ribbonCounts[0].count > ribbonCounts[i].count) + if (ribbonCounts[i].count > ribbonCounts[0].count) { struct RibbonCounter prevBest = ribbonCounts[0]; ribbonCounts[0] = ribbonCounts[i]; @@ -86,3 +86,9 @@ int GameClear(void) SetMainCallback2(CB2_DoHallOfFameScreen); return 0; } + +bool8 sp0C8_whiteout_maybe(void) +{ + SetMainCallback2(CB2_WhiteOut); + return FALSE; +} -- cgit v1.2.3