pokeemerald/src/field_specials.c

4188 lines
118 KiB
C
Raw Normal View History

#include "global.h"
2019-03-25 00:13:32 +01:00
#include "alloc.h"
#include "battle.h"
#include "battle_tower.h"
2018-08-11 23:51:54 +02:00
#include "cable_club.h"
2019-04-04 23:53:06 +02:00
#include "data.h"
2018-08-10 09:42:06 +02:00
#include "decoration.h"
#include "diploma.h"
#include "event_data.h"
#include "event_object_movement.h"
#include "fieldmap.h"
#include "field_camera.h"
2018-08-10 09:42:06 +02:00
#include "field_effect.h"
#include "field_message_box.h"
#include "field_player_avatar.h"
2018-12-08 22:05:11 +01:00
#include "field_screen_effect.h"
#include "field_specials.h"
#include "field_weather.h"
2018-08-09 08:53:21 +02:00
#include "international_string_util.h"
2018-08-10 09:42:06 +02:00
#include "item_icon.h"
#include "link.h"
2018-08-09 08:53:21 +02:00
#include "list_menu.h"
2018-11-13 15:19:04 +01:00
#include "main.h"
2019-03-25 00:13:32 +01:00
#include "mevent.h"
2018-08-11 23:51:54 +02:00
#include "match_call.h"
2018-08-09 08:53:21 +02:00
#include "menu.h"
#include "overworld.h"
#include "party_menu.h"
#include "pokeblock.h"
#include "pokemon.h"
#include "pokemon_storage_system.h"
2018-08-09 08:53:21 +02:00
#include "random.h"
2018-08-11 23:51:54 +02:00
#include "rayquaza_scene.h"
#include "region_map.h"
#include "rtc.h"
#include "script.h"
2018-08-09 08:53:21 +02:00
#include "script_menu.h"
#include "sound.h"
#include "starter_choose.h"
#include "string_util.h"
#include "strings.h"
#include "task.h"
#include "text.h"
#include "tv.h"
#include "wallclock.h"
2018-08-09 08:53:21 +02:00
#include "window.h"
2019-09-13 20:24:07 +02:00
#include "constants/battle_frontier.h"
#include "constants/decorations.h"
#include "constants/event_objects.h"
2018-11-13 15:19:04 +01:00
#include "constants/field_effects.h"
2019-09-13 20:24:07 +02:00
#include "constants/field_specials.h"
#include "constants/items.h"
2018-12-28 22:11:15 +01:00
#include "constants/map_types.h"
#include "constants/maps.h"
#include "constants/songs.h"
#include "constants/species.h"
#include "constants/moves.h"
#include "constants/vars.h"
2018-08-25 19:59:47 +02:00
#include "constants/battle_frontier.h"
#include "constants/weather.h"
2019-06-11 19:37:02 +02:00
#include "constants/metatile_labels.h"
#include "palette.h"
EWRAM_DATA bool8 gBikeCyclingChallenge = FALSE;
EWRAM_DATA u8 gBikeCollisions = 0;
2019-04-04 23:53:06 +02:00
static EWRAM_DATA u32 gBikeCyclingTimer = 0;
static EWRAM_DATA u8 gUnknown_0203AB5C = 0;
static EWRAM_DATA u8 sPetalburgGymSlidingDoorFrameCounter = 0;
2019-04-04 23:53:06 +02:00
static EWRAM_DATA u8 gUnknown_0203AB5E = 0;
2019-09-13 20:24:07 +02:00
static EWRAM_DATA u16 gLilycoveDeptStore_NeverRead = 0;
static EWRAM_DATA u16 gLilycoveDeptStore_DefaultFloorChoice = 0;
2019-04-04 23:53:06 +02:00
static EWRAM_DATA struct ListMenuItem *gUnknown_0203AB64 = NULL;
static EWRAM_DATA u16 gUnknown_0203AB68 = 0;
static EWRAM_DATA u16 gUnknown_0203AB6A = 0;
2019-09-13 20:24:07 +02:00
static EWRAM_DATA u8 gScrollableMultichoiceSprite = 0;
2019-04-04 23:53:06 +02:00
static EWRAM_DATA u8 gUnknown_0203AB6D = 0;
static EWRAM_DATA u8 gUnknown_0203AB6E = 0;
static EWRAM_DATA u8 gUnknown_0203AB6F = 0;
static EWRAM_DATA u32 gUnknown_0203AB70 = 0;
2018-08-09 08:53:21 +02:00
struct ListMenuTemplate gUnknown_030061D0;
extern const u16 gEventObjectPalette8[];
extern const u16 gEventObjectPalette17[];
extern const u16 gEventObjectPalette33[];
extern const u16 gEventObjectPalette34[];
2018-08-11 23:51:54 +02:00
void UpdateMovedLilycoveFanClubMembers(void);
void sub_813BF60(void);
u16 GetNumMovedLilycoveFanClubMembers(void);
static void RecordCyclingRoadResults(u32, u8);
static void LoadLinkPartnerEventObjectSpritePalette(u8 graphicsId, u8 localEventId, u8 paletteNum);
2018-08-11 23:51:54 +02:00
static void Task_PetalburgGym(u8);
static void PetalburgGymFunc(u8, u16);
static void Task_PCTurnOnEffect(u8);
static void PCTurnOnEffect_0(struct Task *);
static void PCTurnOnEffect_1(s16, s8, s8);
static void PCTurnOffEffect(void);
static void Task_LotteryCornerComputerEffect(u8);
static void LotteryCornerComputerEffect(struct Task *);
static void sub_81395BC(u8 taskId);
static void sub_8139620(u8 taskId);
static void sub_8139AF4(u8 taskId);
2019-09-13 20:24:07 +02:00
static void sub_8139C2C(u16 a1, bool8 descending);
static void MoveElevatorWindowLights(u8 taskId);
2018-08-11 23:51:54 +02:00
static void sub_813A2DC(u8 taskId);
2019-09-13 20:24:07 +02:00
static void sub_813AA60(u16 menu, u16 selection);
static void ShowBattleFrontierTutorWindow(u8 menu, u16 selection);
2018-08-11 23:51:54 +02:00
static void sub_813A42C(void);
static void sub_813A4EC(u8 taskId);
static void sub_813A694(u8 taskId);
static void sub_813A46C(s32 itemIndex, bool8 onInit, struct ListMenu *list);
2019-09-13 20:24:07 +02:00
static void sub_813AC44(u16 menu, u16 selection);
static void ShowBattleFrontierTutorMoveDescription(u8 menu, u16 selection);
2018-08-11 23:51:54 +02:00
static void sub_813A570(u8 taskId);
static void sub_813A738(u8 taskId);
static void sub_813A600(u8 taskId);
static void sub_813A664(u8 taskId);
2019-09-13 20:24:07 +02:00
static void ScrollMulti_ShowItemIcon(u16 item);
2018-12-28 20:10:02 +01:00
static void Task_DeoxysRockInteraction(u8 taskId);
static void ChangeDeoxysRockLevel(u8 a0);
static void WaitForDeoxysRockMovement(u8 taskId);
2018-08-11 23:51:54 +02:00
static void sub_813B57C(u8 taskId);
static void sub_813B824(u8 taskId);
static void _fwalk(u8 taskId);
static u8 sub_813BF44(void);
static void sub_813BD84(void);
static u16 sub_813BB74(void);
static void sub_813BE30(struct LinkBattleRecords *linkRecords, u8 a, u8 b);
void Special_ShowDiploma(void)
{
SetMainCallback2(CB2_ShowDiploma);
ScriptContext2_Enable();
}
void Special_ViewWallClock(void)
{
gMain.savedCallback = CB2_ReturnToField;
SetMainCallback2(CB2_ViewWallClock);
ScriptContext2_Enable();
}
void ResetCyclingRoadChallengeData(void)
{
gBikeCyclingChallenge = FALSE;
gBikeCollisions = 0;
gBikeCyclingTimer = 0;
}
void Special_BeginCyclingRoadChallenge(void)
{
gBikeCyclingChallenge = TRUE;
gBikeCollisions = 0;
gBikeCyclingTimer = gMain.vblankCounter1;
}
u16 GetPlayerAvatarBike(void)
{
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_ACRO_BIKE))
return 1;
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE))
return 2;
return 0;
}
static void DetermineCyclingRoadResults(u32 numFrames, u8 numBikeCollisions)
{
u8 result;
if (numBikeCollisions < 100)
{
ConvertIntToDecimalStringN(gStringVar1, numBikeCollisions, STR_CONV_MODE_LEFT_ALIGN, 2);
StringAppend(gStringVar1, gText_SpaceTimes);
}
else
{
StringCopy(gStringVar1, gText_99TimesPlus);
}
if (numFrames < 3600)
{
ConvertIntToDecimalStringN(gStringVar2, numFrames / 60, STR_CONV_MODE_RIGHT_ALIGN, 2);
gStringVar2[2] = CHAR_PERIOD;
ConvertIntToDecimalStringN(&gStringVar2[3], ((numFrames % 60) * 100) / 60, STR_CONV_MODE_LEADING_ZEROS, 2);
StringAppend(gStringVar2, gText_SpaceSeconds);
}
else
{
StringCopy(gStringVar2, gText_1MinutePlus);
}
result = 0;
if (numBikeCollisions == 0)
{
result = 5;
}
else if (numBikeCollisions < 4)
{
result = 4;
}
else if (numBikeCollisions < 10)
{
result = 3;
}
else if (numBikeCollisions < 20)
{
result = 2;
}
else if (numBikeCollisions < 100)
{
result = 1;
}
if (numFrames / 60 <= 10)
{
result += 5;
}
else if (numFrames / 60 <= 15)
{
result += 4;
}
else if (numFrames / 60 <= 20)
{
result += 3;
}
else if (numFrames / 60 <= 40)
{
result += 2;
}
else if (numFrames / 60 < 60)
{
result += 1;
}
gSpecialVar_Result = result;
}
void FinishCyclingRoadChallenge(void) {
const u32 numFrames = gMain.vblankCounter1 - gBikeCyclingTimer;
DetermineCyclingRoadResults(numFrames, gBikeCollisions);
RecordCyclingRoadResults(numFrames, gBikeCollisions);
}
static void RecordCyclingRoadResults(u32 numFrames, u8 numBikeCollisions) {
u16 low = VarGet(VAR_CYCLING_ROAD_RECORD_TIME_L);
u16 high = VarGet(VAR_CYCLING_ROAD_RECORD_TIME_H);
u32 framesRecord = low + (high << 16);
if (framesRecord > numFrames || framesRecord == 0)
{
VarSet(VAR_CYCLING_ROAD_RECORD_TIME_L, numFrames);
VarSet(VAR_CYCLING_ROAD_RECORD_TIME_H, numFrames >> 16);
VarSet(VAR_CYCLING_ROAD_RECORD_COLLISIONS, numBikeCollisions);
}
}
u16 GetRecordedCyclingRoadResults(void) {
u16 low = VarGet(VAR_CYCLING_ROAD_RECORD_TIME_L);
u16 high = VarGet(VAR_CYCLING_ROAD_RECORD_TIME_H);
u32 framesRecord = low + (high << 16);
if (framesRecord == 0)
{
return FALSE;
}
DetermineCyclingRoadResults(framesRecord, VarGet(VAR_CYCLING_ROAD_RECORD_COLLISIONS));
return TRUE;
}
void UpdateCyclingRoadState(void) {
if (gLastUsedWarp.mapNum == MAP_NUM(ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE) && gLastUsedWarp.mapGroup == MAP_GROUP(ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE))
{
return;
}
if (VarGet(VAR_CYCLING_CHALLENGE_STATE) == 2 || VarGet(VAR_CYCLING_CHALLENGE_STATE) == 3)
{
VarSet(VAR_CYCLING_CHALLENGE_STATE, 0);
Overworld_SetSavedMusic(MUS_DUMMY);
}
}
void SetSSTidalFlag(void)
{
FlagSet(FLAG_SYS_CRUISE_MODE);
*GetVarPointer(VAR_CRUISE_STEP_COUNT) = 0;
}
void ResetSSTidalFlag(void)
{
FlagClear(FLAG_SYS_CRUISE_MODE);
}
bool32 CountSSTidalStep(u16 delta)
{
if (!FlagGet(FLAG_SYS_CRUISE_MODE) || (*GetVarPointer(VAR_CRUISE_STEP_COUNT) += delta) <= 0xcc)
{
return FALSE;
}
return TRUE;
}
u8 GetSSTidalLocation(s8 *mapGroup, s8 *mapNum, s16 *x, s16 *y)
{
u16 *varCruiseStepCount = GetVarPointer(VAR_CRUISE_STEP_COUNT);
switch (*GetVarPointer(VAR_PORTHOLE_STATE))
{
case 1:
case 8:
return 1;
case 3:
case 9:
return 4;
case 4:
case 5:
return 2;
case 6:
case 10:
return 3;
case 2:
if (*varCruiseStepCount < 60)
{
*mapNum = MAP_NUM(ROUTE134);
*x = *varCruiseStepCount + 19;
}
else if (*varCruiseStepCount < 140)
{
*mapNum = MAP_NUM(ROUTE133);
*x = *varCruiseStepCount - 60;
}
else
{
*mapNum = MAP_NUM(ROUTE132);
*x = *varCruiseStepCount - 140;
}
break;
case 7:
if (*varCruiseStepCount < 66)
{
*mapNum = MAP_NUM(ROUTE132);
*x = 65 - *varCruiseStepCount;
}
else if (*varCruiseStepCount < 146) {
*mapNum = MAP_NUM(ROUTE133);
*x = 145 - *varCruiseStepCount;
}
else
{
*mapNum = MAP_NUM(ROUTE134);
*x = 224 - *varCruiseStepCount;
}
break;
}
*mapGroup = MAP_GROUP(ROUTE132);
*y = 20;
return 0;
}
2019-02-28 05:54:51 +01:00
bool32 ShouldDoWallyCall(void)
{
2019-01-02 22:12:43 +01:00
if (FlagGet(FLAG_ENABLE_FIRST_WALLY_POKENAV_CALL))
{
switch (gMapHeader.mapType)
{
2019-02-28 05:54:51 +01:00
case MAP_TYPE_TOWN:
case MAP_TYPE_CITY:
case MAP_TYPE_ROUTE:
case MAP_TYPE_OCEAN_ROUTE:
2019-03-01 07:49:11 +01:00
if (++(*GetVarPointer(VAR_WALLY_CALL_STEP_COUNTER)) < 250)
{
return FALSE;
}
break;
default:
return FALSE;
}
}
else
{
return FALSE;
}
return TRUE;
}
2019-02-28 05:54:51 +01:00
bool32 ShouldDoWinonaCall(void)
{
2019-01-02 22:12:43 +01:00
if (FlagGet(FLAG_REGISTER_WINONA_POKENAV))
{
switch (gMapHeader.mapType)
{
2018-12-28 22:11:15 +01:00
case MAP_TYPE_TOWN:
case MAP_TYPE_CITY:
case MAP_TYPE_ROUTE:
2019-02-28 05:54:51 +01:00
case MAP_TYPE_OCEAN_ROUTE:
if (++(*GetVarPointer(VAR_WINONA_CALL_STEP_COUNTER)) < 10)
{
return FALSE;
}
break;
default:
return FALSE;
}
}
else
{
return FALSE;
}
return TRUE;
}
2019-02-28 05:54:51 +01:00
bool32 ShouldDoScottCall(void)
{
2019-01-02 22:12:43 +01:00
if (FlagGet(FLAG_SCOTT_CALL_NATIONAL_DEX))
{
switch (gMapHeader.mapType)
{
2019-09-13 20:24:07 +02:00
case MAP_TYPE_TOWN:
case MAP_TYPE_CITY:
case MAP_TYPE_ROUTE:
case MAP_TYPE_OCEAN_ROUTE:
2019-02-28 05:54:51 +01:00
if (++(*GetVarPointer(VAR_SCOTT_CALL_STEP_COUNTER)) < 10)
{
return FALSE;
}
break;
default:
return FALSE;
}
}
else
{
return FALSE;
}
return TRUE;
}
2019-02-28 05:54:51 +01:00
bool32 ShouldDoRoxanneCall(void)
{
2019-01-02 22:12:43 +01:00
if (FlagGet(FLAG_ENABLE_ROXANNE_FIRST_CALL))
{
switch (gMapHeader.mapType)
{
2019-09-13 20:24:07 +02:00
case MAP_TYPE_TOWN:
case MAP_TYPE_CITY:
case MAP_TYPE_ROUTE:
case MAP_TYPE_OCEAN_ROUTE:
2019-03-01 07:49:11 +01:00
if (++(*GetVarPointer(VAR_ROXANNE_CALL_STEP_COUNTER)) < 250)
{
return FALSE;
}
break;
default:
return FALSE;
}
}
else
{
return FALSE;
}
return TRUE;
}
2019-02-28 05:54:51 +01:00
bool32 ShouldDoRivalRayquazaCall(void)
{
2019-01-02 22:12:43 +01:00
if (FlagGet(FLAG_DEFEATED_MAGMA_SPACE_CENTER))
{
switch (gMapHeader.mapType)
{
2019-09-13 20:24:07 +02:00
case MAP_TYPE_TOWN:
case MAP_TYPE_CITY:
case MAP_TYPE_ROUTE:
case MAP_TYPE_OCEAN_ROUTE:
2019-03-01 07:49:11 +01:00
if (++(*GetVarPointer(VAR_RIVAL_RAYQUAZA_CALL_STEP_COUNTER)) < 250)
{
return FALSE;
}
break;
default:
return FALSE;
}
}
else
{
return FALSE;
}
return TRUE;
}
u8 GetLinkPartnerNames(void)
{
u8 i;
u8 j = 0;
u8 myLinkPlayerNumber = GetMultiplayerId();
u8 nLinkPlayers = GetLinkPlayerCount();
for (i = 0; i < nLinkPlayers; i++)
{
if (myLinkPlayerNumber != i)
{
StringCopy(gTVStringVarPtrs[j], gLinkPlayers[i].name);
j++;
}
}
return nLinkPlayers;
}
void SpawnLinkPartnerEventObject(void)
{
u8 j = 0;
s16 x = 0;
s16 y = 0;
u8 gUnknown_085B2B5C[] = {7, 9, 8, 10};
s8 gUnknown_085B2B60[][2] = {
{ 0, 1},
{ 1, 0},
{ 0, -1},
{-1, 0}
};
u8 myLinkPlayerNumber;
u8 playerFacingDirection;
u8 linkSpriteId;
u8 i;
myLinkPlayerNumber = GetMultiplayerId();
playerFacingDirection = GetPlayerFacingDirection();
switch (playerFacingDirection)
{
case DIR_WEST:
j = 2;
x = gSaveBlock1Ptr->pos.x - 1;
y = gSaveBlock1Ptr->pos.y;
break;
case DIR_NORTH:
j = 1;
x = gSaveBlock1Ptr->pos.x;
y = gSaveBlock1Ptr->pos.y - 1;
break;
case DIR_EAST:
x = gSaveBlock1Ptr->pos.x + 1;
y = gSaveBlock1Ptr->pos.y;
break;
case DIR_SOUTH:
j = 3;
x = gSaveBlock1Ptr->pos.x;
y = gSaveBlock1Ptr->pos.y + 1;
}
for (i = 0; i < gSpecialVar_0x8004; i++)
{
if (myLinkPlayerNumber != i)
{
switch ((u8)gLinkPlayers[i].version)
{
case VERSION_RUBY:
case VERSION_SAPPHIRE:
if (gLinkPlayers[i].gender == 0)
linkSpriteId = EVENT_OBJ_GFX_LINK_RS_BRENDAN;
else
linkSpriteId = EVENT_OBJ_GFX_LINK_RS_MAY;
break;
case VERSION_EMERALD:
if (gLinkPlayers[i].gender == 0)
linkSpriteId = EVENT_OBJ_GFX_RIVAL_BRENDAN_NORMAL;
else
linkSpriteId = EVENT_OBJ_GFX_RIVAL_MAY_NORMAL;
break;
default:
if (gLinkPlayers[i].gender == 0)
linkSpriteId = EVENT_OBJ_GFX_RIVAL_BRENDAN_NORMAL;
else
linkSpriteId = EVENT_OBJ_GFX_RIVAL_MAY_NORMAL;
break;
}
SpawnSpecialEventObjectParameterized(linkSpriteId, gUnknown_085B2B5C[j], 0xf0 - i, gUnknown_085B2B60[j][0] + x + 7, gUnknown_085B2B60[j][1] + y + 7, 0);
LoadLinkPartnerEventObjectSpritePalette(linkSpriteId, 0xf0 - i, i);
j++;
if (j == 4)
{
j = 0;
}
}
}
}
static void LoadLinkPartnerEventObjectSpritePalette(u8 graphicsId, u8 localEventId, u8 paletteNum)
{
u8 adjustedPaletteNum;
// Note: This temp var is necessary; paletteNum += 6 doesn't match.
adjustedPaletteNum = paletteNum + 6;
if (graphicsId == EVENT_OBJ_GFX_LINK_RS_BRENDAN ||
graphicsId == EVENT_OBJ_GFX_LINK_RS_MAY ||
graphicsId == EVENT_OBJ_GFX_RIVAL_BRENDAN_NORMAL ||
graphicsId == EVENT_OBJ_GFX_RIVAL_MAY_NORMAL)
{
u8 obj = GetEventObjectIdByLocalIdAndMap(localEventId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
2018-10-17 14:52:26 +02:00
if (obj != EVENT_OBJECTS_COUNT)
{
u8 spriteId = gEventObjects[obj].spriteId;
struct Sprite *sprite = &gSprites[spriteId];
sprite->oam.paletteNum = adjustedPaletteNum;
switch (graphicsId)
{
case EVENT_OBJ_GFX_LINK_RS_BRENDAN:
LoadPalette(gEventObjectPalette33, 0x100 + (adjustedPaletteNum << 4), 0x20);
break;
case EVENT_OBJ_GFX_LINK_RS_MAY:
LoadPalette(gEventObjectPalette34, 0x100 + (adjustedPaletteNum << 4), 0x20);
break;
case EVENT_OBJ_GFX_RIVAL_BRENDAN_NORMAL:
LoadPalette(gEventObjectPalette8, 0x100 + (adjustedPaletteNum << 4), 0x20);
break;
case EVENT_OBJ_GFX_RIVAL_MAY_NORMAL:
LoadPalette(gEventObjectPalette17, 0x100 + (adjustedPaletteNum << 4), 0x20);
break;
}
}
}
}
2019-09-13 20:24:07 +02:00
static const struct UCoords8 sMauvilleGymSwitchCoords[] =
{
{ 7, 22},
{11, 19},
{10, 16},
{15, 16}
};
2019-06-11 19:37:02 +02:00
// Flips the switches on the ground when the player steps on them.
void MauvilleGymSpecial1(void)
{
u8 i;
2019-06-11 19:37:02 +02:00
for (i = 0; i < ARRAY_COUNT(sMauvilleGymSwitchCoords); i++)
{
if (i == gSpecialVar_0x8004)
{
2019-06-11 19:37:02 +02:00
MapGridSetMetatileIdAt(sMauvilleGymSwitchCoords[i].x, sMauvilleGymSwitchCoords[i].y, METATILE_ID(MauvilleGym, PressedSwitch));
}
else
{
2019-06-11 19:37:02 +02:00
MapGridSetMetatileIdAt(sMauvilleGymSwitchCoords[i].x, sMauvilleGymSwitchCoords[i].y, METATILE_ID(MauvilleGym, RaisedSwitch));
}
}
}
void MauvilleGymSpecial2(void)
{
int x, y;
for (y = 12; y < 24; y++)
{
for (x = 7; x < 16; x++)
{
switch (MapGridGetMetatileIdAt(x, y))
{
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH1_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH2_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH2_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH3_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH3_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH4_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH4_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH1_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH1_On));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH2_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH2_On));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH3_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH3_On) | METATILE_COLLISION_MASK);
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH4_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH4_On) | METATILE_COLLISION_MASK);
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH1_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH2_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH2_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH3_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH3_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH4_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH4_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH1_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH1_On));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH2_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH2_On));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH3_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH3_On) | METATILE_COLLISION_MASK);
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH4_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH4_On) | METATILE_COLLISION_MASK);
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamV1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_On) | METATILE_COLLISION_MASK);
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamV2_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, FloorTile));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamV1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_Off) | METATILE_COLLISION_MASK);
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamV2_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, FloorTile));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, PoleBottom_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamV1_On) | METATILE_COLLISION_MASK);
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, FloorTile):
if (MapGridGetMetatileIdAt(x, y - 1) == METATILE_ID(MauvilleGym, GreenBeamV1_On))
{
2019-06-11 19:37:02 +02:00
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamV2_On) | METATILE_COLLISION_MASK);
}
else
{
2019-06-11 19:37:02 +02:00
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamV2_On) | METATILE_COLLISION_MASK);
}
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, PoleBottom_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamV1_On) | METATILE_COLLISION_MASK);
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, PoleTop_Off):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleTop_On) | METATILE_COLLISION_MASK);
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, PoleTop_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleTop_Off));
break;
}
}
}
}
2019-06-11 19:37:02 +02:00
// Presses all switches and deactivates all beams.
void MauvilleGymSpecial3(void)
{
int i, x, y;
2019-06-11 19:37:02 +02:00
const struct UCoords8 *switchCoords = sMauvilleGymSwitchCoords;
for (i = ARRAY_COUNT(sMauvilleGymSwitchCoords) - 1; i >= 0; i--)
{
2019-06-11 19:37:02 +02:00
MapGridSetMetatileIdAt(switchCoords->x, switchCoords->y, METATILE_ID(MauvilleGym, PressedSwitch));
switchCoords++;
}
for (y = 12; y < 24; y++)
{
for (x = 7; x < 16; x++)
{
switch (MapGridGetMetatileIdAt(x, y))
{
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH1_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH2_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH2_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH3_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH3_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamH4_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, GreenBeamH4_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH1_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH2_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH2_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH3_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH3_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamH4_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, RedBeamH4_Off));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamV1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_On) | METATILE_COLLISION_MASK);
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, RedBeamV1_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleBottom_Off) | METATILE_COLLISION_MASK);
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, GreenBeamV2_On):
case METATILE_ID(MauvilleGym, RedBeamV2_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, FloorTile));
break;
2019-06-11 19:37:02 +02:00
case METATILE_ID(MauvilleGym, PoleTop_On):
MapGridSetMetatileIdAt(x, y, METATILE_ID(MauvilleGym, PoleTop_Off));
break;
}
}
}
}
2018-08-11 23:51:54 +02:00
static const u8 gUnknown_085B2B78[] = {0, 1, 1, 1, 1};
static const u16 sPetalburgGymSlidingDoorMetatiles[] = {
METATILE_ID(PetalburgGym, SlidingDoor_Frame0),
METATILE_ID(PetalburgGym, SlidingDoor_Frame1),
METATILE_ID(PetalburgGym, SlidingDoor_Frame2),
METATILE_ID(PetalburgGym, SlidingDoor_Frame3),
METATILE_ID(PetalburgGym, SlidingDoor_Frame4),
};
void PetalburgGymSpecial1(void)
{
gUnknown_0203AB5C = 0;
sPetalburgGymSlidingDoorFrameCounter = 0;
PlaySE(SE_KI_GASYAN);
CreateTask(Task_PetalburgGym, 8);
}
static void Task_PetalburgGym(u8 taskId)
{
if (gUnknown_085B2B78[sPetalburgGymSlidingDoorFrameCounter] == gUnknown_0203AB5C)
{
PetalburgGymFunc(gSpecialVar_0x8004, sPetalburgGymSlidingDoorMetatiles[sPetalburgGymSlidingDoorFrameCounter]);
gUnknown_0203AB5C = 0;
if ((++sPetalburgGymSlidingDoorFrameCounter) == ARRAY_COUNT(sPetalburgGymSlidingDoorMetatiles))
{
DestroyTask(taskId);
EnableBothScriptContexts();
}
}
else
{
gUnknown_0203AB5C++;
}
}
static void PetalburgGymFunc(u8 roomNumber, u16 metatileId)
{
u16 doorCoordsX[4];
u16 doorCoordsY[4];
u8 i;
u8 nDoors = 0;
switch (roomNumber)
{
case 1:
nDoors = 2;
doorCoordsX[0] = 1;
doorCoordsX[1] = 7;
doorCoordsY[0] = 104;
doorCoordsY[1] = 104;
break;
case 2:
nDoors = 2;
doorCoordsX[0] = 1;
doorCoordsX[1] = 7;
doorCoordsY[0] = 78;
doorCoordsY[1] = 78;
break;
case 3:
nDoors = 2;
doorCoordsX[0] = 1;
doorCoordsX[1] = 7;
doorCoordsY[0] = 91;
doorCoordsY[1] = 91;
break;
case 4:
nDoors = 1;
doorCoordsX[0] = 7;
doorCoordsY[0] = 39;
break;
case 5:
nDoors = 2;
doorCoordsX[0] = 1;
doorCoordsX[1] = 7;
doorCoordsY[0] = 52;
doorCoordsY[1] = 52;
break;
case 6:
nDoors = 1;
doorCoordsX[0] = 1;
doorCoordsY[0] = 65;
break;
case 7:
nDoors = 1;
doorCoordsX[0] = 7;
doorCoordsY[0] = 13;
break;
case 8:
nDoors = 1;
doorCoordsX[0] = 1;
doorCoordsY[0] = 26;
break;
}
for (i = 0; i < nDoors; i++)
{
MapGridSetMetatileIdAt(doorCoordsX[i] + 7, doorCoordsY[i] + 7, metatileId | METATILE_COLLISION_MASK);
MapGridSetMetatileIdAt(doorCoordsX[i] + 7, doorCoordsY[i] + 8, (metatileId + 8) | METATILE_COLLISION_MASK);
}
DrawWholeMapView();
}
void PetalburgGymSpecial2(void)
{
PetalburgGymFunc(gSpecialVar_0x8004, sPetalburgGymSlidingDoorMetatiles[4]);
}
void ShowFieldMessageStringVar4(void)
{
ShowFieldMessage(gStringVar4);
}
void StorePlayerCoordsInVars(void)
{
gSpecialVar_0x8004 = gSaveBlock1Ptr->pos.x;
gSpecialVar_0x8005 = gSaveBlock1Ptr->pos.y;
}
u8 GetPlayerTrainerIdOnesDigit(void)
{
return (u16)((gSaveBlock2Ptr->playerTrainerId[1] << 8) | gSaveBlock2Ptr->playerTrainerId[0]) % 10;
}
void GetPlayerBigGuyGirlString(void)
{
if (gSaveBlock2Ptr->playerGender == MALE)
{
StringCopy(gStringVar1, gText_BigGuy);
}
else
{
StringCopy(gStringVar1, gText_BigGirl);
}
}
void GetRivalSonDaughterString(void)
{
if (gSaveBlock2Ptr->playerGender == MALE)
{
StringCopy(gStringVar1, gText_Daughter);
}
else
{
StringCopy(gStringVar1, gText_Son);
}
}
u8 GetBattleOutcome(void)
{
return gBattleOutcome;
}
void CableCarWarp(void)
{
if (gSpecialVar_0x8004 != 0)
{
2018-12-27 23:30:47 +01:00
SetWarpDestination(MAP_GROUP(ROUTE112_CABLE_CAR_STATION), MAP_NUM(ROUTE112_CABLE_CAR_STATION), -1, 6, 4);
}
else
{
2018-12-27 23:30:47 +01:00
SetWarpDestination(MAP_GROUP(MT_CHIMNEY_CABLE_CAR_STATION), MAP_NUM(MT_CHIMNEY_CABLE_CAR_STATION), -1, 6, 4);
}
}
void SetFlagInVar(void)
{
FlagSet(gSpecialVar_0x8004);
}
u16 GetWeekCount(void)
{
u16 weekCount = gLocalTime.days / 7;
if (weekCount > 9999)
{
weekCount = 9999;
}
return weekCount;
}
u8 GetLeadMonFriendshipScore(void)
{
struct Pokemon *pokemon = &gPlayerParty[GetLeadMonIndex()];
if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) == 255)
{
return 6;
}
if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 200)
{
return 5;
}
if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 150)
{
return 4;
}
if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 100)
{
return 3;
}
if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 50)
{
return 2;
}
if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) >= 1)
{
return 1;
}
return 0;
}
2018-08-11 23:51:54 +02:00
static void CB2_FieldShowRegionMap(void)
{
FieldInitRegionMap(CB2_ReturnToFieldContinueScriptPlayMapMusic);
}
void FieldShowRegionMap(void)
{
SetMainCallback2(CB2_FieldShowRegionMap);
}
void DoPCTurnOnEffect(void)
{
if (FuncIsActiveTask(Task_PCTurnOnEffect) != TRUE)
{
u8 taskId = CreateTask(Task_PCTurnOnEffect, 8);
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[1] = taskId;
gTasks[taskId].data[2] = 0;
gTasks[taskId].data[3] = 0;
gTasks[taskId].data[4] = 0;
}
}
static void Task_PCTurnOnEffect(u8 taskId)
{
struct Task *task = &gTasks[taskId];
if (task->data[0] == 0)
{
PCTurnOnEffect_0(task);
}
}
static void PCTurnOnEffect_0(struct Task *task)
{
u8 playerDirection;
s8 dx = 0;
s8 dy = 0;
if (task->data[3] == 6)
{
task->data[3] = 0;
playerDirection = GetPlayerFacingDirection();
switch (playerDirection)
{
case DIR_NORTH:
dx = 0;
dy = -1;
break;
case DIR_WEST:
dx = -1;
dy = -1;
break;
case DIR_EAST:
dx = 1;
dy = -1;
break;
}
PCTurnOnEffect_1(task->data[4], dx, dy);
DrawWholeMapView();
task->data[4] ^= 1;
if ((++task->data[2]) == 5)
{
DestroyTask(task->data[1]);
}
}
task->data[3]++;
}
2019-09-13 20:24:07 +02:00
static void PCTurnOnEffect_1(s16 pcOff, s8 dx, s8 dy)
{
u16 tileId = 0;
2019-09-13 20:24:07 +02:00
if (pcOff != 0)
{
2019-09-13 20:24:07 +02:00
if (gSpecialVar_0x8004 == PC_LOCATION_OTHER)
{
tileId = METATILE_ID(Building, PC_Off);
}
2019-09-13 20:24:07 +02:00
else if (gSpecialVar_0x8004 == PC_LOCATION_BRENDANS_HOUSE)
{
tileId = METATILE_ID(BrendansMaysHouse, BrendanPC_Off);
}
2019-09-13 20:24:07 +02:00
else if (gSpecialVar_0x8004 == PC_LOCATION_MAYS_HOUSE)
{
tileId = METATILE_ID(BrendansMaysHouse, MayPC_Off);
}
}
else
{
2019-09-13 20:24:07 +02:00
if (gSpecialVar_0x8004 == PC_LOCATION_OTHER)
{
tileId = METATILE_ID(Building, PC_On);
}
2019-09-13 20:24:07 +02:00
else if (gSpecialVar_0x8004 == PC_LOCATION_BRENDANS_HOUSE)
{
tileId = METATILE_ID(BrendansMaysHouse, BrendanPC_On);
}
2019-09-13 20:24:07 +02:00
else if (gSpecialVar_0x8004 == PC_LOCATION_MAYS_HOUSE)
{
tileId = METATILE_ID(BrendansMaysHouse, MayPC_On);
}
}
2019-02-27 04:56:22 +01:00
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_MASK);
}
void DoPCTurnOffEffect(void)
{
PCTurnOffEffect();
}
static void PCTurnOffEffect(void)
{
s8 dx = 0;
s8 dy = 0;
u16 tileId = 0;
u8 playerDirection = GetPlayerFacingDirection();
switch (playerDirection)
{
case DIR_NORTH:
dx = 0;
dy = -1;
break;
case DIR_WEST:
dx = -1;
dy = -1;
break;
case DIR_EAST:
dx = 1;
dy = -1;
break;
}
if (gSpecialVar_0x8004 == 0)
{
tileId = METATILE_ID(Building, PC_Off);
}
else if (gSpecialVar_0x8004 == 1)
{
tileId = METATILE_ID(BrendansMaysHouse, BrendanPC_Off);
}
else if (gSpecialVar_0x8004 == 2)
{
tileId = METATILE_ID(BrendansMaysHouse, MayPC_Off);
}
2019-02-27 04:56:22 +01:00
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_MASK);
DrawWholeMapView();
}
void DoLotteryCornerComputerEffect(void)
{
if (FuncIsActiveTask(Task_LotteryCornerComputerEffect) != TRUE)
{
u8 taskId = CreateTask(Task_LotteryCornerComputerEffect, 8);
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[1] = taskId;
gTasks[taskId].data[2] = 0;
gTasks[taskId].data[3] = 0;
gTasks[taskId].data[4] = 0;
}
}
static void Task_LotteryCornerComputerEffect(u8 taskId)
{
struct Task *task = &gTasks[taskId];
if (task->data[0] == 0)
{
LotteryCornerComputerEffect(task);
}
}
static void LotteryCornerComputerEffect(struct Task *task)
{
if (task->data[3] == 6)
{
task->data[3] = 0;
if (task->data[4] != 0)
{
MapGridSetMetatileIdAt(18, 8, METATILE_ID(Shop, Laptop1_Normal) | METATILE_COLLISION_MASK);
MapGridSetMetatileIdAt(18, 9, METATILE_ID(Shop, Laptop2_Normal) | METATILE_COLLISION_MASK);
}
else
{
MapGridSetMetatileIdAt(18, 8, METATILE_ID(Shop, Laptop1_Flash) | METATILE_COLLISION_MASK);
MapGridSetMetatileIdAt(18, 9, METATILE_ID(Shop, Laptop2_Flash) | METATILE_COLLISION_MASK);
}
DrawWholeMapView();
task->data[4] ^= 1;
if ((++task->data[2]) == 5)
{
DestroyTask(task->data[1]);
}
}
task->data[3]++;
}
void EndLotteryCornerComputerEffect(void)
{
MapGridSetMetatileIdAt(18, 8, METATILE_ID(Shop, Laptop1_Normal) | METATILE_COLLISION_MASK);
MapGridSetMetatileIdAt(18, 9, METATILE_ID(Shop, Laptop2_Normal) | METATILE_COLLISION_MASK);
DrawWholeMapView();
}
void SetTrickHouseEndRoomFlag(void)
{
u16 *specVar = &gSpecialVar_0x8004;
2019-01-02 22:12:43 +01:00
u16 flag = FLAG_TRICK_HOUSE_END_ROOM;
*specVar = flag;
FlagSet(flag);
}
void ResetTrickHouseEndRoomFlag(void)
{
u16 *specVar = &gSpecialVar_0x8004;
2019-01-02 22:12:43 +01:00
u16 flag = FLAG_TRICK_HOUSE_END_ROOM;
*specVar = flag;
FlagClear(flag);
}
bool8 CheckLeadMonCool(void)
{
if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_COOL) < 200)
{
return FALSE;
}
return TRUE;
}
bool8 CheckLeadMonBeauty(void)
{
if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_BEAUTY) < 200)
{
return FALSE;
}
return TRUE;
}
bool8 CheckLeadMonCute(void)
{
if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_CUTE) < 200)
{
return FALSE;
}
return TRUE;
}
bool8 CheckLeadMonSmart(void)
{
if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SMART) < 200)
{
return FALSE;
}
return TRUE;
}
bool8 CheckLeadMonTough(void)
{
if (GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_TOUGH) < 200)
{
return FALSE;
}
return TRUE;
}
void IsGrassTypeInParty(void)
{
u8 i;
u16 species;
struct Pokemon *pokemon;
for (i = 0; i < PARTY_SIZE; i++)
{
pokemon = &gPlayerParty[i];
2018-12-15 23:58:47 +01:00
if (GetMonData(pokemon, MON_DATA_SANITY_HAS_SPECIES) && !GetMonData(pokemon, MON_DATA_IS_EGG))
{
species = GetMonData(pokemon, MON_DATA_SPECIES);
if (gBaseStats[species].type1 == TYPE_GRASS || gBaseStats[species].type2 == TYPE_GRASS)
{
gSpecialVar_Result = TRUE;
return;
}
}
}
gSpecialVar_Result = FALSE;
}
void SpawnCameraObject(void)
{
u8 obj = SpawnSpecialEventObjectParameterized(EVENT_OBJ_GFX_BOY_1, 8, EVENT_OBJ_ID_CAMERA, gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7, 3);
gEventObjects[obj].invisible = TRUE;
CameraObjectSetFollowedObjectId(gEventObjects[obj].spriteId);
}
void RemoveCameraObject(void)
{
CameraObjectSetFollowedObjectId(GetPlayerAvatarObjectId());
RemoveEventObjectByLocalIdAndMap(EVENT_OBJ_ID_CAMERA, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
}
u8 GetPokeblockNameByMonNature(void)
{
return CopyMonFavoritePokeblockName(GetNature(&gPlayerParty[GetLeadMonIndex()]), gStringVar1);
}
void GetSecretBaseNearbyMapName(void)
{
GetMapName(gStringVar1, VarGet(VAR_SECRET_BASE_MAP), 0);
}
u16 GetBestBattleTowerStreak(void)
{
return GetGameStat(GAME_STAT_BATTLE_TOWER_BEST_STREAK);
}
void BufferEReaderTrainerName(void)
{
GetEreaderTrainerName(gStringVar1);
}
u16 GetSlotMachineId(void)
{
2018-08-11 23:51:54 +02:00
static const u8 gUnknown_085B2B88[] = {12, 2, 4, 5, 1, 8, 7, 11, 3, 10, 9, 6};
static const u8 gUnknown_085B2B94[] = {0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5};
static const u8 gUnknown_085B2BA0[] = {3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5};
u32 v0 = gSaveBlock1Ptr->easyChatPairs[0].unk0_0 + gSaveBlock1Ptr->easyChatPairs[0].unk2 + gUnknown_085B2B88[gSpecialVar_0x8004];
2019-09-13 20:24:07 +02:00
if (GetPriceReduction(POKENEWS_GAME_CORNER))
{
return gUnknown_085B2BA0[v0 % 12];
}
return gUnknown_085B2B94[v0 % 12];
}
bool8 FoundAbandonedShipRoom1Key(void)
{
u16 *specVar = &gSpecialVar_0x8004;
u16 flag = FLAG_HIDDEN_ITEM_ABANDONED_SHIP_RM_1_KEY;
*specVar = flag;
if (!FlagGet(flag))
{
return FALSE;
}
return TRUE;
}
bool8 FoundAbandonedShipRoom2Key(void)
{
u16 *specVar = &gSpecialVar_0x8004;
u16 flag = FLAG_HIDDEN_ITEM_ABANDONED_SHIP_RM_2_KEY;
*specVar = flag;
if (!FlagGet(flag))
{
return FALSE;
}
return TRUE;
}
bool8 FoundAbandonedShipRoom4Key(void)
{
u16 *specVar = &gSpecialVar_0x8004;
u16 flag = FLAG_HIDDEN_ITEM_ABANDONED_SHIP_RM_4_KEY;
*specVar = flag;
if (!FlagGet(flag))
{
return FALSE;
}
return TRUE;
}
bool8 FoundAbandonedShipRoom6Key(void)
{
u16 *specVar = &gSpecialVar_0x8004;
u16 flag = FLAG_HIDDEN_ITEM_ABANDONED_SHIP_RM_6_KEY;
*specVar = flag;
if (!FlagGet(flag))
{
return FALSE;
}
return TRUE;
}
bool8 LeadMonHasEffortRibbon(void)
{
return GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_EFFORT_RIBBON, NULL);
}
void GiveLeadMonEffortRibbon(void)
{
bool8 ribbonSet;
struct Pokemon *leadMon;
IncrementGameStat(GAME_STAT_RECEIVED_RIBBONS);
FlagSet(FLAG_SYS_RIBBON_GET);
ribbonSet = TRUE;
leadMon = &gPlayerParty[GetLeadMonIndex()];
SetMonData(leadMon, MON_DATA_EFFORT_RIBBON, &ribbonSet);
if (GetRibbonCount(leadMon) > 4)
{
sub_80EE4DC(leadMon, 0x47);
}
}
bool8 Special_AreLeadMonEVsMaxedOut(void)
{
if (GetMonEVCount(&gPlayerParty[GetLeadMonIndex()]) >= 510)
{
return TRUE;
}
return FALSE;
}
u8 TryUpdateRusturfTunnelState(void)
{
if (!FlagGet(FLAG_RUSTURF_TUNNEL_OPENED) && gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(RUSTURF_TUNNEL) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(RUSTURF_TUNNEL))
{
if (FlagGet(FLAG_HIDE_RUSTURF_TUNNEL_ROCK_1))
{
VarSet(VAR_RUSTURF_TUNNEL_STATE, 4);
return TRUE;
}
else if (FlagGet(FLAG_HIDE_RUSTURF_TUNNEL_ROCK_2))
{
VarSet(VAR_RUSTURF_TUNNEL_STATE, 5);
return TRUE;
}
}
return FALSE;
}
void SetShoalItemFlag(u16 v0)
{
FlagSet(FLAG_SYS_SHOAL_ITEM);
}
void PutZigzagoonInPlayerParty(void)
{
u16 monData;
2019-08-31 05:06:43 +02:00
CreateMon(&gPlayerParty[0], SPECIES_ZIGZAGOON, 7, 0x20, FALSE, 0, OT_ID_PLAYER_ID, 0);
monData = TRUE;
2019-05-14 15:22:16 +02:00
SetMonData(&gPlayerParty[0], MON_DATA_ABILITY_NUM, &monData);
monData = MOVE_TACKLE;
SetMonData(&gPlayerParty[0], MON_DATA_MOVE1, &monData);
monData = MOVE_NONE;
SetMonData(&gPlayerParty[0], MON_DATA_MOVE2, &monData);
SetMonData(&gPlayerParty[0], MON_DATA_MOVE3, &monData);
SetMonData(&gPlayerParty[0], MON_DATA_MOVE4, &monData);
}
bool8 IsStarterInParty(void)
{
u8 i;
u16 starter = GetStarterPokemon(VarGet(VAR_STARTER_MON));
u8 partyCount = CalculatePlayerPartyCount();
for (i = 0; i < partyCount; i++)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) == starter)
{
return TRUE;
}
}
return FALSE;
}
bool8 ScriptCheckFreePokemonStorageSpace(void)
{
return CheckFreePokemonStorageSpace();
}
bool8 IsPokerusInParty(void)
{
if (!CheckPartyPokerus(gPlayerParty, 0x3f))
{
return FALSE;
}
return TRUE;
}
void sub_8139560(void)
{
u8 taskId = CreateTask(sub_81395BC, 9);
gTasks[taskId].data[0] = gSpecialVar_0x8005;
gTasks[taskId].data[1] = 0;
gTasks[taskId].data[2] = gSpecialVar_0x8006;
gTasks[taskId].data[3] = gSpecialVar_0x8007;
gTasks[taskId].data[4] = gSpecialVar_0x8004;
SetCameraPanningCallback(NULL);
PlaySE(SE_W070);
}
static void sub_81395BC(u8 taskId)
{
s16 *data = gTasks[taskId].data;
data[1]++;
if (data[1] % data[3] == 0)
{
data[1] = 0;
data[2]--;
data[0] = -data[0];
data[4] = -data[4];
SetCameraPanning(data[0], data[4]);
if (data[2] == 0)
{
sub_8139620(taskId);
InstallCameraPanAheadCallback();
}
}
}
static void sub_8139620(u8 taskId)
{
DestroyTask(taskId);
EnableBothScriptContexts();
}
bool8 FoundBlackGlasses(void)
{
2018-10-19 20:59:18 +02:00
return FlagGet(FLAG_HIDDEN_ITEM_ROUTE_116_BLACK_GLASSES);
}
void SetRoute119Weather(void)
{
2019-03-01 07:49:11 +01:00
if (IsMapTypeOutdoors(GetLastUsedWarpMapType()) != TRUE)
{
2019-09-13 20:24:07 +02:00
SetSav1Weather(WEATHER_ROUTE119_CYCLE);
}
}
void SetRoute123Weather(void)
{
2019-03-01 07:49:11 +01:00
if (IsMapTypeOutdoors(GetLastUsedWarpMapType()) != TRUE)
{
2019-09-13 20:24:07 +02:00
SetSav1Weather(WEATHER_ROUTE123_CYCLE);
}
}
u8 GetLeadMonIndex(void)
{
u8 i;
u8 partyCount = CalculatePlayerPartyCount();
for (i = 0; i < partyCount; i++)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_EGG && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != 0)
{
return i;
}
}
return 0;
}
u16 ScriptGetPartyMonSpecies(void)
{
return GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES2, NULL);
}
2019-09-13 20:24:07 +02:00
// Removed for Emerald
void TryInitBattleTowerAwardManEventObject(void)
{
2019-09-13 20:24:07 +02:00
//TryInitLocalEventObject(6);
}
u16 GetDaysUntilPacifidlogTMAvailable(void)
{
u16 tmReceivedDay = VarGet(VAR_PACIFIDLOG_TM_RECEIVED_DAY);
if (gLocalTime.days - tmReceivedDay >= 7)
{
return 0;
}
else if (gLocalTime.days < 0)
{
return 8;
}
return 7 - (gLocalTime.days - tmReceivedDay);
}
u16 SetPacifidlogTMReceivedDay(void)
{
VarSet(VAR_PACIFIDLOG_TM_RECEIVED_DAY, gLocalTime.days);
return gLocalTime.days;
}
bool8 MonOTNameMatchesPlayer(void)
{
if (GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_LANGUAGE) != GAME_LANGUAGE)
2018-08-11 23:51:54 +02:00
{
return TRUE; // huh?
2018-08-11 23:51:54 +02:00
}
GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_OT_NAME, gStringVar1);
if (!StringCompare(gSaveBlock2Ptr->playerName, gStringVar1))
{
return FALSE;
}
return TRUE;
}
void BufferLottoTicketNumber(void)
{
if (gSpecialVar_Result >= 10000)
{
TV_PrintIntToStringVar(0, gSpecialVar_Result);
}
else if (gSpecialVar_Result >= 1000)
{
gStringVar1[0] = CHAR_0;
ConvertIntToDecimalStringN(gStringVar1 + 1, gSpecialVar_Result, 0, CountDigits(gSpecialVar_Result));
}
else if (gSpecialVar_Result >= 100)
{
gStringVar1[0] = CHAR_0;
gStringVar1[1] = CHAR_0;
ConvertIntToDecimalStringN(gStringVar1 + 2, gSpecialVar_Result, 0, CountDigits(gSpecialVar_Result));
}
else if (gSpecialVar_Result >= 10)
{
gStringVar1[0] = CHAR_0;
gStringVar1[1] = CHAR_0;
gStringVar1[2] = CHAR_0;
ConvertIntToDecimalStringN(gStringVar1 + 3, gSpecialVar_Result, 0, CountDigits(gSpecialVar_Result));
}
else
{
gStringVar1[0] = CHAR_0;
gStringVar1[1] = CHAR_0;
gStringVar1[2] = CHAR_0;
gStringVar1[3] = CHAR_0;
ConvertIntToDecimalStringN(gStringVar1 + 4, gSpecialVar_Result, 0, CountDigits(gSpecialVar_Result));
}
}
u16 sub_813986C(void)
{
switch (gSpecialVar_Result)
{
case 0:
return mevent_081445C0(3);
case 1:
return mevent_081445C0(4);
case 2:
return mevent_081445C0(0);
case 3:
return mevent_081445C0(1);
case 4:
return mevent_081445C0(2);
default:
return 0;
}
}
2019-09-13 20:24:07 +02:00
bool8 BufferTMHMMoveName(void)
{
if (gSpecialVar_0x8004 >= ITEM_TM01 && gSpecialVar_0x8004 <= ITEM_HM08)
{
StringCopy(gStringVar2, gMoveNames[ItemIdToBattleMoveId(gSpecialVar_0x8004)]);
return TRUE;
}
2018-08-19 01:06:10 +02:00
return FALSE;
}
2019-09-13 20:24:07 +02:00
bool8 IsBadEggInParty(void)
{
u8 partyCount = CalculatePlayerPartyCount();
u8 i;
for (i = 0; i < partyCount; i++)
{
2019-09-13 20:24:07 +02:00
if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_IS_BAD_EGG) == TRUE)
return TRUE;
}
return FALSE;
}
bool8 InMultiBattleRoom(void)
{
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BATTLE_FRONTIER_BATTLE_TOWER_MULTI_BATTLE_ROOM)
&& gSaveBlock1Ptr->location.mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_TOWER_MULTI_BATTLE_ROOM) &&
2018-08-25 19:59:47 +02:00
VarGet(VAR_FRONTIER_BATTLE_MODE) == FRONTIER_MODE_MULTIS)
return TRUE;
return FALSE;
}
void sub_8139980(void)
{
SetCameraPanningCallback(NULL);
SetCameraPanning(8, 0);
}
2019-09-13 20:24:07 +02:00
const struct WindowTemplate gElevatorFloor_WindowTemplate =
{
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-08-09 08:53:21 +02:00
.tilemapLeft = 21,
.tilemapTop = 1,
.width = 8,
.height = 4,
.paletteNum = 15,
.baseBlock = 8,
};
2019-09-13 20:24:07 +02:00
const u8 *const gDeptStoreFloorNames[] =
{
[DEPT_STORE_FLOORNUM_B4F] = gText_B4F,
[DEPT_STORE_FLOORNUM_B3F] = gText_B3F,
[DEPT_STORE_FLOORNUM_B2F] = gText_B2F,
[DEPT_STORE_FLOORNUM_B1F] = gText_B1F,
[DEPT_STORE_FLOORNUM_1F] = gText_1F,
[DEPT_STORE_FLOORNUM_2F] = gText_2F,
[DEPT_STORE_FLOORNUM_3F] = gText_3F,
[DEPT_STORE_FLOORNUM_4F] = gText_4F,
[DEPT_STORE_FLOORNUM_5F] = gText_5F,
[DEPT_STORE_FLOORNUM_6F] = gText_6F,
[DEPT_STORE_FLOORNUM_7F] = gText_7F,
[DEPT_STORE_FLOORNUM_8F] = gText_8F,
[DEPT_STORE_FLOORNUM_9F] = gText_9F,
[DEPT_STORE_FLOORNUM_10F] = gText_10F,
[DEPT_STORE_FLOORNUM_11F] = gText_11F,
[DEPT_STORE_FLOORNUM_ROOFTOP] = gText_Rooftop
2018-08-09 08:53:21 +02:00
};
static const u16 sElevatorWindowTiles_Ascending[][3] =
2018-11-29 21:19:00 +01:00
{
{
METATILE_ID(BattleFrontier, Elevator_Top0),
METATILE_ID(BattleFrontier, Elevator_Top1),
METATILE_ID(BattleFrontier, Elevator_Top2)
},
{
METATILE_ID(BattleFrontier, Elevator_Mid0),
METATILE_ID(BattleFrontier, Elevator_Mid1),
METATILE_ID(BattleFrontier, Elevator_Mid2)
},
{
METATILE_ID(BattleFrontier, Elevator_Bottom0),
METATILE_ID(BattleFrontier, Elevator_Bottom1),
METATILE_ID(BattleFrontier, Elevator_Bottom2)
},
2018-11-29 21:19:00 +01:00
};
static const u16 sElevatorWindowTiles_Descending[][3] =
2018-11-29 21:19:00 +01:00
{
{
METATILE_ID(BattleFrontier, Elevator_Top0),
METATILE_ID(BattleFrontier, Elevator_Top2),
METATILE_ID(BattleFrontier, Elevator_Top1)
},
{
METATILE_ID(BattleFrontier, Elevator_Mid0),
METATILE_ID(BattleFrontier, Elevator_Mid2),
METATILE_ID(BattleFrontier, Elevator_Mid1)
},
{
METATILE_ID(BattleFrontier, Elevator_Bottom0),
METATILE_ID(BattleFrontier, Elevator_Bottom2),
METATILE_ID(BattleFrontier, Elevator_Bottom1)
},
2018-11-29 21:19:00 +01:00
};
2018-08-09 08:53:21 +02:00
2019-09-13 20:24:07 +02:00
void SetDeptStoreFloor(void)
{
u8 deptStoreFloor;
2018-12-27 23:30:47 +01:00
switch (gSaveBlock1Ptr->dynamicWarp.mapNum)
{
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_1F):
2019-09-13 20:24:07 +02:00
deptStoreFloor = DEPT_STORE_FLOORNUM_1F;
break;
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_2F):
2019-09-13 20:24:07 +02:00
deptStoreFloor = DEPT_STORE_FLOORNUM_2F;
break;
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_3F):
2019-09-13 20:24:07 +02:00
deptStoreFloor = DEPT_STORE_FLOORNUM_3F;
break;
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_4F):
2019-09-13 20:24:07 +02:00
deptStoreFloor = DEPT_STORE_FLOORNUM_4F;
break;
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_5F):
2019-09-13 20:24:07 +02:00
deptStoreFloor = DEPT_STORE_FLOORNUM_5F;
break;
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP):
2019-09-13 20:24:07 +02:00
deptStoreFloor = DEPT_STORE_FLOORNUM_ROOFTOP;
break;
default:
2019-09-13 20:24:07 +02:00
deptStoreFloor = DEPT_STORE_FLOORNUM_1F;
break;
}
VarSet(VAR_DEPT_STORE_FLOOR, deptStoreFloor);
}
2018-08-09 08:53:21 +02:00
2019-09-13 20:24:07 +02:00
u16 GetDeptStoreDefaultFloorChoice(void)
2018-08-09 08:53:21 +02:00
{
2019-09-13 20:24:07 +02:00
gLilycoveDeptStore_NeverRead = 0;
gLilycoveDeptStore_DefaultFloorChoice = 0;
2018-08-09 08:53:21 +02:00
2018-12-27 23:30:47 +01:00
if (gSaveBlock1Ptr->dynamicWarp.mapGroup == MAP_GROUP(LILYCOVE_CITY_DEPARTMENT_STORE_1F))
2018-08-09 08:53:21 +02:00
{
2018-12-27 23:30:47 +01:00
switch (gSaveBlock1Ptr->dynamicWarp.mapNum)
2018-08-09 08:53:21 +02:00
{
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_5F):
2019-09-13 20:24:07 +02:00
gLilycoveDeptStore_NeverRead = 0;
gLilycoveDeptStore_DefaultFloorChoice = 0;
2018-08-09 08:53:21 +02:00
break;
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_4F):
2019-09-13 20:24:07 +02:00
gLilycoveDeptStore_NeverRead = 0;
gLilycoveDeptStore_DefaultFloorChoice = 1;
2018-08-09 08:53:21 +02:00
break;
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_3F):
2019-09-13 20:24:07 +02:00
gLilycoveDeptStore_NeverRead = 0;
gLilycoveDeptStore_DefaultFloorChoice = 2;
2018-08-09 08:53:21 +02:00
break;
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_2F):
2019-09-13 20:24:07 +02:00
gLilycoveDeptStore_NeverRead = 0;
gLilycoveDeptStore_DefaultFloorChoice = 3;
2018-08-09 08:53:21 +02:00
break;
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_1F):
2019-09-13 20:24:07 +02:00
gLilycoveDeptStore_NeverRead = 0;
gLilycoveDeptStore_DefaultFloorChoice = 4;
2018-08-09 08:53:21 +02:00
break;
}
}
2019-09-13 20:24:07 +02:00
return gLilycoveDeptStore_DefaultFloorChoice;
2018-08-09 08:53:21 +02:00
}
void ShakeScreenInElevator(void)
{
2018-08-11 23:51:54 +02:00
static const u8 gUnknown_085B2C18[] = { 0x08, 0x10, 0x18, 0x20, 0x26, 0x2e, 0x34, 0x38, 0x39 };
2018-08-09 08:53:21 +02:00
s16 *data = gTasks[CreateTask(sub_8139AF4, 9)].data;
u16 floorDelta;
data[1] = 0;
data[2] = 0;
data[4] = 1;
if (gSpecialVar_0x8005 > gSpecialVar_0x8006)
{
floorDelta = gSpecialVar_0x8005 - gSpecialVar_0x8006;
2019-09-13 20:24:07 +02:00
data[6] = TRUE;
2018-08-09 08:53:21 +02:00
}
else
{
floorDelta = gSpecialVar_0x8006 - gSpecialVar_0x8005;
2019-09-13 20:24:07 +02:00
data[6] = FALSE;
2018-08-09 08:53:21 +02:00
}
if (floorDelta > 8)
floorDelta = 8;
2018-08-19 01:06:10 +02:00
2018-08-09 08:53:21 +02:00
data[5] = gUnknown_085B2C18[floorDelta];
SetCameraPanningCallback(NULL);
sub_8139C2C(floorDelta, data[6]);
PlaySE(SE_ELEBETA);
}
2018-08-11 23:51:54 +02:00
static void sub_8139AF4(u8 taskId)
2018-08-09 08:53:21 +02:00
{
s16 *data = gTasks[taskId].data;
data[1]++;
if (data[1] % 3 == 0)
{
data[1] = 0;
data[2]++;
data[4] = -data[4];
SetCameraPanning(0, data[4]);
if (data[2] == data[5])
{
PlaySE(SE_PINPON);
DestroyTask(taskId);
EnableBothScriptContexts();
InstallCameraPanAheadCallback();
}
}
}
void sub_8139B60(void)
{
int xPos;
2018-08-19 01:06:10 +02:00
2019-09-13 20:24:07 +02:00
gUnknown_0203AB5E = AddWindow(&gElevatorFloor_WindowTemplate);
2018-08-09 08:53:21 +02:00
SetStandardWindowBorderStyle(gUnknown_0203AB5E, 0);
2018-08-19 01:06:10 +02:00
2018-08-09 08:53:21 +02:00
xPos = GetStringCenterAlignXOffset(1, gText_ElevatorNowOn, 64);
AddTextPrinterParameterized(gUnknown_0203AB5E, 1, gText_ElevatorNowOn, xPos, 1, TEXT_SPEED_FF, NULL);
2018-08-19 01:06:10 +02:00
2019-09-13 20:24:07 +02:00
xPos = GetStringCenterAlignXOffset(1, gDeptStoreFloorNames[gSpecialVar_0x8005], 64);
AddTextPrinterParameterized(gUnknown_0203AB5E, 1, gDeptStoreFloorNames[gSpecialVar_0x8005], xPos, 17, TEXT_SPEED_FF, NULL);
2018-08-19 01:06:10 +02:00
2018-08-09 08:53:21 +02:00
PutWindowTilemap(gUnknown_0203AB5E);
CopyWindowToVram(gUnknown_0203AB5E, 3);
}
void sub_8139C10(void)
{
ClearStdWindowAndFrameToTransparent(gUnknown_0203AB5E, TRUE);
2018-08-09 08:53:21 +02:00
RemoveWindow(gUnknown_0203AB5E);
}
static void sub_8139C2C(u16 a1, bool8 descending)
2018-08-09 08:53:21 +02:00
{
2018-08-11 23:51:54 +02:00
static const u8 gUnknown_085B2C21[] = { 0x03, 0x06, 0x09, 0x0c, 0x0f, 0x12, 0x15, 0x18, 0x1b };
if (FuncIsActiveTask(MoveElevatorWindowLights) != TRUE)
2018-08-09 08:53:21 +02:00
{
u8 taskId = CreateTask(MoveElevatorWindowLights, 8);
2018-08-09 08:53:21 +02:00
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[1] = 0;
gTasks[taskId].data[2] = descending;
2018-08-09 08:53:21 +02:00
gTasks[taskId].data[3] = gUnknown_085B2C21[a1];
}
}
static void MoveElevatorWindowLights(u8 taskId)
2018-08-09 08:53:21 +02:00
{
u8 x, y;
s16 *data = gTasks[taskId].data;
if (data[1] == 6)
{
data[0]++;
2019-09-13 20:24:07 +02:00
// ascending
if (data[2] == FALSE)
2018-08-09 08:53:21 +02:00
{
for (y = 0; y < 3; y++)
{
for (x = 0; x < 3; x++)
{
MapGridSetMetatileIdAt(x + 8, y + 7, sElevatorWindowTiles_Ascending[y][data[0] % 3] | METATILE_COLLISION_MASK);
2018-08-09 08:53:21 +02:00
}
}
}
2019-09-13 20:24:07 +02:00
// descending
2018-08-09 08:53:21 +02:00
else
{
for (y = 0; y < 3; y++)
{
for (x = 0; x < 3; x++)
{
MapGridSetMetatileIdAt(x + 8, y + 7, sElevatorWindowTiles_Descending[y][data[0] % 3] | METATILE_COLLISION_MASK);
2018-08-09 08:53:21 +02:00
}
}
}
DrawWholeMapView();
data[1] = 0;
if (data[0] == data[3])
{
DestroyTask(taskId);
}
}
data[1]++;
}
void sub_8139D98(void)
{
u8 i;
2018-11-18 20:00:36 +01:00
u32 ivStorage[NUM_STATS];
2018-08-09 08:53:21 +02:00
2018-11-18 20:00:36 +01:00
ivStorage[STAT_HP] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_HP_IV);
ivStorage[STAT_ATK] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_ATK_IV);
ivStorage[STAT_DEF] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_DEF_IV);
ivStorage[STAT_SPEED] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPEED_IV);
ivStorage[STAT_SPATK] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPATK_IV);
ivStorage[STAT_SPDEF] = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPDEF_IV);
2018-08-09 08:53:21 +02:00
gSpecialVar_0x8005 = 0;
2018-11-18 20:00:36 +01:00
for (i = 0; i < NUM_STATS; i++)
2018-08-09 08:53:21 +02:00
{
gSpecialVar_0x8005 += ivStorage[i];
}
gSpecialVar_0x8006 = 0;
2018-11-29 21:19:00 +01:00
gSpecialVar_0x8007 = ivStorage[STAT_HP];
2018-08-09 08:53:21 +02:00
2018-11-18 20:00:36 +01:00
for (i = 1; i < NUM_STATS; i++)
2018-08-09 08:53:21 +02:00
{
if (ivStorage[gSpecialVar_0x8006] < ivStorage[i])
{
gSpecialVar_0x8006 = i;
gSpecialVar_0x8007 = ivStorage[i];
}
else if (ivStorage[gSpecialVar_0x8006] == ivStorage[i])
{
u16 randomNumber = Random();
2018-11-18 20:00:36 +01:00
if (randomNumber & 1)
2018-08-09 08:53:21 +02:00
{
gSpecialVar_0x8006 = i;
gSpecialVar_0x8007 = ivStorage[i];
}
}
}
}
2019-09-13 20:24:07 +02:00
bool8 UsedPokemonCenterWarp(void)
{
static const u16 sPokemonCenters[] =
{
MAP_OLDALE_TOWN_POKEMON_CENTER_1F,
MAP_DEWFORD_TOWN_POKEMON_CENTER_1F,
MAP_LAVARIDGE_TOWN_POKEMON_CENTER_1F,
MAP_FALLARBOR_TOWN_POKEMON_CENTER_1F,
MAP_VERDANTURF_TOWN_POKEMON_CENTER_1F,
MAP_PACIFIDLOG_TOWN_POKEMON_CENTER_1F,
MAP_PETALBURG_CITY_POKEMON_CENTER_1F,
MAP_SLATEPORT_CITY_POKEMON_CENTER_1F,
MAP_MAUVILLE_CITY_POKEMON_CENTER_1F,
MAP_RUSTBORO_CITY_POKEMON_CENTER_1F,
MAP_FORTREE_CITY_POKEMON_CENTER_1F,
MAP_LILYCOVE_CITY_POKEMON_CENTER_1F,
MAP_MOSSDEEP_CITY_POKEMON_CENTER_1F,
MAP_SOOTOPOLIS_CITY_POKEMON_CENTER_1F,
MAP_EVER_GRANDE_CITY_POKEMON_CENTER_1F,
MAP_EVER_GRANDE_CITY_POKEMON_LEAGUE_1F,
MAP_BATTLE_FRONTIER_POKEMON_CENTER_1F,
MAP_UNION_ROOM,
0xFFFF
};
2018-08-11 23:51:54 +02:00
2018-08-09 08:53:21 +02:00
int i;
u16 map = (gLastUsedWarp.mapGroup << 8) + gLastUsedWarp.mapNum;
2018-08-09 08:53:21 +02:00
2019-09-13 20:24:07 +02:00
for (i = 0; sPokemonCenters[i] != 0xFFFF; i++)
2018-08-09 08:53:21 +02:00
{
2019-09-13 20:24:07 +02:00
if (sPokemonCenters[i] == map)
2018-08-09 08:53:21 +02:00
return TRUE;
}
return FALSE;
}
bool32 sub_8139ED0(void)
{
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRAINER_HILL_ENTRANCE) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRAINER_HILL_ENTRANCE))
{
return FALSE;
}
return TRUE;
}
2019-09-13 20:24:07 +02:00
void UpdateFrontierManiac(u16 daysSince)
2018-08-09 08:53:21 +02:00
{
u16 *var = GetVarPointer(VAR_FRONTIER_MANIAC_FACILITY);
2019-09-13 20:24:07 +02:00
*var += daysSince;
2018-08-09 08:53:21 +02:00
*var %= 10;
}
void sub_8139F20(void)
{
2019-09-13 20:24:07 +02:00
static const u8 *const gUnknown_085B2C50[][3] =
{
2018-08-11 23:51:54 +02:00
{ BattleFrontier_Lounge2_Text_260971, BattleFrontier_Lounge2_Text_260A1E, BattleFrontier_Lounge2_Text_260AE7 },
{ BattleFrontier_Lounge2_Text_2619AC, BattleFrontier_Lounge2_Text_261A91, BattleFrontier_Lounge2_Text_261B0C },
{ BattleFrontier_Lounge2_Text_261B95, BattleFrontier_Lounge2_Text_261B95, BattleFrontier_Lounge2_Text_261B95 },
{ BattleFrontier_Lounge2_Text_261C1A, BattleFrontier_Lounge2_Text_261C1A, BattleFrontier_Lounge2_Text_261C1A },
{ BattleFrontier_Lounge2_Text_260BC4, BattleFrontier_Lounge2_Text_260C6D, BattleFrontier_Lounge2_Text_260D3A },
{ BattleFrontier_Lounge2_Text_260E1E, BattleFrontier_Lounge2_Text_260EC7, BattleFrontier_Lounge2_Text_260F74 },
{ BattleFrontier_Lounge2_Text_2614E6, BattleFrontier_Lounge2_Text_261591, BattleFrontier_Lounge2_Text_26166F },
{ BattleFrontier_Lounge2_Text_261282, BattleFrontier_Lounge2_Text_261329, BattleFrontier_Lounge2_Text_261403 },
{ BattleFrontier_Lounge2_Text_261026, BattleFrontier_Lounge2_Text_2610CC, BattleFrontier_Lounge2_Text_261194 },
{ BattleFrontier_Lounge2_Text_26174D, BattleFrontier_Lounge2_Text_2617F9, BattleFrontier_Lounge2_Text_2618C4 },
};
2019-09-13 20:24:07 +02:00
static const u8 gUnknown_085B2CC8[][2] =
{
2018-08-11 23:51:54 +02:00
{ 0x15, 0x38 },
{ 0x15, 0x23 },
{ 0xff, 0xff },
{ 0xff, 0xff },
{ 0x02, 0x04 },
{ 0x07, 0x15 },
{ 0x07, 0x15 },
{ 0x0e, 0x1c },
{ 0x0d, 0x70 },
{ 0x07, 0x38 }
};
2018-08-09 08:53:21 +02:00
u8 i;
2019-09-13 20:24:07 +02:00
u16 winStreak = 0;
2018-08-09 08:53:21 +02:00
u16 var = VarGet(VAR_FRONTIER_MANIAC_FACILITY);
2019-09-13 20:24:07 +02:00
2018-08-09 08:53:21 +02:00
switch (var)
{
2019-09-13 20:24:07 +02:00
case 0 ... 3:
if (gSaveBlock2Ptr->frontier.towerWinStreaks[var][FRONTIER_LVL_50]
>= gSaveBlock2Ptr->frontier.towerWinStreaks[var][FRONTIER_LVL_OPEN])
2018-08-09 08:53:21 +02:00
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.towerWinStreaks[var][FRONTIER_LVL_50];
2018-08-09 08:53:21 +02:00
}
else
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.towerWinStreaks[var][FRONTIER_LVL_OPEN];
2018-08-09 08:53:21 +02:00
}
break;
case 4:
2019-09-13 20:24:07 +02:00
if (gSaveBlock2Ptr->frontier.domeWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_50]
>= gSaveBlock2Ptr->frontier.domeWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_OPEN])
2018-08-09 08:53:21 +02:00
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.domeWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_50];
2018-08-09 08:53:21 +02:00
}
else
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.domeWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_OPEN];
2018-08-09 08:53:21 +02:00
}
break;
case 5:
2019-09-13 20:24:07 +02:00
if (gSaveBlock2Ptr->frontier.factoryWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_50]
>= gSaveBlock2Ptr->frontier.factoryWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_OPEN])
2018-08-09 08:53:21 +02:00
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.factoryWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_50];
2018-08-09 08:53:21 +02:00
}
else
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.factoryWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_OPEN];
2018-08-09 08:53:21 +02:00
}
break;
case 6:
2019-09-13 20:24:07 +02:00
if (gSaveBlock2Ptr->frontier.palaceWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_50]
>= gSaveBlock2Ptr->frontier.palaceWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_OPEN])
2018-08-09 08:53:21 +02:00
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.palaceWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_50];
2018-08-09 08:53:21 +02:00
}
else
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.palaceWinStreaks[FRONTIER_MODE_SINGLES][FRONTIER_LVL_OPEN];
2018-08-09 08:53:21 +02:00
}
break;
case 7:
2019-09-13 20:24:07 +02:00
if (gSaveBlock2Ptr->frontier.arenaWinStreaks[FRONTIER_LVL_50]
>= gSaveBlock2Ptr->frontier.arenaWinStreaks[FRONTIER_LVL_OPEN])
2018-08-09 08:53:21 +02:00
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.arenaWinStreaks[FRONTIER_LVL_50];
2018-08-09 08:53:21 +02:00
}
else
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.arenaWinStreaks[FRONTIER_LVL_OPEN];
2018-08-09 08:53:21 +02:00
}
break;
case 8:
2019-09-13 20:24:07 +02:00
if (gSaveBlock2Ptr->frontier.pikeWinStreaks[FRONTIER_LVL_50]
>= gSaveBlock2Ptr->frontier.pikeWinStreaks[FRONTIER_LVL_OPEN])
2018-08-09 08:53:21 +02:00
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.pikeWinStreaks[FRONTIER_LVL_50];
2018-08-09 08:53:21 +02:00
}
else
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.pikeWinStreaks[FRONTIER_LVL_OPEN];
2018-08-09 08:53:21 +02:00
}
break;
case 9:
2019-09-13 20:24:07 +02:00
if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[FRONTIER_LVL_50]
>= gSaveBlock2Ptr->frontier.pyramidWinStreaks[FRONTIER_LVL_OPEN])
2018-08-09 08:53:21 +02:00
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.pyramidWinStreaks[FRONTIER_LVL_50];
2018-08-09 08:53:21 +02:00
}
else
{
2019-09-13 20:24:07 +02:00
winStreak = gSaveBlock2Ptr->frontier.pyramidWinStreaks[FRONTIER_LVL_OPEN];
2018-08-09 08:53:21 +02:00
}
break;
}
2019-09-13 20:24:07 +02:00
for (i = 0; i < 2 && gUnknown_085B2CC8[var][i] < winStreak; i++);
2018-08-09 08:53:21 +02:00
ShowFieldMessage(gUnknown_085B2C50[var][i]);
}
2019-09-13 20:24:07 +02:00
// gSpecialVar_0x8005 and 0x8006 here are used by ShakeScreenInElevator
2018-08-09 08:53:21 +02:00
void sub_813A080(void)
{
2018-08-11 23:51:54 +02:00
static const u16 gUnknown_085B2CDC[] = {
0x0007, 0x000e, 0x0015, 0x001c, 0x0023, 0x0031, 0x003f, 0x004d, 0x005b, 0x0000
};
2018-08-09 08:53:21 +02:00
u8 i;
2018-08-25 19:59:47 +02:00
u16 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
2018-08-09 08:53:21 +02:00
2019-01-02 22:12:43 +01:00
if (battleMode == FRONTIER_MODE_MULTIS && !FlagGet(FLAG_CHOSEN_MULTI_BATTLE_NPC_PARTNER))
2018-08-09 08:53:21 +02:00
{
gSpecialVar_0x8005 = 5;
gSpecialVar_0x8006 = 4;
return;
}
2019-09-13 20:24:07 +02:00
for (i = 0; i < ARRAY_COUNT(gUnknown_085B2CDC) - 1; i++)
2018-08-09 08:53:21 +02:00
{
2018-10-30 22:17:03 +01:00
if (gUnknown_085B2CDC[i] > gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode])
2018-08-09 08:53:21 +02:00
{
gSpecialVar_0x8005 = 4;
gSpecialVar_0x8006 = i + 5;
return;
}
}
gSpecialVar_0x8005 = 4;
gSpecialVar_0x8006 = 12;
}
2019-09-13 20:24:07 +02:00
// data[1]: number of options in the multichoice
void ShowScrollableMultichoice(void)
2018-08-09 08:53:21 +02:00
{
u8 taskId = CreateTask(sub_813A2DC, 8);
struct Task *task = &gTasks[taskId];
task->data[11] = gSpecialVar_0x8004;
switch (gSpecialVar_0x8004)
{
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_NONE:
2018-08-09 08:53:21 +02:00
task->data[0] = 1;
task->data[1] = 1;
task->data[2] = 1;
task->data[3] = 1;
task->data[4] = 1;
task->data[5] = 1;
task->data[6] = 0;
task->data[15] = taskId;
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_GLASS_WORKSHOP_VENDOR:
2018-08-09 08:53:21 +02:00
task->data[0] = 5;
task->data[1] = 8;
task->data[2] = 1;
task->data[3] = 1;
task->data[4] = 9;
task->data[5] = 10;
task->data[6] = 0;
task->data[15] = taskId;
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_POKEMON_FAN_CLUB_RATER:
2018-08-09 08:53:21 +02:00
task->data[0] = 6;
task->data[1] = 12;
task->data[2] = 1;
task->data[3] = 1;
task->data[4] = 7;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_1:
2018-08-09 08:53:21 +02:00
task->data[0] = 6;
task->data[1] = 11;
task->data[2] = 14;
task->data[3] = 1;
task->data[4] = 15;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_2:
2018-08-09 08:53:21 +02:00
task->data[0] = 6;
task->data[1] = 6;
task->data[2] = 14;
task->data[3] = 1;
task->data[4] = 15;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BF_EXCHANGE_CORNER_VITAMIN_VENDOR:
2018-08-09 08:53:21 +02:00
task->data[0] = 6;
task->data[1] = 7;
task->data[2] = 14;
task->data[3] = 1;
task->data[4] = 15;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BF_EXCHANGE_CORNER_HOLD_ITEM_VENDOR:
2018-08-09 08:53:21 +02:00
task->data[0] = 6;
task->data[1] = 10;
task->data[2] = 14;
task->data[3] = 1;
task->data[4] = 15;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BERRY_POWDER_VENDOR:
2018-08-09 08:53:21 +02:00
task->data[0] = 6;
task->data[1] = 12;
task->data[2] = 15;
task->data[3] = 1;
task->data[4] = 14;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BF_RECEPTIONIST:
2018-08-09 08:53:21 +02:00
task->data[0] = 6;
task->data[1] = 10;
task->data[2] = 17;
task->data[3] = 1;
task->data[4] = 11;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BF_MOVE_TUTOR_1:
case SCROLL_MULTI_BF_MOVE_TUTOR_2:
2018-08-09 08:53:21 +02:00
task->data[0] = 6;
task->data[1] = 11;
task->data[2] = 15;
task->data[3] = 1;
task->data[4] = 14;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_SS_TIDAL_DESTINATION:
2018-08-09 08:53:21 +02:00
task->data[0] = 6;
task->data[1] = 7;
task->data[2] = 19;
task->data[3] = 1;
task->data[4] = 10;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BATTLE_TENT_RULES:
2018-08-09 08:53:21 +02:00
task->data[0] = 6;
task->data[1] = 7;
task->data[2] = 17;
task->data[3] = 1;
task->data[4] = 12;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
break;
default:
gSpecialVar_Result = 0x7F;
DestroyTask(taskId);
break;
}
}
2019-09-13 20:24:07 +02:00
static const u8 *const sScrollableMenuOptions[][MAX_SCROLL_MULTI_LENGTH] =
{
[SCROLL_MULTI_NONE] =
2018-08-09 08:53:21 +02:00
{
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_GLASS_WORKSHOP_VENDOR] =
2018-08-09 08:53:21 +02:00
{
gText_BlueFlute,
gText_YellowFlute,
gText_RedFlute,
gText_WhiteFlute,
gText_BlackFlute,
gText_PrettyChair,
gText_PrettyDesk,
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_POKEMON_FAN_CLUB_RATER] =
2018-08-09 08:53:21 +02:00
{
gText_0Pts,
gText_10Pts,
gText_20Pts,
gText_30Pts,
gText_40Pts,
gText_50Pts,
gText_60Pts,
gText_70Pts,
gText_80Pts,
gText_90Pts,
gText_100Pts,
2019-09-13 20:24:07 +02:00
gText_QuestionMark
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_1] =
2018-08-09 08:53:21 +02:00
{
gText_KissPoster16BP,
gText_KissCushion32BP,
gText_SmoochumDoll32BP,
gText_TogepiDoll48BP,
gText_MeowthDoll48BP,
gText_ClefairyDoll48BP,
gText_DittoDoll48BP,
gText_CyndaquilDoll80BP,
gText_ChikoritaDoll80BP,
gText_TotodileDoll80BP,
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_2] =
2018-08-09 08:53:21 +02:00
{
gText_LaprasDoll128BP,
gText_SnorlaxDoll128BP,
gText_VenusaurDoll256BP,
gText_CharizardDoll256BP,
gText_BlastoiseDoll256BP,
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_BF_EXCHANGE_CORNER_VITAMIN_VENDOR] =
2018-08-09 08:53:21 +02:00
{
gText_Protein1BP,
gText_Calcium1BP,
gText_Iron1BP,
gText_Zinc1BP,
gText_Carbos1BP,
gText_HpUp1BP,
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_BF_EXCHANGE_CORNER_HOLD_ITEM_VENDOR] =
2018-08-09 08:53:21 +02:00
{
gText_Leftovers48BP,
gText_WhiteHerb48BP,
gText_QuickClaw48BP,
gText_MentalHerb48BP,
gText_BrightPowder64BP,
gText_ChoiceBand64BP,
gText_KingsRock64BP,
gText_FocusBand64BP,
gText_ScopeLens64BP,
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_BERRY_POWDER_VENDOR] =
2018-08-09 08:53:21 +02:00
{
gText_EnergyPowder50,
gText_EnergyRoot80,
gText_HealPowder50,
gText_RevivalHerb300,
gText_Protein1000,
gText_Iron1000,
gText_Carbos1000,
gText_Calcium1000,
gText_Zinc1000,
gText_HPUp1000,
gText_PPUp3000,
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_BF_RECEPTIONIST] =
2018-08-09 08:53:21 +02:00
{
gText_BattleTower2,
gText_BattleDome,
gText_BattlePalace,
gText_BattleArena,
gText_BattleFactory,
gText_BattlePike,
gText_BattlePyramid,
gText_RankingHall,
gText_ExchangeService,
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_BF_MOVE_TUTOR_1] =
2018-08-09 08:53:21 +02:00
{
gText_Softboiled16BP,
gText_SeismicToss24BP,
gText_DreamEater24BP,
gText_MegaPunch24BP,
gText_MegaKick48BP,
gText_BodySlam48BP,
gText_RockSlide48BP,
gText_Counter48BP,
gText_ThunderWave48BP,
gText_SwordsDance48BP,
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_BF_MOVE_TUTOR_2] =
2018-08-09 08:53:21 +02:00
{
gText_DefenseCurl16BP,
gText_Snore24BP,
gText_MudSlap24BP,
gText_Swift24BP,
gText_IcyWind24BP,
gText_Endure48BP,
gText_PsychUp48BP,
gText_IcePunch48BP,
gText_ThunderPunch48BP,
gText_FirePunch48BP,
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_SS_TIDAL_DESTINATION] =
2018-08-09 08:53:21 +02:00
{
gText_SlateportCity,
gText_BattleFrontier,
gText_SouthernIsland,
gText_NavelRock,
gText_BirthIsland,
gText_FarawayIsland,
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
},
2019-09-13 20:24:07 +02:00
[SCROLL_MULTI_BATTLE_TENT_RULES] =
2018-08-09 08:53:21 +02:00
{
gText_BattleTrainers,
gText_BattleBasics,
gText_PokemonNature,
gText_PokemonMoves,
gText_Underpowered,
gText_WhenInDanger,
2019-09-13 20:24:07 +02:00
gText_Exit
2018-08-09 08:53:21 +02:00
}
};
2018-08-11 23:51:54 +02:00
static void sub_813A2DC(u8 taskId)
2018-08-09 08:53:21 +02:00
{
u32 unk1;
u8 i, windowId;
struct WindowTemplate template;
struct Task *task = &gTasks[taskId];
ScriptContext2_Enable();
gUnknown_0203AB68 = 0;
2019-09-13 20:24:07 +02:00
gScrollableMultichoiceSprite = MAX_SPRITES;
2018-08-09 08:53:21 +02:00
sub_813AA60(task->data[11], 0);
2019-09-13 20:24:07 +02:00
ShowBattleFrontierTutorWindow(task->data[11], 0);
2018-08-09 08:53:21 +02:00
gUnknown_0203AB64 = AllocZeroed(task->data[1] * 8);
gUnknown_0203AB6A = 0;
sub_813A42C();
for (unk1 = 0, i = 0; i < task->data[1]; i++)
{
2019-09-13 20:24:07 +02:00
const u8 *text = sScrollableMenuOptions[gSpecialVar_0x8004][i];
2018-08-09 08:53:21 +02:00
gUnknown_0203AB64[i].name = text;
gUnknown_0203AB64[i].id = i;
unk1 = display_text_and_get_width(text, unk1);
}
task->data[4] = convert_pixel_width_to_tile_width(unk1);
2018-08-19 01:06:10 +02:00
if (task->data[2] + task->data[4] > 0x1D)
2018-08-09 08:53:21 +02:00
{
int unk2 = 0x1D - task->data[4];
if (unk2 < 0)
{
task->data[2] = 0;
}
else
{
task->data[2] = unk2;
}
}
template = CreateWindowTemplate(0, task->data[2], task->data[3], task->data[4], task->data[5], 0xF, 0x64);
windowId = AddWindow(&template);
task->data[13] = windowId;
SetStandardWindowBorderStyle(windowId, 0);
gUnknown_030061D0.totalItems = task->data[1];
gUnknown_030061D0.maxShowed = task->data[0];
gUnknown_030061D0.windowId = task->data[13];
sub_813A694(taskId);
task->data[14] = ListMenuInit(&gUnknown_030061D0, task->data[7], task->data[8]);
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].func = sub_813A4EC;
}
2018-08-11 23:51:54 +02:00
static void sub_813A42C(void)
2018-08-09 08:53:21 +02:00
{
gUnknown_030061D0.items = gUnknown_0203AB64;
gUnknown_030061D0.moveCursorFunc = sub_813A46C;
gUnknown_030061D0.itemPrintFunc = NULL;
gUnknown_030061D0.totalItems = 1;
gUnknown_030061D0.maxShowed = 1;
gUnknown_030061D0.windowId = 0;
gUnknown_030061D0.header_X = 0;
gUnknown_030061D0.item_X = 8;
gUnknown_030061D0.cursor_X = 0;
gUnknown_030061D0.upText_Y = 1;
gUnknown_030061D0.cursorPal = 2;
gUnknown_030061D0.fillValue = 1;
gUnknown_030061D0.cursorShadowPal = 3;
gUnknown_030061D0.lettersSpacing = 0;
gUnknown_030061D0.itemVerticalPadding = 0;
gUnknown_030061D0.scrollMultiple = 0;
gUnknown_030061D0.fontId = 1;
gUnknown_030061D0.cursorKind = 0;
}
2018-08-11 23:51:54 +02:00
static void sub_813A46C(s32 itemIndex, bool8 onInit, struct ListMenu *list)
2018-08-09 08:53:21 +02:00
{
u8 taskId;
PlaySE(SE_SELECT);
taskId = FindTaskIdByFunc(sub_813A4EC);
if (taskId != 0xFF)
{
2019-09-13 20:24:07 +02:00
u16 selection;
2018-08-09 08:53:21 +02:00
struct Task *task = &gTasks[taskId];
2019-09-13 20:24:07 +02:00
ListMenuGetScrollAndRow(task->data[14], &selection, NULL);
gUnknown_0203AB68 = selection;
ListMenuGetCurrentItemArrayId(task->data[14], &selection);
2018-08-09 08:53:21 +02:00
sub_813AC44(task->data[11], gUnknown_0203AB6A);
2019-09-13 20:24:07 +02:00
sub_813AA60(task->data[11], selection);
ShowBattleFrontierTutorMoveDescription(task->data[11], selection);
gUnknown_0203AB6A = selection;
2018-08-09 08:53:21 +02:00
}
}
2018-08-10 09:42:06 +02:00
2018-08-11 23:51:54 +02:00
static void sub_813A4EC(u8 taskId)
2018-08-10 09:42:06 +02:00
{
struct Task *task = &gTasks[taskId];
2019-02-02 11:04:38 +01:00
s32 input = ListMenu_ProcessInput(task->data[14]);
2018-08-10 09:42:06 +02:00
2019-02-02 11:04:38 +01:00
switch (input)
2018-08-10 09:42:06 +02:00
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_CANCEL:
2018-08-10 09:42:06 +02:00
gSpecialVar_Result = 0x7F;
PlaySE(SE_SELECT);
sub_813A570(taskId);
break;
default:
2019-02-02 11:04:38 +01:00
gSpecialVar_Result = input;
2018-08-10 09:42:06 +02:00
PlaySE(SE_SELECT);
if (!task->data[6])
{
sub_813A570(taskId);
}
2019-02-02 11:04:38 +01:00
else if (input == task->data[1] - 1)
2018-08-10 09:42:06 +02:00
{
2018-08-11 23:51:54 +02:00
sub_813A570(taskId);
}
else
{
sub_813A738(taskId);
task->func = sub_813A600;
EnableBothScriptContexts();
2018-08-10 09:42:06 +02:00
}
break;
}
}
2018-08-11 23:51:54 +02:00
static void sub_813A570(u8 taskId)
2018-08-10 09:42:06 +02:00
{
u16 array;
struct Task *task = &gTasks[taskId];
ListMenuGetCurrentItemArrayId(task->data[14], &array);
sub_813AC44(task->data[11], array);
sub_813A738(taskId);
DestroyListMenuTask(task->data[14], NULL, NULL);
Free(gUnknown_0203AB64);
ClearStdWindowAndFrameToTransparent(task->data[13], 1);
FillWindowPixelBuffer(task->data[13], PIXEL_FILL(0));
2018-08-10 09:42:06 +02:00
CopyWindowToVram(task->data[13], 2);
RemoveWindow(task->data[13]);
DestroyTask(taskId);
EnableBothScriptContexts();
}
2018-08-11 23:51:54 +02:00
static void sub_813A600(u8 taskId)
2018-08-10 09:42:06 +02:00
{
switch (gTasks[taskId].data[6])
{
case 1:
default:
break;
case 2:
gTasks[taskId].data[6] = 1;
gTasks[taskId].func = sub_813A664;
break;
}
}
void sub_813A630(void)
{
u8 taskId = FindTaskIdByFunc(sub_813A600);
if (taskId == 0xFF)
{
EnableBothScriptContexts();
}
else
{
gTasks[taskId].data[6]++;
}
}
2018-08-11 23:51:54 +02:00
static void sub_813A664(u8 taskId)
2018-08-10 09:42:06 +02:00
{
ScriptContext2_Enable();
sub_813A694(taskId);
gTasks[taskId].func = sub_813A4EC;
}
2018-08-11 23:51:54 +02:00
static void sub_813A694(u8 taskId)
{
static const struct ScrollArrowsTemplate gUnknown_085B3030 = {
.firstArrowType = SCROLL_ARROW_UP,
2018-08-11 23:51:54 +02:00
.firstX = 0,
.firstY = 0,
.secondArrowType = SCROLL_ARROW_DOWN,
2018-08-11 23:51:54 +02:00
.secondX = 0,
.secondY = 0,
.fullyUpThreshold = 0,
.fullyDownThreshold = 0,
.tileTag = 2000,
.palTag = 100,
.palNum = 0
};
2018-08-10 09:42:06 +02:00
struct Task *task = &gTasks[taskId];
struct ScrollArrowsTemplate template = gUnknown_085B3030;
if (task->data[0] != task->data[1])
{
template.firstX = (task->data[4] / 2) * 8 + 12 + (task->data[2] - 1) * 8;
template.firstY = 8;
template.secondX = (task->data[4] / 2) * 8 + 12 + (task->data[2] - 1) * 8;
template.secondY = task->data[5] * 8 + 10;
template.fullyUpThreshold = 0;
template.fullyDownThreshold = task->data[1] - task->data[0];
task->data[12] = AddScrollIndicatorArrowPair(&template, &gUnknown_0203AB68);
}
}
2018-08-11 23:51:54 +02:00
static void sub_813A738(u8 taskId)
2018-08-10 09:42:06 +02:00
{
struct Task *task = &gTasks[taskId];
if (task->data[0] != task->data[1])
{
RemoveScrollIndicatorArrowPair(task->data[12]);
}
}
2019-09-13 20:24:07 +02:00
// Removed for Emerald (replaced by ShowScrollableMultichoice)
void ShowGlassWorkshopMenu(void)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
/*
u8 i;
ScriptContext2_Enable();
Menu_DrawStdWindowFrame(0, 0, 10, 11);
InitMenu(0, 1, 1, 5, 0, 9);
gUnknown_0203925C = 0;
ClearVerticalScrollIndicatorPalettes();
LoadScrollIndicatorPalette();
sub_810F2B4();
for (i = 0; i < 5; i++)
{
Menu_PrintText(gUnknown_083F83C0[i], 1, 2 * i + 1);
}
gUnknown_0203925B = 0;
gUnknown_0203925A = ARRAY_COUNT(gUnknown_083F83C0);
CreateTask(sub_810F118, 8);
*/
2018-08-10 09:42:06 +02:00
}
void sub_813A76C(void)
{
u8 i;
for (i = 0; i < 2; i++)
{
if (gLinkPlayers[i].gender == MALE)
{
VarSet(VAR_OBJ_GFX_ID_F - i, EVENT_OBJ_GFX_BRENDAN_NORMAL);
}
else
{
VarSet(VAR_OBJ_GFX_ID_F - i, EVENT_OBJ_GFX_RIVAL_MAY_NORMAL);
}
}
}
void sub_813A7B8(void)
{
2018-08-11 23:51:54 +02:00
static const u8 *const gUnknown_085B3040[] = {
BattleFrontier_Lounge5_Text_26468D,
BattleFrontier_Lounge5_Text_2646E5,
BattleFrontier_Lounge5_Text_264741,
BattleFrontier_Lounge5_Text_2647A4,
BattleFrontier_Lounge5_Text_2647FC,
BattleFrontier_Lounge5_Text_264858,
BattleFrontier_Lounge5_Text_2648BE,
BattleFrontier_Lounge5_Text_264916,
BattleFrontier_Lounge5_Text_264972,
BattleFrontier_Lounge5_Text_2649D5,
BattleFrontier_Lounge5_Text_264A3F,
BattleFrontier_Lounge5_Text_264A9B,
BattleFrontier_Lounge5_Text_264AF3,
BattleFrontier_Lounge5_Text_264B5D,
BattleFrontier_Lounge5_Text_2648BE,
BattleFrontier_Lounge5_Text_264BC3,
BattleFrontier_Lounge5_Text_264C36,
BattleFrontier_Lounge5_Text_2648BE,
BattleFrontier_Lounge5_Text_264C95,
BattleFrontier_Lounge5_Text_264D01,
BattleFrontier_Lounge5_Text_264D6B,
BattleFrontier_Lounge5_Text_264DD7,
BattleFrontier_Lounge5_Text_264E33,
BattleFrontier_Lounge5_Text_264E8F,
BattleFrontier_Lounge5_Text_2648BE,
};
2018-08-10 09:42:06 +02:00
u8 nature;
if (gSpecialVar_0x8004 >= PARTY_SIZE)
{
gSpecialVar_0x8004 = 0;
}
nature = GetNature(&gPlayerParty[gSpecialVar_0x8004]);
ShowFieldMessage(gUnknown_085B3040[nature]);
}
void UpdateFrontierGambler(u16 a0)
{
u16 *var = GetVarPointer(VAR_FRONTIER_GAMBLER_FACILITY);
*var += a0;
*var %= 12;
}
void sub_813A820(void)
{
2019-09-13 20:24:07 +02:00
static const u8 *const gUnknown_085B30A4[] =
{
2018-08-11 23:51:54 +02:00
BattleFrontier_Lounge3_Text_262261,
BattleFrontier_Lounge3_Text_26230D,
BattleFrontier_Lounge3_Text_2623B9,
BattleFrontier_Lounge3_Text_262464,
BattleFrontier_Lounge3_Text_26250E,
BattleFrontier_Lounge3_Text_2625B8,
BattleFrontier_Lounge3_Text_26266A,
BattleFrontier_Lounge3_Text_26271C,
BattleFrontier_Lounge3_Text_2627C9,
BattleFrontier_Lounge3_Text_262876,
BattleFrontier_Lounge3_Text_26291A,
BattleFrontier_Lounge3_Text_2629BC,
};
2018-08-10 09:42:06 +02:00
u16 var = VarGet(VAR_FRONTIER_GAMBLER_FACILITY);
ShowFieldMessage(gUnknown_085B30A4[var]);
VarSet(VAR_FRONTIER_GAMBLER_SET_FACILITY_F, var);
}
void sub_813A854(void)
{
2019-09-13 20:24:07 +02:00
static const u8 *const gUnknown_085B30D4[] =
{
2018-08-11 23:51:54 +02:00
BattleFrontier_Lounge3_Text_262C04,
BattleFrontier_Lounge3_Text_262C90,
BattleFrontier_Lounge3_Text_262D1C,
BattleFrontier_Lounge3_Text_262DA7,
BattleFrontier_Lounge3_Text_262E34,
BattleFrontier_Lounge3_Text_262EC1,
BattleFrontier_Lounge3_Text_262F56,
BattleFrontier_Lounge3_Text_262FEB,
BattleFrontier_Lounge3_Text_263078,
BattleFrontier_Lounge3_Text_263105,
BattleFrontier_Lounge3_Text_26318C,
BattleFrontier_Lounge3_Text_263211,
};
2018-08-10 09:42:06 +02:00
ShowFieldMessage(gUnknown_085B30D4[VarGet(VAR_FRONTIER_GAMBLER_SET_FACILITY_F)]);
}
void sub_813A878(u8 a0)
{
2019-09-13 20:24:07 +02:00
static const u16 sFrontierChallenges[] =
{
FRONTIER_CHALLENGE(FRONTIER_FACILITY_TOWER, FRONTIER_MODE_SINGLES),
FRONTIER_CHALLENGE(FRONTIER_FACILITY_TOWER, FRONTIER_MODE_DOUBLES),
FRONTIER_CHALLENGE(FRONTIER_FACILITY_TOWER, FRONTIER_MODE_MULTIS),
FRONTIER_CHALLENGE(FRONTIER_FACILITY_DOME, FRONTIER_MODE_SINGLES),
FRONTIER_CHALLENGE(FRONTIER_FACILITY_DOME, FRONTIER_MODE_DOUBLES),
FRONTIER_CHALLENGE(FRONTIER_FACILITY_FACTORY, FRONTIER_MODE_SINGLES),
FRONTIER_CHALLENGE(FRONTIER_FACILITY_FACTORY, FRONTIER_MODE_DOUBLES),
FRONTIER_CHALLENGE(FRONTIER_FACILITY_PALACE, FRONTIER_MODE_SINGLES),
FRONTIER_CHALLENGE(FRONTIER_FACILITY_PALACE, FRONTIER_MODE_DOUBLES),
FRONTIER_CHALLENGE(FRONTIER_FACILITY_ARENA, FRONTIER_MODE_SINGLES),
FRONTIER_CHALLENGE(FRONTIER_FACILITY_PIKE, FRONTIER_MODE_SINGLES),
FRONTIER_CHALLENGE(FRONTIER_FACILITY_PYRAMID, FRONTIER_MODE_SINGLES)
};
2018-08-11 23:51:54 +02:00
2018-08-25 19:59:47 +02:00
u16 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
2019-09-13 20:24:07 +02:00
u16 challenge = VarGet(VAR_FRONTIER_GAMBLER_SET_FACILITY_F);
2018-08-25 19:59:47 +02:00
u16 frontierFacilityId = VarGet(VAR_FRONTIER_FACILITY);
2018-08-10 09:42:06 +02:00
if (VarGet(VAR_FRONTIER_GAMBLER_PLACED_BET_F) == 1)
{
2019-09-13 20:24:07 +02:00
if (sFrontierChallenges[challenge] == FRONTIER_CHALLENGE(frontierFacilityId, battleMode))
2018-08-10 09:42:06 +02:00
{
if (a0 != 0)
{
VarSet(VAR_FRONTIER_GAMBLER_PLACED_BET_F, 2);
}
else
{
VarSet(VAR_FRONTIER_GAMBLER_PLACED_BET_F, 3);
}
}
}
}
void sub_813A8FC(void)
{
u8 string[32];
u32 x;
2018-10-30 22:17:03 +01:00
StringCopy(ConvertIntToDecimalStringN(string, gSaveBlock2Ptr->frontier.battlePoints, STR_CONV_MODE_RIGHT_ALIGN, 4), gText_BP);
2018-08-10 09:42:06 +02:00
x = GetStringRightAlignXOffset(1, string, 48);
AddTextPrinterParameterized(gUnknown_0203AB6D, 1, string, x, 1, 0, NULL);
2018-08-10 09:42:06 +02:00
}
void sub_813A958(void)
{
2018-08-11 23:51:54 +02:00
static const struct WindowTemplate gUnknown_085B311C = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-08-11 23:51:54 +02:00
.tilemapLeft = 1,
.tilemapTop = 1,
.width = 6,
.height = 2,
.paletteNum = 15,
.baseBlock = 8,
};
2018-08-10 09:42:06 +02:00
gUnknown_0203AB6D = AddWindow(&gUnknown_085B311C);
SetStandardWindowBorderStyle(gUnknown_0203AB6D, 0);
sub_813A8FC();
CopyWindowToVram(gUnknown_0203AB6D, 2);
}
void sub_813A988(void)
{
ClearStdWindowAndFrameToTransparent(gUnknown_0203AB6D, TRUE);
2018-08-10 09:42:06 +02:00
RemoveWindow(gUnknown_0203AB6D);
}
2019-09-13 20:24:07 +02:00
void TakeFrontierBattlePoints(void)
2018-08-10 09:42:06 +02:00
{
2018-10-30 22:17:03 +01:00
if (gSaveBlock2Ptr->frontier.battlePoints < gSpecialVar_0x8004)
2018-08-10 09:42:06 +02:00
{
2018-10-30 22:17:03 +01:00
gSaveBlock2Ptr->frontier.battlePoints = 0;
2018-08-10 09:42:06 +02:00
}
else
{
2018-10-30 22:17:03 +01:00
gSaveBlock2Ptr->frontier.battlePoints -= gSpecialVar_0x8004;
2018-08-10 09:42:06 +02:00
}
}
2019-09-13 20:24:07 +02:00
void GiveFrontierBattlePoints(void)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
if (gSaveBlock2Ptr->frontier.battlePoints + gSpecialVar_0x8004 > MAX_BATTLE_FRONTIER_POINTS)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
gSaveBlock2Ptr->frontier.battlePoints = MAX_BATTLE_FRONTIER_POINTS;
2018-08-10 09:42:06 +02:00
}
else
{
2018-10-30 22:17:03 +01:00
gSaveBlock2Ptr->frontier.battlePoints = gSaveBlock2Ptr->frontier.battlePoints + gSpecialVar_0x8004;
2018-08-10 09:42:06 +02:00
}
}
2019-09-13 20:24:07 +02:00
u16 GetFrontierBattlePoints(void)
2018-08-10 09:42:06 +02:00
{
2018-10-30 22:17:03 +01:00
return gSaveBlock2Ptr->frontier.battlePoints;
2018-08-10 09:42:06 +02:00
}
void sub_813AA18(void)
{
2018-08-11 23:51:54 +02:00
static const struct WindowTemplate gUnknown_085B3124 = {
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-08-11 23:51:54 +02:00
.tilemapLeft = 2,
.tilemapTop = 9,
.width = 4,
.height = 4,
.paletteNum = 15,
.baseBlock = 20,
};
2018-08-10 09:42:06 +02:00
gUnknown_0203AB6E = AddWindow(&gUnknown_085B3124);
SetStandardWindowBorderStyle(gUnknown_0203AB6E, 0);
CopyWindowToVram(gUnknown_0203AB6E, 2);
}
void sub_813AA44(void)
{
ClearStdWindowAndFrameToTransparent(gUnknown_0203AB6E, TRUE);
2018-08-10 09:42:06 +02:00
RemoveWindow(gUnknown_0203AB6E);
}
2019-09-13 20:24:07 +02:00
static void sub_813AA60(u16 menu, u16 selection)
{
#include "data/battle_frontier/battle_frontier_exchange_corner.h"
2018-08-10 09:42:06 +02:00
2019-09-13 20:24:07 +02:00
if (menu > SCROLL_MULTI_POKEMON_FAN_CLUB_RATER && menu < SCROLL_MULTI_BERRY_POWDER_VENDOR)
2018-08-10 09:42:06 +02:00
{
FillWindowPixelRect(0, PIXEL_FILL(1), 0, 0, 216, 32);
2019-09-13 20:24:07 +02:00
switch (menu)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_1:
AddTextPrinterParameterized2(0, 1, sBFExchangeCorner_Decor1Descriptions[selection], 0, NULL, 2, 1, 3);
if (sBFExchangeCorner_Decor1[selection] == 0xFFFF)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
ScrollMulti_ShowItemIcon(sBFExchangeCorner_Decor1[selection]);
2018-08-10 09:42:06 +02:00
}
else
{
FreeSpriteTilesByTag(5500);
FreeSpritePaletteByTag(5500);
2019-09-13 20:24:07 +02:00
gScrollableMultichoiceSprite = AddDecorationIconObject(sBFExchangeCorner_Decor1[selection], 33, 88, 0, 5500, 5500);
2018-08-10 09:42:06 +02:00
}
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_2:
AddTextPrinterParameterized2(0, 1, sBFExchangeCorner_Decor2Descriptions[selection], 0, NULL, 2, 1, 3);
if (sBFExchangeCorner_Decor2[selection] == 0xFFFF)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
ScrollMulti_ShowItemIcon(sBFExchangeCorner_Decor2[selection]);
2018-08-10 09:42:06 +02:00
}
else
{
FreeSpriteTilesByTag(5500);
FreeSpritePaletteByTag(5500);
2019-09-13 20:24:07 +02:00
gScrollableMultichoiceSprite = AddDecorationIconObject(sBFExchangeCorner_Decor2[selection], 33, 88, 0, 5500, 5500);
2018-08-10 09:42:06 +02:00
}
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BF_EXCHANGE_CORNER_VITAMIN_VENDOR:
AddTextPrinterParameterized2(0, 1, sBFExchangeCorner_VitaminsDescriptions[selection], 0, NULL, 2, 1, 3);
ScrollMulti_ShowItemIcon(sBFExchangeCorner_Vitamins[selection]);
2018-08-10 09:42:06 +02:00
break;
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BF_EXCHANGE_CORNER_HOLD_ITEM_VENDOR:
AddTextPrinterParameterized2(0, 1, sBFExchangeCorner_HoldItemsDescriptions[selection], 0, NULL, 2, 1, 3);
ScrollMulti_ShowItemIcon(sBFExchangeCorner_HoldItems[selection]);
2018-08-10 09:42:06 +02:00
break;
}
}
}
2019-09-13 20:24:07 +02:00
static void ScrollMulti_ShowItemIcon(u16 item)
2018-08-10 09:42:06 +02:00
{
FreeSpriteTilesByTag(5500);
FreeSpritePaletteByTag(5500);
2019-09-13 20:24:07 +02:00
gScrollableMultichoiceSprite = AddItemIconSprite(5500, 5500, item);
2018-08-10 09:42:06 +02:00
2019-09-13 20:24:07 +02:00
if (gScrollableMultichoiceSprite != MAX_SPRITES)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
gSprites[gScrollableMultichoiceSprite].oam.priority = 0;
gSprites[gScrollableMultichoiceSprite].pos1.x = 36;
gSprites[gScrollableMultichoiceSprite].pos1.y = 92;
2018-08-10 09:42:06 +02:00
}
}
2019-09-13 20:24:07 +02:00
// selection is unused
static void sub_813AC44(u16 menu, u16 selection)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
if (gScrollableMultichoiceSprite != MAX_SPRITES)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
switch (menu)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_1:
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_2:
case SCROLL_MULTI_BF_EXCHANGE_CORNER_VITAMIN_VENDOR:
case SCROLL_MULTI_BF_EXCHANGE_CORNER_HOLD_ITEM_VENDOR:
DestroySpriteAndFreeResources(&gSprites[gScrollableMultichoiceSprite]);
2018-08-10 09:42:06 +02:00
break;
}
2019-09-13 20:24:07 +02:00
gScrollableMultichoiceSprite = MAX_SPRITES;
2018-08-10 09:42:06 +02:00
}
}
2019-09-13 20:24:07 +02:00
static const u16 sBattleFrontier_TutorMoves1[] =
{
MOVE_SOFT_BOILED,
MOVE_SEISMIC_TOSS,
MOVE_DREAM_EATER,
MOVE_MEGA_PUNCH,
MOVE_MEGA_KICK,
MOVE_BODY_SLAM,
MOVE_ROCK_SLIDE,
MOVE_COUNTER,
MOVE_THUNDER_WAVE,
MOVE_SWORDS_DANCE
};
2018-08-10 09:42:06 +02:00
2019-09-13 20:24:07 +02:00
static const u16 sBattleFrontier_TutorMoves2[] =
{
MOVE_DEFENSE_CURL,
MOVE_SNORE,
MOVE_MUD_SLAP,
MOVE_SWIFT,
MOVE_ICY_WIND,
MOVE_ENDURE,
MOVE_PSYCH_UP,
MOVE_ICE_PUNCH,
MOVE_THUNDER_PUNCH,
MOVE_FIRE_PUNCH
};
void BufferBattleFrontierTutorMoveName(void)
2018-08-10 09:42:06 +02:00
{
if (gSpecialVar_0x8005 != 0)
{
2019-09-13 20:24:07 +02:00
StringCopy(gStringVar1, gMoveNames[sBattleFrontier_TutorMoves2[gSpecialVar_0x8004]]);
2018-08-10 09:42:06 +02:00
}
else
{
2019-09-13 20:24:07 +02:00
StringCopy(gStringVar1, gMoveNames[sBattleFrontier_TutorMoves1[gSpecialVar_0x8004]]);
2018-08-10 09:42:06 +02:00
}
}
2019-09-13 20:24:07 +02:00
static void ShowBattleFrontierTutorWindow(u8 menu, u16 selection)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
static const struct WindowTemplate sBattleFrontierTutor_WindowTemplate =
{
2018-10-27 00:53:07 +02:00
.bg = 0,
2018-08-11 23:51:54 +02:00
.tilemapLeft = 1,
.tilemapTop = 7,
.width = 12,
.height = 6,
.paletteNum = 15,
.baseBlock = 28,
};
2019-09-13 20:24:07 +02:00
if (menu == SCROLL_MULTI_BF_MOVE_TUTOR_1 || menu == SCROLL_MULTI_BF_MOVE_TUTOR_2)
2018-08-10 09:42:06 +02:00
{
if (gSpecialVar_0x8006 == 0)
{
2019-09-13 20:24:07 +02:00
gUnknown_0203AB5E = AddWindow(&sBattleFrontierTutor_WindowTemplate);
2018-08-10 09:42:06 +02:00
SetStandardWindowBorderStyle(gUnknown_0203AB5E, 0);
}
2019-09-13 20:24:07 +02:00
ShowBattleFrontierTutorMoveDescription(menu, selection);
2018-08-10 09:42:06 +02:00
}
}
2019-09-13 20:24:07 +02:00
static void ShowBattleFrontierTutorMoveDescription(u8 menu, u16 selection)
2018-08-11 23:51:54 +02:00
{
2019-09-13 20:24:07 +02:00
static const u8 *const sBattleFrontier_TutorMoveDescriptions1[] =
{
2018-08-11 23:51:54 +02:00
BattleFrontier_Lounge7_Text_265E30,
BattleFrontier_Lounge7_Text_265E5B,
BattleFrontier_Lounge7_Text_265E8A,
BattleFrontier_Lounge7_Text_265EC0,
BattleFrontier_Lounge7_Text_265EED,
BattleFrontier_Lounge7_Text_265F1C,
BattleFrontier_Lounge7_Text_265F47,
BattleFrontier_Lounge7_Text_265F77,
BattleFrontier_Lounge7_Text_265FAA,
BattleFrontier_Lounge7_Text_265FDD,
gText_Exit,
};
2018-08-10 09:42:06 +02:00
2019-09-13 20:24:07 +02:00
static const u8 *const sBattleFrontier_TutorMoveDescriptions2[] =
{
2018-08-11 23:51:54 +02:00
BattleFrontier_Lounge7_Text_26600A,
BattleFrontier_Lounge7_Text_26603E,
BattleFrontier_Lounge7_Text_266070,
BattleFrontier_Lounge7_Text_2660A6,
BattleFrontier_Lounge7_Text_2660D0,
BattleFrontier_Lounge7_Text_2660FF,
BattleFrontier_Lounge7_Text_26612D,
BattleFrontier_Lounge7_Text_26615F,
BattleFrontier_Lounge7_Text_266185,
BattleFrontier_Lounge7_Text_2661B5,
gText_Exit,
};
2018-08-10 09:42:06 +02:00
2019-09-13 20:24:07 +02:00
if (menu == SCROLL_MULTI_BF_MOVE_TUTOR_1 || menu == SCROLL_MULTI_BF_MOVE_TUTOR_2)
2018-08-10 09:42:06 +02:00
{
FillWindowPixelRect(gUnknown_0203AB5E, PIXEL_FILL(1), 0, 0, 96, 48);
2019-09-13 20:24:07 +02:00
if (menu == SCROLL_MULTI_BF_MOVE_TUTOR_2)
2018-08-10 09:42:06 +02:00
{
2019-09-13 20:24:07 +02:00
AddTextPrinterParameterized(gUnknown_0203AB5E, 1, sBattleFrontier_TutorMoveDescriptions2[selection], 0, 1, 0, NULL);
2018-08-10 09:42:06 +02:00
}
else
{
2019-09-13 20:24:07 +02:00
AddTextPrinterParameterized(gUnknown_0203AB5E, 1, sBattleFrontier_TutorMoveDescriptions1[selection], 0, 1, 0, NULL);
2018-08-10 09:42:06 +02:00
}
}
}
void sub_813ADB8(void)
{
ClearStdWindowAndFrameToTransparent(gUnknown_0203AB5E, TRUE);
2018-08-10 09:42:06 +02:00
RemoveWindow(gUnknown_0203AB5E);
}
void sub_813ADD4(void)
{
u16 scrollOffset, selectedRow;
u8 i;
u8 taskId = FindTaskIdByFunc(sub_813A600);
if (taskId != 0xFF)
{
struct Task *task = &gTasks[taskId];
ListMenuGetScrollAndRow(task->data[14], &scrollOffset, &selectedRow);
SetStandardWindowBorderStyle(task->data[13], 0);
2018-08-19 01:06:10 +02:00
2018-08-10 09:42:06 +02:00
for (i = 0; i < 6; i++)
{
2019-09-13 20:24:07 +02:00
AddTextPrinterParameterized5(task->data[13], 1, sScrollableMenuOptions[gSpecialVar_0x8004][scrollOffset + i], 10, i * 16, TEXT_SPEED_FF, NULL, 0, 0);
2018-08-10 09:42:06 +02:00
}
AddTextPrinterParameterized(task->data[13], 1, gText_SelectorArrow, 0, selectedRow * 16, TEXT_SPEED_FF, NULL);
2018-08-10 09:42:06 +02:00
PutWindowTilemap(task->data[13]);
CopyWindowToVram(task->data[13], 3);
}
}
void sub_813AEB4(void)
{
u8 i;
2019-09-13 20:24:07 +02:00
u16 moveTutor = 0;
u16 moveIndex = 0;
2018-08-10 09:42:06 +02:00
gSpecialVar_0x8005 = 0;
2018-08-19 01:06:10 +02:00
2019-09-13 20:24:07 +02:00
moveTutor = VarGet(VAR_TEMP_E);
moveIndex = VarGet(VAR_TEMP_D);
2018-08-10 09:42:06 +02:00
2019-09-13 20:24:07 +02:00
if (moveTutor != 0)
2018-08-10 09:42:06 +02:00
{
i = 0;
do
{
2019-09-13 20:24:07 +02:00
if (gTutorMoves[i] == sBattleFrontier_TutorMoves2[moveIndex])
2018-08-10 09:42:06 +02:00
{
gSpecialVar_0x8005 = i;
break;
}
i++;
2019-09-13 20:24:07 +02:00
} while (i < TUTOR_MOVE_COUNT);
2018-08-10 09:42:06 +02:00
}
else
{
i = 0;
do
{
2019-09-13 20:24:07 +02:00
if (gTutorMoves[i] == sBattleFrontier_TutorMoves1[moveIndex])
2018-08-10 09:42:06 +02:00
{
gSpecialVar_0x8005 = i;
break;
}
i++;
2019-09-13 20:24:07 +02:00
} while (i < TUTOR_MOVE_COUNT);
2018-08-10 09:42:06 +02:00
}
}
void sub_813AF48(void)
{
u8 taskId = FindTaskIdByFunc(sub_813A600);
if (taskId != 0xFF)
{
struct Task *task = &gTasks[taskId];
DestroyListMenuTask(task->data[14], NULL, NULL);
Free(gUnknown_0203AB64);
ClearStdWindowAndFrameToTransparent(task->data[13], TRUE);
FillWindowPixelBuffer(task->data[13], PIXEL_FILL(0));
2018-08-10 09:42:06 +02:00
ClearWindowTilemap(task->data[13]);
CopyWindowToVram(task->data[13], 2);
RemoveWindow(task->data[13]);
DestroyTask(taskId);
}
}
2018-12-28 20:10:02 +01:00
void DoDeoxysRockInteraction(void)
2018-08-10 09:42:06 +02:00
{
2018-12-28 20:10:02 +01:00
CreateTask(Task_DeoxysRockInteraction, 8);
2018-08-10 09:42:06 +02:00
}
2018-12-28 20:10:02 +01:00
static const u16 sDeoxysRockPalettes[][16] = {
2018-08-10 09:42:06 +02:00
INCBIN_U16("graphics/misc/deoxys1.gbapal"),
INCBIN_U16("graphics/misc/deoxys2.gbapal"),
INCBIN_U16("graphics/misc/deoxys3.gbapal"),
INCBIN_U16("graphics/misc/deoxys4.gbapal"),
INCBIN_U16("graphics/misc/deoxys5.gbapal"),
INCBIN_U16("graphics/misc/deoxys6.gbapal"),
INCBIN_U16("graphics/misc/deoxys7.gbapal"),
INCBIN_U16("graphics/misc/deoxys8.gbapal"),
INCBIN_U16("graphics/misc/deoxys9.gbapal"),
INCBIN_U16("graphics/misc/deoxys10.gbapal"),
INCBIN_U16("graphics/misc/deoxys11.gbapal"),
};
2018-12-28 20:10:02 +01:00
static const u8 sDeoxysRockCoords[][2] = {
{ 15, 12 },
{ 11, 14 },
{ 15, 8 },
{ 19, 14 },
{ 12, 11 },
{ 18, 11 },
{ 15, 14 },
{ 11, 14 },
{ 19, 14 },
{ 15, 15 },
{ 15, 10 },
2018-08-10 09:42:06 +02:00
};
2018-12-28 20:10:02 +01:00
static void Task_DeoxysRockInteraction(u8 taskId)
2018-08-10 09:42:06 +02:00
{
2018-12-28 20:10:02 +01:00
static const u8 sStoneMaxStepCounts[] = { 4, 8, 8, 8, 4, 4, 4, 6, 3, 3 };
2018-08-11 23:51:54 +02:00
2018-12-28 20:10:02 +01:00
if (FlagGet(FLAG_DEOXYS_ROCK_COMPLETE) == TRUE)
2018-08-10 09:42:06 +02:00
{
gSpecialVar_Result = 3;
EnableBothScriptContexts();
DestroyTask(taskId);
}
else
{
2018-12-28 20:10:02 +01:00
u16 rockLevel = VarGet(VAR_DEOXYS_ROCK_LEVEL);
u16 stepCount = VarGet(VAR_DEOXYS_ROCK_STEP_COUNT);
2018-08-10 09:42:06 +02:00
2018-12-28 20:10:02 +01:00
VarSet(VAR_DEOXYS_ROCK_STEP_COUNT, 0);
if (rockLevel != 0 && sStoneMaxStepCounts[rockLevel - 1] < stepCount)
2018-08-10 09:42:06 +02:00
{
2018-12-28 20:10:02 +01:00
// Player failed to take the shortest path to the stone, so it resets.
ChangeDeoxysRockLevel(0);
VarSet(VAR_DEOXYS_ROCK_LEVEL, 0);
2018-08-10 09:42:06 +02:00
gSpecialVar_Result = 0;
DestroyTask(taskId);
}
2018-12-28 20:10:02 +01:00
else if (rockLevel == 10)
2018-08-10 09:42:06 +02:00
{
2018-12-28 20:10:02 +01:00
FlagSet(FLAG_DEOXYS_ROCK_COMPLETE);
2018-08-10 09:42:06 +02:00
gSpecialVar_Result = 2;
EnableBothScriptContexts();
DestroyTask(taskId);
}
else
{
2018-12-28 20:10:02 +01:00
rockLevel++;
ChangeDeoxysRockLevel(rockLevel);
VarSet(VAR_DEOXYS_ROCK_LEVEL, rockLevel);
2018-08-10 09:42:06 +02:00
gSpecialVar_Result = 1;
DestroyTask(taskId);
}
}
}
2018-12-28 20:10:02 +01:00
static void ChangeDeoxysRockLevel(u8 rockLevel)
2018-08-10 09:42:06 +02:00
{
u8 eventObjectId;
2018-12-28 20:10:02 +01:00
LoadPalette(&sDeoxysRockPalettes[rockLevel], 0x1A0, 8);
2018-08-10 09:42:06 +02:00
TryGetEventObjectIdByLocalIdAndMap(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &eventObjectId);
2018-08-19 01:06:10 +02:00
2018-12-28 20:10:02 +01:00
if (rockLevel == 0)
2018-08-10 09:42:06 +02:00
PlaySE(SE_W109);
else
PlaySE(SE_RG_DEOMOV);
2018-12-28 20:10:02 +01:00
CreateTask(WaitForDeoxysRockMovement, 8);
2018-08-10 09:42:06 +02:00
gFieldEffectArguments[0] = 1;
gFieldEffectArguments[1] = 58;
gFieldEffectArguments[2] = 26;
2018-12-28 20:10:02 +01:00
gFieldEffectArguments[3] = sDeoxysRockCoords[rockLevel][0];
gFieldEffectArguments[4] = sDeoxysRockCoords[rockLevel][1];
2018-08-10 09:42:06 +02:00
2018-12-28 20:10:02 +01:00
if (rockLevel == 0)
2018-08-10 09:42:06 +02:00
gFieldEffectArguments[5] = 60;
else
gFieldEffectArguments[5] = 5;
2018-12-28 20:10:02 +01:00
FieldEffectStart(FLDEFF_MOVE_DEOXYS_ROCK);
Overworld_SetEventObjTemplateCoords(1, sDeoxysRockCoords[rockLevel][0], sDeoxysRockCoords[rockLevel][1]);
2018-08-10 09:42:06 +02:00
}
2018-12-28 20:10:02 +01:00
static void WaitForDeoxysRockMovement(u8 taskId)
2018-08-10 09:42:06 +02:00
{
2018-12-28 20:10:02 +01:00
if (FieldEffectActiveListContains(FLDEFF_MOVE_DEOXYS_ROCK) == FALSE)
2018-08-10 09:42:06 +02:00
{
EnableBothScriptContexts();
DestroyTask(taskId);
}
}
2018-12-28 20:10:02 +01:00
void IncrementBirthIslandRockStepCount(void)
2018-08-10 09:42:06 +02:00
{
2018-12-28 20:10:02 +01:00
u16 var = VarGet(VAR_DEOXYS_ROCK_STEP_COUNT);
2018-08-10 09:42:06 +02:00
if (gSaveBlock1Ptr->location.mapNum == MAP_NUM(BIRTH_ISLAND_EXTERIOR) && gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BIRTH_ISLAND_EXTERIOR))
{
var++;
if (var > 99)
{
2018-12-28 20:10:02 +01:00
VarSet(VAR_DEOXYS_ROCK_STEP_COUNT, 0);
2018-08-10 09:42:06 +02:00
}
else
{
2018-12-28 20:10:02 +01:00
VarSet(VAR_DEOXYS_ROCK_STEP_COUNT, var);
2018-08-10 09:42:06 +02:00
}
}
}
void sub_813B1D0(void)
{
2018-12-28 20:10:02 +01:00
LoadPalette(&sDeoxysRockPalettes[(u8)VarGet(VAR_DEOXYS_ROCK_LEVEL)], 0x1A0, 8);
2018-08-10 09:42:06 +02:00
BlendPalettes(0x04000000, 16, 0);
}
void set_unknown_box_id(u8 id)
{
gUnknown_0203AB6F = id;
}
2018-08-10 23:07:23 +02:00
u16 get_unknown_box_id(void)
2018-08-10 09:42:06 +02:00
{
return gUnknown_0203AB6F;
}
2018-08-10 23:07:23 +02:00
2019-03-02 04:32:50 +01:00
bool8 sub_813B21C(void)
2018-08-10 23:07:23 +02:00
{
if (FlagGet(FLAG_SYS_STORAGE_UNKNOWN_FLAG) == FALSE)
{
if (StorageGetCurrentBox() != VarGet(VAR_STORAGE_UNKNOWN))
{
FlagSet(FLAG_SYS_STORAGE_UNKNOWN_FLAG);
return TRUE;
}
}
return FALSE;
}
bool8 sub_813B260(void)
{
int box;
int i;
set_unknown_box_id(VarGet(VAR_STORAGE_UNKNOWN));
box = StorageGetCurrentBox();
do
{
for (i = 0; i < IN_BOX_COUNT; i++)
{
if (GetBoxMonData(GetBoxedMonPtr(box, i), MON_DATA_SPECIES, 0) == 0)
{
if (get_unknown_box_id() != box)
{
FlagClear(FLAG_SYS_STORAGE_UNKNOWN_FLAG);
}
VarSet(VAR_STORAGE_UNKNOWN, box);
return sub_813B21C();
}
}
if (++box == TOTAL_BOXES_COUNT)
{
box = 0;
}
} while (box != StorageGetCurrentBox());
return FALSE;
}
void CreateUnusualWeatherEvent(void)
2018-08-10 23:07:23 +02:00
{
u16 randomValue = Random();
VarSet(VAR_UNUSUAL_WEATHER_STEP_COUNTER, 0);
2018-08-10 23:07:23 +02:00
2019-01-02 22:12:43 +01:00
if (FlagGet(FLAG_DEFEATED_KYOGRE) == TRUE)
2018-08-10 23:07:23 +02:00
{
2019-03-01 07:49:11 +01:00
VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue % UNUSUAL_WEATHER_COUNT_PER_LEGENDARY) + UNUSUAL_WEATHER_GROUDON_LOCATIONS_START);
2018-08-10 23:07:23 +02:00
}
2019-01-02 22:12:43 +01:00
else if (FlagGet(FLAG_DEFEATED_GROUDON) == TRUE)
2018-08-10 23:07:23 +02:00
{
2019-03-01 07:49:11 +01:00
VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue % UNUSUAL_WEATHER_COUNT_PER_LEGENDARY) + UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START);
2018-08-10 23:07:23 +02:00
}
else if ((randomValue & 1) == 0)
{
randomValue = Random();
2019-03-01 07:49:11 +01:00
VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue % UNUSUAL_WEATHER_COUNT_PER_LEGENDARY) + UNUSUAL_WEATHER_GROUDON_LOCATIONS_START);
2018-08-10 23:07:23 +02:00
}
else
{
randomValue = Random();
2019-03-01 07:49:11 +01:00
VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue % UNUSUAL_WEATHER_COUNT_PER_LEGENDARY) + UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START);
2018-08-10 23:07:23 +02:00
}
}
// Saves the map name for the current unusual weather location in gStringVar1, then
// returns TRUE if the weather is for Kyogre, and FALSE if it's for Groudon.
bool32 GetUnusualWeatherMapNameAndType(void)
2018-08-10 23:07:23 +02:00
{
2019-03-01 07:49:11 +01:00
static const u8 sUnusualWeatherMapNumbers[] = {
MAP_NUM(ROUTE114),
MAP_NUM(ROUTE114),
MAP_NUM(ROUTE115),
MAP_NUM(ROUTE115),
MAP_NUM(ROUTE116),
MAP_NUM(ROUTE116),
MAP_NUM(ROUTE118),
MAP_NUM(ROUTE118),
MAP_NUM(ROUTE105),
MAP_NUM(ROUTE105),
MAP_NUM(ROUTE125),
MAP_NUM(ROUTE125),
MAP_NUM(ROUTE127),
MAP_NUM(ROUTE127),
MAP_NUM(ROUTE129),
MAP_NUM(ROUTE129)
};
2018-08-11 23:51:54 +02:00
u16 unusualWeather = VarGet(VAR_UNUSUAL_WEATHER_LOCATION);
2018-08-10 23:07:23 +02:00
GetMapName(gStringVar1, sUnusualWeatherMapNumbers[unusualWeather - 1], 0);
2018-08-19 01:06:10 +02:00
if (unusualWeather < UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START)
2018-08-10 23:07:23 +02:00
{
return FALSE;
}
else
{
return TRUE;
}
}
bool8 UnusualWeatherHasExpired(void)
2018-08-10 23:07:23 +02:00
{
// Duplicate array.
2019-03-01 07:49:11 +01:00
static const u8 sUnusualWeatherMapNumbers_2[] = {
MAP_NUM(ROUTE114),
MAP_NUM(ROUTE114),
MAP_NUM(ROUTE115),
MAP_NUM(ROUTE115),
MAP_NUM(ROUTE116),
MAP_NUM(ROUTE116),
MAP_NUM(ROUTE118),
MAP_NUM(ROUTE118),
MAP_NUM(ROUTE105),
MAP_NUM(ROUTE105),
MAP_NUM(ROUTE125),
MAP_NUM(ROUTE125),
MAP_NUM(ROUTE127),
MAP_NUM(ROUTE127),
MAP_NUM(ROUTE129),
MAP_NUM(ROUTE129)
};
2018-08-11 23:51:54 +02:00
u16 steps = VarGet(VAR_UNUSUAL_WEATHER_STEP_COUNTER);
u16 unusualWeather = VarGet(VAR_UNUSUAL_WEATHER_LOCATION);
2018-08-10 23:07:23 +02:00
if (unusualWeather == UNUSUAL_WEATHER_NONE)
2018-08-11 23:51:54 +02:00
{
return FALSE;
}
if (++steps > 999)
2018-08-11 23:51:54 +02:00
{
VarSet(VAR_UNUSUAL_WEATHER_STEP_COUNTER, 0);
2018-08-11 23:51:54 +02:00
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(UNDERWATER_MARINE_CAVE))
{
switch (gSaveBlock1Ptr->location.mapNum)
{
case MAP_NUM(UNDERWATER_MARINE_CAVE):
case MAP_NUM(MARINE_CAVE_ENTRANCE):
case MAP_NUM(MARINE_CAVE_END):
case MAP_NUM(TERRA_CAVE_ENTRANCE):
case MAP_NUM(TERRA_CAVE_END):
VarSet(VAR_SHOULD_END_UNUSUAL_WEATHER, 1);
2018-08-11 23:51:54 +02:00
return FALSE;
default:
break;
}
}
2018-08-19 01:06:10 +02:00
2018-08-11 23:51:54 +02:00
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(UNDERWATER3))
{
switch (gSaveBlock1Ptr->location.mapNum)
{
case MAP_NUM(UNDERWATER3):
case MAP_NUM(UNDERWATER5):
case MAP_NUM(UNDERWATER6):
case MAP_NUM(UNDERWATER7):
VarSet(VAR_SHOULD_END_UNUSUAL_WEATHER, 1);
2018-08-11 23:51:54 +02:00
return FALSE;
default:
break;
}
}
if (gSaveBlock1Ptr->location.mapNum == sUnusualWeatherMapNumbers_2[unusualWeather - 1] &&
2018-08-11 23:51:54 +02:00
gSaveBlock1Ptr->location.mapGroup == 0)
{
return TRUE;
}
else
{
VarSet(VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_NONE);
2018-08-11 23:51:54 +02:00
return FALSE;
}
}
else
{
VarSet(VAR_UNUSUAL_WEATHER_STEP_COUNTER, steps);
2018-08-11 23:51:54 +02:00
return FALSE;
}
}
void Unused_SetWeatherSunny(void)
2018-08-11 23:51:54 +02:00
{
SetCurrentAndNextWeather(WEATHER_SUNNY);
2018-08-11 23:51:54 +02:00
}
2019-09-13 20:24:07 +02:00
// Always returns 1
u32 GetMartEmployeeObjectEventId(void)
{
static const u8 sPokeMarts[][3] =
{
{ MAP_GROUP(OLDALE_TOWN_MART), MAP_NUM(OLDALE_TOWN_MART), 1 },
{ MAP_GROUP(LAVARIDGE_TOWN_MART), MAP_NUM(LAVARIDGE_TOWN_MART), 1 },
{ MAP_GROUP(FALLARBOR_TOWN_MART), MAP_NUM(FALLARBOR_TOWN_MART), 1 },
{ MAP_GROUP(VERDANTURF_TOWN_MART), MAP_NUM(VERDANTURF_TOWN_MART), 1 },
{ MAP_GROUP(PETALBURG_CITY_MART), MAP_NUM(PETALBURG_CITY_MART), 1 },
{ MAP_GROUP(SLATEPORT_CITY_MART), MAP_NUM(SLATEPORT_CITY_MART), 1 },
{ MAP_GROUP(MAUVILLE_CITY_MART), MAP_NUM(MAUVILLE_CITY_MART), 1 },
{ MAP_GROUP(RUSTBORO_CITY_MART), MAP_NUM(RUSTBORO_CITY_MART), 1 },
{ MAP_GROUP(FORTREE_CITY_MART), MAP_NUM(FORTREE_CITY_MART), 1 },
{ MAP_GROUP(MOSSDEEP_CITY_MART), MAP_NUM(MOSSDEEP_CITY_MART), 1 },
{ MAP_GROUP(SOOTOPOLIS_CITY_MART), MAP_NUM(SOOTOPOLIS_CITY_MART), 1 },
{ MAP_GROUP(BATTLE_FRONTIER_MART), MAP_NUM(BATTLE_FRONTIER_MART), 1 }
2018-08-11 23:51:54 +02:00
};
u8 i;
2019-09-13 20:24:07 +02:00
for (i = 0; i < ARRAY_COUNT(sPokeMarts); i++)
2018-08-10 23:07:23 +02:00
{
2019-09-13 20:24:07 +02:00
if (gSaveBlock1Ptr->location.mapGroup == sPokeMarts[i][0])
2018-08-10 23:07:23 +02:00
{
2019-09-13 20:24:07 +02:00
if (gSaveBlock1Ptr->location.mapNum == sPokeMarts[i][1])
2018-08-10 23:07:23 +02:00
{
2019-09-13 20:24:07 +02:00
return sPokeMarts[i][2];
2018-08-11 23:51:54 +02:00
}
}
}
2019-09-13 20:24:07 +02:00
return 1;
2018-08-11 23:51:54 +02:00
}
bool32 sub_813B4E0(void)
{
int index = GetRematchIdxByTrainerIdx(gSpecialVar_0x8004);
if (index >= 0)
{
if (FlagGet(FLAG_MATCH_CALL_REGISTERED + index) == TRUE)
return TRUE;
}
return FALSE;
}
bool32 sub_813B514(void)
{
2019-02-27 21:18:56 +01:00
if (!VarGet(VAR_ALWAYS_ZERO_0x403F))
2018-08-11 23:51:54 +02:00
{
return FALSE;
}
return TRUE;
}
void sub_813B534(void)
{
gUnknown_0203AB70 = gBattleTypeFlags;
gBattleTypeFlags = 0;
if (!gReceivedRemoteLinkPlayers)
{
CreateTask(sub_80B3AF8, 5);
}
}
void sub_813B568(void)
{
CreateTask(sub_813B57C, 5);
}
static void sub_813B57C(u8 taskId)
{
switch (gTasks[taskId].data[0])
{
case 0:
if (!FuncIsActiveTask(sub_80B3AF8))
{
gTasks[taskId].data[0]++;
}
break;
case 1:
2018-12-31 09:22:21 +01:00
if (IsLinkTaskFinished() == TRUE)
2018-08-11 23:51:54 +02:00
{
if (GetMultiplayerId() == 0)
2018-08-10 23:07:23 +02:00
{
2018-08-11 23:51:54 +02:00
gTasks[taskId].data[0]++;
}
else
{
SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_0x8004, 2);
gTasks[taskId].data[0]++;
2018-08-10 23:07:23 +02:00
}
}
2018-08-11 23:51:54 +02:00
break;
case 2:
if ((GetBlockReceivedStatus() & 2) != 0)
{
if (GetMultiplayerId() == 0)
{
gSpecialVar_0x8005 = gBlockRecvBuffer[1][0];
ResetBlockReceivedFlag(1);
if (gSpecialVar_0x8004 == 1 && gSpecialVar_0x8005 == 1)
{
gSpecialVar_Result = 1;
}
else if (gSpecialVar_0x8004 == 0 && gSpecialVar_0x8005 == 1)
{
gSpecialVar_Result = 2;
}
else if (gSpecialVar_0x8004 == 1 && gSpecialVar_0x8005 == 0)
{
gSpecialVar_Result = 3;
}
else
{
gSpecialVar_Result = 0;
}
}
gTasks[taskId].data[0]++;
}
break;
case 3:
2018-12-31 09:22:21 +01:00
if (IsLinkTaskFinished() == TRUE)
2018-08-11 23:51:54 +02:00
{
if (GetMultiplayerId() != 0)
{
gTasks[taskId].data[0]++;
}
else
{
SendBlock(bitmask_all_link_players_but_self(), &gSpecialVar_Result, 2);
gTasks[taskId].data[0]++;
}
}
break;
case 4:
if ((GetBlockReceivedStatus() & 1) != 0)
{
if (GetMultiplayerId() != 0)
{
gSpecialVar_Result = gBlockRecvBuffer[0][0];
ResetBlockReceivedFlag(0);
gTasks[taskId].data[0]++;
}
else
{
gTasks[taskId].data[0]++;
}
}
break;
case 5:
if (GetMultiplayerId() == 0)
{
if (gSpecialVar_Result == 2)
{
ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired);
}
}
else
2018-08-10 23:07:23 +02:00
{
2018-08-11 23:51:54 +02:00
if (gSpecialVar_Result == 3)
2018-08-10 23:07:23 +02:00
{
2018-08-11 23:51:54 +02:00
ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired);
2018-08-10 23:07:23 +02:00
}
}
2018-08-11 23:51:54 +02:00
gTasks[taskId].data[0]++;
break;
case 6:
if (!IsTextPrinterActive(0))
{
gTasks[taskId].data[0]++;
}
break;
case 7:
2018-12-31 09:22:21 +01:00
if (IsLinkTaskFinished() == 1)
2018-08-11 23:51:54 +02:00
{
sub_800ADF8();
gTasks[taskId].data[0]++;
}
break;
case 8:
2018-12-31 09:22:21 +01:00
if (IsLinkTaskFinished() == 1)
2018-08-11 23:51:54 +02:00
{
gTasks[taskId].data[0]++;
}
break;
case 9:
if (gWirelessCommType == 0)
{
sub_800AC34();
}
gBattleTypeFlags = gUnknown_0203AB70;
EnableBothScriptContexts();
DestroyTask(taskId);
break;
}
}
void sub_813B7D8(void)
{
if (gSpecialVar_0x8004 == 0)
{
DoRayquazaScene(0, TRUE, CB2_ReturnToFieldContinueScriptPlayMapMusic);
}
else
{
DoRayquazaScene(1, FALSE, CB2_ReturnToFieldContinueScriptPlayMapMusic);
}
}
void sub_813B80C(void)
{
CreateTask(sub_813B824, 8);
PlaySE(SE_W017);
}
static void sub_813B824(u8 taskId)
{
s16 *data = gTasks[taskId].data;
data[1]++;
if (data[1] == gSpecialVar_0x8005)
{
data[0]++;
data[1] = 0;
PlaySE(SE_W017);
}
if (data[0] == gSpecialVar_0x8004 - 1)
{
DestroyTask(taskId);
}
}
void sub_813B880(void)
{
u8 taskId = CreateTask(_fwalk, 8);
gTasks[taskId].data[0] = 4;
gTasks[taskId].data[1] = 4;
gTasks[taskId].data[2] = 4;
gTasks[taskId].data[3] = 0;
}
static void _fwalk(u8 taskId)
{
u8 x, y;
s16 *data = gTasks[taskId].data;
data[data[3]]--;
if (data[data[3]] == 0)
{
for (y = 0; y < 4; y++)
{
for (x = 0; x < 3; x++)
{
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + x + 6, gSaveBlock1Ptr->pos.y + y + 4, x + 0x201 + y * 8 + data[3] * 32);
}
}
DrawWholeMapView();
data[3]++;
if (data[3] == 3)
{
DestroyTask(taskId);
EnableBothScriptContexts();
}
}
}
void sub_813B968(void)
{
gSpecialVar_Result = gSpecialVar_0x8004 / 7;
gSpecialVar_Result -= (gSpecialVar_Result / 20) * 20;
}
void sub_813B9A0(void)
{
if (gSaveBlock1Ptr->lastHealLocation.mapGroup == MAP_GROUP(DEWFORD_TOWN) && gSaveBlock1Ptr->lastHealLocation.mapNum == MAP_NUM(DEWFORD_TOWN))
{
2018-12-27 23:30:47 +01:00
SetLastHealLocationWarp(3);
2018-08-11 23:51:54 +02:00
}
}
2019-09-13 20:24:07 +02:00
bool8 InPokemonCenter(void)
2018-08-11 23:51:54 +02:00
{
2019-09-13 20:24:07 +02:00
static const u16 sPokemonCenters[] =
{
2018-08-11 23:51:54 +02:00
MAP_OLDALE_TOWN_POKEMON_CENTER_1F,
MAP_DEWFORD_TOWN_POKEMON_CENTER_1F,
MAP_LAVARIDGE_TOWN_POKEMON_CENTER_1F,
MAP_FALLARBOR_TOWN_POKEMON_CENTER_1F,
MAP_VERDANTURF_TOWN_POKEMON_CENTER_1F,
MAP_PACIFIDLOG_TOWN_POKEMON_CENTER_1F,
MAP_PETALBURG_CITY_POKEMON_CENTER_1F,
MAP_SLATEPORT_CITY_POKEMON_CENTER_1F,
MAP_MAUVILLE_CITY_POKEMON_CENTER_1F,
MAP_RUSTBORO_CITY_POKEMON_CENTER_1F,
MAP_FORTREE_CITY_POKEMON_CENTER_1F,
MAP_LILYCOVE_CITY_POKEMON_CENTER_1F,
MAP_MOSSDEEP_CITY_POKEMON_CENTER_1F,
MAP_SOOTOPOLIS_CITY_POKEMON_CENTER_1F,
MAP_EVER_GRANDE_CITY_POKEMON_CENTER_1F,
MAP_EVER_GRANDE_CITY_POKEMON_LEAGUE_1F,
MAP_BATTLE_FRONTIER_POKEMON_CENTER_1F,
MAP_SINGLE_BATTLE_COLOSSEUM,
MAP_TRADE_CENTER,
MAP_RECORD_CORNER,
MAP_DOUBLE_BATTLE_COLOSSEUM,
0xFFFF
2018-08-11 23:51:54 +02:00
};
int i;
u16 map = (gSaveBlock1Ptr->location.mapGroup << 8) + gSaveBlock1Ptr->location.mapNum;
2019-09-13 20:24:07 +02:00
for (i = 0; sPokemonCenters[i] != 0xFFFF; i++)
2018-08-11 23:51:54 +02:00
{
2019-09-13 20:24:07 +02:00
if (sPokemonCenters[i] == map)
2018-08-11 23:51:54 +02:00
{
return TRUE;
}
}
return FALSE;
}
void ResetFanClub(void)
{
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] = 0;
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = 0;
}
void sub_813BA30(void)
{
if (sub_813BF44() != 0)
{
UpdateMovedLilycoveFanClubMembers();
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = gSaveBlock2Ptr->playTimeHours;
}
}
2018-08-10 23:07:23 +02:00
2018-08-11 23:51:54 +02:00
void sub_813BA60(void)
{
if (!((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> 7) & 1))
{
sub_813BF60();
sub_813BD84();
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = gSaveBlock2Ptr->playTimeHours;
FlagClear(FLAG_HIDE_FANCLUB_OLD_LADY);
FlagClear(FLAG_HIDE_FANCLUB_BOY);
FlagClear(FLAG_HIDE_FANCLUB_LITTLE_BOY);
FlagClear(FLAG_HIDE_FANCLUB_LADY);
FlagClear(FLAG_HIDE_LILYCOVE_FAN_CLUB_INTERVIEWER);
2018-08-11 23:51:54 +02:00
VarSet(VAR_LILYCOVE_FAN_CLUB_STATE, 1);
}
}
u8 sub_813BADC(u8 a0)
{
static const u8 gUnknown_085B3470[] = { 0x02, 0x01, 0x02, 0x01 };
if (VarGet(VAR_LILYCOVE_FAN_CLUB_STATE) == 2)
{
if ((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] & 0x7F) + gUnknown_085B3470[a0] > 19)
{
if (GetNumMovedLilycoveFanClubMembers() < 3)
2018-08-10 23:07:23 +02:00
{
2018-08-11 23:51:54 +02:00
sub_813BB74();
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] &= 0xFF80;
2018-08-10 23:07:23 +02:00
}
else
{
2018-08-11 23:51:54 +02:00
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] = (gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] & 0xFF80) | 0x14;
2018-08-10 23:07:23 +02:00
}
}
else
{
2018-08-11 23:51:54 +02:00
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] += gUnknown_085B3470[a0];
}
}
return gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] & 0x7F;
}
static u16 sub_813BB74(void)
{
static const u8 gUnknown_085B3474[] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
u8 i;
u8 retVal = 0;
for (i = 0; i < 8; i++)
{
if (!((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gUnknown_085B3474[i]) & 1))
{
retVal = i;
if ((Random() & 1) != 0)
{
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 1 << gUnknown_085B3474[retVal];
return retVal;
}
}
}
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 1 << gUnknown_085B3474[retVal];
return retVal;
}
static u16 sub_813BC00(void)
{
static const u8 gUnknown_085B347C[] = { 0x08, 0x0d, 0x0e, 0x0b, 0x0a, 0x0c, 0x0f, 0x09 };
u8 i;
u8 retVal = 0;
if (GetNumMovedLilycoveFanClubMembers() == 1)
{
return 0;
}
for (i = 0; i < 8; i++)
{
if (((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gUnknown_085B347C[i]) & 1) != 0)
{
retVal = i;
if ((Random() & 1) != 0)
{
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] ^= 1 << gUnknown_085B347C[retVal];
return retVal;
}
}
}
2018-08-19 01:06:10 +02:00
2018-08-11 23:51:54 +02:00
if (((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gUnknown_085B347C[retVal]) & 1))
{
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] ^= 1 << gUnknown_085B347C[retVal];
}
return retVal;
}
u16 GetNumMovedLilycoveFanClubMembers(void)
{
u8 i;
u8 retVal = 0;
for (i = 0; i < 8; i++)
{
if (((gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> (i + 8)) & 1) != 0)
{
retVal++;
}
}
return retVal;
}
void UpdateMovedLilycoveFanClubMembers(void)
{
u8 i = 0;
if (gSaveBlock2Ptr->playTimeHours < 999)
{
while (TRUE)
{
if (GetNumMovedLilycoveFanClubMembers() < 5)
{
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] = gSaveBlock2Ptr->playTimeHours;
break;
}
else if (i == 8)
{
break;
}
else if (gSaveBlock2Ptr->playTimeHours - gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] < 12)
{
return;
}
sub_813BC00();
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_2 - VARS_START] += 12;
i++;
}
}
}
bool8 ShouldMoveLilycoveFanClubMember(void)
{
return (gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> gSpecialVar_0x8004) & 1;
}
static void sub_813BD84(void)
{
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x2000;
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x100;
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x400;
}
void BufferStreakTrainerText(void)
{
u8 a = 0;
u8 b = 0;
switch (gSpecialVar_0x8004)
{
case 8:
break;
case 9:
break;
case 10:
a = 0;
b = 3;
break;
case 11:
a = 0;
b = 1;
break;
case 12:
a = 1;
b = 0;
break;
case 13:
a = 0;
b = 4;
break;
case 14:
a = 1;
b = 5;
break;
case 15:
break;
}
sub_813BE30(&gSaveBlock1Ptr->linkBattleRecords, a, b);
}
static void sub_813BE30(struct LinkBattleRecords *linkRecords, u8 a, u8 b)
{
struct LinkBattleRecord *record = &linkRecords->entries[a];
if (record->name[0] == EOS)
{
switch (b)
{
case 0:
StringCopy(gStringVar1, gText_Wallace);
break;
case 1:
StringCopy(gStringVar1, gText_Steven);
break;
case 2:
StringCopy(gStringVar1, gText_Brawly);
break;
case 3:
StringCopy(gStringVar1, gText_Winona);
break;
case 4:
StringCopy(gStringVar1, gText_Phoebe);
break;
case 5:
StringCopy(gStringVar1, gText_Glacia);
break;
default:
StringCopy(gStringVar1, gText_Wallace);
break;
2018-08-10 23:07:23 +02:00
}
}
else
{
2018-08-11 23:51:54 +02:00
StringCopyN(gStringVar1, record->name, 7);
gStringVar1[7] = EOS;
ConvertInternationalString(gStringVar1, linkRecords->languages[a]);
2018-08-10 23:07:23 +02:00
}
}
2018-08-11 23:51:54 +02:00
void sub_813BF10(void)
2018-08-10 23:07:23 +02:00
{
2018-08-11 23:51:54 +02:00
if (VarGet(VAR_LILYCOVE_FAN_CLUB_STATE) == 2)
{
sub_813BA30();
if (gBattleOutcome == 1)
{
sub_813BB74();
}
else
{
sub_813BC00();
}
}
}
static bool8 sub_813BF44(void)
{
return (gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] >> 7) & 1;
}
void sub_813BF60(void)
{
gSaveBlock1Ptr->vars[VAR_FANCLUB_UNKNOWN_1 - VARS_START] |= 0x80;
}
u8 sub_813BF7C(void)
{
return sub_813BADC(gSpecialVar_0x8004);
2018-08-10 23:07:23 +02:00
}