diff --git a/data/maps/CeladonCity/map.json b/data/maps/CeladonCity/map.json index 4fb826e84a..99d4c3303f 100644 --- a/data/maps/CeladonCity/map.json +++ b/data/maps/CeladonCity/map.json @@ -403,14 +403,5 @@ "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": "LOCALID_CELADON_NURSE" - } ] } diff --git a/data/maps/CeruleanCity/map.json b/data/maps/CeruleanCity/map.json index 17fbb07017..7576e7ec9f 100644 --- a/data/maps/CeruleanCity/map.json +++ b/data/maps/CeruleanCity/map.json @@ -420,14 +420,5 @@ "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": "LOCALID_CERULEAN_NURSE" - } ] } diff --git a/data/maps/CinnabarIsland/map.json b/data/maps/CinnabarIsland/map.json index e152453095..9ea66b99af 100644 --- a/data/maps/CinnabarIsland/map.json +++ b/data/maps/CinnabarIsland/map.json @@ -166,14 +166,5 @@ "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": "LOCALID_CINNABAR_NURSE" - } ] } diff --git a/data/maps/FiveIsland/map.json b/data/maps/FiveIsland/map.json index 68fd73d982..ec4f16ca07 100644 --- a/data/maps/FiveIsland/map.json +++ b/data/maps/FiveIsland/map.json @@ -103,14 +103,5 @@ "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": "LOCALID_FIVE_ISLAND_NURSE" - } ] } diff --git a/data/maps/FourIsland/map.json b/data/maps/FourIsland/map.json index ae8ab6a8a2..b807d3fbd3 100644 --- a/data/maps/FourIsland/map.json +++ b/data/maps/FourIsland/map.json @@ -282,14 +282,5 @@ "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": "LOCALID_FOUR_ISLAND_NURSE" - } ] } diff --git a/data/maps/FuchsiaCity/map.json b/data/maps/FuchsiaCity/map.json index da21cc7348..834806202c 100644 --- a/data/maps/FuchsiaCity/map.json +++ b/data/maps/FuchsiaCity/map.json @@ -435,14 +435,5 @@ "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": "LOCALID_FUCHSIA_NURSE" - } ] } diff --git a/data/maps/IndigoPlateau_Exterior/map.json b/data/maps/IndigoPlateau_Exterior/map.json index cab346b545..1d3903bf15 100644 --- a/data/maps/IndigoPlateau_Exterior/map.json +++ b/data/maps/IndigoPlateau_Exterior/map.json @@ -62,14 +62,5 @@ } ], "coord_events": [], - "bg_events": [], - "heal_locations": [ - { - "id": "HEAL_LOCATION_INDIGO_PLATEAU", - "x": 11, - "y": 7, - "respawn_map": "MAP_INDIGO_PLATEAU_POKEMON_CENTER_1F", - "respawn_npc": "LOCALID_LEAGUE_NURSE" - } - ] + "bg_events": [] } diff --git a/data/maps/LavenderTown/map.json b/data/maps/LavenderTown/map.json index 9b3316e1a0..edbe04fb62 100644 --- a/data/maps/LavenderTown/map.json +++ b/data/maps/LavenderTown/map.json @@ -152,14 +152,5 @@ "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": "LOCALID_LAVENDER_NURSE" - } ] } diff --git a/data/maps/OneIsland/map.json b/data/maps/OneIsland/map.json index eb741c1f20..d6274409e2 100644 --- a/data/maps/OneIsland/map.json +++ b/data/maps/OneIsland/map.json @@ -118,14 +118,5 @@ "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": "LOCALID_ONE_ISLAND_NURSE" - } ] } diff --git a/data/maps/PalletTown/map.json b/data/maps/PalletTown/map.json index ad67958782..802d32dc6d 100644 --- a/data/maps/PalletTown/map.json +++ b/data/maps/PalletTown/map.json @@ -165,14 +165,5 @@ "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": "LOCALID_MOM" - } ] } diff --git a/data/maps/PewterCity/map.json b/data/maps/PewterCity/map.json index c5df180ee1..82fe1beaf5 100644 --- a/data/maps/PewterCity/map.json +++ b/data/maps/PewterCity/map.json @@ -295,14 +295,5 @@ "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": "LOCALID_PEWTER_NURSE" - } ] } diff --git a/data/maps/Route10/map.json b/data/maps/Route10/map.json index 4d8fc826d9..97d85418fa 100644 --- a/data/maps/Route10/map.json +++ b/data/maps/Route10/map.json @@ -280,14 +280,5 @@ "quantity": 1, "underfoot": false } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_ROUTE10", - "x": 13, - "y": 21, - "respawn_map": "MAP_ROUTE10_POKEMON_CENTER_1F", - "respawn_npc": "LOCALID_ROUTE10_NURSE" - } ] } diff --git a/data/maps/Route4/map.json b/data/maps/Route4/map.json index 4eb75a89bd..ba9f45b378 100644 --- a/data/maps/Route4/map.json +++ b/data/maps/Route4/map.json @@ -190,14 +190,5 @@ "quantity": 1, "underfoot": false } - ], - "heal_locations": [ - { - "id": "HEAL_LOCATION_ROUTE4", - "x": 12, - "y": 6, - "respawn_map": "MAP_ROUTE4_POKEMON_CENTER_1F", - "respawn_npc": "LOCALID_ROUTE4_NURSE" - } ] } diff --git a/data/maps/SaffronCity/map.json b/data/maps/SaffronCity/map.json index bbdb3a27ff..77cba6c6d3 100644 --- a/data/maps/SaffronCity/map.json +++ b/data/maps/SaffronCity/map.json @@ -430,14 +430,5 @@ "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": "LOCALID_SAFFRON_NURSE" - } ] } diff --git a/data/maps/SevenIsland/map.json b/data/maps/SevenIsland/map.json index d2ef743fbf..e8b4c1a28e 100644 --- a/data/maps/SevenIsland/map.json +++ b/data/maps/SevenIsland/map.json @@ -110,14 +110,5 @@ "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": "LOCALID_SEVEN_ISLAND_NURSE" - } ] } diff --git a/data/maps/SixIsland/map.json b/data/maps/SixIsland/map.json index 2d3d4dbc8c..e5ebdb14fa 100644 --- a/data/maps/SixIsland/map.json +++ b/data/maps/SixIsland/map.json @@ -100,14 +100,5 @@ "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": "LOCALID_SIX_ISLAND_NURSE" - } ] } diff --git a/data/maps/ThreeIsland/map.json b/data/maps/ThreeIsland/map.json index be44113c95..140e41ddc2 100644 --- a/data/maps/ThreeIsland/map.json +++ b/data/maps/ThreeIsland/map.json @@ -394,14 +394,5 @@ "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": "LOCALID_THREE_ISLAND_NURSE" - } ] } diff --git a/data/maps/TwoIsland/map.json b/data/maps/TwoIsland/map.json index fb62b1b012..41ae31f396 100644 --- a/data/maps/TwoIsland/map.json +++ b/data/maps/TwoIsland/map.json @@ -204,14 +204,5 @@ "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": "LOCALID_TWO_ISLAND_NURSE" - } ] } diff --git a/data/maps/VermilionCity/map.json b/data/maps/VermilionCity/map.json index 5cd15cd516..d0b7a9a421 100644 --- a/data/maps/VermilionCity/map.json +++ b/data/maps/VermilionCity/map.json @@ -301,14 +301,5 @@ "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": "LOCALID_VERMILION_NURSE" - } ] } diff --git a/data/maps/ViridianCity/map.json b/data/maps/ViridianCity/map.json index 2fee18bb92..465d593cef 100644 --- a/data/maps/ViridianCity/map.json +++ b/data/maps/ViridianCity/map.json @@ -278,14 +278,5 @@ "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": "LOCALID_VIRIDIAN_NURSE" - } ] } diff --git a/include/constants/.gitignore b/include/constants/.gitignore index ff77d833c7..5923892b4f 100644 --- a/include/constants/.gitignore +++ b/include/constants/.gitignore @@ -3,3 +3,4 @@ map_groups.h layouts.h region_map_sections.h map_event_ids.h +heal_locations.h diff --git a/include/constants/heal_locations.h b/include/constants/heal_locations.h deleted file mode 100644 index f46647a8ca..0000000000 --- a/include/constants/heal_locations.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H -#define GUARD_CONSTANTS_HEAL_LOCATIONS_H - -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/json_data_rules.mk b/json_data_rules.mk index 65c4ee44e0..eec18467a5 100644 --- a/json_data_rules.mk +++ b/json_data_rules.mk @@ -28,3 +28,13 @@ $(DATA_SRC_SUBDIR)/items.h: $(DATA_SRC_SUBDIR)/items.json $(DATA_SRC_SUBDIR)/ite $(JSONPROC) $^ $@ $(C_BUILDDIR)/item.o: c_dep += $(DATA_SRC_SUBDIR)/items.h + +AUTO_GEN_TARGETS += $(DATA_SRC_SUBDIR)/heal_locations.h +$(DATA_SRC_SUBDIR)/heal_locations.h: $(DATA_SRC_SUBDIR)/heal_locations.json $(DATA_SRC_SUBDIR)/heal_locations.json.txt + $(JSONPROC) $^ $@ + +$(C_BUILDDIR)/heal_location.o: c_dep += $(DATA_SRC_SUBDIR)/heal_locations.h + +AUTO_GEN_TARGETS += include/constants/heal_locations.h +include/constants/heal_locations.h: $(DATA_SRC_SUBDIR)/heal_locations.json $(DATA_SRC_SUBDIR)/heal_locations.constants.json.txt + $(JSONPROC) $^ $@ diff --git a/map_data_rules.mk b/map_data_rules.mk index 3244d6e8db..b32b85a91d 100644 --- a/map_data_rules.mk +++ b/map_data_rules.mk @@ -12,7 +12,6 @@ INCLUDECONSTS_OUTDIR := include/constants AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/map_groups.h AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/layouts.h AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/map_event_ids.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)) @@ -34,11 +33,8 @@ $(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) -# Generate files that depends on data that's distributed across the map.json files. +# Generate constants for map events, which depend on data that's distributed across the map.json files. # There's a lot of map.json files, so we print an abbreviated output with echo. -# We're also not using a pattern rule, and we only want this to run once for both targets, -# so we use a separate target 'event_constants'. -$(INCLUDECONSTS_OUTDIR)/map_event_ids.h $(DATA_SRC_SUBDIR)/heal_locations.h: .event_constants ; -.event_constants: $(MAP_JSONS) - @$(MAPJSON) event_constants firered $^ $(INCLUDECONSTS_OUTDIR)/map_event_ids.h $(DATA_SRC_SUBDIR)/heal_locations.h - @echo "$(MAPJSON) event_constants firered $(INCLUDECONSTS_OUTDIR)/map_event_ids.h $(DATA_SRC_SUBDIR)/heal_locations.h" +$(INCLUDECONSTS_OUTDIR)/map_event_ids.h: $(MAP_JSONS) + @$(MAPJSON) event_constants firered $^ $(INCLUDECONSTS_OUTDIR)/map_event_ids.h + @echo "$(MAPJSON) event_constants firered $(INCLUDECONSTS_OUTDIR)/map_event_ids.h" diff --git a/src/data/heal_locations.constants.json.txt b/src/data/heal_locations.constants.json.txt new file mode 100644 index 0000000000..e9ca860b35 --- /dev/null +++ b/src/data/heal_locations.constants.json.txt @@ -0,0 +1,14 @@ +#ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H +#define GUARD_CONSTANTS_HEAL_LOCATIONS_H + +{{ doNotModifyHeader }} + +enum { + HEAL_LOCATION_NONE, +## for heal_location in heal_locations + {{ heal_location.id }}, +## endfor + NUM_HEAL_LOCATIONS +}; + +#endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H diff --git a/src/data/heal_locations.json b/src/data/heal_locations.json new file mode 100644 index 0000000000..9802525b70 --- /dev/null +++ b/src/data/heal_locations.json @@ -0,0 +1,164 @@ +{ + "heal_locations": [ + { + "id": "HEAL_LOCATION_PALLET_TOWN", + "map": "MAP_PALLET_TOWN", + "x": 6, + "y": 8, + "respawn_map": "MAP_PALLET_TOWN_PLAYERS_HOUSE_1F", + "respawn_npc": "LOCALID_MOM" + }, + { + "id": "HEAL_LOCATION_VIRIDIAN_CITY", + "map": "MAP_VIRIDIAN_CITY", + "x": 26, + "y": 27, + "respawn_map": "MAP_VIRIDIAN_CITY_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_VIRIDIAN_NURSE" + }, + { + "id": "HEAL_LOCATION_PEWTER_CITY", + "map": "MAP_PEWTER_CITY", + "x": 17, + "y": 26, + "respawn_map": "MAP_PEWTER_CITY_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_PEWTER_NURSE" + }, + { + "id": "HEAL_LOCATION_CERULEAN_CITY", + "map": "MAP_CERULEAN_CITY", + "x": 22, + "y": 20, + "respawn_map": "MAP_CERULEAN_CITY_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_CERULEAN_NURSE" + }, + { + "id": "HEAL_LOCATION_LAVENDER_TOWN", + "map": "MAP_LAVENDER_TOWN", + "x": 6, + "y": 6, + "respawn_map": "MAP_LAVENDER_TOWN_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_LAVENDER_NURSE" + }, + { + "id": "HEAL_LOCATION_VERMILION_CITY", + "map": "MAP_VERMILION_CITY", + "x": 15, + "y": 7, + "respawn_map": "MAP_VERMILION_CITY_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_VERMILION_NURSE" + }, + { + "id": "HEAL_LOCATION_CELADON_CITY", + "map": "MAP_CELADON_CITY", + "x": 48, + "y": 12, + "respawn_map": "MAP_CELADON_CITY_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_CELADON_NURSE" + }, + { + "id": "HEAL_LOCATION_FUCHSIA_CITY", + "map": "MAP_FUCHSIA_CITY", + "x": 25, + "y": 32, + "respawn_map": "MAP_FUCHSIA_CITY_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_FUCHSIA_NURSE" + }, + { + "id": "HEAL_LOCATION_CINNABAR_ISLAND", + "map": "MAP_CINNABAR_ISLAND", + "x": 14, + "y": 12, + "respawn_map": "MAP_CINNABAR_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_CINNABAR_NURSE" + }, + { + "id": "HEAL_LOCATION_INDIGO_PLATEAU", + "map": "MAP_INDIGO_PLATEAU_EXTERIOR", + "x": 11, + "y": 7, + "respawn_map": "MAP_INDIGO_PLATEAU_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_LEAGUE_NURSE" + }, + { + "id": "HEAL_LOCATION_SAFFRON_CITY", + "map": "MAP_SAFFRON_CITY", + "x": 24, + "y": 39, + "respawn_map": "MAP_SAFFRON_CITY_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_SAFFRON_NURSE" + }, + { + "id": "HEAL_LOCATION_ROUTE4", + "map": "MAP_ROUTE4", + "x": 12, + "y": 6, + "respawn_map": "MAP_ROUTE4_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_ROUTE4_NURSE" + }, + { + "id": "HEAL_LOCATION_ROUTE10", + "map": "MAP_ROUTE10", + "x": 13, + "y": 21, + "respawn_map": "MAP_ROUTE10_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_ROUTE10_NURSE" + }, + { + "id": "HEAL_LOCATION_ONE_ISLAND", + "map": "MAP_ONE_ISLAND", + "x": 14, + "y": 6, + "respawn_map": "MAP_ONE_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_ONE_ISLAND_NURSE" + }, + { + "id": "HEAL_LOCATION_TWO_ISLAND", + "map": "MAP_TWO_ISLAND", + "x": 21, + "y": 8, + "respawn_map": "MAP_TWO_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_TWO_ISLAND_NURSE" + }, + { + "id": "HEAL_LOCATION_THREE_ISLAND", + "map": "MAP_THREE_ISLAND", + "x": 14, + "y": 28, + "respawn_map": "MAP_THREE_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_THREE_ISLAND_NURSE" + }, + { + "id": "HEAL_LOCATION_FOUR_ISLAND", + "map": "MAP_FOUR_ISLAND", + "x": 18, + "y": 21, + "respawn_map": "MAP_FOUR_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_FOUR_ISLAND_NURSE" + }, + { + "id": "HEAL_LOCATION_FIVE_ISLAND", + "map": "MAP_FIVE_ISLAND", + "x": 18, + "y": 7, + "respawn_map": "MAP_FIVE_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_FIVE_ISLAND_NURSE" + }, + { + "id": "HEAL_LOCATION_SEVEN_ISLAND", + "map": "MAP_SEVEN_ISLAND", + "x": 12, + "y": 4, + "respawn_map": "MAP_SEVEN_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_SEVEN_ISLAND_NURSE" + }, + { + "id": "HEAL_LOCATION_SIX_ISLAND", + "map": "MAP_SIX_ISLAND", + "x": 11, + "y": 12, + "respawn_map": "MAP_SIX_ISLAND_POKEMON_CENTER_1F", + "respawn_npc": "LOCALID_SIX_ISLAND_NURSE" + } + ] +} diff --git a/src/data/heal_locations.json.txt b/src/data/heal_locations.json.txt new file mode 100644 index 0000000000..0dde0f5e45 --- /dev/null +++ b/src/data/heal_locations.json.txt @@ -0,0 +1,24 @@ +{{ doNotModifyHeader }} + +static const struct HealLocation sHealLocations[NUM_HEAL_LOCATIONS - 1] = { +## for heal_location in heal_locations + [{{ heal_location.id }} - 1] = { + .mapGroup = MAP_GROUP({{ heal_location.map }}), + .mapNum = MAP_NUM({{ heal_location.map }}), + .x = {{ heal_location.x }}, + .y = {{ heal_location.y }}, + }, +## endfor +}; + +static const u16 sWhiteoutRespawnHealCenterMapIdxs[NUM_HEAL_LOCATIONS - 1][2] = { +## for heal_location in heal_locations + [{{ heal_location.id }} - 1] = { MAP_GROUP({{ heal_location.respawn_map }}), MAP_NUM({{ heal_location.respawn_map }})}, +## endfor +}; + +static const u8 sWhiteoutRespawnHealerNpcIds[NUM_HEAL_LOCATIONS - 1] = { +## for heal_location in heal_locations + [{{ heal_location.id }} - 1] = {{ heal_location.respawn_npc }}, +## endfor +}; diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp index 99b67d82ea..8d8ec4e4e6 100644 --- a/tools/mapjson/mapjson.cpp +++ b/tools/mapjson/mapjson.cpp @@ -391,18 +391,13 @@ void process_map(string map_filepath, string layouts_filepath, string output_dir write_text_file(out_dir + "connections.inc", connections_text); } -void process_event_constants(const vector &map_filepaths, string output_ids_file, string output_heal_locations_file) { +void process_event_constants(const vector &map_filepaths, string output_ids_file) { string warning = get_generated_warning("data/maps/*/map.json", false); - ostringstream heal_locations_arr_text; - ostringstream respawn_maps_arr_text; - ostringstream respawn_npcs_arr_text; - string guard_name = "CONSTANTS_MAP_EVENT_IDS"; ostringstream ids_file_text; ids_file_text << get_include_guard_start(guard_name) << warning; - // Get heal location data from each map for (const string &filepath : map_filepaths) { string err; string map_json_text = read_text_file(filepath); @@ -432,59 +427,10 @@ void process_event_constants(const vector &map_filepaths, string output_ if (!temp.empty()) { ids_file_text << "// " << map_id << "\n" << temp << "\n"; } - - // Process heal locations. Maps are not required to have a heal locations array, so we check if it exists first. - if (map_data.object_items().find("heal_locations") != map_data.object_items().end()) { - 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_arr_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_arr_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_arr_text << index_text << " " << json_to_string(heal_location, "respawn_npc") << ",\n"; - } - } - } } - // Write event ids file ids_file_text << get_include_guard_end(guard_name); write_text_file(output_ids_file, ids_file_text.str()); - - - // Write heal locations data file - ostringstream heal_locations_file_text; - heal_locations_file_text << warning; - - string arr_body = heal_locations_arr_text.str(); - heal_locations_file_text << "static const struct HealLocation sHealLocations[] =\n{\n" << arr_body << "};\n\n"; - - arr_body = respawn_maps_arr_text.str(); - if (!arr_body.empty()) - heal_locations_file_text << "static const u16 sWhiteoutRespawnHealCenterMapIdxs[][2] =\n{\n" << arr_body << "};\n\n"; - - arr_body = respawn_npcs_arr_text.str(); - if (!arr_body.empty()) - heal_locations_file_text << "static const u8 sWhiteoutRespawnHealerNpcIds[] =\n{\n" << arr_body << "};\n\n"; - - write_text_file(output_heal_locations_file, heal_locations_file_text.str()); } string generate_groups_text(Json groups_data) { @@ -771,21 +717,20 @@ int main(int argc, char *argv[]) { process_layouts(filepath, output_asm, output_c); } else if (mode == "event_constants") { - if (argc < 6) - FATAL_ERROR("USAGE: mapjson event_constants [additional_map_files] "); + if (argc < 5) + FATAL_ERROR("USAGE: mapjson event_constants [additional_map_files] "); infer_separator(argv[3]); vector filepaths; const int firstMapFileArg = 3; - const int lastMapFileArg = argc - 3; + const int lastMapFileArg = argc - 2; for (int i = firstMapFileArg; i <= lastMapFileArg; i++) { filepaths.push_back(argv[i]); } - string output_ids_file(argv[argc - 2]); - string output_heal_locations_file(argv[argc - 1]); + string output_ids_file(argv[argc - 1]); - process_event_constants(filepaths, output_ids_file, output_heal_locations_file); + process_event_constants(filepaths, output_ids_file); } else { FATAL_ERROR("ERROR: must be 'layouts', 'map', 'event_constants', or 'groups'.\n");