From 4753e872c19668d4aa6609ff9f4142c693d04741 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Sat, 13 Jul 2024 22:57:45 +0200 Subject: [PATCH 1/8] FRLG whiteout message + post whiteout event --- data/event_scripts.s | 73 +++++++++++++++++ include/config/overworld.h | 1 + include/constants/heal_locations.h | 1 + include/event_scripts.h | 2 + include/field_screen_effect.h | 1 + include/heal_location.h | 3 + include/strings.h | 4 + src/data/heal_locations.h | 53 +++++++++++++ src/field_screen_effect.c | 122 +++++++++++++++++++++++++++++ src/heal_location.c | 63 +++++++++++++++ src/overworld.c | 18 ++++- src/strings.c | 2 + 12 files changed, 341 insertions(+), 2 deletions(-) diff --git a/data/event_scripts.s b/data/event_scripts.s index 07eafe1c35ea..d4393ac9d473 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -587,6 +587,37 @@ EventScript_WhiteOut:: goto EventScript_ResetMrBriney end +EventScript_AfterWhiteOutHeal:: + lockall + msgbox gText_FirstShouldRestoreMonsHealth + call EventScript_PkmnCenterNurse_TakeAndHealPkmn + call_if_unset FLAG_DEFEATED_RUSTBORO_GYM, EventScript_AfterWhiteOutHealMsgPreRoxanne + call_if_set FLAG_DEFEATED_RUSTBORO_GYM, EventScript_AfterWhiteOutHealMsg + applymovement VAR_LAST_TALKED, Movement_PkmnCenterNurse_Bow + waitmovement 0 + fadedefaultbgm + releaseall + end + +EventScript_AfterWhiteOutHealMsgPreRoxanne:: + msgbox gText_MonsHealedShouldBuyPotions + return + +EventScript_AfterWhiteOutHealMsg:: + msgbox gText_MonsHealed + return + +EventScript_AfterWhiteOutMomHeal:: + lockall + applymovement LOCALID_MOM, Common_Movement_WalkInPlaceFasterDown + waitmovement 0 + msgbox gText_HadQuiteAnExperienceTakeRest + call Common_EventScript_OutOfCenterPartyHeal + msgbox gText_MomExplainHPGetPotions + fadedefaultbgm + releaseall + end + EventScript_ResetMrBriney:: goto_if_eq VAR_BRINEY_LOCATION, 1, EventScript_MoveMrBrineyToHouse goto_if_eq VAR_BRINEY_LOCATION, 2, EventScript_MoveMrBrineyToDewford @@ -887,6 +918,48 @@ gText_PlayerWhitedOut:: .string "{PLAYER} is out of usable\n" .string "POKéMON!\p{PLAYER} whited out!$" +gText_FirstShouldRestoreMonsHealth:: + .string "First, you should restore your\n" + .string "POKéMON to full health.$" + +gText_MonsHealedShouldBuyPotions:: + .string "Your POKéMON have been healed\n" + .string "to perfect health.\p" + .string "If your POKéMON's energy, HP,\n" + .string "is down, please come see us.\p" + .string "If you're planning to go far in the\n" + .string "field, you should buy some POTIONS\l" + .string "at the POKéMON MART.\p" + .string "We hope you excel!$" + +gText_MonsHealed:: + .string "Your POKéMON have been healed\n" + .string "to perfect health.\p" + .string "We hope you excel!$" + +gText_HadQuiteAnExperienceTakeRest:: + .string "MOM: {PLAYER}!\n" + .string "Welcome home.\p" + .string "It sounds like you had quite\n" + .string "an experience.\p" + .string "Maybe you should take a quick\n" + .string "rest.$" + +gText_MomExplainHPGetPotions:: + .string "MOM: Oh, good! You and your\n" + .string "POKéMON are looking great.\p" + .string "I just heard from PROF. BIRCH.\p" + .string "He said that POKéMON's energy is\n" + .string "measured in HP.\p" + .string "If your POKéMON lose their HP,\n" + .string "you can restore them at any\l" + .string "POKéMON CENTER.\p" + .string "If you're going to travel far away,\n" + .string "the smart TRAINER stocks up on\l" + .string "POTIONS at the POKéMON MART.\p" + .string "Make me proud, honey!\p" + .string "Take care!$" + gText_RegisteredTrainerinPokeNav:: .string "Registered {STR_VAR_1} {STR_VAR_2}\n" .string "in the POKéNAV.$" diff --git a/include/config/overworld.h b/include/config/overworld.h index 6847ee9e94ca..0771d1631f72 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -8,6 +8,7 @@ #define OW_POISON_DAMAGE GEN_LATEST // In Gen4, Pokémon no longer faint from Poison in the overworld. In Gen5+, they no longer take damage at all. #define OW_DOUBLE_APPROACH_WITH_ONE_MON FALSE // If enabled, you can be spotted by two trainers at the same time even if you only have one eligible Pokémon in your party. #define OW_HIDE_REPEAT_MAP_POPUP FALSE // If enabled, map popups will not appear if entering a map with the same Map Section Id as the last. +#define OW_FRLG_WHITEOUT TRUE // If enabled, shows an additional whiteout message and post whiteout event script with healing NPC // These generational defines only make a distinction for Berries and the OW_PC_MOVE_ORDER #define GEN_6_XY GEN_6 diff --git a/include/constants/heal_locations.h b/include/constants/heal_locations.h index d3dd8f1f1748..8af550ca0984 100644 --- a/include/constants/heal_locations.h +++ b/include/constants/heal_locations.h @@ -24,5 +24,6 @@ #define HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE 20 #define HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR 21 #define HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST 22 +#define HEAL_LOCATION_MAX (HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST) #endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H diff --git a/include/event_scripts.h b/include/event_scripts.h index fa0bfe5c6ecd..7c35e991c252 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -620,6 +620,8 @@ extern const u8 EventScript_SelectWithoutRegisteredItem[]; // overworld extern const u8 EventScript_WhiteOut[]; +extern const u8 EventScript_AfterWhiteOutMomHeal[]; +extern const u8 EventScript_AfterWhiteOutHeal[]; extern const u8 EventScript_ResetMrBriney[]; extern const u8 EventScript_DoLinkRoomExit[]; extern const u8 CableClub_EventScript_TooBusyToNotice[]; diff --git a/include/field_screen_effect.h b/include/field_screen_effect.h index 6dc9b077d219..9b3aa6229e5f 100644 --- a/include/field_screen_effect.h +++ b/include/field_screen_effect.h @@ -16,6 +16,7 @@ void FieldCB_ReturnToFieldWirelessLink(void); void FieldCB_DefaultWarpExit(void); void FieldCB_WarpExitFadeFromBlack(void); void FieldCB_WarpExitFadeFromWhite(void); +void FieldCB_RushInjuredPokemonToCenter(void); bool8 FieldCB_ReturnToFieldOpenStartMenu(void); void ReturnToFieldOpenStartMenu(void); void FieldCB_ReturnToFieldNoScript(void); diff --git a/include/heal_location.h b/include/heal_location.h index 46f0d785ab7a..a1f5e7a25da4 100644 --- a/include/heal_location.h +++ b/include/heal_location.h @@ -12,5 +12,8 @@ struct HealLocation u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum); const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum); const struct HealLocation *GetHealLocation(u32 index); +bool32 IsLastHealLocation(u32 healLocation); +void SetWhiteoutRespawnWarpAndHealerNpc(struct WarpData * warp); +bool32 HasHealNPC(u32 healLocationId); #endif // GUARD_HEAL_LOCATION_H diff --git a/include/strings.h b/include/strings.h index 2963eb96d15c..ec175ab251d0 100644 --- a/include/strings.h +++ b/include/strings.h @@ -3046,4 +3046,8 @@ extern const u8 gText_PlantBerry[]; extern const u8 gText_AM[]; extern const u8 gText_PM[]; +// FRLG whiteout +extern const u8 gText_PlayerScurriedToCenter[]; +extern const u8 gText_PlayerScurriedBackHome[]; + #endif // GUARD_STRINGS_H diff --git a/src/data/heal_locations.h b/src/data/heal_locations.h index 04530a1dbf2c..bc74b934fcea 100644 --- a/src/data/heal_locations.h +++ b/src/data/heal_locations.h @@ -23,3 +23,56 @@ static const struct HealLocation sHealLocations[] = [HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR - 1] = {MAP_GROUP(SOUTHERN_ISLAND_EXTERIOR), MAP_NUM(SOUTHERN_ISLAND_EXTERIOR), 15, 20}, [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = {MAP_GROUP(BATTLE_FRONTIER_OUTSIDE_EAST), MAP_NUM(BATTLE_FRONTIER_OUTSIDE_EAST), 3, 52}, }; + +static const u16 sHealLocationsPokemonCenter[][2] = +{ + [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = {MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F)}, + [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = {MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F), MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F)}, + [HEAL_LOCATION_PETALBURG_CITY - 1] = {MAP_GROUP(PETALBURG_CITY_POKEMON_CENTER_1F), MAP_NUM(PETALBURG_CITY_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_SLATEPORT_CITY - 1] = {MAP_GROUP(SLATEPORT_CITY_POKEMON_CENTER_1F), MAP_NUM(SLATEPORT_CITY_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_MAUVILLE_CITY - 1] = {MAP_GROUP(MAUVILLE_CITY_POKEMON_CENTER_1F), MAP_NUM(MAUVILLE_CITY_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_RUSTBORO_CITY - 1] = {MAP_GROUP(RUSTBORO_CITY_POKEMON_CENTER_1F), MAP_NUM(RUSTBORO_CITY_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_FORTREE_CITY - 1] = {MAP_GROUP(FORTREE_CITY_POKEMON_CENTER_1F), MAP_NUM(FORTREE_CITY_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_LILYCOVE_CITY - 1] = {MAP_GROUP(LILYCOVE_CITY_POKEMON_CENTER_1F), MAP_NUM(LILYCOVE_CITY_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_MOSSDEEP_CITY - 1] = {MAP_GROUP(MOSSDEEP_CITY_POKEMON_CENTER_1F), MAP_NUM(MOSSDEEP_CITY_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_SOOTOPOLIS_CITY - 1] = {MAP_GROUP(SOOTOPOLIS_CITY_POKEMON_CENTER_1F), MAP_NUM(SOOTOPOLIS_CITY_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_EVER_GRANDE_CITY - 1] = {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_CENTER_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE - 1] = {MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F)}, + [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE - 1] = {MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F), MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F)}, + [HEAL_LOCATION_OLDALE_TOWN - 1] = {MAP_GROUP(OLDALE_TOWN_POKEMON_CENTER_1F), MAP_NUM(OLDALE_TOWN_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_DEWFORD_TOWN - 1] = {MAP_GROUP(DEWFORD_TOWN_POKEMON_CENTER_1F), MAP_NUM(DEWFORD_TOWN_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_LAVARIDGE_TOWN - 1] = {MAP_GROUP(LAVARIDGE_TOWN_POKEMON_CENTER_1F), MAP_NUM(LAVARIDGE_TOWN_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_FALLARBOR_TOWN - 1] = {MAP_GROUP(FALLARBOR_TOWN_POKEMON_CENTER_1F), MAP_NUM(FALLARBOR_TOWN_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_VERDANTURF_TOWN - 1] = {MAP_GROUP(VERDANTURF_TOWN_POKEMON_CENTER_1F), MAP_NUM(VERDANTURF_TOWN_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_PACIFIDLOG_TOWN - 1] = {MAP_GROUP(PACIFIDLOG_TOWN_POKEMON_CENTER_1F), MAP_NUM(PACIFIDLOG_TOWN_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1] = {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F)}, + [HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR - 1] = {MAP_GROUP(SOUTHERN_ISLAND_EXTERIOR), MAP_NUM(SOUTHERN_ISLAND_EXTERIOR)}, + [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = {MAP_GROUP(BATTLE_FRONTIER_POKEMON_CENTER_1F), MAP_NUM(BATTLE_FRONTIER_POKEMON_CENTER_1F)}, +}; + +static const u8 sWhiteoutRespawnHealerNpcLocalIds[] = +{ + [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = 1, + [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = 1, + [HEAL_LOCATION_PETALBURG_CITY - 1] = 1, + [HEAL_LOCATION_SLATEPORT_CITY - 1] = 1, + [HEAL_LOCATION_MAUVILLE_CITY - 1] = 1, + [HEAL_LOCATION_RUSTBORO_CITY - 1] = 1, + [HEAL_LOCATION_FORTREE_CITY - 1] = 1, + [HEAL_LOCATION_LILYCOVE_CITY - 1] = 1, + [HEAL_LOCATION_MOSSDEEP_CITY - 1] = 1, + [HEAL_LOCATION_SOOTOPOLIS_CITY - 1] = 1, + [HEAL_LOCATION_EVER_GRANDE_CITY - 1] = 1, + [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE - 1] = 1, + [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE - 1] = 1, + [HEAL_LOCATION_OLDALE_TOWN - 1] = 1, + [HEAL_LOCATION_DEWFORD_TOWN - 1] = 1, + [HEAL_LOCATION_LAVARIDGE_TOWN - 1] = 1, + [HEAL_LOCATION_FALLARBOR_TOWN - 1] = 1, + [HEAL_LOCATION_VERDANTURF_TOWN - 1] = 1, + [HEAL_LOCATION_PACIFIDLOG_TOWN - 1] = 1, + [HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1] = 1, + [HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR - 1] = 0, // no heal npc + [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = 1, +}; + diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index 9338fe183d17..58ffd6f01f8f 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -7,11 +7,13 @@ #include "field_effect.h" #include "event_object_lock.h" #include "event_object_movement.h" +#include "event_scripts.h" #include "field_player_avatar.h" #include "field_screen_effect.h" #include "field_special_scene.h" #include "field_weather.h" #include "gpu_regs.h" +#include "heal_location.h" #include "io_reg.h" #include "link.h" #include "link_rfu.h" @@ -26,10 +28,13 @@ #include "script.h" #include "sound.h" #include "start_menu.h" +#include "strings.h" +#include "string_util.h" #include "task.h" #include "text.h" #include "constants/event_object_movement.h" #include "constants/event_objects.h" +#include "constants/heal_locations.h" #include "constants/songs.h" #include "constants/rgb.h" #include "trainer_hill.h" @@ -1274,3 +1279,120 @@ static void Task_EnableScriptAfterMusicFade(u8 taskId) ScriptContext_Enable(); } } + + +static const struct WindowTemplate sWindowTemplate_WhiteoutText = +{ + .bg = 0, + .tilemapLeft = 0, + .tilemapTop = 5, + .width = 30, + .height = 11, + .paletteNum = 15, + .baseBlock = 1, +}; + +static const u8 sWhiteoutTextColors[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY }; + +#define tState data[0] +#define tWindowId data[1] +#define tPrintState data[2] + +static bool8 PrintWhiteOutRecoveryMessage(u8 taskId, const u8 *text, u8 x, u8 y) +{ + u8 windowId = gTasks[taskId].tWindowId; + + switch (gTasks[taskId].tPrintState) + { + case 0: + FillWindowPixelBuffer(windowId, PIXEL_FILL(0)); + StringExpandPlaceholders(gStringVar4, text); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, y, 1, 0, sWhiteoutTextColors, 1, gStringVar4); + gTextFlags.canABSpeedUpPrint = FALSE; + gTasks[taskId].tPrintState = 1; + break; + case 1: + RunTextPrinters(); + if (!IsTextPrinterActive(windowId)) + { + gTasks[taskId].tPrintState = 0; + return TRUE; + } + break; + } + return FALSE; +} + +static void Task_RushInjuredPokemonToCenter(u8 taskId) +{ + u8 windowId; + + switch (gTasks[taskId].tState) + { + case 0: + windowId = AddWindow(&sWindowTemplate_WhiteoutText); + gTasks[taskId].tWindowId = windowId; + Menu_LoadStdPalAt(BG_PLTT_ID(15)); + FillWindowPixelBuffer(windowId, PIXEL_FILL(0)); + PutWindowTilemap(windowId); + CopyWindowToVram(windowId, COPYWIN_FULL); + + // Scene changes if last heal location was the player's house + if (IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE) + || IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F) + || IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE) + || IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F)) + gTasks[taskId].tState = 4; + else + gTasks[taskId].tState = 1; + break; + case 1: + if (PrintWhiteOutRecoveryMessage(taskId, gText_PlayerScurriedToCenter, 2, 8)) + { + ObjectEventTurn(&gObjectEvents[gPlayerAvatar.objectEventId], DIR_NORTH); + gTasks[taskId].tState++; + } + break; + case 4: + if (PrintWhiteOutRecoveryMessage(taskId, gText_PlayerScurriedBackHome, 2, 8)) + { + ObjectEventTurn(&gObjectEvents[gPlayerAvatar.objectEventId], DIR_NORTH); + gTasks[taskId].tState++; + } + break; + case 2: + case 5: + windowId = gTasks[taskId].tWindowId; + ClearWindowTilemap(windowId); + CopyWindowToVram(windowId, COPYWIN_MAP); + RemoveWindow(windowId); + FillPalBufferBlack(); + FadeInFromBlack(); + gTasks[taskId].tState++; + break; + case 3: + if (WaitForWeatherFadeIn() == TRUE) + { + DestroyTask(taskId); + ScriptContext_SetupScript(EventScript_AfterWhiteOutHeal); + } + break; + case 6: + if (WaitForWeatherFadeIn() == TRUE) + { + DestroyTask(taskId); + ScriptContext_SetupScript(EventScript_AfterWhiteOutMomHeal); + } + break; + } +} + +void FieldCB_RushInjuredPokemonToCenter(void) +{ + u8 taskId; + + LockPlayerFieldControls(); + FillPalBufferBlack(); + taskId = CreateTask(Task_RushInjuredPokemonToCenter, 10); + gTasks[taskId].tState = 0; +} diff --git a/src/heal_location.c b/src/heal_location.c index 0ab5540346f3..f82e11f57659 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -1,6 +1,9 @@ #include "global.h" +#include "event_data.h" #include "heal_location.h" +#include "overworld.h" #include "constants/heal_locations.h" +#include "constants/maps.h" #include "data/heal_locations.h" @@ -35,3 +38,63 @@ const struct HealLocation *GetHealLocation(u32 index) else return &sHealLocations[index - 1]; } + +bool32 IsLastHealLocation(u32 healLocation) +{ + const struct HealLocation *loc = GetHealLocation(healLocation); + const struct WarpData *warpData = &gSaveBlock1Ptr->lastHealLocation; + + return warpData->mapGroup == loc->group + && warpData->mapNum == loc->map + && warpData->warpId == WARP_ID_NONE + && warpData->x == loc->x + && warpData->y == loc->y; +} + +static void SetWhiteoutRespawnHealerNpcAsLastTalked(u32 healLocationId) +{ + gSpecialVar_LastTalked = sWhiteoutRespawnHealerNpcLocalIds[healLocationId - 1]; +} + +void SetWhiteoutRespawnWarpAndHealerNpc(struct WarpData * warp) +{ + u32 healLocationId = GetHealLocationIndexByMap(gSaveBlock1Ptr->lastHealLocation.mapGroup, gSaveBlock1Ptr->lastHealLocation.mapNum); + warp->mapGroup = sHealLocationsPokemonCenter[healLocationId - 1][0]; + warp->mapNum = sHealLocationsPokemonCenter[healLocationId - 1][1]; + warp->warpId = 0xFF; + + if (sHealLocationsPokemonCenter[healLocationId - 1][0] == MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F) && sHealLocationsPokemonCenter[healLocationId - 1][1] == MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F)) + { + warp->x = 2; + warp->y = 7; + } + else if (sHealLocationsPokemonCenter[healLocationId - 1][0] == MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F) && sHealLocationsPokemonCenter[healLocationId - 1][1] == MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F)) + { + warp->x = 8; + warp->y = 7; + } + else if (sHealLocations[healLocationId - 1].group == MAP_GROUP(EVER_GRANDE_CITY) + && sHealLocations[healLocationId - 1].map == MAP_NUM(EVER_GRANDE_CITY) + && sHealLocations[HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1].x == gSaveBlock1Ptr->lastHealLocation.x + && sHealLocations[HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1].y == gSaveBlock1Ptr->lastHealLocation.y) + { + healLocationId = HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE; + warp->mapGroup = sHealLocationsPokemonCenter[healLocationId - 1][0]; + warp->mapNum = sHealLocationsPokemonCenter[healLocationId - 1][1]; + warp->x = 3; + warp->y = 4; + } + else // standard Pokemon Center layout + { + warp->x = 7; + warp->y = 4; + } + SetWhiteoutRespawnHealerNpcAsLastTalked(healLocationId); +} + +bool32 HasHealNPC(u32 healLocationId) +{ + if (healLocationId == HEAL_LOCATION_NONE || healLocationId > HEAL_LOCATION_MAX) + return FALSE; + return sWhiteoutRespawnHealerNpcLocalIds[healLocationId - 1] > 0; +} diff --git a/src/overworld.c b/src/overworld.c index ca5a268a82c4..f0422360351f 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -62,6 +62,7 @@ #include "vs_seeker.h" #include "frontier_util.h" #include "constants/abilities.h" +#include "constants/heal_locations.h" #include "constants/layouts.h" #include "constants/map_types.h" #include "constants/region_map_sections.h" @@ -689,9 +690,19 @@ void SetWarpDestinationToHealLocation(u8 healLocationId) SetWarpDestination(healLocation->group, healLocation->map, WARP_ID_NONE, healLocation->x, healLocation->y); } +static bool32 IsFLRGWhiteout(void) +{ + if (!OW_FRLG_WHITEOUT) + return FALSE; + return HasHealNPC(GetHealLocationIndexByMap(gSaveBlock1Ptr->lastHealLocation.mapGroup, gSaveBlock1Ptr->lastHealLocation.mapNum)); +} + void SetWarpDestinationToLastHealLocation(void) { - sWarpDestination = gSaveBlock1Ptr->lastHealLocation; + if (IsFLRGWhiteout()) + SetWhiteoutRespawnWarpAndHealerNpc(&sWarpDestination); + else + sWarpDestination = gSaveBlock1Ptr->lastHealLocation; } void SetLastHealLocationWarp(u8 healLocationId) @@ -1610,7 +1621,10 @@ void CB2_WhiteOut(void) ResetInitialPlayerAvatarState(); ScriptContext_Init(); UnlockPlayerFieldControls(); - gFieldCallback = FieldCB_WarpExitFadeFromBlack; + if (IsFLRGWhiteout()) + gFieldCallback = FieldCB_RushInjuredPokemonToCenter; + else + gFieldCallback = FieldCB_WarpExitFadeFromBlack; state = 0; DoMapLoadLoop(&state); SetFieldVBlankCallback(); diff --git a/src/strings.c b/src/strings.c index 254378d37920..28ed992d43c8 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1295,6 +1295,8 @@ const u8 gText_Sorry[] = _("SORRY"); const u8 gText_YaySmileEmoji[] = _("YAY{EMOJI_BIGSMILE}"); const u8 gText_ThankYou[] = _("THANK YOU"); const u8 gText_ByeBye[] = _("BYE-BYE!"); +const u8 gText_PlayerScurriedToCenter[] = _("{PLAYER} scurried to a POKéMON CENTER,\nprotecting the exhausted and fainted\nPOKéMON from further harm…\p"); +const u8 gText_PlayerScurriedBackHome[] = _("{PLAYER} scurried back home, protecting\nthe exhausted and fainted POKéMON from\nfurther harm…\p"); const u8 gText_MatchCallSteven_Strategy[] = _("Attack the weak points!"); const u8 gText_MatchCallSteven_Pokemon[] = _("Ultimate STEEL POKéMON."); const u8 gText_MatchCallSteven_Intro1_BeforeMeteorFallsBattle[] = _("I'd climb even waterfalls"); From 34c7de192c42a588ee963018ce3c92310133689c Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Sun, 14 Jul 2024 12:58:49 +0200 Subject: [PATCH 2/8] added more accurate way to get heal location index, added suggested changes --- include/config/overworld.h | 2 +- include/constants/heal_locations.h | 2 +- include/heal_location.h | 2 +- src/data/heal_locations.h | 168 ++++++++++++++++++++++++----- src/field_screen_effect.c | 1 - src/heal_location.c | 65 ++++++----- src/overworld.c | 2 +- 7 files changed, 179 insertions(+), 63 deletions(-) diff --git a/include/config/overworld.h b/include/config/overworld.h index 0771d1631f72..9d90df25a3f8 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -8,7 +8,7 @@ #define OW_POISON_DAMAGE GEN_LATEST // In Gen4, Pokémon no longer faint from Poison in the overworld. In Gen5+, they no longer take damage at all. #define OW_DOUBLE_APPROACH_WITH_ONE_MON FALSE // If enabled, you can be spotted by two trainers at the same time even if you only have one eligible Pokémon in your party. #define OW_HIDE_REPEAT_MAP_POPUP FALSE // If enabled, map popups will not appear if entering a map with the same Map Section Id as the last. -#define OW_FRLG_WHITEOUT TRUE // If enabled, shows an additional whiteout message and post whiteout event script with healing NPC +#define OW_FRLG_WHITEOUT FALSE // If enabled, shows an additional whiteout message and post whiteout event script with healing NPC // These generational defines only make a distinction for Berries and the OW_PC_MOVE_ORDER #define GEN_6_XY GEN_6 diff --git a/include/constants/heal_locations.h b/include/constants/heal_locations.h index 8af550ca0984..f75308ae6233 100644 --- a/include/constants/heal_locations.h +++ b/include/constants/heal_locations.h @@ -24,6 +24,6 @@ #define HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE 20 #define HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR 21 #define HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST 22 -#define HEAL_LOCATION_MAX (HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST) +#define HEAL_LOCATION_COUNT (HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST + 1) #endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H diff --git a/include/heal_location.h b/include/heal_location.h index a1f5e7a25da4..85e7dfad1229 100644 --- a/include/heal_location.h +++ b/include/heal_location.h @@ -13,7 +13,7 @@ u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum); const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum); const struct HealLocation *GetHealLocation(u32 index); bool32 IsLastHealLocation(u32 healLocation); -void SetWhiteoutRespawnWarpAndHealerNpc(struct WarpData * warp); +void SetWhiteoutRespawnWarpAndHealerNPC(struct WarpData * warp); bool32 HasHealNPC(u32 healLocationId); #endif // GUARD_HEAL_LOCATION_H diff --git a/src/data/heal_locations.h b/src/data/heal_locations.h index bc74b934fcea..57510fbea622 100644 --- a/src/data/heal_locations.h +++ b/src/data/heal_locations.h @@ -24,33 +24,153 @@ static const struct HealLocation sHealLocations[] = [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = {MAP_GROUP(BATTLE_FRONTIER_OUTSIDE_EAST), MAP_NUM(BATTLE_FRONTIER_OUTSIDE_EAST), 3, 52}, }; -static const u16 sHealLocationsPokemonCenter[][2] = +#define DEFAULT_POKEMON_CENTER_COORDS .x = 7, .y = 4 + +static const struct HealLocation sHealLocationsPokemonCenter[HEAL_LOCATION_COUNT - 1] = { - [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = {MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F)}, - [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = {MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F), MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F)}, - [HEAL_LOCATION_PETALBURG_CITY - 1] = {MAP_GROUP(PETALBURG_CITY_POKEMON_CENTER_1F), MAP_NUM(PETALBURG_CITY_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_SLATEPORT_CITY - 1] = {MAP_GROUP(SLATEPORT_CITY_POKEMON_CENTER_1F), MAP_NUM(SLATEPORT_CITY_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_MAUVILLE_CITY - 1] = {MAP_GROUP(MAUVILLE_CITY_POKEMON_CENTER_1F), MAP_NUM(MAUVILLE_CITY_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_RUSTBORO_CITY - 1] = {MAP_GROUP(RUSTBORO_CITY_POKEMON_CENTER_1F), MAP_NUM(RUSTBORO_CITY_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_FORTREE_CITY - 1] = {MAP_GROUP(FORTREE_CITY_POKEMON_CENTER_1F), MAP_NUM(FORTREE_CITY_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_LILYCOVE_CITY - 1] = {MAP_GROUP(LILYCOVE_CITY_POKEMON_CENTER_1F), MAP_NUM(LILYCOVE_CITY_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_MOSSDEEP_CITY - 1] = {MAP_GROUP(MOSSDEEP_CITY_POKEMON_CENTER_1F), MAP_NUM(MOSSDEEP_CITY_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_SOOTOPOLIS_CITY - 1] = {MAP_GROUP(SOOTOPOLIS_CITY_POKEMON_CENTER_1F), MAP_NUM(SOOTOPOLIS_CITY_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_EVER_GRANDE_CITY - 1] = {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_CENTER_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE - 1] = {MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F)}, - [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE - 1] = {MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F), MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F)}, - [HEAL_LOCATION_OLDALE_TOWN - 1] = {MAP_GROUP(OLDALE_TOWN_POKEMON_CENTER_1F), MAP_NUM(OLDALE_TOWN_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_DEWFORD_TOWN - 1] = {MAP_GROUP(DEWFORD_TOWN_POKEMON_CENTER_1F), MAP_NUM(DEWFORD_TOWN_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_LAVARIDGE_TOWN - 1] = {MAP_GROUP(LAVARIDGE_TOWN_POKEMON_CENTER_1F), MAP_NUM(LAVARIDGE_TOWN_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_FALLARBOR_TOWN - 1] = {MAP_GROUP(FALLARBOR_TOWN_POKEMON_CENTER_1F), MAP_NUM(FALLARBOR_TOWN_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_VERDANTURF_TOWN - 1] = {MAP_GROUP(VERDANTURF_TOWN_POKEMON_CENTER_1F), MAP_NUM(VERDANTURF_TOWN_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_PACIFIDLOG_TOWN - 1] = {MAP_GROUP(PACIFIDLOG_TOWN_POKEMON_CENTER_1F), MAP_NUM(PACIFIDLOG_TOWN_POKEMON_CENTER_1F)}, - [HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1] = {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F)}, - [HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR - 1] = {MAP_GROUP(SOUTHERN_ISLAND_EXTERIOR), MAP_NUM(SOUTHERN_ISLAND_EXTERIOR)}, - [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = {MAP_GROUP(BATTLE_FRONTIER_POKEMON_CENTER_1F), MAP_NUM(BATTLE_FRONTIER_POKEMON_CENTER_1F)}, + [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = + { + .group = MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), + .map = MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), + .x = 2, + .y = 7, + }, + [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = + { + .group = MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F), + .map = MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F), + .x = 8, + .y = 7, + }, + [HEAL_LOCATION_PETALBURG_CITY - 1] = + { + .group = MAP_GROUP(PETALBURG_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(PETALBURG_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_SLATEPORT_CITY - 1] = + { + .group = MAP_GROUP(SLATEPORT_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(SLATEPORT_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_MAUVILLE_CITY - 1] = + { + .group = MAP_GROUP(MAUVILLE_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(MAUVILLE_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_RUSTBORO_CITY - 1] = + { + .group = MAP_GROUP(RUSTBORO_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(RUSTBORO_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_FORTREE_CITY - 1] = + { + .group = MAP_GROUP(FORTREE_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(FORTREE_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_LILYCOVE_CITY - 1] = + { + .group = MAP_GROUP(LILYCOVE_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(LILYCOVE_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_MOSSDEEP_CITY - 1] = + { + .group = MAP_GROUP(MOSSDEEP_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(MOSSDEEP_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_SOOTOPOLIS_CITY - 1] = + { + .group = MAP_GROUP(SOOTOPOLIS_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(SOOTOPOLIS_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_EVER_GRANDE_CITY - 1] = + { + .group = MAP_GROUP(EVER_GRANDE_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(EVER_GRANDE_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE - 1] = + { + .group = MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), + .map = MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), + .x = 2, + .y = 7, + }, + [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE - 1] = + { + .group = MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F), + .map = MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F), + .x = 8, + .y = 7, + }, + [HEAL_LOCATION_OLDALE_TOWN - 1] = + { + .group = MAP_GROUP(OLDALE_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(OLDALE_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_DEWFORD_TOWN - 1] = + { + .group = MAP_GROUP(DEWFORD_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(DEWFORD_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_LAVARIDGE_TOWN - 1] = + { + .group = MAP_GROUP(LAVARIDGE_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(LAVARIDGE_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_FALLARBOR_TOWN - 1] = + { + .group = MAP_GROUP(FALLARBOR_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(FALLARBOR_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_VERDANTURF_TOWN - 1] = + { + .group = MAP_GROUP(VERDANTURF_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(VERDANTURF_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_PACIFIDLOG_TOWN - 1] = + { + .group = MAP_GROUP(PACIFIDLOG_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(PACIFIDLOG_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1] = + { + .group = MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), + .map = MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), + .x = 3, + .y = 4, + }, + [HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR - 1] = + { + .group = MAP_GROUP(SOUTHERN_ISLAND_EXTERIOR), + .map = MAP_NUM(SOUTHERN_ISLAND_EXTERIOR), + .x = 15, + .y = 20, + }, + [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = + { + .group = MAP_GROUP(BATTLE_FRONTIER_POKEMON_CENTER_1F), + .map = MAP_NUM(BATTLE_FRONTIER_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, }; -static const u8 sWhiteoutRespawnHealerNpcLocalIds[] = +#undef DEFAULT_POKEMON_CENTER_COORDS + +static const u8 sWhiteoutRespawnHealerNpcLocalIds[HEAL_LOCATION_COUNT - 1] = { [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = 1, [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = 1, diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index 58ffd6f01f8f..1790dfed2cb6 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -1280,7 +1280,6 @@ static void Task_EnableScriptAfterMusicFade(u8 taskId) } } - static const struct WindowTemplate sWindowTemplate_WhiteoutText = { .bg = 0, diff --git a/src/heal_location.c b/src/heal_location.c index f82e11f57659..8b4072d989d8 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -29,6 +29,20 @@ const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum) return &sHealLocations[index - 1]; } +static u32 GetHealLocationIndexByWarpData(struct WarpData *warp) +{ + u32 i; + for (i = 0; i < ARRAY_COUNT(sHealLocations); i++) + { + if (sHealLocations[i].group == warp->mapGroup + && sHealLocations[i].map == warp->mapNum + && sHealLocations[i].x == warp->x + && sHealLocations[i].y == warp->y) + return i + 1; + } + return HEAL_LOCATION_NONE; +} + const struct HealLocation *GetHealLocation(u32 index) { if (index == HEAL_LOCATION_NONE) @@ -51,50 +65,33 @@ bool32 IsLastHealLocation(u32 healLocation) && warpData->y == loc->y; } -static void SetWhiteoutRespawnHealerNpcAsLastTalked(u32 healLocationId) +static void SetWhiteoutRespawnHealerNPCAsLastTalked(u32 healLocationId) { gSpecialVar_LastTalked = sWhiteoutRespawnHealerNpcLocalIds[healLocationId - 1]; } -void SetWhiteoutRespawnWarpAndHealerNpc(struct WarpData * warp) + +void SetWhiteoutRespawnWarpAndHealerNPC(struct WarpData *warp) { - u32 healLocationId = GetHealLocationIndexByMap(gSaveBlock1Ptr->lastHealLocation.mapGroup, gSaveBlock1Ptr->lastHealLocation.mapNum); - warp->mapGroup = sHealLocationsPokemonCenter[healLocationId - 1][0]; - warp->mapNum = sHealLocationsPokemonCenter[healLocationId - 1][1]; - warp->warpId = 0xFF; + u32 healLocationId = GetHealLocationIndexByWarpData(&gSaveBlock1Ptr->lastHealLocation); + struct HealLocation pkmCenterHealLocation; + + if (!HasHealNPC(healLocationId)) + healLocationId = gSaveBlock2Ptr->playerGender == MALE ? HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE : HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE; + + pkmCenterHealLocation = sHealLocationsPokemonCenter[healLocationId - 1]; - if (sHealLocationsPokemonCenter[healLocationId - 1][0] == MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F) && sHealLocationsPokemonCenter[healLocationId - 1][1] == MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F)) - { - warp->x = 2; - warp->y = 7; - } - else if (sHealLocationsPokemonCenter[healLocationId - 1][0] == MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F) && sHealLocationsPokemonCenter[healLocationId - 1][1] == MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F)) - { - warp->x = 8; - warp->y = 7; - } - else if (sHealLocations[healLocationId - 1].group == MAP_GROUP(EVER_GRANDE_CITY) - && sHealLocations[healLocationId - 1].map == MAP_NUM(EVER_GRANDE_CITY) - && sHealLocations[HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1].x == gSaveBlock1Ptr->lastHealLocation.x - && sHealLocations[HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1].y == gSaveBlock1Ptr->lastHealLocation.y) - { - healLocationId = HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE; - warp->mapGroup = sHealLocationsPokemonCenter[healLocationId - 1][0]; - warp->mapNum = sHealLocationsPokemonCenter[healLocationId - 1][1]; - warp->x = 3; - warp->y = 4; - } - else // standard Pokemon Center layout - { - warp->x = 7; - warp->y = 4; - } - SetWhiteoutRespawnHealerNpcAsLastTalked(healLocationId); + warp->mapGroup = pkmCenterHealLocation.group; + warp->mapNum = pkmCenterHealLocation.map; + warp->warpId = WARP_ID_NONE; + warp->x = pkmCenterHealLocation.x; + warp->y = pkmCenterHealLocation.y; + SetWhiteoutRespawnHealerNPCAsLastTalked(healLocationId); } bool32 HasHealNPC(u32 healLocationId) { - if (healLocationId == HEAL_LOCATION_NONE || healLocationId > HEAL_LOCATION_MAX) + if (healLocationId == HEAL_LOCATION_NONE || healLocationId >= HEAL_LOCATION_COUNT) return FALSE; return sWhiteoutRespawnHealerNpcLocalIds[healLocationId - 1] > 0; } diff --git a/src/overworld.c b/src/overworld.c index f0422360351f..a367f87d1853 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -700,7 +700,7 @@ static bool32 IsFLRGWhiteout(void) void SetWarpDestinationToLastHealLocation(void) { if (IsFLRGWhiteout()) - SetWhiteoutRespawnWarpAndHealerNpc(&sWarpDestination); + SetWhiteoutRespawnWarpAndHealerNPC(&sWarpDestination); else sWarpDestination = gSaveBlock1Ptr->lastHealLocation; } From dbf13a55879ea0b86d7ef48f78c170a68014e70c Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Sun, 14 Jul 2024 13:46:47 +0200 Subject: [PATCH 3/8] remove includes --- src/heal_location.c | 1 - src/overworld.c | 1 - 2 files changed, 2 deletions(-) diff --git a/src/heal_location.c b/src/heal_location.c index 8b4072d989d8..015c514788fd 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -1,7 +1,6 @@ #include "global.h" #include "event_data.h" #include "heal_location.h" -#include "overworld.h" #include "constants/heal_locations.h" #include "constants/maps.h" diff --git a/src/overworld.c b/src/overworld.c index a367f87d1853..ba1f53a7e6fb 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -62,7 +62,6 @@ #include "vs_seeker.h" #include "frontier_util.h" #include "constants/abilities.h" -#include "constants/heal_locations.h" #include "constants/layouts.h" #include "constants/map_types.h" #include "constants/region_map_sections.h" From 2a7f1025da6ac2605beee5fec665a2ba6931d92e Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Sun, 14 Jul 2024 14:59:47 +0200 Subject: [PATCH 4/8] fix typo --- src/overworld.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/overworld.c b/src/overworld.c index ba1f53a7e6fb..30d025b8a93c 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -689,7 +689,7 @@ void SetWarpDestinationToHealLocation(u8 healLocationId) SetWarpDestination(healLocation->group, healLocation->map, WARP_ID_NONE, healLocation->x, healLocation->y); } -static bool32 IsFLRGWhiteout(void) +static bool32 IsFRLGWhiteout(void) { if (!OW_FRLG_WHITEOUT) return FALSE; @@ -698,7 +698,7 @@ static bool32 IsFLRGWhiteout(void) void SetWarpDestinationToLastHealLocation(void) { - if (IsFLRGWhiteout()) + if (IsFRLGWhiteout()) SetWhiteoutRespawnWarpAndHealerNPC(&sWarpDestination); else sWarpDestination = gSaveBlock1Ptr->lastHealLocation; @@ -1620,7 +1620,7 @@ void CB2_WhiteOut(void) ResetInitialPlayerAvatarState(); ScriptContext_Init(); UnlockPlayerFieldControls(); - if (IsFLRGWhiteout()) + if (IsFRLGWhiteout()) gFieldCallback = FieldCB_RushInjuredPokemonToCenter; else gFieldCallback = FieldCB_WarpExitFadeFromBlack; From f9476de8a5b2020acc98ed7551c608d495ef92f0 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Sun, 14 Jul 2024 15:16:02 +0200 Subject: [PATCH 5/8] remove redundancy --- src/heal_location.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/heal_location.c b/src/heal_location.c index 015c514788fd..47f2147b5ade 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -73,12 +73,7 @@ static void SetWhiteoutRespawnHealerNPCAsLastTalked(u32 healLocationId) void SetWhiteoutRespawnWarpAndHealerNPC(struct WarpData *warp) { u32 healLocationId = GetHealLocationIndexByWarpData(&gSaveBlock1Ptr->lastHealLocation); - struct HealLocation pkmCenterHealLocation; - - if (!HasHealNPC(healLocationId)) - healLocationId = gSaveBlock2Ptr->playerGender == MALE ? HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE : HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE; - - pkmCenterHealLocation = sHealLocationsPokemonCenter[healLocationId - 1]; + struct HealLocation pkmCenterHealLocation = sHealLocationsPokemonCenter[healLocationId - 1]; warp->mapGroup = pkmCenterHealLocation.group; warp->mapNum = pkmCenterHealLocation.map; From 6dad6edff3520dd0f56e4e51ed457f3fcbad84e2 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Sun, 21 Jul 2024 12:09:43 +0200 Subject: [PATCH 6/8] moved new data to separate file for porymap compatability --- include/constants/heal_locations.h | 2 +- src/data/heal_locations.h | 173 --------------------------- src/data/heal_locations_pkm_center.h | 171 ++++++++++++++++++++++++++ src/heal_location.c | 1 + 4 files changed, 173 insertions(+), 174 deletions(-) create mode 100644 src/data/heal_locations_pkm_center.h diff --git a/include/constants/heal_locations.h b/include/constants/heal_locations.h index f75308ae6233..217594d0b7f2 100644 --- a/include/constants/heal_locations.h +++ b/include/constants/heal_locations.h @@ -24,6 +24,6 @@ #define HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE 20 #define HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR 21 #define HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST 22 -#define HEAL_LOCATION_COUNT (HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST + 1) +#define HEAL_LOCATION_COUNT 23 #endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H diff --git a/src/data/heal_locations.h b/src/data/heal_locations.h index 57510fbea622..04530a1dbf2c 100644 --- a/src/data/heal_locations.h +++ b/src/data/heal_locations.h @@ -23,176 +23,3 @@ static const struct HealLocation sHealLocations[] = [HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR - 1] = {MAP_GROUP(SOUTHERN_ISLAND_EXTERIOR), MAP_NUM(SOUTHERN_ISLAND_EXTERIOR), 15, 20}, [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = {MAP_GROUP(BATTLE_FRONTIER_OUTSIDE_EAST), MAP_NUM(BATTLE_FRONTIER_OUTSIDE_EAST), 3, 52}, }; - -#define DEFAULT_POKEMON_CENTER_COORDS .x = 7, .y = 4 - -static const struct HealLocation sHealLocationsPokemonCenter[HEAL_LOCATION_COUNT - 1] = -{ - [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = - { - .group = MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), - .map = MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), - .x = 2, - .y = 7, - }, - [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = - { - .group = MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F), - .map = MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F), - .x = 8, - .y = 7, - }, - [HEAL_LOCATION_PETALBURG_CITY - 1] = - { - .group = MAP_GROUP(PETALBURG_CITY_POKEMON_CENTER_1F), - .map = MAP_NUM(PETALBURG_CITY_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_SLATEPORT_CITY - 1] = - { - .group = MAP_GROUP(SLATEPORT_CITY_POKEMON_CENTER_1F), - .map = MAP_NUM(SLATEPORT_CITY_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_MAUVILLE_CITY - 1] = - { - .group = MAP_GROUP(MAUVILLE_CITY_POKEMON_CENTER_1F), - .map = MAP_NUM(MAUVILLE_CITY_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_RUSTBORO_CITY - 1] = - { - .group = MAP_GROUP(RUSTBORO_CITY_POKEMON_CENTER_1F), - .map = MAP_NUM(RUSTBORO_CITY_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_FORTREE_CITY - 1] = - { - .group = MAP_GROUP(FORTREE_CITY_POKEMON_CENTER_1F), - .map = MAP_NUM(FORTREE_CITY_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_LILYCOVE_CITY - 1] = - { - .group = MAP_GROUP(LILYCOVE_CITY_POKEMON_CENTER_1F), - .map = MAP_NUM(LILYCOVE_CITY_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_MOSSDEEP_CITY - 1] = - { - .group = MAP_GROUP(MOSSDEEP_CITY_POKEMON_CENTER_1F), - .map = MAP_NUM(MOSSDEEP_CITY_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_SOOTOPOLIS_CITY - 1] = - { - .group = MAP_GROUP(SOOTOPOLIS_CITY_POKEMON_CENTER_1F), - .map = MAP_NUM(SOOTOPOLIS_CITY_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_EVER_GRANDE_CITY - 1] = - { - .group = MAP_GROUP(EVER_GRANDE_CITY_POKEMON_CENTER_1F), - .map = MAP_NUM(EVER_GRANDE_CITY_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE - 1] = - { - .group = MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), - .map = MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), - .x = 2, - .y = 7, - }, - [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE - 1] = - { - .group = MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F), - .map = MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F), - .x = 8, - .y = 7, - }, - [HEAL_LOCATION_OLDALE_TOWN - 1] = - { - .group = MAP_GROUP(OLDALE_TOWN_POKEMON_CENTER_1F), - .map = MAP_NUM(OLDALE_TOWN_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_DEWFORD_TOWN - 1] = - { - .group = MAP_GROUP(DEWFORD_TOWN_POKEMON_CENTER_1F), - .map = MAP_NUM(DEWFORD_TOWN_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_LAVARIDGE_TOWN - 1] = - { - .group = MAP_GROUP(LAVARIDGE_TOWN_POKEMON_CENTER_1F), - .map = MAP_NUM(LAVARIDGE_TOWN_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_FALLARBOR_TOWN - 1] = - { - .group = MAP_GROUP(FALLARBOR_TOWN_POKEMON_CENTER_1F), - .map = MAP_NUM(FALLARBOR_TOWN_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_VERDANTURF_TOWN - 1] = - { - .group = MAP_GROUP(VERDANTURF_TOWN_POKEMON_CENTER_1F), - .map = MAP_NUM(VERDANTURF_TOWN_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_PACIFIDLOG_TOWN - 1] = - { - .group = MAP_GROUP(PACIFIDLOG_TOWN_POKEMON_CENTER_1F), - .map = MAP_NUM(PACIFIDLOG_TOWN_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, - [HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1] = - { - .group = MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), - .map = MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), - .x = 3, - .y = 4, - }, - [HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR - 1] = - { - .group = MAP_GROUP(SOUTHERN_ISLAND_EXTERIOR), - .map = MAP_NUM(SOUTHERN_ISLAND_EXTERIOR), - .x = 15, - .y = 20, - }, - [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = - { - .group = MAP_GROUP(BATTLE_FRONTIER_POKEMON_CENTER_1F), - .map = MAP_NUM(BATTLE_FRONTIER_POKEMON_CENTER_1F), - DEFAULT_POKEMON_CENTER_COORDS, - }, -}; - -#undef DEFAULT_POKEMON_CENTER_COORDS - -static const u8 sWhiteoutRespawnHealerNpcLocalIds[HEAL_LOCATION_COUNT - 1] = -{ - [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = 1, - [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = 1, - [HEAL_LOCATION_PETALBURG_CITY - 1] = 1, - [HEAL_LOCATION_SLATEPORT_CITY - 1] = 1, - [HEAL_LOCATION_MAUVILLE_CITY - 1] = 1, - [HEAL_LOCATION_RUSTBORO_CITY - 1] = 1, - [HEAL_LOCATION_FORTREE_CITY - 1] = 1, - [HEAL_LOCATION_LILYCOVE_CITY - 1] = 1, - [HEAL_LOCATION_MOSSDEEP_CITY - 1] = 1, - [HEAL_LOCATION_SOOTOPOLIS_CITY - 1] = 1, - [HEAL_LOCATION_EVER_GRANDE_CITY - 1] = 1, - [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE - 1] = 1, - [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE - 1] = 1, - [HEAL_LOCATION_OLDALE_TOWN - 1] = 1, - [HEAL_LOCATION_DEWFORD_TOWN - 1] = 1, - [HEAL_LOCATION_LAVARIDGE_TOWN - 1] = 1, - [HEAL_LOCATION_FALLARBOR_TOWN - 1] = 1, - [HEAL_LOCATION_VERDANTURF_TOWN - 1] = 1, - [HEAL_LOCATION_PACIFIDLOG_TOWN - 1] = 1, - [HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1] = 1, - [HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR - 1] = 0, // no heal npc - [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = 1, -}; - diff --git a/src/data/heal_locations_pkm_center.h b/src/data/heal_locations_pkm_center.h new file mode 100644 index 000000000000..8df625cad421 --- /dev/null +++ b/src/data/heal_locations_pkm_center.h @@ -0,0 +1,171 @@ +#define DEFAULT_POKEMON_CENTER_COORDS .x = 7, .y = 4 + +static const struct HealLocation sHealLocationsPokemonCenter[HEAL_LOCATION_COUNT - 1] = +{ + [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = + { + .group = MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), + .map = MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), + .x = 2, + .y = 7, + }, + [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = + { + .group = MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F), + .map = MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F), + .x = 8, + .y = 7, + }, + [HEAL_LOCATION_PETALBURG_CITY - 1] = + { + .group = MAP_GROUP(PETALBURG_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(PETALBURG_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_SLATEPORT_CITY - 1] = + { + .group = MAP_GROUP(SLATEPORT_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(SLATEPORT_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_MAUVILLE_CITY - 1] = + { + .group = MAP_GROUP(MAUVILLE_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(MAUVILLE_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_RUSTBORO_CITY - 1] = + { + .group = MAP_GROUP(RUSTBORO_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(RUSTBORO_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_FORTREE_CITY - 1] = + { + .group = MAP_GROUP(FORTREE_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(FORTREE_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_LILYCOVE_CITY - 1] = + { + .group = MAP_GROUP(LILYCOVE_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(LILYCOVE_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_MOSSDEEP_CITY - 1] = + { + .group = MAP_GROUP(MOSSDEEP_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(MOSSDEEP_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_SOOTOPOLIS_CITY - 1] = + { + .group = MAP_GROUP(SOOTOPOLIS_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(SOOTOPOLIS_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_EVER_GRANDE_CITY - 1] = + { + .group = MAP_GROUP(EVER_GRANDE_CITY_POKEMON_CENTER_1F), + .map = MAP_NUM(EVER_GRANDE_CITY_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE - 1] = + { + .group = MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), + .map = MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F), + .x = 2, + .y = 7, + }, + [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE - 1] = + { + .group = MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_1F), + .map = MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F), + .x = 8, + .y = 7, + }, + [HEAL_LOCATION_OLDALE_TOWN - 1] = + { + .group = MAP_GROUP(OLDALE_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(OLDALE_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_DEWFORD_TOWN - 1] = + { + .group = MAP_GROUP(DEWFORD_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(DEWFORD_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_LAVARIDGE_TOWN - 1] = + { + .group = MAP_GROUP(LAVARIDGE_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(LAVARIDGE_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_FALLARBOR_TOWN - 1] = + { + .group = MAP_GROUP(FALLARBOR_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(FALLARBOR_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_VERDANTURF_TOWN - 1] = + { + .group = MAP_GROUP(VERDANTURF_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(VERDANTURF_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_PACIFIDLOG_TOWN - 1] = + { + .group = MAP_GROUP(PACIFIDLOG_TOWN_POKEMON_CENTER_1F), + .map = MAP_NUM(PACIFIDLOG_TOWN_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, + [HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1] = + { + .group = MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), + .map = MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), + .x = 3, + .y = 4, + }, + [HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR - 1] = + { + .group = MAP_GROUP(SOUTHERN_ISLAND_EXTERIOR), + .map = MAP_NUM(SOUTHERN_ISLAND_EXTERIOR), + .x = 15, + .y = 20, + }, + [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = + { + .group = MAP_GROUP(BATTLE_FRONTIER_POKEMON_CENTER_1F), + .map = MAP_NUM(BATTLE_FRONTIER_POKEMON_CENTER_1F), + DEFAULT_POKEMON_CENTER_COORDS, + }, +}; + +#undef DEFAULT_POKEMON_CENTER_COORDS + +static const u8 sWhiteoutRespawnHealerNpcLocalIds[HEAL_LOCATION_COUNT - 1] = +{ + [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = 1, + [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = 1, + [HEAL_LOCATION_PETALBURG_CITY - 1] = 1, + [HEAL_LOCATION_SLATEPORT_CITY - 1] = 1, + [HEAL_LOCATION_MAUVILLE_CITY - 1] = 1, + [HEAL_LOCATION_RUSTBORO_CITY - 1] = 1, + [HEAL_LOCATION_FORTREE_CITY - 1] = 1, + [HEAL_LOCATION_LILYCOVE_CITY - 1] = 1, + [HEAL_LOCATION_MOSSDEEP_CITY - 1] = 1, + [HEAL_LOCATION_SOOTOPOLIS_CITY - 1] = 1, + [HEAL_LOCATION_EVER_GRANDE_CITY - 1] = 1, + [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE - 1] = 1, + [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE - 1] = 1, + [HEAL_LOCATION_OLDALE_TOWN - 1] = 1, + [HEAL_LOCATION_DEWFORD_TOWN - 1] = 1, + [HEAL_LOCATION_LAVARIDGE_TOWN - 1] = 1, + [HEAL_LOCATION_FALLARBOR_TOWN - 1] = 1, + [HEAL_LOCATION_VERDANTURF_TOWN - 1] = 1, + [HEAL_LOCATION_PACIFIDLOG_TOWN - 1] = 1, + [HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1] = 1, + [HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR - 1] = 0, // no heal npc + [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = 1, +}; diff --git a/src/heal_location.c b/src/heal_location.c index 47f2147b5ade..6a4dbc2470de 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -5,6 +5,7 @@ #include "constants/maps.h" #include "data/heal_locations.h" +#include "data/heal_locations_pkm_center.h" u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum) { From 410738b5b4d74e27b90d00681edb4925055a2a61 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Sat, 27 Jul 2024 20:26:19 +0200 Subject: [PATCH 7/8] fixed issue with undefined respawn locations, cleaned up whiteout task --- include/heal_location.h | 3 +- src/data/heal_locations_pkm_center.h | 4 ++ src/field_screen_effect.c | 63 +++++++++++++--------------- src/heal_location.c | 43 ++++++++++++------- src/overworld.c | 2 +- 5 files changed, 64 insertions(+), 51 deletions(-) diff --git a/include/heal_location.h b/include/heal_location.h index 85e7dfad1229..d956ae9e013e 100644 --- a/include/heal_location.h +++ b/include/heal_location.h @@ -10,9 +10,10 @@ struct HealLocation }; u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum); +u32 GetHealLocationIndexByWarpData(struct WarpData *warp); const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum); const struct HealLocation *GetHealLocation(u32 index); -bool32 IsLastHealLocation(u32 healLocation); +bool32 IsLastHealLocationPlayerHouse(); void SetWhiteoutRespawnWarpAndHealerNPC(struct WarpData * warp); bool32 HasHealNPC(u32 healLocationId); diff --git a/src/data/heal_locations_pkm_center.h b/src/data/heal_locations_pkm_center.h index 8df625cad421..de47ccd26aed 100644 --- a/src/data/heal_locations_pkm_center.h +++ b/src/data/heal_locations_pkm_center.h @@ -144,6 +144,10 @@ static const struct HealLocation sHealLocationsPokemonCenter[HEAL_LOCATION_COUNT #undef DEFAULT_POKEMON_CENTER_COORDS +// localIds can be found in the generated events.inc file for the specific heal location map +// e.g. for OldaleTown_PokemonCenter1F/events.inc the following entry gets generated: +// object_event 1, OBJ_EVENT_GFX_NURSE, 7, 2, 3, MOVEMENT_TYPE_FACE_DOWN, 0, 0, TRAINER_TYPE_NONE, 0, OldaleTown_PokemonCenter_1F_EventScript_Nurse, 0 +// In this case the localId is 1. static const u8 sWhiteoutRespawnHealerNpcLocalIds[HEAL_LOCATION_COUNT - 1] = { [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = 1, diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index 1790dfed2cb6..08e16479a5e7 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -1293,9 +1293,10 @@ static const struct WindowTemplate sWindowTemplate_WhiteoutText = static const u8 sWhiteoutTextColors[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY }; -#define tState data[0] -#define tWindowId data[1] -#define tPrintState data[2] +#define tState data[0] +#define tWindowId data[1] +#define tPrintState data[2] +#define tIsPlayerHouse data[3] static bool8 PrintWhiteOutRecoveryMessage(u8 taskId, const u8 *text, u8 x, u8 y) { @@ -1322,13 +1323,20 @@ static bool8 PrintWhiteOutRecoveryMessage(u8 taskId, const u8 *text, u8 x, u8 y) return FALSE; } +enum { + FRLG_WHITEOUT_ENTER_MSG_SCREEN, + FRLG_WHITEOUT_PRINT_MSG, + FRLG_WHITEOUT_LEAVE_MSG_SCREEN, + FRLG_WHITEOUT_HEAL_SCRIPT, +}; + static void Task_RushInjuredPokemonToCenter(u8 taskId) { u8 windowId; switch (gTasks[taskId].tState) { - case 0: + case FRLG_WHITEOUT_ENTER_MSG_SCREEN: windowId = AddWindow(&sWindowTemplate_WhiteoutText); gTasks[taskId].tWindowId = windowId; Menu_LoadStdPalAt(BG_PLTT_ID(15)); @@ -1336,51 +1344,36 @@ static void Task_RushInjuredPokemonToCenter(u8 taskId) PutWindowTilemap(windowId); CopyWindowToVram(windowId, COPYWIN_FULL); - // Scene changes if last heal location was the player's house - if (IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE) - || IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F) - || IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE) - || IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F)) - gTasks[taskId].tState = 4; - else - gTasks[taskId].tState = 1; - break; - case 1: - if (PrintWhiteOutRecoveryMessage(taskId, gText_PlayerScurriedToCenter, 2, 8)) - { - ObjectEventTurn(&gObjectEvents[gPlayerAvatar.objectEventId], DIR_NORTH); - gTasks[taskId].tState++; - } + gTasks[taskId].tIsPlayerHouse = IsLastHealLocationPlayerHouse(); + gTasks[taskId].tState = FRLG_WHITEOUT_PRINT_MSG; break; - case 4: - if (PrintWhiteOutRecoveryMessage(taskId, gText_PlayerScurriedBackHome, 2, 8)) + case FRLG_WHITEOUT_PRINT_MSG: + { + const u8 *recoveryMessage = gTasks[taskId].tIsPlayerHouse == TRUE ? gText_PlayerScurriedBackHome : gText_PlayerScurriedToCenter; + if (PrintWhiteOutRecoveryMessage(taskId, recoveryMessage, 2, 8)) { ObjectEventTurn(&gObjectEvents[gPlayerAvatar.objectEventId], DIR_NORTH); - gTasks[taskId].tState++; + gTasks[taskId].tState = FRLG_WHITEOUT_LEAVE_MSG_SCREEN; } break; - case 2: - case 5: + } + case FRLG_WHITEOUT_LEAVE_MSG_SCREEN: windowId = gTasks[taskId].tWindowId; ClearWindowTilemap(windowId); CopyWindowToVram(windowId, COPYWIN_MAP); RemoveWindow(windowId); FillPalBufferBlack(); FadeInFromBlack(); - gTasks[taskId].tState++; + gTasks[taskId].tState = FRLG_WHITEOUT_HEAL_SCRIPT; break; - case 3: + case FRLG_WHITEOUT_HEAL_SCRIPT: if (WaitForWeatherFadeIn() == TRUE) { DestroyTask(taskId); - ScriptContext_SetupScript(EventScript_AfterWhiteOutHeal); - } - break; - case 6: - if (WaitForWeatherFadeIn() == TRUE) - { - DestroyTask(taskId); - ScriptContext_SetupScript(EventScript_AfterWhiteOutMomHeal); + if (gTasks[taskId].tIsPlayerHouse) + ScriptContext_SetupScript(EventScript_AfterWhiteOutMomHeal); + else + ScriptContext_SetupScript(EventScript_AfterWhiteOutHeal); } break; } @@ -1393,5 +1386,5 @@ void FieldCB_RushInjuredPokemonToCenter(void) LockPlayerFieldControls(); FillPalBufferBlack(); taskId = CreateTask(Task_RushInjuredPokemonToCenter, 10); - gTasks[taskId].tState = 0; + gTasks[taskId].tState = FRLG_WHITEOUT_ENTER_MSG_SCREEN; } diff --git a/src/heal_location.c b/src/heal_location.c index 6a4dbc2470de..8cbd1e1a2379 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -29,7 +29,7 @@ const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum) return &sHealLocations[index - 1]; } -static u32 GetHealLocationIndexByWarpData(struct WarpData *warp) +u32 GetHealLocationIndexByWarpData(struct WarpData *warp) { u32 i; for (i = 0; i < ARRAY_COUNT(sHealLocations); i++) @@ -53,7 +53,7 @@ const struct HealLocation *GetHealLocation(u32 index) return &sHealLocations[index - 1]; } -bool32 IsLastHealLocation(u32 healLocation) +static bool32 IsLastHealLocation(u32 healLocation) { const struct HealLocation *loc = GetHealLocation(healLocation); const struct WarpData *warpData = &gSaveBlock1Ptr->lastHealLocation; @@ -65,28 +65,43 @@ bool32 IsLastHealLocation(u32 healLocation) && warpData->y == loc->y; } -static void SetWhiteoutRespawnHealerNPCAsLastTalked(u32 healLocationId) +bool32 IsLastHealLocationPlayerHouse() { - gSpecialVar_LastTalked = sWhiteoutRespawnHealerNpcLocalIds[healLocationId - 1]; + if (IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE) + || IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F) + || IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE) + || IsLastHealLocation(HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F)) + return TRUE; + + return FALSE; } +bool32 HasHealNPC(u32 healLocationId) +{ + if (healLocationId == HEAL_LOCATION_NONE || healLocationId >= HEAL_LOCATION_COUNT) + return FALSE; + + return sWhiteoutRespawnHealerNpcLocalIds[healLocationId - 1] > 0 ? TRUE : FALSE; +} void SetWhiteoutRespawnWarpAndHealerNPC(struct WarpData *warp) { - u32 healLocationId = GetHealLocationIndexByWarpData(&gSaveBlock1Ptr->lastHealLocation); - struct HealLocation pkmCenterHealLocation = sHealLocationsPokemonCenter[healLocationId - 1]; - + u32 healLocationId = GetHealLocationIndexByWarpData(&gSaveBlock1Ptr->lastHealLocation); + struct HealLocation pkmCenterHealLocation; + + if (HasHealNPC(healLocationId)) + { + pkmCenterHealLocation = sHealLocationsPokemonCenter[healLocationId - 1]; warp->mapGroup = pkmCenterHealLocation.group; warp->mapNum = pkmCenterHealLocation.map; warp->warpId = WARP_ID_NONE; warp->x = pkmCenterHealLocation.x; warp->y = pkmCenterHealLocation.y; - SetWhiteoutRespawnHealerNPCAsLastTalked(healLocationId); -} -bool32 HasHealNPC(u32 healLocationId) -{ - if (healLocationId == HEAL_LOCATION_NONE || healLocationId >= HEAL_LOCATION_COUNT) - return FALSE; - return sWhiteoutRespawnHealerNpcLocalIds[healLocationId - 1] > 0; + gSpecialVar_LastTalked = sWhiteoutRespawnHealerNpcLocalIds[healLocationId - 1]; + } + else + { + *(warp) = gSaveBlock1Ptr->lastHealLocation; + } } diff --git a/src/overworld.c b/src/overworld.c index 30d025b8a93c..5b6470e7e144 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -693,7 +693,7 @@ static bool32 IsFRLGWhiteout(void) { if (!OW_FRLG_WHITEOUT) return FALSE; - return HasHealNPC(GetHealLocationIndexByMap(gSaveBlock1Ptr->lastHealLocation.mapGroup, gSaveBlock1Ptr->lastHealLocation.mapNum)); + return HasHealNPC(GetHealLocationIndexByWarpData(&gSaveBlock1Ptr->lastHealLocation)); } void SetWarpDestinationToLastHealLocation(void) From e4b539f441d9308855bb248d15e9435c35b8ced1 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:06:03 +0200 Subject: [PATCH 8/8] added suggested changes --- include/config/overworld.h | 2 +- include/heal_location.h | 2 +- src/data/heal_locations_pkm_center.h | 2 +- src/field_screen_effect.c | 6 +++--- src/heal_location.c | 29 ++++++++++++++-------------- src/overworld.c | 2 +- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/include/config/overworld.h b/include/config/overworld.h index 9d90df25a3f8..b4d22ae45a65 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -8,7 +8,7 @@ #define OW_POISON_DAMAGE GEN_LATEST // In Gen4, Pokémon no longer faint from Poison in the overworld. In Gen5+, they no longer take damage at all. #define OW_DOUBLE_APPROACH_WITH_ONE_MON FALSE // If enabled, you can be spotted by two trainers at the same time even if you only have one eligible Pokémon in your party. #define OW_HIDE_REPEAT_MAP_POPUP FALSE // If enabled, map popups will not appear if entering a map with the same Map Section Id as the last. -#define OW_FRLG_WHITEOUT FALSE // If enabled, shows an additional whiteout message and post whiteout event script with healing NPC +#define OW_FRLG_WHITEOUT FALSE // If enabled, shows an additional whiteout message and post whiteout event script with healing NPC. // These generational defines only make a distinction for Berries and the OW_PC_MOVE_ORDER #define GEN_6_XY GEN_6 diff --git a/include/heal_location.h b/include/heal_location.h index d956ae9e013e..8c4ebae96508 100644 --- a/include/heal_location.h +++ b/include/heal_location.h @@ -15,6 +15,6 @@ const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum); const struct HealLocation *GetHealLocation(u32 index); bool32 IsLastHealLocationPlayerHouse(); void SetWhiteoutRespawnWarpAndHealerNPC(struct WarpData * warp); -bool32 HasHealNPC(u32 healLocationId); +u32 GetHealNpcLocalId(u32 healLocationId); #endif // GUARD_HEAL_LOCATION_H diff --git a/src/data/heal_locations_pkm_center.h b/src/data/heal_locations_pkm_center.h index de47ccd26aed..58be0be05ed6 100644 --- a/src/data/heal_locations_pkm_center.h +++ b/src/data/heal_locations_pkm_center.h @@ -148,7 +148,7 @@ static const struct HealLocation sHealLocationsPokemonCenter[HEAL_LOCATION_COUNT // e.g. for OldaleTown_PokemonCenter1F/events.inc the following entry gets generated: // object_event 1, OBJ_EVENT_GFX_NURSE, 7, 2, 3, MOVEMENT_TYPE_FACE_DOWN, 0, 0, TRAINER_TYPE_NONE, 0, OldaleTown_PokemonCenter_1F_EventScript_Nurse, 0 // In this case the localId is 1. -static const u8 sWhiteoutRespawnHealerNpcLocalIds[HEAL_LOCATION_COUNT - 1] = +static const u8 sHealNpcLocalId[HEAL_LOCATION_COUNT - 1] = { [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = 1, [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = 1, diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index 08e16479a5e7..e39a0c6c1f78 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -1298,9 +1298,9 @@ static const u8 sWhiteoutTextColors[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHI #define tPrintState data[2] #define tIsPlayerHouse data[3] -static bool8 PrintWhiteOutRecoveryMessage(u8 taskId, const u8 *text, u8 x, u8 y) +static bool32 PrintWhiteOutRecoveryMessage(u8 taskId, const u8 *text, u32 x, u32 y) { - u8 windowId = gTasks[taskId].tWindowId; + u32 windowId = gTasks[taskId].tWindowId; switch (gTasks[taskId].tPrintState) { @@ -1332,7 +1332,7 @@ enum { static void Task_RushInjuredPokemonToCenter(u8 taskId) { - u8 windowId; + u32 windowId; switch (gTasks[taskId].tState) { diff --git a/src/heal_location.c b/src/heal_location.c index 8cbd1e1a2379..7193ea338e10 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -76,32 +76,31 @@ bool32 IsLastHealLocationPlayerHouse() return FALSE; } -bool32 HasHealNPC(u32 healLocationId) +u32 GetHealNpcLocalId(u32 healLocationId) { if (healLocationId == HEAL_LOCATION_NONE || healLocationId >= HEAL_LOCATION_COUNT) - return FALSE; + return 0; - return sWhiteoutRespawnHealerNpcLocalIds[healLocationId - 1] > 0 ? TRUE : FALSE; + return sHealNpcLocalId[healLocationId - 1]; } void SetWhiteoutRespawnWarpAndHealerNPC(struct WarpData *warp) { u32 healLocationId = GetHealLocationIndexByWarpData(&gSaveBlock1Ptr->lastHealLocation); + u32 healNpcLocalId = GetHealNpcLocalId(healLocationId); struct HealLocation pkmCenterHealLocation; - if (HasHealNPC(healLocationId)) - { - pkmCenterHealLocation = sHealLocationsPokemonCenter[healLocationId - 1]; - warp->mapGroup = pkmCenterHealLocation.group; - warp->mapNum = pkmCenterHealLocation.map; - warp->warpId = WARP_ID_NONE; - warp->x = pkmCenterHealLocation.x; - warp->y = pkmCenterHealLocation.y; - - gSpecialVar_LastTalked = sWhiteoutRespawnHealerNpcLocalIds[healLocationId - 1]; - } - else + if (!healNpcLocalId) { *(warp) = gSaveBlock1Ptr->lastHealLocation; + return; } + + pkmCenterHealLocation = sHealLocationsPokemonCenter[healLocationId - 1]; + warp->mapGroup = pkmCenterHealLocation.group; + warp->mapNum = pkmCenterHealLocation.map; + warp->warpId = WARP_ID_NONE; + warp->x = pkmCenterHealLocation.x; + warp->y = pkmCenterHealLocation.y; + gSpecialVar_LastTalked = healNpcLocalId; } diff --git a/src/overworld.c b/src/overworld.c index 5b6470e7e144..ee441a7f8143 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -693,7 +693,7 @@ static bool32 IsFRLGWhiteout(void) { if (!OW_FRLG_WHITEOUT) return FALSE; - return HasHealNPC(GetHealLocationIndexByWarpData(&gSaveBlock1Ptr->lastHealLocation)); + return GetHealNpcLocalId(GetHealLocationIndexByWarpData(&gSaveBlock1Ptr->lastHealLocation)) > 0; } void SetWarpDestinationToLastHealLocation(void)