Move heal locations data to their associated map.json (#2034)

This commit is contained in:
GriffinR
2024-10-11 15:15:55 -04:00
committed by GitHub
parent af8f4bf45d
commit 091b7269df
28 changed files with 267 additions and 58 deletions

View File

@@ -525,5 +525,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "Common_EventScript_ShowPokemonCenterSign" "script": "Common_EventScript_ShowPokemonCenterSign"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST",
"x": 3,
"y": 52
}
] ]
} }

View File

@@ -170,5 +170,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "DewfordTown_EventScript_HallSign" "script": "DewfordTown_EventScript_HallSign"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_DEWFORD_TOWN",
"x": 2,
"y": 11
}
] ]
} }

View File

@@ -192,5 +192,17 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH",
"script": "Common_EventScript_ShowPokemonCenterSign" "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
}
] ]
} }

View File

@@ -181,5 +181,12 @@
"item": "ITEM_NUGGET", "item": "ITEM_NUGGET",
"flag": "FLAG_HIDDEN_ITEM_FALLARBOR_TOWN_NUGGET" "flag": "FLAG_HIDDEN_ITEM_FALLARBOR_TOWN_NUGGET"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_FALLARBOR_TOWN",
"x": 14,
"y": 8
}
] ]
} }

View File

@@ -232,5 +232,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH",
"script": "Common_EventScript_ShowPokemartSign" "script": "Common_EventScript_ShowPokemartSign"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_FORTREE_CITY",
"x": 5,
"y": 7
}
] ]
} }

View File

@@ -258,5 +258,12 @@
"item": "ITEM_ICE_HEAL", "item": "ITEM_ICE_HEAL",
"flag": "FLAG_HIDDEN_ITEM_LAVARIDGE_TOWN_ICE_HEAL" "flag": "FLAG_HIDDEN_ITEM_LAVARIDGE_TOWN_ICE_HEAL"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_LAVARIDGE_TOWN",
"x": 9,
"y": 7
}
] ]
} }

View File

@@ -518,5 +518,12 @@
"item": "ITEM_POKE_BALL", "item": "ITEM_POKE_BALL",
"flag": "FLAG_HIDDEN_ITEM_LILYCOVE_CITY_POKE_BALL" "flag": "FLAG_HIDDEN_ITEM_LILYCOVE_CITY_POKE_BALL"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_LILYCOVE_CITY",
"x": 24,
"y": 15
}
] ]
} }

View File

@@ -264,5 +264,17 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "LittlerootTown_EventScript_MaysHouseSign" "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
}
] ]
} }

View File

@@ -266,5 +266,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "PlayersHouse_2F_EventScript_GameCube" "script": "PlayersHouse_2F_EventScript_GameCube"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F",
"x": 4,
"y": 2
}
] ]
} }

View File

@@ -266,5 +266,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "LittlerootTown_MaysHouse_2F_EventScript_PC" "script": "LittlerootTown_MaysHouse_2F_EventScript_PC"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F",
"x": 4,
"y": 2
}
] ]
} }

View File

@@ -296,5 +296,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "MauvilleCity_EventScript_GameCornerSign" "script": "MauvilleCity_EventScript_GameCornerSign"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_MAUVILLE_CITY",
"x": 22,
"y": 6
}
] ]
} }

View File

@@ -481,5 +481,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "MossdeepCity_EventScript_WhiteRock" "script": "MossdeepCity_EventScript_WhiteRock"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_MOSSDEEP_CITY",
"x": 28,
"y": 17
}
] ]
} }

View File

@@ -192,5 +192,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH",
"script": "Common_EventScript_ShowPokemartSign" "script": "Common_EventScript_ShowPokemartSign"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_OLDALE_TOWN",
"x": 6,
"y": 17
}
] ]
} }

View File

@@ -135,5 +135,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH",
"script": "Common_EventScript_ShowPokemonCenterSign" "script": "Common_EventScript_ShowPokemonCenterSign"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_PACIFIDLOG_TOWN",
"x": 8,
"y": 16
}
] ]
} }

View File

@@ -326,5 +326,12 @@
"item": "ITEM_RARE_CANDY", "item": "ITEM_RARE_CANDY",
"flag": "FLAG_HIDDEN_ITEM_PETALBURG_CITY_RARE_CANDY" "flag": "FLAG_HIDDEN_ITEM_PETALBURG_CITY_RARE_CANDY"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_PETALBURG_CITY",
"x": 20,
"y": 17
}
] ]
} }

View File

@@ -597,5 +597,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "RustboroCity_EventScript_CuttersHouseSign" "script": "RustboroCity_EventScript_CuttersHouseSign"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_RUSTBORO_CITY",
"x": 16,
"y": 39
}
] ]
} }

View File

@@ -681,5 +681,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH", "player_facing_dir": "BG_EVENT_PLAYER_FACING_NORTH",
"script": "SlateportCity_EventScript_BerryCrushRankingsSign" "script": "SlateportCity_EventScript_BerryCrushRankingsSign"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_SLATEPORT_CITY",
"x": 19,
"y": 20
}
] ]
} }

View File

@@ -392,5 +392,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "SootopolisCity_EventScript_CitySign" "script": "SootopolisCity_EventScript_CitySign"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_SOOTOPOLIS_CITY",
"x": 43,
"y": 32
}
] ]
} }

View File

@@ -67,5 +67,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "SouthernIsland_Exterior_EventScript_Sign" "script": "SouthernIsland_Exterior_EventScript_Sign"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR",
"x": 15,
"y": 20
}
] ]
} }

View File

@@ -195,5 +195,12 @@
"player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY", "player_facing_dir": "BG_EVENT_PLAYER_FACING_ANY",
"script": "VerdanturfTown_EventScript_RusturfTunnelSign" "script": "VerdanturfTown_EventScript_RusturfTunnelSign"
} }
],
"heal_locations": [
{
"id": "HEAL_LOCATION_VERDANTURF_TOWN",
"x": 16,
"y": 4
}
] ]
} }

View File

@@ -1,28 +1,30 @@
#ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H #ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H
#define GUARD_CONSTANTS_HEAL_LOCATIONS_H #define GUARD_CONSTANTS_HEAL_LOCATIONS_H
#define HEAL_LOCATION_NONE 0 enum {
#define HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F 1 HEAL_LOCATION_NONE,
#define HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F 2 HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F,
#define HEAL_LOCATION_PETALBURG_CITY 3 HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F,
#define HEAL_LOCATION_SLATEPORT_CITY 4 HEAL_LOCATION_PETALBURG_CITY,
#define HEAL_LOCATION_MAUVILLE_CITY 5 HEAL_LOCATION_SLATEPORT_CITY,
#define HEAL_LOCATION_RUSTBORO_CITY 6 HEAL_LOCATION_MAUVILLE_CITY,
#define HEAL_LOCATION_FORTREE_CITY 7 HEAL_LOCATION_RUSTBORO_CITY,
#define HEAL_LOCATION_LILYCOVE_CITY 8 HEAL_LOCATION_FORTREE_CITY,
#define HEAL_LOCATION_MOSSDEEP_CITY 9 HEAL_LOCATION_LILYCOVE_CITY,
#define HEAL_LOCATION_SOOTOPOLIS_CITY 10 HEAL_LOCATION_MOSSDEEP_CITY,
#define HEAL_LOCATION_EVER_GRANDE_CITY 11 HEAL_LOCATION_SOOTOPOLIS_CITY,
#define HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE 12 HEAL_LOCATION_EVER_GRANDE_CITY,
#define HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE 13 HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE,
#define HEAL_LOCATION_OLDALE_TOWN 14 HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE,
#define HEAL_LOCATION_DEWFORD_TOWN 15 HEAL_LOCATION_OLDALE_TOWN,
#define HEAL_LOCATION_LAVARIDGE_TOWN 16 HEAL_LOCATION_DEWFORD_TOWN,
#define HEAL_LOCATION_FALLARBOR_TOWN 17 HEAL_LOCATION_LAVARIDGE_TOWN,
#define HEAL_LOCATION_VERDANTURF_TOWN 18 HEAL_LOCATION_FALLARBOR_TOWN,
#define HEAL_LOCATION_PACIFIDLOG_TOWN 19 HEAL_LOCATION_VERDANTURF_TOWN,
#define HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE 20 HEAL_LOCATION_PACIFIDLOG_TOWN,
#define HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR 21 HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE,
#define HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST 22 HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR,
HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST,
};
#endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H #endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H

View File

@@ -3,8 +3,8 @@
struct HealLocation struct HealLocation
{ {
s8 group; s8 mapGroup;
s8 map; s8 mapNum;
u16 x; u16 x;
u16 y; u16 y;
}; };

View File

@@ -11,11 +11,13 @@ INCLUDECONSTS_OUTDIR := include/constants
AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/map_groups.h AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/map_groups.h
AUTO_GEN_TARGETS += $(INCLUDECONSTS_OUTDIR)/layouts.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_DIRS := $(dir $(wildcard $(MAPS_DIR)/*/map.json))
MAP_CONNECTIONS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/connections.inc,$(MAP_DIRS)) MAP_CONNECTIONS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/connections.inc,$(MAP_DIRS))
MAP_EVENTS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/events.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_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) $(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 $@ $(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 $(LAYOUTS_OUTDIR)/layouts.inc $(LAYOUTS_OUTDIR)/layouts_table.inc $(INCLUDECONSTS_OUTDIR)/layouts.h: $(LAYOUTS_DIR)/layouts.json
$(MAPJSON) layouts emerald $< $(LAYOUTS_OUTDIR) $(INCLUDECONSTS_OUTDIR) $(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

1
src/data/.gitignore vendored
View File

@@ -1,3 +1,4 @@
heal_locations.h
wild_encounters.h wild_encounters.h
region_map/region_map_entries.h region_map/region_map_entries.h
region_map/porymap_config.json region_map/porymap_config.json

View File

@@ -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},
};

View File

@@ -10,7 +10,7 @@ u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum)
for (i = 0; i < ARRAY_COUNT(sHealLocations); i++) 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 i + 1;
} }
return HEAL_LOCATION_NONE; return HEAL_LOCATION_NONE;

View File

@@ -659,7 +659,7 @@ void SetWarpDestinationToHealLocation(u8 healLocationId)
{ {
const struct HealLocation *healLocation = GetHealLocation(healLocationId); const struct HealLocation *healLocation = GetHealLocation(healLocationId);
if (healLocation) 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) void SetWarpDestinationToLastHealLocation(void)
@@ -671,7 +671,7 @@ void SetLastHealLocationWarp(u8 healLocationId)
{ {
const struct HealLocation *healLocation = GetHealLocation(healLocationId); const struct HealLocation *healLocation = GetHealLocation(healLocationId);
if (healLocation) 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) void UpdateEscapeWarp(s16 x, s16 y)
@@ -729,7 +729,7 @@ void SetContinueGameWarpToHealLocation(u8 healLocationId)
{ {
const struct HealLocation *healLocation = GetHealLocation(healLocationId); const struct HealLocation *healLocation = GetHealLocation(healLocationId);
if (healLocation) 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) void SetContinueGameWarpToDynamicWarp(int unused)

View File

@@ -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); write_text_file(out_dir + "connections.inc", connections_text);
} }
void process_heal_locations(const vector<string> &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) { string generate_groups_text(Json groups_data) {
ostringstream text; ostringstream text;
@@ -627,9 +690,6 @@ int main(int argc, char *argv[]) {
char *mode_arg = argv[1]; char *mode_arg = argv[1];
string mode(mode_arg); string mode(mode_arg);
if (mode != "layouts" && mode != "map" && mode != "groups")
FATAL_ERROR("ERROR: <mode> must be 'layouts', 'map', or 'groups'.\n");
if (mode == "map") { if (mode == "map") {
if (argc != 6) if (argc != 6)
FATAL_ERROR("USAGE: mapjson map <game-version> <map_file> <layouts_file> <output_dir>\n"); FATAL_ERROR("USAGE: mapjson map <game-version> <map_file> <layouts_file> <output_dir>\n");
@@ -663,8 +723,24 @@ int main(int argc, char *argv[]) {
process_layouts(filepath, output_asm, output_c); process_layouts(filepath, output_asm, output_c);
} }
else if (mode == "heal_locations") {
if (argc < 5)
FATAL_ERROR("USAGE: mapjson heal_locations <game-version> <map_file> [additional_map_files] <output_file>");
infer_separator(argv[3]);
vector<string> 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 { else {
FATAL_ERROR("ERROR: <mode> must be 'layouts', 'map', or 'groups'.\n"); FATAL_ERROR("ERROR: <mode> must be 'layouts', 'map', 'heal_locations', or 'groups'.\n");
} }
return 0; return 0;