through Overworld_ResetStateAfterFly
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
#include "global.h"
|
||||
#include "gflib.h"
|
||||
#include "event_data.h"
|
||||
#include "event_scripts.h"
|
||||
#include "field_specials.h"
|
||||
#include "money.h"
|
||||
#include "overworld.h"
|
||||
#include "script.h"
|
||||
#include "script_pokemon_util.h"
|
||||
#include "constants/maps.h"
|
||||
#include "constants/flags.h"
|
||||
|
||||
u8 CountBadgesForOverworldWhiteOutLossCalculation(void);
|
||||
void sub_8054DD8(void);
|
||||
void sub_80554BC(void);
|
||||
|
||||
static const u8 sWhiteOutMoneyLossMultipliers[] = {
|
||||
2,
|
||||
4,
|
||||
6,
|
||||
9,
|
||||
12,
|
||||
16,
|
||||
20,
|
||||
25,
|
||||
30
|
||||
};
|
||||
|
||||
const u16 sWhiteOutMoneyLossBadgeFlagIDs[] = {
|
||||
FLAG_BADGE01_GET,
|
||||
FLAG_BADGE02_GET,
|
||||
FLAG_BADGE03_GET,
|
||||
FLAG_BADGE04_GET,
|
||||
FLAG_BADGE05_GET,
|
||||
FLAG_BADGE06_GET,
|
||||
FLAG_BADGE07_GET,
|
||||
FLAG_BADGE08_GET
|
||||
};
|
||||
|
||||
void sub_8054BC8(void)
|
||||
{
|
||||
ScriptContext2_RunNewScript(EventScript_ResetEliteFourEnd);
|
||||
RemoveMoney(&gSaveBlock1Ptr->money, ComputeWhiteOutMoneyLoss());
|
||||
HealPlayerParty();
|
||||
sub_8054DD8();
|
||||
sub_80554BC();
|
||||
WarpIntoMap();
|
||||
}
|
||||
|
||||
u32 ComputeWhiteOutMoneyLoss(void)
|
||||
{
|
||||
u8 nbadges = CountBadgesForOverworldWhiteOutLossCalculation();
|
||||
u8 toplevel = GetPlayerPartyHighestLevel();
|
||||
u32 losings = toplevel * 4 * sWhiteOutMoneyLossMultipliers[nbadges];
|
||||
u32 money = GetMoney(&gSaveBlock1Ptr->money);
|
||||
if (losings > money)
|
||||
losings = money;
|
||||
return losings;
|
||||
}
|
||||
|
||||
void OverworldWhiteOutGetMoneyLoss(void)
|
||||
{
|
||||
u32 losings = ComputeWhiteOutMoneyLoss();
|
||||
ConvertIntToDecimalStringN(gStringVar1, losings, STR_CONV_MODE_LEFT_ALIGN, CountDigits(losings));
|
||||
}
|
||||
|
||||
u8 CountBadgesForOverworldWhiteOutLossCalculation(void)
|
||||
{
|
||||
int i;
|
||||
u8 nbadges = 0;
|
||||
for (i = 0; i < NELEMS(sWhiteOutMoneyLossBadgeFlagIDs); i++)
|
||||
{
|
||||
if (FlagGet(sWhiteOutMoneyLossBadgeFlagIDs[i]))
|
||||
nbadges++;
|
||||
}
|
||||
return nbadges;
|
||||
}
|
||||
|
||||
void Overworld_ResetStateAfterFly(void)
|
||||
{
|
||||
ResetInitialPlayerAvatarState();
|
||||
FlagClear(FLAG_SYS_ON_CYCLING_ROAD);
|
||||
VarSet(VAR_MAP_SCENE_ROUTE16, 0);
|
||||
FlagClear(FLAG_SYS_UNK_802);
|
||||
FlagClear(FLAG_SYS_SAFARI_MODE);
|
||||
VarSet(VAR_MAP_SCENE_FUCHSIA_CITY_SAFARI_ZONE_ENTRANCE, 0);
|
||||
FlagClear(FLAG_SYS_USE_STRENGTH);
|
||||
FlagClear(FLAG_SYS_FLASH_ACTIVE);
|
||||
FlagClear(FLAG_0x808);
|
||||
VarSet(VAR_0x404D, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user