From cc3450b8a6604d7c62cd5b53816b34184d185d01 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 31 Oct 2026 23:17:24 -0700 Subject: [PATCH 01/19] devtools: generate FRLG overworld maps as JSON from pokefirered The script reads a map's layout, collision and events from a pokefirered checkout and writes the JSON resource file the FRLG overworld maps load, so a map is regenerated instead of edited by hand. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- devtools/maps/frlg_maps.py | 203 +++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 devtools/maps/frlg_maps.py diff --git a/devtools/maps/frlg_maps.py b/devtools/maps/frlg_maps.py new file mode 100644 index 0000000000..07fe744d0f --- /dev/null +++ b/devtools/maps/frlg_maps.py @@ -0,0 +1,203 @@ +"""Writes FRLG overworld maps as JSON, from the pret/pokefirered decompilation. + +Usage: + python3 devtools/maps/frlg_maps.py --out Packages/Resources/PokemonFRLG/Maps \ + CeruleanCity_PokemonCenter_1F CeruleanCity Route24 \ + CeruleanCave_1F CeruleanCave_2F CeruleanCave_B1F + +Downloads each map's data/maps//map.json, its layout's map.bin and its +tilesets' metatile_attributes.bin at --commit into --cache, then writes +/.json in the schema of Packages/Resources/PokemonFRLG/Maps/README.md. +Warps and connections lead only to maps in the same run: others get an empty +dest_map, or are left out. Named points and flag sets come from POINTS and +FLAG_SETS below. +""" +import argparse +import json +import os +import re +import struct +import subprocess + +COMMIT = 'ce6406d8c2eaf46d543c8a2606de0c3cb1951982' + +# Behaviors with their own tile character; see the README for the legend. +TERRAIN = { + 'MB_TALL_GRASS': '"', 'MB_WARP_DOOR': 'D', 'MB_CAVE_DOOR': 'C', + 'MB_LADDER': 'L', 'MB_UP_ESCALATOR': 'L', 'MB_DOWN_ESCALATOR': 'L', + 'MB_SOUTH_ARROW_WARP': 'v', 'MB_NORTH_ARROW_WARP': '^', + 'MB_EAST_ARROW_WARP': '>', 'MB_WEST_ARROW_WARP': '<', + # Stairs at the side of a room warp like an exit mat, the way the stairs + # go up or down (IsDirectionalStairWarpMetatileBehavior()). + 'MB_UP_RIGHT_STAIR_WARP': '>', 'MB_DOWN_RIGHT_STAIR_WARP': '>', + 'MB_UP_LEFT_STAIR_WARP': '<', 'MB_DOWN_LEFT_STAIR_WARP': '<', + 'MB_IMPASSABLE_NORTH': 'n', 'MB_IMPASSABLE_SOUTH': 's', + 'MB_IMPASSABLE_EAST': 'e', 'MB_IMPASSABLE_WEST': 'w', +} +FLOOR = ('MB_NORMAL', 'MB_CAVE', 'MB_ROCK_STAIRS', 'MB_TALL_GRASS') +DIRECTIONS = {'up': 'north', 'down': 'south', 'left': 'west', 'right': 'east'} + +# Places and flag sets the decompilation doesn't name, written into the map +# they belong to. +# A `*_front` point is where the player stands to talk to someone across a +# counter, or to walk north through a door. +POINTS = { + # Where a new game starts (WarpToPlayersRoom() in src/new_game.c). + 'PalletTown_PlayersHouse_2F': {'start': (6, 6)}, + 'PalletTown': {'oaks_lab_front': (16, 14)}, + # The clerk is across the counter to the west. + 'ViridianCity_Mart': {'clerk_front': (4, 3)}, + 'ViridianCity_PokemonCenter_1F': {'nurse_front': (7, 4)}, + 'PewterCity': {'gym_front': (15, 17)}, + 'PewterCity_PokemonCenter_1F': {'nurse_front': (7, 4)}, + 'PewterCity_Gym': {'brock_front': (6, 6)}, + # The tile in front of the PC. + 'CeruleanCity_PokemonCenter_1F': {'pc': (11, 2), 'nurse_front': (7, 4)}, + # Where the player stands after entering from Cerulean City. + 'CeruleanCave_1F': {'entrance': (33, 21)}, + # Mewtwo's tile. Its battle starts by talking to it from the south. + 'CeruleanCave_B1F': {'mewtwo': (7, 12)}, +} +FLAG_SETS = { + # Set once the player has entered the Hall of Fame. They clear the way + # to Cerulean Cave: its guard, the rival and the Rocket. + 'CeruleanCity': {'after_hall_of_fame': [ + 'FLAG_HIDE_CERULEAN_CAVE_GUARD', + 'FLAG_HIDE_CERULEAN_RIVAL', + 'FLAG_HIDE_CERULEAN_ROCKET', + ]}, +} + + +class Decomp: + def __init__(self, commit, cache): + self.raw = 'https://raw.githubusercontent.com/pret/pokefirered/' + commit + self.cache = os.path.join(cache, commit) + + def path(self, rel): + local = os.path.join(self.cache, rel) + if not os.path.exists(local): + os.makedirs(os.path.dirname(local), exist_ok=True) + subprocess.run(['curl', '-sfL', f'{self.raw}/{rel}', '-o', local], check=True) + return local + + def read(self, rel): + with open(self.path(rel), 'rb') as file: + return file.read() + + +def behaviors(decomp): + names = {} + for line in decomp.read('include/constants/metatile_behaviors.h').decode().splitlines(): + match = re.match(r'#define (MB_\w+)\s+(0x[0-9A-Fa-f]+|\d+)', line) + if match: + names[int(match.group(2), 0)] = match.group(1) + return names + + +def tileset_attributes(decomp, symbol, kind): + name = re.sub(r'([a-z])([A-Z0-9])', r'\1_\2', symbol.replace('gTileset_', '')).lower() + data = decomp.read(f'data/tilesets/{kind}/{name}/metatile_attributes.bin') + return [struct.unpack_from('> 10) & 3, value >> 12 + attributes = primary[metatile] if metatile < 640 else secondary[metatile - 640] + behavior = names.get(attributes & 0x1ff, hex(attributes & 0x1ff)) + row += tile_character(behavior, collision, unhandled) + levels += '%x' % level + tiles.append(row) + elevation.append(levels) + return width, height, tiles, elevation + + +def wander(obj): + movement = obj.get('movement_type', '') + if 'WANDER' not in movement: + return 0, 0 + x = 0 if 'UP_AND_DOWN' in movement else int(obj.get('movement_range_x') or 0) + y = 0 if 'LEFT_AND_RIGHT' in movement else int(obj.get('movement_range_y') or 0) + return x, y + + +def map_json(decomp, name, layouts, names, loaded, unhandled): + source = json.loads(decomp.read(f'data/maps/{name}/map.json')) + width, height, tiles, elevation = grid(decomp, layouts[source['layout']], names, unhandled) + objects = [] + for obj in source.get('object_events', []): + flag = obj.get('flag') or '' + wander_x, wander_y = wander(obj) + objects.append({ + 'x': obj['x'], 'y': obj['y'], + 'kind': obj['graphics_id'].replace('OBJ_EVENT_GFX_', '').lower(), + 'flag': '' if flag == '0' else flag, + 'wander_x': wander_x, 'wander_y': wander_y, + }) + return { + 'name': name, 'width': width, 'height': height, + 'tiles': tiles, 'elevation': elevation, + 'warps': [ + {'x': w['x'], 'y': w['y'], 'dest_map': loaded.get(w['dest_map'], ''), 'dest_warp': int(w['dest_warp_id'])} + for w in source.get('warp_events', []) + ], + 'objects': objects, + 'connections': [ + {'direction': DIRECTIONS[c['direction']], 'offset': c['offset'], 'map': loaded[c['map']]} + for c in (source.get('connections') or []) if c['map'] in loaded + ], + 'points': [{'name': n, 'x': x, 'y': y} for n, (x, y) in POINTS.get(name, {}).items()], + 'flag_sets': [{'name': n, 'flags': flags} for n, flags in FLAG_SETS.get(name, {}).items()], + } + + +def main(): + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument('--commit', default=COMMIT) + parser.add_argument('--cache', default=os.path.expanduser('~/.cache/pokefirered')) + parser.add_argument('--out', required=True) + parser.add_argument('maps', nargs='+') + args = parser.parse_args() + + decomp = Decomp(args.commit, args.cache) + names = behaviors(decomp) + layouts = {l['id']: l for l in json.loads(decomp.read('data/layouts/layouts.json'))['layouts'] if 'id' in l} + loaded = {json.loads(decomp.read(f'data/maps/{m}/map.json'))['id']: m for m in args.maps} + unhandled = {} + os.makedirs(args.out, exist_ok=True) + for name in args.maps: + data = map_json(decomp, name, layouts, names, loaded, unhandled) + with open(os.path.join(args.out, name + '.json'), 'w', newline='\n') as out: + json.dump(data, out, indent=4) + out.write('\n') + if unhandled: + print(f'Non-collision behaviors written as floor: {unhandled}') + + +if __name__ == '__main__': + main() From e770e3fa75caa21a654a98d69e6c358c9f326552 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 31 Oct 2026 23:17:26 -0700 Subject: [PATCH 02/19] FRLG: overworld maps as plain data (tiles, grid, named points, flags) An OverworldMap is plain data: a Grid of Tiles with their elevation, named points, warps and the flag sets a route may depend on, with free functions over it. OverworldMaps loads each map from its JSON resource file, generated by devtools/maps/frlg_maps.py, and names the maps from a new game to Brock. The parse errors are written with std::format. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Overworld/PokemonFRLG_OverworldMap.cpp | 220 +++++++++++++ .../Overworld/PokemonFRLG_OverworldMap.h | 213 +++++++++++++ .../Overworld/PokemonFRLG_OverworldMaps.cpp | 301 ++++++++++++++++++ .../Overworld/PokemonFRLG_OverworldMaps.h | 74 +++++ .../PokemonFRLG_OverworldMaps_Tests.cpp | 163 ++++++++++ .../PokemonFRLG/PokemonFRLG_Tests.cpp | 2 + SerialPrograms/cmake/SourceFiles.cmake | 5 + 7 files changed, 978 insertions(+) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp new file mode 100644 index 0000000000..8ad357066c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp @@ -0,0 +1,220 @@ +/* Overworld Map + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "Common/Cpp/Exceptions.h" +#include "PokemonFRLG_OverworldMap.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +std::optional tile_from_char(char c){ + switch (c){ + case '#': return Tile::WALL; + case 'J': return Tile::LEDGE; + case '.': return Tile::FLOOR; + case '"': return Tile::TALL_GRASS; + case '~': return Tile::WATER; + case 'D': return Tile::DOOR; + case 'C': return Tile::CAVE_ENTRANCE; + case 'L': return Tile::LADDER; + case '^': return Tile::MAT_NORTH; + case 'v': return Tile::MAT_SOUTH; + case '<': return Tile::MAT_WEST; + case '>': return Tile::MAT_EAST; + case 'n': return Tile::CLOSED_NORTH; + case 's': return Tile::CLOSED_SOUTH; + case 'e': return Tile::CLOSED_EAST; + case 'w': return Tile::CLOSED_WEST; + default: return std::nullopt; + } +} + + +bool in_bounds(const MapData& map, const TilePos& point){ + return map.tiles.contains(point); +} +Tile tile_at(const MapData& map, const TilePos& point){ + return in_bounds(map, point) ? map.tiles.at(point) : Tile::WALL; +} +uint8_t elevation_at(const MapData& map, const TilePos& point){ + return map.elevation.contains(point) ? map.elevation.at(point) : ELEVATION_IGNORED; +} + +bool is_wall(const MapData& map, const TilePos& point){ + const Tile tile = tile_at(map, point); + return tile == Tile::WALL || tile == Tile::DOOR || tile == Tile::LEDGE; +} +bool is_ledge(const MapData& map, const TilePos& point){ + return tile_at(map, point) == Tile::LEDGE; +} +bool is_water(const MapData& map, const TilePos& point){ + return tile_at(map, point) == Tile::WATER; +} +bool is_tall_grass(const MapData& map, const TilePos& point){ + return tile_at(map, point) == Tile::TALL_GRASS; +} + +namespace{ + +// The tile closed on its `side` edge. +Tile closed_side(Direction side){ + switch (side){ + case Direction::NORTH: + return Tile::CLOSED_NORTH; + case Direction::SOUTH: + return Tile::CLOSED_SOUTH; + case Direction::EAST: + return Tile::CLOSED_EAST; + case Direction::WEST: + return Tile::CLOSED_WEST; + } + return Tile::WALL; +} +Direction opposite(Direction direction){ + switch (direction){ + case Direction::NORTH: + return Direction::SOUTH; + case Direction::SOUTH: + return Direction::NORTH; + case Direction::EAST: + return Direction::WEST; + case Direction::WEST: + return Direction::EAST; + } + return direction; +} + +} + +bool blocks_entering(const MapData& map, const TilePos& point, Direction direction){ + // Moving south enters by the north edge. + return tile_at(map, point) == closed_side(opposite(direction)); +} +bool blocks_leaving(const MapData& map, const TilePos& point, Direction direction){ + return tile_at(map, point) == closed_side(direction); +} + +bool warps_on_step(const MapData& map, const TilePos& point){ + const Tile tile = tile_at(map, point); + return tile == Tile::CAVE_ENTRANCE || tile == Tile::LADDER; +} +bool is_door(const MapData& map, const TilePos& point){ + return tile_at(map, point) == Tile::DOOR; +} +std::optional exit_mat(const MapData& map, const TilePos& point){ + switch (tile_at(map, point)){ + case Tile::MAT_NORTH: + return Direction::NORTH; + case Tile::MAT_SOUTH: + return Direction::SOUTH; + case Tile::MAT_WEST: + return Direction::WEST; + case Tile::MAT_EAST: + return Direction::EAST; + default: + return std::nullopt; + } +} +bool walks_out_on_arrival(const MapData& map, const TilePos& point){ + const Tile tile = tile_at(map, point); + return tile == Tile::DOOR || tile == Tile::CAVE_ENTRANCE; +} + +void hide_objects(MapData& map, const std::set& flags){ + std::vector shown; + for (const MapObject& object : map.objects){ + if (object.flag.empty() || flags.count(object.flag) == 0){ + shown.push_back(object); + } + } + map.objects = std::move(shown); +} + +const MapObject* object_at(const MapData& map, const TilePos& point){ + for (const MapObject& object : map.objects){ + if (std::abs(object.x - point.x) <= object.wander_x && std::abs(object.y - point.y) <= object.wander_y){ + return &object; + } + } + return nullptr; +} +const MapWarp* warp_at(const MapData& map, const TilePos& point){ + for (const MapWarp& warp : map.warps){ + if (warp.x == point.x && warp.y == point.y){ + return &warp; + } + } + return nullptr; +} + + + +StepKind classify_step(const MapData& map, const PlayerState& state, Direction direction){ + return classify_step_onto(map, state, direction, map, state.position.next(direction)); +} + +StepKind classify_step_onto( + const MapData& from, const PlayerState& state, Direction direction, + const MapData& to, const TilePos& destination +){ + if (is_wall(to, destination) + || blocks_leaving(from, state.position, direction) + || blocks_entering(to, destination, direction) + ){ + return StepKind::BLOCKED; + } + + const uint8_t level = elevation_at(to, destination); + const bool mismatch = state.elevation != ELEVATION_ANY + && level != ELEVATION_ANY && level != ELEVATION_IGNORED + && level != state.elevation; + if (mismatch){ + // CanStopSurfing() and IsPlayerFacingSurfableFishableWater(). + if (state.surfing && level == ELEVATION_GROUND && object_at(to, destination) == nullptr){ + return StepKind::STOP_SURFING; + } + if (!state.surfing && state.elevation == ELEVATION_GROUND && is_water(to, destination)){ + return StepKind::START_SURF; + } + return StepKind::BLOCKED; + } + + if (object_at(to, destination) != nullptr){ + return StepKind::BLOCKED; + } + return StepKind::WALK; +} + +PlayerState after_step(const MapData& map, const PlayerState& state, Direction direction, StepKind kind){ + return after_step_onto(map, state, map, state.position.next(direction), kind); +} + +PlayerState after_step_onto( + const MapData& from, const PlayerState& state, + const MapData& to, const TilePos& destination, StepKind kind +){ + PlayerState next = state; + next.position = destination; + const uint8_t level = elevation_at(to, destination); + if (level != ELEVATION_IGNORED && elevation_at(from, state.position) != ELEVATION_IGNORED){ + next.elevation = level; + } + if (kind == StepKind::START_SURF){ + next.surfing = true; + }else if (kind == StepKind::STOP_SURFING){ + next.surfing = false; + } + return next; +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h new file mode 100644 index 0000000000..83ea60b342 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h @@ -0,0 +1,213 @@ +/* Overworld Map + * + * From: https://github.com/PokemonAutomation/ + * + * An FRLG map as the game sees it: per tile collision, elevation and the + * behaviors that matter for walking (water, one-way edges), plus its warps + * and the objects standing on it. The map data is generated from the + * pret/pokefirered decompilation, and classify_step() follows the game's own + * collision checks (GetCollisionAtCoords() in src/event_object_movement.c), + * so a route planned on these maps is one the game allows. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_OverworldMap_H +#define PokemonAutomation_PokemonFRLG_OverworldMap_H + +#include +#include +#include +#include +#include +#include +#include "Pokemon/Navigation/Pokemon_Grid.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +using Pokemon::Direction; +using Pokemon::TilePos; + + +// A warp from (x, y) to warp `dest_warp` of `dest_map`. Whether and how the +// player takes it depends on the tile there (see Tile). An empty +// `dest_map` leads to a map that isn't loaded. +struct MapWarp{ + int x = 0; + int y = 0; + std::string dest_map; + int dest_warp = 0; +}; + +// An object standing on a tile (person, item ball, rock, Pokemon), which +// blocks it. `kind` is its graphics, e.g. "nurse" or "mewtwo". The game +// hides it once its event flag is set, e.g. a guard who leaves after the +// Hall of Fame; an empty flag means it is always there. A person who wanders +// may stand anywhere up to `wander_x` and `wander_y` tiles from (x, y), so +// all of those tiles count as blocked. +struct MapObject{ + int x = 0; + int y = 0; + std::string kind; + std::string flag; + int wander_x = 0; + int wander_y = 0; +}; + +// Walking off the map's `direction` edge continues on `map`, whose tiles are +// shifted by `offset` along that edge (the decompilation's map connections). +struct MapConnection{ + Direction direction = Direction::NORTH; + int offset = 0; + std::string map; +}; + +// Elevations with a meaning of their own in the game's rules +// (IsElevationMismatchAt() and ObjectEventUpdateElevation() in +// pokefirered). +// Stairs and ladders: they join every elevation. +constexpr uint8_t ELEVATION_ANY = 0; +// Bridges and the like: they don't change the player's elevation. +constexpr uint8_t ELEVATION_IGNORED = 15; +// Ordinary ground: most walkable tiles in the decompilation's map layouts. +// Surf starts and ends here (CanStopSurfing(), and the Surf field move +// checks the player's elevation is 3). +constexpr uint8_t ELEVATION_GROUND = 3; + + +// What a tile is, for walking. The map files write each as one character, +// shown here. +enum class Tile : uint8_t{ + WALL, // '#' collision (wall, cliff) + LEDGE, // 'J' a wall, except that walking into it the way it + // faces hops the player down (not modelled, so the + // planner avoids it) + FLOOR, // '.' + TALL_GRASS, // '"' floor with wild encounters + WATER, // '~' entered only by starting to Surf + DOOR, // 'D' a wall that warps the player who walks north into it + CAVE_ENTRANCE, // 'C' floor that warps the player who steps onto it + LADDER, // 'L' ladder or escalator: floor that warps the player + // who steps onto it + MAT_NORTH, // '^' exit mat, or stairs at the side of a room: floor + MAT_SOUTH, // 'v' that warps the player standing on it who walks + // in the arrow's direction + MAT_WEST, // '<' + MAT_EAST, // '>' + CLOSED_NORTH, // 'n' can't be entered moving south or left moving north + CLOSED_SOUTH, // 's' can't be entered moving north or left moving south + CLOSED_EAST, // 'e' can't be entered moving west or left moving east + CLOSED_WEST, // 'w' can't be entered moving east or left moving west +}; + +// The tile a map file's character stands for, or nothing if it isn't one. +std::optional tile_from_char(char c); + + +// One value per tile of a map, row by row from the top. +template +struct Grid{ + int width = 0; + int height = 0; + std::vector cells; + + bool contains(const TilePos& point) const{ + return 0 <= point.x && point.x < width && 0 <= point.y && point.y < height; + } + // `point` must be inside the grid. + const Cell& at(const TilePos& point) const{ + return cells[(size_t)point.y * width + point.x]; + } +}; + + +// A map as generated from the decompilation (see PokemonFRLG_OverworldMaps.h +// for its JSON form). +struct MapData{ + std::string name; + Grid tiles; + // Walking keeps to one elevation; tiles of elevation 0 (stairs, + // ladders) join elevations, and 15 ignores them. The same size as + // `tiles`. + Grid elevation; + std::vector warps; + std::vector objects; + std::vector connections; + // Places on the map that routes start or end at, by name, e.g. "pc". + std::map points; + // Event flags that are set together, by name, e.g. + // "after_hall_of_fame". + std::map> flag_sets; +}; + +bool in_bounds(const MapData& map, const TilePos& point); +// Out-of-bounds tiles are walls. +Tile tile_at(const MapData& map, const TilePos& point); +uint8_t elevation_at(const MapData& map, const TilePos& point); + +bool is_wall(const MapData& map, const TilePos& point); +bool is_water(const MapData& map, const TilePos& point); +bool is_tall_grass(const MapData& map, const TilePos& point); +bool is_ledge(const MapData& map, const TilePos& point); +// Whether the tile itself refuses a step in `direction`: entering it, or +// leaving it. +bool blocks_entering(const MapData& map, const TilePos& point, Direction direction); +bool blocks_leaving(const MapData& map, const TilePos& point, Direction direction); + +// The warp the game takes on stepping onto this tile (CAVE_ENTRANCE, LADDER). +bool warps_on_step(const MapData& map, const TilePos& point); +// A door, entered by walking north into it. +bool is_door(const MapData& map, const TilePos& point); +// The direction that takes the exit mat on this tile, if it is one. +std::optional exit_mat(const MapData& map, const TilePos& point); +// Arriving on a door or cave entrance, the game walks the player one +// tile south, out of it. +bool walks_out_on_arrival(const MapData& map, const TilePos& point); + +const MapObject* object_at(const MapData& map, const TilePos& point); +const MapWarp* warp_at(const MapData& map, const TilePos& point); + +// Removes the objects the game hides once one of `flags` is set. +void hide_objects(MapData& map, const std::set& flags); + + +// What decides where the player's next step can go. +struct PlayerState{ + TilePos position; + uint8_t elevation = ELEVATION_GROUND; + bool surfing = false; +}; + +enum class StepKind{ + BLOCKED, + WALK, // moves one tile (on land, or on water while surfing) + STOP_SURFING, // moves from water onto land and stops surfing + START_SURF, // blocked, but facing water the player can Surf onto +}; + +// What pressing `direction` once does to the player in `state`. +StepKind classify_step(const MapData& map, const PlayerState& state, Direction direction); + +// The same for a step that crosses into another map: from `state` on `from` +// onto `destination` on `to`. +StepKind classify_step_onto( + const MapData& from, const PlayerState& state, Direction direction, + const MapData& to, const TilePos& destination +); + +// The player after a step of kind WALK, STOP_SURFING or START_SURF (the +// Surf action moves the player onto the water). +PlayerState after_step(const MapData& map, const PlayerState& state, Direction direction, StepKind kind); +PlayerState after_step_onto( + const MapData& from, const PlayerState& state, + const MapData& to, const TilePos& destination, StepKind kind +); + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp new file mode 100644 index 0000000000..92d83d5f5f --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp @@ -0,0 +1,301 @@ +/* Overworld Maps + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Json/JsonArray.h" +#include "Common/Cpp/Json/JsonObject.h" +#include "Common/Cpp/Json/JsonValue.h" +#include "CommonFramework/GlobalAutoPaths.h" +#include "PokemonFRLG_OverworldMaps.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +const char MAP_FOLDER[] = "PokemonFRLG/Maps/"; + +const char* const MAP_NAMES[] = { + // From a new game to Brock. + "PalletTown", + "PalletTown_PlayersHouse_1F", + "PalletTown_PlayersHouse_2F", + "PalletTown_RivalsHouse", + "PalletTown_ProfessorOaksLab", + "Route1", + "ViridianCity", + "ViridianCity_Mart", + "ViridianCity_PokemonCenter_1F", + "Route22", + "Route2", + "Route2_ViridianForest_SouthEntrance", + "ViridianForest", + "Route2_ViridianForest_NorthEntrance", + "PewterCity", + "PewterCity_PokemonCenter_1F", + "PewterCity_Mart", + "PewterCity_Museum_1F", + "PewterCity_Gym", + // Cerulean Cave, for Mewtwo. + "CeruleanCity_PokemonCenter_1F", + "CeruleanCity", + "Route24", + "CeruleanCave_1F", + "CeruleanCave_2F", + "CeruleanCave_B1F", +}; + + +// The readers below take `where`, the source and the path to the object +// being read (e.g. "PokemonFRLG/Maps/CeruleanCity.json: warps[2]."), and +// name the field in what they throw. + +const JsonObject& as_object(const JsonValue& value, const std::string& where){ + const JsonObject* object = value.to_object(); + if (object == nullptr){ + throw ParseException(where + " is not a JSON object."); + } + return *object; +} + +const JsonValue& read_field(const JsonObject& object, const std::string& key, const std::string& where){ + const JsonValue* value = object.get_value(key); + if (value == nullptr){ + throw ParseException(where + key + " is missing."); + } + return *value; +} + +int read_int(const JsonObject& object, const std::string& key, const std::string& where){ + const JsonValue& value = read_field(object, key, where); + if (!value.is_integer()){ + throw ParseException(where + key + " is not an integer."); + } + return (int)value.to_integer_default(); +} + +std::string read_string(const JsonObject& object, const std::string& key, const std::string& where){ + const std::string* text = read_field(object, key, where).to_string(); + if (text == nullptr){ + throw ParseException(where + key + " is not a string."); + } + return *text; +} + +const JsonArray& read_array(const JsonObject& object, const std::string& key, const std::string& where){ + const JsonArray* array = read_field(object, key, where).to_array(); + if (array == nullptr){ + throw ParseException(where + key + " is not an array."); + } + return *array; +} + +// The grid `key`: `height` strings of `width` characters, each read by +// `read_cell`, which gives nothing for a character it doesn't know. +template +Grid read_grid( + const JsonObject& object, const std::string& key, const std::string& where, + int width, int height, std::optional (*read_cell)(char c) +){ + const JsonArray& rows = read_array(object, key, where); + if ((int)rows.size() != height){ + throw ParseException(std::format("{}{} has {} rows, not {}.", where, key, rows.size(), height)); + } + Grid grid{width, height, {}}; + for (int y = 0; y < height; y++){ + const std::string row_where = std::format("{}{}[{}]", where, key, y); + const std::string* row = rows[y].to_string(); + if (row == nullptr || (int)row->size() != width){ + throw ParseException(std::format("{} is not a string of {} tiles.", row_where, width)); + } + for (int x = 0; x < width; x++){ + const std::optional cell = read_cell((*row)[x]); + if (!cell){ + throw ParseException( + row_where + " has unknown tile '" + std::string(1, (*row)[x]) + "' at " + to_string(TilePos{x, y}) + "." + ); + } + grid.cells.push_back(*cell); + } + } + return grid; +} + +// An elevation digit's level. +std::optional elevation_from_char(char digit){ + if ('0' <= digit && digit <= '9'){ + return (uint8_t)(digit - '0'); + } + if ('a' <= digit && digit <= 'f'){ + return (uint8_t)(digit - 'a' + 10); + } + return std::nullopt; +} + +MapWarp read_warp(const JsonObject& object, const std::string& where){ + MapWarp warp; + warp.x = read_int(object, "x", where); + warp.y = read_int(object, "y", where); + warp.dest_map = read_string(object, "dest_map", where); + warp.dest_warp = read_int(object, "dest_warp", where); + return warp; +} + +MapObject read_map_object(const JsonObject& object, const std::string& where){ + MapObject map_object; + map_object.x = read_int(object, "x", where); + map_object.y = read_int(object, "y", where); + map_object.kind = read_string(object, "kind", where); + map_object.flag = read_string(object, "flag", where); + map_object.wander_x = read_int(object, "wander_x", where); + map_object.wander_y = read_int(object, "wander_y", where); + return map_object; +} + +MapConnection read_connection(const JsonObject& object, const std::string& where){ + MapConnection connection; + const std::string direction = read_string(object, "direction", where); + bool known = false; + for (Direction candidate : Pokemon::ALL_DIRECTIONS){ + if (direction == Pokemon::direction_name(candidate)){ + connection.direction = candidate; + known = true; + } + } + if (!known){ + throw ParseException(where + "direction \"" + direction + "\" is not north, east, south or west."); + } + connection.offset = read_int(object, "offset", where); + connection.map = read_string(object, "map", where); + return connection; +} + +std::pair read_point(const JsonObject& object, const std::string& where){ + const std::string name = read_string(object, "name", where); + return {name, TilePos{read_int(object, "x", where), read_int(object, "y", where)}}; +} + +std::pair> read_flag_set(const JsonObject& object, const std::string& where){ + const std::string name = read_string(object, "name", where); + std::set flags; + // Named, since GCC warns of a reference returned for a temporary key. + const std::string key = "flags"; + const JsonArray& array = read_array(object, key, where); + for (size_t c = 0; c < array.size(); c++){ + const std::string* flag = array[c].to_string(); + if (flag == nullptr){ + throw ParseException(std::format("{}{}[{}] is not a string.", where, key, c)); + } + flags.insert(*flag); + } + return {name, std::move(flags)}; +} + +template +std::vector read_list( + const JsonObject& object, const std::string& key, const std::string& where, + Item (*read_item)(const JsonObject& object, const std::string& where) +){ + std::vector items; + const JsonArray& array = read_array(object, key, where); + for (size_t c = 0; c < array.size(); c++){ + const std::string item_where = std::format("{}{}[{}]", where, key, c); + items.push_back(read_item(as_object(array[c], item_where), item_where + ".")); + } + return items; +} + +MapData read_map(const JsonValue& json, const std::string& source){ + const JsonObject& root = as_object(json, source); + const std::string where = source + ": "; + MapData map; + map.name = read_string(root, "name", where); + const int width = read_int(root, "width", where); + const int height = read_int(root, "height", where); + if (width <= 0 || height <= 0){ + throw ParseException(where + "width and height must be positive."); + } + map.tiles = read_grid(root, "tiles", where, width, height, tile_from_char); + map.elevation = read_grid(root, "elevation", where, width, height, elevation_from_char); + map.warps = read_list(root, "warps", where, read_warp); + map.objects = read_list(root, "objects", where, read_map_object); + map.connections = read_list(root, "connections", where, read_connection); + for (auto& point : read_list>(root, "points", where, read_point)){ + map.points.insert(std::move(point)); + } + for (auto& flag_set : read_list>>(root, "flag_sets", where, read_flag_set)){ + map.flag_sets.insert(std::move(flag_set)); + } + return map; +} + +const std::vector& all_maps(){ + static const std::vector MAPS = []{ + std::vector maps; + for (const char* name : MAP_NAMES){ + maps.push_back(load_map(name)); + } + return maps; + }(); + return MAPS; +} + +} + + +MapData parse_map(const std::string& json, const std::string& source){ + return read_map(parse_json(json), source); +} + +MapData load_map(const std::string& name){ + const std::string source = std::string(MAP_FOLDER) + name + ".json"; + MapData map = read_map(load_json_file(RESOURCE_PATH() + source), source); + if (map.name != name){ + throw ParseException(source + ": name is \"" + map.name + "\", not \"" + name + "\"."); + } + return map; +} + +std::vector overworld_maps(const std::set& set_flags){ + std::vector maps = all_maps(); + for (MapData& map : maps){ + hide_objects(map, set_flags); + } + return maps; +} + +TilePos map_point(const std::vector& maps, const std::string& map, const std::string& point){ + for (const MapData& data : maps){ + if (data.name != map){ + continue; + } + const auto iter = data.points.find(point); + if (iter != data.points.end()){ + return iter->second; + } + } + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "No point \"" + point + "\" on map " + map + "."); +} + +std::set map_flag_set(const std::vector& maps, const std::string& name){ + std::set flags; + for (const MapData& map : maps){ + const auto iter = map.flag_sets.find(name); + if (iter != map.flag_sets.end()){ + flags.insert(iter->second.begin(), iter->second.end()); + } + } + return flags; +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h new file mode 100644 index 0000000000..77d30dae4c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h @@ -0,0 +1,74 @@ +/* Overworld Maps + * + * From: https://github.com/PokemonAutomation/ + * + * The FRLG maps the overworld routes know about so far: every map from a + * new game in Pallet Town through Viridian City, Route 2 and Viridian + * Forest to Brock's gym in Pewter City; and Cerulean City, its Pokemon + * Center, Route 24 to its north, and the three floors of Cerulean Cave, + * where Mewtwo waits on B1F. + * + * Each map is a JSON file, Resources/PokemonFRLG/Maps/.json in + * Packages, generated by devtools/maps/frlg_maps.py. The schema (see the + * README.md next to the files) is MapData's: + * + * { + * "name": "CeruleanCity", "width": 48, "height": 40, + * "tiles": ["####~~~...", ...], // `height` rows of `width` tiles + * "elevation": ["0033333...", ...], // the same, one hex digit per tile + * "warps": [{"x": 22, "y": 19, "dest_map": "...", "dest_warp": 1}, ...], + * "objects": [{"x": 1, "y": 13, "kind": "cooltrainer_m", + * "flag": "FLAG_...", "wander_x": 0, "wander_y": 0}, ...], + * "connections": [{"direction": "north", "offset": 12, "map": "Route24"}, ...], + * "points": [{"name": "pc", "x": 11, "y": 2}, ...], + * "flag_sets": [{"name": "after_hall_of_fame", "flags": ["FLAG_...", ...]}, ...] + * } + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_OverworldMaps_H +#define PokemonAutomation_PokemonFRLG_OverworldMaps_H + +#include +#include +#include +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "PokemonFRLG_OverworldMap.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Reads a map from its JSON text. `source` names it in errors. Throws +// ParseException, naming the map and the field, if a field is missing or +// doesn't fit the schema. +MapData parse_map(const std::string& json, const std::string& source); + +// Loads Resources/PokemonFRLG/Maps/.json. Throws FileException if +// the file is missing, and ParseException as parse_map(). +MapData load_map(const std::string& name); + +// Every map, by its decompilation name ("CeruleanCity", "CeruleanCave_B1F", ...), +// with the objects the given event flags hide removed. The files are read +// once, on the first call. +std::vector overworld_maps(const std::set& set_flags = {}); + +// Point `point` of map `map` among `maps`, e.g. ("CeruleanCave_B1F", +// "mewtwo"). Throws InternalProgramError if there is none. +TilePos map_point(const std::vector& maps, const std::string& map, const std::string& point); + +// The flags in flag set `name` of every map among `maps`, e.g. +// "after_hall_of_fame": the flags the Hall of Fame sets, which clear the way +// to Cerulean Cave. +std::set map_flag_set(const std::vector& maps, const std::string& name); + + +void add_tests_OverworldMaps(UnitTestDatabase& database); + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp new file mode 100644 index 0000000000..dc369de97b --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp @@ -0,0 +1,163 @@ +/* Overworld Maps Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "PokemonFRLG_OverworldMaps.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +class Test_OverworldMaps : public UnitTest{ +public: + Test_OverworldMaps(std::string name, std::function body) + : UnitTest("PokemonFRLG::OverworldMaps - " + std::move(name)) + , m_body(std::move(body)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + try{ + return m_body(); + }catch (Exception& e){ + return std::string(e.name()) + ": " + e.message(); + } + } + +private: + std::function m_body; +}; + + +const char* const VALID_MAP = R"({ + "name": "Test", "width": 3, "height": 2, + "tiles": ["#.~", "\"Dv"], + "elevation": ["031", "3f3"], + "warps": [{"x": 1, "y": 1, "dest_map": "Other", "dest_warp": 2}], + "objects": [{"x": 0, "y": 1, "kind": "nurse", "flag": "FLAG_X", "wander_x": 1, "wander_y": 0}], + "connections": [{"direction": "south", "offset": -4, "map": "Other"}], + "points": [{"name": "door", "x": 1, "y": 1}], + "flag_sets": [{"name": "later", "flags": ["FLAG_X", "FLAG_Y"]}] +})"; + +// The ParseException that parsing `json` throws, or empty if it doesn't. +std::string parse_error(const std::string& json){ + try{ + parse_map(json, "Test.json"); + }catch (ParseException& e){ + return e.message(); + } + return ""; +} + +// Whether `text` contains every one of `parts`. +bool mentions(const std::string& text, std::initializer_list parts){ + for (const char* part : parts){ + if (text.find(part) == std::string::npos){ + return false; + } + } + return true; +} + +UnitTestResult test_valid_map(){ + const MapData map = parse_map(VALID_MAP, "Test.json"); + if (map.name != "Test" || map.tiles.width != 3 || map.tiles.height != 2 + || map.tiles.at({0, 1}) != Tile::TALL_GRASS || map.tiles.at({2, 1}) != Tile::MAT_SOUTH + ){ + return "Wrong name, size or tiles."; + } + if (elevation_at(map, {2, 0}) != 1 || elevation_at(map, {1, 1}) != 15){ + return "Wrong elevation."; + } + if (map.warps.size() != 1 || map.warps[0].dest_map != "Other" || map.warps[0].dest_warp != 2){ + return "Wrong warps."; + } + const MapObject* nurse = object_at(map, {1, 1}); + if (map.objects.size() != 1 || nurse == nullptr || nurse->kind != "nurse" || nurse->flag != "FLAG_X"){ + return "Wrong objects."; + } + const MapConnection& connection = map.connections.at(0); + if (connection.direction != Direction::SOUTH || connection.offset != -4 || connection.map != "Other"){ + return "Wrong connections."; + } + if (map.points.at("door") != TilePos{1, 1} || map.flag_sets.at("later") != std::set{"FLAG_X", "FLAG_Y"}){ + return "Wrong points or flag sets."; + } + return true; +} + +UnitTestResult test_missing_field(){ + std::string json = VALID_MAP; + json.replace(json.find("\"elevation\""), 11, "\"heights\""); + const std::string error = parse_error(json); + if (!mentions(error, {"Test.json", "elevation", "missing"})){ + return "Expected an error naming the missing elevation, got: \"" + error + "\""; + } + return true; +} + +UnitTestResult test_bad_field_type(){ + std::string json = VALID_MAP; + json.replace(json.find("\"dest_warp\": 2"), 14, "\"dest_warp\": \"2\""); + const std::string error = parse_error(json); + if (!mentions(error, {"Test.json", "warps[0]", "dest_warp", "integer"})){ + return "Expected an error naming warps[0].dest_warp, got: \"" + error + "\""; + } + return true; +} + +UnitTestResult test_bad_row_length(){ + std::string json = VALID_MAP; + json.replace(json.find("\"#.~\""), 5, "\"#.\""); + const std::string error = parse_error(json); + if (!mentions(error, {"Test.json", "tiles[0]", "string of 3 tiles"})){ + return "Expected an error naming the short row, got: \"" + error + "\""; + } + return true; +} + +UnitTestResult test_unknown_tile(){ + std::string json = VALID_MAP; + json.replace(json.find("\"#.~\""), 5, "\"#.?\""); + const std::string error = parse_error(json); + if (!mentions(error, {"Test.json", "tiles[0]", "unknown tile '?'", "(2, 0)"})){ + return "Expected an error naming the unknown tile, got: \"" + error + "\""; + } + return true; +} + +UnitTestResult test_not_json(){ + const std::string error = parse_error("{\"name\": "); + if (!mentions(error, {"Test.json", "not a JSON object"})){ + return "Expected an error for broken JSON, got: \"" + error + "\""; + } + return true; +} + +} + + +void add_tests_OverworldMaps(UnitTestDatabase& database){ + database.add("valid map", test_valid_map); + database.add("missing field", test_missing_field); + database.add("field of the wrong type", test_bad_field_type); + database.add("row of the wrong length", test_bad_row_length); + database.add("unknown tile", test_unknown_tile); + database.add("not JSON", test_not_json); +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 094a95bfed..3e56b0c844 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -25,6 +25,7 @@ #include "Inference/PokemonFRLG_StatsReader.h" #include "Inference/PokemonFRLG_TrainerIdReader.h" #include "Inference/PokemonFRLG_WildEncounterReader.h" +#include "Overworld/PokemonFRLG_OverworldMaps.h" #include "PokemonFRLG_Navigation.h" #include "Tests/TestUtils.h" @@ -284,6 +285,7 @@ void add_tests(UnitTestDatabase& database){ add_tests_BattleMoveSelectionArrow(database); add_tests_BagDetector(database); add_tests_ExitWildBattle(database); + add_tests_OverworldMaps(database); } diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index b8208f48d2..c78ee29151 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1747,6 +1747,11 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Inference/Sounds/PokemonFRLG_CatchFanfareDetector.h Source/VideoGames/PokemonFRLG/Inference/Sounds/PokemonFRLG_ShinySoundDetector.cpp Source/VideoGames/PokemonFRLG/Inference/Sounds/PokemonFRLG_ShinySoundDetector.h + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp Source/VideoGames/PokemonFRLG/PokemonFRLG_Navigation.cpp Source/VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h Source/VideoGames/PokemonFRLG/PokemonFRLG_Panels.cpp From d0bb032e767fa8b683e97dfea938fd6f61f2a881 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 31 Oct 2026 23:18:21 -0700 Subject: [PATCH 03/19] FRLG: plan overworld routes with the shared leg planner plan_route() runs the shared LegPlanner over an OverworldMap with FRLG's step model (walk, surf, warp, face, ledges) and turns the legs into RouteSteps. Route costs are a map keyed by RouteCost so a program can weigh grass, water and warps. The routes from a new game to Brock are checked by the unit tests. The step text is written with std::format. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Overworld/PokemonFRLG_OverworldRoute.cpp | 712 ++++++++++++++++++ .../Overworld/PokemonFRLG_OverworldRoute.h | 119 +++ .../PokemonFRLG/PokemonFRLG_Tests.cpp | 2 + SerialPrograms/cmake/SourceFiles.cmake | 2 + 4 files changed, 835 insertions(+) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp new file mode 100644 index 0000000000..1bbe90ab9b --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp @@ -0,0 +1,712 @@ +/* Overworld Route + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon/Navigation/Pokemon_LegPlanner.h" +#include "PokemonFRLG_OverworldMaps.h" +#include "PokemonFRLG_OverworldRoute.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +std::string to_string(const MapPosition& position){ + return position.map + " " + to_string(position.point); +} + +std::string to_string(const RouteStep& step){ + std::string text; + switch (step.action){ + case RouteAction::WALK: + text = std::format("walk {} {}", direction_name(step.direction), step.tiles); + if (step.warps){ + text += " (warp)"; + } + if (step.to_wall){ + text += " (to wall)"; + } + break; + case RouteAction::SURF: + text = "surf " + std::string(direction_name(step.direction)); + break; + case RouteAction::FACE: + text = "face " + std::string(direction_name(step.direction)); + break; + } + return text + " -> " + to_string(step.end); +} + + + +const RouteCosts& default_route_costs(){ + static const RouteCosts COSTS{ + {RouteCost::TILE, 1}, + {RouteCost::TURN, 2}, + {RouteCost::WARP, 30}, + {RouteCost::SURF, 40}, + {RouteCost::GRASS_TILE, 20}, + {RouteCost::OPEN_STOP, 8}, + }; + return COSTS; +} + +int route_cost(const RouteCosts& costs, RouteCost kind){ + auto iter = costs.find(kind); + if (iter == costs.end()){ + iter = default_route_costs().find(kind); + } + return iter->second; +} + + + +namespace{ + + +int find_map(const std::vector& maps, const std::string& name){ + for (size_t c = 0; c < maps.size(); c++){ + if (maps[c].name == name){ + return (int)c; + } + } + return -1; +} + +// The player on one of the loaded maps. +struct Located{ + int map = 0; + PlayerState state; + + bool operator==(const Located& other) const{ + return map == other.map + && state.position == other.state.position + && state.elevation == other.state.elevation + && state.surfing == other.state.surfing; + } +}; +struct LocatedHash{ + size_t operator()(const Located& player) const{ + return (((std::hash()(player.state.position) * 31 + player.map) * 16 + + player.state.elevation) * 2) + (player.state.surfing ? 1 : 0); + } +}; + +// What pressing a direction once does to the player. +struct Transition{ + Located next; + RouteAction action = RouteAction::WALK; + bool warped = false; + bool walked_out = false; // the warp ended with the game walking the player out + bool dismounted = false; // stepped off the water onto land +}; + +// The player taking `warp`, or nothing if it leads off the loaded maps. +std::optional take_warp(const std::vector& maps, const MapWarp* warp){ + if (warp == nullptr){ + return std::nullopt; + } + const int destination = find_map(maps, warp->dest_map); + if (destination < 0 || warp->dest_warp < 0 || warp->dest_warp >= (int)maps[destination].warps.size()){ + return std::nullopt; + } + const MapData& map = maps[destination]; + const MapWarp& arrival = map.warps[warp->dest_warp]; + TilePos position{arrival.x, arrival.y}; + Transition transition; + if (walks_out_on_arrival(map, position)){ + position = position.next(Direction::SOUTH); + transition.walked_out = true; + } + transition.next.map = destination; + transition.next.state = PlayerState{position, elevation_at(map, position), false}; + transition.warped = true; + return transition; +} + +// Walking off the map's edge onto the map connected there, if it is loaded. +std::optional cross_edge(const std::vector& maps, const Located& player, Direction direction){ + const MapData& map = maps[player.map]; + for (const MapConnection& connection : map.connections){ + if (connection.direction != direction){ + continue; + } + const int destination = find_map(maps, connection.map); + if (destination < 0){ + return std::nullopt; + } + const MapData& to = maps[destination]; + const TilePos here = player.state.position; + TilePos point; + switch (direction){ + case Direction::NORTH: + point = {here.x - connection.offset, to.tiles.height - 1}; + break; + case Direction::SOUTH: + point = {here.x - connection.offset, 0}; + break; + case Direction::WEST: + point = {to.tiles.width - 1, here.y - connection.offset}; + break; + case Direction::EAST: + point = {0, here.y - connection.offset}; + break; + } + const StepKind kind = classify_step_onto(map, player.state, direction, to, point); + if (kind == StepKind::BLOCKED){ + return std::nullopt; + } + Transition transition; + transition.next.map = destination; + transition.next.state = after_step_onto(map, player.state, to, point, kind); + transition.action = kind == StepKind::START_SURF ? RouteAction::SURF : RouteAction::WALK; + transition.dismounted = kind == StepKind::STOP_SURFING; + return transition; + } + return std::nullopt; +} + +// Pressing `direction` once (field_control_avatar.c): an exit mat or a door +// warps without the player moving, a step onto a ladder or cave entrance +// warps after it, and anything else is a step by the collision rules. +std::optional press(const std::vector& maps, const Located& player, Direction direction){ + const MapData& map = maps[player.map]; + const TilePos here = player.state.position; + if (exit_mat(map, here) == direction){ + return take_warp(maps, warp_at(map, here)); + } + const TilePos ahead = here.next(direction); + if (direction == Direction::NORTH && is_door(map, ahead) && !player.state.surfing){ + return take_warp(maps, warp_at(map, ahead)); + } + + if (!in_bounds(map, ahead)){ + return cross_edge(maps, player, direction); + } + + const StepKind kind = classify_step(map, player.state, direction); + if (kind == StepKind::BLOCKED){ + return std::nullopt; + } + Transition transition; + transition.next = player; + transition.next.state = after_step(map, player.state, direction, kind); + transition.action = kind == StepKind::START_SURF ? RouteAction::SURF : RouteAction::WALK; + transition.dismounted = kind == StepKind::STOP_SURFING; + const TilePos landed = transition.next.state.position; + if (transition.action == RouteAction::WALK && warps_on_step(map, landed) && warp_at(map, landed) != nullptr){ + return take_warp(maps, warp_at(map, landed)); + } + return transition; +} + +// Whether holding `direction` stops the player where they are: a wall, a +// ledge, or water they'd need to Surf onto. A leg that ends there can be +// held for longer than it takes, and walked again after an interruption. A +// person in the way doesn't count, since they may have wandered off, and +// neither does an edge to a map that isn't loaded. +bool stops_at(const std::vector& maps, const Located& player, Direction direction){ + const std::optional transition = press(maps, player, direction); + if (transition){ + return transition->action == RouteAction::SURF; + } + const MapData& map = maps[player.map]; + const TilePos ahead = player.state.position.next(direction); + if (in_bounds(map, ahead)){ + return object_at(map, ahead) == nullptr; + } + for (const MapConnection& connection : map.connections){ + if (connection.direction == direction){ + return false; + } + } + return true; +} + +// The search state: a player, the way they face (4 stands for "not known +// yet", before the first step), and whether they are in the middle of a leg +// that could go on, as opposed to just stopped by a warp or Surf. +// The game's step rules for the shared leg planner. +class StepModel{ +public: + using State = Located; + using StateHash = LocatedHash; + + StepModel(const std::vector& maps, const RouteCosts& costs) + : m_maps(maps) + , m_costs(costs) + {} + + std::optional> press(const State& state, Direction direction) const{ + const std::optional transition = PokemonFRLG::press(m_maps, state, direction); + if (!transition){ + return std::nullopt; + } + Pokemon::Step step; + step.next = transition->next; + step.action = transition->action == RouteAction::SURF ? ACTION_SURF : 0; + // Leaving the water: the player walks at half the speed from here. + step.starts_leg = transition->dismounted; + step.ends_leg = transition->warped || transition->dismounted; + step.warped = transition->warped; + step.facing = transition->walked_out ? Direction::SOUTH : direction; + if (transition->action == RouteAction::SURF){ + step.extra_cost += route_cost(m_costs, RouteCost::SURF); + } + if (transition->warped){ + step.extra_cost += route_cost(m_costs, RouteCost::WARP); + } + if (is_tall_grass(m_maps[step.next.map], step.next.state.position)){ + step.extra_cost += route_cost(m_costs, RouteCost::GRASS_TILE); + } + return step; + } + bool held_at(const State& state, Direction direction) const{ + return stops_at(m_maps, state, direction); + } + + static constexpr int ACTION_SURF = 1; + +private: + const std::vector& m_maps; + const RouteCosts& m_costs; +}; + +Pokemon::LegCosts to_leg_costs(const RouteCosts& costs){ + Pokemon::LegCosts leg_costs; + leg_costs.per_tile = route_cost(costs, RouteCost::TILE); + leg_costs.per_turn = route_cost(costs, RouteCost::TURN); + leg_costs.per_open_stop = route_cost(costs, RouteCost::OPEN_STOP); + return leg_costs; +} + +RouteStep to_route_step(const std::vector& maps, const Pokemon::Leg& leg){ + RouteStep step; + switch (leg.kind){ + case Pokemon::LegKind::WALK: + step.action = RouteAction::WALK; + break; + case Pokemon::LegKind::ACTION: + step.action = RouteAction::SURF; + break; + case Pokemon::LegKind::FACE: + step.action = RouteAction::FACE; + break; + } + step.direction = leg.direction; + step.tiles = leg.kind == Pokemon::LegKind::FACE ? 0 : leg.tiles; + step.warps = leg.warps; + step.surfing = leg.start.state.surfing; + step.to_wall = leg.to_wall; + step.facing_after = leg.facing_after; + step.end = MapPosition{maps[leg.end.map].name, leg.end.state.position}; + return step; +} + +} + + + +std::optional> plan_overworld_route( + const std::vector& maps, + const MapPosition& start, + const RouteGoal& goal, + const RouteCosts& costs, + std::optional start_facing +){ + const int start_map = find_map(maps, start.map); + const int goal_map = find_map(maps, goal.position.map); + if (start_map < 0 || goal_map < 0){ + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Route between maps that aren't loaded."); + } + Located first; + first.map = start_map; + first.state.position = start.point; + first.state.elevation = elevation_at(maps[start_map], start.point); + first.state.surfing = is_water(maps[start_map], start.point); + + const StepModel model(maps, costs); + const auto legs = Pokemon::plan_legs( + model, first, start_facing, + std::function([&](const Located& player){ + return player.map == goal_map && player.state.position == goal.position.point; + }), + goal.facing, to_leg_costs(costs) + ); + if (!legs){ + return std::nullopt; + } + + std::vector route; + for (const Pokemon::Leg& leg : *legs){ + route.push_back(to_route_step(maps, leg)); + } + return route; +} + + +MapPosition follow_overworld_route( + const std::vector& maps, + const MapPosition& start, + const std::vector& route +){ + Located player; + player.map = find_map(maps, start.map); + if (player.map < 0){ + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Route from a map that isn't loaded: " + start.map); + } + player.state.position = start.point; + player.state.elevation = elevation_at(maps[player.map], start.point); + player.state.surfing = is_water(maps[player.map], start.point); + + for (const RouteStep& step : route){ + if (step.action == RouteAction::FACE){ + continue; + } + for (int c = 0; c < step.tiles; c++){ + const std::optional transition = press(maps, player, step.direction); + if (!transition || transition->action != step.action){ + throw InternalProgramError( + nullptr, PA_CURRENT_FUNCTION, + "Step refused at " + to_string(MapPosition{maps[player.map].name, player.state.position}) + ": " + to_string(step) + ); + } + player = transition->next; + } + const MapPosition position{maps[player.map].name, player.state.position}; + if (!(position == step.end)){ + throw InternalProgramError( + nullptr, PA_CURRENT_FUNCTION, + "Ended at " + to_string(position) + " instead of " + to_string(step.end) + ); + } + } + return MapPosition{maps[player.map].name, player.state.position}; +} + + + +namespace{ + +class Test_OverworldRoute : public UnitTest{ +public: + Test_OverworldRoute(std::string name, std::function body) + : UnitTest("PokemonFRLG::OverworldRoute - " + std::move(name)) + , m_body(std::move(body)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + try{ + return m_body(); + }catch (FileException& e){ + // CI runs with upstream Packages, which may not have the maps yet. + return UnitTestResult(UnitTestResult::SKIPPED, "Map files not found: " + e.message()); + }catch (Exception& e){ + return std::string(e.name()) + ": " + e.message(); + } + } + +private: + std::function m_body; +}; + +std::string describe(const std::vector& route){ + std::string text; + for (const RouteStep& step : route){ + text += "\n " + to_string(step); + } + return text; +} + +// A 5x4 map for the step rules: a pond, a raised ledge reached by a stair +// tile, and a tile that can't be entered moving south. +const MapData& small_map(){ + static const MapData MAP = parse_map(R"({ + "name": "Small", "width": 5, "height": 4, + "tiles": ["#####", "#.n.#", "#.~.#", "#####"], + "elevation": ["33333", "33403", "33133", "33333"], + "warps": [], "objects": [], "connections": [], "points": [], "flag_sets": [] + })", "Small"); + return MAP; +} + +UnitTestResult test_step_rules(){ + const MapData& map = small_map(); + PlayerState state{{1, 1}, 3, false}; + if (classify_step(map, state, Direction::EAST) != StepKind::BLOCKED){ + return "Walked from elevation 3 onto elevation 4."; + } + if (classify_step(map, PlayerState{{2, 0}, 3, false}, Direction::SOUTH) != StepKind::BLOCKED){ + return "Entered a north-blocked tile moving south."; + } + state = PlayerState{{1, 2}, 3, false}; + if (classify_step(map, state, Direction::EAST) != StepKind::START_SURF){ + return "Can't start surfing onto the pond."; + } + state = after_step(map, state, Direction::EAST, StepKind::START_SURF); + if (!state.surfing || state.elevation != 1){ + return "Surfing didn't put the player on the water."; + } + if (classify_step(map, state, Direction::EAST) != StepKind::STOP_SURFING){ + return "Can't land from the pond."; + } + if (classify_step(map, PlayerState{{3, 2}, 3, false}, Direction::NORTH) != StepKind::WALK){ + return "Can't step from elevation 3 onto the elevation-0 stair."; + } + return true; +} + +// The maps after the Hall of Fame, which clears the way to Cerulean Cave. +std::vector post_game_maps(){ + return overworld_maps(map_flag_set(overworld_maps(), "after_hall_of_fame")); +} + +MapPosition point_on(const std::vector& maps, const std::string& map, const std::string& point){ + return MapPosition{map, map_point(maps, map, point)}; +} + +const MapData* map_named(const std::vector& maps, const std::string& name){ + const int index = find_map(maps, name); + return index < 0 ? nullptr : &maps[index]; +} + +UnitTestResult test_maps(){ + const std::vector maps = post_game_maps(); + const MapData* b1f = map_named(maps, "CeruleanCave_B1F"); + const MapData* city = map_named(maps, "CeruleanCity"); + if (b1f == nullptr || city == nullptr || map_named(maps, "CeruleanCity_PokemonCenter_1F") == nullptr){ + return "Missing a map."; + } + if (b1f->tiles.width != 40 || b1f->tiles.height != 23 || city->tiles.width != 48 || city->tiles.height != 40){ + return "Unexpected map size."; + } + const TilePos mewtwo_tile = map_point(maps, "CeruleanCave_B1F", "mewtwo"); + const MapObject* mewtwo = object_at(*b1f, mewtwo_tile); + if (mewtwo == nullptr || mewtwo->kind != "mewtwo"){ + return "Mewtwo is not on B1F at " + to_string(mewtwo_tile) + "."; + } + if (object_at(*city, {1, 13}) != nullptr){ + return "The cave guard is still there after the Hall of Fame."; + } + if (object_at(*map_named(overworld_maps(), "CeruleanCity"), {1, 13}) == nullptr){ + return "The cave guard is missing before the Hall of Fame."; + } + return true; +} + +// Plans `start` to `goal`, replays it with the step rules and checks where it ends. +UnitTestResult check_route( + const std::vector& maps, + const MapPosition& start, const RouteGoal& goal, + std::vector& route +){ + const std::optional> planned = plan_overworld_route(maps, start, goal); + if (!planned){ + return "No route from " + to_string(start) + " to " + to_string(goal.position) + "."; + } + route = *planned; + const MapPosition end = follow_overworld_route(maps, start, route); + if (!(end == goal.position)){ + return "Route ends at " + to_string(end) + ":" + describe(route); + } + if (goal.facing && route.back().direction != *goal.facing){ + return "Doesn't end facing " + std::string(direction_name(*goal.facing)) + ":" + describe(route); + } + return true; +} + +// Below Mewtwo, facing it, to talk to it. +RouteGoal facing_mewtwo(const std::vector& maps){ + const TilePos mewtwo = map_point(maps, "CeruleanCave_B1F", "mewtwo"); + return RouteGoal{{"CeruleanCave_B1F", mewtwo.next(Direction::SOUTH)}, Direction::NORTH}; +} + +UnitTestResult test_entrance_to_mewtwo(){ + const std::vector maps = post_game_maps(); + std::vector route; + UnitTestResult result = check_route(maps, point_on(maps, "CeruleanCave_1F", "entrance"), facing_mewtwo(maps), route); + if (result.result != UnitTestResult::PASSED){ + return result; + } + bool surfs = false; + bool reaches_b1f = false; + for (const RouteStep& step : route){ + surfs |= step.action == RouteAction::SURF; + reaches_b1f |= step.warps && step.end.map == "CeruleanCave_B1F"; + } + if (!surfs || !reaches_b1f){ + return "Expected to take the ladder to B1F and to surf:" + describe(route); + } + return true; +} + +UnitTestResult test_pokemon_center_to_mewtwo(){ + const std::vector maps = post_game_maps(); + std::vector route; + UnitTestResult result = check_route( + maps, point_on(maps, "CeruleanCity_PokemonCenter_1F", "pc"), facing_mewtwo(maps), route + ); + if (result.result != UnitTestResult::PASSED){ + return result; + } + // Out through the exit mat, onto the city's step below the door, and + // into the cave by its entrance. + std::vector maps_in_order; + for (const RouteStep& step : route){ + if (step.warps){ + maps_in_order.push_back(step.end.map); + } + } + if (maps_in_order.size() < 2 || maps_in_order[0] != "CeruleanCity" || maps_in_order[1] != "CeruleanCave_1F"){ + return "Expected to leave by the mat and enter the cave next:" + describe(route); + } + if (!(route[0].end.map == "CeruleanCity_PokemonCenter_1F" || route[0].warps)){ + return "Unexpected first step:" + describe(route); + } + return true; +} + +UnitTestResult test_cave_guard_blocks(){ + // Before the Hall of Fame the guard stands in the cave entrance. + const std::vector maps = overworld_maps(); + if (plan_overworld_route(maps, point_on(maps, "CeruleanCity_PokemonCenter_1F", "pc"), facing_mewtwo(maps))){ + return "Planned past the cave guard."; + } + return true; +} + +UnitTestResult test_mewtwo_tile_unreachable(){ + const std::vector maps = post_game_maps(); + const std::optional> route = plan_overworld_route( + maps, + point_on(maps, "CeruleanCave_1F", "entrance"), + {point_on(maps, "CeruleanCave_B1F", "mewtwo"), std::nullopt} + ); + if (route){ + return "Planned a route onto Mewtwo itself:" + describe(*route); + } + return true; +} + +UnitTestResult test_story_maps(){ + const std::vector maps = overworld_maps(); + for (const char* name : { + "PalletTown_PlayersHouse_2F", "PalletTown_ProfessorOaksLab", "Route1", "ViridianCity_Mart", + "Route22", "Route2", "ViridianForest", "PewterCity", "PewterCity_Museum_1F", "PewterCity_Gym", + }){ + if (map_named(maps, name) == nullptr){ + return std::string("Missing map ") + name + "."; + } + } + return true; +} + +// Which maps `route` warps into, in order. +std::vector maps_warped_into(const std::vector& route){ + std::vector maps; + for (const RouteStep& step : route){ + if (step.warps){ + maps.push_back(step.end.map); + } + } + return maps; +} + +UnitTestResult test_bedroom_to_oaks_lab(){ + const std::vector maps = overworld_maps(); + std::vector route; + UnitTestResult result = check_route( + maps, point_on(maps, "PalletTown_PlayersHouse_2F", "start"), + {point_on(maps, "PalletTown", "oaks_lab_front"), Direction::NORTH}, route + ); + if (result.result != UnitTestResult::PASSED){ + return result; + } + const std::vector warped = maps_warped_into(route); + if (warped != std::vector{"PalletTown_PlayersHouse_1F", "PalletTown"}){ + return "Expected to take the stairs and leave by the front door:" + describe(route); + } + return true; +} + +UnitTestResult test_viridian_mart_to_pewter_gym(){ + const std::vector maps = overworld_maps(); + std::vector route; + UnitTestResult result = check_route( + maps, point_on(maps, "ViridianCity_Mart", "clerk_front"), + {point_on(maps, "PewterCity", "gym_front"), Direction::NORTH}, route + ); + if (result.result != UnitTestResult::PASSED){ + return result; + } + const std::vector warped = maps_warped_into(route); + if (std::find(warped.begin(), warped.end(), "ViridianForest") == warped.end()){ + return "Expected to go through Viridian Forest:" + describe(route); + } + return true; +} + +// Two small maps that don't need the map files: a room left by the exit mat +// at its bottom, onto the door of a yard, out of which the game walks the +// player. +const char* const TEST_ROOM_JSON = R"({ + "name": "Room", "width": 5, "height": 4, + "tiles": ["#####", "#...#", "#...#", "##v##"], + "elevation": ["33333", "33333", "33333", "33333"], + "warps": [{"x": 2, "y": 3, "dest_map": "Yard", "dest_warp": 0}], + "objects": [], + "connections": [], "points": [], "flag_sets": [] +})"; +const char* const TEST_YARD_JSON = R"({ + "name": "Yard", "width": 5, "height": 4, + "tiles": ["#####", "##D##", "#...#", "#####"], + "elevation": ["33333", "33333", "33333", "33333"], + "warps": [{"x": 2, "y": 1, "dest_map": "Room", "dest_warp": 0}], + "objects": [], + "connections": [], "points": [], "flag_sets": [] +})"; + +UnitTestResult test_route_through_warp(){ + const std::vector maps{ + parse_map(TEST_ROOM_JSON, "Room"), + parse_map(TEST_YARD_JSON, "Yard"), + }; + std::vector route; + UnitTestResult result = check_route(maps, {"Room", {2, 1}}, {{"Yard", {1, 2}}, std::nullopt}, route); + if (result.result != UnitTestResult::PASSED){ + return result; + } + for (const RouteStep& step : route){ + if (step.warps && step.end.map == "Yard"){ + return true; + } + } + return "Expected to warp into the yard:" + describe(route); +} + +} + +void add_tests_OverworldRoute(UnitTestDatabase& database){ + database.add("route through a warp", test_route_through_warp); + database.add("maps to Brock", test_story_maps); + database.add("bedroom to Oak's Lab", test_bedroom_to_oaks_lab); + database.add("Viridian Mart to Pewter Gym", test_viridian_mart_to_pewter_gym); + database.add("step rules", test_step_rules); + database.add("maps", test_maps); + database.add("Cerulean Cave entrance to Mewtwo", test_entrance_to_mewtwo); + database.add("Cerulean Pokemon Center to Mewtwo", test_pokemon_center_to_mewtwo); + database.add("cave guard blocks the way", test_cave_guard_blocks); + database.add("Mewtwo's tile is blocked", test_mewtwo_tile_unreachable); +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h new file mode 100644 index 0000000000..35afa7a1e4 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h @@ -0,0 +1,119 @@ +/* Overworld Route + * + * From: https://github.com/PokemonAutomation/ + * + * Plans a route over one or more FRLG maps joined by warps: the D-pad legs + * to walk, where to start surfing, and which way to face at the end. FRLG + * moves exactly one tile per step, so a planned route can be walked blind. + * Legs end against walls where that costs little: such a leg can be held + * for longer than it takes, and walked again if something interrupts it. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_OverworldRoute_H +#define PokemonAutomation_PokemonFRLG_OverworldRoute_H + +#include +#include +#include +#include +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "PokemonFRLG_OverworldMap.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +struct MapPosition{ + std::string map; + TilePos point; + + bool operator==(const MapPosition& other) const = default; +}; +std::string to_string(const MapPosition& position); + + +enum class RouteAction{ + WALK, // hold `direction` for `tiles` tiles + SURF, // face `direction`, use Surf, and land on the water there + FACE, // turn to `direction` without moving +}; + +struct RouteStep{ + RouteAction action = RouteAction::WALK; + Direction direction = Direction::NORTH; + int tiles = 0; + // WALK: the last tile is a warp (ladder, stairs), so the screen fades + // and the player arrives on another map. + bool warps = false; + // WALK: on the water, where the player moves twice as fast. + bool surfing = false; + // WALK: a wall stops the player at the end, so the leg can be held for + // longer than it takes and still ends on its tile. + bool to_wall = false; + // Which way the player faces after the step. Arriving at a door or a + // cave mouth, the game walks the player a tile out, facing south. + Direction facing_after = Direction::NORTH; + // Where the player is after the step. + MapPosition end; +}; +std::string to_string(const RouteStep& step); + + +struct RouteGoal{ + MapPosition position; + // Which way to face on arrival, e.g. towards a Pokemon to talk to. + std::optional facing; +}; + +// What the planner weighs a route by. Each is a cost per occurrence. +enum class RouteCost{ + TILE, + TURN, // extra for a leg in a new direction + WARP, // the fade in and out + SURF, // the dialog and the animation + GRASS_TILE, // extra for tall grass, where wild Pokemon appear + // Extra for a leg that ends where the player could keep walking: it has + // to be timed, and if a message or a battle stops it part-way, where + // the player is can only be estimated. A leg that ends at a wall is + // walked again instead. + OPEN_STOP, +}; +using RouteCosts = std::map; + +// TILE 1, TURN 2, WARP 30, SURF 40, GRASS_TILE 20, OPEN_STOP 8. +const RouteCosts& default_route_costs(); + +// `costs`'s cost for `kind`, or the default if it has none. +int route_cost(const RouteCosts& costs, RouteCost kind); + +// The cheapest route from `start`, surfing if it is on water, to +// `goal`, or nothing if there is none. `maps` must hold every map the route +// may pass through; warps to other maps are not taken. Planned with +// Pokemon::plan_legs() on the game's step rules. +std::optional> plan_overworld_route( + const std::vector& maps, + const MapPosition& start, + const RouteGoal& goal, + const RouteCosts& costs = default_route_costs(), + std::optional start_facing = std::nullopt +); + +// Replays `route` from `start` with the game's step rules and returns where +// it ends. Throws InternalProgramError if a step can't be taken as planned. +MapPosition follow_overworld_route( + const std::vector& maps, + const MapPosition& start, + const std::vector& route +); + + +void add_tests_OverworldRoute(UnitTestDatabase& database); + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 3e56b0c844..67d57c3cf2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -26,6 +26,7 @@ #include "Inference/PokemonFRLG_TrainerIdReader.h" #include "Inference/PokemonFRLG_WildEncounterReader.h" #include "Overworld/PokemonFRLG_OverworldMaps.h" +#include "Overworld/PokemonFRLG_OverworldRoute.h" #include "PokemonFRLG_Navigation.h" #include "Tests/TestUtils.h" @@ -286,6 +287,7 @@ void add_tests(UnitTestDatabase& database){ add_tests_BagDetector(database); add_tests_ExitWildBattle(database); add_tests_OverworldMaps(database); + add_tests_OverworldRoute(database); } diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index c78ee29151..f228c379fa 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1752,6 +1752,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h Source/VideoGames/PokemonFRLG/PokemonFRLG_Navigation.cpp Source/VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h Source/VideoGames/PokemonFRLG/PokemonFRLG_Panels.cpp From b734805ce58bac0fa3a2ba550012c414e2339029 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 31 Oct 2026 23:18:24 -0700 Subject: [PATCH 04/19] Pokemon navigation: leg walker with game-supplied movers and interrupts walk_legs() holds a leg for the time its tiles take, through a LegMover the game supplies, and watches a set of LegInterrupts (a battle flash, a dialog) while it does. An interrupt ends the hold, is cleared by the game, and the walker works out how many tiles were walked from the elapsed time and the interrupt's detection delay, then holds the rest. The decisions run against injectable calls so the unit tests cover them without a console. The log and error lines are written with std::format. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../ComputerPrograms_UnitTestRunner.cpp | 1 + .../Pokemon/Navigation/Pokemon_LegWalker.cpp | 70 ++++++ .../Pokemon/Navigation/Pokemon_LegWalker.h | 213 ++++++++++++++++++ .../Navigation/Pokemon_LegWalker_Tests.cpp | 177 +++++++++++++++ .../Navigation/Pokemon_Navigation_Tests.h | 1 + SerialPrograms/cmake/SourceFiles.cmake | 3 + 6 files changed, 465 insertions(+) create mode 100644 SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.cpp create mode 100644 SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.h create mode 100644 SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker_Tests.cpp diff --git a/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp b/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp index 2607f8d0ad..8386a3e306 100644 --- a/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp +++ b/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp @@ -62,6 +62,7 @@ UnitTestDatabase make_UNIT_TESTS_ALL(){ OCR::add_tests(ret); Kernels::add_tests(ret); Pokemon::add_tests_LegPlanner(ret); + Pokemon::add_tests_LegWalker(ret); Pokemon::add_tests_StoryEvents(ret); NintendoSwitch::add_tests_CheckOnlineDetector(ret); NintendoSwitch::add_tests_FailedToConnectDetector(ret); diff --git a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.cpp b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.cpp new file mode 100644 index 0000000000..3c6613295b --- /dev/null +++ b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.cpp @@ -0,0 +1,70 @@ +/* Leg Walker + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "Pokemon_LegWalker.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + + +std::string to_string(const LegSpec& leg){ + return std::format("{} {}{}", direction_name(leg.direction), leg.tiles, leg.to_wall ? " (to wall)" : ""); +} + + +Milliseconds leg_hold(const LegSpec& leg, int tiles){ + if (leg.to_wall){ + return leg.tile_time * (tiles + 2); + } + return leg.tile_time * (tiles - 1) + leg.tile_time / 2; +} + +int tiles_before_interrupt(const LegSpec& leg, Milliseconds elapsed, Milliseconds detection_delay, int remaining){ + const Milliseconds since_first_step = elapsed - detection_delay + leg.tile_time / 2; + if (since_first_step.count() <= 0){ + return 0; + } + return std::clamp((int)(since_first_step / leg.tile_time), 0, remaining); +} + + +LegResult walk_leg_with(const LegSpec& leg, const LegCalls& calls, size_t max_interruptions){ + LegResult result; + int remaining = leg.tiles; + while (true){ + const std::optional outcome = calls.hold_watching(leg_hold(leg, remaining)); + if (!outcome){ + result.tiles = leg.tiles; + return result; + } + result.interruptions++; + if (result.interruptions > max_interruptions){ + calls.fail(std::format("Interrupted {} times on: {}", result.interruptions, to_string(leg))); + } + calls.clear(outcome->interrupt); + const std::string seen = std::format("{} after {}ms", calls.name(outcome->interrupt), outcome->elapsed.count()); + if (leg.to_wall){ + // The wall stops the player on the leg's last tile however far + // they got, so the leg is simply held again. + calls.log(seen + ", walking to the wall again."); + continue; + } + const int walked = tiles_before_interrupt(leg, outcome->elapsed, calls.detection_delay(outcome->interrupt), remaining); + remaining -= walked; + result.exact = false; + calls.log(std::format("{}, about {} tiles walked, {} to go.", seen, walked, remaining)); + if (remaining <= 0){ + result.tiles = leg.tiles; + return result; + } + } +} + + + +} +} diff --git a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.h b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.h new file mode 100644 index 0000000000..14e44f44c3 --- /dev/null +++ b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.h @@ -0,0 +1,213 @@ +/* Leg Walker + * + * From: https://github.com/PokemonAutomation/ + * + * Walks one leg of a plan: holds a direction for the leg's tiles while + * watching for whatever can stop the player part-way (a wild battle, a + * message, a trainer). Each of those is a LegInterrupt the game supplies. + * When one shows, the hold stops, the game clears it, and the rest of the + * leg is walked: a leg to a wall is simply held again, since the wall stops + * the player on its tile; for an open leg, how far the player got is worked + * out from when the interrupt was seen. + * + * How a direction is held (D-pad or stick) and how long a tile takes are + * the game's too, through LegMover. Templated on the console and the + * controller context, like run_until(), so this stays free of any one + * console's types. + * + */ + +#ifndef PokemonAutomation_Pokemon_LegWalker_H +#define PokemonAutomation_Pokemon_LegWalker_H + +#include +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/Time.h" +#include "CommonFramework/Exceptions/OperationFailedExceptionWithScreenshot.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h" +#include "Pokemon_Grid.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + + +// Something that stops the player part-way through a leg. +template +class LegInterrupt{ +public: + virtual ~LegInterrupt() = default; + + virtual std::string name() const = 0; + + // A new watcher for the screen the interruption brings up. + virtual std::unique_ptr make_watcher() const = 0; + + // How long after the step that set it off the watcher fires. The games + // only interrupt between steps, so from this the walker works out how + // many tiles of an open leg were walked. + virtual Milliseconds detection_delay() const = 0; + + // Clears it, leaving the player standing on the overworld, on the same + // tile and facing the same way. + virtual void clear(Console& console, Context& context) const = 0; +}; + +template +using LegInterrupts = std::vector>>; + + +// How the game moves the player. +template +class LegMover{ +public: + virtual ~LegMover() = default; + // Holds `direction` for `duration`, then lets go. + virtual void hold(Context& context, Direction direction, Milliseconds duration) const = 0; +}; + + +// A straight leg, for a player standing still and facing its way. +struct LegSpec{ + Direction direction = Direction::NORTH; + int tiles = 0; + // A wall stops the player after the last tile. + bool to_wall = false; + // How long one tile takes, for this leg's direction and way of moving. + Milliseconds tile_time{0}; +}; +std::string to_string(const LegSpec& leg); + +struct LegResult{ + // Tiles walked, which is `tiles` unless the leg gave up. + int tiles = 0; + // Whether `tiles` is certain: an interrupted open leg is an estimate. + bool exact = true; + size_t interruptions = 0; +}; + + +// How long to hold for `tiles` tiles: an open leg lets go half a tile before +// the last step would end, so the step under way finishes and no other +// starts; a leg to a wall is held two tiles longer than it takes. +Milliseconds leg_hold(const LegSpec& leg, int tiles); + +// How many tiles an open leg had walked when an interrupt was seen +// `elapsed` into its hold, given the interrupt's detection delay. Steps end +// a whole number of tiles into the hold, so this rounds to the nearest. +int tiles_before_interrupt(const LegSpec& leg, Milliseconds elapsed, Milliseconds detection_delay, int remaining); + + +// What one hold reported: nothing if it ran out, or which interrupt showed +// and how long into the hold. +struct HoldOutcome{ + size_t interrupt = 0; + Milliseconds elapsed{0}; +}; + +// The leg's bookkeeping, with the console side passed in, so it can be +// tested with scripted outcomes. `hold_watching` holds for the duration and +// reports the first interrupt seen; `clear` clears interrupt i; +// `detection_delay` is interrupt i's delay; `log` reports progress; `fail` +// throws, and is called after more than `max_interruptions`. +struct LegCalls{ + std::function(Milliseconds hold)> hold_watching; + std::function clear; + std::function detection_delay; + std::function name; + std::function log; + std::function fail; +}; +LegResult walk_leg_with(const LegSpec& leg, const LegCalls& calls, size_t max_interruptions); + + +// Walks `leg`. Throws OperationFailedException if it is interrupted more +// than `max_interruptions` times. +template +LegResult walk_leg( + Console& console, Context& context, + const LegMover& mover, + const LegInterrupts& interrupts, + const LegSpec& leg, + size_t max_interruptions = 5 +){ + auto hold_watching = [&](Milliseconds hold) -> std::optional{ + std::vector> watchers; + std::vector callbacks; + for (const auto& interrupt : interrupts){ + watchers.emplace_back(interrupt->make_watcher()); + callbacks.emplace_back(*watchers.back()); + } + context.wait_for_all_requests(); + WallClock start = current_time(); + const int ret = run_until( + console, context, + [&](Context& context){ + start = current_time(); + mover.hold(context, leg.direction, hold); + }, + callbacks + ); + if (ret < 0){ + return std::nullopt; + } + return HoldOutcome{(size_t)ret, std::chrono::duration_cast(current_time() - start)}; + }; + LegCalls calls; + calls.hold_watching = hold_watching; + calls.clear = [&](size_t index){ interrupts[index]->clear(console, context); }; + calls.detection_delay = [&](size_t index){ return interrupts[index]->detection_delay(); }; + calls.name = [&](size_t index){ return interrupts[index]->name(); }; + calls.log = [&](const std::string& message){ console.log("Leg: " + message, COLOR_ORANGE); }; + calls.fail = [&](const std::string& message){ + OperationFailedExceptionWithScreenshot::fire(ErrorReportMode::SEND_ERROR_REPORT, message, console); + }; + return walk_leg_with(leg, calls, max_interruptions); +} + + +// After a leg: waits `watch` for an interrupt the last step set off, which +// shows after the hold has ended, and clears it. Throws +// OperationFailedException after `max_interruptions` in a row. +template +void clear_late_interrupts( + Console& console, Context& context, + const LegInterrupts& interrupts, + Milliseconds watch, + size_t max_interruptions = 5 +){ + for (size_t count = 0; ; count++){ + std::vector> watchers; + std::vector callbacks; + for (const auto& interrupt : interrupts){ + watchers.emplace_back(interrupt->make_watcher()); + callbacks.emplace_back(*watchers.back()); + } + context.wait_for_all_requests(); + const int ret = wait_until(console, context, watch, callbacks); + if (ret < 0){ + return; + } + if (count >= max_interruptions){ + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + std::format("Interrupted {} times in a row after a leg.", count), + console + ); + } + console.log("Leg: " + interrupts[ret]->name() + " at the end of the leg.", COLOR_ORANGE); + interrupts[ret]->clear(console, context); + } +} + + + + +} +} +#endif diff --git a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker_Tests.cpp b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker_Tests.cpp new file mode 100644 index 0000000000..ac3aa379ee --- /dev/null +++ b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker_Tests.cpp @@ -0,0 +1,177 @@ +/* Leg Walker Tests + * + * From: https://github.com/PokemonAutomation/ + * + * The leg walker's bookkeeping, with holds that report scripted + * interruptions instead of a console. + * + */ + +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon_LegWalker.h" +#include "Pokemon_Navigation_Tests.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + + +namespace{ + +using namespace std::chrono_literals; + +constexpr Milliseconds TILE = 267ms; +constexpr Milliseconds DELAY = 300ms; + +// Holds that report the scripted outcomes in order, then run out. +struct ScriptedLeg{ + std::deque> outcomes; + std::vector holds; + std::vector cleared; + + LegCalls calls(){ + LegCalls calls; + calls.hold_watching = [this](Milliseconds hold) -> std::optional{ + holds.push_back(hold); + if (outcomes.empty()){ + return std::nullopt; + } + std::optional outcome = outcomes.front(); + outcomes.pop_front(); + return outcome; + }; + calls.clear = [this](size_t index){ cleared.push_back(index); }; + calls.detection_delay = [](size_t){ return DELAY; }; + calls.name = [](size_t){ return std::string("a battle"); }; + calls.log = [](const std::string&){}; + calls.fail = [](const std::string& message){ throw std::runtime_error(message); }; + return calls; + } +}; + +// An interrupt set off by step `step`, seen DELAY after it ends. +HoldOutcome after_step(int step){ + return HoldOutcome{0, TILE * step + DELAY}; +} + + +UnitTestResult test_hold_times(){ + const LegSpec open{Direction::EAST, 4, false, TILE}; + const LegSpec wall{Direction::EAST, 4, true, TILE}; + if (leg_hold(open, 4) != TILE * 3 + TILE / 2){ + return std::format("Open leg: {}ms", leg_hold(open, 4).count()); + } + if (leg_hold(wall, 4) != TILE * 6){ + return std::format("Wall leg: {}ms", leg_hold(wall, 4).count()); + } + return true; +} + +UnitTestResult test_tiles_before_interrupt(){ + const LegSpec leg{Direction::EAST, 8, false, TILE}; + for (int step = 0; step <= 8; step++){ + for (Milliseconds jitter : {-100ms, 0ms, 100ms}){ + const int walked = tiles_before_interrupt(leg, TILE * step + DELAY + jitter, DELAY, 8); + if (walked != step){ + return std::format("Step {} seen {}ms off read as {}", step, jitter.count(), walked); + } + } + } + if (tiles_before_interrupt(leg, 50ms, DELAY, 8) != 0){ + return "An interrupt from before the leg should count no tiles."; + } + if (tiles_before_interrupt(leg, TILE * 20, DELAY, 3) != 3){ + return "Should not count more tiles than remain."; + } + return true; +} + +UnitTestResult test_wall_leg_walked_again(){ + ScriptedLeg script; + script.outcomes = {after_step(2)}; + const LegSpec leg{Direction::NORTH, 6, true, TILE}; + const LegResult result = walk_leg_with(leg, script.calls(), 5); + if (script.holds.size() != 2 || script.holds[1] != leg_hold(leg, 6)){ + return "Expected the whole leg held again."; + } + if (!result.exact || result.interruptions != 1 || script.cleared.size() != 1){ + return "Expected an exact result after one interruption."; + } + return true; +} + +UnitTestResult test_open_leg_rest_walked(){ + ScriptedLeg script; + script.outcomes = {after_step(2)}; + const LegSpec leg{Direction::NORTH, 6, false, TILE}; + const LegResult result = walk_leg_with(leg, script.calls(), 5); + if (script.holds.size() != 2 || script.holds[1] != leg_hold(leg, 4)){ + return "Expected the remaining 4 tiles held."; + } + if (result.exact){ + return "An interrupted open leg is an estimate."; + } + return true; +} + +UnitTestResult test_open_leg_interrupted_at_end(){ + ScriptedLeg script; + script.outcomes = {after_step(6)}; + const LegSpec leg{Direction::NORTH, 6, false, TILE}; + walk_leg_with(leg, script.calls(), 5); + if (script.holds.size() != 1){ + return "Nothing was left to walk after the last step."; + } + return true; +} + +UnitTestResult test_too_many_interruptions(){ + ScriptedLeg script; + for (int c = 0; c < 4; c++){ + script.outcomes.push_back(after_step(0)); + } + const LegSpec leg{Direction::NORTH, 6, true, TILE}; + try{ + walk_leg_with(leg, script.calls(), 3); + }catch (std::runtime_error&){ + return true; + } + return "Expected to give up after 3 interruptions."; +} + + +class Test_LegWalker : public UnitTest{ +public: + Test_LegWalker(std::string name, std::function body) + : UnitTest("Pokemon::LegWalker - " + std::move(name)) + , m_body(std::move(body)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + return m_body(); + } + +private: + std::function m_body; +}; + +} + + +void add_tests_LegWalker(UnitTestDatabase& database){ + database.add("hold times", test_hold_times); + database.add("tiles before an interrupt", test_tiles_before_interrupt); + database.add("a wall leg is walked again", test_wall_leg_walked_again); + database.add("an open leg walks the rest", test_open_leg_rest_walked); + database.add("an open leg interrupted at its end", test_open_leg_interrupted_at_end); + database.add("gives up after too many interruptions", test_too_many_interruptions); +} + + + +} +} diff --git a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_Navigation_Tests.h b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_Navigation_Tests.h index e6d709afce..2cc8ae26f3 100644 --- a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_Navigation_Tests.h +++ b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_Navigation_Tests.h @@ -14,6 +14,7 @@ namespace Pokemon{ void add_tests_LegPlanner(UnitTestDatabase& database); +void add_tests_LegWalker(UnitTestDatabase& database); void add_tests_StoryEvents(UnitTestDatabase& database); diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index f228c379fa..48edc3ada2 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1446,6 +1446,9 @@ file(GLOB LIBRARY_SOURCES Source/Pokemon/Navigation/Pokemon_Grid.h Source/Pokemon/Navigation/Pokemon_LegPlanner.h Source/Pokemon/Navigation/Pokemon_LegPlanner_Tests.cpp + Source/Pokemon/Navigation/Pokemon_LegWalker.cpp + Source/Pokemon/Navigation/Pokemon_LegWalker.h + Source/Pokemon/Navigation/Pokemon_LegWalker_Tests.cpp Source/Pokemon/Navigation/Pokemon_Navigation_Tests.h Source/Pokemon/Navigation/Pokemon_StoryEvents.cpp Source/Pokemon/Navigation/Pokemon_StoryEvents.h From 6952e6c5a810ea9289c41b7988a0934c0ab3afe1 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 31 Oct 2026 23:19:22 -0700 Subject: [PATCH 05/19] FRLG: read which way the standing player faces read_player_facing() matches the player sprite at the screen's centre against the four standing sprites, loaded from the sprite sheet in the resources, and gives the Direction the player faces, or nothing while they move. The unit tests run on screenshots of each facing and skip when their files are missing. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../PokemonFRLG_PlayerFacingReader.cpp | 252 ++++++++++++++++++ .../PokemonFRLG_PlayerFacingReader.h | 58 ++++ .../PokemonFRLG/PokemonFRLG_Tests.cpp | 2 + SerialPrograms/cmake/SourceFiles.cmake | 2 + 4 files changed, 314 insertions(+) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.h diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp new file mode 100644 index 0000000000..601dd21086 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp @@ -0,0 +1,252 @@ +/* Player Facing Reader + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include "Common/Cpp/Color.h" +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "CommonFramework/GlobalAutoPaths.h" +#include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonFramework/ImageTypes/ImageRGB32.h" +#include "CommonFramework/ImageTypes/ImageViewRGB32.h" +#include "VideoGames/PokemonFRLG/PokemonFRLG_Settings.h" +#include "PokemonFRLG_PlayerFacingReader.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// The sprite sheet's frames are 16x32, and the standing ones are 0 (south), +// 1 (north) and 2 (west). Rows 12 to 30 are drawn; the rest is empty. +const char PLAYER_SPRITE_SHEET[] = "PokemonFRLG/PlayerSprites/red_normal.png"; +constexpr int SHEET_FRAME_WIDTH = 16; +constexpr int SHEET_FIRST_ROW = 12; + +constexpr int SPRITE_WIDTH = 16; +constexpr int SPRITE_ROWS = 19; +// Where the sprite's first drawn row sits on the GBA's 240x160 screen while +// the camera follows the player. Measured on the console. +constexpr int SPRITE_X = 112; +constexpr int SPRITE_Y = 56 + 12; +constexpr int GBA_WIDTH = 240; +constexpr int GBA_HEIGHT = 160; + +// Average difference per channel over the sprite's pixels. On the console a +// match scored about 12 and the next best sprite over 50. +constexpr double MATCH_MAX = 25; +constexpr double MATCH_MARGIN = 2.0; + + +ImageRGB32 sheet_frame(const ImageViewRGB32& sheet, int frame){ + return sheet.sub_image(frame * SHEET_FRAME_WIDTH, SHEET_FIRST_ROW, SPRITE_WIDTH, SPRITE_ROWS).copy(); +} + +// How far the screen differs from `sprite`, drawn `dy` GBA pixels lower. +double difference(const ImageViewRGB32& game, const ImageViewRGB32& sprite, bool mirror, int dy){ + const double scale_x = (double)game.width() / GBA_WIDTH; + const double scale_y = (double)game.height() / GBA_HEIGHT; + long total = 0; + int pixels = 0; + for (int row = 0; row < SPRITE_ROWS; row++){ + for (int col = 0; col < SPRITE_WIDTH; col++){ + const Color expected(sprite.pixel(mirror ? SPRITE_WIDTH - 1 - col : col, row)); + if (expected.alpha() == 0){ + continue; + } + const size_t x = (size_t)((SPRITE_X + col + 0.5) * scale_x); + const size_t y = (size_t)((SPRITE_Y + dy + row + 0.5) * scale_y); + if (x >= game.width() || y >= game.height()){ + return std::numeric_limits::max(); + } + const Color pixel(game.pixel(x, y)); + total += std::abs((int)pixel.red() - expected.red()); + total += std::abs((int)pixel.green() - expected.green()); + total += std::abs((int)pixel.blue() - expected.blue()); + pixels++; + } + } + return pixels == 0 ? std::numeric_limits::max() : (double)total / (3 * pixels); +} + +} + + +const PlayerSprites& player_sprites(){ + static const PlayerSprites SPRITES = []{ + const ImageRGB32 sheet(RESOURCE_PATH() + PLAYER_SPRITE_SHEET); + return PlayerSprites{sheet_frame(sheet, 0), sheet_frame(sheet, 1), sheet_frame(sheet, 2)}; + }(); + return SPRITES; +} + + +std::optional read_player_facing(const ImageViewRGB32& screen){ + const ImageViewRGB32 game = extract_box_reference(screen, GameSettings::instance().GAME_BOX); + return match_player_facing(game, player_sprites()); +} + +std::optional match_player_facing(const ImageViewRGB32& game, const PlayerSprites& sprites){ + struct Candidate{ + Direction direction; + const ImageViewRGB32& sprite; + bool mirror; + }; + const Candidate candidates[] = { + {Direction::SOUTH, sprites.south, false}, + {Direction::NORTH, sprites.north, false}, + {Direction::WEST, sprites.west, false}, + {Direction::EAST, sprites.west, true}, + }; + + double best = std::numeric_limits::max(); + double second = best; + Direction facing = Direction::SOUTH; + for (const Candidate& candidate : candidates){ + // A pixel either way, for a box that is slightly off. + double score = std::numeric_limits::max(); + for (int dy = -1; dy <= 1; dy++){ + score = std::min(score, difference(game, candidate.sprite, candidate.mirror, dy)); + } + if (score < best){ + second = best; + best = score; + facing = candidate.direction; + }else{ + second = std::min(second, score); + } + } + if (best > MATCH_MAX || second < best * MATCH_MARGIN){ + return std::nullopt; + } + return facing; +} + + + +namespace{ + +class Test_PlayerFacingReader : public UnitTest{ +public: + Test_PlayerFacingReader(const std::string& image, std::optional expected) + : UnitTest("PokemonFRLG::PlayerFacingReader - " + image) + , m_image(UNIT_TEST_RESOURCE_PATH() + image) + , m_expected(expected) + {} + + virtual UnitTestResult run(Logger& logger, CancellableScope& scope) const override{ + std::optional facing; + try{ + facing = read_player_facing(ImageRGB32(m_image)); + }catch (FileException& e){ + // The screenshots and the sprite sheet aren't in CI's resources yet. + return UnitTestResult(UnitTestResult::SKIPPED, "File not found: " + e.message()); + } + if (facing == m_expected){ + return true; + } + return std::string("Read ") + (facing ? direction_name(*facing) : "nothing"); + } + +private: + std::string m_image; + std::optional m_expected; +}; + +// Made-up sprites, so the matching is tested without the sprite sheet: +// solid red facing south, solid blue facing north, and green on the left +// half facing west. +PlayerSprites fixture_sprites(){ + PlayerSprites sprites{ + ImageRGB32(SPRITE_WIDTH, SPRITE_ROWS), + ImageRGB32(SPRITE_WIDTH, SPRITE_ROWS), + ImageRGB32(SPRITE_WIDTH, SPRITE_ROWS), + }; + sprites.south.fill(0xffff0000); + sprites.north.fill(0xff0000ff); + sprites.west.fill(0x00000000); + for (int row = 0; row < SPRITE_ROWS; row++){ + for (int col = 0; col < SPRITE_WIDTH / 2; col++){ + sprites.west.pixel(col, row) = 0xff00ff00; + } + } + return sprites; +} + +// A grey GBA screen at twice its size, with `sprite` drawn where the +// player stands. +ImageRGB32 fixture_screen(const ImageViewRGB32* sprite, bool mirror){ + ImageRGB32 game(2 * GBA_WIDTH, 2 * GBA_HEIGHT); + game.fill(0xff808080); + for (int row = 0; sprite != nullptr && row < SPRITE_ROWS; row++){ + for (int col = 0; col < SPRITE_WIDTH; col++){ + const uint32_t pixel = sprite->pixel(mirror ? SPRITE_WIDTH - 1 - col : col, row); + if (Color(pixel).alpha() == 0){ + continue; + } + for (int dy = 0; dy < 2; dy++){ + for (int dx = 0; dx < 2; dx++){ + game.pixel(2 * (SPRITE_X + col) + dx, 2 * (SPRITE_Y + row) + dy) = pixel; + } + } + } + } + return game; +} + +class Test_PlayerFacingFixture : public UnitTest{ +public: + Test_PlayerFacingFixture() + : UnitTest("PokemonFRLG::PlayerFacingReader - made-up sprites") + {} + + virtual UnitTestResult run(Logger& logger, CancellableScope& scope) const override{ + const PlayerSprites sprites = fixture_sprites(); + struct Case{ + const ImageViewRGB32* sprite; + bool mirror; + std::optional expected; + }; + const Case cases[] = { + {&sprites.south, false, Direction::SOUTH}, + {&sprites.north, false, Direction::NORTH}, + {&sprites.west, false, Direction::WEST}, + {&sprites.west, true, Direction::EAST}, + {nullptr, false, std::nullopt}, + }; + for (const Case& test : cases){ + const std::optional facing = match_player_facing(fixture_screen(test.sprite, test.mirror), sprites); + if (facing != test.expected){ + return std::string("Read ") + (facing ? direction_name(*facing) : "nothing") + + " instead of " + (test.expected ? direction_name(*test.expected) : "nothing"); + } + } + return true; + } +}; + +} + +void add_tests_PlayerFacingReader(UnitTestDatabase& database){ + database.add(); + // LeafGreen on the Switch, captured with a 1080p card. + database.add("PokemonFRLG/PlayerFacingReader/South-Route24.png", Direction::SOUTH); + database.add("PokemonFRLG/PlayerFacingReader/North-Route24.png", Direction::NORTH); + database.add("PokemonFRLG/PlayerFacingReader/South-CeruleanCave.png", Direction::SOUTH); + database.add("PokemonFRLG/PlayerFacingReader/North-CeruleanCave.png", Direction::NORTH); + database.add("PokemonFRLG/PlayerFacingReader/Surfing.png", std::nullopt); + database.add("PokemonFRLG/PlayerFacingReader/Bag.png", std::nullopt); +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.h new file mode 100644 index 0000000000..fb682fde18 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.h @@ -0,0 +1,58 @@ +/* Player Facing Reader + * + * From: https://github.com/PokemonAutomation/ + * + * Which way the player faces, read from the overworld. The camera keeps the + * player on the same spot of the screen, so the reader compares that spot + * with the player's standing sprites from pret/pokefirered, on the sprite's + * own pixels only, so the ground behind doesn't matter. The sprites come + * from Packages: Resources/PokemonFRLG/PlayerSprites/red_normal.png is the + * decompilation's graphics/object_events/pics/people/red_normal.png. + * + * Only the walking player is known: surfing and biking use other sprites. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_PlayerFacingReader_H +#define PokemonAutomation_PokemonFRLG_PlayerFacingReader_H + +#include +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "CommonFramework/ImageTypes/ImageRGB32.h" +#include "CommonFramework/ImageTypes/ImageViewRGB32.h" +#include "PokemonFRLG_OverworldMap.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// The standing player's frames, as the game draws them, with transparent +// pixels at alpha 0. Facing east is facing west mirrored. +struct PlayerSprites{ + ImageRGB32 south; + ImageRGB32 north; + ImageRGB32 west; +}; + +// Loads the frames once. Throws FileException if the file is missing. +const PlayerSprites& player_sprites(); + + +// The way the standing player faces, or nothing if no standing sprite +// matches clearly (surfing, on the bike, in a menu, mid-step). +std::optional read_player_facing(const ImageViewRGB32& screen); + +// The same on `game`, the GBA's 240x160 screen at any scale, already cut +// out of the console's. +std::optional match_player_facing(const ImageViewRGB32& game, const PlayerSprites& sprites); + + +void add_tests_PlayerFacingReader(UnitTestDatabase& database); + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 67d57c3cf2..0400b3f051 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -27,6 +27,7 @@ #include "Inference/PokemonFRLG_WildEncounterReader.h" #include "Overworld/PokemonFRLG_OverworldMaps.h" #include "Overworld/PokemonFRLG_OverworldRoute.h" +#include "Overworld/PokemonFRLG_PlayerFacingReader.h" #include "PokemonFRLG_Navigation.h" #include "Tests/TestUtils.h" @@ -288,6 +289,7 @@ void add_tests(UnitTestDatabase& database){ add_tests_ExitWildBattle(database); add_tests_OverworldMaps(database); add_tests_OverworldRoute(database); + add_tests_PlayerFacingReader(database); } diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 48edc3ada2..23c3d63169 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1757,6 +1757,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.h Source/VideoGames/PokemonFRLG/PokemonFRLG_Navigation.cpp Source/VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h Source/VideoGames/PokemonFRLG/PokemonFRLG_Panels.cpp From ab9a22e0b78ab856f777235461e06a2faba28ba0 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sat, 31 Oct 2026 23:19:23 -0700 Subject: [PATCH 06/19] FRLG: walk overworld routes with the leg walker walk_route() runs a planned route's steps through the shared leg walker: a LegMover that holds the D-pad for a leg, and interrupts for the battle flash, a late wild battle dialog and the repel wearing off, each cleared by the FRLG routine that handles it. A face step is checked with the player facing reader. BattleFlashWatcher sees the screen flashes that start a wild battle from the brightness of recent frames. The repel log line is written with std::format. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../PokemonFRLG_BattleFlashWatcher.cpp | 76 +++++ .../PokemonFRLG_BattleFlashWatcher.h | 46 +++ .../Overworld/PokemonFRLG_OverworldWalk.cpp | 314 ++++++++++++++++++ .../Overworld/PokemonFRLG_OverworldWalk.h | 69 ++++ SerialPrograms/cmake/SourceFiles.cmake | 4 + 5 files changed, 509 insertions(+) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.cpp new file mode 100644 index 0000000000..f7174de9b8 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.cpp @@ -0,0 +1,76 @@ +/* Battle Flash Watcher + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonFramework/ImageTools/ImageStats.h" +#include "CommonFramework/ImageTypes/ImageViewRGB32.h" +#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" +#include "VideoGames/PokemonFRLG/PokemonFRLG_Settings.h" +#include "PokemonFRLG_BattleFlashWatcher.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +using namespace std::chrono_literals; + + +namespace{ + +// On the console a flash took the screen from 145 to 98 (two thirds) and +// back within 80ms, twice in about 300ms. +constexpr std::chrono::milliseconds FLASH_WINDOW = 400ms; +constexpr double FLASH_DARKER = 0.8; // the dip is below this much of the brightness before it +constexpr double FLASH_FLOOR = 0.4; // and above this much: lower is a fade to black +constexpr double FLASH_RECOVERY = 1.1; // then the screen comes back to this much of the dip + +} + + +BattleFlashWatcher::BattleFlashWatcher(Color color) + : VisualInferenceCallback("BattleFlashWatcher") + , m_color(color) +{} + +void BattleFlashWatcher::make_overlays(VideoOverlaySet& items) const{ + items.add(m_color, GameSettings::instance().GAME_BOX); +} + +bool BattleFlashWatcher::process_frame(const ImageViewRGB32& frame, WallClock timestamp){ + const ImageViewRGB32 game_screen = extract_box_reference(frame, GameSettings::instance().GAME_BOX); + const double brightness = image_stats(game_screen).average.sum(); + while (!m_history.empty() && timestamp - m_history.front().first > FLASH_WINDOW){ + m_history.pop_front(); + } + + // The brightest frame before the screen first dips, and the darkest + // frame since. + double before = 0; + double dip = -1; + for (const auto& item : m_history){ + if (dip < 0){ + if (item.second < before * FLASH_DARKER){ + dip = item.second; + }else{ + before = std::max(before, item.second); + } + }else{ + dip = std::min(dip, item.second); + } + } + m_history.emplace_back(timestamp, brightness); + + return dip >= 0 + && dip > before * FLASH_FLOOR + && brightness > dip * FLASH_RECOVERY; +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h new file mode 100644 index 0000000000..a705d3473c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h @@ -0,0 +1,46 @@ +/* Battle Flash Watcher + * + * From: https://github.com/PokemonAutomation/ + * + * Every wild battle starts with the overworld flashing dark twice, within + * half a second of the step that set it off, before the battle's own wipe. + * The wipe and the battle screen differ by map and come seconds later, so + * the flash is the earliest and the same sign of a battle everywhere. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_BattleFlashWatcher_H +#define PokemonAutomation_PokemonFRLG_BattleFlashWatcher_H + +#include +#include +#include "Common/Cpp/Color.h" +#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Fires when the game screen darkens by a fifth or more and starts to come +// back within a moment. A warp's fade, or the Switch dimming its screen, +// only darkens and so doesn't count. +class BattleFlashWatcher : public VisualInferenceCallback{ +public: + BattleFlashWatcher(Color color); + + virtual void make_overlays(VideoOverlaySet& items) const override; + virtual bool process_frame(const ImageViewRGB32& frame, WallClock timestamp) override; + +private: + Color m_color; + // Recent brightness of the game screen. + std::deque> m_history; +}; + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp new file mode 100644 index 0000000000..202b5e076f --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp @@ -0,0 +1,314 @@ +/* Overworld Walk + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "CommonFramework/Exceptions/OperationFailedExceptionWithScreenshot.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_BattleDialogs.h" +#include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h" +#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h" +#include "VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h" +#include "PokemonFRLG_PlayerFacingReader.h" +#include "PokemonFRLG_OverworldWalk.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +using namespace std::chrono_literals; + + +namespace{ + +constexpr Milliseconds TILE_TIME = 267ms; // 16 frames at 60 fps, measured exact over 15 tiles +constexpr Milliseconds SURF_TILE_TIME = 133ms; // the game moves a surfing player at running speed +constexpr Milliseconds TURN_TAP = 40ms; // turns a player facing another way, without a step +constexpr Milliseconds TURN_SETTLE = 300ms; +constexpr Milliseconds FACE_HOLD = 40ms; // short enough to turn without stepping +constexpr Milliseconds FACE_SETTLE = 300ms; // the turn animation, before A reaches what is ahead +constexpr Milliseconds STEP_RELEASE = 100ms; +// From the end of the hold, through the fade out and in. +constexpr Milliseconds WARP_TIMEOUT = 8000ms; +constexpr Milliseconds SURF_PROMPT_TIMEOUT = 5000ms; +constexpr Milliseconds SURF_ANIMATION = 3000ms; +// After a warp's fade: leaving by a door the game walks the player a tile out +// on its own, and a leg started before that ends loses tiles (on the console a +// 600ms wait cost 2 tiles). +constexpr Milliseconds AFTER_WARP = 1500ms; +// A message set off by a leg's last step shows after the hold ends. Caught +// here, before the next leg's turn tap, which the message would swallow. +constexpr Milliseconds AFTER_LEG_WATCH = 500ms; +constexpr size_t MAX_INTERRUPTIONS_PER_LEG = 5; + + +// A wild battle, seen by the flashes it starts with. +class WildBattleInterrupt : public OverworldInterrupt{ +public: + virtual std::string name() const override{ + return "a wild battle"; + } + virtual std::unique_ptr make_watcher() const override{ + return std::make_unique(COLOR_RED); + } + // The first flash shows about 130ms after the step on the console, and + // the watcher needs it to start fading back. Not calibrated yet. + virtual Milliseconds detection_delay() const override{ + return 300ms; + } + virtual void clear(ConsoleHandle& console, ProControllerContext& context) const override{ + flee_battle(console, context); + } +}; + +// A wild battle whose flashes were missed, seen once "Wild +// appeared!" shows. Where an open leg stopped is then only a rough guess. +class LateWildBattleInterrupt : public WildBattleInterrupt{ +public: + virtual std::string name() const override{ + return "a wild battle (seen late)"; + } + virtual std::unique_ptr make_watcher() const override{ + return std::make_unique(COLOR_RED); + } + // The flashes, the wipe and the opening animation. Not calibrated yet. + virtual Milliseconds detection_delay() const override{ + return 2000ms; + } +}; + +class MessageInterrupt : public OverworldInterrupt{ +public: + virtual std::string name() const override{ + return "a message"; + } + virtual std::unique_ptr make_watcher() const override{ + return std::make_unique(COLOR_RED); + } + // The box shows as the step ends; then video lag and the watcher's + // 250ms. Not calibrated yet. + virtual Milliseconds detection_delay() const override{ + return 400ms; + } + virtual void clear(ConsoleHandle& console, ProControllerContext& context) const override{ + WhiteDialogOverWatcher closed(COLOR_RED); + context.wait_for_all_requests(); + const int ret = run_until( + console, context, + [](ProControllerContext& context){ + for (int c = 0; c < 5; c++){ + pbf_press_button(context, BUTTON_B, 160ms, 840ms); + } + }, + {closed} + ); + if (ret < 0){ + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + "walk_overworld_route(): a message on the overworld didn't close.", + console + ); + } + } +}; + +// A message, taken to be "REPEL's effect wore off...", after which another +// Max Repel is used from the Items pocket. +class RepelWoreOffInterrupt : public MessageInterrupt{ +public: + explicit RepelWoreOffInterrupt(int max_repel_slot) + : m_max_repel_slot(max_repel_slot) + {} + virtual std::string name() const override{ + return "a message (Repel wore off?)"; + } + virtual void clear(ConsoleHandle& console, ProControllerContext& context) const override{ + MessageInterrupt::clear(console, context); + use_max_repel_from_bag(console, context, m_max_repel_slot); + } + +private: + int m_max_repel_slot; +}; + + +DpadPosition dpad(Direction direction){ + switch (direction){ + case Direction::NORTH: + return DPAD_UP; + case Direction::EAST: + return DPAD_RIGHT; + case Direction::SOUTH: + return DPAD_DOWN; + case Direction::WEST: + return DPAD_LEFT; + } + return DPAD_NONE; +} + +// The leg mover: holds the D-pad. FRLG moves exactly a tile per 16 frames. +class DpadMover : public Pokemon::LegMover{ +public: + virtual void hold(ProControllerContext& context, Direction direction, Milliseconds duration) const override{ + pbf_press_dpad(context, dpad(direction), duration, STEP_RELEASE); + } +}; + +Pokemon::LegSpec leg_spec(const RouteStep& step){ + return Pokemon::LegSpec{step.direction, step.tiles, step.to_wall, step.surfing ? SURF_TILE_TIME : TILE_TIME}; +} + +// One watcher for the whole fade: a ladder's black is short enough to be +// over before a second watcher, started once the fade is seen, looks. +void wait_out_warp(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step){ + BlackScreenOverWatcher arrival(COLOR_RED); + context.wait_for_all_requests(); + if (wait_until(console, context, WARP_TIMEOUT, {arrival}) < 0){ + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + "walk_overworld_route(): no fade in and out after walking onto the warp to " + step.end.map + ".", + console + ); + } +} + +void start_surf(ConsoleHandle& console, ProControllerContext& context, Direction direction, bool facing_water){ + // "The water is a deep blue... Would you like to SURF?", with YES selected. + // An A pressed while the player is still turning is lost. + if (!facing_water){ + pbf_press_dpad(context, dpad(direction), FACE_HOLD, FACE_SETTLE); + } + pbf_press_button(context, BUTTON_A, 160ms, 0ms); + SelectionDialogWatcher prompt(COLOR_RED); + context.wait_for_all_requests(); + if (wait_until(console, context, SURF_PROMPT_TIMEOUT, {prompt}) < 0){ + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + "walk_overworld_route(): no Surf prompt facing the water.", + console + ); + } + pbf_press_button(context, BUTTON_A, 160ms, 1000ms); + + // " used SURF!" waits for A, then the player jumps onto the water. + for (int c = 0; c < 5; c++){ + context.wait_for_all_requests(); + VideoSnapshot screen = console.video().snapshot(); + if (!screen || !WhiteDialogDetector(COLOR_RED).detect(screen)){ + break; + } + pbf_press_button(context, BUTTON_A, 160ms, 1000ms); + } + pbf_wait(context, SURF_ANIMATION); +} + +} + + + +OverworldInterrupts overworld_interrupts_with_repel(int max_repel_slot){ + OverworldInterrupts ret; + ret.emplace_back(std::make_unique()); + ret.emplace_back(std::make_unique()); + ret.emplace_back(std::make_unique(max_repel_slot)); + return ret; +} + +void use_max_repel_from_bag(ConsoleHandle& console, ProControllerContext& context, int slot){ + console.log(std::format("Using a Max Repel (Items pocket, slot {}).", slot + 1)); + open_bag_from_overworld(console, context); + // The bag is seen while it still slides in, and ignores presses until + // it is done. + pbf_wait(context, 1000ms); + // To the Items pocket, then to the top of it. + for (int c = 0; c < 3; c++){ + pbf_press_dpad(context, DPAD_LEFT, 100ms, 600ms); + } + for (int c = 0; c < 20; c++){ + pbf_press_dpad(context, DPAD_UP, 100ms, 100ms); + } + for (int c = 0; c < slot; c++){ + pbf_press_dpad(context, DPAD_DOWN, 100ms, 300ms); + } + // USE, " used the MAX REPEL.", back to the bag, then out of the + // bag and the start menu. A third A here would open the item's menu again. + pbf_press_button(context, BUTTON_A, 160ms, 800ms); + pbf_press_button(context, BUTTON_A, 160ms, 1500ms); + pbf_press_button(context, BUTTON_A, 160ms, 1500ms); + pbf_press_button(context, BUTTON_B, 160ms, 2000ms); + pbf_press_button(context, BUTTON_B, 160ms, 1000ms); + context.wait_for_all_requests(); +} + +const OverworldInterrupts& default_overworld_interrupts(){ + // Battles first: their screens are checked before the message box's. + static const OverworldInterrupts interrupts = []{ + OverworldInterrupts ret; + ret.emplace_back(std::make_unique()); + ret.emplace_back(std::make_unique()); + ret.emplace_back(std::make_unique()); + return ret; + }(); + return interrupts; +} + + +void walk_overworld_route( + ConsoleHandle& console, ProControllerContext& context, + const std::vector& route, + std::optional facing, + const OverworldInterrupts& interrupts +){ + // Each leg starts with a turn tap unless it goes the way the player faces. + // A tap while already facing that way takes a step, so a facing not + // given is read from the screen. If that fails too it taps anyway. + if (!facing){ + context.wait_for_all_requests(); + VideoSnapshot screen = console.video().snapshot(); + if (screen){ + facing = read_player_facing(screen); + } + console.log(std::string("Route: the player faces ") + (facing ? Pokemon::direction_name(*facing) : "an unknown way") + "."); + } + const DpadMover mover; + for (const RouteStep& step : route){ + console.log("Route: " + to_string(step)); + switch (step.action){ + case RouteAction::WALK: + // Turning first, with a tap, makes the hold start from a standstill + // facing the right way: holding through a turn lost a tile on the + // console, while holds from a standstill were exact over 15 tiles. + if (facing != step.direction){ + pbf_press_dpad(context, dpad(step.direction), TURN_TAP, TURN_SETTLE); + } + Pokemon::walk_leg(console, context, mover, interrupts, leg_spec(step), MAX_INTERRUPTIONS_PER_LEG); + if (step.warps){ + wait_out_warp(console, context, step); + pbf_wait(context, AFTER_WARP); + } + break; + case RouteAction::SURF: + start_surf(console, context, step.direction, facing == step.direction); + break; + case RouteAction::FACE: + pbf_press_dpad(context, dpad(step.direction), FACE_HOLD, STEP_RELEASE); + break; + } + if (step.action != RouteAction::FACE){ + Pokemon::clear_late_interrupts(console, context, interrupts, AFTER_LEG_WATCH, MAX_INTERRUPTIONS_PER_LEG); + } + facing = step.facing_after; + } + context.wait_for_all_requests(); +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h new file mode 100644 index 0000000000..402826fd7a --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h @@ -0,0 +1,69 @@ +/* Overworld Walk + * + * From: https://github.com/PokemonAutomation/ + * + * Walks a planned overworld route with the D-pad. FRLG moves one tile per + * 16 frames and finishes a step once it starts, so a leg is one hold timed + * to land mid-way between the last tile and one more. Warps are waited out + * by their fade; Surf goes through its dialog. + * + * A message or a wild battle can stop the player part-way through a leg. + * Each kind is an OverworldInterrupt: the walker watches for all of them + * while it holds the D-pad, and when one shows it stops, has it cleared and + * walks the rest of the leg. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_OverworldWalk_H +#define PokemonAutomation_PokemonFRLG_OverworldWalk_H + +#include +#include +#include +#include "Pokemon/Navigation/Pokemon_LegWalker.h" +#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" +#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" +#include "PokemonFRLG_OverworldRoute.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Something that stops the player part-way through a leg: a wild battle, a +// message. See Pokemon::LegInterrupt. +using OverworldInterrupt = Pokemon::LegInterrupt; +using OverworldInterrupts = Pokemon::LegInterrupts; + +// A wild battle, run from, and a message (e.g. "REPEL's effect wore off..."), +// closed with B. +const OverworldInterrupts& default_overworld_interrupts(); + +// The same, except that after a message another Max Repel is used, from +// slot `max_repel_slot` (from 0) of the Items pocket. Any message on the +// overworld is taken to be the one saying the last Repel wore off. +OverworldInterrupts overworld_interrupts_with_repel(int max_repel_slot); + +// From the overworld, uses the Max Repel in `slot` (from 0) of the Items +// pocket and returns to the overworld. +void use_max_repel_from_bag(ConsoleHandle& console, ProControllerContext& context, int slot); + + +// Walks `route` from where it was planned. The player must be standing still +// on the overworld, not running and not on the bike. `facing` is the way the +// player faces at the start; if not given, it is read from the screen. Throws OperationFailedException if a +// warp's fade or the Surf prompt doesn't show, or a leg is interrupted too +// many times. +void walk_overworld_route( + ConsoleHandle& console, ProControllerContext& context, + const std::vector& route, + std::optional facing = std::nullopt, + const OverworldInterrupts& interrupts = default_overworld_interrupts() +); + + + +} +} +} +#endif diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 23c3d63169..787541e0e8 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1720,6 +1720,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_TrainerCardDetector.h Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleLevelUpReader.cpp Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleLevelUpReader.h + Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.cpp + Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattlePokemonDetector.cpp Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattlePokemonDetector.h Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleSelectionArrowDetector.cpp @@ -1757,6 +1759,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp + Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.h Source/VideoGames/PokemonFRLG/PokemonFRLG_Navigation.cpp From b2e6af2de23a51e2dddfa217da8b70fc728e2c77 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 1 Nov 2026 09:29:53 -0800 Subject: [PATCH 07/19] devtools: write FRLG maps into a C++ file for tests, and check it frlg_maps.py --cpp writes the maps' JSON, byte for byte as --out writes the Packages files, into a C++ file of raw string literals, so the map tests can run in CI, which has no Packages maps. --check regenerates that file for the maps already in it and fails if it differs. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- devtools/maps/frlg_maps.py | 112 ++++++++++++++++++++++++++++++++++--- 1 file changed, 104 insertions(+), 8 deletions(-) diff --git a/devtools/maps/frlg_maps.py b/devtools/maps/frlg_maps.py index 07fe744d0f..53a539efe2 100644 --- a/devtools/maps/frlg_maps.py +++ b/devtools/maps/frlg_maps.py @@ -4,6 +4,8 @@ python3 devtools/maps/frlg_maps.py --out Packages/Resources/PokemonFRLG/Maps \ CeruleanCity_PokemonCenter_1F CeruleanCity Route24 \ CeruleanCave_1F CeruleanCave_2F CeruleanCave_B1F + python3 devtools/maps/frlg_maps.py --cpp + python3 devtools/maps/frlg_maps.py --cpp --check Downloads each map's data/maps//map.json, its layout's map.bin and its tilesets' metatile_attributes.bin at --commit into --cache, then writes @@ -11,6 +13,10 @@ Warps and connections lead only to maps in the same run: others get an empty dest_map, or are left out. Named points and flag sets come from POINTS and FLAG_SETS below. + +--cpp writes the same JSON into a C++ file, one raw string per map, so the +map tests run without Packages (CI has none). --check regenerates that file, +for the maps already in it, and fails if it differs. """ import argparse import json @@ -18,6 +24,7 @@ import re import struct import subprocess +import sys COMMIT = 'ce6406d8c2eaf46d543c8a2606de0c3cb1951982' @@ -176,27 +183,116 @@ def map_json(decomp, name, layouts, names, loaded, unhandled): } +# The C++ file --cpp writes. Each map is one raw string literal, which MSVC +# limits to 16380 bytes. +CPP_TEMPLATE = '''/* Overworld Maps Test Data + * + * From: https://github.com/PokemonAutomation/ + * + * Generated by devtools/maps/frlg_maps.py; do not edit. Regenerate with + * python3 devtools/maps/frlg_maps.py --cpp + * and check it with + * python3 devtools/maps/frlg_maps.py --cpp --check + * + */ + +#include "Common/Cpp/Exceptions.h" +#include "PokemonFRLG_OverworldMapsTestData.h" + +namespace PokemonAutomation{{ +namespace NintendoSwitch{{ +namespace PokemonFRLG{{ + + +const std::vector>& overworld_map_json(){{ + static const std::vector> MAPS{{ +{entries} + }}; + return MAPS; +}} + +std::vector test_overworld_maps(const std::set& set_flags){{ + static const std::vector ALL = []{{ + std::vector maps; + for (const auto& item : overworld_map_json()){{ + maps.push_back(parse_map(item.second, item.first + " (test data)")); + if (maps.back().name != item.first){{ + throw ParseException(item.first + " (test data): name is \\"" + maps.back().name + "\\"."); + }} + }} + return maps; + }}(); + std::vector maps = ALL; + for (MapData& map : maps){{ + hide_objects(map, set_flags); + }} + return maps; +}} + + + +}} +}} +}} +''' +MAX_LITERAL = 16000 + + +def cpp_text(maps): + entries = [] + for name, text in maps: + if len(text) > MAX_LITERAL: + raise SystemExit(f'{name}: {len(text)} bytes, too long for one string literal.') + entries.append(f' {{"{name}", R"json({text})json"}},') + return CPP_TEMPLATE.format(entries='\n'.join(entries)).replace('\n', '\r\n') + + +def cpp_map_names(path): + with open(path, newline='') as file: + return re.findall(r'^ \{"(\w+)", R"json\(', file.read(), re.MULTILINE) + + +def json_text(data): + return json.dumps(data, indent=4) + '\n' + + def main(): parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--commit', default=COMMIT) parser.add_argument('--cache', default=os.path.expanduser('~/.cache/pokefirered')) - parser.add_argument('--out', required=True) - parser.add_argument('maps', nargs='+') + parser.add_argument('--out', help='folder to write .json into') + parser.add_argument('--cpp', help='C++ file to write every map into') + parser.add_argument('--check', action='store_true', help='check --cpp instead of writing it') + parser.add_argument('maps', nargs='*') args = parser.parse_args() + if args.check and args.cpp and not args.maps: + args.maps = cpp_map_names(args.cpp) + if not args.maps or not (args.out or args.cpp): + parser.error('needs maps, and --out or --cpp') decomp = Decomp(args.commit, args.cache) names = behaviors(decomp) layouts = {l['id']: l for l in json.loads(decomp.read('data/layouts/layouts.json'))['layouts'] if 'id' in l} loaded = {json.loads(decomp.read(f'data/maps/{m}/map.json'))['id']: m for m in args.maps} unhandled = {} - os.makedirs(args.out, exist_ok=True) - for name in args.maps: - data = map_json(decomp, name, layouts, names, loaded, unhandled) - with open(os.path.join(args.out, name + '.json'), 'w', newline='\n') as out: - json.dump(data, out, indent=4) - out.write('\n') + maps = [(name, json_text(map_json(decomp, name, layouts, names, loaded, unhandled))) for name in args.maps] if unhandled: print(f'Non-collision behaviors written as floor: {unhandled}') + if args.out and not args.check: + os.makedirs(args.out, exist_ok=True) + for name, text in maps: + with open(os.path.join(args.out, name + '.json'), 'w', newline='') as out: + out.write(text) + if args.cpp: + text = cpp_text(maps) + if args.check: + with open(args.cpp, newline='') as file: + if file.read() != text: + sys.exit(f'{args.cpp} differs from the generator; regenerate it with --cpp.') + print(f'{args.cpp} matches the generator ({len(maps)} maps).') + else: + with open(args.cpp, 'w', newline='') as out: + out.write(text) if __name__ == '__main__': From 5e9926000a83235be8750ef153ce2da8234b6355 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 1 Nov 2026 09:33:07 -0800 Subject: [PATCH 08/19] FRLG fix: check that the overworld is up before each step With the START menu still open, a Viridian Forest route of three legs to a wall reported each one done; the D-pad only moved the menu's cursor (console B, 2026-11-01). Before each step the route now fails if the START menu, a selection menu or a message is on screen. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Overworld/PokemonFRLG_OverworldWalk.cpp | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp index 202b5e076f..902a4a7e5d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp @@ -12,6 +12,7 @@ #include "CommonFramework/VideoPipeline/VideoFeed.h" #include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_BattleDialogs.h" #include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h" +#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_StartMenuDetector.h" #include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h" #include "VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h" #include "PokemonFRLG_PlayerFacingReader.h" @@ -177,6 +178,33 @@ void wait_out_warp(ConsoleHandle& console, ProControllerContext& context, const } } +// Fails unless the overworld is up. Under the START menu or a message the +// D-pad only moves a cursor, and legs to a wall seem to go fine: three +// "walked" that way in Viridian Forest without the player moving (console B, +// 2026-11-01). +void check_overworld(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step){ + context.wait_for_all_requests(); + VideoSnapshot screen = console.video().snapshot(); + if (!screen){ + return; + } + const char* open = nullptr; + if (StartMenuDetector(COLOR_RED).detect(screen)){ + open = "the START menu"; + }else if (SelectionDialogDetector(COLOR_RED).detect(screen)){ + open = "a menu"; + }else if (WhiteDialogDetector(COLOR_RED).detect(screen)){ + open = "a message"; + } + if (open != nullptr){ + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + std::string("walk_overworld_route(): ") + open + " is open, before: " + to_string(step), + console + ); + } +} + void start_surf(ConsoleHandle& console, ProControllerContext& context, Direction direction, bool facing_water){ // "The water is a deep blue... Would you like to SURF?", with YES selected. // An A pressed while the player is still turning is lost. @@ -278,6 +306,7 @@ void walk_overworld_route( const DpadMover mover; for (const RouteStep& step : route){ console.log("Route: " + to_string(step)); + check_overworld(console, context, step); switch (step.action){ case RouteAction::WALK: // Turning first, with a tap, makes the hold start from a standstill From 9a8924bb87dfc17cd5b0d802a54863f53f5db31d Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 1 Nov 2026 09:33:09 -0800 Subject: [PATCH 09/19] FRLG fix: stop on a trainer battle instead of fleeing it A trainer who sees the player mid-leg speaks first; the walker closed the message as an overworld one, then saw the battle and tried to flee it (console B, 2026-11-01, Viridian Forest). After any message on the overworld the walker now watches 6s for a battle's dialog, and if one shows it stops with "trainer battle" in the error, without an error report, for the caller to fight it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Overworld/PokemonFRLG_OverworldWalk.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp index 902a4a7e5d..fa003efb39 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp @@ -45,6 +45,9 @@ constexpr Milliseconds AFTER_WARP = 1500ms; // A message set off by a leg's last step shows after the hold ends. Caught // here, before the next leg's turn tap, which the message would swallow. constexpr Milliseconds AFTER_LEG_WATCH = 500ms; +// After a message closes: a trainer who saw the player speaks first, then +// the battle starts, with " would like to battle!" seconds later. +constexpr Milliseconds TRAINER_BATTLE_WATCH = 6000ms; constexpr size_t MAX_INTERRUPTIONS_PER_LEG = 5; @@ -115,6 +118,22 @@ class MessageInterrupt : public OverworldInterrupt{ console ); } + check_no_trainer_battle(console, context); + } + +private: + // A trainer's battle can't be fled, and the walker must not try (console + // B, 2026-11-01, Viridian Forest): it stops here for the caller. + static void check_no_trainer_battle(ConsoleHandle& console, ProControllerContext& context){ + BattleDialogWatcher battle(COLOR_RED); + context.wait_for_all_requests(); + if (wait_until(console, context, TRAINER_BATTLE_WATCH, {battle}) >= 0){ + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::NO_ERROR_REPORT, + "walk_overworld_route(): trainer battle: a battle started after a message on the overworld.", + console + ); + } } }; From a31833dd47736fcb5c2a95a052b08640faf4ad45 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 1 Nov 2026 09:38:10 -0800 Subject: [PATCH 10/19] devtools: check committed FRLG map files against the generator The maps the tests use become plain .json files in the repo, built into the program by CMake, so frlg_maps.py no longer writes a C++ file (--cpp). --check now regenerates the maps in --out and fails if any file differs; without map names, the maps are the ones already in --out. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- devtools/maps/frlg_maps.py | 121 ++++++++----------------------------- 1 file changed, 25 insertions(+), 96 deletions(-) diff --git a/devtools/maps/frlg_maps.py b/devtools/maps/frlg_maps.py index 53a539efe2..970e76c07d 100644 --- a/devtools/maps/frlg_maps.py +++ b/devtools/maps/frlg_maps.py @@ -4,8 +4,8 @@ python3 devtools/maps/frlg_maps.py --out Packages/Resources/PokemonFRLG/Maps \ CeruleanCity_PokemonCenter_1F CeruleanCity Route24 \ CeruleanCave_1F CeruleanCave_2F CeruleanCave_B1F - python3 devtools/maps/frlg_maps.py --cpp - python3 devtools/maps/frlg_maps.py --cpp --check + python3 devtools/maps/frlg_maps.py --out + python3 devtools/maps/frlg_maps.py --out --check Downloads each map's data/maps//map.json, its layout's map.bin and its tilesets' metatile_attributes.bin at --commit into --cache, then writes @@ -14,9 +14,9 @@ dest_map, or are left out. Named points and flag sets come from POINTS and FLAG_SETS below. ---cpp writes the same JSON into a C++ file, one raw string per map, so the -map tests run without Packages (CI has none). --check regenerates that file, -for the maps already in it, and fails if it differs. +Without map names, the maps are the ones already in --out. --check writes +nothing: it regenerates them and fails if any file differs, e.g. for the +copies the unit tests build into the program. """ import argparse import json @@ -183,75 +183,6 @@ def map_json(decomp, name, layouts, names, loaded, unhandled): } -# The C++ file --cpp writes. Each map is one raw string literal, which MSVC -# limits to 16380 bytes. -CPP_TEMPLATE = '''/* Overworld Maps Test Data - * - * From: https://github.com/PokemonAutomation/ - * - * Generated by devtools/maps/frlg_maps.py; do not edit. Regenerate with - * python3 devtools/maps/frlg_maps.py --cpp - * and check it with - * python3 devtools/maps/frlg_maps.py --cpp --check - * - */ - -#include "Common/Cpp/Exceptions.h" -#include "PokemonFRLG_OverworldMapsTestData.h" - -namespace PokemonAutomation{{ -namespace NintendoSwitch{{ -namespace PokemonFRLG{{ - - -const std::vector>& overworld_map_json(){{ - static const std::vector> MAPS{{ -{entries} - }}; - return MAPS; -}} - -std::vector test_overworld_maps(const std::set& set_flags){{ - static const std::vector ALL = []{{ - std::vector maps; - for (const auto& item : overworld_map_json()){{ - maps.push_back(parse_map(item.second, item.first + " (test data)")); - if (maps.back().name != item.first){{ - throw ParseException(item.first + " (test data): name is \\"" + maps.back().name + "\\"."); - }} - }} - return maps; - }}(); - std::vector maps = ALL; - for (MapData& map : maps){{ - hide_objects(map, set_flags); - }} - return maps; -}} - - - -}} -}} -}} -''' -MAX_LITERAL = 16000 - - -def cpp_text(maps): - entries = [] - for name, text in maps: - if len(text) > MAX_LITERAL: - raise SystemExit(f'{name}: {len(text)} bytes, too long for one string literal.') - entries.append(f' {{"{name}", R"json({text})json"}},') - return CPP_TEMPLATE.format(entries='\n'.join(entries)).replace('\n', '\r\n') - - -def cpp_map_names(path): - with open(path, newline='') as file: - return re.findall(r'^ \{"(\w+)", R"json\(', file.read(), re.MULTILINE) - - def json_text(data): return json.dumps(data, indent=4) + '\n' @@ -260,15 +191,14 @@ def main(): parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--commit', default=COMMIT) parser.add_argument('--cache', default=os.path.expanduser('~/.cache/pokefirered')) - parser.add_argument('--out', help='folder to write .json into') - parser.add_argument('--cpp', help='C++ file to write every map into') - parser.add_argument('--check', action='store_true', help='check --cpp instead of writing it') - parser.add_argument('maps', nargs='*') + parser.add_argument('--out', required=True, help='folder of the .json files') + parser.add_argument('--check', action='store_true', help='check the files in --out instead of writing them') + parser.add_argument('maps', nargs='*', help='default: the maps already in --out') args = parser.parse_args() - if args.check and args.cpp and not args.maps: - args.maps = cpp_map_names(args.cpp) - if not args.maps or not (args.out or args.cpp): - parser.error('needs maps, and --out or --cpp') + if not args.maps and os.path.isdir(args.out): + args.maps = sorted(f[:-5] for f in os.listdir(args.out) if f.endswith('.json')) + if not args.maps: + parser.error('no maps given, and none in --out') decomp = Decomp(args.commit, args.cache) names = behaviors(decomp) @@ -278,21 +208,20 @@ def main(): maps = [(name, json_text(map_json(decomp, name, layouts, names, loaded, unhandled))) for name in args.maps] if unhandled: print(f'Non-collision behaviors written as floor: {unhandled}') - if args.out and not args.check: - os.makedirs(args.out, exist_ok=True) + if args.check: + differ = [] for name, text in maps: - with open(os.path.join(args.out, name + '.json'), 'w', newline='') as out: - out.write(text) - if args.cpp: - text = cpp_text(maps) - if args.check: - with open(args.cpp, newline='') as file: - if file.read() != text: - sys.exit(f'{args.cpp} differs from the generator; regenerate it with --cpp.') - print(f'{args.cpp} matches the generator ({len(maps)} maps).') - else: - with open(args.cpp, 'w', newline='') as out: - out.write(text) + path = os.path.join(args.out, name + '.json') + if not os.path.exists(path) or open(path, newline='').read() != text: + differ.append(name) + if differ: + sys.exit(f'Differ from the generator: {" ".join(differ)}. Regenerate them without --check.') + print(f'{len(maps)} maps in {args.out} match the generator.') + return + os.makedirs(args.out, exist_ok=True) + for name, text in maps: + with open(os.path.join(args.out, name + '.json'), 'w', newline='') as out: + out.write(text) if __name__ == '__main__': From e5136bffcdc4cee6c3159ec7a47b318c72b8d1bc Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 1 Nov 2026 10:01:27 -0800 Subject: [PATCH 11/19] FRLG: leave the elevation grid out of maps that are all ground In 12 of the 25 maps every tile the player can walk onto is at ground level (3); only walls, ledges, signs and doors differ, at 0. frlg_maps.py now leaves "elevation" out of such maps (about 15 KB of 104 KB), and the loader reads a missing grid as ground everywhere. A door is then 3 rather than 0: the player, put on it by a warp, steps off onto ground either way. A test plans a room and yard written both ways and gets the same routes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Overworld/PokemonFRLG_OverworldMaps.cpp | 5 ++- .../Overworld/PokemonFRLG_OverworldMaps.h | 3 +- .../PokemonFRLG_OverworldMaps_Tests.cpp | 21 ++++++++-- .../Overworld/PokemonFRLG_OverworldRoute.cpp | 38 +++++++++++++++++++ devtools/maps/frlg_maps.py | 18 ++++++++- 5 files changed, 79 insertions(+), 6 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp index 92d83d5f5f..84dd3e780c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp @@ -222,7 +222,10 @@ MapData read_map(const JsonValue& json, const std::string& source){ throw ParseException(where + "width and height must be positive."); } map.tiles = read_grid(root, "tiles", where, width, height, tile_from_char); - map.elevation = read_grid(root, "elevation", where, width, height, elevation_from_char); + // Left out of maps where every tile the player can stand on is ground. + map.elevation = root.get_value("elevation") == nullptr + ? Grid{width, height, std::vector((size_t)width * height, ELEVATION_GROUND)} + : read_grid(root, "elevation", where, width, height, elevation_from_char); map.warps = read_list(root, "warps", where, read_warp); map.objects = read_list(root, "objects", where, read_map_object); map.connections = read_list(root, "connections", where, read_connection); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h index 77d30dae4c..0577d3b8cb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h @@ -15,7 +15,8 @@ * { * "name": "CeruleanCity", "width": 48, "height": 40, * "tiles": ["####~~~...", ...], // `height` rows of `width` tiles - * "elevation": ["0033333...", ...], // the same, one hex digit per tile + * "elevation": ["0033333...", ...], // the same, one hex digit per tile; + * // left out if all ground (3) * "warps": [{"x": 22, "y": 19, "dest_map": "...", "dest_warp": 1}, ...], * "objects": [{"x": 1, "y": 13, "kind": "cooltrainer_m", * "flag": "FLAG_...", "wander_x": 0, "wander_y": 0}, ...], diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp index dc369de97b..7945ca8683 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp @@ -98,10 +98,24 @@ UnitTestResult test_valid_map(){ UnitTestResult test_missing_field(){ std::string json = VALID_MAP; - json.replace(json.find("\"elevation\""), 11, "\"heights\""); + json.replace(json.find("\"warps\""), 7, "\"exits\""); const std::string error = parse_error(json); - if (!mentions(error, {"Test.json", "elevation", "missing"})){ - return "Expected an error naming the missing elevation, got: \"" + error + "\""; + if (!mentions(error, {"Test.json", "warps", "missing"})){ + return "Expected an error naming the missing warps, got: \"" + error + "\""; + } + return true; +} + +UnitTestResult test_elevation_left_out(){ + std::string json = VALID_MAP; + json.erase(json.find("\"elevation\""), std::string("\"elevation\": [\"031\", \"3f3\"],").size()); + const MapData map = parse_map(json, "Test.json"); + for (int y = 0; y < 2; y++){ + for (int x = 0; x < 3; x++){ + if (elevation_at(map, {x, y}) != ELEVATION_GROUND){ + return "Expected ground everywhere without an elevation grid."; + } + } } return true; } @@ -150,6 +164,7 @@ UnitTestResult test_not_json(){ void add_tests_OverworldMaps(UnitTestDatabase& database){ database.add("valid map", test_valid_map); database.add("missing field", test_missing_field); + database.add("elevation left out", test_elevation_left_out); database.add("field of the wrong type", test_bad_field_type); database.add("row of the wrong length", test_bad_row_length); database.add("unknown tile", test_unknown_tile); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp index 1bbe90ab9b..e51f8f5a90 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" #include "Pokemon/Navigation/Pokemon_LegPlanner.h" @@ -690,10 +691,47 @@ UnitTestResult test_route_through_warp(){ return "Expected to warp into the yard:" + describe(route); } +// `json` with its elevation grid replaced by `rows`, or left out if empty. +std::string with_elevation(std::string json, const std::string& rows){ + const size_t begin = json.find("\"elevation\""); + const size_t end = json.find("\n", begin); + json.erase(begin, end - begin + 1); + if (!rows.empty()){ + json.insert(begin, "\"elevation\": " + rows + ",\n"); + } + return json; +} + +// Room and yard as the decompilation writes them, their walls and the +// door at elevation 0, plan the same as with no elevation grid, which +// frlg_maps.py leaves out when every tile the player can stand on is ground. +UnitTestResult test_ground_only_elevation_left_out(){ + const std::vector written{ + parse_map(with_elevation(TEST_ROOM_JSON, R"(["00000", "03330", "03330", "00300"])"), "Room"), + parse_map(with_elevation(TEST_YARD_JSON, R"(["00000", "00000", "03330", "00000"])"), "Yard"), + }; + const std::vector left_out{ + parse_map(with_elevation(TEST_ROOM_JSON, ""), "Room"), + parse_map(with_elevation(TEST_YARD_JSON, ""), "Yard"), + }; + for (const MapPosition& start : {MapPosition{"Room", {1, 1}}, MapPosition{"Room", {3, 2}}}){ + for (const MapPosition& goal : {MapPosition{"Yard", {1, 2}}, MapPosition{"Yard", {3, 2}}, MapPosition{"Room", {2, 2}}}){ + const std::optional> a = plan_overworld_route(written, start, {goal, std::nullopt}); + const std::optional> b = plan_overworld_route(left_out, start, {goal, std::nullopt}); + if (!a || !b || describe(*a) != describe(*b)){ + return "Plans differ from " + to_string(start) + " to " + to_string(goal) + ":" + + (a ? describe(*a) : " none") + "\nwithout elevation:" + (b ? describe(*b) : " none"); + } + } + } + return true; +} + } void add_tests_OverworldRoute(UnitTestDatabase& database){ database.add("route through a warp", test_route_through_warp); + database.add("ground-only elevation left out", test_ground_only_elevation_left_out); database.add("maps to Brock", test_story_maps); database.add("bedroom to Oak's Lab", test_bedroom_to_oaks_lab); database.add("Viridian Mart to Pewter Gym", test_viridian_mart_to_pewter_gym); diff --git a/devtools/maps/frlg_maps.py b/devtools/maps/frlg_maps.py index 970e76c07d..1c8353acca 100644 --- a/devtools/maps/frlg_maps.py +++ b/devtools/maps/frlg_maps.py @@ -153,6 +153,19 @@ def wander(obj): return x, y +# Tiles the player never walks onto: their elevation only matters for doors, +# which the player is put on by a warp and leaves at once. +UNWALKABLE = '#JDS' +GROUND = '3' + + +def ground_only(tiles, elevation): + """Whether every walkable tile is at ground level, so that the map can + leave out its elevation grid (the loader reads ground everywhere).""" + return all(level == GROUND for row, levels in zip(tiles, elevation) + for tile, level in zip(row, levels) if tile not in UNWALKABLE) + + def map_json(decomp, name, layouts, names, loaded, unhandled): source = json.loads(decomp.read(f'data/maps/{name}/map.json')) width, height, tiles, elevation = grid(decomp, layouts[source['layout']], names, unhandled) @@ -166,7 +179,7 @@ def map_json(decomp, name, layouts, names, loaded, unhandled): 'flag': '' if flag == '0' else flag, 'wander_x': wander_x, 'wander_y': wander_y, }) - return { + data = { 'name': name, 'width': width, 'height': height, 'tiles': tiles, 'elevation': elevation, 'warps': [ @@ -181,6 +194,9 @@ def map_json(decomp, name, layouts, names, loaded, unhandled): 'points': [{'name': n, 'x': x, 'y': y} for n, (x, y) in POINTS.get(name, {}).items()], 'flag_sets': [{'name': n, 'flags': flags} for n, flags in FLAG_SETS.get(name, {}).items()], } + if ground_only(tiles, elevation): + del data['elevation'] + return data def json_text(data): From 2172b9e4fdebe91bfeaaa50ecae91494b54f7010 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 1 Nov 2026 12:20:49 -0800 Subject: [PATCH 12/19] FRLG: #117 is the maps and the planner; the walker moves to #118 Scopes the FRLG PRs: this PR keeps the overworld maps (built into the program from Overworld/Maps, generated by devtools/maps/frlg_maps.py), the route planner and the facing reader, now with the built-in maps, signs and wild steps from #118 so its route tests run on the compiled-in maps. The walker (PokemonFRLG_OverworldWalk) and the battle flash watcher it uses move to #118, with the rest of walking. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- SerialPrograms/CMakeLists.txt | 2 + .../PokemonFRLG_BattleFlashWatcher.cpp | 76 ---- .../PokemonFRLG_BattleFlashWatcher.h | 46 --- .../Overworld/Maps/CeruleanCave_1F.json | 188 +++++++++ .../Overworld/Maps/CeruleanCave_2F.json | 177 +++++++++ .../Overworld/Maps/CeruleanCave_B1F.json | 170 ++++++++ .../Overworld/Maps/CeruleanCity.json | 291 ++++++++++++++ .../Maps/CeruleanCity_PokemonCenter_1F.json | 127 ++++++ .../Overworld/Maps/PalletTown.json | 110 ++++++ .../Maps/PalletTown_PlayersHouse_1F.json | 56 +++ .../Maps/PalletTown_PlayersHouse_2F.json | 45 +++ .../Maps/PalletTown_ProfessorOaksLab.json | 126 ++++++ .../Maps/PalletTown_RivalsHouse.json | 58 +++ .../Overworld/Maps/PewterCity.json | 164 ++++++++ .../Overworld/Maps/PewterCity_Gym.json | 78 ++++ .../Overworld/Maps/PewterCity_Mart.json | 76 ++++ .../Overworld/Maps/PewterCity_Museum_1F.json | 109 ++++++ .../Maps/PewterCity_PokemonCenter_1F.json | 122 ++++++ .../PokemonFRLG/Overworld/Maps/Route1.json | 80 ++++ .../PokemonFRLG/Overworld/Maps/Route2.json | 221 +++++++++++ .../PokemonFRLG/Overworld/Maps/Route22.json | 90 +++++ .../PokemonFRLG/Overworld/Maps/Route24.json | 165 ++++++++ .../Route2_ViridianForest_NorthEntrance.json | 74 ++++ .../Route2_ViridianForest_SouthEntrance.json | 66 ++++ .../Overworld/Maps/ViridianCity.json | 214 +++++++++++ .../Overworld/Maps/ViridianCity_Mart.json | 82 ++++ .../Maps/ViridianCity_PokemonCenter_1F.json | 98 +++++ .../Overworld/Maps/ViridianForest.json | 207 ++++++++++ .../Overworld/PokemonFRLG_OverworldMap.cpp | 3 +- .../Overworld/PokemonFRLG_OverworldMap.h | 4 + .../Overworld/PokemonFRLG_OverworldMaps.cpp | 15 +- .../Overworld/PokemonFRLG_OverworldMaps.h | 19 +- .../Overworld/PokemonFRLG_OverworldRoute.cpp | 155 +++++++- .../Overworld/PokemonFRLG_OverworldRoute.h | 4 + .../Overworld/PokemonFRLG_OverworldWalk.cpp | 362 ------------------ .../Overworld/PokemonFRLG_OverworldWalk.h | 69 ---- SerialPrograms/cmake/SourceFiles.cmake | 4 - devtools/maps/frlg_maps.py | 28 +- 38 files changed, 3398 insertions(+), 583 deletions(-) delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.cpp delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_1F.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_2F.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_B1F.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity_PokemonCenter_1F.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_1F.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_2F.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Museum_1F.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_PokemonCenter_1F.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route1.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route22.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_NorthEntrance.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_SouthEntrance.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_PokemonCenter_1F.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index d0966df32f..6a94155e3d 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -197,6 +197,8 @@ add_library(SerialProgramsLib STATIC ${CORE_LIBRARY_SOURCES} ${LIBRARY_SOURCES}) include(cmake/EmbedTextFiles.cmake) pa_embed_text_files(SerialProgramsLib Source/Pokemon/Navigation/TestMaps Pokemon/Navigation/Pokemon_Navigation_Tests.h PokemonAutomation::Pokemon navigation_test_map_json) +pa_embed_text_files(SerialProgramsLib Source/VideoGames/PokemonFRLG/Overworld/Maps + VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h PokemonAutomation::NintendoSwitch::PokemonFRLG overworld_map_json) # Create binary target diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.cpp deleted file mode 100644 index f7174de9b8..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* Battle Flash Watcher - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#include -#include "CommonFramework/ImageTools/ImageBoxes.h" -#include "CommonFramework/ImageTools/ImageStats.h" -#include "CommonFramework/ImageTypes/ImageViewRGB32.h" -#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" -#include "VideoGames/PokemonFRLG/PokemonFRLG_Settings.h" -#include "PokemonFRLG_BattleFlashWatcher.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - -using namespace std::chrono_literals; - - -namespace{ - -// On the console a flash took the screen from 145 to 98 (two thirds) and -// back within 80ms, twice in about 300ms. -constexpr std::chrono::milliseconds FLASH_WINDOW = 400ms; -constexpr double FLASH_DARKER = 0.8; // the dip is below this much of the brightness before it -constexpr double FLASH_FLOOR = 0.4; // and above this much: lower is a fade to black -constexpr double FLASH_RECOVERY = 1.1; // then the screen comes back to this much of the dip - -} - - -BattleFlashWatcher::BattleFlashWatcher(Color color) - : VisualInferenceCallback("BattleFlashWatcher") - , m_color(color) -{} - -void BattleFlashWatcher::make_overlays(VideoOverlaySet& items) const{ - items.add(m_color, GameSettings::instance().GAME_BOX); -} - -bool BattleFlashWatcher::process_frame(const ImageViewRGB32& frame, WallClock timestamp){ - const ImageViewRGB32 game_screen = extract_box_reference(frame, GameSettings::instance().GAME_BOX); - const double brightness = image_stats(game_screen).average.sum(); - while (!m_history.empty() && timestamp - m_history.front().first > FLASH_WINDOW){ - m_history.pop_front(); - } - - // The brightest frame before the screen first dips, and the darkest - // frame since. - double before = 0; - double dip = -1; - for (const auto& item : m_history){ - if (dip < 0){ - if (item.second < before * FLASH_DARKER){ - dip = item.second; - }else{ - before = std::max(before, item.second); - } - }else{ - dip = std::min(dip, item.second); - } - } - m_history.emplace_back(timestamp, brightness); - - return dip >= 0 - && dip > before * FLASH_FLOOR - && brightness > dip * FLASH_RECOVERY; -} - - - -} -} -} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h deleted file mode 100644 index a705d3473c..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Battle Flash Watcher - * - * From: https://github.com/PokemonAutomation/ - * - * Every wild battle starts with the overworld flashing dark twice, within - * half a second of the step that set it off, before the battle's own wipe. - * The wipe and the battle screen differ by map and come seconds later, so - * the flash is the earliest and the same sign of a battle everywhere. - * - */ - -#ifndef PokemonAutomation_PokemonFRLG_BattleFlashWatcher_H -#define PokemonAutomation_PokemonFRLG_BattleFlashWatcher_H - -#include -#include -#include "Common/Cpp/Color.h" -#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -// Fires when the game screen darkens by a fifth or more and starts to come -// back within a moment. A warp's fade, or the Switch dimming its screen, -// only darkens and so doesn't count. -class BattleFlashWatcher : public VisualInferenceCallback{ -public: - BattleFlashWatcher(Color color); - - virtual void make_overlays(VideoOverlaySet& items) const override; - virtual bool process_frame(const ImageViewRGB32& frame, WallClock timestamp) override; - -private: - Color m_color; - // Recent brightness of the game screen. - std::deque> m_history; -}; - - - -} -} -} -#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_1F.json new file mode 100644 index 0000000000..71d6f98963 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_1F.json @@ -0,0 +1,188 @@ +{ + "name": "CeruleanCave_1F", + "width": 40, + "height": 23, + "tiles": [ + "########################################", + "#######...##.#########~~~~~~~~~#..##..##", + "#######...L..#########~~~~~~~~~#..L...##", + "#######..##..#~~~~~~~~~~~~~~~~~#......##", + "##L####..##..#~~~~~~~~~~#...#~~##.######", + "##.#.........#~~~~~~~~~~#...#~~~~~~~~~~#", + "#..#....##...#~~~#..........#~~~~~~~~~~#", + "#L.#....##...#~~~#..........#~~~~~~~~~~#", + "#..#....##...#~~~#.................#~~~#", + "####....##.###~~~#...######...#....#~~~#", + "##.#....#~~~##~~~#...##.####..L....#~~~#", + "##......#~~~##~~~##.###.L.##.......#~~~#", + "##......#~~~~~~~~#....#...##...#####~~~#", + "##......#~~~~~~~~#..#.##.###...###.....#", + "##..##..#~~~~~~~~#.........#...#.......#", + "##..#L..#~~~#....##......###...#.....###", + "##......#...#....####...####...#...#####", + "##......#...#..................#...#####", + "#####.###...##.#...............#...#####", + "#####..........#...............#...#####", + "#####..........#...............#...#####", + "#####..........#################.v.#####", + "########################################" + ], + "elevation": [ + "0000000000000000000000000000000000000000", + "0000000333003000000000111111111033003300", + "0000000333333000000000111111111033333300", + "0000000330033011111111111111111033333300", + "0030000330033011111111110444011003000000", + "0030333333333011111111110444011111111110", + "0330333300333011104444444444011111111110", + "0330333300333011104444444444011111111110", + "0330333300333011104444444444444444401110", + "0000333300300011104440000004440444401110", + "0030333301110011104440030000444444401110", + "0033333301110011100000033300444444401110", + "0033333301111111103333033300444000001110", + "0033333301111111103303003000444000333330", + "0033003301111111103333333330444033333330", + "0033033301110444400333333000444033333000", + "0033333303330444400003330000444033300000", + "0033333303330444444444444444444033300000", + "0000030003330000444444444444444033300000", + "0000033333333330444444444444444033300000", + "0000033333333330444444444444444033300000", + "0000033333333330000000000000000033300000", + "0000000000000000000000000000000000000000" + ], + "warps": [ + { + "x": 33, + "y": 21, + "dest_map": "CeruleanCity", + "dest_warp": 7 + }, + { + "x": 34, + "y": 2, + "dest_map": "CeruleanCave_2F", + "dest_warp": 0 + }, + { + "x": 1, + "y": 7, + "dest_map": "CeruleanCave_B1F", + "dest_warp": 0 + }, + { + "x": 10, + "y": 2, + "dest_map": "CeruleanCave_2F", + "dest_warp": 1 + }, + { + "x": 5, + "y": 15, + "dest_map": "CeruleanCave_2F", + "dest_warp": 2 + }, + { + "x": 30, + "y": 10, + "dest_map": "CeruleanCave_2F", + "dest_warp": 3 + }, + { + "x": 24, + "y": 11, + "dest_map": "CeruleanCave_2F", + "dest_warp": 4 + }, + { + "x": 2, + "y": 4, + "dest_map": "CeruleanCave_2F", + "dest_warp": 5 + } + ], + "objects": [ + { + "x": 7, + "y": 3, + "kind": "item_ball", + "flag": "FLAG_HIDE_CERULEAN_CAVE_1F_NUGGET", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 11, + "y": 16, + "kind": "item_ball", + "flag": "FLAG_HIDE_CERULEAN_CAVE_1F_FULL_RESTORE", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 25, + "y": 5, + "kind": "item_ball", + "flag": "FLAG_HIDE_CERULEAN_CAVE_1F_MAX_ELIXIR", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 7, + "y": 21, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_12", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 13, + "y": 21, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_13", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 5, + "y": 20, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_14", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 14, + "y": 20, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_15", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 11, + "y": 21, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_16", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 9, + "y": 18, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_17", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [ + { + "name": "entrance", + "x": 33, + "y": 21 + } + ], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_2F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_2F.json new file mode 100644 index 0000000000..5150099e00 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_2F.json @@ -0,0 +1,177 @@ +{ + "name": "CeruleanCave_2F", + "width": 40, + "height": 23, + "tiles": [ + "########################################", + "########################################", + "########################################", + "####....####..##.....#............######", + "#######......L#..###.#.#########.L######", + "####..####.####.##.#.#.........#########", + "####.L...#.........###########....######", + "#######.############.........####.######", + "####.#...............#######....#.######", + "####.#################..#.L###.##.######", + "####.#....#............L#...#...#.######", + "####.#.##.#.#####.#######.#####.#.######", + "####.#..#.#.....#.......#.....#.#.######", + "####.#..#.#####.#######.#####.#.########", + "####.#.L#.#.....#.....#.....#.#.#.######", + "####.####.#.#####.###.#.#.#.#.#.#.######", + "####.#....#.........#.#.#.#.#.#.#.######", + "####.#.####.#########.#.#.#.###.#.######", + "####.#....#.....#.....#.#.#.....#.######", + "####.############.#####.#.#######.######", + "####..............#.....#.........######", + "########################################", + "########################################" + ], + "warps": [ + { + "x": 33, + "y": 4, + "dest_map": "CeruleanCave_1F", + "dest_warp": 1 + }, + { + "x": 13, + "y": 4, + "dest_map": "CeruleanCave_1F", + "dest_warp": 3 + }, + { + "x": 7, + "y": 14, + "dest_map": "CeruleanCave_1F", + "dest_warp": 4 + }, + { + "x": 26, + "y": 9, + "dest_map": "CeruleanCave_1F", + "dest_warp": 5 + }, + { + "x": 23, + "y": 10, + "dest_map": "CeruleanCave_1F", + "dest_warp": 6 + }, + { + "x": 5, + "y": 6, + "dest_map": "CeruleanCave_1F", + "dest_warp": 7 + } + ], + "objects": [ + { + "x": 9, + "y": 18, + "kind": "item_ball", + "flag": "FLAG_HIDE_CERULEAN_CAVE_2F_PP_UP", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 29, + "y": 16, + "kind": "item_ball", + "flag": "FLAG_HIDE_CERULEAN_CAVE_2F_ULTRA_BALL", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 33, + "y": 12, + "kind": "item_ball", + "flag": "FLAG_HIDE_CERULEAN_CAVE_2F_FULL_RESTORE", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 33, + "y": 10, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_12", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 33, + "y": 9, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_13", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 25, + "y": 11, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_14", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 28, + "y": 20, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_15", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 30, + "y": 20, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_16", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 9, + "y": 13, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_17", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 23, + "y": 16, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_18", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 13, + "y": 6, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_19", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 4, + "y": 12, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_1A", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 10, + "y": 20, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_1B", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_B1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_B1F.json new file mode 100644 index 0000000000..58f72c3415 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_B1F.json @@ -0,0 +1,170 @@ +{ + "name": "CeruleanCave_B1F", + "width": 40, + "height": 23, + "tiles": [ + "########################################", + "##..............##.....############....#", + "##..............#........#######.......#", + "##..............#..####.....#######....#", + "##......#####.###..####.....#######....#", + "##......#..........########.#######.#..#", + "##..##..##........#########............#", + "##..#L..###......##########............#", + "##......#~~~~~##................#...####", + "#########~~~~~##................#...####", + "#~~~############................#...####", + "#~~~##############.########.###.#...####", + "#~~~#.#.#.########........#.###.#...####", + "#~~~#.....########........#.....#...####", + "#~~~#.....########........#.....#...####", + "#~~~###.###~~~~#......#...#.###.#...####", + "#~~~~~~~~~~~~~~#......#...#.###.#...####", + "#~~~~~~~~~~~~~~#......#...#.....#...####", + "#~~~~~~~~~~~~~~#......#...#.....#...####", + "######~~~~~~~~~##.##.##...###.###...####", + "######~~~~~~~~~~~~#.......###.......####", + "######~~~~~~~~~~~~##.....####.......####", + "########################################" + ], + "elevation": [ + "0000000000000000000000000000000000000000", + "0033333333333333003333300000000000033330", + "0033333333333333033333333000000033333330", + "0033333333333333033000033333000000033330", + "0033333300000300033000033333000000033330", + "0033333303333333333000000003000000030330", + "0033003300333333330000000003333333333330", + "0033033300033333300000000003333333333330", + "0033333301111100444444444444444403330000", + "0000000001111100444444444444444403330000", + "0111000000000000444444444444444403330000", + "0111000000000000000000000004000403330000", + "0111030303000000003333333304000403330000", + "0111033333000000003333333304444403330000", + "0111033333000000003333333304444403330000", + "0111000300011110444444033304000403330000", + "0111111111111110444444033304000403330000", + "0111111111111110444444033304444403330000", + "0111111111111110404444033304444403330000", + "0000001111111110030000033300000003330000", + "0000001111111111110333333300033333330000", + "0000001111111111110033333000033333330000", + "0000000000000000000000000000000000000000" + ], + "warps": [ + { + "x": 5, + "y": 7, + "dest_map": "CeruleanCave_1F", + "dest_warp": 2 + } + ], + "objects": [ + { + "x": 31, + "y": 9, + "kind": "item_ball", + "flag": "FLAG_HIDE_CERULEAN_CAVE_B1F_ULTRA_BALL", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 32, + "y": 2, + "kind": "item_ball", + "flag": "FLAG_HIDE_CERULEAN_CAVE_B1F_MAX_REVIVE", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 7, + "y": 12, + "kind": "mewtwo", + "flag": "FLAG_HIDE_MEWTWO", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 37, + "y": 1, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_12", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 38, + "y": 2, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_13", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 35, + "y": 1, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_14", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 37, + "y": 4, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_15", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 35, + "y": 5, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_16", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 2, + "y": 2, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_17", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 4, + "y": 1, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_18", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 6, + "y": 1, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_19", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 3, + "y": 4, + "kind": "rock_smash_rock", + "flag": "FLAG_TEMP_1A", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [ + { + "name": "mewtwo", + "x": 7, + "y": 12 + } + ], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json new file mode 100644 index 0000000000..af06b3db98 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json @@ -0,0 +1,291 @@ +{ + "name": "CeruleanCity", + "width": 48, + "height": 40, + "tiles": [ + "################~~~~~#...#...#~~~~~~~~~~~~~~~~~~", + "################~~~~~#...#JJJ#~~~~~~~~~~~~~~~~~~", + "####~~~~~~~~~~~~~~~~~#...#...#~~~~~~~~~~~~~~~~~~", + "####~~~~~~~~~~~~~~~~~#...#...#~~~~~~~~~~~~~~~~~~", + "####~~~~~~~~~~~~~~~~~#...#...###################", + "####~~~###############...#...#.........#########", + "####~~~#.............#...#...#.........#########", + "####~~~#.............#...#...#.........#########", + "####~~~##.v.##########.......#.v.##...##########", + "####~~~###############......#######...##########", + "####~~~###############......#######...##########", + "####~~~###D######D####......##D####......#######", + "#C##~~~#..........................#......#######", + "....~~~#..........................#......#######", + "....~~~#..........................#......#######", + "....~~~#.....#######..............#......#######", + "~~~~~~~#...JJ############.........#......#......", + "~~~~~~~#.....##D#########.........#......#######", + "~~~~~~~#............#####JJJ#######.............", + "########............SSD##...#######.............", + "............................#######JJJ#..#######", + "...........................S..#D#.....#..#......", + "......................................#..#######", + "#######...............................#..#######", + "#######.....####......................#..#######", + "#######....#####....S.................#..#######", + "#######....#####.....###############..#..#######", + "#######....#####.....###############..#..#######", + "#######....S#CC#.....##D###SSD######..#..#######", + "#######...............................#..#######", + "#######...............................#..#######", + "#######...............................#..#######", + "###################S######.############..#######", + "#######..................................#######", + "#######..................................#######", + "###############....#........#....###############", + "###############....#JJJJJJJJ#....###############", + "###############....#........#....###############", + "###############....#........#....###############", + "###############....#........#....###############" + ], + "elevation": [ + "000000000000000011111033303330100000000000000000", + "000000000000000011111033300000100000000000000000", + "000011111111111111111033303330100000000000000000", + "000011111111111111111033303330111111111111111111", + "000011111111111111111033303330000000000000000000", + "000011100000000000000033303330333333333000000000", + "000011103333333333333033303330333333333000000000", + "000011103333333333333033303330333333333000000000", + "000011100333000000000033333330333003330000000000", + "000011100000000000000033333300000003330000000000", + "000011100000000000000033333300000003330000000000", + "000011100000000000000033333300000003333330000000", + "030011103333333333333333333333333303333330000000", + "333311103333333333333333333333333303333330000000", + "333311103333333333333333333333333303333330000000", + "333311103333300000003333333333333303333330000000", + "111111103330000000000000033333333303333330333333", + "111111103333300000000000033333333303333330000000", + "111111103333333333330000000000000003333333333333", + "000000003333333333330000033300000003333333333333", + "333333333333333333333333333300000000000330000000", + "333333333333333333333333333033000333330330333333", + "333333333333333333333333333333333333330330000000", + "000000033333333333333333333333333333330330000000", + "000000033333000033333333333333333333330330000000", + "000000033330000033330333333333333333330330000000", + "000000033330000033333000000000000000330330000000", + "000000033330000033333000000000000000330330000000", + "000000033330033033333000000000000000330330000000", + "000000033333333333333333333333333333330330000000", + "000000033333333333333333333333333333330330000000", + "000000033333333333333333333333333333330330000000", + "000000000000000000000000003000000000000330000000", + "000000033333333333333333333333333333333330000000", + "000000033333333333333333333333333333333330000000", + "000000000000000333303333333303333000000000000000", + "000000000000000333300000000003333000000000000000", + "000000000000000333303333333303333000000000000000", + "000000000000000333303333333303333000000000000000", + "000000000000000333303333333303333000000000000000" + ], + "warps": [ + { + "x": 10, + "y": 11, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 30, + "y": 11, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 15, + "y": 17, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 22, + "y": 19, + "dest_map": "CeruleanCity_PokemonCenter_1F", + "dest_warp": 1 + }, + { + "x": 31, + "y": 21, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 13, + "y": 28, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 29, + "y": 28, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 1, + "y": 12, + "dest_map": "CeruleanCave_1F", + "dest_warp": 0 + }, + { + "x": 10, + "y": 8, + "dest_map": "", + "dest_warp": 3 + }, + { + "x": 31, + "y": 8, + "dest_map": "", + "dest_warp": 3 + }, + { + "x": 31, + "y": 9, + "dest_map": "", + "dest_warp": 3 + }, + { + "x": 14, + "y": 28, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 23, + "y": 28, + "dest_map": "", + "dest_warp": 0 + }, + { + "x": 17, + "y": 11, + "dest_map": "", + "dest_warp": 0 + } + ], + "objects": [ + { + "x": 31, + "y": 12, + "kind": "policeman", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 33, + "y": 6, + "kind": "rocket_m", + "flag": "FLAG_HIDE_CERULEAN_ROCKET", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 16, + "y": 21, + "kind": "little_boy", + "flag": "", + "wander_x": 0, + "wander_y": 3 + }, + { + "x": 9, + "y": 23, + "kind": "balding_man", + "flag": "", + "wander_x": 1, + "wander_y": 1 + }, + { + "x": 32, + "y": 29, + "kind": "slowbro", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 33, + "y": 29, + "kind": "lass", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 34, + "y": 22, + "kind": "youngster", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 22, + "y": 0, + "kind": "blue", + "flag": "FLAG_HIDE_CERULEAN_RIVAL", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 26, + "y": 32, + "kind": "cut_tree", + "flag": "FLAG_TEMP_13", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 50, + "y": 18, + "kind": "cut_tree", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 12, + "y": 30, + "kind": "woman_1", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 1, + "y": 13, + "kind": "cooltrainer_m", + "flag": "FLAG_HIDE_CERULEAN_CAVE_GUARD", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [ + { + "direction": "north", + "offset": 12, + "map": "Route24" + } + ], + "points": [], + "flag_sets": [ + { + "name": "after_hall_of_fame", + "flags": [ + "FLAG_HIDE_CERULEAN_CAVE_GUARD", + "FLAG_HIDE_CERULEAN_RIVAL", + "FLAG_HIDE_CERULEAN_ROCKET" + ] + } + ] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity_PokemonCenter_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity_PokemonCenter_1F.json new file mode 100644 index 0000000000..22d90bfb20 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity_PokemonCenter_1F.json @@ -0,0 +1,127 @@ +{ + "name": "CeruleanCity_PokemonCenter_1F", + "width": 15, + "height": 10, + "tiles": [ + "#.#############", + "###############", + "....###..##....", + "....#######....", + "...............", + "...............", + "#L.........##..", + "...........##..", + ".......v.......", + "###############" + ], + "elevation": [ + "030000000000000", + "000000000000000", + "333300033003333", + "333300000003333", + "333333333333333", + "330333333333333", + "044033333330033", + "330333333330033", + "333333333333333", + "000000000000000" + ], + "warps": [ + { + "x": 6, + "y": 8, + "dest_map": "CeruleanCity", + "dest_warp": 3 + }, + { + "x": 7, + "y": 8, + "dest_map": "CeruleanCity", + "dest_warp": 3 + }, + { + "x": 8, + "y": 8, + "dest_map": "CeruleanCity", + "dest_warp": 3 + }, + { + "x": 1, + "y": 6, + "dest_map": "", + "dest_warp": 0 + } + ], + "objects": [ + { + "x": 7, + "y": 2, + "kind": "nurse", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 12, + "y": 5, + "kind": "gentleman", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 5, + "y": 4, + "kind": "rocker", + "flag": "", + "wander_x": 1, + "wander_y": 0 + }, + { + "x": 4, + "y": 8, + "kind": "youngster", + "flag": "", + "wander_x": 1, + "wander_y": 0 + }, + { + "x": 3, + "y": 3, + "kind": "lass", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 2, + "y": 1, + "kind": "0", + "flag": "FLAG_HIDE_POSTGAME_GOSSIPERS", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 3, + "y": 1, + "kind": "0", + "flag": "FLAG_HIDE_POSTGAME_GOSSIPERS", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [ + { + "name": "pc", + "x": 11, + "y": 2 + }, + { + "name": "nurse_front", + "x": 7, + "y": 4 + } + ], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown.json new file mode 100644 index 0000000000..2794c4b8d7 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown.json @@ -0,0 +1,110 @@ +{ + "name": "PalletTown", + "width": 24, + "height": 20, + "tiles": [ + "############..##########", + "############..##########", + "##....................##", + "##....................##", + "##...#####....#####...##", + "##...#####....#####...##", + "##...#####....#####...##", + "##..S#D###...S#D###...##", + "##....................##", + "##....................##", + "##...........#######..##", + "##...####S...#######..##", + "##...........#######..##", + "##...........###D###..##", + "##...S................##", + "##....................##", + "##...........###S##...##", + "##.....~~~~...........##", + "##.....~~~~...........##", + "##.....~~~~...........##" + ], + "elevation": [ + "000000000000330000000000", + "000000000000330000000000", + "003333333333333333333300", + "003333333333333333333300", + "003330000033330000033300", + "003330000033330000033300", + "003330000033330000033300", + "003300000033300000033300", + "003333333333333333333300", + "003333333333333333333300", + "003333333333300000003300", + "003330000033300000003300", + "003333333333300000003300", + "003333333333300000003300", + "003330333333333333333300", + "003333333333333333333300", + "003333333333300000033300", + "003333311113333333333300", + "003333311113333333333300", + "003333311113333333333300" + ], + "warps": [ + { + "x": 6, + "y": 7, + "dest_map": "PalletTown_PlayersHouse_1F", + "dest_warp": 1 + }, + { + "x": 15, + "y": 7, + "dest_map": "PalletTown_RivalsHouse", + "dest_warp": 0 + }, + { + "x": 16, + "y": 13, + "dest_map": "PalletTown_ProfessorOaksLab", + "dest_warp": 0 + } + ], + "objects": [ + { + "x": 3, + "y": 10, + "kind": "woman_1", + "flag": "", + "wander_x": 1, + "wander_y": 4 + }, + { + "x": 13, + "y": 17, + "kind": "fat_man", + "flag": "", + "wander_x": 6, + "wander_y": 2 + }, + { + "x": 10, + "y": 8, + "kind": "prof_oak", + "flag": "FLAG_HIDE_OAK_IN_PALLET_TOWN", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [ + { + "direction": "north", + "offset": 0, + "map": "Route1" + } + ], + "points": [ + { + "name": "oaks_lab_front", + "x": 16, + "y": 14 + } + ], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_1F.json new file mode 100644 index 0000000000..c4b5a50cdc --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_1F.json @@ -0,0 +1,56 @@ +{ + "name": "PalletTown_PlayersHouse_1F", + "width": 13, + "height": 10, + "tiles": [ + "#############", + "#############", + "#.........>##", + "#............", + "#.....##.....", + "#.....##.....", + "#............", + "##..........#", + "#...v........", + "#############" + ], + "warps": [ + { + "x": 5, + "y": 8, + "dest_map": "PalletTown", + "dest_warp": 0 + }, + { + "x": 4, + "y": 8, + "dest_map": "PalletTown", + "dest_warp": 0 + }, + { + "x": 10, + "y": 2, + "dest_map": "PalletTown_PlayersHouse_2F", + "dest_warp": 0 + }, + { + "x": 3, + "y": 9, + "dest_map": "PalletTown", + "dest_warp": 0 + } + ], + "objects": [ + { + "x": 8, + "y": 4, + "kind": "mom", + "flag": "", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_2F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_2F.json new file mode 100644 index 0000000000..c69bd6be3d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_2F.json @@ -0,0 +1,45 @@ +{ + "name": "PalletTown_PlayersHouse_2F", + "width": 12, + "height": 9, + "tiles": [ + "############", + "###########S", + "#.......##<.", + "#.......##..", + "#.s...#.....", + "#.n...#.....", + "#.#.........", + "#...........", + "#..........." + ], + "elevation": [ + "000000000000", + "000000000000", + "033333330033", + "033333330033", + "033333033333", + "003033033333", + "040403333333", + "003033333333", + "033333333333" + ], + "warps": [ + { + "x": 10, + "y": 2, + "dest_map": "PalletTown_PlayersHouse_1F", + "dest_warp": 2 + } + ], + "objects": [], + "connections": [], + "points": [ + { + "name": "start", + "x": 6, + "y": 6 + } + ], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json new file mode 100644 index 0000000000..0cc55ccd2b --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json @@ -0,0 +1,126 @@ +{ + "name": "PalletTown_ProfessorOaksLab", + "width": 13, + "height": 14, + "tiles": [ + "#############", + "######SS#####", + ".............", + "#............", + "###.....###..", + ".##..........", + ".............", + ".............", + "#####...#####", + ".............", + ".............", + ".............", + "#.....v.....#", + "#############" + ], + "warps": [ + { + "x": 6, + "y": 12, + "dest_map": "PalletTown", + "dest_warp": 2 + }, + { + "x": 7, + "y": 12, + "dest_map": "PalletTown", + "dest_warp": 2 + }, + { + "x": 5, + "y": 12, + "dest_map": "PalletTown", + "dest_warp": 2 + } + ], + "objects": [ + { + "x": 3, + "y": 11, + "kind": "scientist", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 2, + "y": 10, + "kind": "worker_f", + "flag": "", + "wander_x": 0, + "wander_y": 4 + }, + { + "x": 11, + "y": 10, + "kind": "scientist", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 6, + "y": 3, + "kind": "prof_oak", + "flag": "FLAG_HIDE_OAK_IN_HIS_LAB", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 8, + "y": 4, + "kind": "item_ball", + "flag": "FLAG_HIDE_BULBASAUR_BALL", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 9, + "y": 4, + "kind": "item_ball", + "flag": "FLAG_HIDE_SQUIRTLE_BALL", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 10, + "y": 4, + "kind": "item_ball", + "flag": "FLAG_HIDE_CHARMANDER_BALL", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 5, + "y": 4, + "kind": "blue", + "flag": "FLAG_HIDE_RIVAL_IN_LAB", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 4, + "y": 1, + "kind": "pokedex", + "flag": "FLAG_HIDE_POKEDEX", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 5, + "y": 1, + "kind": "pokedex", + "flag": "FLAG_HIDE_POKEDEX", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json new file mode 100644 index 0000000000..7e4d85de31 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json @@ -0,0 +1,58 @@ +{ + "name": "PalletTown_RivalsHouse", + "width": 13, + "height": 10, + "tiles": [ + "#############", + "#############", + ".............", + ".............", + "......##.....", + "......##.....", + ".............", + ".............", + "#...v.......#", + "#############" + ], + "warps": [ + { + "x": 4, + "y": 8, + "dest_map": "PalletTown", + "dest_warp": 1 + }, + { + "x": 5, + "y": 8, + "dest_map": "PalletTown", + "dest_warp": 1 + }, + { + "x": 3, + "y": 8, + "dest_map": "PalletTown", + "dest_warp": 1 + } + ], + "objects": [ + { + "x": 10, + "y": 6, + "kind": "daisy", + "flag": "", + "wander_x": 1, + "wander_y": 3 + }, + { + "x": 6, + "y": 4, + "kind": "town_map", + "flag": "FLAG_HIDE_TOWN_MAP", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json new file mode 100644 index 0000000000..924deae088 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json @@ -0,0 +1,164 @@ +{ + "name": "PewterCity", + "width": 48, + "height": 40, + "tiles": [ + "################################################", + "#######################....#####################", + "####........#################.........##########", + "####........#################.........##########", + "####........#############D######......##########", + "####........###########...............##########", + "#######.....#####C#####..#######........########", + "####JJJ..JJJJJJJ...SJJJJJJJJJJJJJJJJJ...########", + "####....................................########", + "####............................#####...########", + "######..........................#####...########", + "######..........................#D###...########", + "######..................................########", + "######...##.#######.##..................########", + "######...#############..................########", + "######...##.#######.##..................########", + "######...##S..#D#...##....####..........########", + "######...............#....######........########", + "######...............#....SSD###........########", + "######...............#.................S########", + "######################..........................", + "######..........................................", + "######.......#########..........................", + "######.......#########....##########............", + "######.......#########....##########....########", + "######.......##SSD####....#####S#####...########", + "######....................#.........#...########", + "######....................#.........#...########", + "######..#####.............#.........#...########", + "######..#####.............#.........#...########", + "######..#D###.......S.....#JJJJ.JJJJ#...########", + "######..................................########", + "######..................................########", + "######..................................########", + "######..................................########", + "######..................................########", + "####################....########################", + "####################....########################", + "####################....########################", + "####################....########################" + ], + "warps": [ + { + "x": 17, + "y": 6, + "dest_map": "PewterCity_Museum_1F", + "dest_warp": 1 + }, + { + "x": 25, + "y": 4, + "dest_map": "PewterCity_Museum_1F", + "dest_warp": 3 + }, + { + "x": 15, + "y": 16, + "dest_map": "PewterCity_Gym", + "dest_warp": 1 + }, + { + "x": 28, + "y": 18, + "dest_map": "PewterCity_Mart", + "dest_warp": 1 + }, + { + "x": 33, + "y": 11, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 17, + "y": 25, + "dest_map": "PewterCity_PokemonCenter_1F", + "dest_warp": 1 + }, + { + "x": 9, + "y": 30, + "dest_map": "", + "dest_warp": 1 + } + ], + "objects": [ + { + "x": 6, + "y": 15, + "kind": "lass", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 33, + "y": 17, + "kind": "man", + "flag": "FLAG_HIDE_PEWTER_MUSEUM_GUIDE", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 21, + "y": 28, + "kind": "fat_man", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 33, + "y": 27, + "kind": "bug_catcher", + "flag": "", + "wander_x": 2, + "wander_y": 0 + }, + { + "x": 42, + "y": 20, + "kind": "boy", + "flag": "FLAG_HIDE_PEWTER_CITY_GYM_GUIDE", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 30, + "y": 5, + "kind": "cut_tree", + "flag": "FLAG_TEMP_12", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 46, + "y": 20, + "kind": "scientist", + "flag": "FLAG_HIDE_PEWTER_CITY_RUNNING_SHOES_GUY", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [ + { + "direction": "south", + "offset": 12, + "map": "Route2" + } + ], + "points": [ + { + "name": "gym_front", + "x": 15, + "y": 17 + } + ], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json new file mode 100644 index 0000000000..4c478d8e8e --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json @@ -0,0 +1,78 @@ +{ + "name": "PewterCity_Gym", + "width": 13, + "height": 16, + "tiles": [ + "#############", + "####.....####", + "#############", + "#....#.#....#", + "#...........#", + "#...#...#...#", + "#...........#", + "#..#.#.#.#..#", + "##.........##", + "#...#...#...#", + "##.........##", + "#...........#", + "#...S...S...#", + "#...........#", + "#.....v.....#", + "#############" + ], + "warps": [ + { + "x": 5, + "y": 14, + "dest_map": "PewterCity", + "dest_warp": 2 + }, + { + "x": 6, + "y": 14, + "dest_map": "PewterCity", + "dest_warp": 2 + }, + { + "x": 7, + "y": 14, + "dest_map": "PewterCity", + "dest_warp": 2 + } + ], + "objects": [ + { + "x": 6, + "y": 5, + "kind": "brock", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 3, + "y": 8, + "kind": "camper", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 7, + "y": 12, + "kind": "gym_guy", + "flag": "", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [ + { + "name": "brock_front", + "x": 6, + "y": 6 + } + ], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json new file mode 100644 index 0000000000..1cdef57978 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json @@ -0,0 +1,76 @@ +{ + "name": "PewterCity_Mart", + "width": 11, + "height": 9, + "tiles": [ + "###########", + "###########", + "##.#......#", + "...#.......", + "####...##.#", + ".......##.#", + ".##....##.#", + "....v......", + "###########" + ], + "elevation": [ + "00000000000", + "00000000000", + "00303333330", + "33003333333", + "00003330030", + "33333330030", + "30033330030", + "33333333333", + "00000000000" + ], + "warps": [ + { + "x": 3, + "y": 7, + "dest_map": "PewterCity", + "dest_warp": 3 + }, + { + "x": 4, + "y": 7, + "dest_map": "PewterCity", + "dest_warp": 3 + }, + { + "x": 5, + "y": 7, + "dest_map": "PewterCity", + "dest_warp": 3 + } + ], + "objects": [ + { + "x": 8, + "y": 2, + "kind": "youngster", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 6, + "y": 4, + "kind": "boy", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 2, + "y": 3, + "kind": "clerk", + "flag": "", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Museum_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Museum_1F.json new file mode 100644 index 0000000000..ecf6acb232 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Museum_1F.json @@ -0,0 +1,109 @@ +{ + "name": "PewterCity_Museum_1F", + "width": 28, + "height": 11, + "tiles": [ + "############################", + "############################", + "...............#............", + "...............#......#....#", + "...####........#...........#", + "...............#............", + "...........#...#...........#", + "...####..###...###.........#", + "........>###.....#..........", + "#........###..v.##...v..##..", + "############################" + ], + "warps": [ + { + "x": 13, + "y": 9, + "dest_map": "PewterCity", + "dest_warp": 0 + }, + { + "x": 14, + "y": 9, + "dest_map": "PewterCity", + "dest_warp": 0 + }, + { + "x": 15, + "y": 9, + "dest_map": "PewterCity", + "dest_warp": 0 + }, + { + "x": 21, + "y": 9, + "dest_map": "PewterCity", + "dest_warp": 1 + }, + { + "x": 22, + "y": 9, + "dest_map": "PewterCity", + "dest_warp": 1 + }, + { + "x": 8, + "y": 8, + "dest_map": "", + "dest_warp": 0 + } + ], + "objects": [ + { + "x": 16, + "y": 5, + "kind": "worker_m", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 2, + "y": 4, + "kind": "old_man_1", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 21, + "y": 3, + "kind": "scientist", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 22, + "y": 3, + "kind": "old_amber", + "flag": "FLAG_HIDE_OLD_AMBER", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 26, + "y": 4, + "kind": "scientist", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 26, + "y": 7, + "kind": "scientist", + "flag": "", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_PokemonCenter_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_PokemonCenter_1F.json new file mode 100644 index 0000000000..e6c20a0d10 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_PokemonCenter_1F.json @@ -0,0 +1,122 @@ +{ + "name": "PewterCity_PokemonCenter_1F", + "width": 15, + "height": 10, + "tiles": [ + "#.#############", + "###############", + "....###..##....", + "....#######....", + "...............", + "...............", + "#L.........##..", + "...........##..", + ".......v.......", + "###############" + ], + "elevation": [ + "030000000000000", + "000000000000000", + "333300033003333", + "333300000003333", + "333333333333333", + "330333333333333", + "044033333330033", + "330333333330033", + "333333333333333", + "000000000000000" + ], + "warps": [ + { + "x": 6, + "y": 8, + "dest_map": "PewterCity", + "dest_warp": 5 + }, + { + "x": 7, + "y": 8, + "dest_map": "PewterCity", + "dest_warp": 5 + }, + { + "x": 8, + "y": 8, + "dest_map": "PewterCity", + "dest_warp": 5 + }, + { + "x": 1, + "y": 6, + "dest_map": "", + "dest_warp": 0 + } + ], + "objects": [ + { + "x": 2, + "y": 2, + "kind": "jigglypuff", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 4, + "y": 8, + "kind": "gentleman", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 7, + "y": 2, + "kind": "nurse", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 1, + "y": 2, + "kind": "youngster", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 13, + "y": 2, + "kind": "woman_1", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 10, + "y": 7, + "kind": "gba_kid", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 14, + "y": 6, + "kind": "gba_kid", + "flag": "", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [ + { + "name": "nurse_front", + "x": 7, + "y": 4 + } + ], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route1.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route1.json new file mode 100644 index 0000000000..9c0ea3ca1d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route1.json @@ -0,0 +1,80 @@ +{ + "name": "Route1", + "width": 24, + "height": 40, + "tiles": [ + "##########....##########", + "##########....##########", + "##....................##", + "##....................##", + "##......##............##", + "##JJJJJJ##JJJJJJ......##", + "##......##\"\"\"\"\"\"\"\"\"\"\"\"##", + "##......##\"\"\"\"\"\"\"\"\"\"\"\"##", + "##......##\"\"\"\"\"\"\"\"\"\"\"\"##", + "##......##\"\"\"\"\"\"\"\"\"\"\"\"##", + "##JJJJJJ##\"\"\"\"\"\"\"\"\"\"\"\"##", + "##......##............##", + "##....................##", + "##..............\"\"\"\"\"\"##", + "##..............\"\"\"\"\"\"##", + "####JJJJJJ######\"\"\"\"\"\"##", + "####......######\"\"\"\"\"\"##", + "##..............\"\"\"\"\"\"##", + "##....................##", + "##....................##", + "##JJ.JJJJ..JJJJJJJJJJJ##", + "##....................##", + "##....................##", + "##....................##", + "##..........\"\"\"\"\"\"....##", + "############\"\"\"\"\"\"....##", + "############\"\"\"\"\"\"JJJJ##", + "##..........\"\"\"\"\"\"....##", + "##..........\"\"\"\"\"\"....##", + "##....................##", + "##....................##", + "##JJJJ...SJJJJJJJJJJJJ##", + "##..\"\"\"\"\"\"\"......\"\"\"\"\"##", + "##..\"\"\"\"\"\"\"......\"\"\"\"\"##", + "##\"\"\"\"\"\"\"......\"\"\"\"\"..##", + "##\"\"\"\"\"\"\"...\"\".\"\"\"\"\"..##", + "############\"\"##########", + "##.........#\"\"#.......##", + "############\"\"##########", + "############\"\"##########" + ], + "warps": [], + "objects": [ + { + "x": 6, + "y": 28, + "kind": "clerk", + "flag": "", + "wander_x": 0, + "wander_y": 1 + }, + { + "x": 19, + "y": 16, + "kind": "boy", + "flag": "", + "wander_x": 1, + "wander_y": 0 + } + ], + "connections": [ + { + "direction": "north", + "offset": -12, + "map": "ViridianCity" + }, + { + "direction": "south", + "offset": 0, + "map": "PalletTown" + } + ], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2.json new file mode 100644 index 0000000000..6e4337074e --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2.json @@ -0,0 +1,221 @@ +{ + "name": "Route2", + "width": 24, + "height": 80, + "tiles": [ + "########....############", + "########....############", + "##\"\"\"\"\"\"\"...############", + "##\"\"\"\"\"\"\"...#.........##", + "##\"\"\"\"\"\"\"...#.........##", + "##\"\"\"\"\"\"\"...#.........##", + "##\"\"\"\"\"\"\"...#########.##", + "##\"\"\"\"\"\"\"...#########.##", + "##\"\"\"\"\"\"\"...#########.##", + "##..........#########.##", + "##..........#########.##", + "##..........#####C###.##", + "##..........#.S.......##", + "####.vv.###.#.........##", + "###########...........##", + "##########............##", + "##############........##", + "##############........##", + "##############........##", + "##############........##", + "##############........##", + "###################...##", + "#################D#...##", + "##############........##", + "################......##", + "################......##", + "##################.#####", + "################......##", + "################......##", + "################......##", + "################......##", + "################......##", + "################JJJ.JJ##", + "################......##", + "################......##", + "################......##", + "################......##", + "################JJJ.JJ##", + "################......##", + "################......##", + "################......##", + "#################.vv.###", + "########################", + "########################", + "########################", + "##........##############", + "##################CC####", + "#################....###", + "################......##", + "################......##", + "###.####.#######......##", + "#####CC#########JJJ.JJ##", + "####....########......##", + "##............##......##", + "##............##......##", + "##JJJJJJJJJ...##......##", + "##....\"\"\"\"\"\"\".##......##", + "##....\"\"\"\"\"\"\".##JJ.JJJ##", + "##....\"\"\"\"\"\"\".##......##", + "##....\"\"\"\"\"\"\".##......##", + "##....\"\"\"\"\"\"\".##......##", + "##............##......##", + "##....................##", + "##....##########......##", + "##....##########......##", + "##....##########......##", + "##....##########......##", + "##............##......##", + "##............##......##", + "##....................##", + "##JJJJJJJ..JJJ..JJ.JJJ##", + "##............##......##", + "####..........##......##", + "####...S......##......##", + "####..........##......##", + "####..........##......##", + "####..........##......##", + "####..........##......##", + "#######.......##########", + "#######.....############" + ], + "warps": [ + { + "x": 5, + "y": 13, + "dest_map": "Route2_ViridianForest_NorthEntrance", + "dest_warp": 3 + }, + { + "x": 6, + "y": 13, + "dest_map": "Route2_ViridianForest_NorthEntrance", + "dest_warp": 3 + }, + { + "x": 5, + "y": 51, + "dest_map": "Route2_ViridianForest_SouthEntrance", + "dest_warp": 1 + }, + { + "x": 17, + "y": 11, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 17, + "y": 22, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 18, + "y": 46, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 18, + "y": 41, + "dest_map": "", + "dest_warp": 3 + }, + { + "x": 19, + "y": 41, + "dest_map": "", + "dest_warp": 3 + }, + { + "x": 19, + "y": 46, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 6, + "y": 51, + "dest_map": "Route2_ViridianForest_SouthEntrance", + "dest_warp": 1 + } + ], + "objects": [ + { + "x": 16, + "y": 62, + "kind": "cut_tree", + "flag": "FLAG_TEMP_14", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 15, + "y": 69, + "kind": "cut_tree", + "flag": "FLAG_TEMP_13", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 11, + "y": 13, + "kind": "cut_tree", + "flag": "FLAG_TEMP_15", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 18, + "y": 26, + "kind": "cut_tree", + "flag": "FLAG_TEMP_16", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 17, + "y": 54, + "kind": "item_ball", + "flag": "FLAG_HIDE_ROUTE2_ETHER", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 17, + "y": 64, + "kind": "item_ball", + "flag": "FLAG_HIDE_ROUTE2_PARALYZE_HEAL", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 6, + "y": 85, + "kind": "cut_tree", + "flag": "", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [ + { + "direction": "north", + "offset": -12, + "map": "PewterCity" + }, + { + "direction": "south", + "offset": -12, + "map": "ViridianCity" + } + ], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route22.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route22.json new file mode 100644 index 0000000000..ef4a2a11fb --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route22.json @@ -0,0 +1,90 @@ +{ + "name": "Route22", + "width": 48, + "height": 24, + "tiles": [ + "#############################################...", + "###########################################.#...", + "##################################........#.###.", + "##################################JJJJ.JJJ#...##", + "######################....................#.....", + "########D######...........................######", + "#####.......###.........................##......", + "###...........#.............######......##......", + "###...........#JJJJJJJ~~~~~~######JJ..JJ##......", + "###JJJJJJJ..JJ#\"\"\"\"\"\"\"~~~~~~######\"\"\"\"\"\"##......", + "###...........#\"\"\"\"\"\"\"~~~~~~######\"\"\"\"\"\"##....##", + "###...........#\"\"\"\"\"\"\"~~~~~~######\"\"\"\"\"\"##....##", + "####...S#######\"\"\"\"\"\"\"......######\"\"\"\"\"\"##....##", + "####...........\"\"\"\"\"\"\"......######\"\"\"\"\"\"##....##", + "####........................######............##", + "####JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ..JJJJJ##", + "####..........................................##", + "####..........................................##", + "####..........................................##", + "################################################", + "################################################", + "################################################", + "################################################", + "################################################" + ], + "elevation": [ + "000000000000000000000000000000000000000000000333", + "000000000000000000000000000000000000000000030333", + "000000000000000000000000000000000033333333030003", + "000000000000000000000000000000000000003000033300", + "000000000000000000000033333333333333333333033333", + "000000000000000333333333333333333333333333000000", + "000003333333000333333333333333333333333300333333", + "000333333333330333333333333300000033333300333333", + "000333333333330000000011111100000000330000333333", + "000000000033000333333311111100000033333300333333", + "000333333333330333333311111100000033333300333300", + "000333333333330333333311111100000033333300333300", + "000033300000000333333333333300000033333300333300", + "000033333333333333333333333300000033333300333300", + "000033333333333333333333333300000033333333333300", + "000000000000000000000000000000000000000330000000", + "000033333333333333333333333333333333333333333300", + "000033333333333333333333333333333333333333333300", + "000033333333333333333333333333333333333333333300", + "000000000000000000000000000000000000000000000000", + "000000000000000000000000000000000000000000000000", + "000000000000000000000000000000000000000000000000", + "000000000000000000000000000000000000000000000000", + "000000000000000000000000000000000000000000000000" + ], + "warps": [ + { + "x": 8, + "y": 5, + "dest_map": "", + "dest_warp": 2 + }, + { + "x": 9, + "y": 5, + "dest_map": "", + "dest_warp": 2 + } + ], + "objects": [ + { + "x": 25, + "y": 4, + "kind": "blue", + "flag": "FLAG_HIDE_ROUTE_22_RIVAL", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [ + { + "direction": "east", + "offset": -10, + "map": "ViridianCity" + } + ], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json new file mode 100644 index 0000000000..ecac345dff --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json @@ -0,0 +1,165 @@ +{ + "name": "Route24", + "width": 24, + "height": 40, + "tiles": [ + "########################", + "########################", + "########################", + "####.........J...J......", + "####.........J...J......", + "####.........J...J......", + "###JJJJ..JJJJ#...#JJJJJJ", + "###.....................", + "###.....................", + "###.....................", + "###..........###########", + "###..........#..........", + "###..........#...#######", + "###..........#...#######", + "###..........#...#######", + "###..........#...#######", + "###...~~~#...#...#######", + "###...~~~#...#...#######", + "###...~~~#...#...#######", + "###\"\"\"~~~#...#...#######", + "###\"\"\"~~~#...#...#######", + "###\"\"\"~~~#...#...#######", + "###\"\"\"~~~#...#...#######", + "###\"\"\"~~~#...#...#######", + "###\"\"\"~~~#...#...#######", + "###\"\"\"~~~#...#...#######", + "###\"\"\"~~~#...#...#######", + "###\"\"\"~~~#...#...#~~~~~~", + "###\"\"\"~~~#...#...#~~~~~~", + "###\"\"\"~~~#...#...#~~~~~~", + "###\"\"\"~~~#...#...#~~~~~~", + "###\"\"\"~~~#...#...#~~~~~~", + "####~~~~~#...#...#~~~~~~", + "####~~~~~#...#...#~~~~~~", + "####~~~~~#...#...#~~~~~~", + "####~~~~~#...#...#~~~~~~", + "####~~~~~#...#...#~~~~~~", + "####~~~~~#...#...#~~~~~~", + "####~~~~~#...#...#~~~~~~", + "####~~~~~#...#...#~~~~~~" + ], + "elevation": [ + "000000000000000000000000", + "000000000000000000000000", + "000000000000000000000000", + "000033333333303330333333", + "000033333333303330333333", + "000033333333303330333333", + "000000033000003330000000", + "000333333333333333333333", + "000333333333333333333333", + "000333333333333333333333", + "000333333333300000000000", + "000333333333303333333333", + "000333333333303330000000", + "000333333333303330000000", + "000333333333303330000000", + "000333333333303330000000", + "000333111033303330000000", + "000333111033303330000000", + "000333111033303330000000", + "000333111033303330000000", + "000333111033303330000000", + "000333111033303330000000", + "000333111033303330000000", + "000333111033303330000000", + "000333111033303330000000", + "000333111033303330000000", + "000333111033303330000000", + "000333111033303330111111", + "000333111033303330100000", + "000333111033303330100000", + "000333111033303330100000", + "000333111033303330100000", + "000011111033303330100000", + "000011111033303330100000", + "000011111033303330100000", + "000011111033303330100000", + "000011111033303330100000", + "000011111033303330100000", + "000011111033303330100000", + "000011111033303330100000" + ], + "warps": [], + "objects": [ + { + "x": 12, + "y": 15, + "kind": "man", + "flag": "FLAG_HIDE_NUGGET_BRIDGE_ROCKET", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 12, + "y": 19, + "kind": "camper", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 10, + "y": 22, + "kind": "lass", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 12, + "y": 25, + "kind": "youngster", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 10, + "y": 28, + "kind": "lass", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 12, + "y": 31, + "kind": "bug_catcher", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 5, + "y": 21, + "kind": "camper", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 11, + "y": 4, + "kind": "item_ball", + "flag": "FLAG_HIDE_ROUTE24_TM45", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [ + { + "direction": "south", + "offset": -12, + "map": "CeruleanCity" + } + ], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_NorthEntrance.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_NorthEntrance.json new file mode 100644 index 0000000000..e7776b1911 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_NorthEntrance.json @@ -0,0 +1,74 @@ +{ + "name": "Route2_ViridianForest_NorthEntrance", + "width": 15, + "height": 12, + "tiles": [ + "###############", + "#######C#######", + "##...#...#...##", + "#.............#", + "#..........##.#", + "###........##.#", + "#.............#", + "#..........##.#", + "###........##.#", + "#.............#", + "#......v......#", + "###############" + ], + "warps": [ + { + "x": 6, + "y": 10, + "dest_map": "ViridianForest", + "dest_warp": 2 + }, + { + "x": 7, + "y": 10, + "dest_map": "ViridianForest", + "dest_warp": 2 + }, + { + "x": 8, + "y": 10, + "dest_map": "ViridianForest", + "dest_warp": 2 + }, + { + "x": 7, + "y": 1, + "dest_map": "Route2", + "dest_warp": 0 + } + ], + "objects": [ + { + "x": 5, + "y": 4, + "kind": "youngster", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 4, + "y": 7, + "kind": "old_man_1", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 10, + "y": 5, + "kind": "cooltrainer_f", + "flag": "", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_SouthEntrance.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_SouthEntrance.json new file mode 100644 index 0000000000..d36530577d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_SouthEntrance.json @@ -0,0 +1,66 @@ +{ + "name": "Route2_ViridianForest_SouthEntrance", + "width": 15, + "height": 12, + "tiles": [ + "###############", + "#######C#######", + "##...#...#...##", + "#.............#", + "#..........##.#", + "###........##.#", + "#.............#", + "#..........##.#", + "###........##.#", + "#.............#", + "#......v......#", + "###############" + ], + "warps": [ + { + "x": 6, + "y": 10, + "dest_map": "Route2", + "dest_warp": 2 + }, + { + "x": 7, + "y": 10, + "dest_map": "Route2", + "dest_warp": 2 + }, + { + "x": 8, + "y": 10, + "dest_map": "Route2", + "dest_warp": 2 + }, + { + "x": 7, + "y": 1, + "dest_map": "ViridianForest", + "dest_warp": 0 + } + ], + "objects": [ + { + "x": 10, + "y": 6, + "kind": "woman_2", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 4, + "y": 7, + "kind": "woman_1", + "flag": "", + "wander_x": 1, + "wander_y": 1 + } + ], + "connections": [], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity.json new file mode 100644 index 0000000000..fb3714c07b --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity.json @@ -0,0 +1,214 @@ +{ + "name": "ViridianCity", + "width": 48, + "height": 40, + "tiles": [ + "###################.....########################", + "###################....S########################", + "###################.....########################", + "###################.....########################", + "###################.....####..............######", + "########..................................######", + "########.##########.......................######", + "########.###########.............######...######", + "########.##########..............######...######", + "########.###########...######....######...######", + "########.##########.....#####...S..#D#....######", + "########.###########...##D###.............######", + "########.##########........##JJJJJJJJJJJJJ######", + "########.###########......................######", + "########.##########.......................######", + "######...###########.........###################", + ".........##########.S..######.............######", + "........................#####.....####....######", + ".......................##D###.....####....######", + "..................................SSD#....######", + "#######...................................######", + "#######...................................######", + "#######...................................######", + "###########.............#####.............######", + "###########.##..........#####.............######", + "#######.....##..........#####.............######", + "#######....~~~~~~.......SSD##.............######", + "#######....~~~~~~.........................######", + "#######....~~~~~~.........................######", + "#######....~~~~~~.........................######", + "#######JJJJ~~~~~~JJJ...JJJJJJJJJJJJJJJJJJJ######", + "#######.............S.....................######", + "#######...................................######", + "#######...................................######", + "##############............................######", + "##############............................######", + "######################....######################", + "######################....######################", + "######################....######################", + "######################....######################" + ], + "elevation": [ + "000000000000000000033333000000000000000000000000", + "000000000000000000033330000000000000000000000000", + "000000000000000000033333000000000000000000000000", + "000000000000000000033333000000000000000000000000", + "000000000000000000033333000033333333333333000000", + "000000003333333333333333333333333333333333000000", + "000000003000000000033333333333333333333333000000", + "000000003000000000003333333333333000000333000000", + "000000003000000000033333333333333000000333000000", + "000000003000000000003330000003333000000333000000", + "000000003000000000033333000003330330003333000000", + "000000003000000000003330000003333333333333000000", + "000000003000000000033333333000000000000000000000", + "000000003000000000003333333333333333333333000000", + "000000003000000000033333333333333333333333000000", + "000000333000000000003333333330000000000000000000", + "333333333000000000030330000003333333333333000000", + "333333333333333333333333000003333300003333000000", + "333333333333333333333330000003333300003333000000", + "333333333333333333333333333333333300003333000000", + "000000033333333333333333333333333333333333000000", + "000000033333333333333333333333333333333333000000", + "000000033333333333333333333333333333333333000000", + "000000000003333333333333000003333333333333000000", + "000000000003003333333333000003333333333333000000", + "000000033333003333333333000003333333333333000000", + "000000033331111113333333000003333333333333000000", + "000000033331111113333333333333333333333333000000", + "000000033331111113333333333333333333333333000000", + "000000033331111113333333333333333333333333000000", + "000000000001111110003330000000000000000000000000", + "000000033333333333330333333333333333333333000000", + "000000033333333333333333333333333333333333000000", + "000000033333333333333333333333333333333333000000", + "000000000000003333333333333333333333333333000000", + "000000000000003333333333333333333333333333000000", + "000000000000000000000033330000000000000000000000", + "000000000000000000000033330000000000000000000000", + "000000000000000000000033330000000000000000000000", + "000000000000000000000033330000000000000000000000" + ], + "warps": [ + { + "x": 26, + "y": 26, + "dest_map": "ViridianCity_PokemonCenter_1F", + "dest_warp": 1 + }, + { + "x": 25, + "y": 11, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 36, + "y": 10, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 25, + "y": 18, + "dest_map": "", + "dest_warp": 1 + }, + { + "x": 36, + "y": 19, + "dest_map": "ViridianCity_Mart", + "dest_warp": 1 + } + ], + "objects": [ + { + "x": 8, + "y": 26, + "kind": "fat_man", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 11, + "y": 24, + "kind": "cut_tree", + "flag": "FLAG_TEMP_11", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 34, + "y": 11, + "kind": "old_man_1", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 21, + "y": 6, + "kind": "var_0", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 20, + "y": 12, + "kind": "woman_3", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 33, + "y": 26, + "kind": "youngster", + "flag": "", + "wander_x": 0, + "wander_y": 2 + }, + { + "x": 16, + "y": 22, + "kind": "boy", + "flag": "", + "wander_x": 1, + "wander_y": 2 + }, + { + "x": 18, + "y": 5, + "kind": "cut_tree", + "flag": "FLAG_TEMP_12", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 17, + "y": 5, + "kind": "item_ball", + "flag": "FLAG_HIDE_VIRIDIAN_CITY_POTION", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [ + { + "direction": "north", + "offset": 12, + "map": "Route2" + }, + { + "direction": "south", + "offset": 12, + "map": "Route1" + }, + { + "direction": "west", + "offset": 10, + "map": "Route22" + } + ], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json new file mode 100644 index 0000000000..f4b1fa32fc --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json @@ -0,0 +1,82 @@ +{ + "name": "ViridianCity_Mart", + "width": 11, + "height": 9, + "tiles": [ + "###########", + "###########", + "##.#......#", + "...#.......", + "####...##.#", + ".......##.#", + ".##....##.#", + "....v......", + "###########" + ], + "elevation": [ + "00000000000", + "00000000000", + "00303333330", + "33003333333", + "00003330030", + "33333330030", + "30033330030", + "33333333333", + "00000000000" + ], + "warps": [ + { + "x": 3, + "y": 7, + "dest_map": "ViridianCity", + "dest_warp": 4 + }, + { + "x": 4, + "y": 7, + "dest_map": "ViridianCity", + "dest_warp": 4 + }, + { + "x": 5, + "y": 7, + "dest_map": "ViridianCity", + "dest_warp": 4 + } + ], + "objects": [ + { + "x": 2, + "y": 3, + "kind": "clerk", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 6, + "y": 2, + "kind": "youngster", + "flag": "", + "wander_x": 1, + "wander_y": 1 + }, + { + "x": 9, + "y": 5, + "kind": "woman_1", + "flag": "", + "wander_x": 0, + "wander_y": 1 + } + ], + "connections": [], + "points": [ + { + "name": "clerk_front", + "x": 4, + "y": 3 + } + ], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_PokemonCenter_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_PokemonCenter_1F.json new file mode 100644 index 0000000000..7bb1c5369c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_PokemonCenter_1F.json @@ -0,0 +1,98 @@ +{ + "name": "ViridianCity_PokemonCenter_1F", + "width": 15, + "height": 10, + "tiles": [ + "#.#############", + "###############", + "....###..##....", + "....#######....", + "...............", + "...............", + "#L.........##..", + "...........##..", + ".......v.......", + "###############" + ], + "elevation": [ + "030000000000000", + "000000000000000", + "333300033003333", + "333300000003333", + "333333333333333", + "330333333333333", + "044033333330033", + "330333333330033", + "333333333333333", + "000000000000000" + ], + "warps": [ + { + "x": 6, + "y": 8, + "dest_map": "ViridianCity", + "dest_warp": 0 + }, + { + "x": 7, + "y": 8, + "dest_map": "ViridianCity", + "dest_warp": 0 + }, + { + "x": 8, + "y": 8, + "dest_map": "ViridianCity", + "dest_warp": 0 + }, + { + "x": 1, + "y": 6, + "dest_map": "", + "dest_warp": 0 + } + ], + "objects": [ + { + "x": 7, + "y": 2, + "kind": "nurse", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 12, + "y": 5, + "kind": "gentleman", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 4, + "y": 7, + "kind": "boy", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 2, + "y": 3, + "kind": "youngster", + "flag": "", + "wander_x": 1, + "wander_y": 1 + } + ], + "connections": [], + "points": [ + { + "name": "nurse_front", + "x": 7, + "y": 4 + } + ], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json new file mode 100644 index 0000000000..5d359b42a4 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json @@ -0,0 +1,207 @@ +{ + "name": "ViridianForest", + "width": 54, + "height": 69, + "tiles": [ + "######################################################", + "######################################################", + "######################################################", + "######################################################", + "######################################################", + "###########.............###........................###", + "###########.............###........................###", + "###########.............###........................###", + "#..#####..#.............###.....###############....###", + "####CCC####.............###.....###############....###", + "####...####.............###.....###############....###", + "####...####.....###.....###.....###############....###", + "####..S####\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###############....###", + "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###############....###", + "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###############....###", + "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\".............###", + "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\".............###", + "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\".............###", + "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\".......#########", + "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"........#########", + "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"######......#########", + "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###...\"\"\"######......#########", + "###\"\"\"\"\"###\"\"\"\"\"###.....###......######......#########", + "###\"\"\"\"\"###\"\"\"\"\"###..............######......#########", + "###\"\"\"\"\"###\"\"\"\"\"#####............######......#########", + "###\"\"\"\"\"###\"\"\"\"\"#####............######............###", + "###\"\"\"\"\"###\"\"\"\"\"\"\"#####################....S.......###", + "###\"\"\"\"\"...\"\"\"\"\"\"\"#####################............###", + "###...............#####################............###", + "###......S........#####################\"\"\"\"........###", + "###...............#####################\"\"\"\"\"###....###", + "###.....................###############\"\"\"\"\"###....###", + "###.....................###############\"\"\"\"\"###....###", + "###.....................###############\"\"\"\"\"###....###", + "##################......###############\"\"\"\"\"###....###", + "##################......###############\"\"\"\"\"###....###", + "#######################################\"\"\"\"\"###....###", + "#######################################\"\"\"\"\"###....###", + "#######################################\"\"\"\"\"###....###", + "###\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"#####################\"\"\"\"\"###....###", + "###\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"#####################\"\"\"\"\"###....###", + "###\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"#####################\"\"\"\"\"###....###", + "###\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"#####################\"\"\"\"\"###....###", + "###\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"######\"\"\"\"........###", + "############\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"S..\"\"######\"\"\".........###", + "############\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"...\"\"######\"\"\".........###", + "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", + "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", + "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", + "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", + "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", + "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", + "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", + "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", + "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", + "###\"\"\"\"\"\"\"\"\"..\"\"\"\"\"\"\"\"\"\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\"...\"\"\"\"\"\"###", + "###\"\"\"\"\"\"\"\"\"..\"\"\"\"\"\"\"\"\"\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\"...\"\"\"\"\"\"###", + "###\"\"\"\"\"\"\"\"\"...\"\"\"\"\"\"\"\"\"\"\"\".###.\"\"\"\"\"\"\"\"\"...\"\"\"\"\"\"\"###", + "###\"\"\"\"\"\"\"\"\"....\"\"\"\"\"\"\"\"\"\".......\"\"\"\"\"\"\"....\"\"\"\"\"\"\"###", + "###\"\"\"\"\"\"\"\"............................S....\"\"\"\"\"\"\"###", + "###\"\"\"\"\"\"\"\"....................S...........\"\"\"\"\"\"\"\"###", + "###\"\"\"\"\"\"\"\"................................\"\"\"\"\"\"\"\"###", + "###########################.vvv..#####################", + "######################################################", + "######################################################", + "######################################################", + "######################################################", + "######################################################", + "######################################################" + ], + "warps": [ + { + "x": 29, + "y": 62, + "dest_map": "Route2_ViridianForest_SouthEntrance", + "dest_warp": 3 + }, + { + "x": 28, + "y": 62, + "dest_map": "Route2_ViridianForest_SouthEntrance", + "dest_warp": 3 + }, + { + "x": 5, + "y": 9, + "dest_map": "Route2_ViridianForest_NorthEntrance", + "dest_warp": 1 + }, + { + "x": 6, + "y": 9, + "dest_map": "Route2_ViridianForest_NorthEntrance", + "dest_warp": 1 + }, + { + "x": 30, + "y": 62, + "dest_map": "Route2_ViridianForest_SouthEntrance", + "dest_warp": 3 + }, + { + "x": 4, + "y": 9, + "dest_map": "Route2_ViridianForest_NorthEntrance", + "dest_warp": 1 + } + ], + "objects": [ + { + "x": 29, + "y": 58, + "kind": "youngster", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 45, + "y": 58, + "kind": "boy", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 47, + "y": 45, + "kind": "bug_catcher", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 47, + "y": 29, + "kind": "bug_catcher", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 7, + "y": 22, + "kind": "bug_catcher", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 5, + "y": 41, + "kind": "item_ball", + "flag": "FLAG_HIDE_VIRIDIAN_FOREST_POKE_BALL", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 40, + "y": 21, + "kind": "item_ball", + "flag": "FLAG_HIDE_VIRIDIAN_FOREST_ANTIDOTE", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 21, + "y": 34, + "kind": "item_ball", + "flag": "FLAG_HIDE_VIRIDIAN_FOREST_POTION", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 43, + "y": 6, + "kind": "bug_catcher", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 16, + "y": 5, + "kind": "bug_catcher", + "flag": "", + "wander_x": 0, + "wander_y": 0 + }, + { + "x": 49, + "y": 60, + "kind": "item_ball", + "flag": "FLAG_HIDE_VIRIDIAN_FOREST_POTION_2", + "wander_x": 0, + "wander_y": 0 + } + ], + "connections": [], + "points": [], + "flag_sets": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp index 8ad357066c..d838d5cb7b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp @@ -21,6 +21,7 @@ std::optional tile_from_char(char c){ case '"': return Tile::TALL_GRASS; case '~': return Tile::WATER; case 'D': return Tile::DOOR; + case 'S': return Tile::SIGN; case 'C': return Tile::CAVE_ENTRANCE; case 'L': return Tile::LADDER; case '^': return Tile::MAT_NORTH; @@ -48,7 +49,7 @@ uint8_t elevation_at(const MapData& map, const TilePos& point){ bool is_wall(const MapData& map, const TilePos& point){ const Tile tile = tile_at(map, point); - return tile == Tile::WALL || tile == Tile::DOOR || tile == Tile::LEDGE; + return tile == Tile::WALL || tile == Tile::DOOR || tile == Tile::SIGN || tile == Tile::LEDGE; } bool is_ledge(const MapData& map, const TilePos& point){ return tile_at(map, point) == Tile::LEDGE; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h index 83ea60b342..804b838a2f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h @@ -88,6 +88,10 @@ enum class Tile : uint8_t{ TALL_GRASS, // '"' floor with wild encounters WATER, // '~' entered only by starting to Surf DOOR, // 'D' a wall that warps the player who walks north into it + SIGN, // 'S' a wall that shows its message to the player who + // walks into it moving north or south (signposts, + // Center and Mart signs; pokefirered + // TrySetUpWalkIntoSignpostScript()) CAVE_ENTRANCE, // 'C' floor that warps the player who steps onto it LADDER, // 'L' ladder or escalator: floor that warps the player // who steps onto it diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp index 84dd3e780c..af15091f25 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp @@ -4,12 +4,12 @@ * */ +#include #include #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/Json/JsonArray.h" #include "Common/Cpp/Json/JsonObject.h" #include "Common/Cpp/Json/JsonValue.h" -#include "CommonFramework/GlobalAutoPaths.h" #include "PokemonFRLG_OverworldMaps.h" namespace PokemonAutomation{ @@ -19,8 +19,6 @@ namespace PokemonFRLG{ namespace{ -const char MAP_FOLDER[] = "PokemonFRLG/Maps/"; - const char* const MAP_NAMES[] = { // From a new game to Brock. "PalletTown", @@ -53,7 +51,7 @@ const char* const MAP_NAMES[] = { // The readers below take `where`, the source and the path to the object -// being read (e.g. "PokemonFRLG/Maps/CeruleanCity.json: warps[2]."), and +// being read (e.g. "Maps/CeruleanCity.json: warps[2]."), and // name the field in what they throw. const JsonObject& as_object(const JsonValue& value, const std::string& where){ @@ -257,8 +255,13 @@ MapData parse_map(const std::string& json, const std::string& source){ } MapData load_map(const std::string& name){ - const std::string source = std::string(MAP_FOLDER) + name + ".json"; - MapData map = read_map(load_json_file(RESOURCE_PATH() + source), source); + const std::string source = "Maps/" + name + ".json"; + const std::vector>& files = overworld_map_json(); + const auto file = std::find_if(files.begin(), files.end(), [&](const auto& item){ return item.first == name; }); + if (file == files.end()){ + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, source + " is not built into the program."); + } + MapData map = read_map(parse_json(file->second), source); if (map.name != name){ throw ParseException(source + ": name is \"" + map.name + "\", not \"" + name + "\"."); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h index 0577d3b8cb..1a7930d1f1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h @@ -8,9 +8,10 @@ * Center, Route 24 to its north, and the three floors of Cerulean Cave, * where Mewtwo waits on B1F. * - * Each map is a JSON file, Resources/PokemonFRLG/Maps/.json in - * Packages, generated by devtools/maps/frlg_maps.py. The schema (see the - * README.md next to the files) is MapData's: + * Each map is a JSON file, Maps/.json next to this file, generated by + * devtools/maps/frlg_maps.py and built into the program by CMake + * (pa_embed_text_files() in cmake/EmbedTextFiles.cmake), so the program and + * its tests read the same copy. The schema is MapData's: * * { * "name": "CeruleanCity", "width": 48, "height": 40, @@ -32,6 +33,7 @@ #include #include +#include #include #include "Common/Cpp/TestRunners/UnitTestDatabase.h" #include "PokemonFRLG_OverworldMap.h" @@ -46,12 +48,17 @@ namespace PokemonFRLG{ // doesn't fit the schema. MapData parse_map(const std::string& json, const std::string& source); -// Loads Resources/PokemonFRLG/Maps/.json. Throws FileException if -// the file is missing, and ParseException as parse_map(). +// (name, JSON text) of each file in Maps/, sorted by name. Generated at +// build time. +// TODO: move the maps to PokemonAutomation/Packages (Resources/PokemonFRLG/Maps) when ready. +const std::vector>& overworld_map_json(); + +// Reads map `name` from overworld_map_json(). Throws InternalProgramError if +// it isn't built in, and ParseException as parse_map(). MapData load_map(const std::string& name); // Every map, by its decompilation name ("CeruleanCity", "CeruleanCave_B1F", ...), -// with the objects the given event flags hide removed. The files are read +// with the objects the given event flags hide removed. The maps are parsed // once, on the first call. std::vector overworld_maps(const std::set& set_flags = {}); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp index e51f8f5a90..d598e108f8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp @@ -208,8 +208,8 @@ std::optional press(const std::vector& maps, const Located& return transition; } -// Whether holding `direction` stops the player where they are: a wall, a -// ledge, or water they'd need to Surf onto. A leg that ends there can be +// Whether holding `direction` stops the player where they are: a wall, or +// water they'd need to Surf onto. A leg that ends there can be // held for longer than it takes, and walked again after an interruption. A // person in the way doesn't count, since they may have wandered off, and // neither does an edge to a map that isn't loaded. @@ -220,6 +220,19 @@ bool stops_at(const std::vector& maps, const Located& player, Direction } const MapData& map = maps[player.map]; const TilePos ahead = player.state.position.next(direction); + // Held into a sign moving north or south, the game shows the sign's + // message: the player stops, but the walk is interrupted (console B, + // 2026-11-01, the poster on the bedroom's wall). + if (tile_at(map, ahead) == Tile::SIGN && (direction == Direction::NORTH || direction == Direction::SOUTH)){ + return false; + } + // Held into a ledge the way it faces, the player hops down it (console + // B, 2026-11-01, Viridian City: "south 2 (to wall)" from the Pokemon + // Center hopped the ledge two rows down). The maps don't keep which way + // a ledge faces, so none is held into. + if (is_ledge(map, ahead)){ + return false; + } if (in_bounds(map, ahead)){ return object_at(map, ahead) == nullptr; } @@ -266,6 +279,10 @@ class StepModel{ } if (is_tall_grass(m_maps[step.next.map], step.next.state.position)){ step.extra_cost += route_cost(m_costs, RouteCost::GRASS_TILE); + step.wild = true; + } + if (step.next.state.surfing){ + step.wild = true; } return step; } @@ -308,6 +325,12 @@ RouteStep to_route_step(const std::vector& maps, const Pokemon::Leg maps{parse_map(TEST_SIGN_ROOM_JSON, "SignRoom")}; + std::vector route; + UnitTestResult result = check_route(maps, {"SignRoom", {2, 3}}, {{"SignRoom", {2, 1}}, std::nullopt}, route); + if (result.result != UnitTestResult::PASSED){ + return result; + } + for (const RouteStep& step : route){ + if (step.to_wall && step.end.point == TilePos{2, 1}){ + return "Expected no hold into the sign:" + describe(route); + } + } + route.clear(); + result = check_route(maps, {"SignRoom", {1, 3}}, {{"SignRoom", {1, 1}}, std::nullopt}, route); + if (result.result != UnitTestResult::PASSED){ + return result; + } + if (route.empty() || !route.back().to_wall){ + return "Expected the wall to stop the player beside the sign:" + describe(route); + } + return true; +} + +// A yard with a row of ledges across it. +const char* const TEST_LEDGE_YARD_JSON = R"({ + "name": "LedgeYard", "width": 5, "height": 6, + "tiles": ["#####", "#...#", "#...#", "#JJJ#", "#...#", "#####"], + "elevation": ["33333", "33333", "33333", "33333", "33333", "33333"], + "warps": [], "objects": [], + "connections": [], "points": [], "flag_sets": [] +})"; + +// A ledge isn't a wall to hold into: moving the way it faces the player +// would hop it, and the maps don't say which way that is. Viridian City, +// from the Pokemon Center's door south to the row above the ledge. +UnitTestResult test_no_hold_into_ledge(){ + const std::vector maps{parse_map(TEST_LEDGE_YARD_JSON, "LedgeYard")}; + std::vector route; + UnitTestResult result = check_route(maps, {"LedgeYard", {2, 1}}, {{"LedgeYard", {2, 2}}, std::nullopt}, route); + if (result.result != UnitTestResult::PASSED){ + return result; + } + for (const RouteStep& step : route){ + if (step.to_wall){ + return "Expected no hold into the ledge:" + describe(route); + } + } + route.clear(); + const std::vector world = overworld_maps(); + result = check_route(world, {"ViridianCity", {26, 27}}, {{"ViridianCity", {26, 29}}, std::nullopt}, route); + if (result.result != UnitTestResult::PASSED){ + return result; + } + for (const RouteStep& step : route){ + if (step.to_wall && step.end.point == TilePos{26, 29}){ + return "Expected no hold into the ledge below the Pokemon Center:" + describe(route); + } + } + return true; +} + // Two small maps that don't need the map files: a room left by the exit mat // at its bottom, onto the door of a yard, out of which the game walks the // player. +// No wild battle can start between the bedroom and Oak's Lab: Pallet Town's +// streets have no tall grass. Route 2 and Viridian Forest do. +UnitTestResult test_wild_steps(){ + const std::vector maps = overworld_maps(); + std::vector route; + UnitTestResult result = check_route( + maps, point_on(maps, "PalletTown_PlayersHouse_2F", "start"), + {point_on(maps, "PalletTown", "oaks_lab_front"), Direction::NORTH}, route + ); + if (result.result != UnitTestResult::PASSED){ + return result; + } + for (const RouteStep& step : route){ + if (step.wild){ + return "Expected no wild step from the bedroom to Oak's Lab, got " + to_string(step) + ":" + describe(route); + } + } + route.clear(); + result = check_route( + maps, point_on(maps, "ViridianCity_Mart", "clerk_front"), + {point_on(maps, "PewterCity", "gym_front"), Direction::NORTH}, route + ); + if (result.result != UnitTestResult::PASSED){ + return result; + } + bool forest = false; + for (const RouteStep& step : route){ + forest = forest || (step.wild && step.end.map == "ViridianForest"); + } + if (!forest){ + return "Expected a wild step in Viridian Forest:" + describe(route); + } + // The leg from Pallet Town north onto Route 1 crosses Route 1's grass + // after the map's edge. + route.clear(); + result = check_route( + maps, point_on(maps, "PalletTown", "oaks_lab_front"), + {point_on(maps, "ViridianCity_Mart", "clerk_front"), std::nullopt}, route + ); + if (result.result != UnitTestResult::PASSED){ + return result; + } + for (const RouteStep& step : route){ + if (step.end.map == "Route1" && step.direction == Direction::NORTH && step.tiles > 14 && !step.wild){ + return "Expected the leg from Pallet Town onto Route 1 to be wild, got " + to_string(step) + ":" + describe(route); + } + } + return true; +} + const char* const TEST_ROOM_JSON = R"({ "name": "Room", "width": 5, "height": 4, "tiles": ["#####", "#...#", "#...#", "##v##"], @@ -735,6 +877,9 @@ void add_tests_OverworldRoute(UnitTestDatabase& database){ database.add("maps to Brock", test_story_maps); database.add("bedroom to Oak's Lab", test_bedroom_to_oaks_lab); database.add("Viridian Mart to Pewter Gym", test_viridian_mart_to_pewter_gym); + database.add("wild steps", test_wild_steps); + database.add("no hold into a sign", test_no_hold_into_sign); + database.add("no hold into a ledge", test_no_hold_into_ledge); database.add("step rules", test_step_rules); database.add("maps", test_maps); database.add("Cerulean Cave entrance to Mewtwo", test_entrance_to_mewtwo); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h index 35afa7a1e4..112d402e35 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h @@ -52,6 +52,10 @@ struct RouteStep{ // WALK: a wall stops the player at the end, so the leg can be held for // longer than it takes and still ends on its tile. bool to_wall = false; + // WALK, SURF: a wild Pokemon can appear on the way: the step crosses + // tall grass or water. Elsewhere (indoors, streets) no wild battle can + // start, so the walker doesn't watch for one. + bool wild = false; // Which way the player faces after the step. Arriving at a door or a // cave mouth, the game walks the player a tile out, facing south. Direction facing_after = Direction::NORTH; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp deleted file mode 100644 index fa003efb39..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp +++ /dev/null @@ -1,362 +0,0 @@ -/* Overworld Walk - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#include -#include -#include "CommonFramework/Exceptions/OperationFailedExceptionWithScreenshot.h" -#include "CommonTools/Async/InferenceRoutines.h" -#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" -#include "CommonFramework/VideoPipeline/VideoFeed.h" -#include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_BattleDialogs.h" -#include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h" -#include "VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_StartMenuDetector.h" -#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h" -#include "VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h" -#include "PokemonFRLG_PlayerFacingReader.h" -#include "PokemonFRLG_OverworldWalk.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - -using namespace std::chrono_literals; - - -namespace{ - -constexpr Milliseconds TILE_TIME = 267ms; // 16 frames at 60 fps, measured exact over 15 tiles -constexpr Milliseconds SURF_TILE_TIME = 133ms; // the game moves a surfing player at running speed -constexpr Milliseconds TURN_TAP = 40ms; // turns a player facing another way, without a step -constexpr Milliseconds TURN_SETTLE = 300ms; -constexpr Milliseconds FACE_HOLD = 40ms; // short enough to turn without stepping -constexpr Milliseconds FACE_SETTLE = 300ms; // the turn animation, before A reaches what is ahead -constexpr Milliseconds STEP_RELEASE = 100ms; -// From the end of the hold, through the fade out and in. -constexpr Milliseconds WARP_TIMEOUT = 8000ms; -constexpr Milliseconds SURF_PROMPT_TIMEOUT = 5000ms; -constexpr Milliseconds SURF_ANIMATION = 3000ms; -// After a warp's fade: leaving by a door the game walks the player a tile out -// on its own, and a leg started before that ends loses tiles (on the console a -// 600ms wait cost 2 tiles). -constexpr Milliseconds AFTER_WARP = 1500ms; -// A message set off by a leg's last step shows after the hold ends. Caught -// here, before the next leg's turn tap, which the message would swallow. -constexpr Milliseconds AFTER_LEG_WATCH = 500ms; -// After a message closes: a trainer who saw the player speaks first, then -// the battle starts, with " would like to battle!" seconds later. -constexpr Milliseconds TRAINER_BATTLE_WATCH = 6000ms; -constexpr size_t MAX_INTERRUPTIONS_PER_LEG = 5; - - -// A wild battle, seen by the flashes it starts with. -class WildBattleInterrupt : public OverworldInterrupt{ -public: - virtual std::string name() const override{ - return "a wild battle"; - } - virtual std::unique_ptr make_watcher() const override{ - return std::make_unique(COLOR_RED); - } - // The first flash shows about 130ms after the step on the console, and - // the watcher needs it to start fading back. Not calibrated yet. - virtual Milliseconds detection_delay() const override{ - return 300ms; - } - virtual void clear(ConsoleHandle& console, ProControllerContext& context) const override{ - flee_battle(console, context); - } -}; - -// A wild battle whose flashes were missed, seen once "Wild -// appeared!" shows. Where an open leg stopped is then only a rough guess. -class LateWildBattleInterrupt : public WildBattleInterrupt{ -public: - virtual std::string name() const override{ - return "a wild battle (seen late)"; - } - virtual std::unique_ptr make_watcher() const override{ - return std::make_unique(COLOR_RED); - } - // The flashes, the wipe and the opening animation. Not calibrated yet. - virtual Milliseconds detection_delay() const override{ - return 2000ms; - } -}; - -class MessageInterrupt : public OverworldInterrupt{ -public: - virtual std::string name() const override{ - return "a message"; - } - virtual std::unique_ptr make_watcher() const override{ - return std::make_unique(COLOR_RED); - } - // The box shows as the step ends; then video lag and the watcher's - // 250ms. Not calibrated yet. - virtual Milliseconds detection_delay() const override{ - return 400ms; - } - virtual void clear(ConsoleHandle& console, ProControllerContext& context) const override{ - WhiteDialogOverWatcher closed(COLOR_RED); - context.wait_for_all_requests(); - const int ret = run_until( - console, context, - [](ProControllerContext& context){ - for (int c = 0; c < 5; c++){ - pbf_press_button(context, BUTTON_B, 160ms, 840ms); - } - }, - {closed} - ); - if (ret < 0){ - OperationFailedExceptionWithScreenshot::fire( - ErrorReportMode::SEND_ERROR_REPORT, - "walk_overworld_route(): a message on the overworld didn't close.", - console - ); - } - check_no_trainer_battle(console, context); - } - -private: - // A trainer's battle can't be fled, and the walker must not try (console - // B, 2026-11-01, Viridian Forest): it stops here for the caller. - static void check_no_trainer_battle(ConsoleHandle& console, ProControllerContext& context){ - BattleDialogWatcher battle(COLOR_RED); - context.wait_for_all_requests(); - if (wait_until(console, context, TRAINER_BATTLE_WATCH, {battle}) >= 0){ - OperationFailedExceptionWithScreenshot::fire( - ErrorReportMode::NO_ERROR_REPORT, - "walk_overworld_route(): trainer battle: a battle started after a message on the overworld.", - console - ); - } - } -}; - -// A message, taken to be "REPEL's effect wore off...", after which another -// Max Repel is used from the Items pocket. -class RepelWoreOffInterrupt : public MessageInterrupt{ -public: - explicit RepelWoreOffInterrupt(int max_repel_slot) - : m_max_repel_slot(max_repel_slot) - {} - virtual std::string name() const override{ - return "a message (Repel wore off?)"; - } - virtual void clear(ConsoleHandle& console, ProControllerContext& context) const override{ - MessageInterrupt::clear(console, context); - use_max_repel_from_bag(console, context, m_max_repel_slot); - } - -private: - int m_max_repel_slot; -}; - - -DpadPosition dpad(Direction direction){ - switch (direction){ - case Direction::NORTH: - return DPAD_UP; - case Direction::EAST: - return DPAD_RIGHT; - case Direction::SOUTH: - return DPAD_DOWN; - case Direction::WEST: - return DPAD_LEFT; - } - return DPAD_NONE; -} - -// The leg mover: holds the D-pad. FRLG moves exactly a tile per 16 frames. -class DpadMover : public Pokemon::LegMover{ -public: - virtual void hold(ProControllerContext& context, Direction direction, Milliseconds duration) const override{ - pbf_press_dpad(context, dpad(direction), duration, STEP_RELEASE); - } -}; - -Pokemon::LegSpec leg_spec(const RouteStep& step){ - return Pokemon::LegSpec{step.direction, step.tiles, step.to_wall, step.surfing ? SURF_TILE_TIME : TILE_TIME}; -} - -// One watcher for the whole fade: a ladder's black is short enough to be -// over before a second watcher, started once the fade is seen, looks. -void wait_out_warp(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step){ - BlackScreenOverWatcher arrival(COLOR_RED); - context.wait_for_all_requests(); - if (wait_until(console, context, WARP_TIMEOUT, {arrival}) < 0){ - OperationFailedExceptionWithScreenshot::fire( - ErrorReportMode::SEND_ERROR_REPORT, - "walk_overworld_route(): no fade in and out after walking onto the warp to " + step.end.map + ".", - console - ); - } -} - -// Fails unless the overworld is up. Under the START menu or a message the -// D-pad only moves a cursor, and legs to a wall seem to go fine: three -// "walked" that way in Viridian Forest without the player moving (console B, -// 2026-11-01). -void check_overworld(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step){ - context.wait_for_all_requests(); - VideoSnapshot screen = console.video().snapshot(); - if (!screen){ - return; - } - const char* open = nullptr; - if (StartMenuDetector(COLOR_RED).detect(screen)){ - open = "the START menu"; - }else if (SelectionDialogDetector(COLOR_RED).detect(screen)){ - open = "a menu"; - }else if (WhiteDialogDetector(COLOR_RED).detect(screen)){ - open = "a message"; - } - if (open != nullptr){ - OperationFailedExceptionWithScreenshot::fire( - ErrorReportMode::SEND_ERROR_REPORT, - std::string("walk_overworld_route(): ") + open + " is open, before: " + to_string(step), - console - ); - } -} - -void start_surf(ConsoleHandle& console, ProControllerContext& context, Direction direction, bool facing_water){ - // "The water is a deep blue... Would you like to SURF?", with YES selected. - // An A pressed while the player is still turning is lost. - if (!facing_water){ - pbf_press_dpad(context, dpad(direction), FACE_HOLD, FACE_SETTLE); - } - pbf_press_button(context, BUTTON_A, 160ms, 0ms); - SelectionDialogWatcher prompt(COLOR_RED); - context.wait_for_all_requests(); - if (wait_until(console, context, SURF_PROMPT_TIMEOUT, {prompt}) < 0){ - OperationFailedExceptionWithScreenshot::fire( - ErrorReportMode::SEND_ERROR_REPORT, - "walk_overworld_route(): no Surf prompt facing the water.", - console - ); - } - pbf_press_button(context, BUTTON_A, 160ms, 1000ms); - - // " used SURF!" waits for A, then the player jumps onto the water. - for (int c = 0; c < 5; c++){ - context.wait_for_all_requests(); - VideoSnapshot screen = console.video().snapshot(); - if (!screen || !WhiteDialogDetector(COLOR_RED).detect(screen)){ - break; - } - pbf_press_button(context, BUTTON_A, 160ms, 1000ms); - } - pbf_wait(context, SURF_ANIMATION); -} - -} - - - -OverworldInterrupts overworld_interrupts_with_repel(int max_repel_slot){ - OverworldInterrupts ret; - ret.emplace_back(std::make_unique()); - ret.emplace_back(std::make_unique()); - ret.emplace_back(std::make_unique(max_repel_slot)); - return ret; -} - -void use_max_repel_from_bag(ConsoleHandle& console, ProControllerContext& context, int slot){ - console.log(std::format("Using a Max Repel (Items pocket, slot {}).", slot + 1)); - open_bag_from_overworld(console, context); - // The bag is seen while it still slides in, and ignores presses until - // it is done. - pbf_wait(context, 1000ms); - // To the Items pocket, then to the top of it. - for (int c = 0; c < 3; c++){ - pbf_press_dpad(context, DPAD_LEFT, 100ms, 600ms); - } - for (int c = 0; c < 20; c++){ - pbf_press_dpad(context, DPAD_UP, 100ms, 100ms); - } - for (int c = 0; c < slot; c++){ - pbf_press_dpad(context, DPAD_DOWN, 100ms, 300ms); - } - // USE, " used the MAX REPEL.", back to the bag, then out of the - // bag and the start menu. A third A here would open the item's menu again. - pbf_press_button(context, BUTTON_A, 160ms, 800ms); - pbf_press_button(context, BUTTON_A, 160ms, 1500ms); - pbf_press_button(context, BUTTON_A, 160ms, 1500ms); - pbf_press_button(context, BUTTON_B, 160ms, 2000ms); - pbf_press_button(context, BUTTON_B, 160ms, 1000ms); - context.wait_for_all_requests(); -} - -const OverworldInterrupts& default_overworld_interrupts(){ - // Battles first: their screens are checked before the message box's. - static const OverworldInterrupts interrupts = []{ - OverworldInterrupts ret; - ret.emplace_back(std::make_unique()); - ret.emplace_back(std::make_unique()); - ret.emplace_back(std::make_unique()); - return ret; - }(); - return interrupts; -} - - -void walk_overworld_route( - ConsoleHandle& console, ProControllerContext& context, - const std::vector& route, - std::optional facing, - const OverworldInterrupts& interrupts -){ - // Each leg starts with a turn tap unless it goes the way the player faces. - // A tap while already facing that way takes a step, so a facing not - // given is read from the screen. If that fails too it taps anyway. - if (!facing){ - context.wait_for_all_requests(); - VideoSnapshot screen = console.video().snapshot(); - if (screen){ - facing = read_player_facing(screen); - } - console.log(std::string("Route: the player faces ") + (facing ? Pokemon::direction_name(*facing) : "an unknown way") + "."); - } - const DpadMover mover; - for (const RouteStep& step : route){ - console.log("Route: " + to_string(step)); - check_overworld(console, context, step); - switch (step.action){ - case RouteAction::WALK: - // Turning first, with a tap, makes the hold start from a standstill - // facing the right way: holding through a turn lost a tile on the - // console, while holds from a standstill were exact over 15 tiles. - if (facing != step.direction){ - pbf_press_dpad(context, dpad(step.direction), TURN_TAP, TURN_SETTLE); - } - Pokemon::walk_leg(console, context, mover, interrupts, leg_spec(step), MAX_INTERRUPTIONS_PER_LEG); - if (step.warps){ - wait_out_warp(console, context, step); - pbf_wait(context, AFTER_WARP); - } - break; - case RouteAction::SURF: - start_surf(console, context, step.direction, facing == step.direction); - break; - case RouteAction::FACE: - pbf_press_dpad(context, dpad(step.direction), FACE_HOLD, STEP_RELEASE); - break; - } - if (step.action != RouteAction::FACE){ - Pokemon::clear_late_interrupts(console, context, interrupts, AFTER_LEG_WATCH, MAX_INTERRUPTIONS_PER_LEG); - } - facing = step.facing_after; - } - context.wait_for_all_requests(); -} - - - -} -} -} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h deleted file mode 100644 index 402826fd7a..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Overworld Walk - * - * From: https://github.com/PokemonAutomation/ - * - * Walks a planned overworld route with the D-pad. FRLG moves one tile per - * 16 frames and finishes a step once it starts, so a leg is one hold timed - * to land mid-way between the last tile and one more. Warps are waited out - * by their fade; Surf goes through its dialog. - * - * A message or a wild battle can stop the player part-way through a leg. - * Each kind is an OverworldInterrupt: the walker watches for all of them - * while it holds the D-pad, and when one shows it stops, has it cleared and - * walks the rest of the leg. - * - */ - -#ifndef PokemonAutomation_PokemonFRLG_OverworldWalk_H -#define PokemonAutomation_PokemonFRLG_OverworldWalk_H - -#include -#include -#include -#include "Pokemon/Navigation/Pokemon_LegWalker.h" -#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" -#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" -#include "PokemonFRLG_OverworldRoute.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -// Something that stops the player part-way through a leg: a wild battle, a -// message. See Pokemon::LegInterrupt. -using OverworldInterrupt = Pokemon::LegInterrupt; -using OverworldInterrupts = Pokemon::LegInterrupts; - -// A wild battle, run from, and a message (e.g. "REPEL's effect wore off..."), -// closed with B. -const OverworldInterrupts& default_overworld_interrupts(); - -// The same, except that after a message another Max Repel is used, from -// slot `max_repel_slot` (from 0) of the Items pocket. Any message on the -// overworld is taken to be the one saying the last Repel wore off. -OverworldInterrupts overworld_interrupts_with_repel(int max_repel_slot); - -// From the overworld, uses the Max Repel in `slot` (from 0) of the Items -// pocket and returns to the overworld. -void use_max_repel_from_bag(ConsoleHandle& console, ProControllerContext& context, int slot); - - -// Walks `route` from where it was planned. The player must be standing still -// on the overworld, not running and not on the bike. `facing` is the way the -// player faces at the start; if not given, it is read from the screen. Throws OperationFailedException if a -// warp's fade or the Surf prompt doesn't show, or a leg is interrupted too -// many times. -void walk_overworld_route( - ConsoleHandle& console, ProControllerContext& context, - const std::vector& route, - std::optional facing = std::nullopt, - const OverworldInterrupts& interrupts = default_overworld_interrupts() -); - - - -} -} -} -#endif diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index fd03fce82e..1716333bf0 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1738,8 +1738,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_TrainerCardDetector.h Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleLevelUpReader.cpp Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleLevelUpReader.h - Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.cpp - Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleFlashWatcher.h Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattlePokemonDetector.cpp Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattlePokemonDetector.h Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleSelectionArrowDetector.cpp @@ -1777,8 +1775,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h - Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp - Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.h Source/VideoGames/PokemonFRLG/PokemonFRLG_Navigation.cpp diff --git a/devtools/maps/frlg_maps.py b/devtools/maps/frlg_maps.py index 1c8353acca..9e6ab7e62f 100644 --- a/devtools/maps/frlg_maps.py +++ b/devtools/maps/frlg_maps.py @@ -1,7 +1,9 @@ """Writes FRLG overworld maps as JSON, from the pret/pokefirered decompilation. +TODO: move the maps to PokemonAutomation/Packages (Resources/PokemonFRLG/Maps) when ready. + Usage: - python3 devtools/maps/frlg_maps.py --out Packages/Resources/PokemonFRLG/Maps \ + python3 devtools/maps/frlg_maps.py --out SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps \ CeruleanCity_PokemonCenter_1F CeruleanCity Route24 \ CeruleanCave_1F CeruleanCave_2F CeruleanCave_B1F python3 devtools/maps/frlg_maps.py --out @@ -9,14 +11,15 @@ Downloads each map's data/maps//map.json, its layout's map.bin and its tilesets' metatile_attributes.bin at --commit into --cache, then writes -/.json in the schema of Packages/Resources/PokemonFRLG/Maps/README.md. +/.json in the schema given in PokemonFRLG_OverworldMaps.h. Warps and connections lead only to maps in the same run: others get an empty dest_map, or are left out. Named points and flag sets come from POINTS and FLAG_SETS below. Without map names, the maps are the ones already in --out. --check writes -nothing: it regenerates them and fails if any file differs, e.g. for the -copies the unit tests build into the program. +nothing: it regenerates them and fails if any file differs. The program +builds in the files of SerialPrograms/Source/VideoGames/PokemonFRLG/ +Overworld/Maps, the folder to write and check. """ import argparse import json @@ -108,7 +111,15 @@ def tileset_attributes(decomp, symbol, kind): return [struct.unpack_from('> 10) & 3, value >> 12 attributes = primary[metatile] if metatile < 640 else secondary[metatile - 640] behavior = names.get(attributes & 0x1ff, hex(attributes & 0x1ff)) - row += tile_character(behavior, collision, unhandled) + row += tile_character(behavior, collision, unhandled, (x, y) in signs) levels += '%x' % level tiles.append(row) elevation.append(levels) @@ -168,7 +179,8 @@ def ground_only(tiles, elevation): def map_json(decomp, name, layouts, names, loaded, unhandled): source = json.loads(decomp.read(f'data/maps/{name}/map.json')) - width, height, tiles, elevation = grid(decomp, layouts[source['layout']], names, unhandled) + signs = frozenset((e['x'], e['y']) for e in source.get('bg_events', []) if e.get('type') == 'sign') + width, height, tiles, elevation = grid(decomp, layouts[source['layout']], names, unhandled, signs) objects = [] for obj in source.get('object_events', []): flag = obj.get('flag') or '' From 449ed43e603ae965bec4c45cdcdbb7334f339fac Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 1 Nov 2026 16:31:27 -0800 Subject: [PATCH 13/19] FRLG: maps in the shared Pokemon::MapData schema FRLG kept its own map types (Grid, Tile, MapWarp, MapObject, MapConnection, MapData) and parser. They are gone: FRLG reads Pokemon::MapData, and PokemonFRLG_OverworldMap keeps only the game's rules on it. - frlg_maps.py writes the shared schema: a source, the shared glyphs (ledges by the way they are hopped, closed edges as 8 2 4 6), and cave entrances, ladders and exit mats as open tiles whose warp says how it is entered. A warp leads to point "warp_" of its map; one to a map that isn't loaded has no destination. - warps_on_step(), exit_mat() and walks_out_on_arrival() read the tile's warp; object_at() the wander box; hide_objects() hide_flag. - parse_map() wraps Pokemon::parse_map(). No behaviour change: per tile, every rule reads the same on the old and new map files, and every warp arrives on the same tile. The one wander box past a map's edge (Oak's lab) is clipped to it, and the two cut trees standing off their maps (Route 2, Cerulean City) are left out. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Overworld/Maps/CeruleanCave_1F.json | 164 +++++++------ .../Overworld/Maps/CeruleanCave_2F.json | 151 ++++++------ .../Overworld/Maps/CeruleanCave_B1F.json | 141 +++++------ .../Overworld/Maps/CeruleanCity.json | 225 ++++++++--------- .../Maps/CeruleanCity_PokemonCenter_1F.json | 112 +++++---- .../Overworld/Maps/PalletTown.json | 82 ++++--- .../Maps/PalletTown_PlayersHouse_1F.json | 48 ++-- .../Maps/PalletTown_PlayersHouse_2F.json | 33 +-- .../Maps/PalletTown_ProfessorOaksLab.json | 109 ++++---- .../Maps/PalletTown_RivalsHouse.json | 51 ++-- .../Overworld/Maps/PewterCity.json | 125 +++++----- .../Overworld/Maps/PewterCity_Gym.json | 63 +++-- .../Overworld/Maps/PewterCity_Mart.json | 56 +++-- .../Overworld/Maps/PewterCity_Museum_1F.json | 95 ++++--- .../Maps/PewterCity_PokemonCenter_1F.json | 100 ++++---- .../PokemonFRLG/Overworld/Maps/Route1.json | 101 ++++---- .../PokemonFRLG/Overworld/Maps/Route2.json | 158 ++++++------ .../PokemonFRLG/Overworld/Maps/Route22.json | 48 ++-- .../PokemonFRLG/Overworld/Maps/Route24.json | 137 +++++------ .../Route2_ViridianForest_NorthEntrance.json | 64 ++--- .../Route2_ViridianForest_SouthEntrance.json | 60 +++-- .../Overworld/Maps/ViridianCity.json | 142 +++++------ .../Overworld/Maps/ViridianCity_Mart.json | 71 +++--- .../Maps/ViridianCity_PokemonCenter_1F.json | 80 +++--- .../Overworld/Maps/ViridianForest.json | 232 +++++++++--------- .../Overworld/PokemonFRLG_OverworldMap.cpp | 111 ++++----- .../Overworld/PokemonFRLG_OverworldMap.h | 144 +++-------- .../Overworld/PokemonFRLG_OverworldMaps.cpp | 193 +-------------- .../Overworld/PokemonFRLG_OverworldMaps.h | 23 +- .../PokemonFRLG_OverworldMaps_Tests.cpp | 9 +- .../Overworld/PokemonFRLG_OverworldRoute.cpp | 27 +- devtools/maps/frlg_maps.py | 168 +++++++++---- 32 files changed, 1555 insertions(+), 1768 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_1F.json index 71d6f98963..a6cb236993 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_1F.json @@ -1,30 +1,33 @@ { "name": "CeruleanCave_1F", - "width": 40, - "height": 23, + "source": { + "decomp_file": "data/maps/CeruleanCave_1F/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "########################################", - "#######...##.#########~~~~~~~~~#..##..##", - "#######...L..#########~~~~~~~~~#..L...##", - "#######..##..#~~~~~~~~~~~~~~~~~#......##", - "##L####..##..#~~~~~~~~~~#...#~~##.######", - "##.#.........#~~~~~~~~~~#...#~~~~~~~~~~#", - "#..#....##...#~~~#..........#~~~~~~~~~~#", - "#L.#....##...#~~~#..........#~~~~~~~~~~#", - "#..#....##...#~~~#.................#~~~#", - "####....##.###~~~#...######...#....#~~~#", - "##.#....#~~~##~~~#...##.####..L....#~~~#", - "##......#~~~##~~~##.###.L.##.......#~~~#", - "##......#~~~~~~~~#....#...##...#####~~~#", - "##......#~~~~~~~~#..#.##.###...###.....#", - "##..##..#~~~~~~~~#.........#...#.......#", - "##..#L..#~~~#....##......###...#.....###", + "#######...##.#########wwwwwwwww#..##..##", + "#######......#########wwwwwwwww#......##", + "#######..##..#wwwwwwwwwwwwwwwww#......##", + "##.####..##..#wwwwwwwwww#...#ww##.######", + "##.#.........#wwwwwwwwww#...#wwwwwwwwww#", + "#..#....##...#www#..........#wwwwwwwwww#", + "#..#....##...#www#..........#wwwwwwwwww#", + "#..#....##...#www#.................#www#", + "####....##.###www#...######...#....#www#", + "##.#....#www##www#...##.####.......#www#", + "##......#www##www##.###...##.......#www#", + "##......#wwwwwwww#....#...##...#####www#", + "##......#wwwwwwww#..#.##.###...###.....#", + "##..##..#wwwwwwww#.........#...#.......#", + "##..#...#www#....##......###...#.....###", "##......#...#....####...####...#...#####", "##......#...#..................#...#####", "#####.###...##.#...............#...#####", "#####..........#...............#...#####", "#####..........#...............#...#####", - "#####..........#################.v.#####", + "#####..........#################...#####", "########################################" ], "elevation": [ @@ -52,137 +55,140 @@ "0000033333333330000000000000000033300000", "0000000000000000000000000000000000000000" ], + "points": { + "entrance": [33, 21], + "warp_0": [33, 21], + "warp_1": [34, 2], + "warp_2": [1, 7], + "warp_3": [10, 2], + "warp_4": [5, 15], + "warp_5": [30, 10], + "warp_6": [24, 11], + "warp_7": [2, 4] + }, "warps": [ { "x": 33, "y": 21, - "dest_map": "CeruleanCity", - "dest_warp": 7 + "enter": "walk_south", + "to_map": "CeruleanCity", + "to_point": "warp_7" }, { "x": 34, "y": 2, - "dest_map": "CeruleanCave_2F", - "dest_warp": 0 + "enter": "step_on", + "to_map": "CeruleanCave_2F", + "to_point": "warp_0" }, { "x": 1, "y": 7, - "dest_map": "CeruleanCave_B1F", - "dest_warp": 0 + "enter": "step_on", + "to_map": "CeruleanCave_B1F", + "to_point": "warp_0" }, { "x": 10, "y": 2, - "dest_map": "CeruleanCave_2F", - "dest_warp": 1 + "enter": "step_on", + "to_map": "CeruleanCave_2F", + "to_point": "warp_1" }, { "x": 5, "y": 15, - "dest_map": "CeruleanCave_2F", - "dest_warp": 2 + "enter": "step_on", + "to_map": "CeruleanCave_2F", + "to_point": "warp_2" }, { "x": 30, "y": 10, - "dest_map": "CeruleanCave_2F", - "dest_warp": 3 + "enter": "step_on", + "to_map": "CeruleanCave_2F", + "to_point": "warp_3" }, { "x": 24, "y": 11, - "dest_map": "CeruleanCave_2F", - "dest_warp": 4 + "enter": "step_on", + "to_map": "CeruleanCave_2F", + "to_point": "warp_4" }, { "x": 2, "y": 4, - "dest_map": "CeruleanCave_2F", - "dest_warp": 5 + "enter": "step_on", + "to_map": "CeruleanCave_2F", + "to_point": "warp_5" } ], "objects": [ { + "name": "item_ball", + "kind": "item", "x": 7, "y": 3, - "kind": "item_ball", - "flag": "FLAG_HIDE_CERULEAN_CAVE_1F_NUGGET", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CERULEAN_CAVE_1F_NUGGET" }, { + "name": "item_ball", + "kind": "item", "x": 11, "y": 16, - "kind": "item_ball", - "flag": "FLAG_HIDE_CERULEAN_CAVE_1F_FULL_RESTORE", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CERULEAN_CAVE_1F_FULL_RESTORE" }, { + "name": "item_ball", + "kind": "item", "x": 25, "y": 5, - "kind": "item_ball", - "flag": "FLAG_HIDE_CERULEAN_CAVE_1F_MAX_ELIXIR", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CERULEAN_CAVE_1F_MAX_ELIXIR" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 7, "y": 21, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_12", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_12" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 13, "y": 21, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_13", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_13" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 5, "y": 20, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_14", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_14" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 14, "y": 20, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_15", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_15" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 11, "y": 21, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_16", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_16" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 9, "y": 18, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_17", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_17" } ], - "connections": [], - "points": [ - { - "name": "entrance", - "x": 33, - "y": 21 - } - ], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_2F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_2F.json index 5150099e00..185103d4c8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_2F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_2F.json @@ -1,23 +1,26 @@ { "name": "CeruleanCave_2F", - "width": 40, - "height": 23, + "source": { + "decomp_file": "data/maps/CeruleanCave_2F/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "########################################", "########################################", "########################################", "####....####..##.....#............######", - "#######......L#..###.#.#########.L######", + "#######.......#..###.#.#########..######", "####..####.####.##.#.#.........#########", - "####.L...#.........###########....######", + "####.....#.........###########....######", "#######.############.........####.######", "####.#...............#######....#.######", - "####.#################..#.L###.##.######", - "####.#....#............L#...#...#.######", + "####.#################..#..###.##.######", + "####.#....#.............#...#...#.######", "####.#.##.#.#####.#######.#####.#.######", "####.#..#.#.....#.......#.....#.#.######", "####.#..#.#####.#######.#####.#.########", - "####.#.L#.#.....#.....#.....#.#.#.######", + "####.#..#.#.....#.....#.....#.#.#.######", "####.####.#.#####.###.#.#.#.#.#.#.######", "####.#....#.........#.#.#.#.#.#.#.######", "####.#.####.#########.#.#.#.###.#.######", @@ -27,151 +30,151 @@ "########################################", "########################################" ], + "points": { + "warp_0": [33, 4], + "warp_1": [13, 4], + "warp_2": [7, 14], + "warp_3": [26, 9], + "warp_4": [23, 10], + "warp_5": [5, 6] + }, "warps": [ { "x": 33, "y": 4, - "dest_map": "CeruleanCave_1F", - "dest_warp": 1 + "enter": "step_on", + "to_map": "CeruleanCave_1F", + "to_point": "warp_1" }, { "x": 13, "y": 4, - "dest_map": "CeruleanCave_1F", - "dest_warp": 3 + "enter": "step_on", + "to_map": "CeruleanCave_1F", + "to_point": "warp_3" }, { "x": 7, "y": 14, - "dest_map": "CeruleanCave_1F", - "dest_warp": 4 + "enter": "step_on", + "to_map": "CeruleanCave_1F", + "to_point": "warp_4" }, { "x": 26, "y": 9, - "dest_map": "CeruleanCave_1F", - "dest_warp": 5 + "enter": "step_on", + "to_map": "CeruleanCave_1F", + "to_point": "warp_5" }, { "x": 23, "y": 10, - "dest_map": "CeruleanCave_1F", - "dest_warp": 6 + "enter": "step_on", + "to_map": "CeruleanCave_1F", + "to_point": "warp_6" }, { "x": 5, "y": 6, - "dest_map": "CeruleanCave_1F", - "dest_warp": 7 + "enter": "step_on", + "to_map": "CeruleanCave_1F", + "to_point": "warp_7" } ], "objects": [ { + "name": "item_ball", + "kind": "item", "x": 9, "y": 18, - "kind": "item_ball", - "flag": "FLAG_HIDE_CERULEAN_CAVE_2F_PP_UP", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CERULEAN_CAVE_2F_PP_UP" }, { + "name": "item_ball", + "kind": "item", "x": 29, "y": 16, - "kind": "item_ball", - "flag": "FLAG_HIDE_CERULEAN_CAVE_2F_ULTRA_BALL", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CERULEAN_CAVE_2F_ULTRA_BALL" }, { + "name": "item_ball", + "kind": "item", "x": 33, "y": 12, - "kind": "item_ball", - "flag": "FLAG_HIDE_CERULEAN_CAVE_2F_FULL_RESTORE", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CERULEAN_CAVE_2F_FULL_RESTORE" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 33, "y": 10, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_12", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_12" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 33, "y": 9, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_13", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_13" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 25, "y": 11, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_14", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_14" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 28, "y": 20, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_15", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_15" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 30, "y": 20, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_16", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_16" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 9, "y": 13, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_17", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_17" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 23, "y": 16, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_18", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_18" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 13, "y": 6, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_19", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_19" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 4, "y": 12, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_1A", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_1A" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 10, "y": 20, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_1B", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_1B" } ], - "connections": [], - "points": [], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_B1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_B1F.json index 58f72c3415..683929ff37 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_B1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCave_B1F.json @@ -1,7 +1,10 @@ { "name": "CeruleanCave_B1F", - "width": 40, - "height": 23, + "source": { + "decomp_file": "data/maps/CeruleanCave_B1F/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "########################################", "##..............##.....############....#", @@ -10,21 +13,21 @@ "##......#####.###..####.....#######....#", "##......#..........########.#######.#..#", "##..##..##........#########............#", - "##..#L..###......##########............#", - "##......#~~~~~##................#...####", - "#########~~~~~##................#...####", - "#~~~############................#...####", - "#~~~##############.########.###.#...####", - "#~~~#.#.#.########........#.###.#...####", - "#~~~#.....########........#.....#...####", - "#~~~#.....########........#.....#...####", - "#~~~###.###~~~~#......#...#.###.#...####", - "#~~~~~~~~~~~~~~#......#...#.###.#...####", - "#~~~~~~~~~~~~~~#......#...#.....#...####", - "#~~~~~~~~~~~~~~#......#...#.....#...####", - "######~~~~~~~~~##.##.##...###.###...####", - "######~~~~~~~~~~~~#.......###.......####", - "######~~~~~~~~~~~~##.....####.......####", + "##..#...###......##########............#", + "##......#wwwww##................#...####", + "#########wwwww##................#...####", + "#www############................#...####", + "#www##############.########.###.#...####", + "#www#.#.#.########........#.###.#...####", + "#www#.....########........#.....#...####", + "#www#.....########........#.....#...####", + "#www###.###wwww#......#...#.###.#...####", + "#wwwwwwwwwwwwww#......#...#.###.#...####", + "#wwwwwwwwwwwwww#......#...#.....#...####", + "#wwwwwwwwwwwwww#......#...#.....#...####", + "######wwwwwwwww##.##.##...###.###...####", + "######wwwwwwwwwwww#.......###.......####", + "######wwwwwwwwwwww##.....####.......####", "########################################" ], "elevation": [ @@ -52,119 +55,105 @@ "0000001111111111110033333000033333330000", "0000000000000000000000000000000000000000" ], + "points": { + "mewtwo": [7, 12], + "warp_0": [5, 7] + }, "warps": [ { "x": 5, "y": 7, - "dest_map": "CeruleanCave_1F", - "dest_warp": 2 + "enter": "step_on", + "to_map": "CeruleanCave_1F", + "to_point": "warp_2" } ], "objects": [ { + "name": "item_ball", + "kind": "item", "x": 31, "y": 9, - "kind": "item_ball", - "flag": "FLAG_HIDE_CERULEAN_CAVE_B1F_ULTRA_BALL", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CERULEAN_CAVE_B1F_ULTRA_BALL" }, { + "name": "item_ball", + "kind": "item", "x": 32, "y": 2, - "kind": "item_ball", - "flag": "FLAG_HIDE_CERULEAN_CAVE_B1F_MAX_REVIVE", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CERULEAN_CAVE_B1F_MAX_REVIVE" }, { + "name": "mewtwo", + "kind": "npc", "x": 7, "y": 12, - "kind": "mewtwo", - "flag": "FLAG_HIDE_MEWTWO", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_MEWTWO" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 37, "y": 1, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_12", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_12" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 38, "y": 2, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_13", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_13" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 35, "y": 1, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_14", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_14" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 37, "y": 4, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_15", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_15" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 35, "y": 5, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_16", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_16" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 2, "y": 2, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_17", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_17" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 4, "y": 1, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_18", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_18" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 6, "y": 1, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_19", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_19" }, { + "name": "rock_smash_rock", + "kind": "npc", "x": 3, "y": 4, - "kind": "rock_smash_rock", - "flag": "FLAG_TEMP_1A", - "wander_x": 0, - "wander_y": 0 - } - ], - "connections": [], - "points": [ - { - "name": "mewtwo", - "x": 7, - "y": 12 + "hide_flag": "FLAG_TEMP_1A" } ], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json index af06b3db98..0c54fa2d7d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json @@ -1,29 +1,32 @@ { "name": "CeruleanCity", - "width": 48, - "height": 40, + "source": { + "decomp_file": "data/maps/CeruleanCity/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ - "################~~~~~#...#...#~~~~~~~~~~~~~~~~~~", - "################~~~~~#...#JJJ#~~~~~~~~~~~~~~~~~~", - "####~~~~~~~~~~~~~~~~~#...#...#~~~~~~~~~~~~~~~~~~", - "####~~~~~~~~~~~~~~~~~#...#...#~~~~~~~~~~~~~~~~~~", - "####~~~~~~~~~~~~~~~~~#...#...###################", - "####~~~###############...#...#.........#########", - "####~~~#.............#...#...#.........#########", - "####~~~#.............#...#...#.........#########", - "####~~~##.v.##########.......#.v.##...##########", - "####~~~###############......#######...##########", - "####~~~###############......#######...##########", - "####~~~###D######D####......##D####......#######", - "#C##~~~#..........................#......#######", - "....~~~#..........................#......#######", - "....~~~#..........................#......#######", - "....~~~#.....#######..............#......#######", - "~~~~~~~#...JJ############.........#......#......", - "~~~~~~~#.....##D#########.........#......#######", - "~~~~~~~#............#####JJJ#######.............", + "################wwwww#...#...#wwwwwwwwwwwwwwwwww", + "################wwwww#...#vvv#wwwwwwwwwwwwwwwwww", + "####wwwwwwwwwwwwwwwww#...#...#wwwwwwwwwwwwwwwwww", + "####wwwwwwwwwwwwwwwww#...#...#wwwwwwwwwwwwwwwwww", + "####wwwwwwwwwwwwwwwww#...#...###################", + "####www###############...#...#.........#########", + "####www#.............#...#...#.........#########", + "####www#.............#...#...#.........#########", + "####www##...##########.......#...##...##########", + "####www###############......#######...##########", + "####www###############......#######...##########", + "####www###D######D####......##D####......#######", + "#.##www#..........................#......#######", + "....www#..........................#......#######", + "....www#..........................#......#######", + "....www#.....#######..............#......#######", + "wwwwwww#...vv############.........#......#......", + "wwwwwww#.....##D#########.........#......#######", + "wwwwwww#............#####vvv#######.............", "########............SSD##...#######.............", - "............................#######JJJ#..#######", + "............................#######vvv#..#######", "...........................S..#D#.....#..#......", "......................................#..#######", "#######...............................#..#######", @@ -31,7 +34,7 @@ "#######....#####....S.................#..#######", "#######....#####.....###############..#..#######", "#######....#####.....###############..#..#######", - "#######....S#CC#.....##D###SSD######..#..#######", + "#######....S#..#.....##D###SSD######..#..#######", "#######...............................#..#######", "#######...............................#..#######", "#######...............................#..#######", @@ -39,7 +42,7 @@ "#######..................................#######", "#######..................................#######", "###############....#........#....###############", - "###############....#JJJJJJJJ#....###############", + "###############....#vvvvvvvv#....###############", "###############....#........#....###############", "###############....#........#....###############", "###############....#........#....###############" @@ -86,206 +89,182 @@ "000000000000000333303333333303333000000000000000", "000000000000000333303333333303333000000000000000" ], + "points": { + "warp_3": [22, 19], + "warp_7": [1, 12] + }, "warps": [ { "x": 10, "y": 11, - "dest_map": "", - "dest_warp": 1 + "enter": "walk_into" }, { "x": 30, "y": 11, - "dest_map": "", - "dest_warp": 1 + "enter": "walk_into" }, { "x": 15, "y": 17, - "dest_map": "", - "dest_warp": 1 + "enter": "walk_into" }, { "x": 22, "y": 19, - "dest_map": "CeruleanCity_PokemonCenter_1F", - "dest_warp": 1 + "enter": "walk_into", + "to_map": "CeruleanCity_PokemonCenter_1F", + "to_point": "warp_1" }, { "x": 31, "y": 21, - "dest_map": "", - "dest_warp": 1 + "enter": "walk_into" }, { "x": 13, "y": 28, - "dest_map": "", - "dest_warp": 1 + "enter": "cave_entrance" }, { "x": 29, "y": 28, - "dest_map": "", - "dest_warp": 1 + "enter": "walk_into" }, { "x": 1, "y": 12, - "dest_map": "CeruleanCave_1F", - "dest_warp": 0 + "enter": "cave_entrance", + "to_map": "CeruleanCave_1F", + "to_point": "warp_0" }, { "x": 10, "y": 8, - "dest_map": "", - "dest_warp": 3 + "enter": "walk_south" }, { "x": 31, "y": 8, - "dest_map": "", - "dest_warp": 3 + "enter": "walk_south" }, { "x": 31, "y": 9, - "dest_map": "", - "dest_warp": 3 + "enter": "walk_into" }, { "x": 14, "y": 28, - "dest_map": "", - "dest_warp": 1 + "enter": "cave_entrance" }, { "x": 23, "y": 28, - "dest_map": "", - "dest_warp": 0 + "enter": "walk_into" }, { "x": 17, "y": 11, - "dest_map": "", - "dest_warp": 0 + "enter": "walk_into" } ], "objects": [ { + "name": "policeman", + "kind": "npc", "x": 31, - "y": 12, - "kind": "policeman", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 12 }, { + "name": "rocket_m", + "kind": "npc", "x": 33, "y": 6, - "kind": "rocket_m", - "flag": "FLAG_HIDE_CERULEAN_ROCKET", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CERULEAN_ROCKET" }, { + "name": "little_boy", + "kind": "npc", "x": 16, "y": 21, - "kind": "little_boy", - "flag": "", - "wander_x": 0, - "wander_y": 3 + "wander": { + "x0": 16, + "y0": 18, + "x1": 16, + "y1": 24 + } }, { + "name": "balding_man", + "kind": "npc", "x": 9, "y": 23, - "kind": "balding_man", - "flag": "", - "wander_x": 1, - "wander_y": 1 + "wander": { + "x0": 8, + "y0": 22, + "x1": 10, + "y1": 24 + } }, { + "name": "slowbro", + "kind": "npc", "x": 32, - "y": 29, - "kind": "slowbro", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 29 }, { + "name": "lass", + "kind": "npc", "x": 33, - "y": 29, - "kind": "lass", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 29 }, { + "name": "youngster", + "kind": "npc", "x": 34, - "y": 22, - "kind": "youngster", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 22 }, { + "name": "blue", + "kind": "npc", "x": 22, "y": 0, - "kind": "blue", - "flag": "FLAG_HIDE_CERULEAN_RIVAL", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CERULEAN_RIVAL" }, { + "name": "cut_tree", + "kind": "npc", "x": 26, "y": 32, - "kind": "cut_tree", - "flag": "FLAG_TEMP_13", - "wander_x": 0, - "wander_y": 0 - }, - { - "x": 50, - "y": 18, - "kind": "cut_tree", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_13" }, { + "name": "woman_1", + "kind": "npc", "x": 12, - "y": 30, - "kind": "woman_1", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 30 }, { + "name": "cooltrainer_m", + "kind": "npc", "x": 1, "y": 13, - "kind": "cooltrainer_m", - "flag": "FLAG_HIDE_CERULEAN_CAVE_GUARD", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CERULEAN_CAVE_GUARD" } ], + "flag_sets": { + "after_hall_of_fame": [ + "FLAG_HIDE_CERULEAN_CAVE_GUARD", + "FLAG_HIDE_CERULEAN_RIVAL", + "FLAG_HIDE_CERULEAN_ROCKET" + ] + }, "connections": [ { - "direction": "north", - "offset": 12, - "map": "Route24" - } - ], - "points": [], - "flag_sets": [ - { - "name": "after_hall_of_fame", - "flags": [ - "FLAG_HIDE_CERULEAN_CAVE_GUARD", - "FLAG_HIDE_CERULEAN_RIVAL", - "FLAG_HIDE_CERULEAN_ROCKET" - ] + "side": "north", + "to_map": "Route24", + "offset": 12 } ] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity_PokemonCenter_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity_PokemonCenter_1F.json index 22d90bfb20..c538b6e3b1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity_PokemonCenter_1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity_PokemonCenter_1F.json @@ -1,7 +1,10 @@ { "name": "CeruleanCity_PokemonCenter_1F", - "width": 15, - "height": 10, + "source": { + "decomp_file": "data/maps/CeruleanCity_PokemonCenter_1F/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "#.#############", "###############", @@ -9,9 +12,9 @@ "....#######....", "...............", "...............", - "#L.........##..", + "#..........##..", "...........##..", - ".......v.......", + "...............", "###############" ], "elevation": [ @@ -26,102 +29,97 @@ "333333333333333", "000000000000000" ], + "points": { + "pc": [11, 2], + "nurse_front": [7, 4], + "warp_1": [7, 8] + }, "warps": [ { "x": 6, "y": 8, - "dest_map": "CeruleanCity", - "dest_warp": 3 + "enter": "walk_into", + "to_map": "CeruleanCity", + "to_point": "warp_3" }, { "x": 7, "y": 8, - "dest_map": "CeruleanCity", - "dest_warp": 3 + "enter": "walk_south", + "to_map": "CeruleanCity", + "to_point": "warp_3" }, { "x": 8, "y": 8, - "dest_map": "CeruleanCity", - "dest_warp": 3 + "enter": "walk_into", + "to_map": "CeruleanCity", + "to_point": "warp_3" }, { "x": 1, "y": 6, - "dest_map": "", - "dest_warp": 0 + "enter": "step_on" } ], "objects": [ { + "name": "nurse", + "kind": "npc", "x": 7, - "y": 2, - "kind": "nurse", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 2 }, { + "name": "gentleman", + "kind": "npc", "x": 12, - "y": 5, - "kind": "gentleman", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 5 }, { + "name": "rocker", + "kind": "npc", "x": 5, "y": 4, - "kind": "rocker", - "flag": "", - "wander_x": 1, - "wander_y": 0 + "wander": { + "x0": 4, + "y0": 4, + "x1": 6, + "y1": 4 + } }, { + "name": "youngster", + "kind": "npc", "x": 4, "y": 8, - "kind": "youngster", - "flag": "", - "wander_x": 1, - "wander_y": 0 + "wander": { + "x0": 3, + "y0": 8, + "x1": 5, + "y1": 8 + } }, { + "name": "lass", + "kind": "npc", "x": 3, - "y": 3, - "kind": "lass", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 3 }, { + "name": "0", + "kind": "npc", "x": 2, "y": 1, - "kind": "0", - "flag": "FLAG_HIDE_POSTGAME_GOSSIPERS", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_POSTGAME_GOSSIPERS" }, { + "name": "0", + "kind": "npc", "x": 3, "y": 1, - "kind": "0", - "flag": "FLAG_HIDE_POSTGAME_GOSSIPERS", - "wander_x": 0, - "wander_y": 0 - } - ], - "connections": [], - "points": [ - { - "name": "pc", - "x": 11, - "y": 2 - }, - { - "name": "nurse_front", - "x": 7, - "y": 4 + "hide_flag": "FLAG_HIDE_POSTGAME_GOSSIPERS" } ], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown.json index 2794c4b8d7..63540ac440 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown.json @@ -1,7 +1,10 @@ { "name": "PalletTown", - "width": 24, - "height": 20, + "source": { + "decomp_file": "data/maps/PalletTown/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "############..##########", "############..##########", @@ -20,9 +23,9 @@ "##...S................##", "##....................##", "##...........###S##...##", - "##.....~~~~...........##", - "##.....~~~~...........##", - "##.....~~~~...........##" + "##.....wwww...........##", + "##.....wwww...........##", + "##.....wwww...........##" ], "elevation": [ "000000000000330000000000", @@ -46,65 +49,74 @@ "003333311113333333333300", "003333311113333333333300" ], + "points": { + "oaks_lab_front": [16, 14], + "warp_0": [6, 7], + "warp_1": [15, 7], + "warp_2": [16, 13] + }, "warps": [ { "x": 6, "y": 7, - "dest_map": "PalletTown_PlayersHouse_1F", - "dest_warp": 1 + "enter": "walk_into", + "to_map": "PalletTown_PlayersHouse_1F", + "to_point": "warp_1" }, { "x": 15, "y": 7, - "dest_map": "PalletTown_RivalsHouse", - "dest_warp": 0 + "enter": "walk_into", + "to_map": "PalletTown_RivalsHouse", + "to_point": "warp_0" }, { "x": 16, "y": 13, - "dest_map": "PalletTown_ProfessorOaksLab", - "dest_warp": 0 + "enter": "walk_into", + "to_map": "PalletTown_ProfessorOaksLab", + "to_point": "warp_0" } ], "objects": [ { + "name": "woman_1", + "kind": "npc", "x": 3, "y": 10, - "kind": "woman_1", - "flag": "", - "wander_x": 1, - "wander_y": 4 + "wander": { + "x0": 2, + "y0": 6, + "x1": 4, + "y1": 14 + } }, { + "name": "fat_man", + "kind": "npc", "x": 13, "y": 17, - "kind": "fat_man", - "flag": "", - "wander_x": 6, - "wander_y": 2 + "wander": { + "x0": 7, + "y0": 15, + "x1": 19, + "y1": 19 + } }, { + "name": "prof_oak", + "kind": "npc", "x": 10, "y": 8, - "kind": "prof_oak", - "flag": "FLAG_HIDE_OAK_IN_PALLET_TOWN", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_OAK_IN_PALLET_TOWN" } ], + "flag_sets": {}, "connections": [ { - "direction": "north", - "offset": 0, - "map": "Route1" + "side": "north", + "to_map": "Route1", + "offset": 0 } - ], - "points": [ - { - "name": "oaks_lab_front", - "x": 16, - "y": 14 - } - ], - "flag_sets": [] + ] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_1F.json index c4b5a50cdc..ee57a2a78a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_1F.json @@ -1,56 +1,64 @@ { "name": "PalletTown_PlayersHouse_1F", - "width": 13, - "height": 10, + "source": { + "decomp_file": "data/maps/PalletTown_PlayersHouse_1F/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "#############", "#############", - "#.........>##", + "#..........##", "#............", "#.....##.....", "#.....##.....", "#............", "##..........#", - "#...v........", + "#............", "#############" ], + "points": { + "warp_1": [4, 8], + "warp_2": [10, 2] + }, "warps": [ { "x": 5, "y": 8, - "dest_map": "PalletTown", - "dest_warp": 0 + "enter": "walk_into", + "to_map": "PalletTown", + "to_point": "warp_0" }, { "x": 4, "y": 8, - "dest_map": "PalletTown", - "dest_warp": 0 + "enter": "walk_south", + "to_map": "PalletTown", + "to_point": "warp_0" }, { "x": 10, "y": 2, - "dest_map": "PalletTown_PlayersHouse_2F", - "dest_warp": 0 + "enter": "walk_east", + "to_map": "PalletTown_PlayersHouse_2F", + "to_point": "warp_0" }, { "x": 3, "y": 9, - "dest_map": "PalletTown", - "dest_warp": 0 + "enter": "walk_into", + "to_map": "PalletTown", + "to_point": "warp_0" } ], "objects": [ { + "name": "mom", + "kind": "npc", "x": 8, - "y": 4, - "kind": "mom", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 4 } ], - "connections": [], - "points": [], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_2F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_2F.json index c69bd6be3d..eb5cbf8d32 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_2F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_2F.json @@ -1,14 +1,17 @@ { "name": "PalletTown_PlayersHouse_2F", - "width": 12, - "height": 9, + "source": { + "decomp_file": "data/maps/PalletTown_PlayersHouse_2F/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "############", "###########S", - "#.......##<.", "#.......##..", - "#.s...#.....", - "#.n...#.....", + "#.......##..", + "#.2...#.....", + "#.8...#.....", "#.#.........", "#...........", "#..........." @@ -24,22 +27,20 @@ "003033333333", "033333333333" ], + "points": { + "start": [6, 6], + "warp_0": [10, 2] + }, "warps": [ { "x": 10, "y": 2, - "dest_map": "PalletTown_PlayersHouse_1F", - "dest_warp": 2 + "enter": "walk_west", + "to_map": "PalletTown_PlayersHouse_1F", + "to_point": "warp_2" } ], "objects": [], - "connections": [], - "points": [ - { - "name": "start", - "x": 6, - "y": 6 - } - ], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json index 0cc55ccd2b..158ea7c73d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json @@ -1,7 +1,10 @@ { "name": "PalletTown_ProfessorOaksLab", - "width": 13, - "height": 14, + "source": { + "decomp_file": "data/maps/PalletTown_ProfessorOaksLab/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "#############", "######SS#####", @@ -15,112 +18,110 @@ ".............", ".............", ".............", - "#.....v.....#", + "#...........#", "#############" ], + "points": { + "warp_0": [6, 12] + }, "warps": [ { "x": 6, "y": 12, - "dest_map": "PalletTown", - "dest_warp": 2 + "enter": "walk_south", + "to_map": "PalletTown", + "to_point": "warp_2" }, { "x": 7, "y": 12, - "dest_map": "PalletTown", - "dest_warp": 2 + "enter": "walk_into", + "to_map": "PalletTown", + "to_point": "warp_2" }, { "x": 5, "y": 12, - "dest_map": "PalletTown", - "dest_warp": 2 + "enter": "walk_into", + "to_map": "PalletTown", + "to_point": "warp_2" } ], "objects": [ { + "name": "scientist", + "kind": "npc", "x": 3, - "y": 11, - "kind": "scientist", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 11 }, { + "name": "worker_f", + "kind": "npc", "x": 2, "y": 10, - "kind": "worker_f", - "flag": "", - "wander_x": 0, - "wander_y": 4 + "wander": { + "x0": 2, + "y0": 6, + "x1": 2, + "y1": 13 + } }, { + "name": "scientist", + "kind": "npc", "x": 11, - "y": 10, - "kind": "scientist", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 10 }, { + "name": "prof_oak", + "kind": "npc", "x": 6, "y": 3, - "kind": "prof_oak", - "flag": "FLAG_HIDE_OAK_IN_HIS_LAB", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_OAK_IN_HIS_LAB" }, { + "name": "item_ball", + "kind": "item", "x": 8, "y": 4, - "kind": "item_ball", - "flag": "FLAG_HIDE_BULBASAUR_BALL", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_BULBASAUR_BALL" }, { + "name": "item_ball", + "kind": "item", "x": 9, "y": 4, - "kind": "item_ball", - "flag": "FLAG_HIDE_SQUIRTLE_BALL", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_SQUIRTLE_BALL" }, { + "name": "item_ball", + "kind": "item", "x": 10, "y": 4, - "kind": "item_ball", - "flag": "FLAG_HIDE_CHARMANDER_BALL", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_CHARMANDER_BALL" }, { + "name": "blue", + "kind": "npc", "x": 5, "y": 4, - "kind": "blue", - "flag": "FLAG_HIDE_RIVAL_IN_LAB", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_RIVAL_IN_LAB" }, { + "name": "pokedex", + "kind": "npc", "x": 4, "y": 1, - "kind": "pokedex", - "flag": "FLAG_HIDE_POKEDEX", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_POKEDEX" }, { + "name": "pokedex", + "kind": "npc", "x": 5, "y": 1, - "kind": "pokedex", - "flag": "FLAG_HIDE_POKEDEX", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_POKEDEX" } ], - "connections": [], - "points": [], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json index 7e4d85de31..bfd7bdf2e0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json @@ -1,7 +1,10 @@ { "name": "PalletTown_RivalsHouse", - "width": 13, - "height": 10, + "source": { + "decomp_file": "data/maps/PalletTown_RivalsHouse/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "#############", "#############", @@ -11,48 +14,56 @@ "......##.....", ".............", ".............", - "#...v.......#", + "#...........#", "#############" ], + "points": { + "warp_0": [4, 8] + }, "warps": [ { "x": 4, "y": 8, - "dest_map": "PalletTown", - "dest_warp": 1 + "enter": "walk_south", + "to_map": "PalletTown", + "to_point": "warp_1" }, { "x": 5, "y": 8, - "dest_map": "PalletTown", - "dest_warp": 1 + "enter": "walk_into", + "to_map": "PalletTown", + "to_point": "warp_1" }, { "x": 3, "y": 8, - "dest_map": "PalletTown", - "dest_warp": 1 + "enter": "walk_into", + "to_map": "PalletTown", + "to_point": "warp_1" } ], "objects": [ { + "name": "daisy", + "kind": "npc", "x": 10, "y": 6, - "kind": "daisy", - "flag": "", - "wander_x": 1, - "wander_y": 3 + "wander": { + "x0": 9, + "y0": 3, + "x1": 11, + "y1": 9 + } }, { + "name": "town_map", + "kind": "npc", "x": 6, "y": 4, - "kind": "town_map", - "flag": "FLAG_HIDE_TOWN_MAP", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_TOWN_MAP" } ], - "connections": [], - "points": [], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json index 924deae088..da09eb8aa1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json @@ -1,7 +1,10 @@ { "name": "PewterCity", - "width": 48, - "height": 40, + "source": { + "decomp_file": "data/maps/PewterCity/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "################################################", "#######################....#####################", @@ -9,8 +12,8 @@ "####........#################.........##########", "####........#############D######......##########", "####........###########...............##########", - "#######.....#####C#####..#######........########", - "####JJJ..JJJJJJJ...SJJJJJJJJJJJJJJJJJ...########", + "#######.....#####.#####..#######........########", + "####vvv..vvvvvvv...Svvvvvvvvvvvvvvvvv...########", "####....................................########", "####............................#####...########", "######..........................#####...########", @@ -33,7 +36,7 @@ "######....................#.........#...########", "######..#####.............#.........#...########", "######..#####.............#.........#...########", - "######..#D###.......S.....#JJJJ.JJJJ#...########", + "######..#D###.......S.....#vvvv.vvvv#...########", "######..................................########", "######..................................########", "######..................................########", @@ -44,121 +47,121 @@ "####################....########################", "####################....########################" ], + "points": { + "gym_front": [15, 17], + "warp_0": [17, 6], + "warp_1": [25, 4], + "warp_2": [15, 16], + "warp_3": [28, 18], + "warp_5": [17, 25] + }, "warps": [ { "x": 17, "y": 6, - "dest_map": "PewterCity_Museum_1F", - "dest_warp": 1 + "enter": "cave_entrance", + "to_map": "PewterCity_Museum_1F", + "to_point": "warp_1" }, { "x": 25, "y": 4, - "dest_map": "PewterCity_Museum_1F", - "dest_warp": 3 + "enter": "walk_into", + "to_map": "PewterCity_Museum_1F", + "to_point": "warp_3" }, { "x": 15, "y": 16, - "dest_map": "PewterCity_Gym", - "dest_warp": 1 + "enter": "walk_into", + "to_map": "PewterCity_Gym", + "to_point": "warp_1" }, { "x": 28, "y": 18, - "dest_map": "PewterCity_Mart", - "dest_warp": 1 + "enter": "walk_into", + "to_map": "PewterCity_Mart", + "to_point": "warp_1" }, { "x": 33, "y": 11, - "dest_map": "", - "dest_warp": 1 + "enter": "walk_into" }, { "x": 17, "y": 25, - "dest_map": "PewterCity_PokemonCenter_1F", - "dest_warp": 1 + "enter": "walk_into", + "to_map": "PewterCity_PokemonCenter_1F", + "to_point": "warp_1" }, { "x": 9, "y": 30, - "dest_map": "", - "dest_warp": 1 + "enter": "walk_into" } ], "objects": [ { + "name": "lass", + "kind": "npc", "x": 6, - "y": 15, - "kind": "lass", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 15 }, { + "name": "man", + "kind": "npc", "x": 33, "y": 17, - "kind": "man", - "flag": "FLAG_HIDE_PEWTER_MUSEUM_GUIDE", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_PEWTER_MUSEUM_GUIDE" }, { + "name": "fat_man", + "kind": "npc", "x": 21, - "y": 28, - "kind": "fat_man", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 28 }, { + "name": "bug_catcher", + "kind": "npc", "x": 33, "y": 27, - "kind": "bug_catcher", - "flag": "", - "wander_x": 2, - "wander_y": 0 + "wander": { + "x0": 31, + "y0": 27, + "x1": 35, + "y1": 27 + } }, { + "name": "boy", + "kind": "npc", "x": 42, "y": 20, - "kind": "boy", - "flag": "FLAG_HIDE_PEWTER_CITY_GYM_GUIDE", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_PEWTER_CITY_GYM_GUIDE" }, { + "name": "cut_tree", + "kind": "npc", "x": 30, "y": 5, - "kind": "cut_tree", - "flag": "FLAG_TEMP_12", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_12" }, { + "name": "scientist", + "kind": "npc", "x": 46, "y": 20, - "kind": "scientist", - "flag": "FLAG_HIDE_PEWTER_CITY_RUNNING_SHOES_GUY", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_PEWTER_CITY_RUNNING_SHOES_GUY" } ], + "flag_sets": {}, "connections": [ { - "direction": "south", - "offset": 12, - "map": "Route2" + "side": "south", + "to_map": "Route2", + "offset": 12 } - ], - "points": [ - { - "name": "gym_front", - "x": 15, - "y": 17 - } - ], - "flag_sets": [] + ] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json index 4c478d8e8e..75afb1541c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json @@ -1,7 +1,10 @@ { "name": "PewterCity_Gym", - "width": 13, - "height": 16, + "source": { + "decomp_file": "data/maps/PewterCity_Gym/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "#############", "####.....####", @@ -17,62 +20,56 @@ "#...........#", "#...S...S...#", "#...........#", - "#.....v.....#", + "#...........#", "#############" ], + "points": { + "brock_front": [6, 6], + "warp_1": [6, 14] + }, "warps": [ { "x": 5, "y": 14, - "dest_map": "PewterCity", - "dest_warp": 2 + "enter": "walk_into", + "to_map": "PewterCity", + "to_point": "warp_2" }, { "x": 6, "y": 14, - "dest_map": "PewterCity", - "dest_warp": 2 + "enter": "walk_south", + "to_map": "PewterCity", + "to_point": "warp_2" }, { "x": 7, "y": 14, - "dest_map": "PewterCity", - "dest_warp": 2 + "enter": "walk_into", + "to_map": "PewterCity", + "to_point": "warp_2" } ], "objects": [ { + "name": "brock", + "kind": "npc", "x": 6, - "y": 5, - "kind": "brock", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 5 }, { + "name": "camper", + "kind": "npc", "x": 3, - "y": 8, - "kind": "camper", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 8 }, { + "name": "gym_guy", + "kind": "npc", "x": 7, - "y": 12, - "kind": "gym_guy", - "flag": "", - "wander_x": 0, - "wander_y": 0 - } - ], - "connections": [], - "points": [ - { - "name": "brock_front", - "x": 6, - "y": 6 + "y": 12 } ], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json index 1cdef57978..7b4e49dea9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json @@ -1,7 +1,10 @@ { "name": "PewterCity_Mart", - "width": 11, - "height": 9, + "source": { + "decomp_file": "data/maps/PewterCity_Mart/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "###########", "###########", @@ -10,7 +13,7 @@ "####...##.#", ".......##.#", ".##....##.#", - "....v......", + "...........", "###########" ], "elevation": [ @@ -24,53 +27,52 @@ "33333333333", "00000000000" ], + "points": { + "warp_1": [4, 7] + }, "warps": [ { "x": 3, "y": 7, - "dest_map": "PewterCity", - "dest_warp": 3 + "enter": "walk_into", + "to_map": "PewterCity", + "to_point": "warp_3" }, { "x": 4, "y": 7, - "dest_map": "PewterCity", - "dest_warp": 3 + "enter": "walk_south", + "to_map": "PewterCity", + "to_point": "warp_3" }, { "x": 5, "y": 7, - "dest_map": "PewterCity", - "dest_warp": 3 + "enter": "walk_into", + "to_map": "PewterCity", + "to_point": "warp_3" } ], "objects": [ { + "name": "youngster", + "kind": "npc", "x": 8, - "y": 2, - "kind": "youngster", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 2 }, { + "name": "boy", + "kind": "npc", "x": 6, - "y": 4, - "kind": "boy", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 4 }, { + "name": "clerk", + "kind": "npc", "x": 2, - "y": 3, - "kind": "clerk", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 3 } ], - "connections": [], - "points": [], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Museum_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Museum_1F.json index ecf6acb232..1ea83f0faf 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Museum_1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Museum_1F.json @@ -1,7 +1,10 @@ { "name": "PewterCity_Museum_1F", - "width": 28, - "height": 11, + "source": { + "decomp_file": "data/maps/PewterCity_Museum_1F/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "############################", "############################", @@ -11,99 +14,95 @@ "...............#............", "...........#...#...........#", "...####..###...###.........#", - "........>###.....#..........", - "#........###..v.##...v..##..", + ".........###.....#..........", + "#........###....##......##..", "############################" ], + "points": { + "warp_1": [14, 9], + "warp_3": [21, 9] + }, "warps": [ { "x": 13, "y": 9, - "dest_map": "PewterCity", - "dest_warp": 0 + "enter": "walk_into", + "to_map": "PewterCity", + "to_point": "warp_0" }, { "x": 14, "y": 9, - "dest_map": "PewterCity", - "dest_warp": 0 + "enter": "walk_south", + "to_map": "PewterCity", + "to_point": "warp_0" }, { "x": 15, "y": 9, - "dest_map": "PewterCity", - "dest_warp": 0 + "enter": "walk_into", + "to_map": "PewterCity", + "to_point": "warp_0" }, { "x": 21, "y": 9, - "dest_map": "PewterCity", - "dest_warp": 1 + "enter": "walk_south", + "to_map": "PewterCity", + "to_point": "warp_1" }, { "x": 22, "y": 9, - "dest_map": "PewterCity", - "dest_warp": 1 + "enter": "walk_into", + "to_map": "PewterCity", + "to_point": "warp_1" }, { "x": 8, "y": 8, - "dest_map": "", - "dest_warp": 0 + "enter": "walk_east" } ], "objects": [ { + "name": "worker_m", + "kind": "npc", "x": 16, - "y": 5, - "kind": "worker_m", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 5 }, { + "name": "old_man_1", + "kind": "npc", "x": 2, - "y": 4, - "kind": "old_man_1", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 4 }, { + "name": "scientist", + "kind": "npc", "x": 21, - "y": 3, - "kind": "scientist", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 3 }, { + "name": "old_amber", + "kind": "npc", "x": 22, "y": 3, - "kind": "old_amber", - "flag": "FLAG_HIDE_OLD_AMBER", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_OLD_AMBER" }, { + "name": "scientist", + "kind": "npc", "x": 26, - "y": 4, - "kind": "scientist", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 4 }, { + "name": "scientist", + "kind": "npc", "x": 26, - "y": 7, - "kind": "scientist", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 7 } ], - "connections": [], - "points": [], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_PokemonCenter_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_PokemonCenter_1F.json index e6c20a0d10..90267e027f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_PokemonCenter_1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_PokemonCenter_1F.json @@ -1,7 +1,10 @@ { "name": "PewterCity_PokemonCenter_1F", - "width": 15, - "height": 10, + "source": { + "decomp_file": "data/maps/PewterCity_PokemonCenter_1F/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "#.#############", "###############", @@ -9,9 +12,9 @@ "....#######....", "...............", "...............", - "#L.........##..", + "#..........##..", "...........##..", - ".......v.......", + "...............", "###############" ], "elevation": [ @@ -26,97 +29,82 @@ "333333333333333", "000000000000000" ], + "points": { + "nurse_front": [7, 4], + "warp_1": [7, 8] + }, "warps": [ { "x": 6, "y": 8, - "dest_map": "PewterCity", - "dest_warp": 5 + "enter": "walk_into", + "to_map": "PewterCity", + "to_point": "warp_5" }, { "x": 7, "y": 8, - "dest_map": "PewterCity", - "dest_warp": 5 + "enter": "walk_south", + "to_map": "PewterCity", + "to_point": "warp_5" }, { "x": 8, "y": 8, - "dest_map": "PewterCity", - "dest_warp": 5 + "enter": "walk_into", + "to_map": "PewterCity", + "to_point": "warp_5" }, { "x": 1, "y": 6, - "dest_map": "", - "dest_warp": 0 + "enter": "step_on" } ], "objects": [ { + "name": "jigglypuff", + "kind": "npc", "x": 2, - "y": 2, - "kind": "jigglypuff", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 2 }, { + "name": "gentleman", + "kind": "npc", "x": 4, - "y": 8, - "kind": "gentleman", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 8 }, { + "name": "nurse", + "kind": "npc", "x": 7, - "y": 2, - "kind": "nurse", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 2 }, { + "name": "youngster", + "kind": "npc", "x": 1, - "y": 2, - "kind": "youngster", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 2 }, { + "name": "woman_1", + "kind": "npc", "x": 13, - "y": 2, - "kind": "woman_1", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 2 }, { + "name": "gba_kid", + "kind": "npc", "x": 10, - "y": 7, - "kind": "gba_kid", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 7 }, { + "name": "gba_kid", + "kind": "npc", "x": 14, - "y": 6, - "kind": "gba_kid", - "flag": "", - "wander_x": 0, - "wander_y": 0 - } - ], - "connections": [], - "points": [ - { - "name": "nurse_front", - "x": 7, - "y": 4 + "y": 6 } ], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route1.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route1.json index 9c0ea3ca1d..c48c746b72 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route1.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route1.json @@ -1,80 +1,91 @@ { "name": "Route1", - "width": 24, - "height": 40, + "source": { + "decomp_file": "data/maps/Route1/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "##########....##########", "##########....##########", "##....................##", "##....................##", "##......##............##", - "##JJJJJJ##JJJJJJ......##", - "##......##\"\"\"\"\"\"\"\"\"\"\"\"##", - "##......##\"\"\"\"\"\"\"\"\"\"\"\"##", - "##......##\"\"\"\"\"\"\"\"\"\"\"\"##", - "##......##\"\"\"\"\"\"\"\"\"\"\"\"##", - "##JJJJJJ##\"\"\"\"\"\"\"\"\"\"\"\"##", + "##vvvvvv##vvvvvv......##", + "##......##~~~~~~~~~~~~##", + "##......##~~~~~~~~~~~~##", + "##......##~~~~~~~~~~~~##", + "##......##~~~~~~~~~~~~##", + "##vvvvvv##~~~~~~~~~~~~##", "##......##............##", "##....................##", - "##..............\"\"\"\"\"\"##", - "##..............\"\"\"\"\"\"##", - "####JJJJJJ######\"\"\"\"\"\"##", - "####......######\"\"\"\"\"\"##", - "##..............\"\"\"\"\"\"##", + "##..............~~~~~~##", + "##..............~~~~~~##", + "####vvvvvv######~~~~~~##", + "####......######~~~~~~##", + "##..............~~~~~~##", "##....................##", "##....................##", - "##JJ.JJJJ..JJJJJJJJJJJ##", + "##vv.vvvv..vvvvvvvvvvv##", "##....................##", "##....................##", "##....................##", - "##..........\"\"\"\"\"\"....##", - "############\"\"\"\"\"\"....##", - "############\"\"\"\"\"\"JJJJ##", - "##..........\"\"\"\"\"\"....##", - "##..........\"\"\"\"\"\"....##", + "##..........~~~~~~....##", + "############~~~~~~....##", + "############~~~~~~vvvv##", + "##..........~~~~~~....##", + "##..........~~~~~~....##", "##....................##", "##....................##", - "##JJJJ...SJJJJJJJJJJJJ##", - "##..\"\"\"\"\"\"\"......\"\"\"\"\"##", - "##..\"\"\"\"\"\"\"......\"\"\"\"\"##", - "##\"\"\"\"\"\"\"......\"\"\"\"\"..##", - "##\"\"\"\"\"\"\"...\"\".\"\"\"\"\"..##", - "############\"\"##########", - "##.........#\"\"#.......##", - "############\"\"##########", - "############\"\"##########" + "##vvvv...Svvvvvvvvvvvv##", + "##..~~~~~~~......~~~~~##", + "##..~~~~~~~......~~~~~##", + "##~~~~~~~......~~~~~..##", + "##~~~~~~~...~~.~~~~~..##", + "############~~##########", + "##.........#~~#.......##", + "############~~##########", + "############~~##########" ], + "points": {}, "warps": [], "objects": [ { + "name": "clerk", + "kind": "npc", "x": 6, "y": 28, - "kind": "clerk", - "flag": "", - "wander_x": 0, - "wander_y": 1 + "wander": { + "x0": 6, + "y0": 27, + "x1": 6, + "y1": 29 + } }, { + "name": "boy", + "kind": "npc", "x": 19, "y": 16, - "kind": "boy", - "flag": "", - "wander_x": 1, - "wander_y": 0 + "wander": { + "x0": 18, + "y0": 16, + "x1": 20, + "y1": 16 + } } ], + "flag_sets": {}, "connections": [ { - "direction": "north", - "offset": -12, - "map": "ViridianCity" + "side": "north", + "to_map": "ViridianCity", + "offset": -12 }, { - "direction": "south", - "offset": 0, - "map": "PalletTown" + "side": "south", + "to_map": "PalletTown", + "offset": 0 } - ], - "points": [], - "flag_sets": [] + ] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2.json index 6e4337074e..706949faeb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2.json @@ -1,22 +1,25 @@ { "name": "Route2", - "width": 24, - "height": 80, + "source": { + "decomp_file": "data/maps/Route2/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "########....############", "########....############", - "##\"\"\"\"\"\"\"...############", - "##\"\"\"\"\"\"\"...#.........##", - "##\"\"\"\"\"\"\"...#.........##", - "##\"\"\"\"\"\"\"...#.........##", - "##\"\"\"\"\"\"\"...#########.##", - "##\"\"\"\"\"\"\"...#########.##", - "##\"\"\"\"\"\"\"...#########.##", + "##~~~~~~~...############", + "##~~~~~~~...#.........##", + "##~~~~~~~...#.........##", + "##~~~~~~~...#.........##", + "##~~~~~~~...#########.##", + "##~~~~~~~...#########.##", + "##~~~~~~~...#########.##", "##..........#########.##", "##..........#########.##", - "##..........#####C###.##", + "##..........#####.###.##", "##..........#.S.......##", - "####.vv.###.#.........##", + "####....###.#.........##", "###########...........##", "##########............##", "##############........##", @@ -35,35 +38,35 @@ "################......##", "################......##", "################......##", - "################JJJ.JJ##", + "################vvv.vv##", "################......##", "################......##", "################......##", "################......##", - "################JJJ.JJ##", + "################vvv.vv##", "################......##", "################......##", "################......##", - "#################.vv.###", + "#################....###", "########################", "########################", "########################", "##........##############", - "##################CC####", + "##################..####", "#################....###", "################......##", "################......##", "###.####.#######......##", - "#####CC#########JJJ.JJ##", + "#####..#########vvv.vv##", "####....########......##", "##............##......##", "##............##......##", - "##JJJJJJJJJ...##......##", - "##....\"\"\"\"\"\"\".##......##", - "##....\"\"\"\"\"\"\".##JJ.JJJ##", - "##....\"\"\"\"\"\"\".##......##", - "##....\"\"\"\"\"\"\".##......##", - "##....\"\"\"\"\"\"\".##......##", + "##vvvvvvvvv...##......##", + "##....~~~~~~~.##......##", + "##....~~~~~~~.##vv.vvv##", + "##....~~~~~~~.##......##", + "##....~~~~~~~.##......##", + "##....~~~~~~~.##......##", "##............##......##", "##....................##", "##....##########......##", @@ -73,7 +76,7 @@ "##............##......##", "##............##......##", "##....................##", - "##JJJJJJJ..JJJ..JJ.JJJ##", + "##vvvvvvv..vvv..vv.vvv##", "##............##......##", "####..........##......##", "####...S......##......##", @@ -84,138 +87,125 @@ "#######.......##########", "#######.....############" ], + "points": { + "warp_0": [5, 13], + "warp_2": [5, 51] + }, "warps": [ { "x": 5, "y": 13, - "dest_map": "Route2_ViridianForest_NorthEntrance", - "dest_warp": 3 + "enter": "walk_south", + "to_map": "Route2_ViridianForest_NorthEntrance", + "to_point": "warp_3" }, { "x": 6, "y": 13, - "dest_map": "Route2_ViridianForest_NorthEntrance", - "dest_warp": 3 + "enter": "walk_south", + "to_map": "Route2_ViridianForest_NorthEntrance", + "to_point": "warp_3" }, { "x": 5, "y": 51, - "dest_map": "Route2_ViridianForest_SouthEntrance", - "dest_warp": 1 + "enter": "cave_entrance", + "to_map": "Route2_ViridianForest_SouthEntrance", + "to_point": "warp_1" }, { "x": 17, "y": 11, - "dest_map": "", - "dest_warp": 1 + "enter": "cave_entrance" }, { "x": 17, "y": 22, - "dest_map": "", - "dest_warp": 1 + "enter": "walk_into" }, { "x": 18, "y": 46, - "dest_map": "", - "dest_warp": 1 + "enter": "cave_entrance" }, { "x": 18, "y": 41, - "dest_map": "", - "dest_warp": 3 + "enter": "walk_south" }, { "x": 19, "y": 41, - "dest_map": "", - "dest_warp": 3 + "enter": "walk_south" }, { "x": 19, "y": 46, - "dest_map": "", - "dest_warp": 1 + "enter": "cave_entrance" }, { "x": 6, "y": 51, - "dest_map": "Route2_ViridianForest_SouthEntrance", - "dest_warp": 1 + "enter": "cave_entrance", + "to_map": "Route2_ViridianForest_SouthEntrance", + "to_point": "warp_1" } ], "objects": [ { + "name": "cut_tree", + "kind": "npc", "x": 16, "y": 62, - "kind": "cut_tree", - "flag": "FLAG_TEMP_14", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_14" }, { + "name": "cut_tree", + "kind": "npc", "x": 15, "y": 69, - "kind": "cut_tree", - "flag": "FLAG_TEMP_13", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_13" }, { + "name": "cut_tree", + "kind": "npc", "x": 11, "y": 13, - "kind": "cut_tree", - "flag": "FLAG_TEMP_15", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_15" }, { + "name": "cut_tree", + "kind": "npc", "x": 18, "y": 26, - "kind": "cut_tree", - "flag": "FLAG_TEMP_16", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_16" }, { + "name": "item_ball", + "kind": "item", "x": 17, "y": 54, - "kind": "item_ball", - "flag": "FLAG_HIDE_ROUTE2_ETHER", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_ROUTE2_ETHER" }, { + "name": "item_ball", + "kind": "item", "x": 17, "y": 64, - "kind": "item_ball", - "flag": "FLAG_HIDE_ROUTE2_PARALYZE_HEAL", - "wander_x": 0, - "wander_y": 0 - }, - { - "x": 6, - "y": 85, - "kind": "cut_tree", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_ROUTE2_PARALYZE_HEAL" } ], + "flag_sets": {}, "connections": [ { - "direction": "north", - "offset": -12, - "map": "PewterCity" + "side": "north", + "to_map": "PewterCity", + "offset": -12 }, { - "direction": "south", - "offset": -12, - "map": "ViridianCity" + "side": "south", + "to_map": "ViridianCity", + "offset": -12 } - ], - "points": [], - "flag_sets": [] + ] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route22.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route22.json index ef4a2a11fb..be2d5629b2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route22.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route22.json @@ -1,24 +1,27 @@ { "name": "Route22", - "width": 48, - "height": 24, + "source": { + "decomp_file": "data/maps/Route22/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "#############################################...", "###########################################.#...", "##################################........#.###.", - "##################################JJJJ.JJJ#...##", + "##################################vvvv.vvv#...##", "######################....................#.....", "########D######...........................######", "#####.......###.........................##......", "###...........#.............######......##......", - "###...........#JJJJJJJ~~~~~~######JJ..JJ##......", - "###JJJJJJJ..JJ#\"\"\"\"\"\"\"~~~~~~######\"\"\"\"\"\"##......", - "###...........#\"\"\"\"\"\"\"~~~~~~######\"\"\"\"\"\"##....##", - "###...........#\"\"\"\"\"\"\"~~~~~~######\"\"\"\"\"\"##....##", - "####...S#######\"\"\"\"\"\"\"......######\"\"\"\"\"\"##....##", - "####...........\"\"\"\"\"\"\"......######\"\"\"\"\"\"##....##", + "###...........#vvvvvvvwwwwww######vv..vv##......", + "###vvvvvvv..vv#~~~~~~~wwwwww######~~~~~~##......", + "###...........#~~~~~~~wwwwww######~~~~~~##....##", + "###...........#~~~~~~~wwwwww######~~~~~~##....##", + "####...S#######~~~~~~~......######~~~~~~##....##", + "####...........~~~~~~~......######~~~~~~##....##", "####........................######............##", - "####JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ..JJJJJ##", + "####vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv..vvvvv##", "####..........................................##", "####..........................................##", "####..........................................##", @@ -54,37 +57,34 @@ "000000000000000000000000000000000000000000000000", "000000000000000000000000000000000000000000000000" ], + "points": {}, "warps": [ { "x": 8, "y": 5, - "dest_map": "", - "dest_warp": 2 + "enter": "walk_into" }, { "x": 9, "y": 5, - "dest_map": "", - "dest_warp": 2 + "enter": "walk_into" } ], "objects": [ { + "name": "blue", + "kind": "npc", "x": 25, "y": 4, - "kind": "blue", - "flag": "FLAG_HIDE_ROUTE_22_RIVAL", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_ROUTE_22_RIVAL" } ], + "flag_sets": {}, "connections": [ { - "direction": "east", - "offset": -10, - "map": "ViridianCity" + "side": "east", + "to_map": "ViridianCity", + "offset": -10 } - ], - "points": [], - "flag_sets": [] + ] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json index ecac345dff..59d1789c3c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json @@ -1,15 +1,18 @@ { "name": "Route24", - "width": 24, - "height": 40, + "source": { + "decomp_file": "data/maps/Route24/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "########################", "########################", "########################", - "####.........J...J......", - "####.........J...J......", - "####.........J...J......", - "###JJJJ..JJJJ#...#JJJJJJ", + "####.........>...<......", + "####.........>...<......", + "####.........>...<......", + "###vvvv..vvvv#...#vvvvvv", "###.....................", "###.....................", "###.....................", @@ -19,30 +22,30 @@ "###..........#...#######", "###..........#...#######", "###..........#...#######", - "###...~~~#...#...#######", - "###...~~~#...#...#######", - "###...~~~#...#...#######", - "###\"\"\"~~~#...#...#######", - "###\"\"\"~~~#...#...#######", - "###\"\"\"~~~#...#...#######", - "###\"\"\"~~~#...#...#######", - "###\"\"\"~~~#...#...#######", - "###\"\"\"~~~#...#...#######", - "###\"\"\"~~~#...#...#######", - "###\"\"\"~~~#...#...#######", - "###\"\"\"~~~#...#...#~~~~~~", - "###\"\"\"~~~#...#...#~~~~~~", - "###\"\"\"~~~#...#...#~~~~~~", - "###\"\"\"~~~#...#...#~~~~~~", - "###\"\"\"~~~#...#...#~~~~~~", - "####~~~~~#...#...#~~~~~~", - "####~~~~~#...#...#~~~~~~", - "####~~~~~#...#...#~~~~~~", - "####~~~~~#...#...#~~~~~~", - "####~~~~~#...#...#~~~~~~", - "####~~~~~#...#...#~~~~~~", - "####~~~~~#...#...#~~~~~~", - "####~~~~~#...#...#~~~~~~" + "###...www#...#...#######", + "###...www#...#...#######", + "###...www#...#...#######", + "###~~~www#...#...#######", + "###~~~www#...#...#######", + "###~~~www#...#...#######", + "###~~~www#...#...#######", + "###~~~www#...#...#######", + "###~~~www#...#...#######", + "###~~~www#...#...#######", + "###~~~www#...#...#######", + "###~~~www#...#...#wwwwww", + "###~~~www#...#...#wwwwww", + "###~~~www#...#...#wwwwww", + "###~~~www#...#...#wwwwww", + "###~~~www#...#...#wwwwww", + "####wwwww#...#...#wwwwww", + "####wwwww#...#...#wwwwww", + "####wwwww#...#...#wwwwww", + "####wwwww#...#...#wwwwww", + "####wwwww#...#...#wwwwww", + "####wwwww#...#...#wwwwww", + "####wwwww#...#...#wwwwww", + "####wwwww#...#...#wwwwww" ], "elevation": [ "000000000000000000000000", @@ -86,80 +89,66 @@ "000011111033303330100000", "000011111033303330100000" ], + "points": {}, "warps": [], "objects": [ { + "name": "man", + "kind": "npc", "x": 12, "y": 15, - "kind": "man", - "flag": "FLAG_HIDE_NUGGET_BRIDGE_ROCKET", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_NUGGET_BRIDGE_ROCKET" }, { + "name": "camper", + "kind": "npc", "x": 12, - "y": 19, - "kind": "camper", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 19 }, { + "name": "lass", + "kind": "npc", "x": 10, - "y": 22, - "kind": "lass", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 22 }, { + "name": "youngster", + "kind": "npc", "x": 12, - "y": 25, - "kind": "youngster", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 25 }, { + "name": "lass", + "kind": "npc", "x": 10, - "y": 28, - "kind": "lass", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 28 }, { + "name": "bug_catcher", + "kind": "npc", "x": 12, - "y": 31, - "kind": "bug_catcher", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 31 }, { + "name": "camper", + "kind": "npc", "x": 5, - "y": 21, - "kind": "camper", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 21 }, { + "name": "item_ball", + "kind": "item", "x": 11, "y": 4, - "kind": "item_ball", - "flag": "FLAG_HIDE_ROUTE24_TM45", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_ROUTE24_TM45" } ], + "flag_sets": {}, "connections": [ { - "direction": "south", - "offset": -12, - "map": "CeruleanCity" + "side": "south", + "to_map": "CeruleanCity", + "offset": -12 } - ], - "points": [], - "flag_sets": [] + ] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_NorthEntrance.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_NorthEntrance.json index e7776b1911..021edbb11d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_NorthEntrance.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_NorthEntrance.json @@ -1,10 +1,13 @@ { "name": "Route2_ViridianForest_NorthEntrance", - "width": 15, - "height": 12, + "source": { + "decomp_file": "data/maps/Route2_ViridianForest_NorthEntrance/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "###############", - "#######C#######", + "#######.#######", "##...#...#...##", "#.............#", "#..........##.#", @@ -13,62 +16,63 @@ "#..........##.#", "###........##.#", "#.............#", - "#......v......#", + "#.............#", "###############" ], + "points": { + "warp_1": [7, 10], + "warp_3": [7, 1] + }, "warps": [ { "x": 6, "y": 10, - "dest_map": "ViridianForest", - "dest_warp": 2 + "enter": "walk_into", + "to_map": "ViridianForest", + "to_point": "warp_2" }, { "x": 7, "y": 10, - "dest_map": "ViridianForest", - "dest_warp": 2 + "enter": "walk_south", + "to_map": "ViridianForest", + "to_point": "warp_2" }, { "x": 8, "y": 10, - "dest_map": "ViridianForest", - "dest_warp": 2 + "enter": "walk_into", + "to_map": "ViridianForest", + "to_point": "warp_2" }, { "x": 7, "y": 1, - "dest_map": "Route2", - "dest_warp": 0 + "enter": "cave_entrance", + "to_map": "Route2", + "to_point": "warp_0" } ], "objects": [ { + "name": "youngster", + "kind": "npc", "x": 5, - "y": 4, - "kind": "youngster", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 4 }, { + "name": "old_man_1", + "kind": "npc", "x": 4, - "y": 7, - "kind": "old_man_1", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 7 }, { + "name": "cooltrainer_f", + "kind": "npc", "x": 10, - "y": 5, - "kind": "cooltrainer_f", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 5 } ], - "connections": [], - "points": [], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_SouthEntrance.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_SouthEntrance.json index d36530577d..3b00abc4eb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_SouthEntrance.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route2_ViridianForest_SouthEntrance.json @@ -1,10 +1,13 @@ { "name": "Route2_ViridianForest_SouthEntrance", - "width": 15, - "height": 12, + "source": { + "decomp_file": "data/maps/Route2_ViridianForest_SouthEntrance/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "###############", - "#######C#######", + "#######.#######", "##...#...#...##", "#.............#", "#..........##.#", @@ -13,54 +16,63 @@ "#..........##.#", "###........##.#", "#.............#", - "#......v......#", + "#.............#", "###############" ], + "points": { + "warp_1": [7, 10], + "warp_3": [7, 1] + }, "warps": [ { "x": 6, "y": 10, - "dest_map": "Route2", - "dest_warp": 2 + "enter": "walk_into", + "to_map": "Route2", + "to_point": "warp_2" }, { "x": 7, "y": 10, - "dest_map": "Route2", - "dest_warp": 2 + "enter": "walk_south", + "to_map": "Route2", + "to_point": "warp_2" }, { "x": 8, "y": 10, - "dest_map": "Route2", - "dest_warp": 2 + "enter": "walk_into", + "to_map": "Route2", + "to_point": "warp_2" }, { "x": 7, "y": 1, - "dest_map": "ViridianForest", - "dest_warp": 0 + "enter": "cave_entrance", + "to_map": "ViridianForest", + "to_point": "warp_0" } ], "objects": [ { + "name": "woman_2", + "kind": "npc", "x": 10, - "y": 6, - "kind": "woman_2", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 6 }, { + "name": "woman_1", + "kind": "npc", "x": 4, "y": 7, - "kind": "woman_1", - "flag": "", - "wander_x": 1, - "wander_y": 1 + "wander": { + "x0": 3, + "y0": 6, + "x1": 5, + "y1": 8 + } } ], - "connections": [], - "points": [], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity.json index fb3714c07b..5bf976082a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity.json @@ -1,7 +1,10 @@ { "name": "ViridianCity", - "width": 48, - "height": 40, + "source": { + "decomp_file": "data/maps/ViridianCity/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "###################.....########################", "###################....S########################", @@ -15,7 +18,7 @@ "########.###########...######....######...######", "########.##########.....#####...S..#D#....######", "########.###########...##D###.............######", - "########.##########........##JJJJJJJJJJJJJ######", + "########.##########........##vvvvvvvvvvvvv######", "########.###########......................######", "########.##########.......................######", "######...###########.........###################", @@ -29,11 +32,11 @@ "###########.............#####.............######", "###########.##..........#####.............######", "#######.....##..........#####.............######", - "#######....~~~~~~.......SSD##.............######", - "#######....~~~~~~.........................######", - "#######....~~~~~~.........................######", - "#######....~~~~~~.........................######", - "#######JJJJ~~~~~~JJJ...JJJJJJJJJJJJJJJJJJJ######", + "#######....wwwwww.......SSD##.............######", + "#######....wwwwww.........................######", + "#######....wwwwww.........................######", + "#######....wwwwww.........................######", + "#######vvvvwwwwwwvvv...vvvvvvvvvvvvvvvvvvv######", "#######.............S.....................######", "#######...................................######", "#######...................................######", @@ -86,129 +89,128 @@ "000000000000000000000033330000000000000000000000", "000000000000000000000033330000000000000000000000" ], + "points": { + "warp_0": [26, 26], + "warp_4": [36, 19] + }, "warps": [ { "x": 26, "y": 26, - "dest_map": "ViridianCity_PokemonCenter_1F", - "dest_warp": 1 + "enter": "walk_into", + "to_map": "ViridianCity_PokemonCenter_1F", + "to_point": "warp_1" }, { "x": 25, "y": 11, - "dest_map": "", - "dest_warp": 1 + "enter": "walk_into" }, { "x": 36, "y": 10, - "dest_map": "", - "dest_warp": 1 + "enter": "walk_into" }, { "x": 25, "y": 18, - "dest_map": "", - "dest_warp": 1 + "enter": "walk_into" }, { "x": 36, "y": 19, - "dest_map": "ViridianCity_Mart", - "dest_warp": 1 + "enter": "walk_into", + "to_map": "ViridianCity_Mart", + "to_point": "warp_1" } ], "objects": [ { + "name": "fat_man", + "kind": "npc", "x": 8, - "y": 26, - "kind": "fat_man", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 26 }, { + "name": "cut_tree", + "kind": "npc", "x": 11, "y": 24, - "kind": "cut_tree", - "flag": "FLAG_TEMP_11", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_11" }, { + "name": "old_man_1", + "kind": "npc", "x": 34, - "y": 11, - "kind": "old_man_1", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 11 }, { + "name": "var_0", + "kind": "npc", "x": 21, - "y": 6, - "kind": "var_0", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 6 }, { + "name": "woman_3", + "kind": "npc", "x": 20, - "y": 12, - "kind": "woman_3", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 12 }, { + "name": "youngster", + "kind": "npc", "x": 33, "y": 26, - "kind": "youngster", - "flag": "", - "wander_x": 0, - "wander_y": 2 + "wander": { + "x0": 33, + "y0": 24, + "x1": 33, + "y1": 28 + } }, { + "name": "boy", + "kind": "npc", "x": 16, "y": 22, - "kind": "boy", - "flag": "", - "wander_x": 1, - "wander_y": 2 + "wander": { + "x0": 15, + "y0": 20, + "x1": 17, + "y1": 24 + } }, { + "name": "cut_tree", + "kind": "npc", "x": 18, "y": 5, - "kind": "cut_tree", - "flag": "FLAG_TEMP_12", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_TEMP_12" }, { + "name": "item_ball", + "kind": "item", "x": 17, "y": 5, - "kind": "item_ball", - "flag": "FLAG_HIDE_VIRIDIAN_CITY_POTION", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_VIRIDIAN_CITY_POTION" } ], + "flag_sets": {}, "connections": [ { - "direction": "north", - "offset": 12, - "map": "Route2" + "side": "north", + "to_map": "Route2", + "offset": 12 }, { - "direction": "south", - "offset": 12, - "map": "Route1" + "side": "south", + "to_map": "Route1", + "offset": 12 }, { - "direction": "west", - "offset": 10, - "map": "Route22" + "side": "west", + "to_map": "Route22", + "offset": 10 } - ], - "points": [], - "flag_sets": [] + ] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json index f4b1fa32fc..1078ec3405 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json @@ -1,7 +1,10 @@ { "name": "ViridianCity_Mart", - "width": 11, - "height": 9, + "source": { + "decomp_file": "data/maps/ViridianCity_Mart/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "###########", "###########", @@ -10,7 +13,7 @@ "####...##.#", ".......##.#", ".##....##.#", - "....v......", + "...........", "###########" ], "elevation": [ @@ -24,59 +27,65 @@ "33333333333", "00000000000" ], + "points": { + "clerk_front": [4, 3], + "warp_1": [4, 7] + }, "warps": [ { "x": 3, "y": 7, - "dest_map": "ViridianCity", - "dest_warp": 4 + "enter": "walk_into", + "to_map": "ViridianCity", + "to_point": "warp_4" }, { "x": 4, "y": 7, - "dest_map": "ViridianCity", - "dest_warp": 4 + "enter": "walk_south", + "to_map": "ViridianCity", + "to_point": "warp_4" }, { "x": 5, "y": 7, - "dest_map": "ViridianCity", - "dest_warp": 4 + "enter": "walk_into", + "to_map": "ViridianCity", + "to_point": "warp_4" } ], "objects": [ { + "name": "clerk", + "kind": "npc", "x": 2, - "y": 3, - "kind": "clerk", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 3 }, { + "name": "youngster", + "kind": "npc", "x": 6, "y": 2, - "kind": "youngster", - "flag": "", - "wander_x": 1, - "wander_y": 1 + "wander": { + "x0": 5, + "y0": 1, + "x1": 7, + "y1": 3 + } }, { + "name": "woman_1", + "kind": "npc", "x": 9, "y": 5, - "kind": "woman_1", - "flag": "", - "wander_x": 0, - "wander_y": 1 - } - ], - "connections": [], - "points": [ - { - "name": "clerk_front", - "x": 4, - "y": 3 + "wander": { + "x0": 9, + "y0": 4, + "x1": 9, + "y1": 6 + } } ], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_PokemonCenter_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_PokemonCenter_1F.json index 7bb1c5369c..63a2707d8f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_PokemonCenter_1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_PokemonCenter_1F.json @@ -1,7 +1,10 @@ { "name": "ViridianCity_PokemonCenter_1F", - "width": 15, - "height": 10, + "source": { + "decomp_file": "data/maps/ViridianCity_PokemonCenter_1F/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "#.#############", "###############", @@ -9,9 +12,9 @@ "....#######....", "...............", "...............", - "#L.........##..", + "#..........##..", "...........##..", - ".......v.......", + "...............", "###############" ], "elevation": [ @@ -26,73 +29,70 @@ "333333333333333", "000000000000000" ], + "points": { + "nurse_front": [7, 4], + "warp_1": [7, 8] + }, "warps": [ { "x": 6, "y": 8, - "dest_map": "ViridianCity", - "dest_warp": 0 + "enter": "walk_into", + "to_map": "ViridianCity", + "to_point": "warp_0" }, { "x": 7, "y": 8, - "dest_map": "ViridianCity", - "dest_warp": 0 + "enter": "walk_south", + "to_map": "ViridianCity", + "to_point": "warp_0" }, { "x": 8, "y": 8, - "dest_map": "ViridianCity", - "dest_warp": 0 + "enter": "walk_into", + "to_map": "ViridianCity", + "to_point": "warp_0" }, { "x": 1, "y": 6, - "dest_map": "", - "dest_warp": 0 + "enter": "step_on" } ], "objects": [ { + "name": "nurse", + "kind": "npc", "x": 7, - "y": 2, - "kind": "nurse", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 2 }, { + "name": "gentleman", + "kind": "npc", "x": 12, - "y": 5, - "kind": "gentleman", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 5 }, { + "name": "boy", + "kind": "npc", "x": 4, - "y": 7, - "kind": "boy", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 7 }, { + "name": "youngster", + "kind": "npc", "x": 2, "y": 3, - "kind": "youngster", - "flag": "", - "wander_x": 1, - "wander_y": 1 - } - ], - "connections": [], - "points": [ - { - "name": "nurse_front", - "x": 7, - "y": 4 + "wander": { + "x0": 1, + "y0": 2, + "x1": 3, + "y1": 4 + } } ], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json index 5d359b42a4..93352339c5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json @@ -1,7 +1,10 @@ { "name": "ViridianForest", - "width": 54, - "height": 69, + "source": { + "decomp_file": "data/maps/ViridianForest/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, "tiles": [ "######################################################", "######################################################", @@ -12,60 +15,60 @@ "###########.............###........................###", "###########.............###........................###", "#..#####..#.............###.....###############....###", - "####CCC####.............###.....###############....###", + "####...####.............###.....###############....###", "####...####.............###.....###############....###", "####...####.....###.....###.....###############....###", - "####..S####\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###############....###", - "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###############....###", - "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###############....###", - "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\".............###", - "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\".............###", - "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\".............###", - "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\".......#########", - "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"........#########", - "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"\"######......#########", - "###\"\"\"\"\"###\"\"\"\"\"###\"\"\"\"\"###...\"\"\"######......#########", - "###\"\"\"\"\"###\"\"\"\"\"###.....###......######......#########", - "###\"\"\"\"\"###\"\"\"\"\"###..............######......#########", - "###\"\"\"\"\"###\"\"\"\"\"#####............######......#########", - "###\"\"\"\"\"###\"\"\"\"\"#####............######............###", - "###\"\"\"\"\"###\"\"\"\"\"\"\"#####################....S.......###", - "###\"\"\"\"\"...\"\"\"\"\"\"\"#####################............###", + "####..S####~~~~~###~~~~~###~~~~~###############....###", + "###~~~~~###~~~~~###~~~~~###~~~~~###############....###", + "###~~~~~###~~~~~###~~~~~###~~~~~###############....###", + "###~~~~~###~~~~~###~~~~~###~~~~~~~~~~~.............###", + "###~~~~~###~~~~~###~~~~~###~~~~~~~~~~~.............###", + "###~~~~~###~~~~~###~~~~~###~~~~~~~~~~~.............###", + "###~~~~~###~~~~~###~~~~~###~~~~~~~~~~~.......#########", + "###~~~~~###~~~~~###~~~~~###~~~~~~~~~~........#########", + "###~~~~~###~~~~~###~~~~~###~~~~~~######......#########", + "###~~~~~###~~~~~###~~~~~###...~~~######......#########", + "###~~~~~###~~~~~###.....###......######......#########", + "###~~~~~###~~~~~###..............######......#########", + "###~~~~~###~~~~~#####............######......#########", + "###~~~~~###~~~~~#####............######............###", + "###~~~~~###~~~~~~~#####################....S.......###", + "###~~~~~...~~~~~~~#####################............###", "###...............#####################............###", - "###......S........#####################\"\"\"\"........###", - "###...............#####################\"\"\"\"\"###....###", - "###.....................###############\"\"\"\"\"###....###", - "###.....................###############\"\"\"\"\"###....###", - "###.....................###############\"\"\"\"\"###....###", - "##################......###############\"\"\"\"\"###....###", - "##################......###############\"\"\"\"\"###....###", - "#######################################\"\"\"\"\"###....###", - "#######################################\"\"\"\"\"###....###", - "#######################################\"\"\"\"\"###....###", - "###\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"#####################\"\"\"\"\"###....###", - "###\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"#####################\"\"\"\"\"###....###", - "###\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"#####################\"\"\"\"\"###....###", - "###\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"#####################\"\"\"\"\"###....###", - "###\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"######\"\"\"\"........###", - "############\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"S..\"\"######\"\"\".........###", - "############\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"...\"\"######\"\"\".........###", - "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", - "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", - "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", - "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", - "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", - "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", - "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", - "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", - "############..\"\"\"#########\"\"...\"\"######\"\"\"...#########", - "###\"\"\"\"\"\"\"\"\"..\"\"\"\"\"\"\"\"\"\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\"...\"\"\"\"\"\"###", - "###\"\"\"\"\"\"\"\"\"..\"\"\"\"\"\"\"\"\"\"\"\"\"\"###\"\"\"\"\"\"\"\"\"\"\"...\"\"\"\"\"\"###", - "###\"\"\"\"\"\"\"\"\"...\"\"\"\"\"\"\"\"\"\"\"\".###.\"\"\"\"\"\"\"\"\"...\"\"\"\"\"\"\"###", - "###\"\"\"\"\"\"\"\"\"....\"\"\"\"\"\"\"\"\"\".......\"\"\"\"\"\"\"....\"\"\"\"\"\"\"###", - "###\"\"\"\"\"\"\"\"............................S....\"\"\"\"\"\"\"###", - "###\"\"\"\"\"\"\"\"....................S...........\"\"\"\"\"\"\"\"###", - "###\"\"\"\"\"\"\"\"................................\"\"\"\"\"\"\"\"###", - "###########################.vvv..#####################", + "###......S........#####################~~~~........###", + "###...............#####################~~~~~###....###", + "###.....................###############~~~~~###....###", + "###.....................###############~~~~~###....###", + "###.....................###############~~~~~###....###", + "##################......###############~~~~~###....###", + "##################......###############~~~~~###....###", + "#######################################~~~~~###....###", + "#######################################~~~~~###....###", + "#######################################~~~~~###....###", + "###~~~~~~~~~~~~~~~#####################~~~~~###....###", + "###~~~~~~~~~~~~~~~#####################~~~~~###....###", + "###~~~~~~~~~~~~~~~#####################~~~~~###....###", + "###~~~~~~~~~~~~~~~#####################~~~~~###....###", + "###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~######~~~~........###", + "############~~~~~~~~~~~~~~~~S..~~######~~~.........###", + "############~~~~~~~~~~~~~~~~...~~######~~~.........###", + "############..~~~#########~~...~~######~~~...#########", + "############..~~~#########~~...~~######~~~...#########", + "############..~~~#########~~...~~######~~~...#########", + "############..~~~#########~~...~~######~~~...#########", + "############..~~~#########~~...~~######~~~...#########", + "############..~~~#########~~...~~######~~~...#########", + "############..~~~#########~~...~~######~~~...#########", + "############..~~~#########~~...~~######~~~...#########", + "############..~~~#########~~...~~######~~~...#########", + "###~~~~~~~~~..~~~~~~~~~~~~~~###~~~~~~~~~~~...~~~~~~###", + "###~~~~~~~~~..~~~~~~~~~~~~~~###~~~~~~~~~~~...~~~~~~###", + "###~~~~~~~~~...~~~~~~~~~~~~.###.~~~~~~~~~...~~~~~~~###", + "###~~~~~~~~~....~~~~~~~~~~.......~~~~~~~....~~~~~~~###", + "###~~~~~~~~............................S....~~~~~~~###", + "###~~~~~~~~....................S...........~~~~~~~~###", + "###~~~~~~~~................................~~~~~~~~###", + "###########################......#####################", "######################################################", "######################################################", "######################################################", @@ -73,135 +76,126 @@ "######################################################", "######################################################" ], + "points": { + "warp_0": [29, 62], + "warp_2": [5, 9] + }, "warps": [ { "x": 29, "y": 62, - "dest_map": "Route2_ViridianForest_SouthEntrance", - "dest_warp": 3 + "enter": "walk_south", + "to_map": "Route2_ViridianForest_SouthEntrance", + "to_point": "warp_3" }, { "x": 28, "y": 62, - "dest_map": "Route2_ViridianForest_SouthEntrance", - "dest_warp": 3 + "enter": "walk_south", + "to_map": "Route2_ViridianForest_SouthEntrance", + "to_point": "warp_3" }, { "x": 5, "y": 9, - "dest_map": "Route2_ViridianForest_NorthEntrance", - "dest_warp": 1 + "enter": "cave_entrance", + "to_map": "Route2_ViridianForest_NorthEntrance", + "to_point": "warp_1" }, { "x": 6, "y": 9, - "dest_map": "Route2_ViridianForest_NorthEntrance", - "dest_warp": 1 + "enter": "cave_entrance", + "to_map": "Route2_ViridianForest_NorthEntrance", + "to_point": "warp_1" }, { "x": 30, "y": 62, - "dest_map": "Route2_ViridianForest_SouthEntrance", - "dest_warp": 3 + "enter": "walk_south", + "to_map": "Route2_ViridianForest_SouthEntrance", + "to_point": "warp_3" }, { "x": 4, "y": 9, - "dest_map": "Route2_ViridianForest_NorthEntrance", - "dest_warp": 1 + "enter": "cave_entrance", + "to_map": "Route2_ViridianForest_NorthEntrance", + "to_point": "warp_1" } ], "objects": [ { + "name": "youngster", + "kind": "npc", "x": 29, - "y": 58, - "kind": "youngster", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 58 }, { + "name": "boy", + "kind": "npc", "x": 45, - "y": 58, - "kind": "boy", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 58 }, { + "name": "bug_catcher", + "kind": "npc", "x": 47, - "y": 45, - "kind": "bug_catcher", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 45 }, { + "name": "bug_catcher", + "kind": "npc", "x": 47, - "y": 29, - "kind": "bug_catcher", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 29 }, { + "name": "bug_catcher", + "kind": "npc", "x": 7, - "y": 22, - "kind": "bug_catcher", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 22 }, { + "name": "item_ball", + "kind": "item", "x": 5, "y": 41, - "kind": "item_ball", - "flag": "FLAG_HIDE_VIRIDIAN_FOREST_POKE_BALL", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_VIRIDIAN_FOREST_POKE_BALL" }, { + "name": "item_ball", + "kind": "item", "x": 40, "y": 21, - "kind": "item_ball", - "flag": "FLAG_HIDE_VIRIDIAN_FOREST_ANTIDOTE", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_VIRIDIAN_FOREST_ANTIDOTE" }, { + "name": "item_ball", + "kind": "item", "x": 21, "y": 34, - "kind": "item_ball", - "flag": "FLAG_HIDE_VIRIDIAN_FOREST_POTION", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_VIRIDIAN_FOREST_POTION" }, { + "name": "bug_catcher", + "kind": "npc", "x": 43, - "y": 6, - "kind": "bug_catcher", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 6 }, { + "name": "bug_catcher", + "kind": "npc", "x": 16, - "y": 5, - "kind": "bug_catcher", - "flag": "", - "wander_x": 0, - "wander_y": 0 + "y": 5 }, { + "name": "item_ball", + "kind": "item", "x": 49, "y": 60, - "kind": "item_ball", - "flag": "FLAG_HIDE_VIRIDIAN_FOREST_POTION_2", - "wander_x": 0, - "wander_y": 0 + "hide_flag": "FLAG_HIDE_VIRIDIAN_FOREST_POTION_2" } ], - "connections": [], - "points": [], - "flag_sets": [] + "flag_sets": {}, + "connections": [] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp index d838d5cb7b..5a61b137e1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp @@ -4,7 +4,6 @@ * */ -#include #include "Common/Cpp/Exceptions.h" #include "PokemonFRLG_OverworldMap.h" @@ -13,69 +12,56 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -std::optional tile_from_char(char c){ - switch (c){ - case '#': return Tile::WALL; - case 'J': return Tile::LEDGE; - case '.': return Tile::FLOOR; - case '"': return Tile::TALL_GRASS; - case '~': return Tile::WATER; - case 'D': return Tile::DOOR; - case 'S': return Tile::SIGN; - case 'C': return Tile::CAVE_ENTRANCE; - case 'L': return Tile::LADDER; - case '^': return Tile::MAT_NORTH; - case 'v': return Tile::MAT_SOUTH; - case '<': return Tile::MAT_WEST; - case '>': return Tile::MAT_EAST; - case 'n': return Tile::CLOSED_NORTH; - case 's': return Tile::CLOSED_SOUTH; - case 'e': return Tile::CLOSED_EAST; - case 'w': return Tile::CLOSED_WEST; - default: return std::nullopt; - } -} - - bool in_bounds(const MapData& map, const TilePos& point){ return map.tiles.contains(point); } -Tile tile_at(const MapData& map, const TilePos& point){ - return in_bounds(map, point) ? map.tiles.at(point) : Tile::WALL; +TileKind tile_at(const MapData& map, const TilePos& point){ + return in_bounds(map, point) ? map.tiles.at(point) : TileKind::WALL; } uint8_t elevation_at(const MapData& map, const TilePos& point){ - return map.elevation.contains(point) ? map.elevation.at(point) : ELEVATION_IGNORED; + if (!in_bounds(map, point)){ + return ELEVATION_IGNORED; + } + return map.elevation ? map.elevation->at(point) : ELEVATION_GROUND; } bool is_wall(const MapData& map, const TilePos& point){ - const Tile tile = tile_at(map, point); - return tile == Tile::WALL || tile == Tile::DOOR || tile == Tile::SIGN || tile == Tile::LEDGE; + const TileKind tile = tile_at(map, point); + return tile == TileKind::WALL || tile == TileKind::DOOR || tile == TileKind::SIGN || is_ledge(map, point); } bool is_ledge(const MapData& map, const TilePos& point){ - return tile_at(map, point) == Tile::LEDGE; + switch (tile_at(map, point)){ + case TileKind::LEDGE_NORTH: + case TileKind::LEDGE_SOUTH: + case TileKind::LEDGE_WEST: + case TileKind::LEDGE_EAST: + return true; + default: + return false; + } } bool is_water(const MapData& map, const TilePos& point){ - return tile_at(map, point) == Tile::WATER; + return tile_at(map, point) == TileKind::WATER; } bool is_tall_grass(const MapData& map, const TilePos& point){ - return tile_at(map, point) == Tile::TALL_GRASS; + return tile_at(map, point) == TileKind::TALL_GRASS; } namespace{ // The tile closed on its `side` edge. -Tile closed_side(Direction side){ +TileKind closed_side(Direction side){ switch (side){ case Direction::NORTH: - return Tile::CLOSED_NORTH; + return TileKind::CLOSED_NORTH; case Direction::SOUTH: - return Tile::CLOSED_SOUTH; + return TileKind::CLOSED_SOUTH; case Direction::EAST: - return Tile::CLOSED_EAST; + return TileKind::CLOSED_EAST; case Direction::WEST: - return Tile::CLOSED_WEST; + return TileKind::CLOSED_WEST; } - return Tile::WALL; + return TileKind::WALL; } Direction opposite(Direction direction){ switch (direction){ @@ -91,6 +77,15 @@ Direction opposite(Direction direction){ return direction; } +// How the warp on this tile is entered, if there is one. +std::optional warp_entry(const MapData& map, const TilePos& point){ + const MapWarp* warp = warp_at(map, point); + if (warp == nullptr){ + return std::nullopt; + } + return warp->enter; +} + } bool blocks_entering(const MapData& map, const TilePos& point, Direction direction){ @@ -102,35 +97,38 @@ bool blocks_leaving(const MapData& map, const TilePos& point, Direction directio } bool warps_on_step(const MapData& map, const TilePos& point){ - const Tile tile = tile_at(map, point); - return tile == Tile::CAVE_ENTRANCE || tile == Tile::LADDER; + const std::optional entry = warp_entry(map, point); + return entry == WarpEntry::STEP_ON || entry == WarpEntry::CAVE_ENTRANCE; } bool is_door(const MapData& map, const TilePos& point){ - return tile_at(map, point) == Tile::DOOR; + return tile_at(map, point) == TileKind::DOOR; } std::optional exit_mat(const MapData& map, const TilePos& point){ - switch (tile_at(map, point)){ - case Tile::MAT_NORTH: + const std::optional entry = warp_entry(map, point); + if (!entry){ + return std::nullopt; + } + switch (*entry){ + case WarpEntry::WALK_NORTH: return Direction::NORTH; - case Tile::MAT_SOUTH: + case WarpEntry::WALK_SOUTH: return Direction::SOUTH; - case Tile::MAT_WEST: + case WarpEntry::WALK_WEST: return Direction::WEST; - case Tile::MAT_EAST: + case WarpEntry::WALK_EAST: return Direction::EAST; default: return std::nullopt; } } bool walks_out_on_arrival(const MapData& map, const TilePos& point){ - const Tile tile = tile_at(map, point); - return tile == Tile::DOOR || tile == Tile::CAVE_ENTRANCE; + return is_door(map, point) || warp_entry(map, point) == WarpEntry::CAVE_ENTRANCE; } void hide_objects(MapData& map, const std::set& flags){ std::vector shown; for (const MapObject& object : map.objects){ - if (object.flag.empty() || flags.count(object.flag) == 0){ + if (!object.hide_flag || flags.count(*object.hide_flag) == 0){ shown.push_back(object); } } @@ -139,20 +137,15 @@ void hide_objects(MapData& map, const std::set& flags){ const MapObject* object_at(const MapData& map, const TilePos& point){ for (const MapObject& object : map.objects){ - if (std::abs(object.x - point.x) <= object.wander_x && std::abs(object.y - point.y) <= object.wander_y){ + const Pokemon::TileBox box = object.wander.value_or( + Pokemon::TileBox{.x0 = object.x, .y0 = object.y, .x1 = object.x, .y1 = object.y} + ); + if (box.x0 <= point.x && point.x <= box.x1 && box.y0 <= point.y && point.y <= box.y1){ return &object; } } return nullptr; } -const MapWarp* warp_at(const MapData& map, const TilePos& point){ - for (const MapWarp& warp : map.warps){ - if (warp.x == point.x && warp.y == point.y){ - return &warp; - } - } - return nullptr; -} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h index 804b838a2f..34a0859ee2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h @@ -2,12 +2,13 @@ * * From: https://github.com/PokemonAutomation/ * - * An FRLG map as the game sees it: per tile collision, elevation and the - * behaviors that matter for walking (water, one-way edges), plus its warps - * and the objects standing on it. The map data is generated from the - * pret/pokefirered decompilation, and classify_step() follows the game's own - * collision checks (GetCollisionAtCoords() in src/event_object_movement.c), - * so a route planned on these maps is one the game allows. + * FRLG's walking rules on a map (a Pokemon::MapData): per tile collision, + * elevation and the behaviors that matter for walking (water, one-way + * edges), plus its warps and the objects standing on it. The map data is + * generated from the pret/pokefirered decompilation, and classify_step() + * follows the game's own collision checks (GetCollisionAtCoords() in + * src/event_object_movement.c), so a route planned on these maps is one the + * game allows. * */ @@ -15,12 +16,11 @@ #define PokemonAutomation_PokemonFRLG_OverworldMap_H #include -#include #include #include #include -#include #include "Pokemon/Navigation/Pokemon_Grid.h" +#include "Pokemon/Navigation/Pokemon_MapData.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -29,41 +29,15 @@ namespace PokemonFRLG{ using Pokemon::Direction; using Pokemon::TilePos; +using Pokemon::TileKind; +using Pokemon::MapData; +using Pokemon::MapWarp; +using Pokemon::MapObject; +using Pokemon::MapConnection; +using Pokemon::WarpEntry; +using Pokemon::warp_at; -// A warp from (x, y) to warp `dest_warp` of `dest_map`. Whether and how the -// player takes it depends on the tile there (see Tile). An empty -// `dest_map` leads to a map that isn't loaded. -struct MapWarp{ - int x = 0; - int y = 0; - std::string dest_map; - int dest_warp = 0; -}; - -// An object standing on a tile (person, item ball, rock, Pokemon), which -// blocks it. `kind` is its graphics, e.g. "nurse" or "mewtwo". The game -// hides it once its event flag is set, e.g. a guard who leaves after the -// Hall of Fame; an empty flag means it is always there. A person who wanders -// may stand anywhere up to `wander_x` and `wander_y` tiles from (x, y), so -// all of those tiles count as blocked. -struct MapObject{ - int x = 0; - int y = 0; - std::string kind; - std::string flag; - int wander_x = 0; - int wander_y = 0; -}; - -// Walking off the map's `direction` edge continues on `map`, whose tiles are -// shifted by `offset` along that edge (the decompilation's map connections). -struct MapConnection{ - Direction direction = Direction::NORTH; - int offset = 0; - std::string map; -}; - // Elevations with a meaning of their own in the game's rules // (IsElevationMismatchAt() and ObjectEventUpdateElevation() in // pokefirered). @@ -77,78 +51,23 @@ constexpr uint8_t ELEVATION_IGNORED = 15; constexpr uint8_t ELEVATION_GROUND = 3; -// What a tile is, for walking. The map files write each as one character, -// shown here. -enum class Tile : uint8_t{ - WALL, // '#' collision (wall, cliff) - LEDGE, // 'J' a wall, except that walking into it the way it - // faces hops the player down (not modelled, so the - // planner avoids it) - FLOOR, // '.' - TALL_GRASS, // '"' floor with wild encounters - WATER, // '~' entered only by starting to Surf - DOOR, // 'D' a wall that warps the player who walks north into it - SIGN, // 'S' a wall that shows its message to the player who - // walks into it moving north or south (signposts, - // Center and Mart signs; pokefirered - // TrySetUpWalkIntoSignpostScript()) - CAVE_ENTRANCE, // 'C' floor that warps the player who steps onto it - LADDER, // 'L' ladder or escalator: floor that warps the player - // who steps onto it - MAT_NORTH, // '^' exit mat, or stairs at the side of a room: floor - MAT_SOUTH, // 'v' that warps the player standing on it who walks - // in the arrow's direction - MAT_WEST, // '<' - MAT_EAST, // '>' - CLOSED_NORTH, // 'n' can't be entered moving south or left moving north - CLOSED_SOUTH, // 's' can't be entered moving north or left moving south - CLOSED_EAST, // 'e' can't be entered moving west or left moving east - CLOSED_WEST, // 'w' can't be entered moving east or left moving west -}; - -// The tile a map file's character stands for, or nothing if it isn't one. -std::optional tile_from_char(char c); - - -// One value per tile of a map, row by row from the top. -template -struct Grid{ - int width = 0; - int height = 0; - std::vector cells; - - bool contains(const TilePos& point) const{ - return 0 <= point.x && point.x < width && 0 <= point.y && point.y < height; - } - // `point` must be inside the grid. - const Cell& at(const TilePos& point) const{ - return cells[(size_t)point.y * width + point.x]; - } -}; - - -// A map as generated from the decompilation (see PokemonFRLG_OverworldMaps.h -// for its JSON form). -struct MapData{ - std::string name; - Grid tiles; - // Walking keeps to one elevation; tiles of elevation 0 (stairs, - // ladders) join elevations, and 15 ignores them. The same size as - // `tiles`. - Grid elevation; - std::vector warps; - std::vector objects; - std::vector connections; - // Places on the map that routes start or end at, by name, e.g. "pc". - std::map points; - // Event flags that are set together, by name, e.g. - // "after_hall_of_fame". - std::map> flag_sets; -}; +// How FRLG reads a map's tiles (Pokemon::TileKind) and warps: +// - WALL, DOOR, SIGN and the ledges are walls. A DOOR warps the player who +// walks north into it; a SIGN shows its message to the player who walks +// into it moving north or south (signposts, Center and Mart signs; +// pokefirered TrySetUpWalkIntoSignpostScript()). Ledges are hopped the +// way they face, which isn't modelled, so the planner avoids them. +// - WATER is entered only by starting to Surf. +// - CLOSED_ can't be entered or left through that side. +// - A warp entered by step_on (ladders, escalators) or cave_entrance warps +// the player who steps onto its tile; walk_ (exit mats, stairs +// at the side of a room) warps the player standing on it who walks that +// way. +// A map without an elevation grid is all ground. bool in_bounds(const MapData& map, const TilePos& point); // Out-of-bounds tiles are walls. -Tile tile_at(const MapData& map, const TilePos& point); +TileKind tile_at(const MapData& map, const TilePos& point); uint8_t elevation_at(const MapData& map, const TilePos& point); bool is_wall(const MapData& map, const TilePos& point); @@ -160,7 +79,8 @@ bool is_ledge(const MapData& map, const TilePos& point); bool blocks_entering(const MapData& map, const TilePos& point, Direction direction); bool blocks_leaving(const MapData& map, const TilePos& point, Direction direction); -// The warp the game takes on stepping onto this tile (CAVE_ENTRANCE, LADDER). +// Whether the game takes this tile's warp on stepping onto it (a ladder or +// cave entrance). bool warps_on_step(const MapData& map, const TilePos& point); // A door, entered by walking north into it. bool is_door(const MapData& map, const TilePos& point); @@ -170,8 +90,8 @@ std::optional exit_mat(const MapData& map, const TilePos& point); // tile south, out of it. bool walks_out_on_arrival(const MapData& map, const TilePos& point); +// The object standing, or maybe wandering, on this tile. const MapObject* object_at(const MapData& map, const TilePos& point); -const MapWarp* warp_at(const MapData& map, const TilePos& point); // Removes the objects the game hides once one of `flags` is set. void hide_objects(MapData& map, const std::set& flags); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp index af15091f25..0f7514fe28 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp @@ -5,10 +5,7 @@ */ #include -#include #include "Common/Cpp/Exceptions.h" -#include "Common/Cpp/Json/JsonArray.h" -#include "Common/Cpp/Json/JsonObject.h" #include "Common/Cpp/Json/JsonValue.h" #include "PokemonFRLG_OverworldMaps.h" @@ -50,192 +47,6 @@ const char* const MAP_NAMES[] = { }; -// The readers below take `where`, the source and the path to the object -// being read (e.g. "Maps/CeruleanCity.json: warps[2]."), and -// name the field in what they throw. - -const JsonObject& as_object(const JsonValue& value, const std::string& where){ - const JsonObject* object = value.to_object(); - if (object == nullptr){ - throw ParseException(where + " is not a JSON object."); - } - return *object; -} - -const JsonValue& read_field(const JsonObject& object, const std::string& key, const std::string& where){ - const JsonValue* value = object.get_value(key); - if (value == nullptr){ - throw ParseException(where + key + " is missing."); - } - return *value; -} - -int read_int(const JsonObject& object, const std::string& key, const std::string& where){ - const JsonValue& value = read_field(object, key, where); - if (!value.is_integer()){ - throw ParseException(where + key + " is not an integer."); - } - return (int)value.to_integer_default(); -} - -std::string read_string(const JsonObject& object, const std::string& key, const std::string& where){ - const std::string* text = read_field(object, key, where).to_string(); - if (text == nullptr){ - throw ParseException(where + key + " is not a string."); - } - return *text; -} - -const JsonArray& read_array(const JsonObject& object, const std::string& key, const std::string& where){ - const JsonArray* array = read_field(object, key, where).to_array(); - if (array == nullptr){ - throw ParseException(where + key + " is not an array."); - } - return *array; -} - -// The grid `key`: `height` strings of `width` characters, each read by -// `read_cell`, which gives nothing for a character it doesn't know. -template -Grid read_grid( - const JsonObject& object, const std::string& key, const std::string& where, - int width, int height, std::optional (*read_cell)(char c) -){ - const JsonArray& rows = read_array(object, key, where); - if ((int)rows.size() != height){ - throw ParseException(std::format("{}{} has {} rows, not {}.", where, key, rows.size(), height)); - } - Grid grid{width, height, {}}; - for (int y = 0; y < height; y++){ - const std::string row_where = std::format("{}{}[{}]", where, key, y); - const std::string* row = rows[y].to_string(); - if (row == nullptr || (int)row->size() != width){ - throw ParseException(std::format("{} is not a string of {} tiles.", row_where, width)); - } - for (int x = 0; x < width; x++){ - const std::optional cell = read_cell((*row)[x]); - if (!cell){ - throw ParseException( - row_where + " has unknown tile '" + std::string(1, (*row)[x]) + "' at " + to_string(TilePos{x, y}) + "." - ); - } - grid.cells.push_back(*cell); - } - } - return grid; -} - -// An elevation digit's level. -std::optional elevation_from_char(char digit){ - if ('0' <= digit && digit <= '9'){ - return (uint8_t)(digit - '0'); - } - if ('a' <= digit && digit <= 'f'){ - return (uint8_t)(digit - 'a' + 10); - } - return std::nullopt; -} - -MapWarp read_warp(const JsonObject& object, const std::string& where){ - MapWarp warp; - warp.x = read_int(object, "x", where); - warp.y = read_int(object, "y", where); - warp.dest_map = read_string(object, "dest_map", where); - warp.dest_warp = read_int(object, "dest_warp", where); - return warp; -} - -MapObject read_map_object(const JsonObject& object, const std::string& where){ - MapObject map_object; - map_object.x = read_int(object, "x", where); - map_object.y = read_int(object, "y", where); - map_object.kind = read_string(object, "kind", where); - map_object.flag = read_string(object, "flag", where); - map_object.wander_x = read_int(object, "wander_x", where); - map_object.wander_y = read_int(object, "wander_y", where); - return map_object; -} - -MapConnection read_connection(const JsonObject& object, const std::string& where){ - MapConnection connection; - const std::string direction = read_string(object, "direction", where); - bool known = false; - for (Direction candidate : Pokemon::ALL_DIRECTIONS){ - if (direction == Pokemon::direction_name(candidate)){ - connection.direction = candidate; - known = true; - } - } - if (!known){ - throw ParseException(where + "direction \"" + direction + "\" is not north, east, south or west."); - } - connection.offset = read_int(object, "offset", where); - connection.map = read_string(object, "map", where); - return connection; -} - -std::pair read_point(const JsonObject& object, const std::string& where){ - const std::string name = read_string(object, "name", where); - return {name, TilePos{read_int(object, "x", where), read_int(object, "y", where)}}; -} - -std::pair> read_flag_set(const JsonObject& object, const std::string& where){ - const std::string name = read_string(object, "name", where); - std::set flags; - // Named, since GCC warns of a reference returned for a temporary key. - const std::string key = "flags"; - const JsonArray& array = read_array(object, key, where); - for (size_t c = 0; c < array.size(); c++){ - const std::string* flag = array[c].to_string(); - if (flag == nullptr){ - throw ParseException(std::format("{}{}[{}] is not a string.", where, key, c)); - } - flags.insert(*flag); - } - return {name, std::move(flags)}; -} - -template -std::vector read_list( - const JsonObject& object, const std::string& key, const std::string& where, - Item (*read_item)(const JsonObject& object, const std::string& where) -){ - std::vector items; - const JsonArray& array = read_array(object, key, where); - for (size_t c = 0; c < array.size(); c++){ - const std::string item_where = std::format("{}{}[{}]", where, key, c); - items.push_back(read_item(as_object(array[c], item_where), item_where + ".")); - } - return items; -} - -MapData read_map(const JsonValue& json, const std::string& source){ - const JsonObject& root = as_object(json, source); - const std::string where = source + ": "; - MapData map; - map.name = read_string(root, "name", where); - const int width = read_int(root, "width", where); - const int height = read_int(root, "height", where); - if (width <= 0 || height <= 0){ - throw ParseException(where + "width and height must be positive."); - } - map.tiles = read_grid(root, "tiles", where, width, height, tile_from_char); - // Left out of maps where every tile the player can stand on is ground. - map.elevation = root.get_value("elevation") == nullptr - ? Grid{width, height, std::vector((size_t)width * height, ELEVATION_GROUND)} - : read_grid(root, "elevation", where, width, height, elevation_from_char); - map.warps = read_list(root, "warps", where, read_warp); - map.objects = read_list(root, "objects", where, read_map_object); - map.connections = read_list(root, "connections", where, read_connection); - for (auto& point : read_list>(root, "points", where, read_point)){ - map.points.insert(std::move(point)); - } - for (auto& flag_set : read_list>>(root, "flag_sets", where, read_flag_set)){ - map.flag_sets.insert(std::move(flag_set)); - } - return map; -} - const std::vector& all_maps(){ static const std::vector MAPS = []{ std::vector maps; @@ -251,7 +62,7 @@ const std::vector& all_maps(){ MapData parse_map(const std::string& json, const std::string& source){ - return read_map(parse_json(json), source); + return Pokemon::parse_map(parse_json(json), source); } MapData load_map(const std::string& name){ @@ -261,7 +72,7 @@ MapData load_map(const std::string& name){ if (file == files.end()){ throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, source + " is not built into the program."); } - MapData map = read_map(parse_json(file->second), source); + MapData map = parse_map(file->second, source); if (map.name != name){ throw ParseException(source + ": name is \"" + map.name + "\", not \"" + name + "\"."); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h index 1a7930d1f1..cff0668eb5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h @@ -11,20 +11,9 @@ * Each map is a JSON file, Maps/.json next to this file, generated by * devtools/maps/frlg_maps.py and built into the program by CMake * (pa_embed_text_files() in cmake/EmbedTextFiles.cmake), so the program and - * its tests read the same copy. The schema is MapData's: - * - * { - * "name": "CeruleanCity", "width": 48, "height": 40, - * "tiles": ["####~~~...", ...], // `height` rows of `width` tiles - * "elevation": ["0033333...", ...], // the same, one hex digit per tile; - * // left out if all ground (3) - * "warps": [{"x": 22, "y": 19, "dest_map": "...", "dest_warp": 1}, ...], - * "objects": [{"x": 1, "y": 13, "kind": "cooltrainer_m", - * "flag": "FLAG_...", "wander_x": 0, "wander_y": 0}, ...], - * "connections": [{"direction": "north", "offset": 12, "map": "Route24"}, ...], - * "points": [{"name": "pc", "x": 11, "y": 2}, ...], - * "flag_sets": [{"name": "after_hall_of_fame", "flags": ["FLAG_...", ...]}, ...] - * } + * its tests read the same copy. The schema is Pokemon::MapData's + * (Pokemon/Navigation/Pokemon_MapData.h). A warp leads to point + * "warp_" of its map, the tile of that map's warp n. * */ @@ -43,9 +32,9 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -// Reads a map from its JSON text. `source` names it in errors. Throws -// ParseException, naming the map and the field, if a field is missing or -// doesn't fit the schema. +// Reads a map from its JSON text (Pokemon::parse_map()). `source` names it +// in errors. Throws ParseException, naming the map and the field, if a field +// is missing or doesn't fit the schema. MapData parse_map(const std::string& json, const std::string& source); // (name, JSON text) of each file in Maps/, sorted by name. Generated at diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp index 7945ca8683..4a8135b5f0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp @@ -72,22 +72,23 @@ bool mentions(const std::string& text, std::initializer_list parts) UnitTestResult test_valid_map(){ const MapData map = parse_map(VALID_MAP, "Test.json"); if (map.name != "Test" || map.tiles.width != 3 || map.tiles.height != 2 - || map.tiles.at({0, 1}) != Tile::TALL_GRASS || map.tiles.at({2, 1}) != Tile::MAT_SOUTH + || map.tiles.at({0, 1}) != TileKind::TALL_GRASS || exit_mat(map, {2, 1}) != Direction::SOUTH ){ return "Wrong name, size or tiles."; } if (elevation_at(map, {2, 0}) != 1 || elevation_at(map, {1, 1}) != 15){ return "Wrong elevation."; } - if (map.warps.size() != 1 || map.warps[0].dest_map != "Other" || map.warps[0].dest_warp != 2){ + const MapWarp* door = warp_at(map, {1, 1}); + if (map.warps.size() != 2 || door == nullptr || !door->to || door->to->map != "Other" || door->to->point != "warp_2"){ return "Wrong warps."; } const MapObject* nurse = object_at(map, {1, 1}); - if (map.objects.size() != 1 || nurse == nullptr || nurse->kind != "nurse" || nurse->flag != "FLAG_X"){ + if (map.objects.size() != 1 || nurse == nullptr || nurse->name != "nurse" || nurse->hide_flag != "FLAG_X"){ return "Wrong objects."; } const MapConnection& connection = map.connections.at(0); - if (connection.direction != Direction::SOUTH || connection.offset != -4 || connection.map != "Other"){ + if (connection.side != Direction::SOUTH || connection.offset != -4 || connection.to_map != "Other"){ return "Wrong connections."; } if (map.points.at("door") != TilePos{1, 1} || map.flag_sets.at("later") != std::set{"FLAG_X", "FLAG_Y"}){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp index d598e108f8..6d49f4cbfd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp @@ -111,16 +111,19 @@ struct Transition{ // The player taking `warp`, or nothing if it leads off the loaded maps. std::optional take_warp(const std::vector& maps, const MapWarp* warp){ - if (warp == nullptr){ + if (warp == nullptr || !warp->to){ return std::nullopt; } - const int destination = find_map(maps, warp->dest_map); - if (destination < 0 || warp->dest_warp < 0 || warp->dest_warp >= (int)maps[destination].warps.size()){ + const int destination = find_map(maps, warp->to->map); + if (destination < 0){ return std::nullopt; } const MapData& map = maps[destination]; - const MapWarp& arrival = map.warps[warp->dest_warp]; - TilePos position{arrival.x, arrival.y}; + const auto arrival = map.points.find(warp->to->point); + if (arrival == map.points.end()){ + return std::nullopt; + } + TilePos position = arrival->second; Transition transition; if (walks_out_on_arrival(map, position)){ position = position.next(Direction::SOUTH); @@ -136,10 +139,10 @@ std::optional take_warp(const std::vector& maps, const MapW std::optional cross_edge(const std::vector& maps, const Located& player, Direction direction){ const MapData& map = maps[player.map]; for (const MapConnection& connection : map.connections){ - if (connection.direction != direction){ + if (connection.side != direction){ continue; } - const int destination = find_map(maps, connection.map); + const int destination = find_map(maps, connection.to_map); if (destination < 0){ return std::nullopt; } @@ -223,13 +226,13 @@ bool stops_at(const std::vector& maps, const Located& player, Direction // Held into a sign moving north or south, the game shows the sign's // message: the player stops, but the walk is interrupted (console B, // 2026-11-01, the poster on the bedroom's wall). - if (tile_at(map, ahead) == Tile::SIGN && (direction == Direction::NORTH || direction == Direction::SOUTH)){ + if (tile_at(map, ahead) == TileKind::SIGN && (direction == Direction::NORTH || direction == Direction::SOUTH)){ return false; } // Held into a ledge the way it faces, the player hops down it (console // B, 2026-11-01, Viridian City: "south 2 (to wall)" from the Pokemon - // Center hopped the ledge two rows down). The maps don't keep which way - // a ledge faces, so none is held into. + // Center hopped the ledge two rows down). Routes don't hop ledges, so + // none is held into. if (is_ledge(map, ahead)){ return false; } @@ -237,7 +240,7 @@ bool stops_at(const std::vector& maps, const Located& player, Direction return object_at(map, ahead) == nullptr; } for (const MapConnection& connection : map.connections){ - if (connection.direction == direction){ + if (connection.side == direction){ return false; } } @@ -509,7 +512,7 @@ UnitTestResult test_maps(){ } const TilePos mewtwo_tile = map_point(maps, "CeruleanCave_B1F", "mewtwo"); const MapObject* mewtwo = object_at(*b1f, mewtwo_tile); - if (mewtwo == nullptr || mewtwo->kind != "mewtwo"){ + if (mewtwo == nullptr || mewtwo->name != "mewtwo"){ return "Mewtwo is not on B1F at " + to_string(mewtwo_tile) + "."; } if (object_at(*city, {1, 13}) != nullptr){ diff --git a/devtools/maps/frlg_maps.py b/devtools/maps/frlg_maps.py index 9e6ab7e62f..3a4ef4a25a 100644 --- a/devtools/maps/frlg_maps.py +++ b/devtools/maps/frlg_maps.py @@ -11,10 +11,11 @@ Downloads each map's data/maps//map.json, its layout's map.bin and its tilesets' metatile_attributes.bin at --commit into --cache, then writes -/.json in the schema given in PokemonFRLG_OverworldMaps.h. -Warps and connections lead only to maps in the same run: others get an empty -dest_map, or are left out. Named points and flag sets come from POINTS and -FLAG_SETS below. +/.json in the schema of Pokemon::MapData (Pokemon_MapData.h). +Warps and connections lead only to maps in the same run: a warp to another map +has no destination, and a connection to one is left out. A warp arrives at +point "warp_" of its map, the tile of that map's warp n. Other named points +and flag sets come from POINTS and FLAG_SETS below. Without map names, the maps are the ones already in --out. --check writes nothing: it regenerates them and fails if any file differs. The program @@ -30,20 +31,28 @@ import sys COMMIT = 'ce6406d8c2eaf46d543c8a2606de0c3cb1951982' +# When COMMIT was pinned, for each map's "source". +COMMIT_DATE = '2026-10-31' -# Behaviors with their own tile character; see the README for the legend. +# Behaviors with a glyph of their own (Pokemon_MapData.h has the legend). TERRAIN = { - 'MB_TALL_GRASS': '"', 'MB_WARP_DOOR': 'D', 'MB_CAVE_DOOR': 'C', - 'MB_LADDER': 'L', 'MB_UP_ESCALATOR': 'L', 'MB_DOWN_ESCALATOR': 'L', - 'MB_SOUTH_ARROW_WARP': 'v', 'MB_NORTH_ARROW_WARP': '^', - 'MB_EAST_ARROW_WARP': '>', 'MB_WEST_ARROW_WARP': '<', + 'MB_TALL_GRASS': '~', 'MB_WARP_DOOR': 'D', + 'MB_IMPASSABLE_NORTH': '8', 'MB_IMPASSABLE_SOUTH': '2', + 'MB_IMPASSABLE_EAST': '6', 'MB_IMPASSABLE_WEST': '4', +} +# Open tiles whose warp is taken other than by walking into it: how. +WARP_ENTRIES = { + 'MB_CAVE_DOOR': 'cave_entrance', + 'MB_LADDER': 'step_on', 'MB_UP_ESCALATOR': 'step_on', 'MB_DOWN_ESCALATOR': 'step_on', + 'MB_SOUTH_ARROW_WARP': 'walk_south', 'MB_NORTH_ARROW_WARP': 'walk_north', + 'MB_EAST_ARROW_WARP': 'walk_east', 'MB_WEST_ARROW_WARP': 'walk_west', # Stairs at the side of a room warp like an exit mat, the way the stairs # go up or down (IsDirectionalStairWarpMetatileBehavior()). - 'MB_UP_RIGHT_STAIR_WARP': '>', 'MB_DOWN_RIGHT_STAIR_WARP': '>', - 'MB_UP_LEFT_STAIR_WARP': '<', 'MB_DOWN_LEFT_STAIR_WARP': '<', - 'MB_IMPASSABLE_NORTH': 'n', 'MB_IMPASSABLE_SOUTH': 's', - 'MB_IMPASSABLE_EAST': 'e', 'MB_IMPASSABLE_WEST': 'w', + 'MB_UP_RIGHT_STAIR_WARP': 'walk_east', 'MB_DOWN_RIGHT_STAIR_WARP': 'walk_east', + 'MB_UP_LEFT_STAIR_WARP': 'walk_west', 'MB_DOWN_LEFT_STAIR_WARP': 'walk_west', } +# Ledges, by the way the player hops over them. +LEDGES = {'MB_JUMP_NORTH': '^', 'MB_JUMP_SOUTH': 'v', 'MB_JUMP_WEST': '<', 'MB_JUMP_EAST': '>'} FLOOR = ('MB_NORMAL', 'MB_CAVE', 'MB_ROCK_STAIRS', 'MB_TALL_GRASS') DIRECTIONS = {'up': 'north', 'down': 'south', 'left': 'west', 'right': 'east'} @@ -117,30 +126,36 @@ def tileset_attributes(decomp, symbol, kind): SIGN_BEHAVIORS = ('MB_POKEMON_CENTER_SIGN', 'MB_POKEMART_SIGN', 'MB_INDIGO_PLATEAU_SIGN_1', 'MB_INDIGO_PLATEAU_SIGN_2') -def tile_character(behavior, collision, unhandled, sign_event=False): +def tile_glyph(behavior, collision, unhandled, sign_event=False): + """The tile's glyph, and how its warp (if it has one) is entered: None for + walking into it, the default.""" if behavior in SIGN_BEHAVIORS or (behavior == 'MB_SIGNPOST' and sign_event): - return 'S' + return 'S', None if behavior == 'MB_WARP_DOOR': - return 'D' # doors have collision - if behavior.startswith('MB_JUMP_'): - return 'J' # ledges: hopped down, never stopped at + return 'D', None # doors have collision + if behavior in LEDGES: + return LEDGES[behavior], None if collision: - return '#' + return '#', None + if behavior in WARP_ENTRIES: + return '.', WARP_ENTRIES[behavior] if behavior in TERRAIN: - return TERRAIN[behavior] + return TERRAIN[behavior], None if 'WATER' in behavior: - return '~' + return 'w', None if behavior not in FLOOR: unhandled[behavior] = unhandled.get(behavior, 0) + 1 - return '.' + return '.', None def grid(decomp, layout, names, unhandled, signs=frozenset()): + """The map's tile rows, elevation rows, and how the warp on each tile is + entered, by (x, y), where it isn't by walking into it.""" width, height = layout['width'], layout['height'] blocks = decomp.read(layout['blockdata_filepath']) primary = tileset_attributes(decomp, layout['primary_tileset'], 'primary') secondary = tileset_attributes(decomp, layout['secondary_tileset'], 'secondary') - tiles, elevation = [], [] + tiles, elevation, entries = [], [], {} for y in range(height): row, levels = '', '' for x in range(width): @@ -148,25 +163,47 @@ def grid(decomp, layout, names, unhandled, signs=frozenset()): metatile, collision, level = value & 0x3ff, (value >> 10) & 3, value >> 12 attributes = primary[metatile] if metatile < 640 else secondary[metatile - 640] behavior = names.get(attributes & 0x1ff, hex(attributes & 0x1ff)) - row += tile_character(behavior, collision, unhandled, (x, y) in signs) + glyph, entry = tile_glyph(behavior, collision, unhandled, (x, y) in signs) + row += glyph + if entry: + entries[(x, y)] = entry levels += '%x' % level tiles.append(row) elevation.append(levels) - return width, height, tiles, elevation + return tiles, elevation, entries -def wander(obj): +def wander_box(obj, tiles): + """The tiles a wandering person may stand on, kept inside the map, or None + if they stand still.""" movement = obj.get('movement_type', '') if 'WANDER' not in movement: - return 0, 0 + return None x = 0 if 'UP_AND_DOWN' in movement else int(obj.get('movement_range_x') or 0) y = 0 if 'LEFT_AND_RIGHT' in movement else int(obj.get('movement_range_y') or 0) - return x, y + if x == 0 and y == 0: + return None + return { + 'x0': max(obj['x'] - x, 0), 'y0': max(obj['y'] - y, 0), + 'x1': min(obj['x'] + x, len(tiles[0]) - 1), 'y1': min(obj['y'] + y, len(tiles) - 1), + } + + +def map_object(obj, tiles): + kind = obj['graphics_id'].replace('OBJ_EVENT_GFX_', '').lower() + data = {'name': kind, 'kind': 'item' if kind == 'item_ball' else 'npc', 'x': obj['x'], 'y': obj['y']} + box = wander_box(obj, tiles) + if box: + data['wander'] = box + flag = obj.get('flag') or '0' + if flag != '0': + data['hide_flag'] = flag + return data # Tiles the player never walks onto: their elevation only matters for doors, # which the player is put on by a warp and leaves at once. -UNWALKABLE = '#JDS' +UNWALKABLE = '#^v<>DS' GROUND = '3' @@ -177,34 +214,56 @@ def ground_only(tiles, elevation): for tile, level in zip(row, levels) if tile not in UNWALKABLE) -def map_json(decomp, name, layouts, names, loaded, unhandled): - source = json.loads(decomp.read(f'data/maps/{name}/map.json')) +def warp_point(index): + return f'warp_{index}' + + +def warp(event, entries, loaded, sources): + """A warp event as MapData's warp: how it is entered, and the point it + leads to, if its map is loaded and has that warp.""" + data = {'x': event['x'], 'y': event['y'], 'enter': entries.get((event['x'], event['y']), 'walk_into')} + to_map, index = loaded.get(event['dest_map']), int(event['dest_warp_id']) + if to_map is not None and index < len(sources[to_map].get('warp_events', [])): + data['to_map'] = to_map + data['to_point'] = warp_point(index) + return data + + +def arrivals(sources, loaded): + """For each map, the indices of its warps that a warp leads to.""" + arriving = {name: set() for name in sources} + for source in sources.values(): + for event in source.get('warp_events', []): + to_map = loaded.get(event['dest_map']) + if to_map is not None and int(event['dest_warp_id']) < len(sources[to_map].get('warp_events', [])): + arriving[to_map].add(int(event['dest_warp_id'])) + return arriving + + +def map_json(decomp, name, sources, layouts, names, loaded, unhandled): + source = sources[name] signs = frozenset((e['x'], e['y']) for e in source.get('bg_events', []) if e.get('type') == 'sign') - width, height, tiles, elevation = grid(decomp, layouts[source['layout']], names, unhandled, signs) - objects = [] - for obj in source.get('object_events', []): - flag = obj.get('flag') or '' - wander_x, wander_y = wander(obj) - objects.append({ - 'x': obj['x'], 'y': obj['y'], - 'kind': obj['graphics_id'].replace('OBJ_EVENT_GFX_', '').lower(), - 'flag': '' if flag == '0' else flag, - 'wander_x': wander_x, 'wander_y': wander_y, - }) + tiles, elevation, entries = grid(decomp, layouts[source['layout']], names, unhandled, signs) + warp_events = source.get('warp_events', []) + points = {n: [x, y] for n, (x, y) in POINTS.get(name, {}).items()} + for index in sorted(arrivals(sources, loaded)[name]): + points[warp_point(index)] = [warp_events[index]['x'], warp_events[index]['y']] data = { - 'name': name, 'width': width, 'height': height, + 'name': name, + 'source': {'decomp_file': f'data/maps/{name}/map.json', 'revision': COMMIT, 'date': COMMIT_DATE}, 'tiles': tiles, 'elevation': elevation, - 'warps': [ - {'x': w['x'], 'y': w['y'], 'dest_map': loaded.get(w['dest_map'], ''), 'dest_warp': int(w['dest_warp_id'])} - for w in source.get('warp_events', []) + 'points': points, + 'warps': [warp(event, entries, loaded, sources) for event in warp_events], + # A few objects stand off the map, where no route meets them. + 'objects': [ + map_object(obj, tiles) for obj in source.get('object_events', []) + if 0 <= obj['x'] < len(tiles[0]) and 0 <= obj['y'] < len(tiles) ], - 'objects': objects, + 'flag_sets': FLAG_SETS.get(name, {}), 'connections': [ - {'direction': DIRECTIONS[c['direction']], 'offset': c['offset'], 'map': loaded[c['map']]} + {'side': DIRECTIONS[c['direction']], 'to_map': loaded[c['map']], 'offset': c['offset']} for c in (source.get('connections') or []) if c['map'] in loaded ], - 'points': [{'name': n, 'x': x, 'y': y} for n, (x, y) in POINTS.get(name, {}).items()], - 'flag_sets': [{'name': n, 'flags': flags} for n, flags in FLAG_SETS.get(name, {}).items()], } if ground_only(tiles, elevation): del data['elevation'] @@ -212,7 +271,9 @@ def map_json(decomp, name, layouts, names, loaded, unhandled): def json_text(data): - return json.dumps(data, indent=4) + '\n' + text = json.dumps(data, indent=4) + # A point's [x, y] on one line. + return re.sub(r'\[\s*(-?\d+),\s*(-?\d+)\s*\]', r'[\1, \2]', text) + '\n' def main(): @@ -231,9 +292,10 @@ def main(): decomp = Decomp(args.commit, args.cache) names = behaviors(decomp) layouts = {l['id']: l for l in json.loads(decomp.read('data/layouts/layouts.json'))['layouts'] if 'id' in l} - loaded = {json.loads(decomp.read(f'data/maps/{m}/map.json'))['id']: m for m in args.maps} + sources = {m: json.loads(decomp.read(f'data/maps/{m}/map.json')) for m in args.maps} + loaded = {source['id']: m for m, source in sources.items()} unhandled = {} - maps = [(name, json_text(map_json(decomp, name, layouts, names, loaded, unhandled))) for name in args.maps] + maps = [(name, json_text(map_json(decomp, name, sources, layouts, names, loaded, unhandled))) for name in args.maps] if unhandled: print(f'Non-collision behaviors written as floor: {unhandled}') if args.check: From 82c740faf3736a67dba26201a320be5adfd05ebe Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 1 Nov 2026 16:41:37 -0800 Subject: [PATCH 14/19] FRLG: test maps in the shared schema The inline test maps of the map and route tests are written as Pokemon::MapData maps: a source, no width or height, the shared glyphs (water 'w', a closed north edge '8', south-facing ledges 'v'), points and flag sets as objects, and the room's exit mat as an open tile with a walk_south warp to the yard's point "warp_0". Two parse checks move to fields the shared schema still requires or checks (tiles, a warp's x), and the short row is the second one, since the first sets the width. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../PokemonFRLG_OverworldMaps_Tests.cpp | 38 ++++++++++-------- .../Overworld/PokemonFRLG_OverworldRoute.cpp | 39 ++++++++----------- 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp index 4a8135b5f0..65ac381ce5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp @@ -39,14 +39,18 @@ class Test_OverworldMaps : public UnitTest{ const char* const VALID_MAP = R"({ - "name": "Test", "width": 3, "height": 2, - "tiles": ["#.~", "\"Dv"], + "name": "Test", + "source": {"decomp_file": "data/maps/Test/map.json", "revision": "test", "date": "2026-10-31"}, + "tiles": ["#.w", "~D."], "elevation": ["031", "3f3"], - "warps": [{"x": 1, "y": 1, "dest_map": "Other", "dest_warp": 2}], - "objects": [{"x": 0, "y": 1, "kind": "nurse", "flag": "FLAG_X", "wander_x": 1, "wander_y": 0}], - "connections": [{"direction": "south", "offset": -4, "map": "Other"}], - "points": [{"name": "door", "x": 1, "y": 1}], - "flag_sets": [{"name": "later", "flags": ["FLAG_X", "FLAG_Y"]}] + "points": {"door": [1, 1]}, + "warps": [ + {"x": 1, "y": 1, "enter": "walk_into", "to_map": "Other", "to_point": "warp_2"}, + {"x": 2, "y": 1, "enter": "walk_south"} + ], + "objects": [{"name": "nurse", "kind": "npc", "x": 0, "y": 1, "wander": {"x0": 0, "y0": 1, "x1": 1, "y1": 1}, "hide_flag": "FLAG_X"}], + "flag_sets": {"later": ["FLAG_X", "FLAG_Y"]}, + "connections": [{"side": "south", "to_map": "Other", "offset": -4}] })"; // The ParseException that parsing `json` throws, or empty if it doesn't. @@ -99,10 +103,10 @@ UnitTestResult test_valid_map(){ UnitTestResult test_missing_field(){ std::string json = VALID_MAP; - json.replace(json.find("\"warps\""), 7, "\"exits\""); + json.replace(json.find("\"tiles\""), 7, "\"cells\""); const std::string error = parse_error(json); - if (!mentions(error, {"Test.json", "warps", "missing"})){ - return "Expected an error naming the missing warps, got: \"" + error + "\""; + if (!mentions(error, {"Test.json", "tiles", "missing"})){ + return "Expected an error naming the missing tiles, got: \"" + error + "\""; } return true; } @@ -123,19 +127,19 @@ UnitTestResult test_elevation_left_out(){ UnitTestResult test_bad_field_type(){ std::string json = VALID_MAP; - json.replace(json.find("\"dest_warp\": 2"), 14, "\"dest_warp\": \"2\""); + json.replace(json.find("\"x\": 1"), 6, "\"x\": \"1\""); const std::string error = parse_error(json); - if (!mentions(error, {"Test.json", "warps[0]", "dest_warp", "integer"})){ - return "Expected an error naming warps[0].dest_warp, got: \"" + error + "\""; + if (!mentions(error, {"Test.json", "warps[0]", "x", "integer"})){ + return "Expected an error naming warps[0].x, got: \"" + error + "\""; } return true; } UnitTestResult test_bad_row_length(){ std::string json = VALID_MAP; - json.replace(json.find("\"#.~\""), 5, "\"#.\""); + json.replace(json.find("\"~D.\""), 5, "\"~D\""); const std::string error = parse_error(json); - if (!mentions(error, {"Test.json", "tiles[0]", "string of 3 tiles"})){ + if (!mentions(error, {"Test.json", "tiles[1]", "string of 3 glyphs"})){ return "Expected an error naming the short row, got: \"" + error + "\""; } return true; @@ -143,9 +147,9 @@ UnitTestResult test_bad_row_length(){ UnitTestResult test_unknown_tile(){ std::string json = VALID_MAP; - json.replace(json.find("\"#.~\""), 5, "\"#.?\""); + json.replace(json.find("\"#.w\""), 5, "\"#.?\""); const std::string error = parse_error(json); - if (!mentions(error, {"Test.json", "tiles[0]", "unknown tile '?'", "(2, 0)"})){ + if (!mentions(error, {"Test.json", "tiles[0]", "unknown glyph '?'", "(2, 0)"})){ return "Expected an error naming the unknown tile, got: \"" + error + "\""; } return true; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp index 6d49f4cbfd..8e6faf16c7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp @@ -452,10 +452,9 @@ std::string describe(const std::vector& route){ // tile, and a tile that can't be entered moving south. const MapData& small_map(){ static const MapData MAP = parse_map(R"({ - "name": "Small", "width": 5, "height": 4, - "tiles": ["#####", "#.n.#", "#.~.#", "#####"], - "elevation": ["33333", "33403", "33133", "33333"], - "warps": [], "objects": [], "connections": [], "points": [], "flag_sets": [] + "name": "Small", "source": {"decomp_file": "", "revision": "test", "date": "2026-10-31"}, + "tiles": ["#####", "#.8.#", "#.w.#", "#####"], + "elevation": ["33333", "33403", "33133", "33333"] })", "Small"); return MAP; } @@ -678,11 +677,9 @@ UnitTestResult test_viridian_mart_to_pewter_gym(){ // A room with a sign on its north wall, above the third column. const char* const TEST_SIGN_ROOM_JSON = R"({ - "name": "SignRoom", "width": 5, "height": 5, + "name": "SignRoom", "source": {"decomp_file": "", "revision": "test", "date": "2026-10-31"}, "tiles": ["##S##", "#...#", "#...#", "#...#", "#####"], - "elevation": ["33333", "33333", "33333", "33333", "33333"], - "warps": [], "objects": [], - "connections": [], "points": [], "flag_sets": [] + "elevation": ["33333", "33333", "33333", "33333", "33333"] })"; // Walking north under a sign stops by counting tiles, never by holding into @@ -712,15 +709,13 @@ UnitTestResult test_no_hold_into_sign(){ // A yard with a row of ledges across it. const char* const TEST_LEDGE_YARD_JSON = R"({ - "name": "LedgeYard", "width": 5, "height": 6, - "tiles": ["#####", "#...#", "#...#", "#JJJ#", "#...#", "#####"], - "elevation": ["33333", "33333", "33333", "33333", "33333", "33333"], - "warps": [], "objects": [], - "connections": [], "points": [], "flag_sets": [] + "name": "LedgeYard", "source": {"decomp_file": "", "revision": "test", "date": "2026-10-31"}, + "tiles": ["#####", "#...#", "#...#", "#vvv#", "#...#", "#####"], + "elevation": ["33333", "33333", "33333", "33333", "33333", "33333"] })"; // A ledge isn't a wall to hold into: moving the way it faces the player -// would hop it, and the maps don't say which way that is. Viridian City, +// would hop it, and routes don't hop ledges. Viridian City, // from the Pokemon Center's door south to the row above the ledge. UnitTestResult test_no_hold_into_ledge(){ const std::vector maps{parse_map(TEST_LEDGE_YARD_JSON, "LedgeYard")}; @@ -802,20 +797,18 @@ UnitTestResult test_wild_steps(){ } const char* const TEST_ROOM_JSON = R"({ - "name": "Room", "width": 5, "height": 4, - "tiles": ["#####", "#...#", "#...#", "##v##"], + "name": "Room", "source": {"decomp_file": "", "revision": "test", "date": "2026-10-31"}, + "tiles": ["#####", "#...#", "#...#", "##.##"], "elevation": ["33333", "33333", "33333", "33333"], - "warps": [{"x": 2, "y": 3, "dest_map": "Yard", "dest_warp": 0}], - "objects": [], - "connections": [], "points": [], "flag_sets": [] + "points": {"warp_0": [2, 3]}, + "warps": [{"x": 2, "y": 3, "enter": "walk_south", "to_map": "Yard", "to_point": "warp_0"}] })"; const char* const TEST_YARD_JSON = R"({ - "name": "Yard", "width": 5, "height": 4, + "name": "Yard", "source": {"decomp_file": "", "revision": "test", "date": "2026-10-31"}, "tiles": ["#####", "##D##", "#...#", "#####"], "elevation": ["33333", "33333", "33333", "33333"], - "warps": [{"x": 2, "y": 1, "dest_map": "Room", "dest_warp": 0}], - "objects": [], - "connections": [], "points": [], "flag_sets": [] + "points": {"warp_0": [2, 1]}, + "warps": [{"x": 2, "y": 1, "enter": "walk_into", "to_map": "Room", "to_point": "warp_0"}] })"; UnitTestResult test_route_through_warp(){ From 0bc538b03ee950137d8201b4cc2562e03ba808b6 Mon Sep 17 00:00:00 2001 From: dayfine Date: Mon, 2 Nov 2026 01:41:21 -0800 Subject: [PATCH 15/19] FRLG route: wall holds, leg tiles and a cost for open legs through grass Moved here from #119, which uses them to find the player again after a stopped leg: OverworldRoute.cpp/.h belong to this PR. hold_to_wall() and leg_tiles() replay the step rules; OPEN_WILD_STOP makes the planner avoid open legs across tall grass or water. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Overworld/PokemonFRLG_OverworldRoute.cpp | 79 +++++++++++++++++++ .../Overworld/PokemonFRLG_OverworldRoute.h | 30 ++++++- 2 files changed, 108 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp index 8e6faf16c7..bc4a207524 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp @@ -55,6 +55,7 @@ const RouteCosts& default_route_costs(){ {RouteCost::SURF, 40}, {RouteCost::GRASS_TILE, 20}, {RouteCost::OPEN_STOP, 8}, + {RouteCost::OPEN_WILD_STOP, 300}, }; return COSTS; } @@ -305,6 +306,7 @@ Pokemon::LegCosts to_leg_costs(const RouteCosts& costs){ leg_costs.per_tile = route_cost(costs, RouteCost::TILE); leg_costs.per_turn = route_cost(costs, RouteCost::TURN); leg_costs.per_open_stop = route_cost(costs, RouteCost::OPEN_STOP); + leg_costs.per_open_wild_stop = route_cost(costs, RouteCost::OPEN_WILD_STOP); return leg_costs; } @@ -379,6 +381,83 @@ std::optional> plan_overworld_route( } +namespace{ + +// Further than any straight line on a map. +constexpr int MAX_HOLD_TILES = 128; + +std::optional locate(const std::vector& maps, const MapPosition& position, bool surfing){ + const int map = find_map(maps, position.map); + if (map < 0){ + return std::nullopt; + } + Located player; + player.map = map; + player.state = PlayerState{position.point, elevation_at(maps[map], position.point), surfing}; + return player; +} + +// A plain step: no warp, no Surf, no getting off the water. +std::optional plain_step(const std::vector& maps, const Located& player, Direction direction){ + const std::optional transition = press(maps, player, direction); + if (!transition || transition->warped || transition->dismounted || transition->action != RouteAction::WALK){ + return std::nullopt; + } + return transition->next; +} + +} + + +namespace{ + +// Holding north into a ledge stops the player: the maps don't keep which way +// a ledge faces, but FRLG's face south, east or west (pokefirered has no +// MB_JUMP_NORTH on any map these load). Only finding the player again +// relies on this; routes never hold into a ledge (stops_at()). +bool ledge_stops_north(const std::vector& maps, const Located& player, Direction direction){ + return direction == Direction::NORTH && is_ledge(maps[player.map], player.state.position.next(direction)); +} + +} + +std::optional hold_to_wall( + const std::vector& maps, + const MapPosition& from, bool surfing, Direction direction +){ + std::optional player = locate(maps, from, surfing); + WallHold hold; + for (int c = 0; player && c <= MAX_HOLD_TILES; c++){ + if (stops_at(maps, *player, direction) || ledge_stops_north(maps, *player, direction)){ + hold.end = MapPosition{maps[player->map].name, player->state.position}; + hold.tiles = c; + return hold; + } + player = plain_step(maps, *player, direction); + if (player){ + const MapData& map = maps[player->map]; + hold.wild = hold.wild || is_tall_grass(map, player->state.position) || player->state.surfing; + } + } + return std::nullopt; +} + +std::vector leg_tiles( + const std::vector& maps, + const MapPosition& start, const RouteStep& step +){ + std::vector tiles{start}; + std::optional player = locate(maps, start, step.surfing); + const int along = step.tiles - (step.warps ? 1 : 0); + for (int c = 0; player && c < along; c++){ + player = plain_step(maps, *player, step.direction); + if (player){ + tiles.push_back(MapPosition{maps[player->map].name, player->state.position}); + } + } + return tiles; +} + MapPosition follow_overworld_route( const std::vector& maps, const MapPosition& start, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h index 112d402e35..ce5d6f872b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h @@ -83,10 +83,15 @@ enum class RouteCost{ // the player is can only be estimated. A leg that ends at a wall is // walked again instead. OPEN_STOP, + // Extra again when that leg crosses tall grass or water, where a wild + // battle is likely to stop it: the walker can't tell where it did + // (console B, 2026-11-01, Route 1, four runs). + OPEN_WILD_STOP, }; using RouteCosts = std::map; -// TILE 1, TURN 2, WARP 30, SURF 40, GRASS_TILE 20, OPEN_STOP 8. +// TILE 1, TURN 2, WARP 30, SURF 40, GRASS_TILE 20, OPEN_STOP 8, +// OPEN_WILD_STOP 300. const RouteCosts& default_route_costs(); // `costs`'s cost for `kind`, or the default if it has none. @@ -104,6 +109,29 @@ std::optional> plan_overworld_route( std::optional start_facing = std::nullopt ); +// Holding `direction` from `from`, on the water if `surfing`: where a wall +// stops the player, how many tiles on, and whether any tile on the way is +// tall grass or water. +struct WallHold{ + MapPosition end; + int tiles = 0; + bool wild = false; +}; +// Nothing unless every step on the way is a plain walk: a warp, Surf, a +// ledge, a person, a sign that would speak, or the edge of the loaded maps +// comes first. +std::optional hold_to_wall( + const std::vector& maps, + const MapPosition& from, bool surfing, Direction direction +); + +// The tiles a WALK `step` from `start` passes through, `start` first, short +// of a warp at its end. +std::vector leg_tiles( + const std::vector& maps, + const MapPosition& start, const RouteStep& step +); + // Replays `route` from `start` with the game's step rules and returns where // it ends. Throws InternalProgramError if a step can't be taken as planned. MapPosition follow_overworld_route( From 9cf7e2a1fb972b08b2af3cac1e9c258db3da7652 Mon Sep 17 00:00:00 2001 From: dayfine Date: Mon, 2 Nov 2026 16:01:09 -0800 Subject: [PATCH 16/19] FRLG: PlayerFacingReader image tests read the facing from the file name As the other image tests do, the expected result ends the file name: _, so a test is registered with its path only. The images are renamed to match (Route24_South.png, ...). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../PokemonFRLG_PlayerFacingReader.cpp | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp index 601dd21086..f747f401b1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_PlayerFacingReader.cpp @@ -5,15 +5,18 @@ */ #include +#include #include #include #include "Common/Cpp/Color.h" #include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Filesystem/Filesystem.h" #include "Common/Cpp/TestRunners/UnitTest.h" #include "CommonFramework/GlobalAutoPaths.h" #include "CommonFramework/ImageTools/ImageBoxes.h" #include "CommonFramework/ImageTypes/ImageRGB32.h" #include "CommonFramework/ImageTypes/ImageViewRGB32.h" +#include "Tests/TestUtils.h" #include "VideoGames/PokemonFRLG/PokemonFRLG_Settings.h" #include "PokemonFRLG_PlayerFacingReader.h" @@ -135,13 +138,21 @@ namespace{ class Test_PlayerFacingReader : public UnitTest{ public: - Test_PlayerFacingReader(const std::string& image, std::optional expected) + // The image's name ends with the way the player faces, or "None" where + // no standing player shows: _. + Test_PlayerFacingReader(const std::string& image) : UnitTest("PokemonFRLG::PlayerFacingReader - " + image) , m_image(UNIT_TEST_RESOURCE_PATH() + image) - , m_expected(expected) {} virtual UnitTestResult run(Logger& logger, CancellableScope& scope) const override{ + const std::vector words = parse_words(Filesystem::Path(m_image).stem().string()); + if (words.size() < 2){ + return "Error: filename must be _."; + } + std::string expected = words.back(); + std::transform(expected.begin(), expected.end(), expected.begin(), [](unsigned char c){ return (char)std::tolower(c); }); + std::optional facing; try{ facing = read_player_facing(ImageRGB32(m_image)); @@ -149,15 +160,15 @@ class Test_PlayerFacingReader : public UnitTest{ // The screenshots and the sprite sheet aren't in CI's resources yet. return UnitTestResult(UnitTestResult::SKIPPED, "File not found: " + e.message()); } - if (facing == m_expected){ + const std::string read = facing ? direction_name(*facing) : "none"; + if (read == expected){ return true; } - return std::string("Read ") + (facing ? direction_name(*facing) : "nothing"); + return "Expected " + expected + ", read " + read; } private: std::string m_image; - std::optional m_expected; }; // Made-up sprites, so the matching is tested without the sprite sheet: @@ -237,12 +248,12 @@ class Test_PlayerFacingFixture : public UnitTest{ void add_tests_PlayerFacingReader(UnitTestDatabase& database){ database.add(); // LeafGreen on the Switch, captured with a 1080p card. - database.add("PokemonFRLG/PlayerFacingReader/South-Route24.png", Direction::SOUTH); - database.add("PokemonFRLG/PlayerFacingReader/North-Route24.png", Direction::NORTH); - database.add("PokemonFRLG/PlayerFacingReader/South-CeruleanCave.png", Direction::SOUTH); - database.add("PokemonFRLG/PlayerFacingReader/North-CeruleanCave.png", Direction::NORTH); - database.add("PokemonFRLG/PlayerFacingReader/Surfing.png", std::nullopt); - database.add("PokemonFRLG/PlayerFacingReader/Bag.png", std::nullopt); + database.add("PokemonFRLG/PlayerFacingReader/Route24_South.png"); + database.add("PokemonFRLG/PlayerFacingReader/Route24_North.png"); + database.add("PokemonFRLG/PlayerFacingReader/CeruleanCave_South.png"); + database.add("PokemonFRLG/PlayerFacingReader/CeruleanCave_North.png"); + database.add("PokemonFRLG/PlayerFacingReader/Surfing_None.png"); + database.add("PokemonFRLG/PlayerFacingReader/Bag_None.png"); } From b583188bbd7469121497aba51bcf3918fcc73e10 Mon Sep 17 00:00:00 2001 From: dayfine Date: Mon, 2 Nov 2026 20:10:09 -0800 Subject: [PATCH 17/19] FRLG maps: whether a trainer may see a tile trainer_may_see() checks a trainer's sight from its tile, or from every tile of its wander box, each way it looks, short of a wall. The walker uses it to tell which legs cross a trainer's sight. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Overworld/PokemonFRLG_OverworldMap.cpp | 44 ++++++++++++++++-- .../Overworld/PokemonFRLG_OverworldMap.h | 6 +++ .../PokemonFRLG_OverworldMaps_Tests.cpp | 45 +++++++++++++++++++ 3 files changed, 92 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp index 5a61b137e1..e0fc1a339e 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.cpp @@ -135,11 +135,34 @@ void hide_objects(MapData& map, const std::set& flags){ map.objects = std::move(shown); } +namespace{ + +// The tiles `object` may stand on: its wander box, or its own tile. +Pokemon::TileBox standing_box(const MapObject& object){ + return object.wander.value_or( + Pokemon::TileBox{.x0 = object.x, .y0 = object.y, .x1 = object.x, .y1 = object.y} + ); +} + +// Whether `trainer`, standing on `from`, sees `tile` any way it looks. +bool sees_from(const MapData& map, const Pokemon::MapTrainer& trainer, const TilePos& from, const TilePos& tile){ + for (Direction look : trainer.looks){ + TilePos seen = from; + for (int c = 0; c < trainer.sight && !is_wall(map, seen.next(look)); c++){ + seen = seen.next(look); + if (seen == tile){ + return true; + } + } + } + return false; +} + +} + const MapObject* object_at(const MapData& map, const TilePos& point){ for (const MapObject& object : map.objects){ - const Pokemon::TileBox box = object.wander.value_or( - Pokemon::TileBox{.x0 = object.x, .y0 = object.y, .x1 = object.x, .y1 = object.y} - ); + const Pokemon::TileBox box = standing_box(object); if (box.x0 <= point.x && point.x <= box.x1 && box.y0 <= point.y && point.y <= box.y1){ return &object; } @@ -147,6 +170,21 @@ const MapObject* object_at(const MapData& map, const TilePos& point){ return nullptr; } +bool trainer_may_see(const MapData& map, const MapObject& object, const TilePos& tile){ + if (!object.trainer){ + return false; + } + const Pokemon::TileBox box = standing_box(object); + for (int y = box.y0; y <= box.y1; y++){ + for (int x = box.x0; x <= box.x1; x++){ + if (sees_from(map, *object.trainer, TilePos{x, y}, tile)){ + return true; + } + } + } + return false; +} + StepKind classify_step(const MapData& map, const PlayerState& state, Direction direction){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h index 34a0859ee2..399d5f0537 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h @@ -93,6 +93,12 @@ bool walks_out_on_arrival(const MapData& map, const TilePos& point); // The object standing, or maybe wandering, on this tile. const MapObject* object_at(const MapData& map, const TilePos& point); +// Whether `object`, a trainer, may see the player on `tile`: up to its +// sight ahead, any way it looks, short of a wall, from its tile or, for +// one who wanders, from any tile it may wander to. False for an object +// that isn't a trainer. +bool trainer_may_see(const MapData& map, const MapObject& object, const TilePos& tile); + // Removes the objects the game hides once one of `flags` is set. void hide_objects(MapData& map, const std::set& flags); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp index 65ac381ce5..ea9679dcb6 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp @@ -155,6 +155,50 @@ UnitTestResult test_unknown_tile(){ return true; } +// Route 3's Lass Robin, shrunk: she wanders x 2, y 2..4 looking north and +// south, sight 3, below a corridor (row 1) walled off at x 2 above it; a +// bug catcher at (5, 4) looks west, sight 2. +const char* const TRAINERS_MAP = R"({ + "name": "Trainers", + "source": {"decomp_file": "", "revision": "test", "date": "2026-11-02"}, + "tiles": ["##.####", ".......", ".......", ".......", ".......", "~~~~~~~"], + "objects": [ + {"name": "lass", "kind": "npc", "x": 2, "y": 3, "wander": {"x0": 2, "y0": 2, "x1": 2, "y1": 4}, "trainer": {"sight": 3, "looks": ["north", "south"]}}, + {"name": "bug_catcher", "kind": "npc", "x": 5, "y": 4, "facing": "west", "trainer": {"sight": 2}}, + {"name": "youngster", "kind": "npc", "x": 6, "y": 1} + ] +})"; + +// A wanderer sees from every tile she may stand on, short of a wall; a +// trainer standing still only along his facing; a non-trainer nothing. +UnitTestResult test_trainer_sight(){ + const MapData map = parse_map(TRAINERS_MAP, "Trainers.json"); + const MapObject& lass = map.objects[0]; + const MapObject& bug_catcher = map.objects[1]; + const MapObject& youngster = map.objects[2]; + struct Case{ + const MapObject* object; + TilePos tile; + bool sees; + }; + const Case cases[] = { + {&lass, {2, 1}, true}, // from (2, 2..4), north + {&lass, {2, 0}, true}, // the gap in the wall, 2 tiles up from (2, 2) + {&lass, {2, 5}, true}, // south, from (2, 4) + {&lass, {1, 1}, false}, + {&bug_catcher, {3, 4}, true}, + {&bug_catcher, {2, 4}, false}, // past his sight + {&bug_catcher, {5, 3}, false}, // not his way + {&youngster, {5, 1}, false}, + }; + for (const Case& c : cases){ + if (trainer_may_see(map, *c.object, c.tile) != c.sees){ + return c.object->name + (c.sees ? " should see " : " shouldn't see ") + Pokemon::to_string(c.tile) + "."; + } + } + return true; +} + UnitTestResult test_not_json(){ const std::string error = parse_error("{\"name\": "); if (!mentions(error, {"Test.json", "not a JSON object"})){ @@ -174,6 +218,7 @@ void add_tests_OverworldMaps(UnitTestDatabase& database){ database.add("row of the wrong length", test_bad_row_length); database.add("unknown tile", test_unknown_tile); database.add("not JSON", test_not_json); + database.add("trainer sight", test_trainer_sight); } From cfc85e21282360697bde2dec8ce68841485f8987 Mon Sep 17 00:00:00 2001 From: dayfine Date: Mon, 2 Nov 2026 20:13:13 -0800 Subject: [PATCH 18/19] FRLG route: never hold a leg into a warp to a map that isn't loaded press() refuses a warp whose map isn't loaded as if it were a wall, so stops_at() called the tile before Route 4's Pokemon Center escalator a wall: "west 5 (to wall)" rode the escalator up to 2F (console B, 2026-11-02). A leg there now ends by counting tiles. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../PokemonFRLG_OverworldMaps_Tests.cpp | 30 +++++++++++++++++++ .../Overworld/PokemonFRLG_OverworldRoute.cpp | 23 ++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp index ea9679dcb6..b9c82f093f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp @@ -11,6 +11,7 @@ #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" #include "PokemonFRLG_OverworldMaps.h" +#include "PokemonFRLG_OverworldRoute.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -207,6 +208,34 @@ UnitTestResult test_not_json(){ return true; } +// A hall with an escalator at (1, 2) to a floor that isn't loaded, like +// Route 4's Pokemon Center. +const char* const ESCALATOR_HALL = R"({ + "name": "Hall", "source": {"decomp_file": "", "revision": "test", "date": "2026-11-02"}, + "tiles": ["######", "#....#", "#....#", "######"], + "warps": [{"x": 1, "y": 2, "enter": "step_on"}] +})"; + +// Holding west along the escalator's row rides it: a leg there ends by +// counting tiles, never by holding to the wall behind it (console B, +// 2026-11-02, Route 4's Pokemon Center). +UnitTestResult test_no_hold_onto_escalator(){ + const std::vector maps{parse_map(ESCALATOR_HALL, "Hall")}; + if (hold_to_wall(maps, {"Hall", {4, 2}}, false, Direction::WEST)){ + return "Expected no hold west along the escalator's row."; + } + const std::optional> route = plan_overworld_route(maps, {"Hall", {4, 2}}, {{"Hall", {2, 1}}, std::nullopt}); + if (!route || !(follow_overworld_route(maps, {"Hall", {4, 2}}, *route) == MapPosition{"Hall", {2, 1}})){ + return "Expected a route from (4, 2) to (2, 1)."; + } + for (const RouteStep& step : *route){ + if (step.to_wall && step.direction == Direction::WEST && step.end.point == TilePos{2, 2}){ + return "Expected no hold west next to the escalator: " + to_string(step); + } + } + return true; +} + } @@ -219,6 +248,7 @@ void add_tests_OverworldMaps(UnitTestDatabase& database){ database.add("unknown tile", test_unknown_tile); database.add("not JSON", test_not_json); database.add("trainer sight", test_trainer_sight); + database.add("no hold onto an escalator", test_no_hold_onto_escalator); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp index bc4a207524..6e63bc8ed4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp @@ -212,6 +212,23 @@ std::optional press(const std::vector& maps, const Located& return transition; } +// Whether pressing `direction` takes a warp to a map that isn't loaded, +// which press() refuses as if it were a wall. +bool warps_off_loaded_maps(const std::vector& maps, const Located& player, Direction direction){ + const MapData& map = maps[player.map]; + const TilePos here = player.state.position; + const TilePos ahead = here.next(direction); + const MapWarp* warp = nullptr; + if (exit_mat(map, here) == direction){ + warp = warp_at(map, here); + }else if (direction == Direction::NORTH && is_door(map, ahead) && !player.state.surfing){ + warp = warp_at(map, ahead); + }else if (in_bounds(map, ahead) && warps_on_step(map, ahead) && classify_step(map, player.state, direction) != StepKind::BLOCKED){ + warp = warp_at(map, ahead); + } + return warp != nullptr && !take_warp(maps, warp); +} + // Whether holding `direction` stops the player where they are: a wall, or // water they'd need to Surf onto. A leg that ends there can be // held for longer than it takes, and walked again after an interruption. A @@ -222,6 +239,12 @@ bool stops_at(const std::vector& maps, const Located& player, Direction if (transition){ return transition->action == RouteAction::SURF; } + // Nor does a warp to a map that isn't loaded: the player takes it (console + // B, 2026-11-02, "west 5 (to wall)" rode Route 4's Pokemon Center + // escalator up to 2F). + if (warps_off_loaded_maps(maps, player, direction)){ + return false; + } const MapData& map = maps[player.map]; const TilePos ahead = player.state.position.next(direction); // Held into a sign moving north or south, the game shows the sign's From 3414eafb7e30012f03f259b3fbaedf9da7583855 Mon Sep 17 00:00:00 2001 From: dayfine Date: Mon, 2 Nov 2026 21:11:57 -0800 Subject: [PATCH 19/19] Leg walker: an open leg stopped at an interrupt says how far the timing puts the player A leg that stops at its first interrupt (stop_on_interrupt) used to leave LegResult::tiles at 0, so the caller had to look for the player along the whole leg. It now carries tiles_before_interrupt()'s estimate, which the FRLG recovery walk (#119) narrows its search with. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Source/Pokemon/Navigation/Pokemon_LegWalker.cpp | 9 ++++++++- .../Source/Pokemon/Navigation/Pokemon_LegWalker.h | 4 +++- .../Pokemon/Navigation/Pokemon_LegWalker_Tests.cpp | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.cpp b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.cpp index fbb88051fb..84ed2fa37e 100644 --- a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.cpp +++ b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.cpp @@ -63,9 +63,16 @@ LegResult walk_leg_with(const LegSpec& leg, const LegCalls& calls, size_t max_in calls.clear(outcome->interrupt); const std::string seen = std::format("{} after {}ms", calls.name(outcome->interrupt), outcome->elapsed.count()); if (stops_here(leg, result, *outcome)){ - calls.log(seen + ", stopping the leg."); result.exact = false; result.stopped = true; + if (leg.to_wall){ + calls.log(seen + ", stopping the leg."); + return result; + } + // The caller finds the player again, near where the timing says. + result.tiles = leg.tiles - remaining + + tiles_before_interrupt(leg, outcome->elapsed, calls.detection_delay(outcome->interrupt), remaining); + calls.log(std::format("{}, about {} of {} tiles walked, stopping the leg.", seen, result.tiles, leg.tiles)); return result; } if (leg.to_wall){ diff --git a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.h b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.h index ca694db900..3993176f26 100644 --- a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.h +++ b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker.h @@ -94,7 +94,9 @@ struct LegResult{ bool exact = true; size_t interruptions = 0; // The leg stopped at an interrupt (stop_on_interrupt, stop_if_blocked): - // the player is somewhere along it, and `tiles` is not known. + // the player is somewhere along it. For an open leg `tiles` is then how + // many the interrupt's timing says were walked (tiles_before_interrupt()), + // for the caller to look around; for a leg to a wall it is 0. bool stopped = false; }; diff --git a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker_Tests.cpp b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker_Tests.cpp index 667fb55d64..9f9564e275 100644 --- a/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker_Tests.cpp +++ b/SerialPrograms/Source/Pokemon/Navigation/Pokemon_LegWalker_Tests.cpp @@ -130,7 +130,8 @@ UnitTestResult test_open_leg_interrupted_at_end(){ return true; } -// An open leg set to stop at an interrupt doesn't walk on from a guess. +// An open leg set to stop at an interrupt doesn't walk on from a guess; it +// says how far the timing puts the player, for the caller to look around. UnitTestResult test_open_leg_stops(){ ScriptedLeg script; script.outcomes = {after_step(2)}; @@ -140,6 +141,9 @@ UnitTestResult test_open_leg_stops(){ if (script.holds.size() != 1 || !result.stopped || result.exact || script.cleared.size() != 1){ return "Expected one hold, the interrupt cleared, and the leg stopped."; } + if (result.tiles != 2){ + return std::format("Expected the timing to put the player 2 tiles in, got {}.", result.tiles); + } return true; }