diff --git a/data/maps/BattleFrontier_OutsideEast/map.json b/data/maps/BattleFrontier_OutsideEast/map.json index c99fe30474..959244d82b 100644 --- a/data/maps/BattleFrontier_OutsideEast/map.json +++ b/data/maps/BattleFrontier_OutsideEast/map.json @@ -525,5 +525,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "Common_EventScript_ShowPokemonCenterSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST", + "x": 3, + "y": 52 + } ] } diff --git a/data/maps/DewfordTown/map.json b/data/maps/DewfordTown/map.json index f073a74368..26551e4efe 100644 --- a/data/maps/DewfordTown/map.json +++ b/data/maps/DewfordTown/map.json @@ -170,5 +170,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "DewfordTown_EventScript_HallSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_DEWFORD_TOWN", + "x": 2, + "y": 11 + } ] } diff --git a/data/maps/EverGrandeCity/map.json b/data/maps/EverGrandeCity/map.json index 58978b7ff8..ed2d9bb9ce 100644 --- a/data/maps/EverGrandeCity/map.json +++ b/data/maps/EverGrandeCity/map.json @@ -192,5 +192,17 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "script": "Common_EventScript_ShowPokemonCenterSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_EVER_GRANDE_CITY", + "x": 27, + "y": 49 + }, + { + "id": "HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE", + "x": 18, + "y": 6 + } ] } diff --git a/data/maps/FallarborTown/map.json b/data/maps/FallarborTown/map.json index 4888640a59..41e55a3ce4 100644 --- a/data/maps/FallarborTown/map.json +++ b/data/maps/FallarborTown/map.json @@ -181,5 +181,12 @@ "item": "ITEM_NUGGET", "flag": "FLAG_HIDDEN_ITEM_FALLARBOR_TOWN_NUGGET" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_FALLARBOR_TOWN", + "x": 14, + "y": 8 + } ] } diff --git a/data/maps/FortreeCity/map.json b/data/maps/FortreeCity/map.json index 007d8b22d7..39483a94b5 100644 --- a/data/maps/FortreeCity/map.json +++ b/data/maps/FortreeCity/map.json @@ -232,5 +232,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "script": "Common_EventScript_ShowPokemartSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_FORTREE_CITY", + "x": 5, + "y": 7 + } ] } diff --git a/data/maps/LavaridgeTown/map.json b/data/maps/LavaridgeTown/map.json index ecf7c5b9f1..33c7ce3c08 100644 --- a/data/maps/LavaridgeTown/map.json +++ b/data/maps/LavaridgeTown/map.json @@ -258,5 +258,12 @@ "item": "ITEM_ICE_HEAL", "flag": "FLAG_HIDDEN_ITEM_LAVARIDGE_TOWN_ICE_HEAL" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_LAVARIDGE_TOWN", + "x": 9, + "y": 7 + } ] } diff --git a/data/maps/LilycoveCity/map.json b/data/maps/LilycoveCity/map.json index 398cf219ea..34bd8d1334 100644 --- a/data/maps/LilycoveCity/map.json +++ b/data/maps/LilycoveCity/map.json @@ -518,5 +518,12 @@ "item": "ITEM_POKE_BALL", "flag": "FLAG_HIDDEN_ITEM_LILYCOVE_CITY_POKE_BALL" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_LILYCOVE_CITY", + "x": 24, + "y": 15 + } ] } diff --git a/data/maps/LittlerootTown/map.json b/data/maps/LittlerootTown/map.json index 8311ffaa3c..4cff63da09 100644 --- a/data/maps/LittlerootTown/map.json +++ b/data/maps/LittlerootTown/map.json @@ -264,5 +264,17 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "LittlerootTown_EventScript_MaysHouseSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE", + "x": 5, + "y": 9 + }, + { + "id": "HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE", + "x": 14, + "y": 9 + } ] } diff --git a/data/maps/LittlerootTown_BrendansHouse_2F/map.json b/data/maps/LittlerootTown_BrendansHouse_2F/map.json index e9b6834ee5..89869459c5 100644 --- a/data/maps/LittlerootTown_BrendansHouse_2F/map.json +++ b/data/maps/LittlerootTown_BrendansHouse_2F/map.json @@ -266,5 +266,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "PlayersHouse_2F_EventScript_GameCube" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F", + "x": 4, + "y": 2 + } ] } diff --git a/data/maps/LittlerootTown_MaysHouse_2F/map.json b/data/maps/LittlerootTown_MaysHouse_2F/map.json index ce3a5f5701..b852fc0400 100644 --- a/data/maps/LittlerootTown_MaysHouse_2F/map.json +++ b/data/maps/LittlerootTown_MaysHouse_2F/map.json @@ -266,5 +266,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "LittlerootTown_MaysHouse_2F_EventScript_PC" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F", + "x": 4, + "y": 2 + } ] } diff --git a/data/maps/MauvilleCity/map.json b/data/maps/MauvilleCity/map.json index f4da4222b1..c123138dd5 100644 --- a/data/maps/MauvilleCity/map.json +++ b/data/maps/MauvilleCity/map.json @@ -296,5 +296,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "MauvilleCity_EventScript_GameCornerSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_MAUVILLE_CITY", + "x": 22, + "y": 6 + } ] } diff --git a/data/maps/MossdeepCity/map.json b/data/maps/MossdeepCity/map.json index 3759694d88..232cbda814 100644 --- a/data/maps/MossdeepCity/map.json +++ b/data/maps/MossdeepCity/map.json @@ -481,5 +481,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "MossdeepCity_EventScript_WhiteRock" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_MOSSDEEP_CITY", + "x": 28, + "y": 17 + } ] } diff --git a/data/maps/OldaleTown/map.json b/data/maps/OldaleTown/map.json index 302ef5e9d0..4bb86784e9 100644 --- a/data/maps/OldaleTown/map.json +++ b/data/maps/OldaleTown/map.json @@ -192,5 +192,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "script": "Common_EventScript_ShowPokemartSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_OLDALE_TOWN", + "x": 6, + "y": 17 + } ] } diff --git a/data/maps/PacifidlogTown/map.json b/data/maps/PacifidlogTown/map.json index 37cfe8ad08..e1f5700f17 100644 --- a/data/maps/PacifidlogTown/map.json +++ b/data/maps/PacifidlogTown/map.json @@ -135,5 +135,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "script": "Common_EventScript_ShowPokemonCenterSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_PACIFIDLOG_TOWN", + "x": 8, + "y": 16 + } ] } diff --git a/data/maps/PetalburgCity/map.json b/data/maps/PetalburgCity/map.json index d653e46aec..63e02e8955 100644 --- a/data/maps/PetalburgCity/map.json +++ b/data/maps/PetalburgCity/map.json @@ -326,5 +326,12 @@ "item": "ITEM_RARE_CANDY", "flag": "FLAG_HIDDEN_ITEM_PETALBURG_CITY_RARE_CANDY" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_PETALBURG_CITY", + "x": 20, + "y": 17 + } ] } diff --git a/data/maps/RustboroCity/map.json b/data/maps/RustboroCity/map.json index 3d77404ee7..2d42b30850 100644 --- a/data/maps/RustboroCity/map.json +++ b/data/maps/RustboroCity/map.json @@ -597,5 +597,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "RustboroCity_EventScript_CuttersHouseSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_RUSTBORO_CITY", + "x": 16, + "y": 39 + } ] } diff --git a/data/maps/SlateportCity/map.json b/data/maps/SlateportCity/map.json index 972b51447e..b285f030ee 100644 --- a/data/maps/SlateportCity/map.json +++ b/data/maps/SlateportCity/map.json @@ -681,5 +681,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "script": "SlateportCity_EventScript_BerryCrushRankingsSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_SLATEPORT_CITY", + "x": 19, + "y": 20 + } ] } diff --git a/data/maps/SootopolisCity/map.json b/data/maps/SootopolisCity/map.json index c6a6757d23..a436d72cb3 100644 --- a/data/maps/SootopolisCity/map.json +++ b/data/maps/SootopolisCity/map.json @@ -392,5 +392,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "SootopolisCity_EventScript_CitySign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_SOOTOPOLIS_CITY", + "x": 43, + "y": 32 + } ] } diff --git a/data/maps/SouthernIsland_Exterior/map.json b/data/maps/SouthernIsland_Exterior/map.json index 53a988398c..6912e3f4bd 100644 --- a/data/maps/SouthernIsland_Exterior/map.json +++ b/data/maps/SouthernIsland_Exterior/map.json @@ -67,5 +67,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "SouthernIsland_Exterior_EventScript_Sign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR", + "x": 15, + "y": 20 + } ] } diff --git a/data/maps/VerdanturfTown/map.json b/data/maps/VerdanturfTown/map.json index ae40730c0e..c8395b10c0 100644 --- a/data/maps/VerdanturfTown/map.json +++ b/data/maps/VerdanturfTown/map.json @@ -195,5 +195,12 @@ "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "script": "VerdanturfTown_EventScript_RusturfTunnelSign" } + ], + "heal_locations": [ + { + "id": "HEAL_LOCATION_VERDANTURF_TOWN", + "x": 16, + "y": 4 + } ] } diff --git a/include/constants/heal_locations.h b/include/constants/heal_locations.h index d3dd8f1f17..4a9771d810 100644 --- a/include/constants/heal_locations.h +++ b/include/constants/heal_locations.h @@ -1,28 +1,30 @@ #ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H #define GUARD_CONSTANTS_HEAL_LOCATIONS_H -#define HEAL_LOCATION_NONE 0 -#define HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F 1 -#define HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F 2 -#define HEAL_LOCATION_PETALBURG_CITY 3 -#define HEAL_LOCATION_SLATEPORT_CITY 4 -#define HEAL_LOCATION_MAUVILLE_CITY 5 -#define HEAL_LOCATION_RUSTBORO_CITY 6 -#define HEAL_LOCATION_FORTREE_CITY 7 -#define HEAL_LOCATION_LILYCOVE_CITY 8 -#define HEAL_LOCATION_MOSSDEEP_CITY 9 -#define HEAL_LOCATION_SOOTOPOLIS_CITY 10 -#define HEAL_LOCATION_EVER_GRANDE_CITY 11 -#define HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE 12 -#define HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE 13 -#define HEAL_LOCATION_OLDALE_TOWN 14 -#define HEAL_LOCATION_DEWFORD_TOWN 15 -#define HEAL_LOCATION_LAVARIDGE_TOWN 16 -#define HEAL_LOCATION_FALLARBOR_TOWN 17 -#define HEAL_LOCATION_VERDANTURF_TOWN 18 -#define HEAL_LOCATION_PACIFIDLOG_TOWN 19 -#define HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE 20 -#define HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR 21 -#define HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST 22 +enum { + HEAL_LOCATION_NONE, + HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F, + HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F, + HEAL_LOCATION_PETALBURG_CITY, + HEAL_LOCATION_SLATEPORT_CITY, + HEAL_LOCATION_MAUVILLE_CITY, + HEAL_LOCATION_RUSTBORO_CITY, + HEAL_LOCATION_FORTREE_CITY, + HEAL_LOCATION_LILYCOVE_CITY, + HEAL_LOCATION_MOSSDEEP_CITY, + HEAL_LOCATION_SOOTOPOLIS_CITY, + HEAL_LOCATION_EVER_GRANDE_CITY, + HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE, + HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE, + HEAL_LOCATION_OLDALE_TOWN, + HEAL_LOCATION_DEWFORD_TOWN, + HEAL_LOCATION_LAVARIDGE_TOWN, + HEAL_LOCATION_FALLARBOR_TOWN, + HEAL_LOCATION_VERDANTURF_TOWN, + HEAL_LOCATION_PACIFIDLOG_TOWN, + HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE, + HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR, + HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST, +}; #endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H diff --git a/include/heal_location.h b/include/heal_location.h index 46f0d785ab..c087cfb3cd 100644 --- a/include/heal_location.h +++ b/include/heal_location.h @@ -3,8 +3,8 @@ struct HealLocation { - s8 group; - s8 map; + s8 mapGroup; + s8 mapNum; u16 x; u16 y; }; diff --git a/map_data_rules.mk b/map_data_rules.mk index ed7c08edea..199991ad56 100755 --- 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 - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@ @@ -31,3 +33,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 emerald $< $(LAYOUTS_OUTDIR) $(INCLUDECONSTS_OUTDIR) + +$(DATA_SRC_SUBDIR)/heal_locations.h: $(MAP_JSONS) + @$(MAPJSON) heal_locations emerald $^ $(DATA_SRC_SUBDIR)/heal_locations.h diff --git a/src/data/.gitignore b/src/data/.gitignore index f9205e5627..371e10c56e 100755 --- a/src/data/.gitignore +++ b/src/data/.gitignore @@ -1,3 +1,4 @@ +heal_locations.h wild_encounters.h region_map/region_map_entries.h region_map/porymap_config.json diff --git a/src/data/heal_locations.h b/src/data/heal_locations.h deleted file mode 100644 index 2aba995b43..0000000000 --- a/src/data/heal_locations.h +++ /dev/null @@ -1,25 +0,0 @@ -static const struct HealLocation sHealLocations[] = -{ - [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F - 1] = {MAP_GROUP(MAP_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F), MAP_NUM(MAP_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F), 4, 2}, - [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F - 1] = {MAP_GROUP(MAP_LITTLEROOT_TOWN_MAYS_HOUSE_2F), MAP_NUM(MAP_LITTLEROOT_TOWN_MAYS_HOUSE_2F), 4, 2}, - [HEAL_LOCATION_PETALBURG_CITY - 1] = {MAP_GROUP(MAP_PETALBURG_CITY), MAP_NUM(MAP_PETALBURG_CITY), 20, 17}, - [HEAL_LOCATION_SLATEPORT_CITY - 1] = {MAP_GROUP(MAP_SLATEPORT_CITY), MAP_NUM(MAP_SLATEPORT_CITY), 19, 20}, - [HEAL_LOCATION_MAUVILLE_CITY - 1] = {MAP_GROUP(MAP_MAUVILLE_CITY), MAP_NUM(MAP_MAUVILLE_CITY), 22, 6}, - [HEAL_LOCATION_RUSTBORO_CITY - 1] = {MAP_GROUP(MAP_RUSTBORO_CITY), MAP_NUM(MAP_RUSTBORO_CITY), 16, 39}, - [HEAL_LOCATION_FORTREE_CITY - 1] = {MAP_GROUP(MAP_FORTREE_CITY), MAP_NUM(MAP_FORTREE_CITY), 5, 7}, - [HEAL_LOCATION_LILYCOVE_CITY - 1] = {MAP_GROUP(MAP_LILYCOVE_CITY), MAP_NUM(MAP_LILYCOVE_CITY), 24, 15}, - [HEAL_LOCATION_MOSSDEEP_CITY - 1] = {MAP_GROUP(MAP_MOSSDEEP_CITY), MAP_NUM(MAP_MOSSDEEP_CITY), 28, 17}, - [HEAL_LOCATION_SOOTOPOLIS_CITY - 1] = {MAP_GROUP(MAP_SOOTOPOLIS_CITY), MAP_NUM(MAP_SOOTOPOLIS_CITY), 43, 32}, - [HEAL_LOCATION_EVER_GRANDE_CITY - 1] = {MAP_GROUP(MAP_EVER_GRANDE_CITY), MAP_NUM(MAP_EVER_GRANDE_CITY), 27, 49}, - [HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE - 1] = {MAP_GROUP(MAP_LITTLEROOT_TOWN), MAP_NUM(MAP_LITTLEROOT_TOWN), 5, 9}, - [HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE - 1] = {MAP_GROUP(MAP_LITTLEROOT_TOWN), MAP_NUM(MAP_LITTLEROOT_TOWN), 14, 9}, - [HEAL_LOCATION_OLDALE_TOWN - 1] = {MAP_GROUP(MAP_OLDALE_TOWN), MAP_NUM(MAP_OLDALE_TOWN), 6, 17}, - [HEAL_LOCATION_DEWFORD_TOWN - 1] = {MAP_GROUP(MAP_DEWFORD_TOWN), MAP_NUM(MAP_DEWFORD_TOWN), 2, 11}, - [HEAL_LOCATION_LAVARIDGE_TOWN - 1] = {MAP_GROUP(MAP_LAVARIDGE_TOWN), MAP_NUM(MAP_LAVARIDGE_TOWN), 9, 7}, - [HEAL_LOCATION_FALLARBOR_TOWN - 1] = {MAP_GROUP(MAP_FALLARBOR_TOWN), MAP_NUM(MAP_FALLARBOR_TOWN), 14, 8}, - [HEAL_LOCATION_VERDANTURF_TOWN - 1] = {MAP_GROUP(MAP_VERDANTURF_TOWN), MAP_NUM(MAP_VERDANTURF_TOWN), 16, 4}, - [HEAL_LOCATION_PACIFIDLOG_TOWN - 1] = {MAP_GROUP(MAP_PACIFIDLOG_TOWN), MAP_NUM(MAP_PACIFIDLOG_TOWN), 8, 16}, - [HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE - 1] = {MAP_GROUP(MAP_EVER_GRANDE_CITY), MAP_NUM(MAP_EVER_GRANDE_CITY), 18, 6}, - [HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR - 1] = {MAP_GROUP(MAP_SOUTHERN_ISLAND_EXTERIOR), MAP_NUM(MAP_SOUTHERN_ISLAND_EXTERIOR), 15, 20}, - [HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST - 1] = {MAP_GROUP(MAP_BATTLE_FRONTIER_OUTSIDE_EAST), MAP_NUM(MAP_BATTLE_FRONTIER_OUTSIDE_EAST), 3, 52}, -}; diff --git a/src/heal_location.c b/src/heal_location.c index 0ab5540346..a787b33590 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -10,7 +10,7 @@ u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum) for (i = 0; i < ARRAY_COUNT(sHealLocations); i++) { - if (sHealLocations[i].group == mapGroup && sHealLocations[i].map == mapNum) + if (sHealLocations[i].mapGroup == mapGroup && sHealLocations[i].mapNum == mapNum) return i + 1; } return HEAL_LOCATION_NONE; diff --git a/src/overworld.c b/src/overworld.c index af07660de9..43e49baee9 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -659,7 +659,7 @@ void SetWarpDestinationToHealLocation(u8 healLocationId) { const struct HealLocation *healLocation = GetHealLocation(healLocationId); if (healLocation) - SetWarpDestination(healLocation->group, healLocation->map, WARP_ID_NONE, healLocation->x, healLocation->y); + SetWarpDestination(healLocation->mapGroup, healLocation->mapNum, WARP_ID_NONE, healLocation->x, healLocation->y); } void SetWarpDestinationToLastHealLocation(void) @@ -671,7 +671,7 @@ void SetLastHealLocationWarp(u8 healLocationId) { const struct HealLocation *healLocation = GetHealLocation(healLocationId); if (healLocation) - SetWarpData(&gSaveBlock1Ptr->lastHealLocation, healLocation->group, healLocation->map, WARP_ID_NONE, healLocation->x, healLocation->y); + SetWarpData(&gSaveBlock1Ptr->lastHealLocation, healLocation->mapGroup, healLocation->mapNum, WARP_ID_NONE, healLocation->x, healLocation->y); } void UpdateEscapeWarp(s16 x, s16 y) @@ -729,7 +729,7 @@ void SetContinueGameWarpToHealLocation(u8 healLocationId) { const struct HealLocation *healLocation = GetHealLocation(healLocationId); if (healLocation) - SetWarpData(&gSaveBlock1Ptr->continueGameWarp, healLocation->group, healLocation->map, WARP_ID_NONE, healLocation->x, healLocation->y); + SetWarpData(&gSaveBlock1Ptr->continueGameWarp, healLocation->mapGroup, healLocation->mapNum, WARP_ID_NONE, healLocation->x, healLocation->y); } void SetContinueGameWarpToDynamicWarp(int unused) 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;