From bb50006fc91604185ec127e859a3fb30920bc8c7 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 11 Oct 2024 15:17:18 -0400 Subject: [PATCH] Move heal locations data to their associated map.json (#673) --- .gitignore | 1 + data/maps/CeladonCity/map.json | 9 + .../CeladonCity_PokemonCenter_1F/scripts.inc | 2 +- data/maps/CeruleanCity/map.json | 9 + data/maps/CeruleanCity_Gym/scripts.inc | 2 +- .../CeruleanCity_PokemonCenter_1F/scripts.inc | 2 +- data/maps/CinnabarIsland/map.json | 9 + data/maps/CinnabarIsland_Gym/scripts.inc | 2 +- .../scripts.inc | 2 +- data/maps/FiveIsland/map.json | 9 + .../FiveIsland_PokemonCenter_1F/scripts.inc | 2 +- data/maps/FourIsland/map.json | 9 + .../FourIsland_PokemonCenter_1F/scripts.inc | 2 +- data/maps/FuchsiaCity/map.json | 9 + .../FuchsiaCity_PokemonCenter_1F/scripts.inc | 2 +- data/maps/IndigoPlateau_Exterior/map.json | 11 +- .../scripts.inc | 2 +- data/maps/LavenderTown/map.json | 9 + .../LavenderTown_PokemonCenter_1F/scripts.inc | 2 +- data/maps/OneIsland/map.json | 9 + .../OneIsland_PokemonCenter_1F/scripts.inc | 2 +- data/maps/PalletTown/map.json | 9 + .../PalletTown_PlayersHouse_2F/scripts.inc | 2 +- data/maps/PewterCity/map.json | 9 + .../PewterCity_PokemonCenter_1F/scripts.inc | 2 +- .../maps/PokemonLeague_HallOfFame/scripts.inc | 2 +- data/maps/Route10/map.json | 9 + .../maps/Route10_PokemonCenter_1F/scripts.inc | 2 +- data/maps/Route4/map.json | 9 + data/maps/Route4_PokemonCenter_1F/scripts.inc | 2 +- data/maps/SaffronCity/map.json | 9 + .../SaffronCity_PokemonCenter_1F/scripts.inc | 2 +- data/maps/SevenIsland/map.json | 9 + .../SevenIsland_PokemonCenter_1F/scripts.inc | 2 +- data/maps/SixIsland/map.json | 9 + .../SixIsland_PokemonCenter_1F/scripts.inc | 2 +- data/maps/ThreeIsland/map.json | 9 + .../ThreeIsland_PokemonCenter_1F/scripts.inc | 2 +- data/maps/TwoIsland/map.json | 9 + .../TwoIsland_PokemonCenter_1F/scripts.inc | 2 +- data/maps/VermilionCity/map.json | 9 + .../scripts.inc | 2 +- data/maps/ViridianCity/map.json | 9 + .../ViridianCity_PokemonCenter_1F/scripts.inc | 2 +- include/constants/heal_locations.h | 43 ++-- include/heal_location.h | 4 +- map_data_rules.mk | 5 + src/data/heal_locations.h | 71 ------ src/field_screen_effect.c | 6 +- src/heal_location.c | 27 ++- src/overworld.c | 6 +- src/post_battle_event_funcs.c | 2 +- src/region_map.c | 216 +++++++++--------- tools/mapjson/mapjson.cpp | 84 ++++++- 54 files changed, 446 insertions(+), 247 deletions(-) delete mode 100644 src/data/heal_locations.h diff --git a/.gitignore b/.gitignore index c5872bb896..5ed9cf3ffd 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ ld_script_ruby.txt ld_script_sapphire.txt sound/**/*.bin sound/songs/midi/*.s +src/data/heal_locations.h src/data/items.h src/data/wild_encounters.h src/data/region_map/region_map_entries.h diff --git a/data/maps/CeladonCity/map.json b/data/maps/CeladonCity/map.json index ec34003c3a..d044943686 100644 --- a/data/maps/CeladonCity/map.json +++ b/data/maps/CeladonCity/map.json @@ -400,5 +400,14 @@ "quantity": 1, "underfoot": false } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_CELADON_CITY", + "x": 48, + "y": 12, + "respawn_map": "MAP_CELADON_CITY_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/CeladonCity_PokemonCenter_1F/scripts.inc b/data/maps/CeladonCity_PokemonCenter_1F/scripts.inc index cebda4e357..14a76d95fc 100644 --- a/data/maps/CeladonCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/CeladonCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ CeladonCity_PokemonCenter_1F_MapScripts:: .byte 0 CeladonCity_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_CELADON_CITY + setrespawn HEAL_LOCATION_CELADON_CITY end CeladonCity_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/CeruleanCity/map.json b/data/maps/CeruleanCity/map.json index 5e534008d3..b94ba69a61 100644 --- a/data/maps/CeruleanCity/map.json +++ b/data/maps/CeruleanCity/map.json @@ -413,5 +413,14 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "CeruleanCity_BikeShop_EventScript_Bicycle" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_CERULEAN_CITY", + "x": 22, + "y": 20, + "respawn_map": "MAP_CERULEAN_CITY_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/CeruleanCity_Gym/scripts.inc b/data/maps/CeruleanCity_Gym/scripts.inc index 94190b0862..108f40a1ca 100644 --- a/data/maps/CeruleanCity_Gym/scripts.inc +++ b/data/maps/CeruleanCity_Gym/scripts.inc @@ -13,7 +13,7 @@ CeruleanCity_Gym_EventScript_MistyDefeated:: famechecker FAMECHECKER_MISTY, 1 setflag FLAG_DEFEATED_MISTY setflag FLAG_BADGE02_GET - setrespawn SPAWN_CERULEAN_CITY + setrespawn HEAL_LOCATION_CERULEAN_CITY set_gym_trainers 2 goto CeruleanCity_Gym_EventScript_GiveTM03 end diff --git a/data/maps/CeruleanCity_PokemonCenter_1F/scripts.inc b/data/maps/CeruleanCity_PokemonCenter_1F/scripts.inc index 43325e9299..9850fd25c5 100644 --- a/data/maps/CeruleanCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/CeruleanCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ CeruleanCity_PokemonCenter_1F_MapScripts:: .byte 0 CeruleanCity_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_CERULEAN_CITY + setrespawn HEAL_LOCATION_CERULEAN_CITY end CeruleanCity_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/CinnabarIsland/map.json b/data/maps/CinnabarIsland/map.json index 09e909d0c0..5c46e56381 100644 --- a/data/maps/CinnabarIsland/map.json +++ b/data/maps/CinnabarIsland/map.json @@ -164,5 +164,14 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "CinnabarIsland_EventScript_PokemonLabSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_CINNABAR_ISLAND", + "x": 14, + "y": 12, + "respawn_map": "MAP_CINNABAR_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/CinnabarIsland_Gym/scripts.inc b/data/maps/CinnabarIsland_Gym/scripts.inc index 38ec546f6f..b63ea18c72 100644 --- a/data/maps/CinnabarIsland_Gym/scripts.inc +++ b/data/maps/CinnabarIsland_Gym/scripts.inc @@ -64,7 +64,7 @@ CinnabarIsland_Gym_EventScript_DefeatedBlaine:: famechecker FAMECHECKER_BLAINE, 1 setflag FLAG_DEFEATED_BLAINE setflag FLAG_BADGE07_GET - setrespawn SPAWN_CINNABAR_ISLAND + setrespawn HEAL_LOCATION_CINNABAR_ISLAND setvar VAR_MAP_SCENE_CINNABAR_ISLAND, 1 clearflag FLAG_HIDE_CINNABAR_BILL set_gym_trainers 7 diff --git a/data/maps/CinnabarIsland_PokemonCenter_1F/scripts.inc b/data/maps/CinnabarIsland_PokemonCenter_1F/scripts.inc index 5f0b86d7ef..d345fe7b86 100644 --- a/data/maps/CinnabarIsland_PokemonCenter_1F/scripts.inc +++ b/data/maps/CinnabarIsland_PokemonCenter_1F/scripts.inc @@ -6,7 +6,7 @@ CinnabarIsland_PokemonCenter_1F_MapScripts:: .byte 0 CinnabarIsland_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_CINNABAR_ISLAND + setrespawn HEAL_LOCATION_CINNABAR_ISLAND end CinnabarIsland_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/FiveIsland/map.json b/data/maps/FiveIsland/map.json index 2da00d1c3a..638e35a9f4 100644 --- a/data/maps/FiveIsland/map.json +++ b/data/maps/FiveIsland/map.json @@ -103,5 +103,14 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "FiveIsland_EventScript_IslandSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_FIVE_ISLAND", + "x": 18, + "y": 7, + "respawn_map": "MAP_FIVE_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/FiveIsland_PokemonCenter_1F/scripts.inc b/data/maps/FiveIsland_PokemonCenter_1F/scripts.inc index ac8c5328e8..5c90166865 100644 --- a/data/maps/FiveIsland_PokemonCenter_1F/scripts.inc +++ b/data/maps/FiveIsland_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ FiveIsland_PokemonCenter_1F_MapScripts:: .byte 0 FiveIsland_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_FIVE_ISLAND + setrespawn HEAL_LOCATION_FIVE_ISLAND end FiveIsland_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/FourIsland/map.json b/data/maps/FourIsland/map.json index b347b7606f..51c0ba569e 100644 --- a/data/maps/FourIsland/map.json +++ b/data/maps/FourIsland/map.json @@ -280,5 +280,14 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "FourIsland_EventScript_LoreleisHouseSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_FOUR_ISLAND", + "x": 18, + "y": 21, + "respawn_map": "MAP_FOUR_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/FourIsland_PokemonCenter_1F/scripts.inc b/data/maps/FourIsland_PokemonCenter_1F/scripts.inc index 630ad96b3a..3b90884547 100644 --- a/data/maps/FourIsland_PokemonCenter_1F/scripts.inc +++ b/data/maps/FourIsland_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ FourIsland_PokemonCenter_1F_MapScripts:: .byte 0 FourIsland_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_FOUR_ISLAND + setrespawn HEAL_LOCATION_FOUR_ISLAND end FourIsland_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/FuchsiaCity/map.json b/data/maps/FuchsiaCity/map.json index 834806202c..e0c4306fc9 100644 --- a/data/maps/FuchsiaCity/map.json +++ b/data/maps/FuchsiaCity/map.json @@ -435,5 +435,14 @@ "quantity": 1, "underfoot": false } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_FUCHSIA_CITY", + "x": 25, + "y": 32, + "respawn_map": "MAP_FUCHSIA_CITY_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/FuchsiaCity_PokemonCenter_1F/scripts.inc b/data/maps/FuchsiaCity_PokemonCenter_1F/scripts.inc index 4aad5d24d1..7dcd895876 100644 --- a/data/maps/FuchsiaCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/FuchsiaCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ FuchsiaCity_PokemonCenter_1F_MapScripts:: .byte 0 FuchsiaCity_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_FUCHSIA_CITY + setrespawn HEAL_LOCATION_FUCHSIA_CITY end FuchsiaCity_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/IndigoPlateau_Exterior/map.json b/data/maps/IndigoPlateau_Exterior/map.json index 13d14c8258..345f71005e 100644 --- a/data/maps/IndigoPlateau_Exterior/map.json +++ b/data/maps/IndigoPlateau_Exterior/map.json @@ -60,5 +60,14 @@ } ], "coord_events": [], - "bg_events": [] + "bg_events": [], + "heal_locations": [ + { + "id": "HEAL_LOCATION_INDIGO_PLATEAU", + "x": 11, + "y": 7, + "respawn_map": "MAP_INDIGO_PLATEAU_POKEMON_CENTER_1F", + "respawn_npc": 2 + } + ] } diff --git a/data/maps/IndigoPlateau_PokemonCenter_1F/scripts.inc b/data/maps/IndigoPlateau_PokemonCenter_1F/scripts.inc index bb6d74b5f9..bc53f0fd66 100644 --- a/data/maps/IndigoPlateau_PokemonCenter_1F/scripts.inc +++ b/data/maps/IndigoPlateau_PokemonCenter_1F/scripts.inc @@ -6,7 +6,7 @@ IndigoPlateau_PokemonCenter_1F_MapScripts:: .byte 0 IndigoPlateau_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_INDIGO_PLATEAU + setrespawn HEAL_LOCATION_INDIGO_PLATEAU specialvar VAR_RESULT, IsNationalPokedexEnabled call_if_eq VAR_RESULT, TRUE, IndigoPlateau_PokemonCenter_1F_EventScript_CheckBlockDoor end diff --git a/data/maps/LavenderTown/map.json b/data/maps/LavenderTown/map.json index edbe04fb62..0c44605b3e 100644 --- a/data/maps/LavenderTown/map.json +++ b/data/maps/LavenderTown/map.json @@ -152,5 +152,14 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "LavenderTown_EventScript_VolunteerHouseSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_LAVENDER_TOWN", + "x": 6, + "y": 6, + "respawn_map": "MAP_LAVENDER_TOWN_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/LavenderTown_PokemonCenter_1F/scripts.inc b/data/maps/LavenderTown_PokemonCenter_1F/scripts.inc index a9ce2ec30f..2f4cb3cb57 100644 --- a/data/maps/LavenderTown_PokemonCenter_1F/scripts.inc +++ b/data/maps/LavenderTown_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ LavenderTown_PokemonCenter_1F_MapScripts:: .byte 0 LavenderTown_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_LAVENDER_TOWN + setrespawn HEAL_LOCATION_LAVENDER_TOWN end LavenderTown_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/OneIsland/map.json b/data/maps/OneIsland/map.json index f8ac5c92d2..b1c9a82096 100644 --- a/data/maps/OneIsland/map.json +++ b/data/maps/OneIsland/map.json @@ -117,5 +117,14 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "OneIsland_EventScript_PokemonNetCenterSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_ONE_ISLAND", + "x": 14, + "y": 6, + "respawn_map": "MAP_ONE_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/OneIsland_PokemonCenter_1F/scripts.inc b/data/maps/OneIsland_PokemonCenter_1F/scripts.inc index bb05cbec45..2ea70736be 100644 --- a/data/maps/OneIsland_PokemonCenter_1F/scripts.inc +++ b/data/maps/OneIsland_PokemonCenter_1F/scripts.inc @@ -28,7 +28,7 @@ OneIsland_PokemonCenter_1F_EventScript_SetNetworkMachineOn:: return OneIsland_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_ONE_ISLAND + setrespawn HEAL_LOCATION_ONE_ISLAND call_if_eq VAR_MAP_SCENE_ONE_ISLAND_POKEMON_CENTER_1F, 6, OneIsland_PokemonCenter_1F_EventScript_SetCelioQuestDone call_if_eq VAR_MAP_SCENE_ONE_ISLAND_POKEMON_CENTER_1F, 0, OneIsland_PokemonCenter_1F_EventScript_SetBillCelioFirstMeetingPos call_if_eq VAR_MAP_SCENE_ONE_ISLAND_POKEMON_CENTER_1F, 2, OneIsland_PokemonCenter_1F_EventScript_SetBillCelioReadyToLeavePos diff --git a/data/maps/PalletTown/map.json b/data/maps/PalletTown/map.json index 355411bc1b..c0a6ff39e2 100644 --- a/data/maps/PalletTown/map.json +++ b/data/maps/PalletTown/map.json @@ -162,5 +162,14 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "PalletTown_EventScript_TrainerTips" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_PALLET_TOWN", + "x": 6, + "y": 8, + "respawn_map": "MAP_PALLET_TOWN_PLAYERS_HOUSE_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/PalletTown_PlayersHouse_2F/scripts.inc b/data/maps/PalletTown_PlayersHouse_2F/scripts.inc index a26d8588ab..ac05113215 100644 --- a/data/maps/PalletTown_PlayersHouse_2F/scripts.inc +++ b/data/maps/PalletTown_PlayersHouse_2F/scripts.inc @@ -8,7 +8,7 @@ PalletTown_PlayersHouse_2F_OnTransition:: end PalletTown_PlayersHouse_2F_EventScript_SetRespawn:: - setrespawn SPAWN_PALLET_TOWN + setrespawn HEAL_LOCATION_PALLET_TOWN return PalletTown_PlayersHouse_2F_OnWarp:: diff --git a/data/maps/PewterCity/map.json b/data/maps/PewterCity/map.json index ddc3481ca0..bed0b16ca1 100644 --- a/data/maps/PewterCity/map.json +++ b/data/maps/PewterCity/map.json @@ -292,5 +292,14 @@ "quantity": 1, "underfoot": false } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_PEWTER_CITY", + "x": 17, + "y": 26, + "respawn_map": "MAP_PEWTER_CITY_POKEMON_CENTER_1F", + "respawn_npc": 3 + } ] } diff --git a/data/maps/PewterCity_PokemonCenter_1F/scripts.inc b/data/maps/PewterCity_PokemonCenter_1F/scripts.inc index 80b45defb3..a68ea93ba3 100644 --- a/data/maps/PewterCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/PewterCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ PewterCity_PokemonCenter_1F_MapScripts:: .byte 0 PewterCity_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_PEWTER_CITY + setrespawn HEAL_LOCATION_PEWTER_CITY end PewterCity_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/PokemonLeague_HallOfFame/scripts.inc b/data/maps/PokemonLeague_HallOfFame/scripts.inc index e8fae588d8..920a69430c 100644 --- a/data/maps/PokemonLeague_HallOfFame/scripts.inc +++ b/data/maps/PokemonLeague_HallOfFame/scripts.inc @@ -37,7 +37,7 @@ PokemonLeague_HallOfFame_EventScript_EnterRoom:: delay 40 setvar VAR_TEMP_1, 1 call EventScript_SetDefeatedEliteFourFlagsVars - setrespawn SPAWN_PALLET_TOWN + setrespawn HEAL_LOCATION_PALLET_TOWN fadescreenspeed FADE_TO_BLACK, 24 special EnterHallOfFame waitstate diff --git a/data/maps/Route10/map.json b/data/maps/Route10/map.json index 97d85418fa..dd4ad7950c 100644 --- a/data/maps/Route10/map.json +++ b/data/maps/Route10/map.json @@ -280,5 +280,14 @@ "quantity": 1, "underfoot": false } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_ROUTE10", + "x": 13, + "y": 21, + "respawn_map": "MAP_ROUTE10_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/Route10_PokemonCenter_1F/scripts.inc b/data/maps/Route10_PokemonCenter_1F/scripts.inc index 1624afbefd..f721e04dba 100644 --- a/data/maps/Route10_PokemonCenter_1F/scripts.inc +++ b/data/maps/Route10_PokemonCenter_1F/scripts.inc @@ -7,7 +7,7 @@ Route10_PokemonCenter_1F_MapScripts:: Route10_PokemonCenter_1F_OnTransition:: setworldmapflag FLAG_WORLD_MAP_ROUTE10_POKEMON_CENTER_1F - setrespawn SPAWN_ROUTE10 + setrespawn HEAL_LOCATION_ROUTE10 end Route10_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/Route4/map.json b/data/maps/Route4/map.json index 3273015c15..2165112f6f 100644 --- a/data/maps/Route4/map.json +++ b/data/maps/Route4/map.json @@ -190,5 +190,14 @@ "quantity": 1, "underfoot": false } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_ROUTE4", + "x": 12, + "y": 6, + "respawn_map": "MAP_ROUTE4_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/Route4_PokemonCenter_1F/scripts.inc b/data/maps/Route4_PokemonCenter_1F/scripts.inc index 32d2ff660f..d0098c0438 100644 --- a/data/maps/Route4_PokemonCenter_1F/scripts.inc +++ b/data/maps/Route4_PokemonCenter_1F/scripts.inc @@ -7,7 +7,7 @@ Route4_PokemonCenter_1F_MapScripts:: Route4_PokemonCenter_1F_OnTransition:: setworldmapflag FLAG_WORLD_MAP_ROUTE4_POKEMON_CENTER_1F - setrespawn SPAWN_ROUTE4 + setrespawn HEAL_LOCATION_ROUTE4 end Route4_PokemonCenter_1F_EventScript_Boy:: diff --git a/data/maps/SaffronCity/map.json b/data/maps/SaffronCity/map.json index 31eb5193c0..d335da517d 100644 --- a/data/maps/SaffronCity/map.json +++ b/data/maps/SaffronCity/map.json @@ -429,5 +429,14 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "SaffronCity_EventScript_TrainerFanClubSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_SAFFRON_CITY", + "x": 24, + "y": 39, + "respawn_map": "MAP_SAFFRON_CITY_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/SaffronCity_PokemonCenter_1F/scripts.inc b/data/maps/SaffronCity_PokemonCenter_1F/scripts.inc index 8b4390f0a0..43d1d94d38 100644 --- a/data/maps/SaffronCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/SaffronCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ SaffronCity_PokemonCenter_1F_MapScripts:: .byte 0 SaffronCity_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_SAFFRON_CITY + setrespawn HEAL_LOCATION_SAFFRON_CITY end SaffronCity_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/SevenIsland/map.json b/data/maps/SevenIsland/map.json index d775303af2..c1a54814d7 100644 --- a/data/maps/SevenIsland/map.json +++ b/data/maps/SevenIsland/map.json @@ -109,5 +109,14 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "SevenIsland_EventScript_IslandSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_SEVEN_ISLAND", + "x": 12, + "y": 4, + "respawn_map": "MAP_SEVEN_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/SevenIsland_PokemonCenter_1F/scripts.inc b/data/maps/SevenIsland_PokemonCenter_1F/scripts.inc index 7d2400d671..784e767871 100644 --- a/data/maps/SevenIsland_PokemonCenter_1F/scripts.inc +++ b/data/maps/SevenIsland_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ SevenIsland_PokemonCenter_1F_MapScripts:: .byte 0 SevenIsland_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_SEVEN_ISLAND + setrespawn HEAL_LOCATION_SEVEN_ISLAND end SevenIsland_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/SixIsland/map.json b/data/maps/SixIsland/map.json index e5ebdb14fa..e834c759b0 100644 --- a/data/maps/SixIsland/map.json +++ b/data/maps/SixIsland/map.json @@ -100,5 +100,14 @@ "quantity": 1, "underfoot": false } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_SIX_ISLAND", + "x": 11, + "y": 12, + "respawn_map": "MAP_SIX_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/SixIsland_PokemonCenter_1F/scripts.inc b/data/maps/SixIsland_PokemonCenter_1F/scripts.inc index 9efdc8681b..5053503b52 100644 --- a/data/maps/SixIsland_PokemonCenter_1F/scripts.inc +++ b/data/maps/SixIsland_PokemonCenter_1F/scripts.inc @@ -7,7 +7,7 @@ SixIsland_PokemonCenter_1F_MapScripts:: .byte 0 SixIsland_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_SIX_ISLAND + setrespawn HEAL_LOCATION_SIX_ISLAND call_if_eq VAR_MAP_SCENE_SIX_ISLAND_POKEMON_CENTER_1F, 0, SixIsland_PokemonCenter_1F_EventScript_ShowRival end diff --git a/data/maps/ThreeIsland/map.json b/data/maps/ThreeIsland/map.json index 69d7336058..6a975331d6 100644 --- a/data/maps/ThreeIsland/map.json +++ b/data/maps/ThreeIsland/map.json @@ -385,5 +385,14 @@ "quantity": 1, "underfoot": false } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_THREE_ISLAND", + "x": 14, + "y": 28, + "respawn_map": "MAP_THREE_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/ThreeIsland_PokemonCenter_1F/scripts.inc b/data/maps/ThreeIsland_PokemonCenter_1F/scripts.inc index e336cc9561..2ac23be737 100644 --- a/data/maps/ThreeIsland_PokemonCenter_1F/scripts.inc +++ b/data/maps/ThreeIsland_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ ThreeIsland_PokemonCenter_1F_MapScripts:: .byte 0 ThreeIsland_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_THREE_ISLAND + setrespawn HEAL_LOCATION_THREE_ISLAND end ThreeIsland_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/TwoIsland/map.json b/data/maps/TwoIsland/map.json index 41ae31f396..c866bddfcd 100644 --- a/data/maps/TwoIsland/map.json +++ b/data/maps/TwoIsland/map.json @@ -204,5 +204,14 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "TwoIsland_EventScript_FastCurrentSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_TWO_ISLAND", + "x": 21, + "y": 8, + "respawn_map": "MAP_TWO_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/TwoIsland_PokemonCenter_1F/scripts.inc b/data/maps/TwoIsland_PokemonCenter_1F/scripts.inc index 66ed1ecf5e..f0c4d17470 100644 --- a/data/maps/TwoIsland_PokemonCenter_1F/scripts.inc +++ b/data/maps/TwoIsland_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ TwoIsland_PokemonCenter_1F_MapScripts:: .byte 0 TwoIsland_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_TWO_ISLAND + setrespawn HEAL_LOCATION_TWO_ISLAND end TwoIsland_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/VermilionCity/map.json b/data/maps/VermilionCity/map.json index cda186af70..3c63a11f5f 100644 --- a/data/maps/VermilionCity/map.json +++ b/data/maps/VermilionCity/map.json @@ -300,5 +300,14 @@ "quantity": 1, "underfoot": false } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_VERMILION_CITY", + "x": 15, + "y": 7, + "respawn_map": "MAP_VERMILION_CITY_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/VermilionCity_PokemonCenter_1F/scripts.inc b/data/maps/VermilionCity_PokemonCenter_1F/scripts.inc index b0a892f09c..904b0a65d3 100644 --- a/data/maps/VermilionCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/VermilionCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ VermilionCity_PokemonCenter_1F_MapScripts:: .byte 0 VermilionCity_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_VERMILION_CITY + setrespawn HEAL_LOCATION_VERMILION_CITY end VermilionCity_PokemonCenter_1F_EventScript_Nurse:: diff --git a/data/maps/ViridianCity/map.json b/data/maps/ViridianCity/map.json index ccd10d4327..0633b37891 100644 --- a/data/maps/ViridianCity/map.json +++ b/data/maps/ViridianCity/map.json @@ -274,5 +274,14 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "ViridianCity_EventScript_GymDoor" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_VIRIDIAN_CITY", + "x": 26, + "y": 27, + "respawn_map": "MAP_VIRIDIAN_CITY_POKEMON_CENTER_1F", + "respawn_npc": 1 + } ] } diff --git a/data/maps/ViridianCity_PokemonCenter_1F/scripts.inc b/data/maps/ViridianCity_PokemonCenter_1F/scripts.inc index ce6b688205..40d3d77f15 100644 --- a/data/maps/ViridianCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/ViridianCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ ViridianCity_PokemonCenter_1F_MapScripts:: .byte 0 ViridianCity_PokemonCenter_1F_OnTransition:: - setrespawn SPAWN_VIRIDIAN_CITY + setrespawn HEAL_LOCATION_VIRIDIAN_CITY end ViridianCity_PokemonCenter_1F_EventScript_Nurse:: diff --git a/include/constants/heal_locations.h b/include/constants/heal_locations.h index 1c613d4643..f46647a8ca 100644 --- a/include/constants/heal_locations.h +++ b/include/constants/heal_locations.h @@ -1,25 +1,28 @@ #ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H #define GUARD_CONSTANTS_HEAL_LOCATIONS_H -#define SPAWN_PALLET_TOWN 1 -#define SPAWN_VIRIDIAN_CITY 2 -#define SPAWN_PEWTER_CITY 3 -#define SPAWN_CERULEAN_CITY 4 -#define SPAWN_LAVENDER_TOWN 5 -#define SPAWN_VERMILION_CITY 6 -#define SPAWN_CELADON_CITY 7 -#define SPAWN_FUCHSIA_CITY 8 -#define SPAWN_CINNABAR_ISLAND 9 -#define SPAWN_INDIGO_PLATEAU 10 -#define SPAWN_SAFFRON_CITY 11 -#define SPAWN_ROUTE4 12 -#define SPAWN_ROUTE10 13 -#define SPAWN_ONE_ISLAND 14 -#define SPAWN_TWO_ISLAND 15 -#define SPAWN_THREE_ISLAND 16 -#define SPAWN_FOUR_ISLAND 17 -#define SPAWN_FIVE_ISLAND 18 -#define SPAWN_SEVEN_ISLAND 19 -#define SPAWN_SIX_ISLAND 20 +enum { + HEAL_LOCATION_NONE, + HEAL_LOCATION_PALLET_TOWN, + HEAL_LOCATION_VIRIDIAN_CITY, + HEAL_LOCATION_PEWTER_CITY, + HEAL_LOCATION_CERULEAN_CITY, + HEAL_LOCATION_LAVENDER_TOWN, + HEAL_LOCATION_VERMILION_CITY, + HEAL_LOCATION_CELADON_CITY, + HEAL_LOCATION_FUCHSIA_CITY, + HEAL_LOCATION_CINNABAR_ISLAND, + HEAL_LOCATION_INDIGO_PLATEAU, + HEAL_LOCATION_SAFFRON_CITY, + HEAL_LOCATION_ROUTE4, + HEAL_LOCATION_ROUTE10, + HEAL_LOCATION_ONE_ISLAND, + HEAL_LOCATION_TWO_ISLAND, + HEAL_LOCATION_THREE_ISLAND, + HEAL_LOCATION_FOUR_ISLAND, + HEAL_LOCATION_FIVE_ISLAND, + HEAL_LOCATION_SEVEN_ISLAND, + HEAL_LOCATION_SIX_ISLAND, +}; #endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H diff --git a/include/heal_location.h b/include/heal_location.h index 2480d1723d..4c64def01b 100644 --- a/include/heal_location.h +++ b/include/heal_location.h @@ -5,8 +5,8 @@ struct HealLocation { - s8 group; - s8 map; + s8 mapGroup; + s8 mapNum; s16 x; s16 y; }; diff --git a/map_data_rules.mk b/map_data_rules.mk index d1eb6c8cb8..4fc4d51546 100644 --- a/map_data_rules.mk +++ b/map_data_rules.mk @@ -11,11 +11,13 @@ INCLUDECONSTS_OUTDIR := include/constants AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/map_groups.h AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/layouts.h +AUTO_GEN_TARGETS += $(DATA_SRC_SUBDIR)/heal_locations.h MAP_DIRS := $(dir $(wildcard $(MAPS_DIR)/*/map.json)) MAP_CONNECTIONS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/connections.inc,$(MAP_DIRS)) MAP_EVENTS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/events.inc,$(MAP_DIRS)) MAP_HEADERS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/header.inc,$(MAP_DIRS)) +MAP_JSONS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/map.json,$(MAP_DIRS)) $(DATA_ASM_BUILDDIR)/maps.o: $(DATA_ASM_SUBDIR)/maps.s $(LAYOUTS_DIR)/layouts.inc $(LAYOUTS_DIR)/layouts_table.inc $(MAPS_DIR)/headers.inc $(MAPS_DIR)/groups.inc $(MAPS_DIR)/connections.inc $(MAP_CONNECTIONS) $(MAP_HEADERS) $(PREPROC) $< charmap.txt | $(CPP) -I include -nostdinc -undef -Wno-unicode - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@ @@ -30,3 +32,6 @@ $(MAPS_OUTDIR)/connections.inc $(MAPS_OUTDIR)/groups.inc $(MAPS_OUTDIR)/events.i $(LAYOUTS_OUTDIR)/layouts.inc $(LAYOUTS_OUTDIR)/layouts_table.inc $(INCLUDECONSTS_OUTDIR)/layouts.h: $(LAYOUTS_DIR)/layouts.json $(MAPJSON) layouts firered $< $(LAYOUTS_OUTDIR) $(INCLUDECONSTS_OUTDIR) + +$(DATA_SRC_SUBDIR)/heal_locations.h: $(MAP_JSONS) + @$(MAPJSON) heal_locations firered $^ $(DATA_SRC_SUBDIR)/heal_locations.h diff --git a/src/data/heal_locations.h b/src/data/heal_locations.h deleted file mode 100644 index 7d6061a8b3..0000000000 --- a/src/data/heal_locations.h +++ /dev/null @@ -1,71 +0,0 @@ -static const struct HealLocation sSpawnPoints[] = -{ - [SPAWN_PALLET_TOWN - 1] = {MAP_GROUP(MAP_PALLET_TOWN), MAP_NUM(MAP_PALLET_TOWN), 6, 8}, - [SPAWN_VIRIDIAN_CITY - 1] = {MAP_GROUP(MAP_VIRIDIAN_CITY), MAP_NUM(MAP_VIRIDIAN_CITY), 26, 27}, - [SPAWN_PEWTER_CITY - 1] = {MAP_GROUP(MAP_PEWTER_CITY), MAP_NUM(MAP_PEWTER_CITY), 17, 26}, - [SPAWN_CERULEAN_CITY - 1] = {MAP_GROUP(MAP_CERULEAN_CITY), MAP_NUM(MAP_CERULEAN_CITY), 22, 20}, - [SPAWN_LAVENDER_TOWN - 1] = {MAP_GROUP(MAP_LAVENDER_TOWN), MAP_NUM(MAP_LAVENDER_TOWN), 6, 6}, - [SPAWN_VERMILION_CITY - 1] = {MAP_GROUP(MAP_VERMILION_CITY), MAP_NUM(MAP_VERMILION_CITY), 15, 7}, - [SPAWN_CELADON_CITY - 1] = {MAP_GROUP(MAP_CELADON_CITY), MAP_NUM(MAP_CELADON_CITY), 48, 12}, - [SPAWN_FUCHSIA_CITY - 1] = {MAP_GROUP(MAP_FUCHSIA_CITY), MAP_NUM(MAP_FUCHSIA_CITY), 25, 32}, - [SPAWN_CINNABAR_ISLAND - 1] = {MAP_GROUP(MAP_CINNABAR_ISLAND), MAP_NUM(MAP_CINNABAR_ISLAND), 14, 12}, - [SPAWN_INDIGO_PLATEAU - 1] = {MAP_GROUP(MAP_INDIGO_PLATEAU_EXTERIOR), MAP_NUM(MAP_INDIGO_PLATEAU_EXTERIOR), 11, 7}, - [SPAWN_SAFFRON_CITY - 1] = {MAP_GROUP(MAP_SAFFRON_CITY), MAP_NUM(MAP_SAFFRON_CITY), 24, 39}, - [SPAWN_ROUTE4 - 1] = {MAP_GROUP(MAP_ROUTE4), MAP_NUM(MAP_ROUTE4), 12, 6}, - [SPAWN_ROUTE10 - 1] = {MAP_GROUP(MAP_ROUTE10), MAP_NUM(MAP_ROUTE10), 13, 21}, - [SPAWN_ONE_ISLAND - 1] = {MAP_GROUP(MAP_ONE_ISLAND), MAP_NUM(MAP_ONE_ISLAND), 14, 6}, - [SPAWN_TWO_ISLAND - 1] = {MAP_GROUP(MAP_TWO_ISLAND), MAP_NUM(MAP_TWO_ISLAND), 21, 8}, - [SPAWN_THREE_ISLAND - 1] = {MAP_GROUP(MAP_THREE_ISLAND), MAP_NUM(MAP_THREE_ISLAND), 14, 28}, - [SPAWN_FOUR_ISLAND - 1] = {MAP_GROUP(MAP_FOUR_ISLAND), MAP_NUM(MAP_FOUR_ISLAND), 18, 21}, - [SPAWN_FIVE_ISLAND - 1] = {MAP_GROUP(MAP_FIVE_ISLAND), MAP_NUM(MAP_FIVE_ISLAND), 18, 7}, - [SPAWN_SEVEN_ISLAND - 1] = {MAP_GROUP(MAP_SEVEN_ISLAND), MAP_NUM(MAP_SEVEN_ISLAND), 12, 4}, - [SPAWN_SIX_ISLAND - 1] = {MAP_GROUP(MAP_SIX_ISLAND), MAP_NUM(MAP_SIX_ISLAND), 11, 12}, -}; - -static const u16 sWhiteoutRespawnHealCenterMapIdxs[][2] = -{ - [SPAWN_PALLET_TOWN - 1] = {MAP_GROUP(MAP_PALLET_TOWN_PLAYERS_HOUSE_1F), MAP_NUM(MAP_PALLET_TOWN_PLAYERS_HOUSE_1F)}, - [SPAWN_VIRIDIAN_CITY - 1] = {MAP_GROUP(MAP_VIRIDIAN_CITY_POKEMON_CENTER_1F), MAP_NUM(MAP_VIRIDIAN_CITY_POKEMON_CENTER_1F)}, - [SPAWN_PEWTER_CITY - 1] = {MAP_GROUP(MAP_PEWTER_CITY_POKEMON_CENTER_1F), MAP_NUM(MAP_PEWTER_CITY_POKEMON_CENTER_1F)}, - [SPAWN_CERULEAN_CITY - 1] = {MAP_GROUP(MAP_CERULEAN_CITY_POKEMON_CENTER_1F), MAP_NUM(MAP_CERULEAN_CITY_POKEMON_CENTER_1F)}, - [SPAWN_LAVENDER_TOWN - 1] = {MAP_GROUP(MAP_LAVENDER_TOWN_POKEMON_CENTER_1F), MAP_NUM(MAP_LAVENDER_TOWN_POKEMON_CENTER_1F)}, - [SPAWN_VERMILION_CITY - 1] = {MAP_GROUP(MAP_VERMILION_CITY_POKEMON_CENTER_1F), MAP_NUM(MAP_VERMILION_CITY_POKEMON_CENTER_1F)}, - [SPAWN_CELADON_CITY - 1] = {MAP_GROUP(MAP_CELADON_CITY_POKEMON_CENTER_1F), MAP_NUM(MAP_CELADON_CITY_POKEMON_CENTER_1F)}, - [SPAWN_FUCHSIA_CITY - 1] = {MAP_GROUP(MAP_FUCHSIA_CITY_POKEMON_CENTER_1F), MAP_NUM(MAP_FUCHSIA_CITY_POKEMON_CENTER_1F)}, - [SPAWN_CINNABAR_ISLAND - 1] = {MAP_GROUP(MAP_CINNABAR_ISLAND_POKEMON_CENTER_1F), MAP_NUM(MAP_CINNABAR_ISLAND_POKEMON_CENTER_1F)}, - [SPAWN_INDIGO_PLATEAU - 1] = {MAP_GROUP(MAP_INDIGO_PLATEAU_POKEMON_CENTER_1F), MAP_NUM(MAP_INDIGO_PLATEAU_POKEMON_CENTER_1F)}, - [SPAWN_SAFFRON_CITY - 1] = {MAP_GROUP(MAP_SAFFRON_CITY_POKEMON_CENTER_1F), MAP_NUM(MAP_SAFFRON_CITY_POKEMON_CENTER_1F)}, - [SPAWN_ROUTE4 - 1] = {MAP_GROUP(MAP_ROUTE4_POKEMON_CENTER_1F), MAP_NUM(MAP_ROUTE4_POKEMON_CENTER_1F)}, - [SPAWN_ROUTE10 - 1] = {MAP_GROUP(MAP_ROUTE10_POKEMON_CENTER_1F), MAP_NUM(MAP_ROUTE10_POKEMON_CENTER_1F)}, - [SPAWN_ONE_ISLAND - 1] = {MAP_GROUP(MAP_ONE_ISLAND_POKEMON_CENTER_1F), MAP_NUM(MAP_ONE_ISLAND_POKEMON_CENTER_1F)}, - [SPAWN_TWO_ISLAND - 1] = {MAP_GROUP(MAP_TWO_ISLAND_POKEMON_CENTER_1F), MAP_NUM(MAP_TWO_ISLAND_POKEMON_CENTER_1F)}, - [SPAWN_THREE_ISLAND - 1] = {MAP_GROUP(MAP_THREE_ISLAND_POKEMON_CENTER_1F), MAP_NUM(MAP_THREE_ISLAND_POKEMON_CENTER_1F)}, - [SPAWN_FOUR_ISLAND - 1] = {MAP_GROUP(MAP_FOUR_ISLAND_POKEMON_CENTER_1F), MAP_NUM(MAP_FOUR_ISLAND_POKEMON_CENTER_1F)}, - [SPAWN_FIVE_ISLAND - 1] = {MAP_GROUP(MAP_FIVE_ISLAND_POKEMON_CENTER_1F), MAP_NUM(MAP_FIVE_ISLAND_POKEMON_CENTER_1F)}, - [SPAWN_SEVEN_ISLAND - 1] = {MAP_GROUP(MAP_SEVEN_ISLAND_POKEMON_CENTER_1F), MAP_NUM(MAP_SEVEN_ISLAND_POKEMON_CENTER_1F)}, - [SPAWN_SIX_ISLAND - 1] = {MAP_GROUP(MAP_SIX_ISLAND_POKEMON_CENTER_1F), MAP_NUM(MAP_SIX_ISLAND_POKEMON_CENTER_1F)}, -}; - -static const u8 sWhiteoutRespawnHealerNpcIds[] = -{ - [SPAWN_PALLET_TOWN - 1] = 1, - [SPAWN_VIRIDIAN_CITY - 1] = 1, - [SPAWN_PEWTER_CITY - 1] = 3, - [SPAWN_CERULEAN_CITY - 1] = 1, - [SPAWN_LAVENDER_TOWN - 1] = 1, - [SPAWN_VERMILION_CITY - 1] = 1, - [SPAWN_CELADON_CITY - 1] = 1, - [SPAWN_FUCHSIA_CITY - 1] = 1, - [SPAWN_CINNABAR_ISLAND - 1] = 1, - [SPAWN_INDIGO_PLATEAU - 1] = 2, - [SPAWN_SAFFRON_CITY - 1] = 1, - [SPAWN_ROUTE4 - 1] = 1, - [SPAWN_ROUTE10 - 1] = 1, - [SPAWN_ONE_ISLAND - 1] = 1, - [SPAWN_TWO_ISLAND - 1] = 1, - [SPAWN_THREE_ISLAND - 1] = 1, - [SPAWN_FOUR_ISLAND - 1] = 1, - [SPAWN_FIVE_ISLAND - 1] = 1, - [SPAWN_SEVEN_ISLAND - 1] = 1, - [SPAWN_SIX_ISLAND - 1] = 1, -}; diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index f311e0f7a8..af00120974 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -400,9 +400,9 @@ static void Task_RushInjuredPokemonToCenter(u8 taskId) CopyWindowToVram(windowId, COPYWIN_FULL); // Scene changes if last heal location was the player's house - loc = GetHealLocation(SPAWN_PALLET_TOWN); - if (gSaveBlock1Ptr->lastHealLocation.mapGroup == loc->group - && gSaveBlock1Ptr->lastHealLocation.mapNum == loc->map + loc = GetHealLocation(HEAL_LOCATION_PALLET_TOWN); + if (gSaveBlock1Ptr->lastHealLocation.mapGroup == loc->mapGroup + && gSaveBlock1Ptr->lastHealLocation.mapNum == loc->mapNum && gSaveBlock1Ptr->lastHealLocation.warpId == WARP_ID_NONE && gSaveBlock1Ptr->lastHealLocation.x == loc->x && gSaveBlock1Ptr->lastHealLocation.y == loc->y) diff --git a/src/heal_location.c b/src/heal_location.c index 4aaa527594..1f7de48c0c 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -6,9 +6,9 @@ static void SetWhiteoutRespawnHealerNpcAsLastTalked(u32 healLocationIdx); -// Arrays described here because porymap will overrwrite the below data file +// Arrays described here because mapjson will overrwrite the below data file -// sSpawnPoints +// sHealLocations // This array defines the fly points for unlocked spawns. // sWhiteoutRespawnHealCenterMapIdxs @@ -30,32 +30,32 @@ static u32 GetHealLocationIndexFromMapGroupAndNum(u16 mapGroup, u16 mapNum) { u32 i; - for (i = 0; i < NELEMS(sSpawnPoints); i++) { - if (sSpawnPoints[i].group == mapGroup && sSpawnPoints[i].map == mapNum) + for (i = 0; i < ARRAY_COUNT(sHealLocations); i++) { + if (sHealLocations[i].mapGroup == mapGroup && sHealLocations[i].mapNum == mapNum) { return i + 1; } } - return 0; + return HEAL_LOCATION_NONE; } static const struct HealLocation * GetHealLocationPointerFromMapGroupAndNum(u16 mapGroup, u16 mapNum) { u32 i = GetHealLocationIndexFromMapGroupAndNum(mapGroup, mapNum); - if (i == 0) + if (i == HEAL_LOCATION_NONE) return NULL; - return &sSpawnPoints[i - 1]; + return &sHealLocations[i - 1]; } const struct HealLocation * GetHealLocation(u32 idx) { - if (idx == 0) + if (idx == HEAL_LOCATION_NONE) return NULL; - if (idx > NELEMS(sSpawnPoints)) + if (idx > ARRAY_COUNT(sHealLocations)) return NULL; - return &sSpawnPoints[idx - 1]; + return &sHealLocations[idx - 1]; } void SetWhiteoutRespawnWarpAndHealerNpc(struct WarpData * warp) @@ -76,9 +76,14 @@ void SetWhiteoutRespawnWarpAndHealerNpc(struct WarpData * warp) else { healLocationIdx = GetHealLocationIndexFromMapGroupAndNum(gSaveBlock1Ptr->lastHealLocation.mapGroup, gSaveBlock1Ptr->lastHealLocation.mapNum); +#ifdef BUGFIX + // Avoid out of bounds read + if (healLocationIdx == HEAL_LOCATION_NONE) + return; +#endif warp->mapGroup = sWhiteoutRespawnHealCenterMapIdxs[healLocationIdx - 1][0]; warp->mapNum = sWhiteoutRespawnHealCenterMapIdxs[healLocationIdx - 1][1]; - warp->warpId = 0xFF; + warp->warpId = WARP_ID_NONE; if (sWhiteoutRespawnHealCenterMapIdxs[healLocationIdx - 1][0] == MAP_GROUP(MAP_PALLET_TOWN_PLAYERS_HOUSE_1F) && sWhiteoutRespawnHealCenterMapIdxs[healLocationIdx - 1][1] == MAP_NUM(MAP_PALLET_TOWN_PLAYERS_HOUSE_1F)) { diff --git a/src/overworld.c b/src/overworld.c index 58df331f4f..830146cfe0 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -611,7 +611,7 @@ void SetWarpDestinationToHealLocation(u8 healLocationId) { const struct HealLocation *warp = GetHealLocation(healLocationId); if (warp) - SetWarpDestination(warp->group, warp->map, -1, warp->x, warp->y); + SetWarpDestination(warp->mapGroup, warp->mapNum, -1, warp->x, warp->y); } void SetWarpDestinationToLastHealLocation(void) @@ -628,7 +628,7 @@ void SetLastHealLocationWarp(u8 healLocationId) { const struct HealLocation *healLocation = GetHealLocation(healLocationId); if (healLocation) - SetWarpData(&gSaveBlock1Ptr->lastHealLocation, healLocation->group, healLocation->map, -1, healLocation->x, healLocation->y); + SetWarpData(&gSaveBlock1Ptr->lastHealLocation, healLocation->mapGroup, healLocation->mapNum, -1, healLocation->x, healLocation->y); } void UpdateEscapeWarp(s16 x, s16 y) @@ -690,7 +690,7 @@ void SetContinueGameWarpToHealLocation(u8 healLocationId) { const struct HealLocation *warp = GetHealLocation(healLocationId); if (warp) - SetWarpData(&gSaveBlock1Ptr->continueGameWarp, warp->group, warp->map, -1, warp->x, warp->y); + SetWarpData(&gSaveBlock1Ptr->continueGameWarp, warp->mapGroup, warp->mapNum, -1, warp->x, warp->y); } void SetContinueGameWarpToDynamicWarp(int unused) diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c index ae61d68a6d..cab6d3afe2 100644 --- a/src/post_battle_event_funcs.c +++ b/src/post_battle_event_funcs.c @@ -28,7 +28,7 @@ bool8 EnterHallOfFame(void) SetGameStat(GAME_STAT_FIRST_HOF_PLAY_TIME, (gSaveBlock2Ptr->playTimeHours << 16) | (gSaveBlock2Ptr->playTimeMinutes << 8) | gSaveBlock2Ptr->playTimeSeconds); } SetContinueGameWarpStatus(); - SetContinueGameWarpToHealLocation(SPAWN_PALLET_TOWN); + SetContinueGameWarpToHealLocation(HEAL_LOCATION_PALLET_TOWN); gaveAtLeastOneRibbon = FALSE; for (i = 0, r7 = &ribbonState; i < PARTY_SIZE; i++) { diff --git a/src/region_map.c b/src/region_map.c index c1257e5648..2703278752 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -826,114 +826,114 @@ static const u8 sTextColors[] = {TEXT_DYNAMIC_COLOR_6, TEXT_COLOR_WHITE, TEXT_CO #include "data/region_map/region_map_layout_sevii_67.h" static const u8 sMapFlyDestinations[][3] = { - [MAPSEC_PALLET_TOWN - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), SPAWN_PALLET_TOWN}, - [MAPSEC_VIRIDIAN_CITY - MAPSECS_KANTO] = {MAP(MAP_VIRIDIAN_CITY), SPAWN_VIRIDIAN_CITY}, - [MAPSEC_PEWTER_CITY - MAPSECS_KANTO] = {MAP(MAP_PEWTER_CITY), SPAWN_PEWTER_CITY}, - [MAPSEC_CERULEAN_CITY - MAPSECS_KANTO] = {MAP(MAP_CERULEAN_CITY), SPAWN_CERULEAN_CITY}, - [MAPSEC_LAVENDER_TOWN - MAPSECS_KANTO] = {MAP(MAP_LAVENDER_TOWN), SPAWN_LAVENDER_TOWN}, - [MAPSEC_VERMILION_CITY - MAPSECS_KANTO] = {MAP(MAP_VERMILION_CITY), SPAWN_VERMILION_CITY}, - [MAPSEC_CELADON_CITY - MAPSECS_KANTO] = {MAP(MAP_CELADON_CITY), SPAWN_CELADON_CITY}, - [MAPSEC_FUCHSIA_CITY - MAPSECS_KANTO] = {MAP(MAP_FUCHSIA_CITY), SPAWN_FUCHSIA_CITY}, - [MAPSEC_CINNABAR_ISLAND - MAPSECS_KANTO] = {MAP(MAP_CINNABAR_ISLAND), SPAWN_CINNABAR_ISLAND}, - [MAPSEC_INDIGO_PLATEAU - MAPSECS_KANTO] = {MAP(MAP_INDIGO_PLATEAU_EXTERIOR), SPAWN_INDIGO_PLATEAU}, - [MAPSEC_SAFFRON_CITY - MAPSECS_KANTO] = {MAP(MAP_SAFFRON_CITY), SPAWN_SAFFRON_CITY}, - [MAPSEC_ROUTE_4_POKECENTER - MAPSECS_KANTO] = {MAP(MAP_ROUTE4), SPAWN_ROUTE4}, - [MAPSEC_ROUTE_10_POKECENTER - MAPSECS_KANTO] = {MAP(MAP_ROUTE10), SPAWN_ROUTE10}, - [MAPSEC_ROUTE_1 - MAPSECS_KANTO] = {MAP(MAP_ROUTE1), 0}, - [MAPSEC_ROUTE_2 - MAPSECS_KANTO] = {MAP(MAP_ROUTE2), 0}, - [MAPSEC_ROUTE_3 - MAPSECS_KANTO] = {MAP(MAP_ROUTE3), 0}, - [MAPSEC_ROUTE_4 - MAPSECS_KANTO] = {MAP(MAP_ROUTE4), 0}, - [MAPSEC_ROUTE_5 - MAPSECS_KANTO] = {MAP(MAP_ROUTE5), 0}, - [MAPSEC_ROUTE_6 - MAPSECS_KANTO] = {MAP(MAP_ROUTE6), 0}, - [MAPSEC_ROUTE_7 - MAPSECS_KANTO] = {MAP(MAP_ROUTE7), 0}, - [MAPSEC_ROUTE_8 - MAPSECS_KANTO] = {MAP(MAP_ROUTE8), 0}, - [MAPSEC_ROUTE_9 - MAPSECS_KANTO] = {MAP(MAP_ROUTE9), 0}, - [MAPSEC_ROUTE_10 - MAPSECS_KANTO] = {MAP(MAP_ROUTE10), 0}, - [MAPSEC_ROUTE_11 - MAPSECS_KANTO] = {MAP(MAP_ROUTE11), 0}, - [MAPSEC_ROUTE_12 - MAPSECS_KANTO] = {MAP(MAP_ROUTE12), 0}, - [MAPSEC_ROUTE_13 - MAPSECS_KANTO] = {MAP(MAP_ROUTE13), 0}, - [MAPSEC_ROUTE_14 - MAPSECS_KANTO] = {MAP(MAP_ROUTE14), 0}, - [MAPSEC_ROUTE_15 - MAPSECS_KANTO] = {MAP(MAP_ROUTE15), 0}, - [MAPSEC_ROUTE_16 - MAPSECS_KANTO] = {MAP(MAP_ROUTE16), 0}, - [MAPSEC_ROUTE_17 - MAPSECS_KANTO] = {MAP(MAP_ROUTE17), 0}, - [MAPSEC_ROUTE_18 - MAPSECS_KANTO] = {MAP(MAP_ROUTE18), 0}, - [MAPSEC_ROUTE_19 - MAPSECS_KANTO] = {MAP(MAP_ROUTE19), 0}, - [MAPSEC_ROUTE_20 - MAPSECS_KANTO] = {MAP(MAP_ROUTE20), 0}, - [MAPSEC_ROUTE_21 - MAPSECS_KANTO] = {MAP(MAP_ROUTE21_NORTH), 0}, - [MAPSEC_ROUTE_22 - MAPSECS_KANTO] = {MAP(MAP_ROUTE22), 0}, - [MAPSEC_ROUTE_23 - MAPSECS_KANTO] = {MAP(MAP_ROUTE23), 0}, - [MAPSEC_ROUTE_24 - MAPSECS_KANTO] = {MAP(MAP_ROUTE24), 0}, - [MAPSEC_ROUTE_25 - MAPSECS_KANTO] = {MAP(MAP_ROUTE25), 0}, - [MAPSEC_VIRIDIAN_FOREST - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_MT_MOON - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_S_S_ANNE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_UNDERGROUND_PATH - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_UNDERGROUND_PATH_2 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_DIGLETTS_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_KANTO_VICTORY_ROAD - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_ROCKET_HIDEOUT - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_SILPH_CO - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_POKEMON_MANSION - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_KANTO_SAFARI_ZONE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_POKEMON_LEAGUE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_ROCK_TUNNEL - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_SEAFOAM_ISLANDS - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_POKEMON_TOWER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_CERULEAN_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_POWER_PLANT - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_ONE_ISLAND - MAPSECS_KANTO] = {MAP(MAP_ONE_ISLAND), SPAWN_ONE_ISLAND}, - [MAPSEC_TWO_ISLAND - MAPSECS_KANTO] = {MAP(MAP_TWO_ISLAND), SPAWN_TWO_ISLAND}, - [MAPSEC_THREE_ISLAND - MAPSECS_KANTO] = {MAP(MAP_THREE_ISLAND), SPAWN_THREE_ISLAND}, - [MAPSEC_FOUR_ISLAND - MAPSECS_KANTO] = {MAP(MAP_FOUR_ISLAND), SPAWN_FOUR_ISLAND}, - [MAPSEC_FIVE_ISLAND - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND), SPAWN_FIVE_ISLAND}, - [MAPSEC_SEVEN_ISLAND - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND), SPAWN_SEVEN_ISLAND}, - [MAPSEC_SIX_ISLAND - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND), SPAWN_SIX_ISLAND}, - [MAPSEC_KINDLE_ROAD - MAPSECS_KANTO] = {MAP(MAP_ONE_ISLAND_KINDLE_ROAD), 0}, - [MAPSEC_TREASURE_BEACH - MAPSECS_KANTO] = {MAP(MAP_ONE_ISLAND_TREASURE_BEACH), 0}, - [MAPSEC_CAPE_BRINK - MAPSECS_KANTO] = {MAP(MAP_TWO_ISLAND_CAPE_BRINK), 0}, - [MAPSEC_BOND_BRIDGE - MAPSECS_KANTO] = {MAP(MAP_THREE_ISLAND_BOND_BRIDGE), 0}, - [MAPSEC_THREE_ISLE_PORT - MAPSECS_KANTO] = {MAP(MAP_THREE_ISLAND_PORT), 0}, - [MAPSEC_SEVII_ISLE_6 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_6), 0}, - [MAPSEC_SEVII_ISLE_7 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_7), 0}, - [MAPSEC_SEVII_ISLE_8 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_8), 0}, - [MAPSEC_SEVII_ISLE_9 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_9), 0}, - [MAPSEC_RESORT_GORGEOUS - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_RESORT_GORGEOUS), 0}, - [MAPSEC_WATER_LABYRINTH - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_WATER_LABYRINTH), 0}, - [MAPSEC_FIVE_ISLE_MEADOW - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_MEADOW), 0}, - [MAPSEC_MEMORIAL_PILLAR - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_MEMORIAL_PILLAR), 0}, - [MAPSEC_OUTCAST_ISLAND - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_OUTCAST_ISLAND), 0}, - [MAPSEC_GREEN_PATH - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_GREEN_PATH), 0}, - [MAPSEC_WATER_PATH - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_WATER_PATH), 0}, - [MAPSEC_RUIN_VALLEY - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_RUIN_VALLEY), 0}, - [MAPSEC_TRAINER_TOWER - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_TRAINER_TOWER), 0}, - [MAPSEC_CANYON_ENTRANCE - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_SEVAULT_CANYON_ENTRANCE), 0}, - [MAPSEC_SEVAULT_CANYON - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_SEVAULT_CANYON), 0}, - [MAPSEC_TANOBY_RUINS - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_TANOBY_RUINS), 0}, - [MAPSEC_SEVII_ISLE_22 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_SEVII_ISLE_23 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_SEVII_ISLE_24 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_NAVEL_ROCK - MAPSECS_KANTO] = {MAP(MAP_NAVEL_ROCK_EXTERIOR), 0}, - [MAPSEC_MT_EMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_BERRY_FOREST - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_ICEFALL_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_ROCKET_WAREHOUSE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_TRAINER_TOWER_2 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_DOTTED_HOLE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_LOST_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_PATTERN_BUSH - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_ALTERING_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_TANOBY_CHAMBERS - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_THREE_ISLE_PATH - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_TANOBY_KEY - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_BIRTH_ISLAND - MAPSECS_KANTO] = {MAP(MAP_BIRTH_ISLAND_EXTERIOR), 0}, - [MAPSEC_MONEAN_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_LIPTOO_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_WEEPTH_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_DILFORD_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_SCUFIB_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_RIXY_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_VIAPOIS_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, - [MAPSEC_EMBER_SPA - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), 0}, + [MAPSEC_PALLET_TOWN - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_PALLET_TOWN}, + [MAPSEC_VIRIDIAN_CITY - MAPSECS_KANTO] = {MAP(MAP_VIRIDIAN_CITY), HEAL_LOCATION_VIRIDIAN_CITY}, + [MAPSEC_PEWTER_CITY - MAPSECS_KANTO] = {MAP(MAP_PEWTER_CITY), HEAL_LOCATION_PEWTER_CITY}, + [MAPSEC_CERULEAN_CITY - MAPSECS_KANTO] = {MAP(MAP_CERULEAN_CITY), HEAL_LOCATION_CERULEAN_CITY}, + [MAPSEC_LAVENDER_TOWN - MAPSECS_KANTO] = {MAP(MAP_LAVENDER_TOWN), HEAL_LOCATION_LAVENDER_TOWN}, + [MAPSEC_VERMILION_CITY - MAPSECS_KANTO] = {MAP(MAP_VERMILION_CITY), HEAL_LOCATION_VERMILION_CITY}, + [MAPSEC_CELADON_CITY - MAPSECS_KANTO] = {MAP(MAP_CELADON_CITY), HEAL_LOCATION_CELADON_CITY}, + [MAPSEC_FUCHSIA_CITY - MAPSECS_KANTO] = {MAP(MAP_FUCHSIA_CITY), HEAL_LOCATION_FUCHSIA_CITY}, + [MAPSEC_CINNABAR_ISLAND - MAPSECS_KANTO] = {MAP(MAP_CINNABAR_ISLAND), HEAL_LOCATION_CINNABAR_ISLAND}, + [MAPSEC_INDIGO_PLATEAU - MAPSECS_KANTO] = {MAP(MAP_INDIGO_PLATEAU_EXTERIOR), HEAL_LOCATION_INDIGO_PLATEAU}, + [MAPSEC_SAFFRON_CITY - MAPSECS_KANTO] = {MAP(MAP_SAFFRON_CITY), HEAL_LOCATION_SAFFRON_CITY}, + [MAPSEC_ROUTE_4_POKECENTER - MAPSECS_KANTO] = {MAP(MAP_ROUTE4), HEAL_LOCATION_ROUTE4}, + [MAPSEC_ROUTE_10_POKECENTER - MAPSECS_KANTO] = {MAP(MAP_ROUTE10), HEAL_LOCATION_ROUTE10}, + [MAPSEC_ROUTE_1 - MAPSECS_KANTO] = {MAP(MAP_ROUTE1), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_2 - MAPSECS_KANTO] = {MAP(MAP_ROUTE2), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_3 - MAPSECS_KANTO] = {MAP(MAP_ROUTE3), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_4 - MAPSECS_KANTO] = {MAP(MAP_ROUTE4), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_5 - MAPSECS_KANTO] = {MAP(MAP_ROUTE5), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_6 - MAPSECS_KANTO] = {MAP(MAP_ROUTE6), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_7 - MAPSECS_KANTO] = {MAP(MAP_ROUTE7), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_8 - MAPSECS_KANTO] = {MAP(MAP_ROUTE8), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_9 - MAPSECS_KANTO] = {MAP(MAP_ROUTE9), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_10 - MAPSECS_KANTO] = {MAP(MAP_ROUTE10), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_11 - MAPSECS_KANTO] = {MAP(MAP_ROUTE11), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_12 - MAPSECS_KANTO] = {MAP(MAP_ROUTE12), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_13 - MAPSECS_KANTO] = {MAP(MAP_ROUTE13), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_14 - MAPSECS_KANTO] = {MAP(MAP_ROUTE14), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_15 - MAPSECS_KANTO] = {MAP(MAP_ROUTE15), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_16 - MAPSECS_KANTO] = {MAP(MAP_ROUTE16), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_17 - MAPSECS_KANTO] = {MAP(MAP_ROUTE17), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_18 - MAPSECS_KANTO] = {MAP(MAP_ROUTE18), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_19 - MAPSECS_KANTO] = {MAP(MAP_ROUTE19), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_20 - MAPSECS_KANTO] = {MAP(MAP_ROUTE20), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_21 - MAPSECS_KANTO] = {MAP(MAP_ROUTE21_NORTH), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_22 - MAPSECS_KANTO] = {MAP(MAP_ROUTE22), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_23 - MAPSECS_KANTO] = {MAP(MAP_ROUTE23), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_24 - MAPSECS_KANTO] = {MAP(MAP_ROUTE24), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_25 - MAPSECS_KANTO] = {MAP(MAP_ROUTE25), HEAL_LOCATION_NONE}, + [MAPSEC_VIRIDIAN_FOREST - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_MT_MOON - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_S_S_ANNE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_UNDERGROUND_PATH - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_UNDERGROUND_PATH_2 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_DIGLETTS_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_KANTO_VICTORY_ROAD - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ROCKET_HIDEOUT - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_SILPH_CO - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_POKEMON_MANSION - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_KANTO_SAFARI_ZONE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_POKEMON_LEAGUE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ROCK_TUNNEL - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_SEAFOAM_ISLANDS - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_POKEMON_TOWER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_CERULEAN_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_POWER_PLANT - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ONE_ISLAND - MAPSECS_KANTO] = {MAP(MAP_ONE_ISLAND), HEAL_LOCATION_ONE_ISLAND}, + [MAPSEC_TWO_ISLAND - MAPSECS_KANTO] = {MAP(MAP_TWO_ISLAND), HEAL_LOCATION_TWO_ISLAND}, + [MAPSEC_THREE_ISLAND - MAPSECS_KANTO] = {MAP(MAP_THREE_ISLAND), HEAL_LOCATION_THREE_ISLAND}, + [MAPSEC_FOUR_ISLAND - MAPSECS_KANTO] = {MAP(MAP_FOUR_ISLAND), HEAL_LOCATION_FOUR_ISLAND}, + [MAPSEC_FIVE_ISLAND - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND), HEAL_LOCATION_FIVE_ISLAND}, + [MAPSEC_SEVEN_ISLAND - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND), HEAL_LOCATION_SEVEN_ISLAND}, + [MAPSEC_SIX_ISLAND - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND), HEAL_LOCATION_SIX_ISLAND}, + [MAPSEC_KINDLE_ROAD - MAPSECS_KANTO] = {MAP(MAP_ONE_ISLAND_KINDLE_ROAD), HEAL_LOCATION_NONE}, + [MAPSEC_TREASURE_BEACH - MAPSECS_KANTO] = {MAP(MAP_ONE_ISLAND_TREASURE_BEACH), HEAL_LOCATION_NONE}, + [MAPSEC_CAPE_BRINK - MAPSECS_KANTO] = {MAP(MAP_TWO_ISLAND_CAPE_BRINK), HEAL_LOCATION_NONE}, + [MAPSEC_BOND_BRIDGE - MAPSECS_KANTO] = {MAP(MAP_THREE_ISLAND_BOND_BRIDGE), HEAL_LOCATION_NONE}, + [MAPSEC_THREE_ISLE_PORT - MAPSECS_KANTO] = {MAP(MAP_THREE_ISLAND_PORT), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_6 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_6), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_7 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_7), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_8 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_8), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_9 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_9), HEAL_LOCATION_NONE}, + [MAPSEC_RESORT_GORGEOUS - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_RESORT_GORGEOUS), HEAL_LOCATION_NONE}, + [MAPSEC_WATER_LABYRINTH - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_WATER_LABYRINTH), HEAL_LOCATION_NONE}, + [MAPSEC_FIVE_ISLE_MEADOW - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_MEADOW), HEAL_LOCATION_NONE}, + [MAPSEC_MEMORIAL_PILLAR - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_MEMORIAL_PILLAR), HEAL_LOCATION_NONE}, + [MAPSEC_OUTCAST_ISLAND - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_OUTCAST_ISLAND), HEAL_LOCATION_NONE}, + [MAPSEC_GREEN_PATH - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_GREEN_PATH), HEAL_LOCATION_NONE}, + [MAPSEC_WATER_PATH - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_WATER_PATH), HEAL_LOCATION_NONE}, + [MAPSEC_RUIN_VALLEY - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_RUIN_VALLEY), HEAL_LOCATION_NONE}, + [MAPSEC_TRAINER_TOWER - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_TRAINER_TOWER), HEAL_LOCATION_NONE}, + [MAPSEC_CANYON_ENTRANCE - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_SEVAULT_CANYON_ENTRANCE), HEAL_LOCATION_NONE}, + [MAPSEC_SEVAULT_CANYON - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_SEVAULT_CANYON), HEAL_LOCATION_NONE}, + [MAPSEC_TANOBY_RUINS - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_TANOBY_RUINS), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_22 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_23 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_24 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_NAVEL_ROCK - MAPSECS_KANTO] = {MAP(MAP_NAVEL_ROCK_EXTERIOR), HEAL_LOCATION_NONE}, + [MAPSEC_MT_EMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_BERRY_FOREST - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ICEFALL_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ROCKET_WAREHOUSE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_TRAINER_TOWER_2 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_DOTTED_HOLE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_LOST_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_PATTERN_BUSH - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ALTERING_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_TANOBY_CHAMBERS - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_THREE_ISLE_PATH - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_TANOBY_KEY - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_BIRTH_ISLAND - MAPSECS_KANTO] = {MAP(MAP_BIRTH_ISLAND_EXTERIOR), HEAL_LOCATION_NONE}, + [MAPSEC_MONEAN_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_LIPTOO_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_WEEPTH_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_DILFORD_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_SCUFIB_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_RIXY_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_VIAPOIS_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_EMBER_SPA - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, }; static void RegionMap_DarkenPalette(u16 *pal, u16 size, u16 tint) diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp index 94328b4857..3a427f98c2 100644 --- a/tools/mapjson/mapjson.cpp +++ b/tools/mapjson/mapjson.cpp @@ -371,6 +371,69 @@ void process_map(string map_filepath, string layouts_filepath, string output_dir write_text_file(out_dir + "connections.inc", connections_text); } +void process_heal_locations(const vector &map_filepaths, string output_file) { + ostringstream heal_locations_text; + ostringstream respawn_maps_text; + ostringstream respawn_npcs_text; + + // Get heal location data from each map + for (const string &filepath : map_filepaths) { + string err; + string map_json_text = read_text_file(filepath); + Json map_data = Json::parse(map_json_text, err); + if (map_data == Json()) + FATAL_ERROR("Failed to read '%s' while generating '%s': %s\n", filepath.c_str(), output_file.c_str(), err.c_str()); + + // Skip if no heal locations present + if (map_data.object_items().find("heal_locations") == map_data.object_items().end() || map_data["heal_locations"].array_items().size() <= 0) + continue; + + string map_id = json_to_string(map_data, "id"); + for (auto &heal_location : map_data["heal_locations"].array_items()) { + // Each array is indexed with the heal location's ID, e.g. '[HEAL_LOCATION_NAME - 1] = ' + string index_text = "\t[" + json_to_string(heal_location, "id") + " - 1] ="; + + // Add element to main heal locations array + heal_locations_text << index_text << "\n\t{\n" + << "\t\t.mapGroup = MAP_GROUP(" << map_id << "),\n" + << "\t\t.mapNum = MAP_NUM(" << map_id << "),\n" + << "\t\t.x = " << json_to_string(heal_location, "x") << ",\n" + << "\t\t.y = " << json_to_string(heal_location, "y") << ",\n" + << "\t},\n"; + + // Add element to respawn map array (if field is present) + if (heal_location.object_items().find("respawn_map") != heal_location.object_items().end()) { + string respawn_map_id = json_to_string(heal_location, "respawn_map"); + respawn_maps_text << index_text << " {" + << "MAP_GROUP(" << respawn_map_id << "), " + << "MAP_NUM(" << respawn_map_id << ")" + << "},\n"; + } + + // Add element to respawn NPC array (if field is present) + if (heal_location.object_items().find("respawn_npc") != heal_location.object_items().end()) { + respawn_npcs_text << index_text << " " << json_to_string(heal_location, "respawn_npc") << ",\n"; + } + } + } + + ostringstream text; + text << "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from data/maps/*/map.json\n//\n\n"; + + string arr_body = heal_locations_text.str(); + text << "static const struct HealLocation sHealLocations[] =\n{\n" << arr_body << "};\n\n"; + + arr_body = respawn_maps_text.str(); + if (!arr_body.empty()) + text << "static const u16 sWhiteoutRespawnHealCenterMapIdxs[][2] =\n{\n" << arr_body << "};\n\n"; + + arr_body = respawn_npcs_text.str(); + if (!arr_body.empty()) + text << "static const u8 sWhiteoutRespawnHealerNpcIds[] =\n{\n" << arr_body << "};\n\n"; + + write_text_file(output_file, text.str()); +} + string generate_groups_text(Json groups_data) { ostringstream text; @@ -627,9 +690,6 @@ int main(int argc, char *argv[]) { char *mode_arg = argv[1]; string mode(mode_arg); - if (mode != "layouts" && mode != "map" && mode != "groups") - FATAL_ERROR("ERROR: must be 'layouts', 'map', or 'groups'.\n"); - if (mode == "map") { if (argc != 6) FATAL_ERROR("USAGE: mapjson map \n"); @@ -663,8 +723,24 @@ int main(int argc, char *argv[]) { process_layouts(filepath, output_asm, output_c); } + else if (mode == "heal_locations") { + if (argc < 5) + FATAL_ERROR("USAGE: mapjson heal_locations [additional_map_files] "); + + infer_separator(argv[3]); + + vector filepaths; + const int firstMapFileArg = 3; + const int lastMapFileArg = argc - 2; + for (int i = firstMapFileArg; i <= lastMapFileArg; i++) { + filepaths.push_back(argv[i]); + } + string output_file(argv[argc - 1]); + + process_heal_locations(filepaths, output_file); + } else { - FATAL_ERROR("ERROR: must be 'layouts', 'map', or 'groups'.\n"); + FATAL_ERROR("ERROR: must be 'layouts', 'map', 'heal_locations', or 'groups'.\n"); } return 0;