2018-08-08 10:37:12 +02:00
|
|
|
#include "global.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2018-08-08 10:37:12 +02:00
|
|
|
#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"
|
2018-08-08 10:37:12 +02:00
|
|
|
#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"
|
2018-08-08 10:37:12 +02:00
|
|
|
#include "field_message_box.h"
|
|
|
|
#include "field_player_avatar.h"
|
2018-12-08 22:05:11 +01:00
|
|
|
#include "field_screen_effect.h"
|
2018-08-08 10:37:12 +02:00
|
|
|
#include "field_specials.h"
|
|
|
|
#include "field_weather.h"
|
2020-11-23 20:45:16 +01:00
|
|
|
#include "graphics.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"
|
2018-08-08 10:37:12 +02:00
|
|
|
#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"
|
2018-08-08 10:37:12 +02:00
|
|
|
#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"
|
2018-08-08 10:37:12 +02:00
|
|
|
#include "region_map.h"
|
|
|
|
#include "rtc.h"
|
|
|
|
#include "script.h"
|
2018-08-09 08:53:21 +02:00
|
|
|
#include "script_menu.h"
|
2018-08-08 10:37:12 +02:00
|
|
|
#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"
|
2020-01-08 11:43:06 +01:00
|
|
|
#include "constants/battle_tower.h"
|
2019-09-13 20:24:07 +02:00
|
|
|
#include "constants/decorations.h"
|
2018-08-08 10:37:12 +02:00
|
|
|
#include "constants/event_objects.h"
|
2019-11-21 20:03:35 +01:00
|
|
|
#include "constants/event_object_movement.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"
|
2018-08-08 10:37:12 +02:00
|
|
|
#include "constants/items.h"
|
2019-09-14 02:22:09 +02:00
|
|
|
#include "constants/heal_locations.h"
|
2018-12-28 22:11:15 +01:00
|
|
|
#include "constants/map_types.h"
|
2018-08-08 10:37:12 +02:00
|
|
|
#include "constants/maps.h"
|
2019-11-05 21:08:07 +01:00
|
|
|
#include "constants/mevent.h"
|
2019-10-07 08:00:16 +02:00
|
|
|
#include "constants/tv.h"
|
2019-09-19 23:26:25 +02:00
|
|
|
#include "constants/script_menu.h"
|
2020-05-20 22:36:00 +02:00
|
|
|
#include "constants/slot_machine.h"
|
2018-08-08 10:37:12 +02:00
|
|
|
#include "constants/songs.h"
|
|
|
|
#include "constants/moves.h"
|
2019-10-18 01:22:03 +02:00
|
|
|
#include "constants/party_menu.h"
|
2018-08-25 19:59:47 +02:00
|
|
|
#include "constants/battle_frontier.h"
|
2019-02-23 04:20:42 +01:00
|
|
|
#include "constants/weather.h"
|
2019-06-11 19:37:02 +02:00
|
|
|
#include "constants/metatile_labels.h"
|
2019-03-02 06:36:59 +01:00
|
|
|
#include "palette.h"
|
2018-08-08 10:37:12 +02:00
|
|
|
|
|
|
|
EWRAM_DATA bool8 gBikeCyclingChallenge = FALSE;
|
|
|
|
EWRAM_DATA u8 gBikeCollisions = 0;
|
2019-09-17 07:49:07 +02:00
|
|
|
static EWRAM_DATA u32 sBikeCyclingTimer = 0;
|
2019-10-15 10:58:52 +02:00
|
|
|
static EWRAM_DATA u8 sSlidingDoorNextFrameCounter = 0;
|
|
|
|
static EWRAM_DATA u8 sSlidingDoorFrame = 0;
|
2019-09-17 07:49:07 +02:00
|
|
|
static EWRAM_DATA u8 sTutorMoveAndElevatorWindowId = 0;
|
|
|
|
static EWRAM_DATA u16 sLilycoveDeptStore_NeverRead = 0;
|
|
|
|
static EWRAM_DATA u16 sLilycoveDeptStore_DefaultFloorChoice = 0;
|
|
|
|
static EWRAM_DATA struct ListMenuItem *sScrollableMultichoice_ListMenuItem = NULL;
|
|
|
|
static EWRAM_DATA u16 sScrollableMultichoice_ScrollOffset = 0;
|
|
|
|
static EWRAM_DATA u16 sFrontierExchangeCorner_NeverRead = 0;
|
|
|
|
static EWRAM_DATA u8 sScrollableMultichoice_ItemSpriteId = 0;
|
|
|
|
static EWRAM_DATA u8 sBattlePointsWindowId = 0;
|
|
|
|
static EWRAM_DATA u8 sFrontierExchangeCorner_ItemIconWindowId = 0;
|
|
|
|
static EWRAM_DATA u8 sPCBoxToSendMon = 0;
|
2020-01-08 11:43:06 +01:00
|
|
|
static EWRAM_DATA u32 sBattleTowerMultiBattleTypeFlags = 0;
|
2018-08-09 08:53:21 +02:00
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
struct ListMenuTemplate gScrollableMultichoice_ListMenuTemplate;
|
2018-08-08 10:37:12 +02:00
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
void TryLoseFansFromPlayTime(void);
|
|
|
|
void SetPlayerGotFirstFans(void);
|
|
|
|
u16 GetNumFansOfPlayerInTrainerFanClub(void);
|
2018-08-08 10:37:12 +02:00
|
|
|
|
|
|
|
static void RecordCyclingRoadResults(u32, u8);
|
2019-11-21 04:55:44 +01:00
|
|
|
static void LoadLinkPartnerObjectEventSpritePalette(u8 graphicsId, u8 localEventId, u8 paletteNum);
|
2019-10-15 10:58:52 +02:00
|
|
|
static void Task_PetalburgGymSlideOpenRoomDoors(u8 taskId);
|
|
|
|
static void PetalburgGymSetDoorMetatiles(u8 roomNumber, u16 metatileId);
|
2018-08-11 23:51:54 +02:00
|
|
|
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 *);
|
2019-09-30 07:42:52 +02:00
|
|
|
static void Task_ShakeCamera(u8 taskId);
|
|
|
|
static void StopCameraShake(u8 taskId);
|
2019-09-14 02:22:09 +02:00
|
|
|
static void Task_MoveElevator(u8 taskId);
|
|
|
|
static void MoveElevatorWindowLights(u16 floorDelta, bool8 descending);
|
|
|
|
static void Task_MoveElevatorWindowLights(u8 taskId);
|
|
|
|
static void Task_ShowScrollableMultichoice(u8 taskId);
|
|
|
|
static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection);
|
2019-09-13 20:24:07 +02:00
|
|
|
static void ShowBattleFrontierTutorWindow(u8 menu, u16 selection);
|
2019-09-14 02:22:09 +02:00
|
|
|
static void InitScrollableMultichoice(void);
|
|
|
|
static void ScrollableMultichoice_ProcessInput(u8 taskId);
|
|
|
|
static void ScrollableMultichoice_UpdateScrollArrows(u8 taskId);
|
|
|
|
static void ScrollableMultichoice_MoveCursor(s32 itemIndex, bool8 onInit, struct ListMenu *list);
|
2019-09-13 23:03:43 +02:00
|
|
|
static void HideFrontierExchangeCornerItemIcon(u16 menu, u16 unused);
|
2019-09-13 20:24:07 +02:00
|
|
|
static void ShowBattleFrontierTutorMoveDescription(u8 menu, u16 selection);
|
2019-09-14 02:22:09 +02:00
|
|
|
static void CloseScrollableMultichoice(u8 taskId);
|
|
|
|
static void ScrollableMultichoice_RemoveScrollArrows(u8 taskId);
|
2018-08-11 23:51:54 +02:00
|
|
|
static void sub_813A600(u8 taskId);
|
|
|
|
static void sub_813A664(u8 taskId);
|
2019-09-13 23:03:43 +02:00
|
|
|
static void ShowFrontierExchangeCornerItemIcon(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);
|
2020-01-08 11:43:06 +01:00
|
|
|
static void Task_LinkRetireStatusWithBattleTowerPartner(u8 taskId);
|
2019-09-30 07:42:52 +02:00
|
|
|
static void Task_LoopWingFlapSE(u8 taskId);
|
|
|
|
static void Task_CloseBattlePikeCurtain(u8 taskId);
|
2019-11-17 23:34:11 +01:00
|
|
|
static u8 DidPlayerGetFirstFans(void);
|
|
|
|
static void SetInitialFansOfPlayer(void);
|
|
|
|
static u16 PlayerGainRandomTrainerFan(void);
|
|
|
|
static void BufferFanClubTrainerName_(struct LinkBattleRecords *linkRecords, u8 a, u8 b);
|
2018-08-08 10:37:12 +02:00
|
|
|
|
|
|
|
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;
|
2019-09-17 07:49:07 +02:00
|
|
|
sBikeCyclingTimer = 0;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Special_BeginCyclingRoadChallenge(void)
|
|
|
|
{
|
|
|
|
gBikeCyclingChallenge = TRUE;
|
|
|
|
gBikeCollisions = 0;
|
2019-09-17 07:49:07 +02:00
|
|
|
sBikeCyclingTimer = gMain.vblankCounter1;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2019-09-17 07:49:07 +02:00
|
|
|
const u32 numFrames = gMain.vblankCounter1 - sBikeCyclingTimer;
|
2018-08-08 10:37:12 +02:00
|
|
|
|
|
|
|
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) {
|
2018-09-05 00:31:37 +02:00
|
|
|
if (gLastUsedWarp.mapNum == MAP_NUM(ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE) && gLastUsedWarp.mapGroup == MAP_GROUP(ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE))
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-11-08 09:37:46 +01:00
|
|
|
// Returns TRUE if the Cruise is over
|
2018-08-08 10:37:12 +02:00
|
|
|
bool32 CountSSTidalStep(u16 delta)
|
|
|
|
{
|
2019-11-08 09:37:46 +01:00
|
|
|
if (!FlagGet(FLAG_SYS_CRUISE_MODE) || (*GetVarPointer(VAR_CRUISE_STEP_COUNT) += delta) < SS_TIDAL_MAX_STEPS)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetSSTidalLocation(s8 *mapGroup, s8 *mapNum, s16 *x, s16 *y)
|
|
|
|
{
|
|
|
|
u16 *varCruiseStepCount = GetVarPointer(VAR_CRUISE_STEP_COUNT);
|
2019-11-08 09:37:46 +01:00
|
|
|
switch (*GetVarPointer(VAR_SS_TIDAL_STATE))
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-11-08 09:37:46 +01:00
|
|
|
case SS_TIDAL_BOARD_SLATEPORT:
|
|
|
|
case SS_TIDAL_LAND_SLATEPORT:
|
2019-09-14 02:22:09 +02:00
|
|
|
return SS_TIDAL_LOCATION_SLATEPORT;
|
2019-11-08 09:37:46 +01:00
|
|
|
case SS_TIDAL_HALFWAY_LILYCOVE:
|
|
|
|
case SS_TIDAL_EXIT_CURRENTS_RIGHT:
|
2019-09-14 02:22:09 +02:00
|
|
|
return SS_TIDAL_LOCATION_ROUTE131;
|
2019-11-08 09:37:46 +01:00
|
|
|
case SS_TIDAL_LAND_LILYCOVE:
|
|
|
|
case SS_TIDAL_BOARD_LILYCOVE:
|
2019-09-14 02:22:09 +02:00
|
|
|
return SS_TIDAL_LOCATION_LILYCOVE;
|
2019-11-08 09:37:46 +01:00
|
|
|
case SS_TIDAL_DEPART_LILYCOVE:
|
|
|
|
case SS_TIDAL_EXIT_CURRENTS_LEFT:
|
2019-09-14 02:22:09 +02:00
|
|
|
return SS_TIDAL_LOCATION_ROUTE124;
|
2019-11-08 09:37:46 +01:00
|
|
|
case SS_TIDAL_DEPART_SLATEPORT:
|
2018-08-08 10:37:12 +02:00
|
|
|
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;
|
2019-11-08 09:37:46 +01:00
|
|
|
case SS_TIDAL_HALFWAY_SLATEPORT:
|
2018-08-08 10:37:12 +02:00
|
|
|
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;
|
2019-12-17 09:24:44 +01:00
|
|
|
return SS_TIDAL_LOCATION_CURRENTS;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
2019-02-28 05:54:51 +01:00
|
|
|
bool32 ShouldDoWallyCall(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-01-02 22:12:43 +01:00
|
|
|
if (FlagGet(FLAG_ENABLE_FIRST_WALLY_POKENAV_CALL))
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-12 17:07:43 +01:00
|
|
|
bool32 ShouldDoScottFortreeCall(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-11-12 17:07:43 +01:00
|
|
|
if (FlagGet(FLAG_SCOTT_CALL_FORTREE_GYM))
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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:
|
2019-11-12 17:07:43 +01:00
|
|
|
if (++(*GetVarPointer(VAR_SCOTT_FORTREE_CALL_STEP_COUNTER)) < 10)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-12 17:07:43 +01:00
|
|
|
bool32 ShouldDoScottBattleFrontierCall(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-11-12 17:07:43 +01:00
|
|
|
if (FlagGet(FLAG_SCOTT_CALL_BATTLE_FRONTIER))
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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-11-12 17:07:43 +01:00
|
|
|
if (++(*GetVarPointer(VAR_SCOTT_BF_CALL_STEP_COUNTER)) < 10)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-02-28 05:54:51 +01:00
|
|
|
bool32 ShouldDoRoxanneCall(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-01-02 22:12:43 +01:00
|
|
|
if (FlagGet(FLAG_ENABLE_ROXANNE_FIRST_CALL))
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-02-28 05:54:51 +01:00
|
|
|
bool32 ShouldDoRivalRayquazaCall(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-01-02 22:12:43 +01:00
|
|
|
if (FlagGet(FLAG_DEFEATED_MAGMA_SPACE_CENTER))
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void SpawnLinkPartnerObjectEvent(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
u8 j = 0;
|
|
|
|
s16 x = 0;
|
|
|
|
s16 y = 0;
|
2019-09-14 02:22:09 +02:00
|
|
|
u8 movementTypes[] = {
|
|
|
|
MOVEMENT_TYPE_FACE_UP,
|
|
|
|
MOVEMENT_TYPE_FACE_LEFT,
|
|
|
|
MOVEMENT_TYPE_FACE_DOWN,
|
|
|
|
MOVEMENT_TYPE_FACE_RIGHT
|
|
|
|
};
|
|
|
|
s8 coordOffsets[][2] = {
|
2018-08-08 10:37:12 +02:00
|
|
|
{ 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)
|
2019-11-21 05:12:51 +01:00
|
|
|
linkSpriteId = OBJ_EVENT_GFX_LINK_RS_BRENDAN;
|
2018-08-08 10:37:12 +02:00
|
|
|
else
|
2019-11-21 05:12:51 +01:00
|
|
|
linkSpriteId = OBJ_EVENT_GFX_LINK_RS_MAY;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case VERSION_EMERALD:
|
|
|
|
if (gLinkPlayers[i].gender == 0)
|
2019-11-21 05:12:51 +01:00
|
|
|
linkSpriteId = OBJ_EVENT_GFX_RIVAL_BRENDAN_NORMAL;
|
2018-08-08 10:37:12 +02:00
|
|
|
else
|
2019-11-21 05:12:51 +01:00
|
|
|
linkSpriteId = OBJ_EVENT_GFX_RIVAL_MAY_NORMAL;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (gLinkPlayers[i].gender == 0)
|
2019-11-21 05:12:51 +01:00
|
|
|
linkSpriteId = OBJ_EVENT_GFX_RIVAL_BRENDAN_NORMAL;
|
2018-08-08 10:37:12 +02:00
|
|
|
else
|
2019-11-21 05:12:51 +01:00
|
|
|
linkSpriteId = OBJ_EVENT_GFX_RIVAL_MAY_NORMAL;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-11-21 04:55:44 +01:00
|
|
|
SpawnSpecialObjectEventParameterized(linkSpriteId, movementTypes[j], 240 - i, coordOffsets[j][0] + x + 7, coordOffsets[j][1] + y + 7, 0);
|
|
|
|
LoadLinkPartnerObjectEventSpritePalette(linkSpriteId, 240 - i, i);
|
2018-08-08 10:37:12 +02:00
|
|
|
j++;
|
2019-09-14 02:22:09 +02:00
|
|
|
if (j == MAX_LINK_PLAYERS)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
j = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void LoadLinkPartnerObjectEventSpritePalette(u8 graphicsId, u8 localEventId, u8 paletteNum)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-03-02 06:36:59 +01:00
|
|
|
u8 adjustedPaletteNum;
|
|
|
|
// Note: This temp var is necessary; paletteNum += 6 doesn't match.
|
|
|
|
adjustedPaletteNum = paletteNum + 6;
|
2019-11-21 05:12:51 +01:00
|
|
|
if (graphicsId == OBJ_EVENT_GFX_LINK_RS_BRENDAN ||
|
|
|
|
graphicsId == OBJ_EVENT_GFX_LINK_RS_MAY ||
|
|
|
|
graphicsId == OBJ_EVENT_GFX_RIVAL_BRENDAN_NORMAL ||
|
|
|
|
graphicsId == OBJ_EVENT_GFX_RIVAL_MAY_NORMAL)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 obj = GetObjectEventIdByLocalIdAndMap(localEventId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
2019-11-21 05:12:51 +01:00
|
|
|
if (obj != OBJECT_EVENTS_COUNT)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 spriteId = gObjectEvents[obj].spriteId;
|
2018-08-08 10:37:12 +02:00
|
|
|
struct Sprite *sprite = &gSprites[spriteId];
|
2019-03-02 06:36:59 +01:00
|
|
|
sprite->oam.paletteNum = adjustedPaletteNum;
|
2018-08-08 10:37:12 +02:00
|
|
|
|
|
|
|
switch (graphicsId)
|
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
case OBJ_EVENT_GFX_LINK_RS_BRENDAN:
|
|
|
|
LoadPalette(gObjectEventPal_RubySapphireBrendan, 0x100 + (adjustedPaletteNum << 4), 0x20);
|
|
|
|
break;
|
|
|
|
case OBJ_EVENT_GFX_LINK_RS_MAY:
|
|
|
|
LoadPalette(gObjectEventPal_RubySapphireMay, 0x100 + (adjustedPaletteNum << 4), 0x20);
|
|
|
|
break;
|
|
|
|
case OBJ_EVENT_GFX_RIVAL_BRENDAN_NORMAL:
|
|
|
|
LoadPalette(gObjectEventPal_Brendan, 0x100 + (adjustedPaletteNum << 4), 0x20);
|
|
|
|
break;
|
|
|
|
case OBJ_EVENT_GFX_RIVAL_MAY_NORMAL:
|
|
|
|
LoadPalette(gObjectEventPal_May, 0x100 + (adjustedPaletteNum << 4), 0x20);
|
|
|
|
break;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-11 23:25:07 +02:00
|
|
|
// NOTE: Coordinates are +7, +7 from actual in-map coordinates
|
2019-09-13 20:24:07 +02:00
|
|
|
static const struct UCoords8 sMauvilleGymSwitchCoords[] =
|
|
|
|
{
|
2018-08-08 10:37:12 +02:00
|
|
|
{ 7, 22},
|
|
|
|
{11, 19},
|
|
|
|
{10, 16},
|
|
|
|
{15, 16}
|
|
|
|
};
|
|
|
|
|
2019-10-11 23:25:07 +02:00
|
|
|
// Presses the stepped-on switch and raises the rest
|
|
|
|
void MauvilleGymPressSwitch(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-06-11 19:37:02 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sMauvilleGymSwitchCoords); i++)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
if (i == gSpecialVar_0x8004)
|
2020-07-02 06:17:14 +02:00
|
|
|
MapGridSetMetatileIdAt(sMauvilleGymSwitchCoords[i].x, sMauvilleGymSwitchCoords[i].y, METATILE_MauvilleGym_PressedSwitch);
|
2018-08-08 10:37:12 +02:00
|
|
|
else
|
2020-07-02 06:17:14 +02:00
|
|
|
MapGridSetMetatileIdAt(sMauvilleGymSwitchCoords[i].x, sMauvilleGymSwitchCoords[i].y, METATILE_MauvilleGym_RaisedSwitch);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-11 23:25:07 +02:00
|
|
|
// Sets the gym barriers back to the default state; their alt state is handled by MauvilleCity_Gym_EventScript_SetAltBarriers
|
|
|
|
void MauvilleGymSetDefaultBarriers(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
int x, y;
|
2019-10-11 23:25:07 +02:00
|
|
|
// All switches/barriers are within these coord ranges -7
|
2018-08-08 10:37:12 +02:00
|
|
|
for (y = 12; y < 24; y++)
|
|
|
|
{
|
|
|
|
for (x = 7; x < 16; x++)
|
|
|
|
{
|
|
|
|
switch (MapGridGetMetatileIdAt(x, y))
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH1_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH1_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH2_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH2_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH3_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH3_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH4_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH4_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH1_Off:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH1_On);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH2_Off:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH2_On);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH3_Off:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH3_On | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH4_Off:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH4_On | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH1_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH1_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH2_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH2_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH3_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH3_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH4_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH4_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH1_Off:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH1_On);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH2_Off:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH2_On);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH3_Off:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH3_On | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH4_Off:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH4_On | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamV1_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_On | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamV2_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_FloorTile);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamV1_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_Off | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamV2_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_FloorTile);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_PoleBottom_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamV1_On | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_FloorTile:
|
|
|
|
if (MapGridGetMetatileIdAt(x, y - 1) == METATILE_MauvilleGym_GreenBeamV1_On)
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamV2_On | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
else
|
2020-07-02 06:17:14 +02:00
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV2_On | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_PoleBottom_Off:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV1_On | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_PoleTop_Off:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleTop_On | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_PoleTop_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleTop_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-11 19:37:02 +02:00
|
|
|
// Presses all switches and deactivates all beams.
|
2019-10-11 23:25:07 +02:00
|
|
|
void MauvilleGymDeactivatePuzzle(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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--)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
MapGridSetMetatileIdAt(switchCoords->x, switchCoords->y, METATILE_MauvilleGym_PressedSwitch);
|
2018-08-08 10:37:12 +02:00
|
|
|
switchCoords++;
|
|
|
|
}
|
|
|
|
for (y = 12; y < 24; y++)
|
|
|
|
{
|
|
|
|
for (x = 7; x < 16; x++)
|
|
|
|
{
|
|
|
|
switch (MapGridGetMetatileIdAt(x, y))
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH1_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH1_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH2_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH2_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH3_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH3_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamH4_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH4_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH1_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH1_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH2_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH2_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH3_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH3_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamH4_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH4_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamV1_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_On | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_RedBeamV1_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_Off | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_GreenBeamV2_On:
|
|
|
|
case METATILE_MauvilleGym_RedBeamV2_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_FloorTile);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
2020-07-02 06:17:14 +02:00
|
|
|
case METATILE_MauvilleGym_PoleTop_On:
|
|
|
|
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleTop_Off);
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-15 10:58:52 +02:00
|
|
|
static const bool8 sSlidingDoorNextFrameDelay[] = {0, 1, 1, 1, 1};
|
2019-06-12 00:02:06 +02:00
|
|
|
|
|
|
|
static const u16 sPetalburgGymSlidingDoorMetatiles[] = {
|
2020-07-02 06:17:14 +02:00
|
|
|
METATILE_PetalburgGym_SlidingDoor_Frame0,
|
|
|
|
METATILE_PetalburgGym_SlidingDoor_Frame1,
|
|
|
|
METATILE_PetalburgGym_SlidingDoor_Frame2,
|
|
|
|
METATILE_PetalburgGym_SlidingDoor_Frame3,
|
|
|
|
METATILE_PetalburgGym_SlidingDoor_Frame4,
|
2019-06-12 00:02:06 +02:00
|
|
|
};
|
2018-08-08 10:37:12 +02:00
|
|
|
|
2019-10-15 10:58:52 +02:00
|
|
|
void PetalburgGymSlideOpenRoomDoors(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-10-15 10:58:52 +02:00
|
|
|
sSlidingDoorNextFrameCounter = 0;
|
|
|
|
sSlidingDoorFrame = 0;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_UNLOCK);
|
2019-10-15 10:58:52 +02:00
|
|
|
CreateTask(Task_PetalburgGymSlideOpenRoomDoors, 8);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
2019-10-15 10:58:52 +02:00
|
|
|
static void Task_PetalburgGymSlideOpenRoomDoors(u8 taskId)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-10-15 10:58:52 +02:00
|
|
|
if (sSlidingDoorNextFrameDelay[sSlidingDoorFrame] == sSlidingDoorNextFrameCounter)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-10-15 10:58:52 +02:00
|
|
|
PetalburgGymSetDoorMetatiles(gSpecialVar_0x8004, sPetalburgGymSlidingDoorMetatiles[sSlidingDoorFrame]);
|
|
|
|
sSlidingDoorNextFrameCounter = 0;
|
|
|
|
if ((++sSlidingDoorFrame) == ARRAY_COUNT(sPetalburgGymSlidingDoorMetatiles))
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-15 10:58:52 +02:00
|
|
|
sSlidingDoorNextFrameCounter++;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-15 10:58:52 +02:00
|
|
|
static void PetalburgGymSetDoorMetatiles(u8 roomNumber, u16 metatileId)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-06-12 00:02:06 +02:00
|
|
|
u16 doorCoordsX[4];
|
|
|
|
u16 doorCoordsY[4];
|
2018-08-08 10:37:12 +02:00
|
|
|
u8 i;
|
|
|
|
u8 nDoors = 0;
|
2019-06-12 00:02:06 +02:00
|
|
|
switch (roomNumber)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
nDoors = 2;
|
2019-06-12 00:02:06 +02:00
|
|
|
doorCoordsX[0] = 1;
|
|
|
|
doorCoordsX[1] = 7;
|
|
|
|
doorCoordsY[0] = 104;
|
|
|
|
doorCoordsY[1] = 104;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
nDoors = 2;
|
2019-06-12 00:02:06 +02:00
|
|
|
doorCoordsX[0] = 1;
|
|
|
|
doorCoordsX[1] = 7;
|
|
|
|
doorCoordsY[0] = 78;
|
|
|
|
doorCoordsY[1] = 78;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
nDoors = 2;
|
2019-06-12 00:02:06 +02:00
|
|
|
doorCoordsX[0] = 1;
|
|
|
|
doorCoordsX[1] = 7;
|
|
|
|
doorCoordsY[0] = 91;
|
|
|
|
doorCoordsY[1] = 91;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
nDoors = 1;
|
2019-06-12 00:02:06 +02:00
|
|
|
doorCoordsX[0] = 7;
|
|
|
|
doorCoordsY[0] = 39;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
nDoors = 2;
|
2019-06-12 00:02:06 +02:00
|
|
|
doorCoordsX[0] = 1;
|
|
|
|
doorCoordsX[1] = 7;
|
|
|
|
doorCoordsY[0] = 52;
|
|
|
|
doorCoordsY[1] = 52;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
nDoors = 1;
|
2019-06-12 00:02:06 +02:00
|
|
|
doorCoordsX[0] = 1;
|
|
|
|
doorCoordsY[0] = 65;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
nDoors = 1;
|
2019-06-12 00:02:06 +02:00
|
|
|
doorCoordsX[0] = 7;
|
|
|
|
doorCoordsY[0] = 13;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
nDoors = 1;
|
2019-06-12 00:02:06 +02:00
|
|
|
doorCoordsX[0] = 1;
|
|
|
|
doorCoordsY[0] = 26;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (i = 0; i < nDoors; i++)
|
|
|
|
{
|
2019-06-12 00:02:06 +02:00
|
|
|
MapGridSetMetatileIdAt(doorCoordsX[i] + 7, doorCoordsY[i] + 7, metatileId | METATILE_COLLISION_MASK);
|
|
|
|
MapGridSetMetatileIdAt(doorCoordsX[i] + 7, doorCoordsY[i] + 8, (metatileId + 8) | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
DrawWholeMapView();
|
|
|
|
}
|
|
|
|
|
2019-10-15 10:58:52 +02:00
|
|
|
void PetalburgGymUnlockRoomDoors(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-10-15 10:58:52 +02:00
|
|
|
PetalburgGymSetDoorMetatiles(gSpecialVar_0x8004, sPetalburgGymSlidingDoorMetatiles[4]);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
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);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-22 23:56:47 +02:00
|
|
|
void SetHiddenItemFlag(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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()];
|
2019-12-18 08:32:52 +01:00
|
|
|
if (GetMonData(pokemon, MON_DATA_FRIENDSHIP) == MAX_FRIENDSHIP)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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-17 07:49:07 +02:00
|
|
|
static void PCTurnOnEffect_1(s16 isPcTurnedOn, s8 dx, s8 dy)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
u16 tileId = 0;
|
2019-09-17 07:49:07 +02:00
|
|
|
if (isPcTurnedOn)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-09-13 20:24:07 +02:00
|
|
|
if (gSpecialVar_0x8004 == PC_LOCATION_OTHER)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
tileId = METATILE_Building_PC_Off;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
2019-09-13 20:24:07 +02:00
|
|
|
else if (gSpecialVar_0x8004 == PC_LOCATION_BRENDANS_HOUSE)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
tileId = METATILE_BrendansMaysHouse_BrendanPC_Off;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
2019-09-13 20:24:07 +02:00
|
|
|
else if (gSpecialVar_0x8004 == PC_LOCATION_MAYS_HOUSE)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
tileId = METATILE_BrendansMaysHouse_MayPC_Off;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-13 20:24:07 +02:00
|
|
|
if (gSpecialVar_0x8004 == PC_LOCATION_OTHER)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
tileId = METATILE_Building_PC_On;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
2019-09-13 20:24:07 +02:00
|
|
|
else if (gSpecialVar_0x8004 == PC_LOCATION_BRENDANS_HOUSE)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
tileId = METATILE_BrendansMaysHouse_BrendanPC_On;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
2019-09-13 20:24:07 +02:00
|
|
|
else if (gSpecialVar_0x8004 == PC_LOCATION_MAYS_HOUSE)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
tileId = METATILE_BrendansMaysHouse_MayPC_On;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
2019-02-27 04:56:22 +01:00
|
|
|
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
tileId = METATILE_Building_PC_Off;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
else if (gSpecialVar_0x8004 == 1)
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
tileId = METATILE_BrendansMaysHouse_BrendanPC_Off;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
else if (gSpecialVar_0x8004 == 2)
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
tileId = METATILE_BrendansMaysHouse_MayPC_Off;
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
2019-02-27 04:56:22 +01:00
|
|
|
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
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)
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
MapGridSetMetatileIdAt(18, 8, METATILE_Shop_Laptop1_Normal | METATILE_COLLISION_MASK);
|
|
|
|
MapGridSetMetatileIdAt(18, 9, METATILE_Shop_Laptop2_Normal | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
MapGridSetMetatileIdAt(18, 8, METATILE_Shop_Laptop1_Flash | METATILE_COLLISION_MASK);
|
|
|
|
MapGridSetMetatileIdAt(18, 9, METATILE_Shop_Laptop2_Flash | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
DrawWholeMapView();
|
|
|
|
task->data[4] ^= 1;
|
|
|
|
if ((++task->data[2]) == 5)
|
|
|
|
{
|
|
|
|
DestroyTask(task->data[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
task->data[3]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EndLotteryCornerComputerEffect(void)
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
MapGridSetMetatileIdAt(18, 8, METATILE_Shop_Laptop1_Normal | METATILE_COLLISION_MASK);
|
|
|
|
MapGridSetMetatileIdAt(18, 9, METATILE_Shop_Laptop2_Normal | METATILE_COLLISION_MASK);
|
2018-08-08 10:37:12 +02:00
|
|
|
DrawWholeMapView();
|
|
|
|
}
|
|
|
|
|
2019-12-21 00:52:29 +01:00
|
|
|
void SetTrickHouseNuggetFlag(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
u16 *specVar = &gSpecialVar_0x8004;
|
2019-12-21 00:52:29 +01:00
|
|
|
u16 flag = FLAG_HIDDEN_ITEM_TRICK_HOUSE_NUGGET;
|
2018-08-08 10:37:12 +02:00
|
|
|
*specVar = flag;
|
|
|
|
FlagSet(flag);
|
|
|
|
}
|
|
|
|
|
2019-12-21 00:52:29 +01:00
|
|
|
void ResetTrickHouseNuggetFlag(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
u16 *specVar = &gSpecialVar_0x8004;
|
2019-12-21 00:52:29 +01:00
|
|
|
u16 flag = FLAG_HIDDEN_ITEM_TRICK_HOUSE_NUGGET;
|
2018-08-08 10:37:12 +02:00
|
|
|
*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))
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
species = GetMonData(pokemon, MON_DATA_SPECIES);
|
|
|
|
if (gBaseStats[species].type1 == TYPE_GRASS || gBaseStats[species].type2 == TYPE_GRASS)
|
|
|
|
{
|
|
|
|
gSpecialVar_Result = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gSpecialVar_Result = FALSE;
|
|
|
|
}
|
|
|
|
|
2018-12-19 20:08:01 +01:00
|
|
|
void SpawnCameraObject(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-11-21 05:12:51 +01:00
|
|
|
u8 obj = SpawnSpecialObjectEventParameterized(OBJ_EVENT_GFX_BOY_1, MOVEMENT_TYPE_FACE_DOWN, OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7, 3);
|
2019-11-21 04:55:44 +01:00
|
|
|
gObjectEvents[obj].invisible = TRUE;
|
|
|
|
CameraObjectSetFollowedObjectId(gObjectEvents[obj].spriteId);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
2018-12-19 20:08:01 +01:00
|
|
|
void RemoveCameraObject(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
CameraObjectSetFollowedObjectId(GetPlayerAvatarObjectId());
|
2019-11-21 05:12:51 +01:00
|
|
|
RemoveObjectEventByLocalIdAndMap(OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
static const u8 sSlotMachineRandomSeeds[] = {12, 2, 4, 5, 1, 8, 7, 11, 3, 10, 9, 6};
|
2019-09-14 02:22:09 +02:00
|
|
|
static const u8 sSlotMachineIds[] = {0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5};
|
|
|
|
static const u8 sSlotMachineServiceDayIds[] = {3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5};
|
2018-08-11 23:51:54 +02:00
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
u32 rnd = gSaveBlock1Ptr->easyChatPairs[0].unk0_0 + gSaveBlock1Ptr->easyChatPairs[0].unk2 + sSlotMachineRandomSeeds[gSpecialVar_0x8004];
|
2019-09-13 20:24:07 +02:00
|
|
|
if (GetPriceReduction(POKENEWS_GAME_CORNER))
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
return sSlotMachineServiceDayIds[rnd % SLOT_MACHINE_COUNT];
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
2019-09-14 02:22:09 +02:00
|
|
|
return sSlotMachineIds[rnd % SLOT_MACHINE_COUNT];
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool8 FoundAbandonedShipRoom1Key(void)
|
|
|
|
{
|
|
|
|
u16 *specVar = &gSpecialVar_0x8004;
|
2018-10-18 04:07:23 +02:00
|
|
|
u16 flag = FLAG_HIDDEN_ITEM_ABANDONED_SHIP_RM_1_KEY;
|
2018-08-08 10:37:12 +02:00
|
|
|
*specVar = flag;
|
|
|
|
if (!FlagGet(flag))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool8 FoundAbandonedShipRoom2Key(void)
|
|
|
|
{
|
|
|
|
u16 *specVar = &gSpecialVar_0x8004;
|
2018-10-18 04:07:23 +02:00
|
|
|
u16 flag = FLAG_HIDDEN_ITEM_ABANDONED_SHIP_RM_2_KEY;
|
2018-08-08 10:37:12 +02:00
|
|
|
*specVar = flag;
|
|
|
|
if (!FlagGet(flag))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool8 FoundAbandonedShipRoom4Key(void)
|
|
|
|
{
|
|
|
|
u16 *specVar = &gSpecialVar_0x8004;
|
2018-10-18 04:07:23 +02:00
|
|
|
u16 flag = FLAG_HIDDEN_ITEM_ABANDONED_SHIP_RM_4_KEY;
|
2018-08-08 10:37:12 +02:00
|
|
|
*specVar = flag;
|
|
|
|
if (!FlagGet(flag))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool8 FoundAbandonedShipRoom6Key(void)
|
|
|
|
{
|
|
|
|
u16 *specVar = &gSpecialVar_0x8004;
|
2018-10-18 04:07:23 +02:00
|
|
|
u16 flag = FLAG_HIDDEN_ITEM_ABANDONED_SHIP_RM_6_KEY;
|
2018-08-08 10:37:12 +02:00
|
|
|
*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);
|
2019-11-11 03:54:00 +01:00
|
|
|
if (GetRibbonCount(leadMon) > NUM_CUTIES_RIBBONS)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2021-02-18 15:59:24 +01:00
|
|
|
TryPutSpotTheCutiesOnAir(leadMon, MON_DATA_EFFORT_RIBBON);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool8 Special_AreLeadMonEVsMaxedOut(void)
|
|
|
|
{
|
2021-01-07 22:11:45 +01:00
|
|
|
if (GetMonEVCount(&gPlayerParty[GetLeadMonIndex()]) >= MAX_TOTAL_EVS)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 TryUpdateRusturfTunnelState(void)
|
|
|
|
{
|
2019-11-07 02:38:53 +01:00
|
|
|
if (!FlagGet(FLAG_RUSTURF_TUNNEL_OPENED)
|
|
|
|
&& gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(RUSTURF_TUNNEL)
|
|
|
|
&& gSaveBlock1Ptr->location.mapNum == MAP_NUM(RUSTURF_TUNNEL))
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
void SetShoalItemFlag(u16 unused)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
FlagSet(FLAG_SYS_SHOAL_ITEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PutZigzagoonInPlayerParty(void)
|
|
|
|
{
|
|
|
|
u16 monData;
|
2021-01-07 23:13:14 +01:00
|
|
|
CreateMon(&gPlayerParty[0], SPECIES_ZIGZAGOON, 7, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0);
|
2018-08-08 10:37:12 +02:00
|
|
|
monData = TRUE;
|
2019-05-14 15:22:16 +02:00
|
|
|
SetMonData(&gPlayerParty[0], MON_DATA_ABILITY_NUM, &monData);
|
2018-08-08 10:37:12 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
#define horizontalPan data[0]
|
|
|
|
#define delayCounter data[1]
|
|
|
|
#define numShakes data[2]
|
|
|
|
#define delay data[3]
|
|
|
|
#define verticalPan data[4]
|
|
|
|
|
|
|
|
void ShakeCamera(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-09-30 07:42:52 +02:00
|
|
|
u8 taskId = CreateTask(Task_ShakeCamera, 9);
|
|
|
|
gTasks[taskId].horizontalPan = gSpecialVar_0x8005;
|
|
|
|
gTasks[taskId].delayCounter = 0;
|
|
|
|
gTasks[taskId].numShakes = gSpecialVar_0x8006;
|
|
|
|
gTasks[taskId].delay = gSpecialVar_0x8007;
|
|
|
|
gTasks[taskId].verticalPan = gSpecialVar_0x8004;
|
2018-08-08 10:37:12 +02:00
|
|
|
SetCameraPanningCallback(NULL);
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_M_STRENGTH);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
static void Task_ShakeCamera(u8 taskId)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
delayCounter++;
|
|
|
|
if (delayCounter % delay == 0)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-09-30 07:42:52 +02:00
|
|
|
delayCounter = 0;
|
|
|
|
numShakes--;
|
|
|
|
horizontalPan = -horizontalPan;
|
|
|
|
verticalPan = -verticalPan;
|
|
|
|
SetCameraPanning(horizontalPan, verticalPan);
|
|
|
|
if (numShakes == 0)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-09-30 07:42:52 +02:00
|
|
|
StopCameraShake(taskId);
|
2018-08-08 10:37:12 +02:00
|
|
|
InstallCameraPanAheadCallback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
static void StopCameraShake(u8 taskId)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
}
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
#undef horizontalPan
|
|
|
|
#undef delayCounter
|
|
|
|
#undef numShakes
|
|
|
|
#undef delay
|
|
|
|
#undef verticalPan
|
|
|
|
|
2018-08-08 10:37:12 +02:00
|
|
|
bool8 FoundBlackGlasses(void)
|
|
|
|
{
|
2018-10-19 20:59:18 +02:00
|
|
|
return FlagGet(FLAG_HIDDEN_ITEM_ROUTE_116_BLACK_GLASSES);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetRoute119Weather(void)
|
|
|
|
{
|
2019-03-01 07:49:11 +01:00
|
|
|
if (IsMapTypeOutdoors(GetLastUsedWarpMapType()) != TRUE)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-09-13 20:24:07 +02:00
|
|
|
SetSav1Weather(WEATHER_ROUTE119_CYCLE);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetRoute123Weather(void)
|
|
|
|
{
|
2019-03-01 07:49:11 +01:00
|
|
|
if (IsMapTypeOutdoors(GetLastUsedWarpMapType()) != TRUE)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-09-13 20:24:07 +02:00
|
|
|
SetSav1Weather(WEATHER_ROUTE123_CYCLE);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2019-11-21 04:55:44 +01:00
|
|
|
void TryInitBattleTowerAwardManObjectEvent(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
//TryInitLocalObjectEvent(6);
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-11-09 09:07:32 +01:00
|
|
|
bool8 MonOTNameNotPlayer(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
if (GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_LANGUAGE) != GAME_LANGUAGE)
|
2019-11-09 09:07:32 +01:00
|
|
|
return TRUE;
|
2018-08-08 10:37:12 +02:00
|
|
|
|
|
|
|
GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_OT_NAME, gStringVar1);
|
2019-11-09 09:07:32 +01:00
|
|
|
|
2018-08-08 10:37:12 +02:00
|
|
|
if (!StringCompare(gSaveBlock2Ptr->playerName, gStringVar1))
|
|
|
|
return FALSE;
|
2019-11-09 09:07:32 +01:00
|
|
|
|
2018-08-08 10:37:12 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BufferLottoTicketNumber(void)
|
|
|
|
{
|
|
|
|
if (gSpecialVar_Result >= 10000)
|
|
|
|
{
|
|
|
|
TV_PrintIntToStringVar(0, gSpecialVar_Result);
|
|
|
|
}
|
|
|
|
else if (gSpecialVar_Result >= 1000)
|
|
|
|
{
|
|
|
|
gStringVar1[0] = CHAR_0;
|
2019-09-30 21:43:44 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1 + 1, gSpecialVar_Result, STR_CONV_MODE_LEFT_ALIGN, CountDigits(gSpecialVar_Result));
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
else if (gSpecialVar_Result >= 100)
|
|
|
|
{
|
|
|
|
gStringVar1[0] = CHAR_0;
|
|
|
|
gStringVar1[1] = CHAR_0;
|
2019-09-30 21:43:44 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1 + 2, gSpecialVar_Result, STR_CONV_MODE_LEFT_ALIGN, CountDigits(gSpecialVar_Result));
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
else if (gSpecialVar_Result >= 10)
|
|
|
|
{
|
|
|
|
gStringVar1[0] = CHAR_0;
|
|
|
|
gStringVar1[1] = CHAR_0;
|
|
|
|
gStringVar1[2] = CHAR_0;
|
2019-09-30 21:43:44 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1 + 3, gSpecialVar_Result, STR_CONV_MODE_LEFT_ALIGN, CountDigits(gSpecialVar_Result));
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gStringVar1[0] = CHAR_0;
|
|
|
|
gStringVar1[1] = CHAR_0;
|
|
|
|
gStringVar1[2] = CHAR_0;
|
|
|
|
gStringVar1[3] = CHAR_0;
|
2019-09-30 21:43:44 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1 + 4, gSpecialVar_Result, STR_CONV_MODE_LEFT_ALIGN, CountDigits(gSpecialVar_Result));
|
2018-08-08 10:37:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-05 21:08:07 +01:00
|
|
|
u16 GetMysteryEventCardVal(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
switch (gSpecialVar_Result)
|
|
|
|
{
|
2019-11-05 21:08:07 +01:00
|
|
|
case GET_NUM_STAMPS:
|
|
|
|
return mevent_081445C0(GET_NUM_STAMPS_INTERNAL);
|
|
|
|
case GET_MAX_STAMPS:
|
|
|
|
return mevent_081445C0(GET_MAX_STAMPS_INTERNAL);
|
|
|
|
case GET_CARD_BATTLES_WON:
|
|
|
|
return mevent_081445C0(GET_CARD_BATTLES_WON_INTERNAL);
|
|
|
|
case 3: // Never occurs
|
2018-08-08 10:37:12 +02:00
|
|
|
return mevent_081445C0(1);
|
2019-11-05 21:08:07 +01:00
|
|
|
case 4: // Never occurs
|
2018-08-08 10:37:12 +02:00
|
|
|
return mevent_081445C0(2);
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-13 20:24:07 +02:00
|
|
|
bool8 BufferTMHMMoveName(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2018-08-08 10:37:12 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-09-13 20:24:07 +02:00
|
|
|
bool8 IsBadEggInParty(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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)
|
2018-08-08 10:37:12 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-01-08 11:43:06 +01:00
|
|
|
bool8 InMultiPartnerRoom(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
2020-01-08 11:43:06 +01:00
|
|
|
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BATTLE_FRONTIER_BATTLE_TOWER_MULTI_PARTNER_ROOM)
|
|
|
|
&& gSaveBlock1Ptr->location.mapNum == MAP_NUM(BATTLE_FRONTIER_BATTLE_TOWER_MULTI_PARTNER_ROOM) &&
|
2018-08-25 19:59:47 +02:00
|
|
|
VarGet(VAR_FRONTIER_BATTLE_MODE) == FRONTIER_MODE_MULTIS)
|
2018-08-08 10:37:12 +02:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
void OffsetCameraForBattle(void)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2019-06-12 01:12:47 +02:00
|
|
|
static const u16 sElevatorWindowTiles_Ascending[][3] =
|
2018-11-29 21:19:00 +01:00
|
|
|
{
|
2019-06-12 01:12:47 +02:00
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
METATILE_BattleFrontier_Elevator_Top0,
|
|
|
|
METATILE_BattleFrontier_Elevator_Top1,
|
|
|
|
METATILE_BattleFrontier_Elevator_Top2
|
2019-06-12 01:12:47 +02:00
|
|
|
},
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
METATILE_BattleFrontier_Elevator_Mid0,
|
|
|
|
METATILE_BattleFrontier_Elevator_Mid1,
|
|
|
|
METATILE_BattleFrontier_Elevator_Mid2
|
2019-06-12 01:12:47 +02:00
|
|
|
},
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
METATILE_BattleFrontier_Elevator_Bottom0,
|
|
|
|
METATILE_BattleFrontier_Elevator_Bottom1,
|
|
|
|
METATILE_BattleFrontier_Elevator_Bottom2
|
2019-06-12 01:12:47 +02:00
|
|
|
},
|
2018-11-29 21:19:00 +01:00
|
|
|
};
|
2019-06-12 01:12:47 +02:00
|
|
|
|
|
|
|
static const u16 sElevatorWindowTiles_Descending[][3] =
|
2018-11-29 21:19:00 +01:00
|
|
|
{
|
2019-06-12 01:12:47 +02:00
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
METATILE_BattleFrontier_Elevator_Top0,
|
|
|
|
METATILE_BattleFrontier_Elevator_Top2,
|
|
|
|
METATILE_BattleFrontier_Elevator_Top1
|
2019-06-12 01:12:47 +02:00
|
|
|
},
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
METATILE_BattleFrontier_Elevator_Mid0,
|
|
|
|
METATILE_BattleFrontier_Elevator_Mid2,
|
|
|
|
METATILE_BattleFrontier_Elevator_Mid1
|
2019-06-12 01:12:47 +02:00
|
|
|
},
|
|
|
|
{
|
2020-07-02 06:17:14 +02:00
|
|
|
METATILE_BattleFrontier_Elevator_Bottom0,
|
|
|
|
METATILE_BattleFrontier_Elevator_Bottom2,
|
|
|
|
METATILE_BattleFrontier_Elevator_Bottom1
|
2019-06-12 01:12:47 +02:00
|
|
|
},
|
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)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
u8 deptStoreFloor;
|
2018-12-27 23:30:47 +01:00
|
|
|
switch (gSaveBlock1Ptr->dynamicWarp.mapNum)
|
2018-08-08 10:37:12 +02:00
|
|
|
{
|
|
|
|
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_1F):
|
2019-09-13 20:24:07 +02:00
|
|
|
deptStoreFloor = DEPT_STORE_FLOORNUM_1F;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_2F):
|
2019-09-13 20:24:07 +02:00
|
|
|
deptStoreFloor = DEPT_STORE_FLOORNUM_2F;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_3F):
|
2019-09-13 20:24:07 +02:00
|
|
|
deptStoreFloor = DEPT_STORE_FLOORNUM_3F;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_4F):
|
2019-09-13 20:24:07 +02:00
|
|
|
deptStoreFloor = DEPT_STORE_FLOORNUM_4F;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_5F):
|
2019-09-13 20:24:07 +02:00
|
|
|
deptStoreFloor = DEPT_STORE_FLOORNUM_5F;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP):
|
2019-09-13 20:24:07 +02:00
|
|
|
deptStoreFloor = DEPT_STORE_FLOORNUM_ROOFTOP;
|
2018-08-08 10:37:12 +02:00
|
|
|
break;
|
|
|
|
default:
|
2019-09-13 20:24:07 +02:00
|
|
|
deptStoreFloor = DEPT_STORE_FLOORNUM_1F;
|
2018-08-08 10:37:12 +02:00
|
|
|
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-17 07:49:07 +02:00
|
|
|
sLilycoveDeptStore_NeverRead = 0;
|
|
|
|
sLilycoveDeptStore_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-17 07:49:07 +02:00
|
|
|
sLilycoveDeptStore_NeverRead = 0;
|
|
|
|
sLilycoveDeptStore_DefaultFloorChoice = 0;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
|
|
|
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_4F):
|
2019-09-17 07:49:07 +02:00
|
|
|
sLilycoveDeptStore_NeverRead = 0;
|
|
|
|
sLilycoveDeptStore_DefaultFloorChoice = 1;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
|
|
|
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_3F):
|
2019-09-17 07:49:07 +02:00
|
|
|
sLilycoveDeptStore_NeverRead = 0;
|
|
|
|
sLilycoveDeptStore_DefaultFloorChoice = 2;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
|
|
|
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_2F):
|
2019-09-17 07:49:07 +02:00
|
|
|
sLilycoveDeptStore_NeverRead = 0;
|
|
|
|
sLilycoveDeptStore_DefaultFloorChoice = 3;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
|
|
|
case MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_1F):
|
2019-09-17 07:49:07 +02:00
|
|
|
sLilycoveDeptStore_NeverRead = 0;
|
|
|
|
sLilycoveDeptStore_DefaultFloorChoice = 4;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
return sLilycoveDeptStore_DefaultFloorChoice;
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
void MoveElevator(void)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
static const u8 sElevatorTripLength[] = { 8, 16, 24, 32, 38, 46, 52, 56, 57 };
|
2018-08-11 23:51:54 +02:00
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
s16 *data = gTasks[CreateTask(Task_MoveElevator, 9)].data;
|
2018-08-09 08:53:21 +02:00
|
|
|
u16 floorDelta;
|
|
|
|
|
|
|
|
data[1] = 0;
|
|
|
|
data[2] = 0;
|
|
|
|
data[4] = 1;
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
// descending
|
2018-08-09 08:53:21 +02:00
|
|
|
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
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
data[5] = sElevatorTripLength[floorDelta];
|
2018-08-09 08:53:21 +02:00
|
|
|
|
|
|
|
SetCameraPanningCallback(NULL);
|
2019-09-14 02:22:09 +02:00
|
|
|
MoveElevatorWindowLights(floorDelta, data[6]);
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_ELEVATOR);
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
static void Task_MoveElevator(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]);
|
2019-09-14 02:22:09 +02:00
|
|
|
|
|
|
|
// arrived at floor
|
2018-08-09 08:53:21 +02:00
|
|
|
if (data[2] == data[5])
|
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_DING_DONG);
|
2018-08-09 08:53:21 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
InstallCameraPanAheadCallback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
void ShowDeptStoreElevatorFloorSelect(void)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
|
|
|
int xPos;
|
2018-08-19 01:06:10 +02:00
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
sTutorMoveAndElevatorWindowId = AddWindow(&gElevatorFloor_WindowTemplate);
|
|
|
|
SetStandardWindowBorderStyle(sTutorMoveAndElevatorWindowId, 0);
|
2018-08-19 01:06:10 +02:00
|
|
|
|
2018-08-09 08:53:21 +02:00
|
|
|
xPos = GetStringCenterAlignXOffset(1, gText_ElevatorNowOn, 64);
|
2019-09-17 07:49:07 +02:00
|
|
|
AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, 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);
|
2019-09-17 07:49:07 +02:00
|
|
|
AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, 1, gDeptStoreFloorNames[gSpecialVar_0x8005], xPos, 17, TEXT_SPEED_FF, NULL);
|
2018-08-19 01:06:10 +02:00
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
PutWindowTilemap(sTutorMoveAndElevatorWindowId);
|
|
|
|
CopyWindowToVram(sTutorMoveAndElevatorWindowId, 3);
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
void CloseDeptStoreElevatorWindow(void)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(sTutorMoveAndElevatorWindowId, TRUE);
|
|
|
|
RemoveWindow(sTutorMoveAndElevatorWindowId);
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
static void MoveElevatorWindowLights(u16 floorDelta, bool8 descending)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
static const u8 sElevatorLightCycles[] = { 3, 6, 9, 12, 15, 18, 21, 24, 27 };
|
2018-08-11 23:51:54 +02:00
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
if (FuncIsActiveTask(Task_MoveElevatorWindowLights) != TRUE)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
u8 taskId = CreateTask(Task_MoveElevatorWindowLights, 8);
|
2018-08-09 08:53:21 +02:00
|
|
|
gTasks[taskId].data[0] = 0;
|
|
|
|
gTasks[taskId].data[1] = 0;
|
2019-06-12 01:12:47 +02:00
|
|
|
gTasks[taskId].data[2] = descending;
|
2019-09-14 02:22:09 +02:00
|
|
|
gTasks[taskId].data[3] = sElevatorLightCycles[floorDelta];
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
static void Task_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
|
2019-06-12 01:12:47 +02:00
|
|
|
if (data[2] == FALSE)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
|
|
|
for (y = 0; y < 3; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < 3; x++)
|
|
|
|
{
|
2019-06-12 01:12:47 +02:00
|
|
|
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++)
|
|
|
|
{
|
2019-06-12 01:12:47 +02:00
|
|
|
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]++;
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
void BufferVarsForIVRater(void)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
|
|
|
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;
|
2018-09-05 00:31:37 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-09-16 06:29:59 +02:00
|
|
|
bool32 PlayerNotAtTrainerHillEntrance(void)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
|
|
|
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;
|
2019-09-13 23:03:43 +02:00
|
|
|
*var %= FRONTIER_MANIAC_FACILITY_COUNT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShowFrontierManiacMessage(void)
|
|
|
|
{
|
|
|
|
static const u8 *const sFrontierManiacMessages[][FRONTIER_MANIAC_MESSAGE_COUNT] =
|
|
|
|
{
|
|
|
|
[FRONTIER_MANIAC_BATTLE_TOWER_SINGLES] =
|
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge2_Text_SalonMaidenIsThere,
|
|
|
|
BattleFrontier_Lounge2_Text_SalonMaidenSilverMons,
|
|
|
|
BattleFrontier_Lounge2_Text_SalonMaidenGoldMons
|
2019-09-13 23:03:43 +02:00
|
|
|
},
|
|
|
|
[FRONTIER_MANIAC_BATTLE_TOWER_DOUBLES] =
|
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge2_Text_DoubleBattleAdvice1,
|
|
|
|
BattleFrontier_Lounge2_Text_DoubleBattleAdvice2,
|
|
|
|
BattleFrontier_Lounge2_Text_DoubleBattleAdvice3
|
2019-09-13 23:03:43 +02:00
|
|
|
},
|
|
|
|
[FRONTIER_MANIAC_BATTLE_TOWER_MULTIS] =
|
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge2_Text_MultiBattleAdvice,
|
|
|
|
BattleFrontier_Lounge2_Text_MultiBattleAdvice,
|
|
|
|
BattleFrontier_Lounge2_Text_MultiBattleAdvice
|
2019-09-13 23:03:43 +02:00
|
|
|
},
|
2019-11-17 00:11:27 +01:00
|
|
|
[FRONTIER_MANIAC_BATTLE_TOWER_LINK] =
|
2019-09-13 23:03:43 +02:00
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge2_Text_LinkMultiBattleAdvice,
|
|
|
|
BattleFrontier_Lounge2_Text_LinkMultiBattleAdvice,
|
|
|
|
BattleFrontier_Lounge2_Text_LinkMultiBattleAdvice
|
2019-09-13 23:03:43 +02:00
|
|
|
},
|
|
|
|
[FRONTIER_MANIAC_BATTLE_DOME] =
|
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge2_Text_DomeAceIsThere,
|
|
|
|
BattleFrontier_Lounge2_Text_DomeAceSilverMons,
|
|
|
|
BattleFrontier_Lounge2_Text_DomeAceGoldMons
|
2019-09-13 23:03:43 +02:00
|
|
|
},
|
|
|
|
[FRONTIER_MANIAC_BATTLE_FACTORY] =
|
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge2_Text_FactoryHeadIsThere,
|
|
|
|
BattleFrontier_Lounge2_Text_FactoryHeadSilverMons,
|
|
|
|
BattleFrontier_Lounge2_Text_FactoryHeadGoldMons
|
2019-09-13 23:03:43 +02:00
|
|
|
},
|
|
|
|
[FRONTIER_MANIAC_BATTLE_PALACE] =
|
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge2_Text_PalaceMavenIsThere,
|
|
|
|
BattleFrontier_Lounge2_Text_PalaceMavenSilverMons,
|
|
|
|
BattleFrontier_Lounge2_Text_PalaceMavenGoldMons
|
2019-09-13 23:03:43 +02:00
|
|
|
},
|
|
|
|
[FRONTIER_MANIAC_BATTLE_ARENA] =
|
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge2_Text_ArenaTycoonIsThere,
|
|
|
|
BattleFrontier_Lounge2_Text_ArenaTycoonSilverMons,
|
|
|
|
BattleFrontier_Lounge2_Text_ArenaTycoonGoldMons
|
2019-09-13 23:03:43 +02:00
|
|
|
},
|
|
|
|
[FRONTIER_MANIAC_BATTLE_PIKE] =
|
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge2_Text_PikeQueenIsThere,
|
|
|
|
BattleFrontier_Lounge2_Text_PikeQueenSilverMons,
|
|
|
|
BattleFrontier_Lounge2_Text_PikeQueenGoldMons
|
2019-09-13 23:03:43 +02:00
|
|
|
},
|
|
|
|
[FRONTIER_MANIAC_BATTLE_PYRAMID] =
|
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge2_Text_PyramidKingIsThere,
|
|
|
|
BattleFrontier_Lounge2_Text_PyramidKingSilverMons,
|
|
|
|
BattleFrontier_Lounge2_Text_PyramidKingGoldMons
|
2019-09-13 23:03:43 +02:00
|
|
|
},
|
2018-08-11 23:51:54 +02:00
|
|
|
};
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
static const u8 sFrontierManiacStreakThresholds[][FRONTIER_MANIAC_MESSAGE_COUNT - 1] =
|
|
|
|
{
|
2019-11-17 00:11:27 +01:00
|
|
|
[FRONTIER_MANIAC_BATTLE_TOWER_SINGLES] = { 21, 56 },
|
|
|
|
[FRONTIER_MANIAC_BATTLE_TOWER_DOUBLES] = { 21, 35 },
|
|
|
|
[FRONTIER_MANIAC_BATTLE_TOWER_MULTIS] = { 255, 255 },
|
|
|
|
[FRONTIER_MANIAC_BATTLE_TOWER_LINK] = { 255, 255 },
|
|
|
|
[FRONTIER_MANIAC_BATTLE_DOME] = { 2, 4 },
|
|
|
|
[FRONTIER_MANIAC_BATTLE_FACTORY] = { 7, 21 },
|
|
|
|
[FRONTIER_MANIAC_BATTLE_PALACE] = { 7, 21 },
|
|
|
|
[FRONTIER_MANIAC_BATTLE_ARENA] = { 14, 28 },
|
|
|
|
[FRONTIER_MANIAC_BATTLE_PIKE] = { 13, 112 }, //BUG: 112 (0x70) is probably a mistake; the Pike Queen is battled twice well before that
|
|
|
|
[FRONTIER_MANIAC_BATTLE_PYRAMID] = { 7, 56 }
|
2018-08-11 23:51:54 +02:00
|
|
|
};
|
|
|
|
|
2018-08-09 08:53:21 +02:00
|
|
|
u8 i;
|
2019-09-13 20:24:07 +02:00
|
|
|
u16 winStreak = 0;
|
2019-09-13 23:03:43 +02:00
|
|
|
u16 facility = VarGet(VAR_FRONTIER_MANIAC_FACILITY);
|
2019-09-13 20:24:07 +02:00
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
switch (facility)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
case FRONTIER_MANIAC_BATTLE_TOWER_SINGLES:
|
|
|
|
case FRONTIER_MANIAC_BATTLE_TOWER_DOUBLES:
|
|
|
|
case FRONTIER_MANIAC_BATTLE_TOWER_MULTIS:
|
2019-11-17 00:11:27 +01:00
|
|
|
case FRONTIER_MANIAC_BATTLE_TOWER_LINK:
|
2019-09-13 23:03:43 +02:00
|
|
|
if (gSaveBlock2Ptr->frontier.towerWinStreaks[facility][FRONTIER_LVL_50]
|
|
|
|
>= gSaveBlock2Ptr->frontier.towerWinStreaks[facility][FRONTIER_LVL_OPEN])
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
winStreak = gSaveBlock2Ptr->frontier.towerWinStreaks[facility][FRONTIER_LVL_50];
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
winStreak = gSaveBlock2Ptr->frontier.towerWinStreaks[facility][FRONTIER_LVL_OPEN];
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
break;
|
2019-09-13 23:03:43 +02:00
|
|
|
case FRONTIER_MANIAC_BATTLE_DOME:
|
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;
|
2019-09-13 23:03:43 +02:00
|
|
|
case FRONTIER_MANIAC_BATTLE_FACTORY:
|
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;
|
2019-09-13 23:03:43 +02:00
|
|
|
case FRONTIER_MANIAC_BATTLE_PALACE:
|
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;
|
2019-09-13 23:03:43 +02:00
|
|
|
case FRONTIER_MANIAC_BATTLE_ARENA:
|
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;
|
2019-09-13 23:03:43 +02:00
|
|
|
case FRONTIER_MANIAC_BATTLE_PIKE:
|
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;
|
2019-09-13 23:03:43 +02:00
|
|
|
case FRONTIER_MANIAC_BATTLE_PYRAMID:
|
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 23:03:43 +02:00
|
|
|
for (i = 0; i < FRONTIER_MANIAC_MESSAGE_COUNT - 1 && sFrontierManiacStreakThresholds[facility][i] < winStreak; i++);
|
2018-08-09 08:53:21 +02:00
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
ShowFieldMessage(sFrontierManiacMessages[facility][i]);
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
// gSpecialVar_0x8005 and 0x8006 here are used by MoveElevator
|
|
|
|
void BufferBattleTowerElevatorFloors(void)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
static const u16 sBattleTowerStreakThresholds[] = {
|
|
|
|
7, 14, 21, 28, 35, 49, 63, 77, 91, 0
|
2018-08-11 23:51:54 +02:00
|
|
|
};
|
|
|
|
|
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 23:03:43 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sBattleTowerStreakThresholds) - 1; i++)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
if (sBattleTowerStreakThresholds[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-19 23:26:25 +02:00
|
|
|
// Scrollable Multichoice task data defines
|
|
|
|
#define tMaxItemsOnScreen data[0]
|
|
|
|
#define tNumItems data[1]
|
|
|
|
#define tLeft data[2]
|
|
|
|
#define tTop data[3]
|
|
|
|
#define tWidth data[4]
|
|
|
|
#define tHeight data[5]
|
|
|
|
#define tKeepOpenAfterSelect data[6]
|
|
|
|
#define tScrollOffset data[7]
|
|
|
|
#define tSelectedRow data[8]
|
|
|
|
#define tScrollMultiId data[11]
|
|
|
|
#define tScrollArrowId data[12]
|
|
|
|
#define tWindowId data[13]
|
|
|
|
#define tListTaskId data[14]
|
|
|
|
#define tTaskId data[15]
|
|
|
|
// data[9] and [10] unused
|
|
|
|
|
2019-09-13 20:24:07 +02:00
|
|
|
void ShowScrollableMultichoice(void)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
u8 taskId = CreateTask(Task_ShowScrollableMultichoice, 8);
|
2018-08-09 08:53:21 +02:00
|
|
|
struct Task *task = &gTasks[taskId];
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tScrollMultiId = gSpecialVar_0x8004;
|
2018-08-09 08:53:21 +02:00
|
|
|
|
|
|
|
switch (gSpecialVar_0x8004)
|
|
|
|
{
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_NONE:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = 1;
|
|
|
|
task->tNumItems = 1;
|
|
|
|
task->tLeft = 1;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 1;
|
|
|
|
task->tHeight = 1;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_GLASS_WORKSHOP_VENDOR:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN - 1;
|
|
|
|
task->tNumItems = 8;
|
|
|
|
task->tLeft = 1;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 9;
|
|
|
|
task->tHeight = 10;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_POKEMON_FAN_CLUB_RATER:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
|
|
|
|
task->tNumItems = 12;
|
|
|
|
task->tLeft = 1;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 7;
|
|
|
|
task->tHeight = 12;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_1:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
|
|
|
|
task->tNumItems = 11;
|
|
|
|
task->tLeft = 14;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 15;
|
|
|
|
task->tHeight = 12;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_2:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
|
|
|
|
task->tNumItems = 6;
|
|
|
|
task->tLeft = 14;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 15;
|
|
|
|
task->tHeight = 12;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_BF_EXCHANGE_CORNER_VITAMIN_VENDOR:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
|
|
|
|
task->tNumItems = 7;
|
|
|
|
task->tLeft = 14;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 15;
|
|
|
|
task->tHeight = 12;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_BF_EXCHANGE_CORNER_HOLD_ITEM_VENDOR:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
|
|
|
|
task->tNumItems = 10;
|
|
|
|
task->tLeft = 14;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 15;
|
|
|
|
task->tHeight = 12;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_BERRY_POWDER_VENDOR:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
|
|
|
|
task->tNumItems = 12;
|
|
|
|
task->tLeft = 15;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 14;
|
|
|
|
task->tHeight = 12;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_BF_RECEPTIONIST:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
|
|
|
|
task->tNumItems = 10;
|
|
|
|
task->tLeft = 17;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 11;
|
|
|
|
task->tHeight = 12;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_BF_MOVE_TUTOR_1:
|
|
|
|
case SCROLL_MULTI_BF_MOVE_TUTOR_2:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
|
|
|
|
task->tNumItems = 11;
|
|
|
|
task->tLeft = 15;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 14;
|
|
|
|
task->tHeight = 12;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_SS_TIDAL_DESTINATION:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
|
|
|
|
task->tNumItems = 7;
|
|
|
|
task->tLeft = 19;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 10;
|
|
|
|
task->tHeight = 12;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
2019-09-13 20:24:07 +02:00
|
|
|
case SCROLL_MULTI_BATTLE_TENT_RULES:
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
|
|
|
|
task->tNumItems = 7;
|
|
|
|
task->tLeft = 17;
|
|
|
|
task->tTop = 1;
|
|
|
|
task->tWidth = 12;
|
|
|
|
task->tHeight = 12;
|
|
|
|
task->tKeepOpenAfterSelect = FALSE;
|
|
|
|
task->tTaskId = taskId;
|
2018-08-09 08:53:21 +02:00
|
|
|
break;
|
|
|
|
default:
|
2019-09-19 23:26:25 +02:00
|
|
|
gSpecialVar_Result = MULTI_B_PRESSED;
|
2018-08-09 08:53:21 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-19 23:26:25 +02:00
|
|
|
static const u8 *const sScrollableMultichoiceOptions[][MAX_SCROLL_MULTI_LENGTH] =
|
2019-09-13 20:24:07 +02:00
|
|
|
{
|
|
|
|
[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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
static void Task_ShowScrollableMultichoice(u8 taskId)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-19 23:26:25 +02:00
|
|
|
u32 width;
|
2018-08-09 08:53:21 +02:00
|
|
|
u8 i, windowId;
|
|
|
|
struct WindowTemplate template;
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
|
|
|
ScriptContext2_Enable();
|
2019-09-17 07:49:07 +02:00
|
|
|
sScrollableMultichoice_ScrollOffset = 0;
|
|
|
|
sScrollableMultichoice_ItemSpriteId = MAX_SPRITES;
|
2019-09-19 23:26:25 +02:00
|
|
|
FillFrontierExchangeCornerWindowAndItemIcon(task->tScrollMultiId, 0);
|
|
|
|
ShowBattleFrontierTutorWindow(task->tScrollMultiId, 0);
|
|
|
|
sScrollableMultichoice_ListMenuItem = AllocZeroed(task->tNumItems * 8);
|
2019-09-17 07:49:07 +02:00
|
|
|
sFrontierExchangeCorner_NeverRead = 0;
|
2019-09-14 02:22:09 +02:00
|
|
|
InitScrollableMultichoice();
|
2018-08-09 08:53:21 +02:00
|
|
|
|
2019-09-19 23:26:25 +02:00
|
|
|
for (width = 0, i = 0; i < task->tNumItems; i++)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-19 23:26:25 +02:00
|
|
|
const u8 *text = sScrollableMultichoiceOptions[gSpecialVar_0x8004][i];
|
2019-09-17 07:49:07 +02:00
|
|
|
sScrollableMultichoice_ListMenuItem[i].name = text;
|
|
|
|
sScrollableMultichoice_ListMenuItem[i].id = i;
|
2019-09-19 23:26:25 +02:00
|
|
|
width = DisplayTextAndGetWidth(text, width);
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tWidth = ConvertPixelWidthToTileWidth(width);
|
2018-08-19 01:06:10 +02:00
|
|
|
|
2019-09-19 23:26:25 +02:00
|
|
|
if (task->tLeft + task->tWidth > MAX_MULTICHOICE_WIDTH + 1)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-19 23:26:25 +02:00
|
|
|
int adjustedLeft = MAX_MULTICHOICE_WIDTH + 1 - task->tWidth;
|
|
|
|
if (adjustedLeft < 0)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tLeft = 0;
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tLeft = adjustedLeft;
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-19 23:26:25 +02:00
|
|
|
template = CreateWindowTemplate(0, task->tLeft, task->tTop, task->tWidth, task->tHeight, 0xF, 0x64);
|
2018-08-09 08:53:21 +02:00
|
|
|
windowId = AddWindow(&template);
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tWindowId = windowId;
|
2018-08-09 08:53:21 +02:00
|
|
|
SetStandardWindowBorderStyle(windowId, 0);
|
|
|
|
|
2019-09-19 23:26:25 +02:00
|
|
|
gScrollableMultichoice_ListMenuTemplate.totalItems = task->tNumItems;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.maxShowed = task->tMaxItemsOnScreen;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.windowId = task->tWindowId;
|
2018-08-09 08:53:21 +02:00
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
ScrollableMultichoice_UpdateScrollArrows(taskId);
|
2019-09-19 23:26:25 +02:00
|
|
|
task->tListTaskId = ListMenuInit(&gScrollableMultichoice_ListMenuTemplate, task->tScrollOffset, task->tSelectedRow);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2019-09-14 02:22:09 +02:00
|
|
|
gTasks[taskId].func = ScrollableMultichoice_ProcessInput;
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
static void InitScrollableMultichoice(void)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
gScrollableMultichoice_ListMenuTemplate.items = sScrollableMultichoice_ListMenuItem;
|
2019-09-14 02:22:09 +02:00
|
|
|
gScrollableMultichoice_ListMenuTemplate.moveCursorFunc = ScrollableMultichoice_MoveCursor;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.itemPrintFunc = NULL;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.totalItems = 1;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.maxShowed = 1;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.windowId = 0;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.header_X = 0;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.item_X = 8;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.cursor_X = 0;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.upText_Y = 1;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.cursorPal = 2;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.fillValue = 1;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.cursorShadowPal = 3;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.lettersSpacing = 0;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.itemVerticalPadding = 0;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.scrollMultiple = 0;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.fontId = 1;
|
|
|
|
gScrollableMultichoice_ListMenuTemplate.cursorKind = 0;
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
static void ScrollableMultichoice_MoveCursor(s32 itemIndex, bool8 onInit, struct ListMenu *list)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
PlaySE(SE_SELECT);
|
2019-09-14 02:22:09 +02:00
|
|
|
taskId = FindTaskIdByFunc(ScrollableMultichoice_ProcessInput);
|
2021-02-20 05:22:26 +01:00
|
|
|
if (taskId != TASK_NONE)
|
2018-08-09 08:53:21 +02:00
|
|
|
{
|
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-19 23:26:25 +02:00
|
|
|
ListMenuGetScrollAndRow(task->tListTaskId, &selection, NULL);
|
2019-09-17 07:49:07 +02:00
|
|
|
sScrollableMultichoice_ScrollOffset = selection;
|
2019-09-19 23:26:25 +02:00
|
|
|
ListMenuGetCurrentItemArrayId(task->tListTaskId, &selection);
|
|
|
|
HideFrontierExchangeCornerItemIcon(task->tScrollMultiId, sFrontierExchangeCorner_NeverRead);
|
|
|
|
FillFrontierExchangeCornerWindowAndItemIcon(task->tScrollMultiId, selection);
|
|
|
|
ShowBattleFrontierTutorMoveDescription(task->tScrollMultiId, selection);
|
2019-09-17 07:49:07 +02:00
|
|
|
sFrontierExchangeCorner_NeverRead = selection;
|
2018-08-09 08:53:21 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-10 09:42:06 +02:00
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
static void ScrollableMultichoice_ProcessInput(u8 taskId)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
2019-09-19 23:26:25 +02:00
|
|
|
s32 input = ListMenu_ProcessInput(task->tListTaskId);
|
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;
|
2019-03-03 08:50:40 +01:00
|
|
|
case LIST_CANCEL:
|
2019-09-19 23:26:25 +02:00
|
|
|
gSpecialVar_Result = MULTI_B_PRESSED;
|
2018-08-10 09:42:06 +02:00
|
|
|
PlaySE(SE_SELECT);
|
2019-09-14 02:22:09 +02:00
|
|
|
CloseScrollableMultichoice(taskId);
|
2018-08-10 09:42:06 +02:00
|
|
|
break;
|
|
|
|
default:
|
2019-02-02 11:04:38 +01:00
|
|
|
gSpecialVar_Result = input;
|
2018-08-10 09:42:06 +02:00
|
|
|
PlaySE(SE_SELECT);
|
2019-09-19 23:26:25 +02:00
|
|
|
if (!task->tKeepOpenAfterSelect)
|
2018-10-24 23:14:45 +02:00
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
CloseScrollableMultichoice(taskId);
|
2018-10-24 23:14:45 +02:00
|
|
|
}
|
2019-09-19 23:26:25 +02:00
|
|
|
// if selected option was the last one (Exit)
|
|
|
|
else if (input == task->tNumItems - 1)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
CloseScrollableMultichoice(taskId);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
ScrollableMultichoice_RemoveScrollArrows(taskId);
|
2018-08-11 23:51:54 +02:00
|
|
|
task->func = sub_813A600;
|
|
|
|
EnableBothScriptContexts();
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
static void CloseScrollableMultichoice(u8 taskId)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
u16 selection;
|
2018-08-10 09:42:06 +02:00
|
|
|
struct Task *task = &gTasks[taskId];
|
2019-09-19 23:26:25 +02:00
|
|
|
ListMenuGetCurrentItemArrayId(task->tListTaskId, &selection);
|
|
|
|
HideFrontierExchangeCornerItemIcon(task->tScrollMultiId, selection);
|
2019-09-14 02:22:09 +02:00
|
|
|
ScrollableMultichoice_RemoveScrollArrows(taskId);
|
2019-09-19 23:26:25 +02:00
|
|
|
DestroyListMenuTask(task->tListTaskId, NULL, NULL);
|
2019-09-17 07:49:07 +02:00
|
|
|
Free(sScrollableMultichoice_ListMenuItem);
|
2019-09-19 23:26:25 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(task->tWindowId, 1);
|
|
|
|
FillWindowPixelBuffer(task->tWindowId, PIXEL_FILL(0));
|
|
|
|
CopyWindowToVram(task->tWindowId, 2);
|
|
|
|
RemoveWindow(task->tWindowId);
|
2018-08-10 09:42:06 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
}
|
|
|
|
|
2019-09-19 23:26:25 +02:00
|
|
|
// Functionally unused; tKeepOpenAfterSelect is only != 0 in unused functions
|
2018-08-11 23:51:54 +02:00
|
|
|
static void sub_813A600(u8 taskId)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-19 23:26:25 +02:00
|
|
|
switch (gTasks[taskId].tKeepOpenAfterSelect)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case 2:
|
2019-09-19 23:26:25 +02:00
|
|
|
gTasks[taskId].tKeepOpenAfterSelect = 1;
|
2018-08-10 09:42:06 +02:00
|
|
|
gTasks[taskId].func = sub_813A664;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
// Never called
|
2018-08-10 09:42:06 +02:00
|
|
|
void sub_813A630(void)
|
|
|
|
{
|
|
|
|
u8 taskId = FindTaskIdByFunc(sub_813A600);
|
2021-02-20 05:22:26 +01:00
|
|
|
if (taskId == TASK_NONE)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-19 23:26:25 +02:00
|
|
|
gTasks[taskId].tKeepOpenAfterSelect++;
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-11 23:51:54 +02:00
|
|
|
static void sub_813A664(u8 taskId)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
2019-09-14 02:22:09 +02:00
|
|
|
ScrollableMultichoice_UpdateScrollArrows(taskId);
|
|
|
|
gTasks[taskId].func = ScrollableMultichoice_ProcessInput;
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
static void ScrollableMultichoice_UpdateScrollArrows(u8 taskId)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
static const struct ScrollArrowsTemplate sScrollableMultichoice_ScrollArrowsTemplate = {
|
2019-03-03 08:50:40 +01:00
|
|
|
.firstArrowType = SCROLL_ARROW_UP,
|
2018-08-11 23:51:54 +02:00
|
|
|
.firstX = 0,
|
|
|
|
.firstY = 0,
|
2019-03-03 08:50:40 +01:00
|
|
|
.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];
|
2019-09-14 02:22:09 +02:00
|
|
|
struct ScrollArrowsTemplate template = sScrollableMultichoice_ScrollArrowsTemplate;
|
2019-09-19 23:26:25 +02:00
|
|
|
if (task->tMaxItemsOnScreen != task->data[1])
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-19 23:26:25 +02:00
|
|
|
template.firstX = (task->tWidth / 2) * 8 + 12 + (task->tLeft - 1) * 8;
|
2018-08-10 09:42:06 +02:00
|
|
|
template.firstY = 8;
|
2019-09-19 23:26:25 +02:00
|
|
|
template.secondX = (task->tWidth / 2) * 8 + 12 + (task->tLeft - 1) * 8;
|
|
|
|
template.secondY = task->tHeight * 8 + 10;
|
2018-08-10 09:42:06 +02:00
|
|
|
template.fullyUpThreshold = 0;
|
2019-09-19 23:26:25 +02:00
|
|
|
template.fullyDownThreshold = task->data[1] - task->tMaxItemsOnScreen;
|
|
|
|
task->tScrollArrowId = AddScrollIndicatorArrowPair(&template, &sScrollableMultichoice_ScrollOffset);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
static void ScrollableMultichoice_RemoveScrollArrows(u8 taskId)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
2019-09-19 23:26:25 +02:00
|
|
|
if (task->tMaxItemsOnScreen != task->data[1])
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-19 23:26:25 +02:00
|
|
|
RemoveScrollIndicatorArrowPair(task->tScrollArrowId);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
void SetBattleTowerLinkPlayerGfx(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
if (gLinkPlayers[i].gender == MALE)
|
|
|
|
{
|
2019-11-21 05:12:51 +01:00
|
|
|
VarSet(VAR_OBJ_GFX_ID_F - i, OBJ_EVENT_GFX_BRENDAN_NORMAL);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-21 05:12:51 +01:00
|
|
|
VarSet(VAR_OBJ_GFX_ID_F - i, OBJ_EVENT_GFX_RIVAL_MAY_NORMAL);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
void ShowNatureGirlMessage(void)
|
|
|
|
{
|
2020-07-17 02:12:12 +02:00
|
|
|
static const u8 *const sNatureGirlMessages[NUM_NATURES] = {
|
2019-09-17 07:49:07 +02:00
|
|
|
[NATURE_HARDY] = BattleFrontier_Lounge5_Text_NatureGirlHardy,
|
|
|
|
[NATURE_LONELY] = BattleFrontier_Lounge5_Text_NatureGirlLonely,
|
|
|
|
[NATURE_BRAVE] = BattleFrontier_Lounge5_Text_NatureGirlBrave,
|
|
|
|
[NATURE_ADAMANT] = BattleFrontier_Lounge5_Text_NatureGirlAdamant,
|
|
|
|
[NATURE_NAUGHTY] = BattleFrontier_Lounge5_Text_NatureGirlNaughty,
|
|
|
|
[NATURE_BOLD] = BattleFrontier_Lounge5_Text_NatureGirlBold,
|
|
|
|
[NATURE_DOCILE] = BattleFrontier_Lounge5_Text_NatureGirlDocileNaiveQuietQuirky,
|
|
|
|
[NATURE_RELAXED] = BattleFrontier_Lounge5_Text_NatureGirlRelaxed,
|
|
|
|
[NATURE_IMPISH] = BattleFrontier_Lounge5_Text_NatureGirlImpish,
|
|
|
|
[NATURE_LAX] = BattleFrontier_Lounge5_Text_NatureGirlLax,
|
|
|
|
[NATURE_TIMID] = BattleFrontier_Lounge5_Text_NatureGirlTimid,
|
|
|
|
[NATURE_HASTY] = BattleFrontier_Lounge5_Text_NatureGirlHasty,
|
|
|
|
[NATURE_SERIOUS] = BattleFrontier_Lounge5_Text_NatureGirlSerious,
|
|
|
|
[NATURE_JOLLY] = BattleFrontier_Lounge5_Text_NatureGirlJolly,
|
|
|
|
[NATURE_NAIVE] = BattleFrontier_Lounge5_Text_NatureGirlDocileNaiveQuietQuirky,
|
|
|
|
[NATURE_MODEST] = BattleFrontier_Lounge5_Text_NatureGirlModest,
|
|
|
|
[NATURE_MILD] = BattleFrontier_Lounge5_Text_NatureGirlMild,
|
|
|
|
[NATURE_QUIET] = BattleFrontier_Lounge5_Text_NatureGirlDocileNaiveQuietQuirky,
|
|
|
|
[NATURE_BASHFUL] = BattleFrontier_Lounge5_Text_NatureGirlBashful,
|
|
|
|
[NATURE_RASH] = BattleFrontier_Lounge5_Text_NatureGirlRash,
|
|
|
|
[NATURE_CALM] = BattleFrontier_Lounge5_Text_NatureGirlCalm,
|
|
|
|
[NATURE_GENTLE] = BattleFrontier_Lounge5_Text_NatureGirlGentle,
|
|
|
|
[NATURE_SASSY] = BattleFrontier_Lounge5_Text_NatureGirlSassy,
|
|
|
|
[NATURE_CAREFUL] = BattleFrontier_Lounge5_Text_NatureGirlCareful,
|
|
|
|
[NATURE_QUIRKY] = BattleFrontier_Lounge5_Text_NatureGirlDocileNaiveQuietQuirky,
|
2018-08-11 23:51:54 +02:00
|
|
|
};
|
|
|
|
|
2018-08-10 09:42:06 +02:00
|
|
|
u8 nature;
|
|
|
|
|
|
|
|
if (gSpecialVar_0x8004 >= PARTY_SIZE)
|
|
|
|
{
|
|
|
|
gSpecialVar_0x8004 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nature = GetNature(&gPlayerParty[gSpecialVar_0x8004]);
|
2019-09-13 23:03:43 +02:00
|
|
|
ShowFieldMessage(sNatureGirlMessages[nature]);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
void UpdateFrontierGambler(u16 daysSince)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
u16 *var = GetVarPointer(VAR_FRONTIER_GAMBLER_CHALLENGE);
|
|
|
|
*var += daysSince;
|
|
|
|
*var %= FRONTIER_GAMBLER_CHALLENGE_COUNT;
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
void ShowFrontierGamblerLookingMessage(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
static const u8 *const sFrontierGamblerLookingMessages[] =
|
2019-09-13 20:24:07 +02:00
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattleTowerSingle,
|
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattleTowerDouble,
|
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattleTowerMulti,
|
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattleDomeSingle,
|
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattleDomeDouble,
|
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattleFactorySingle,
|
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattleFactoryDouble,
|
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattlePalaceSingle,
|
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattlePalaceDouble,
|
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattleArena,
|
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattlePike,
|
|
|
|
BattleFrontier_Lounge3_Text_ChallengeBattlePyramid,
|
2018-08-11 23:51:54 +02:00
|
|
|
};
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
u16 challenge = VarGet(VAR_FRONTIER_GAMBLER_CHALLENGE);
|
|
|
|
ShowFieldMessage(sFrontierGamblerLookingMessages[challenge]);
|
|
|
|
VarSet(VAR_FRONTIER_GAMBLER_SET_CHALLENGE, challenge);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
void ShowFrontierGamblerGoMessage(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
static const u8 *const sFrontierGamblerGoMessages[] =
|
2019-09-13 20:24:07 +02:00
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge3_Text_GetToBattleTowerSingle,
|
|
|
|
BattleFrontier_Lounge3_Text_GetToBattleTowerDouble,
|
|
|
|
BattleFrontier_Lounge3_Text_GetToBattleTowerMulti,
|
|
|
|
BattleFrontier_Lounge3_Text_GetToBattleDomeSingle,
|
|
|
|
BattleFrontier_Lounge3_Text_GetToBattleDomeDouble,
|
|
|
|
BattleFrontier_Lounge3_Text_GetToBattleFactorySingle,
|
|
|
|
BattleFrontier_Lounge3_Text_GetToBattleFactoryDouble,
|
|
|
|
BattleFrontier_Lounge3_Text_GetToBattlePalaceSingle,
|
|
|
|
BattleFrontier_Lounge3_Text_GetToBattlePalaceDouble,
|
|
|
|
BattleFrontier_Lounge3_Text_GetToBattleArena,
|
|
|
|
BattleFrontier_Lounge3_Text_GetToBattlePike,
|
|
|
|
BattleFrontier_Lounge3_Text_GetToBattlePyramid,
|
2018-08-11 23:51:54 +02:00
|
|
|
};
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
ShowFieldMessage(sFrontierGamblerGoMessages[VarGet(VAR_FRONTIER_GAMBLER_SET_CHALLENGE)]);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
void FrontierGamblerSetWonOrLost(bool8 won)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
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 23:03:43 +02:00
|
|
|
u16 challenge = VarGet(VAR_FRONTIER_GAMBLER_SET_CHALLENGE);
|
2018-08-25 19:59:47 +02:00
|
|
|
u16 frontierFacilityId = VarGet(VAR_FRONTIER_FACILITY);
|
2018-08-10 09:42:06 +02:00
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
if (VarGet(VAR_FRONTIER_GAMBLER_STATE) == FRONTIER_GAMBLER_PLACED_BET)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-13 20:24:07 +02:00
|
|
|
if (sFrontierChallenges[challenge] == FRONTIER_CHALLENGE(frontierFacilityId, battleMode))
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
if (won)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
VarSet(VAR_FRONTIER_GAMBLER_STATE, FRONTIER_GAMBLER_WON);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
VarSet(VAR_FRONTIER_GAMBLER_STATE, FRONTIER_GAMBLER_LOST);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
void UpdateBattlePointsWindow(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
|
|
|
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);
|
2019-09-17 07:49:07 +02:00
|
|
|
AddTextPrinterParameterized(sBattlePointsWindowId, 1, string, x, 1, 0, NULL);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
void ShowBattlePointsWindow(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
static const struct WindowTemplate sBattlePoints_WindowTemplate = {
|
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,
|
|
|
|
};
|
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
sBattlePointsWindowId = AddWindow(&sBattlePoints_WindowTemplate);
|
|
|
|
SetStandardWindowBorderStyle(sBattlePointsWindowId, 0);
|
2019-09-13 23:03:43 +02:00
|
|
|
UpdateBattlePointsWindow();
|
2019-09-17 07:49:07 +02:00
|
|
|
CopyWindowToVram(sBattlePointsWindowId, 2);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
void CloseBattlePointsWindow(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(sBattlePointsWindowId, TRUE);
|
|
|
|
RemoveWindow(sBattlePointsWindowId);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
void ShowFrontierExchangeCornerItemIconWindow(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
static const struct WindowTemplate sFrontierExchangeCorner_ItemIconWindowTemplate = {
|
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,
|
|
|
|
};
|
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
sFrontierExchangeCorner_ItemIconWindowId = AddWindow(&sFrontierExchangeCorner_ItemIconWindowTemplate);
|
|
|
|
SetStandardWindowBorderStyle(sFrontierExchangeCorner_ItemIconWindowId, 0);
|
|
|
|
CopyWindowToVram(sFrontierExchangeCorner_ItemIconWindowId, 2);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
void CloseFrontierExchangeCornerItemIconWindow(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(sFrontierExchangeCorner_ItemIconWindowId, TRUE);
|
|
|
|
RemoveWindow(sFrontierExchangeCorner_ItemIconWindowId);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-09-13 20:24:07 +02:00
|
|
|
#include "data/battle_frontier/battle_frontier_exchange_corner.h"
|
2018-08-11 23:51:54 +02:00
|
|
|
|
2019-09-19 23:26:25 +02:00
|
|
|
if (menu >= SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_1 && menu <= SCROLL_MULTI_BF_EXCHANGE_CORNER_HOLD_ITEM_VENDOR)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-03-02 23:25:39 +01: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:
|
2019-09-13 23:03:43 +02:00
|
|
|
AddTextPrinterParameterized2(0, 1, sFrontierExchangeCorner_Decor1Descriptions[selection], 0, NULL, 2, 1, 3);
|
|
|
|
if (sFrontierExchangeCorner_Decor1[selection] == 0xFFFF)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_Decor1[selection]);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FreeSpriteTilesByTag(5500);
|
|
|
|
FreeSpritePaletteByTag(5500);
|
2019-09-17 07:49:07 +02:00
|
|
|
sScrollableMultichoice_ItemSpriteId = AddDecorationIconObject(sFrontierExchangeCorner_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:
|
2019-09-13 23:03:43 +02:00
|
|
|
AddTextPrinterParameterized2(0, 1, sFrontierExchangeCorner_Decor2Descriptions[selection], 0, NULL, 2, 1, 3);
|
|
|
|
if (sFrontierExchangeCorner_Decor2[selection] == 0xFFFF)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-13 23:03:43 +02:00
|
|
|
ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_Decor2[selection]);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FreeSpriteTilesByTag(5500);
|
|
|
|
FreeSpritePaletteByTag(5500);
|
2019-09-17 07:49:07 +02:00
|
|
|
sScrollableMultichoice_ItemSpriteId = AddDecorationIconObject(sFrontierExchangeCorner_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:
|
2019-09-13 23:03:43 +02:00
|
|
|
AddTextPrinterParameterized2(0, 1, sFrontierExchangeCorner_VitaminsDescriptions[selection], 0, NULL, 2, 1, 3);
|
|
|
|
ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_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:
|
2019-09-13 23:03:43 +02:00
|
|
|
AddTextPrinterParameterized2(0, 1, sFrontierExchangeCorner_HoldItemsDescriptions[selection], 0, NULL, 2, 1, 3);
|
|
|
|
ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_HoldItems[selection]);
|
2018-08-10 09:42:06 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
static void ShowFrontierExchangeCornerItemIcon(u16 item)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
|
|
|
FreeSpriteTilesByTag(5500);
|
|
|
|
FreeSpritePaletteByTag(5500);
|
2019-09-17 07:49:07 +02:00
|
|
|
sScrollableMultichoice_ItemSpriteId = AddItemIconSprite(5500, 5500, item);
|
2018-08-10 09:42:06 +02:00
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
if (sScrollableMultichoice_ItemSpriteId != MAX_SPRITES)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
gSprites[sScrollableMultichoice_ItemSpriteId].oam.priority = 0;
|
|
|
|
gSprites[sScrollableMultichoice_ItemSpriteId].pos1.x = 36;
|
|
|
|
gSprites[sScrollableMultichoice_ItemSpriteId].pos1.y = 92;
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-13 23:03:43 +02:00
|
|
|
static void HideFrontierExchangeCornerItemIcon(u16 menu, u16 unused)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
if (sScrollableMultichoice_ItemSpriteId != 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:
|
2019-09-17 07:49:07 +02:00
|
|
|
DestroySpriteAndFreeResources(&gSprites[sScrollableMultichoice_ItemSpriteId]);
|
2018-08-10 09:42:06 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-09-17 07:49:07 +02:00
|
|
|
sScrollableMultichoice_ItemSpriteId = 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
|
|
|
|
};
|
2018-08-10 09:42:06 +02:00
|
|
|
|
2019-09-13 20:24:07 +02:00
|
|
|
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-17 07:49:07 +02:00
|
|
|
sTutorMoveAndElevatorWindowId = AddWindow(&sBattleFrontierTutor_WindowTemplate);
|
|
|
|
SetStandardWindowBorderStyle(sTutorMoveAndElevatorWindowId, 0);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
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[] =
|
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge7_Text_SoftboiledDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_SeismicTossDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_DreamEaterDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_MegaPunchDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_MegaKickDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_BodySlamDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_RockSlideDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_CounterDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_ThunderWaveDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_SwordsDanceDesc,
|
2018-08-11 23:51:54 +02:00
|
|
|
gText_Exit,
|
|
|
|
};
|
2018-08-10 09:42:06 +02:00
|
|
|
|
2019-09-13 20:24:07 +02:00
|
|
|
static const u8 *const sBattleFrontier_TutorMoveDescriptions2[] =
|
|
|
|
{
|
2019-11-12 23:52:32 +01:00
|
|
|
BattleFrontier_Lounge7_Text_DefenseCurlDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_SnoreDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_MudSlapDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_SwiftDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_IcyWindDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_EndureDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_PsychUpDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_IcePunchDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_ThunderPunchDesc,
|
|
|
|
BattleFrontier_Lounge7_Text_FirePunchDesc,
|
2018-08-11 23:51:54 +02:00
|
|
|
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
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
FillWindowPixelRect(sTutorMoveAndElevatorWindowId, 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-17 07:49:07 +02:00
|
|
|
AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, 1, sBattleFrontier_TutorMoveDescriptions2[selection], 0, 1, 0, NULL);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, 1, sBattleFrontier_TutorMoveDescriptions1[selection], 0, 1, 0, NULL);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
void CloseBattleFrontierTutorWindow(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(sTutorMoveAndElevatorWindowId, TRUE);
|
|
|
|
RemoveWindow(sTutorMoveAndElevatorWindowId);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
// Never called
|
2018-08-10 09:42:06 +02:00
|
|
|
void sub_813ADD4(void)
|
|
|
|
{
|
|
|
|
u16 scrollOffset, selectedRow;
|
|
|
|
u8 i;
|
|
|
|
u8 taskId = FindTaskIdByFunc(sub_813A600);
|
2021-02-20 05:22:26 +01:00
|
|
|
if (taskId != TASK_NONE)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
2019-09-19 23:26:25 +02:00
|
|
|
ListMenuGetScrollAndRow(task->tListTaskId, &scrollOffset, &selectedRow);
|
|
|
|
SetStandardWindowBorderStyle(task->tWindowId, 0);
|
2018-08-19 01:06:10 +02:00
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
for (i = 0; i < MAX_SCROLL_MULTI_ON_SCREEN; i++)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-19 23:26:25 +02:00
|
|
|
AddTextPrinterParameterized5(task->tWindowId, 1, sScrollableMultichoiceOptions[gSpecialVar_0x8004][scrollOffset + i], 10, i * 16, TEXT_SPEED_FF, NULL, 0, 0);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-19 23:26:25 +02:00
|
|
|
AddTextPrinterParameterized(task->tWindowId, 1, gText_SelectorArrow, 0, selectedRow * 16, TEXT_SPEED_FF, NULL);
|
|
|
|
PutWindowTilemap(task->tWindowId);
|
|
|
|
CopyWindowToVram(task->tWindowId, 3);
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
void GetBattleFrontierTutorMoveIndex(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
// Never called
|
2018-08-10 09:42:06 +02:00
|
|
|
void sub_813AF48(void)
|
|
|
|
{
|
|
|
|
u8 taskId = FindTaskIdByFunc(sub_813A600);
|
2021-02-20 05:22:26 +01:00
|
|
|
if (taskId != TASK_NONE)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
2019-09-19 23:26:25 +02:00
|
|
|
DestroyListMenuTask(task->tListTaskId, NULL, NULL);
|
2019-09-17 07:49:07 +02:00
|
|
|
Free(sScrollableMultichoice_ListMenuItem);
|
2019-09-19 23:26:25 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(task->tWindowId, TRUE);
|
|
|
|
FillWindowPixelBuffer(task->tWindowId, PIXEL_FILL(0));
|
|
|
|
ClearWindowTilemap(task->tWindowId);
|
|
|
|
CopyWindowToVram(task->tWindowId, 2);
|
|
|
|
RemoveWindow(task->tWindowId);
|
2018-08-10 09:42:06 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-19 23:26:25 +02:00
|
|
|
// Undefine Scrollable Multichoice task data macros
|
|
|
|
#undef tMaxItemsOnScreen
|
|
|
|
#undef tNumItems
|
|
|
|
#undef tLeft
|
|
|
|
#undef tTop
|
|
|
|
#undef tWidth
|
|
|
|
#undef tHeight
|
|
|
|
#undef tKeepOpenAfterSelect
|
|
|
|
#undef tScrollOffset
|
|
|
|
#undef tSelectedRow
|
|
|
|
#undef tScrollMultiId
|
|
|
|
#undef tScrollArrowId
|
|
|
|
#undef tWindowId
|
|
|
|
#undef tListTaskId
|
|
|
|
#undef tTaskId
|
|
|
|
|
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
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2018-12-28 20:10:02 +01:00
|
|
|
LoadPalette(&sDeoxysRockPalettes[rockLevel], 0x1A0, 8);
|
2019-11-21 04:55:44 +01:00
|
|
|
TryGetObjectEventIdByLocalIdAndMap(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectEventId);
|
2018-08-19 01:06:10 +02:00
|
|
|
|
2018-12-28 20:10:02 +01:00
|
|
|
if (rockLevel == 0)
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_M_CONFUSE_RAY);
|
2018-08-10 09:42:06 +02:00
|
|
|
else
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_RG_DEOXYS_MOVE);
|
2018-08-10 09:42:06 +02:00
|
|
|
|
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);
|
2019-11-21 06:14:40 +01:00
|
|
|
Overworld_SetObjEventTemplateCoords(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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-31 22:00:37 +01:00
|
|
|
void SetDeoxysRockPalette(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
void SetPCBoxToSendMon(u8 boxId)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
sPCBoxToSendMon = boxId;
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
u16 GetPCBoxToSendMon(void)
|
2018-08-10 09:42:06 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
return sPCBoxToSendMon;
|
2018-08-10 09:42:06 +02:00
|
|
|
}
|
2018-08-10 23:07:23 +02:00
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
bool8 ShouldShowBoxWasFullMessage(void)
|
2018-08-10 23:07:23 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
if (!FlagGet(FLAG_SHOWN_BOX_WAS_FULL_MESSAGE))
|
2018-08-10 23:07:23 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
if (StorageGetCurrentBox() != VarGet(VAR_PC_BOX_TO_SEND_MON))
|
2018-08-10 23:07:23 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
FlagSet(FLAG_SHOWN_BOX_WAS_FULL_MESSAGE);
|
2018-08-10 23:07:23 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-09-17 07:49:07 +02:00
|
|
|
bool8 IsDestinationBoxFull(void)
|
2018-08-10 23:07:23 +02:00
|
|
|
{
|
|
|
|
int box;
|
|
|
|
int i;
|
2019-09-17 07:49:07 +02:00
|
|
|
SetPCBoxToSendMon(VarGet(VAR_PC_BOX_TO_SEND_MON));
|
2018-08-10 23:07:23 +02:00
|
|
|
box = StorageGetCurrentBox();
|
|
|
|
do
|
|
|
|
{
|
|
|
|
for (i = 0; i < IN_BOX_COUNT; i++)
|
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
if (GetBoxMonData(GetBoxedMonPtr(box, i), MON_DATA_SPECIES, 0) == SPECIES_NONE)
|
2018-08-10 23:07:23 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
if (GetPCBoxToSendMon() != box)
|
2018-08-10 23:07:23 +02:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
FlagClear(FLAG_SHOWN_BOX_WAS_FULL_MESSAGE);
|
2018-08-10 23:07:23 +02:00
|
|
|
}
|
2019-09-17 07:49:07 +02:00
|
|
|
VarSet(VAR_PC_BOX_TO_SEND_MON, box);
|
|
|
|
return ShouldShowBoxWasFullMessage();
|
2018-08-10 23:07:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (++box == TOTAL_BOXES_COUNT)
|
|
|
|
{
|
|
|
|
box = 0;
|
|
|
|
}
|
|
|
|
} while (box != StorageGetCurrentBox());
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-12-02 01:19:47 +01:00
|
|
|
void CreateAbnormalWeatherEvent(void)
|
2018-08-10 23:07:23 +02:00
|
|
|
{
|
|
|
|
u16 randomValue = Random();
|
2019-12-02 01:19:47 +01:00
|
|
|
VarSet(VAR_ABNORMAL_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
|
|
|
{
|
2020-02-05 08:47:32 +01:00
|
|
|
VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % TERRA_CAVE_LOCATIONS) + TERRA_CAVE_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
|
|
|
{
|
2020-02-05 08:47:32 +01:00
|
|
|
VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % MARINE_CAVE_LOCATIONS) + MARINE_CAVE_LOCATIONS_START);
|
2018-08-10 23:07:23 +02:00
|
|
|
}
|
|
|
|
else if ((randomValue & 1) == 0)
|
|
|
|
{
|
|
|
|
randomValue = Random();
|
2020-02-05 08:47:32 +01:00
|
|
|
VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % TERRA_CAVE_LOCATIONS) + TERRA_CAVE_LOCATIONS_START);
|
2018-08-10 23:07:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
randomValue = Random();
|
2020-02-05 08:47:32 +01:00
|
|
|
VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % MARINE_CAVE_LOCATIONS) + MARINE_CAVE_LOCATIONS_START);
|
2018-08-10 23:07:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 01:19:47 +01:00
|
|
|
// Saves the map name for the current abnormal weather location in gStringVar1, then
|
2019-02-27 10:27:54 +01:00
|
|
|
// returns TRUE if the weather is for Kyogre, and FALSE if it's for Groudon.
|
2019-12-02 01:19:47 +01:00
|
|
|
bool32 GetAbnormalWeatherMapNameAndType(void)
|
2018-08-10 23:07:23 +02:00
|
|
|
{
|
2019-12-02 01:19:47 +01:00
|
|
|
static const u8 sAbnormalWeatherMapNumbers[] = {
|
2019-03-01 07:49:11 +01:00
|
|
|
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
|
|
|
|
2019-12-02 01:19:47 +01:00
|
|
|
u16 abnormalWeather = VarGet(VAR_ABNORMAL_WEATHER_LOCATION);
|
2018-08-10 23:07:23 +02:00
|
|
|
|
2019-12-02 01:19:47 +01:00
|
|
|
GetMapName(gStringVar1, sAbnormalWeatherMapNumbers[abnormalWeather - 1], 0);
|
2018-08-19 01:06:10 +02:00
|
|
|
|
2020-02-05 08:47:32 +01:00
|
|
|
if (abnormalWeather < MARINE_CAVE_LOCATIONS_START)
|
2018-08-10 23:07:23 +02:00
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-12-02 01:19:47 +01:00
|
|
|
bool8 AbnormalWeatherHasExpired(void)
|
2018-08-10 23:07:23 +02:00
|
|
|
{
|
2019-02-27 10:27:54 +01:00
|
|
|
// Duplicate array.
|
2019-12-02 01:19:47 +01:00
|
|
|
static const u8 sAbnormalWeatherMapNumbers[] = {
|
2019-03-01 07:49:11 +01:00
|
|
|
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
|
|
|
|
2019-12-02 01:19:47 +01:00
|
|
|
u16 steps = VarGet(VAR_ABNORMAL_WEATHER_STEP_COUNTER);
|
|
|
|
u16 abnormalWeather = VarGet(VAR_ABNORMAL_WEATHER_LOCATION);
|
2018-08-10 23:07:23 +02:00
|
|
|
|
2019-12-02 01:19:47 +01:00
|
|
|
if (abnormalWeather == ABNORMAL_WEATHER_NONE)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-02-27 20:42:32 +01:00
|
|
|
if (++steps > 999)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-12-02 01:19:47 +01:00
|
|
|
VarSet(VAR_ABNORMAL_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):
|
2019-12-02 01:19:47 +01:00
|
|
|
VarSet(VAR_SHOULD_END_ABNORMAL_WEATHER, 1);
|
2018-08-11 23:51:54 +02:00
|
|
|
return FALSE;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-08-19 01:06:10 +02:00
|
|
|
|
2020-09-01 09:03:14 +02:00
|
|
|
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(UNDERWATER_ROUTE127))
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
switch (gSaveBlock1Ptr->location.mapNum)
|
|
|
|
{
|
2020-09-01 09:03:14 +02:00
|
|
|
case MAP_NUM(UNDERWATER_ROUTE127):
|
|
|
|
case MAP_NUM(UNDERWATER_ROUTE129):
|
|
|
|
case MAP_NUM(UNDERWATER_ROUTE105):
|
|
|
|
case MAP_NUM(UNDERWATER_ROUTE125):
|
2019-12-02 01:19:47 +01:00
|
|
|
VarSet(VAR_SHOULD_END_ABNORMAL_WEATHER, 1);
|
2018-08-11 23:51:54 +02:00
|
|
|
return FALSE;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 01:19:47 +01:00
|
|
|
if (gSaveBlock1Ptr->location.mapNum == sAbnormalWeatherMapNumbers[abnormalWeather - 1] &&
|
2018-08-11 23:51:54 +02:00
|
|
|
gSaveBlock1Ptr->location.mapGroup == 0)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-02 01:19:47 +01:00
|
|
|
VarSet(VAR_ABNORMAL_WEATHER_LOCATION, ABNORMAL_WEATHER_NONE);
|
2018-08-11 23:51:54 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-02 01:19:47 +01:00
|
|
|
VarSet(VAR_ABNORMAL_WEATHER_STEP_COUNTER, steps);
|
2018-08-11 23:51:54 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-23 04:20:42 +01:00
|
|
|
void Unused_SetWeatherSunny(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-02-23 04:20:42 +01:00
|
|
|
SetCurrentAndNextWeather(WEATHER_SUNNY);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2020-06-21 07:56:57 +02:00
|
|
|
// All mart employees have a local id of 1, so function always returns 1
|
2019-09-13 20:24:07 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
bool32 IsTrainerRegistered(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
int index = GetRematchIdxByTrainerIdx(gSpecialVar_0x8004);
|
|
|
|
if (index >= 0)
|
|
|
|
{
|
|
|
|
if (FlagGet(FLAG_MATCH_CALL_REGISTERED + index) == TRUE)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
// Always returns FALSE
|
2019-10-11 10:14:09 +02:00
|
|
|
bool32 ShouldDistributeEonTicket(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-10-11 10:14:09 +02:00
|
|
|
if (!VarGet(VAR_DISTRIBUTE_EON_TICKET))
|
2018-08-11 23:51:54 +02:00
|
|
|
return FALSE;
|
2019-10-11 10:14:09 +02:00
|
|
|
|
2018-08-11 23:51:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_813B534(void)
|
|
|
|
{
|
2020-01-08 11:43:06 +01:00
|
|
|
sBattleTowerMultiBattleTypeFlags = gBattleTypeFlags;
|
2018-08-11 23:51:54 +02:00
|
|
|
gBattleTypeFlags = 0;
|
|
|
|
if (!gReceivedRemoteLinkPlayers)
|
|
|
|
{
|
|
|
|
CreateTask(sub_80B3AF8, 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 11:43:06 +01:00
|
|
|
void LinkRetireStatusWithBattleTowerPartner(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2020-01-08 11:43:06 +01:00
|
|
|
CreateTask(Task_LinkRetireStatusWithBattleTowerPartner, 5);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2020-01-08 11:43:06 +01:00
|
|
|
static void Task_LinkRetireStatusWithBattleTowerPartner(u8 taskId)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
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);
|
2020-01-08 11:43:06 +01:00
|
|
|
if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_RETIRE
|
|
|
|
&& gSpecialVar_0x8005 == BATTLE_TOWER_LINK_RETIRE)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2020-01-08 11:43:06 +01:00
|
|
|
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_BOTH_RETIRE;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
2020-01-08 11:43:06 +01:00
|
|
|
else if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_CONTINUE
|
|
|
|
&& gSpecialVar_0x8005 == BATTLE_TOWER_LINK_RETIRE)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2020-01-08 11:43:06 +01:00
|
|
|
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_PARTNER_RETIRE;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
2020-01-08 11:43:06 +01:00
|
|
|
else if (gSpecialVar_0x8004 == BATTLE_TOWER_LINK_RETIRE
|
|
|
|
&& gSpecialVar_0x8005 == BATTLE_TOWER_LINK_CONTINUE)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2020-01-08 11:43:06 +01:00
|
|
|
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_PLAYER_RETIRE;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-08 11:43:06 +01:00
|
|
|
gSpecialVar_Result = BATTLE_TOWER_LINKSTAT_CONTINUE;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
2020-01-08 11:43:06 +01:00
|
|
|
if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_PARTNER_RETIRE)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
ShowFieldAutoScrollMessage(gText_YourPartnerHasRetired);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2018-08-10 23:07:23 +02:00
|
|
|
{
|
2020-01-08 11:43:06 +01:00
|
|
|
if (gSpecialVar_Result == BATTLE_TOWER_LINKSTAT_PLAYER_RETIRE)
|
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
|
|
|
{
|
2020-08-13 09:09:47 +02:00
|
|
|
SetLinkStandbyCallback();
|
2018-08-11 23:51:54 +02:00
|
|
|
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)
|
|
|
|
{
|
2020-08-13 09:09:47 +02:00
|
|
|
SetCloseLinkCallback();
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
2020-01-08 11:43:06 +01:00
|
|
|
gBattleTypeFlags = sBattleTowerMultiBattleTypeFlags;
|
2018-08-11 23:51:54 +02:00
|
|
|
EnableBothScriptContexts();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
void Script_DoRayquazaScene(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2020-08-25 23:49:42 +02:00
|
|
|
if (!gSpecialVar_0x8004)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2020-08-25 23:49:42 +02:00
|
|
|
// Groudon/Kyogre fight scene
|
2018-08-11 23:51:54 +02:00
|
|
|
DoRayquazaScene(0, TRUE, CB2_ReturnToFieldContinueScriptPlayMapMusic);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-25 23:49:42 +02:00
|
|
|
// Rayquaza arrives scene
|
2018-08-11 23:51:54 +02:00
|
|
|
DoRayquazaScene(1, FALSE, CB2_ReturnToFieldContinueScriptPlayMapMusic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
#define playCount data[0]
|
|
|
|
#define delay data[1]
|
|
|
|
|
|
|
|
void LoopWingFlapSE(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-09-30 07:42:52 +02:00
|
|
|
CreateTask(Task_LoopWingFlapSE, 8);
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_M_WING_ATTACK);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
static void Task_LoopWingFlapSE(u8 taskId)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
delay++;
|
|
|
|
if (delay == gSpecialVar_0x8005)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-09-30 07:42:52 +02:00
|
|
|
playCount++;
|
|
|
|
delay = 0;
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_M_WING_ATTACK);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
if (playCount == gSpecialVar_0x8004 - 1)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
#undef playCount
|
|
|
|
#undef delay
|
|
|
|
|
|
|
|
void CloseBattlePikeCurtain(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-09-30 07:42:52 +02:00
|
|
|
u8 taskId = CreateTask(Task_CloseBattlePikeCurtain, 8);
|
2018-08-11 23:51:54 +02:00
|
|
|
gTasks[taskId].data[0] = 4;
|
|
|
|
gTasks[taskId].data[1] = 4;
|
|
|
|
gTasks[taskId].data[2] = 4;
|
|
|
|
gTasks[taskId].data[3] = 0;
|
|
|
|
}
|
|
|
|
|
2019-09-30 07:42:52 +02:00
|
|
|
static void Task_CloseBattlePikeCurtain(u8 taskId)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
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++)
|
|
|
|
{
|
2019-09-30 07:42:52 +02:00
|
|
|
MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + x + 6, gSaveBlock1Ptr->pos.y + y + 4, x + 513 + y * 8 + data[3] * 32);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DrawWholeMapView();
|
|
|
|
data[3]++;
|
|
|
|
if (data[3] == 3)
|
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
void GetBattlePyramidHint(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
gSpecialVar_Result = gSpecialVar_0x8004 / 7;
|
|
|
|
gSpecialVar_Result -= (gSpecialVar_Result / 20) * 20;
|
|
|
|
}
|
|
|
|
|
2019-09-14 02:22:09 +02:00
|
|
|
// Used to avoid a potential softlock if the player respawns on Dewford with no way off
|
|
|
|
void ResetHealLocationFromDewford(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
if (gSaveBlock1Ptr->lastHealLocation.mapGroup == MAP_GROUP(DEWFORD_TOWN) && gSaveBlock1Ptr->lastHealLocation.mapNum == MAP_NUM(DEWFORD_TOWN))
|
|
|
|
{
|
2019-09-14 02:22:09 +02:00
|
|
|
SetLastHealLocationWarp(HEAL_LOCATION_PETALBURG_CITY);
|
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,
|
2019-11-07 18:37:11 +01:00
|
|
|
MAP_BATTLE_COLOSSEUM_2P,
|
2018-08-11 23:51:54 +02:00
|
|
|
MAP_TRADE_CENTER,
|
|
|
|
MAP_RECORD_CORNER,
|
2019-11-07 18:37:11 +01:00
|
|
|
MAP_BATTLE_COLOSSEUM_4P,
|
2018-12-05 15:31:01 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
/* Summary of the Lilycove Trainer Fan Club, because it's a little messy
|
|
|
|
|
|
|
|
## The Fan Club room itself
|
|
|
|
There are initially 4 members of the Fan Club (+ an interviewer), none of whom are fans of the player
|
|
|
|
After becoming the champion there will be 8 members of the Fan Club, 3 of whom are automatically fans of the player
|
|
|
|
After this point, if a club member is a fan of the player they will sit at the front table and comment on the player
|
|
|
|
If they are not fans of the player, they will sit at the far table and can make comments about a different trainer (see BufferFanClubTrainerName)
|
|
|
|
|
|
|
|
## Gaining/losing fans
|
|
|
|
After every link battle the player will gain a fan if they won, or lose a fan if they lost
|
|
|
|
If the player has at least 3 fans, this is the only way to gain fans
|
|
|
|
If the player has fewer than 3 fans, they may also gain fans by completing certain tasks enough times (see TryGainNewFanFromCounter)
|
|
|
|
If the player has at least 5 fans, they can lose a fan every 12 real-time hours, or more often if the timer variable is reset (see TryLoseFansFromPlayTime)
|
2019-11-18 18:35:59 +01:00
|
|
|
If the player has only 1 fan left it cannot be lost
|
2019-11-17 23:34:11 +01:00
|
|
|
|
|
|
|
## Variables
|
|
|
|
VAR_FANCLUB_FAN_COUNTER, a bitfield for tracking the fans
|
|
|
|
Bits 1-7: Counter for when to add new fans
|
|
|
|
Bit 8: Flag set after receiving the initial 3 fans
|
|
|
|
Bits 9-16: Flags for each of the 8 club members, set to 1 when theyre a fan of the player and 0 when theyre not
|
|
|
|
|
|
|
|
VAR_FANCLUB_LOSE_FAN_TIMER, a timer for when to lose fans
|
|
|
|
Compared against playTimeHours. When theyre equal, a fan is ready to be lost
|
|
|
|
For every fan thats lost this way 12 hours are added to the timer
|
|
|
|
|
|
|
|
VAR_LILYCOVE_FAN_CLUB_STATE
|
|
|
|
0: Player is not the champion yet
|
|
|
|
1: Player is the champion, ready to meet their initial fans
|
|
|
|
2: Player has met their initial fans
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define FANCLUB_BITFIELD (gSaveBlock1Ptr->vars[VAR_FANCLUB_FAN_COUNTER - VARS_START])
|
|
|
|
#define FANCLUB_COUNTER 0x007F
|
|
|
|
#define FANCLUB_FAN_FLAGS 0xFF80
|
|
|
|
|
|
|
|
#define GET_TRAINER_FAN_CLUB_FLAG(flag) (FANCLUB_BITFIELD >> (flag) & 1)
|
|
|
|
#define SET_TRAINER_FAN_CLUB_FLAG(flag) (FANCLUB_BITFIELD |= 1 << (flag))
|
|
|
|
#define FLIP_TRAINER_FAN_CLUB_FLAG(flag)(FANCLUB_BITFIELD ^= 1 << (flag))
|
|
|
|
|
|
|
|
#define GET_TRAINER_FAN_CLUB_COUNTER (FANCLUB_BITFIELD & FANCLUB_COUNTER)
|
|
|
|
#define SET_TRAINER_FAN_CLUB_COUNTER(count) (FANCLUB_BITFIELD = (FANCLUB_BITFIELD & FANCLUB_FAN_FLAGS) | (count))
|
|
|
|
#define INCR_TRAINER_FAN_CLUB_COUNTER(count)(FANCLUB_BITFIELD += (count))
|
|
|
|
#define CLEAR_TRAINER_FAN_CLUB_COUNTER (FANCLUB_BITFIELD &= ~(FANCLUB_COUNTER))
|
|
|
|
|
2018-08-11 23:51:54 +02:00
|
|
|
void ResetFanClub(void)
|
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
gSaveBlock1Ptr->vars[VAR_FANCLUB_FAN_COUNTER - VARS_START] = 0;
|
|
|
|
gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] = 0;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
void TryLoseFansFromPlayTimeAfterLinkBattle(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
if (DidPlayerGetFirstFans())
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
TryLoseFansFromPlayTime();
|
|
|
|
gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] = gSaveBlock2Ptr->playTimeHours;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-10 23:07:23 +02:00
|
|
|
|
2019-11-07 19:26:53 +01:00
|
|
|
void UpdateTrainerFanClubGameClear(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
if (!GET_TRAINER_FAN_CLUB_FLAG(FANCLUB_GOT_FIRST_FANS))
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
SetPlayerGotFirstFans();
|
|
|
|
SetInitialFansOfPlayer();
|
|
|
|
gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] = gSaveBlock2Ptr->playTimeHours;
|
2018-08-11 23:51:54 +02:00
|
|
|
FlagClear(FLAG_HIDE_FANCLUB_OLD_LADY);
|
|
|
|
FlagClear(FLAG_HIDE_FANCLUB_BOY);
|
|
|
|
FlagClear(FLAG_HIDE_FANCLUB_LITTLE_BOY);
|
|
|
|
FlagClear(FLAG_HIDE_FANCLUB_LADY);
|
2018-10-18 04:07:23 +02:00
|
|
|
FlagClear(FLAG_HIDE_LILYCOVE_FAN_CLUB_INTERVIEWER);
|
2018-08-11 23:51:54 +02:00
|
|
|
VarSet(VAR_LILYCOVE_FAN_CLUB_STATE, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
// If the player has < 3 fans, gain a new fan whenever the counter reaches 20+
|
2020-06-17 23:48:20 +02:00
|
|
|
// Defeating Drake or participating in a Contest increments the counter by 2
|
2019-11-17 23:34:11 +01:00
|
|
|
// Participating at Battle Tower or in a Secret Base battle increments the counter by 1
|
|
|
|
u8 TryGainNewFanFromCounter(u8 incrementId)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2020-06-17 23:48:20 +02:00
|
|
|
static const u8 sCounterIncrements[] =
|
|
|
|
{
|
|
|
|
[FANCOUNTER_DEFEATED_DRAKE] = 2,
|
|
|
|
[FANCOUNTER_BATTLED_AT_BASE] = 1,
|
|
|
|
[FANCOUNTER_FINISHED_CONTEST] = 2,
|
|
|
|
[FANCOUNTER_USED_BATTLE_TOWER] = 1
|
|
|
|
};
|
2018-08-11 23:51:54 +02:00
|
|
|
|
|
|
|
if (VarGet(VAR_LILYCOVE_FAN_CLUB_STATE) == 2)
|
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
if (GET_TRAINER_FAN_CLUB_COUNTER + sCounterIncrements[incrementId] > 19)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
if (GetNumFansOfPlayerInTrainerFanClub() < 3)
|
2018-08-10 23:07:23 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
PlayerGainRandomTrainerFan();
|
|
|
|
CLEAR_TRAINER_FAN_CLUB_COUNTER;
|
2018-08-10 23:07:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
SET_TRAINER_FAN_CLUB_COUNTER(20);
|
2018-08-10 23:07:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
INCR_TRAINER_FAN_CLUB_COUNTER(sCounterIncrements[incrementId]);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
return GET_TRAINER_FAN_CLUB_COUNTER;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
|
|
|
|
// Loop through the fan club members, and if theyre not a fan of the player there is a 50% chance for them to become a fan
|
|
|
|
// Stops when a fan is gained
|
|
|
|
// If no new fan was gained while looping, the last non-fan in the list becomes a fan
|
|
|
|
// If all the members are already fans of the player then this redundantly sets the first fan in the list to be a fan
|
|
|
|
static u16 PlayerGainRandomTrainerFan(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
static const u8 sFanClubMemberIds[NUM_TRAINER_FAN_CLUB_MEMBERS] =
|
2019-11-10 16:59:15 +01:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
FANCLUB_MEMBER1,
|
|
|
|
FANCLUB_MEMBER2,
|
|
|
|
FANCLUB_MEMBER3,
|
|
|
|
FANCLUB_MEMBER4,
|
|
|
|
FANCLUB_MEMBER5,
|
|
|
|
FANCLUB_MEMBER6,
|
|
|
|
FANCLUB_MEMBER7,
|
|
|
|
FANCLUB_MEMBER8
|
2019-11-10 16:59:15 +01:00
|
|
|
};
|
2018-08-11 23:51:54 +02:00
|
|
|
|
|
|
|
u8 i;
|
2019-11-17 23:34:11 +01:00
|
|
|
u8 idx = 0;
|
2018-08-11 23:51:54 +02:00
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sFanClubMemberIds); i++)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
if (!GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i]))
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
idx = i;
|
|
|
|
if (Random() & 1)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
SET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]);
|
|
|
|
return idx;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-17 23:34:11 +01:00
|
|
|
SET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]);
|
|
|
|
return idx;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
// Loops through the fan club members, and if theyre a fan of the player there is a 50% chance for them to stop being a fan
|
|
|
|
// Stops if a fan is removed, or if the player has only one fan left
|
|
|
|
// If no fan was lost while looping, the last current fan in the list will stop being a fan
|
|
|
|
static u16 PlayerLoseRandomTrainerFan(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
static const u8 sFanClubMemberIds[NUM_TRAINER_FAN_CLUB_MEMBERS] =
|
2019-11-10 16:59:15 +01:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
FANCLUB_MEMBER1,
|
|
|
|
FANCLUB_MEMBER6,
|
|
|
|
FANCLUB_MEMBER7,
|
|
|
|
FANCLUB_MEMBER4,
|
|
|
|
FANCLUB_MEMBER3,
|
|
|
|
FANCLUB_MEMBER5,
|
|
|
|
FANCLUB_MEMBER8,
|
|
|
|
FANCLUB_MEMBER2
|
2019-11-10 16:59:15 +01:00
|
|
|
};
|
2018-08-11 23:51:54 +02:00
|
|
|
|
|
|
|
u8 i;
|
2019-11-17 23:34:11 +01:00
|
|
|
u8 idx = 0;
|
2018-08-11 23:51:54 +02:00
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
if (GetNumFansOfPlayerInTrainerFanClub() == 1)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sFanClubMemberIds); i++)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
if (GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[i]))
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
idx = i;
|
|
|
|
if (Random() & 1)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
FLIP_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]);
|
|
|
|
return idx;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-19 01:06:10 +02:00
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
if (GET_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]))
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
FLIP_TRAINER_FAN_CLUB_FLAG(sFanClubMemberIds[idx]);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
return idx;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
u16 GetNumFansOfPlayerInTrainerFanClub(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-11-17 23:34:11 +01:00
|
|
|
u8 numFans = 0;
|
2018-08-11 23:51:54 +02:00
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
for (i = 0; i < NUM_TRAINER_FAN_CLUB_MEMBERS; i++)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
if (GET_TRAINER_FAN_CLUB_FLAG(i + FANCLUB_MEMBER1))
|
|
|
|
numFans++;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
return numFans;
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
// If the player has > 5 fans in the Trainer Fan Club, then lose 1 fan for every 12 hours since the last fan loss / timer reset
|
|
|
|
void TryLoseFansFromPlayTime(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
u8 i = 0;
|
|
|
|
if (gSaveBlock2Ptr->playTimeHours < 999)
|
|
|
|
{
|
|
|
|
while (TRUE)
|
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
if (GetNumFansOfPlayerInTrainerFanClub() < 5)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] = gSaveBlock2Ptr->playTimeHours;
|
2018-08-11 23:51:54 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-11-17 23:34:11 +01:00
|
|
|
else if (i == NUM_TRAINER_FAN_CLUB_MEMBERS)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2019-11-17 23:34:11 +01:00
|
|
|
else if (gSaveBlock2Ptr->playTimeHours - gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] < 12)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-11-17 23:34:11 +01:00
|
|
|
PlayerLoseRandomTrainerFan();
|
|
|
|
gSaveBlock1Ptr->vars[VAR_FANCLUB_LOSE_FAN_TIMER - VARS_START] += 12;
|
2018-08-11 23:51:54 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
bool8 IsFanClubMemberFanOfPlayer(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
return GET_TRAINER_FAN_CLUB_FLAG(gSpecialVar_0x8004);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
static void SetInitialFansOfPlayer(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER6);
|
|
|
|
SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER1);
|
|
|
|
SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_MEMBER3);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
void BufferFanClubTrainerName(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
u8 whichLinkTrainer = 0;
|
|
|
|
u8 whichNPCTrainer = 0;
|
2018-08-11 23:51:54 +02:00
|
|
|
switch (gSpecialVar_0x8004)
|
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
case FANCLUB_MEMBER1:
|
2018-08-11 23:51:54 +02:00
|
|
|
break;
|
2019-11-17 23:34:11 +01:00
|
|
|
case FANCLUB_MEMBER2:
|
2018-08-11 23:51:54 +02:00
|
|
|
break;
|
2019-11-17 23:34:11 +01:00
|
|
|
case FANCLUB_MEMBER3:
|
|
|
|
whichLinkTrainer = 0;
|
|
|
|
whichNPCTrainer = 3;
|
2018-08-11 23:51:54 +02:00
|
|
|
break;
|
2019-11-17 23:34:11 +01:00
|
|
|
case FANCLUB_MEMBER4:
|
|
|
|
whichLinkTrainer = 0;
|
|
|
|
whichNPCTrainer = 1;
|
2018-08-11 23:51:54 +02:00
|
|
|
break;
|
2019-11-17 23:34:11 +01:00
|
|
|
case FANCLUB_MEMBER5:
|
|
|
|
whichLinkTrainer = 1;
|
|
|
|
whichNPCTrainer = 0;
|
2018-08-11 23:51:54 +02:00
|
|
|
break;
|
2019-11-17 23:34:11 +01:00
|
|
|
case FANCLUB_MEMBER6:
|
|
|
|
whichLinkTrainer = 0;
|
|
|
|
whichNPCTrainer = 4;
|
2018-08-11 23:51:54 +02:00
|
|
|
break;
|
2019-11-17 23:34:11 +01:00
|
|
|
case FANCLUB_MEMBER7:
|
|
|
|
whichLinkTrainer = 1;
|
|
|
|
whichNPCTrainer = 5;
|
2018-08-11 23:51:54 +02:00
|
|
|
break;
|
2019-11-17 23:34:11 +01:00
|
|
|
case FANCLUB_MEMBER8:
|
2018-08-11 23:51:54 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-11-17 23:34:11 +01:00
|
|
|
BufferFanClubTrainerName_(&gSaveBlock1Ptr->linkBattleRecords, whichLinkTrainer, whichNPCTrainer);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
static void BufferFanClubTrainerName_(struct LinkBattleRecords *linkRecords, u8 whichLinkTrainer, u8 whichNPCTrainer)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
struct LinkBattleRecord *record = &linkRecords->entries[whichLinkTrainer];
|
2018-08-11 23:51:54 +02:00
|
|
|
if (record->name[0] == EOS)
|
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
switch (whichNPCTrainer)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
StringCopyN(gStringVar1, record->name, PLAYER_NAME_LENGTH);
|
|
|
|
gStringVar1[PLAYER_NAME_LENGTH] = EOS;
|
|
|
|
ConvertInternationalString(gStringVar1, linkRecords->languages[whichLinkTrainer]);
|
2018-08-10 23:07:23 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-11 23:51:54 +02:00
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
void UpdateTrainerFansAfterLinkBattle(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)
|
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
TryLoseFansFromPlayTimeAfterLinkBattle();
|
2019-11-10 16:59:15 +01:00
|
|
|
if (gBattleOutcome == B_OUTCOME_WON)
|
2019-11-17 23:34:11 +01:00
|
|
|
PlayerGainRandomTrainerFan();
|
2018-08-11 23:51:54 +02:00
|
|
|
else
|
2019-11-17 23:34:11 +01:00
|
|
|
PlayerLoseRandomTrainerFan();
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
static bool8 DidPlayerGetFirstFans(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
return GET_TRAINER_FAN_CLUB_FLAG(FANCLUB_GOT_FIRST_FANS);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
void SetPlayerGotFirstFans(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
SET_TRAINER_FAN_CLUB_FLAG(FANCLUB_GOT_FIRST_FANS);
|
2018-08-11 23:51:54 +02:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:34:11 +01:00
|
|
|
// return value is always ignored
|
|
|
|
u8 Script_TryGainNewFanFromCounter(void)
|
2018-08-11 23:51:54 +02:00
|
|
|
{
|
2019-11-17 23:34:11 +01:00
|
|
|
return TryGainNewFanFromCounter(gSpecialVar_0x8004);
|
2018-08-10 23:07:23 +02:00
|
|
|
}
|