2018-10-21 02:53:41 +02:00
|
|
|
#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"
|
2019-11-11 03:54:00 +01:00
|
|
|
#include "constants/tv.h"
|
2018-10-21 02:53:41 +02:00
|
|
|
|
|
|
|
int GameClear(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
bool32 ribbonGet;
|
|
|
|
struct RibbonCounter {
|
|
|
|
u8 partyIndex;
|
|
|
|
u8 count;
|
|
|
|
} ribbonCounts[6];
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2018-12-27 23:30:47 +01:00
|
|
|
SetContinueGameWarpStatus();
|
2018-10-21 02:53:41 +02:00
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->playerGender == MALE)
|
2018-12-27 23:30:47 +01:00
|
|
|
SetContinueGameWarpToHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F);
|
2018-10-21 02:53:41 +02:00
|
|
|
else
|
2018-12-27 23:30:47 +01:00
|
|
|
SetContinueGameWarpToHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F);
|
2018-10-21 02:53:41 +02:00
|
|
|
|
|
|
|
ribbonGet = FALSE;
|
|
|
|
|
2018-11-18 20:00:36 +01:00
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
2018-10-21 02:53:41 +02:00
|
|
|
{
|
|
|
|
struct Pokemon *mon = &gPlayerParty[i];
|
|
|
|
|
|
|
|
ribbonCounts[i].partyIndex = i;
|
|
|
|
ribbonCounts[i].count = 0;
|
|
|
|
|
2018-12-15 23:58:47 +01:00
|
|
|
if (GetMonData(mon, MON_DATA_SANITY_HAS_SPECIES)
|
|
|
|
&& !GetMonData(mon, MON_DATA_SANITY_IS_EGG)
|
2018-10-21 02:53:41 +02:00
|
|
|
&& !GetMonData(mon, MON_DATA_CHAMPION_RIBBON))
|
|
|
|
{
|
2018-10-21 23:24:43 +02:00
|
|
|
u8 val[1] = {TRUE};
|
|
|
|
SetMonData(mon, MON_DATA_CHAMPION_RIBBON, val);
|
2018-10-21 02:53:41 +02:00
|
|
|
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++)
|
|
|
|
{
|
2018-10-21 23:24:43 +02:00
|
|
|
if (ribbonCounts[i].count > ribbonCounts[0].count)
|
2018-10-21 02:53:41 +02:00
|
|
|
{
|
|
|
|
struct RibbonCounter prevBest = ribbonCounts[0];
|
|
|
|
ribbonCounts[0] = ribbonCounts[i];
|
|
|
|
ribbonCounts[i] = prevBest;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-11 03:54:00 +01:00
|
|
|
if (ribbonCounts[0].count > NUM_CUTIES_RIBBONS)
|
2018-10-21 02:53:41 +02:00
|
|
|
{
|
2019-11-11 03:54:00 +01:00
|
|
|
TryPutSpotTheCutiesOnAir(&gPlayerParty[ribbonCounts[0].partyIndex], MON_DATA_CHAMPION_RIBBON);
|
2018-10-21 02:53:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetMainCallback2(CB2_DoHallOfFameScreen);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-10-21 23:24:43 +02:00
|
|
|
|
2019-10-07 02:04:30 +02:00
|
|
|
bool8 SetCB2WhiteOut(void)
|
2018-10-21 23:24:43 +02:00
|
|
|
{
|
|
|
|
SetMainCallback2(CB2_WhiteOut);
|
|
|
|
return FALSE;
|
|
|
|
}
|