diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json index 0c54fa2d7d..10e47a673a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity.json @@ -265,6 +265,11 @@ "side": "north", "to_map": "Route24", "offset": 12 + }, + { + "side": "west", + "to_map": "Route4", + "offset": 10 } ] } 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 c538b6e3b1..28d628941f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity_PokemonCenter_1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/CeruleanCity_PokemonCenter_1F.json @@ -5,6 +5,7 @@ "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", "date": "2026-10-31" }, + "allow_running": false, "tiles": [ "#.#############", "###############", 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 ee57a2a78a..bc171fed17 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_1F.json @@ -5,6 +5,7 @@ "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", "date": "2026-10-31" }, + "allow_running": false, "tiles": [ "#############", "#############", 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 eb5cbf8d32..7ca500d896 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_2F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_PlayersHouse_2F.json @@ -5,6 +5,7 @@ "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", "date": "2026-10-31" }, + "allow_running": false, "tiles": [ "############", "###########S", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json index 158ea7c73d..724be58581 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_ProfessorOaksLab.json @@ -5,6 +5,7 @@ "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", "date": "2026-10-31" }, + "allow_running": false, "tiles": [ "#############", "######SS#####", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json index bfd7bdf2e0..641924ae26 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PalletTown_RivalsHouse.json @@ -5,6 +5,7 @@ "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", "date": "2026-10-31" }, + "allow_running": false, "tiles": [ "#############", "#############", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json index da09eb8aa1..845d8ae7dc 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity.json @@ -162,6 +162,11 @@ "side": "south", "to_map": "Route2", "offset": 12 + }, + { + "side": "east", + "to_map": "Route3", + "offset": 10 } ] } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json index 75afb1541c..5f5f46c50b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Gym.json @@ -5,6 +5,7 @@ "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", "date": "2026-10-31" }, + "allow_running": false, "tiles": [ "#############", "####.....####", @@ -61,7 +62,11 @@ "name": "camper", "kind": "npc", "x": 3, - "y": 8 + "y": 8, + "facing": "east", + "trainer": { + "sight": 4 + } }, { "name": "gym_guy", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json index 7b4e49dea9..29f7f0d2cd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Mart.json @@ -5,6 +5,7 @@ "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", "date": "2026-10-31" }, + "allow_running": false, "tiles": [ "###########", "###########", 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 1ea83f0faf..ee0947b080 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Museum_1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_Museum_1F.json @@ -5,6 +5,7 @@ "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", "date": "2026-10-31" }, + "allow_running": false, "tiles": [ "############################", "############################", 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 90267e027f..87ce82cab4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_PokemonCenter_1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/PewterCity_PokemonCenter_1F.json @@ -5,6 +5,7 @@ "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", "date": "2026-10-31" }, + "allow_running": false, "tiles": [ "#.#############", "###############", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json index 59d1789c3c..2c3bd7ee03 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route24.json @@ -103,37 +103,61 @@ "name": "camper", "kind": "npc", "x": 12, - "y": 19 + "y": 19, + "facing": "west", + "trainer": { + "sight": 2 + } }, { "name": "lass", "kind": "npc", "x": 10, - "y": 22 + "y": 22, + "facing": "east", + "trainer": { + "sight": 2 + } }, { "name": "youngster", "kind": "npc", "x": 12, - "y": 25 + "y": 25, + "facing": "west", + "trainer": { + "sight": 2 + } }, { "name": "lass", "kind": "npc", "x": 10, - "y": 28 + "y": 28, + "facing": "east", + "trainer": { + "sight": 2 + } }, { "name": "bug_catcher", "kind": "npc", "x": 12, - "y": 31 + "y": 31, + "facing": "west", + "trainer": { + "sight": 2 + } }, { "name": "camper", "kind": "npc", "x": 5, - "y": 21 + "y": 21, + "facing": "north", + "trainer": { + "sight": 5 + } }, { "name": "item_ball", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route3.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route3.json new file mode 100644 index 0000000000..91a4f7fc9c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route3.json @@ -0,0 +1,142 @@ +{ + "name": "Route3", + "source": { + "decomp_file": "data/maps/Route3/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, + "tiles": [ + "####################################################################........########", + "####################################################################........########", + "####################################################################........########", + "#############......................#################################.......#########", + "###########..........................###############################.....###########", + "###########..........................######................#########.....###########", + "###########.........###.......##.....#####...................#######.....###########", + "###########vvv..vvvv###vvvvvvv##vvv..#####...................#######.....###########", + "#######.............###.......##.....#####vvvv..#######vvvvv.#######vvv..###########", + "....................###.......##................#######......#######.....###########", + "....................###.......###...............#######......#####.......~~~~#######", + ".........###........###.......###~~~~~~~........#######...............##S~~~~~~#####", + "..##########vvvv..vv###vvvvvvv###~~~~~~~~~~~~~~########................~~~~~~~~#####", + "############........###.......###~~~~~~~~~~~~~~########................~~~~~~~~#####", + "############.................######~~~~~~~~~~~~########...............~~~~~~~~~#####", + "##############...............######~~~~~~~~~~~~##########.............~~~~~~~~~#####", + "#######################################~~~~~~~~##########.............~~~~~~########", + "####################################################################################", + "####################################################################################", + "####################################################################################" + ], + "points": {}, + "warps": [], + "objects": [ + { + "name": "youngster", + "kind": "npc", + "x": 70, + "y": 13 + }, + { + "name": "lass", + "kind": "npc", + "x": 40, + "y": 11, + "wander": { + "x0": 40, + "y0": 10, + "x1": 40, + "y1": 12 + }, + "trainer": { + "sight": 3, + "looks": [ + "north", + "south" + ] + } + }, + { + "name": "bug_catcher", + "kind": "npc", + "x": 32, + "y": 6, + "facing": "east", + "trainer": { + "sight": 4 + } + }, + { + "name": "lass", + "kind": "npc", + "x": 30, + "y": 3, + "facing": "west", + "trainer": { + "sight": 5 + } + }, + { + "name": "bug_catcher", + "kind": "npc", + "x": 25, + "y": 4, + "facing": "south", + "trainer": { + "sight": 2 + } + }, + { + "name": "youngster", + "kind": "npc", + "x": 29, + "y": 10, + "facing": "west", + "trainer": { + "sight": 5 + } + }, + { + "name": "lass", + "kind": "npc", + "x": 19, + "y": 9, + "facing": "west", + "trainer": { + "sight": 5 + } + }, + { + "name": "bug_catcher", + "kind": "npc", + "x": 12, + "y": 6, + "facing": "east", + "trainer": { + "sight": 3 + } + }, + { + "name": "youngster", + "kind": "npc", + "x": 17, + "y": 4, + "facing": "south", + "trainer": { + "sight": 2 + } + } + ], + "flag_sets": {}, + "connections": [ + { + "side": "north", + "to_map": "Route4", + "offset": 60 + }, + { + "side": "west", + "to_map": "PewterCity", + "offset": -10 + } + ] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route4.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route4.json new file mode 100644 index 0000000000..3dd6fc1123 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route4.json @@ -0,0 +1,142 @@ +{ + "name": "Route4", + "source": { + "decomp_file": "data/maps/Route4/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, + "tiles": [ + "############################################################################################################", + "##########.....#############################################################################################", + "###########################################..<......>.#########.<.....<###############...........###########", + "###########################################..<......>..>.....<..<.....<.....................................", + "####...#..#################################..<......>..>.....<..<.....<.....................................", + "###..#....SSD##.###.############.########....#vv..vv#..>.....<..<.....#vvvvvvvvvvvvvvvvvvvvvvvvvv###########", + "###..................##########........................>.....<..<................................#wwwwwwwwww", + "###vvvvv..........S..##########...S....................>.....<..#v..vvvvvvvvvvvvvvvvvvvvvvvvvvvvv#wwwwwwwwww", + "###..................#########.........................>.....<...................................#wwwwwwwwww", + "###............vvvvvvv########vvvvvvvvvvv...vvvvvvvvvvv#.....#v#......................####vvvvvvv###########", + "###.#.................########.................................#vvvvv..####vvvvvvvvvvv####..................", + "###vvvvvvvvv........#.########.........................................####~~~~~~~~~~~####..................", + "###............vvvvvvv###################..............................####~~~~~~~~~~~####..................", + "######.#..............###########################......................####~~~~~~~~~~~~~##.......###########", + "########.............############################......................####~~~~~~~~~~~~~##vv...vv###########", + "########vvv.......###############################vv..vvvvvvvvv..vvvvv######~~~~~~~~~~~~~##.......###########", + "########........#################################....................######~~~~~~~~~~~~.##.......###########", + "########........#################################....................######~~~~~~~~~~~...........###########", + "########.....vvv########################################.............#################.........#############", + "########........############################################################################################" + ], + "elevation": [ + "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "000000000033333000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "000000000000000000000000000000000000000000033033333303000000000303333300000000000000003333333333300000000000", + "000000000000000000000000000000000000000000033033333303303333303303333303333333333333333333333333333333333333", + "000033303300000000000000000000000000000000033033333303303333303303333303333333333333333333333333333333333333", + "000330333300000300030000000000003000000003333000330003303333303303333300000000000000000000000000000000000000", + "000333333333333333333000000000033333333333333333333333303333303303333333333333333333333333333333301111111111", + "000000003333333333033000000000033303333333333333333333303333303300330000000000000000000000000000001111111111", + "000333333333333333333000000000333333333333333333333333303333303333333333333333333333333333333333301111111111", + "000333333333333000000000000000000000000003330000000000003333300033333333333333333333330000000000000000000000", + "000303333333333333333300000000333333333333333333333333333333333000000330000000000000000000333333333333333333", + "000000000000333333330300000000333333333333333333333333333333333333333330000333333333330000333333333333333333", + "000333333333333000000000000000000000000003333333333333333333333333333330000333333333330000333333333333333333", + "000000303333333333333300000000000000000000000000033333333333333333333330000333333333333300333333300000000000", + "000000003333333333333000000000000000000000000000033333333333333333333330000333333333333300003330000000000000", + "000000000003333333000000000000000000000000000000000330000000003300000000000333333333333300333333300000000000", + "000000003333333300000000000000000000000000000000033333333333333333333000000333333333333300333333300000000000", + "000000003333333300000000000000000000000000000000033333333333333333333000000333333333333333333333300000000000", + "000000003333300000000000000000000000000000000000000000003333333333333000000000000000003333333330000000000000", + "000000003333333300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ], + "points": { + "warp_2": [12, 5] + }, + "warps": [ + { + "x": 19, + "y": 5, + "enter": "cave_entrance" + }, + { + "x": 32, + "y": 5, + "enter": "cave_entrance" + }, + { + "x": 12, + "y": 5, + "enter": "walk_into", + "to_map": "Route4_PokemonCenter_1F", + "to_point": "warp_1" + } + ], + "objects": [ + { + "name": "woman_1", + "kind": "npc", + "x": 9, + "y": 8, + "wander": { + "x0": 8, + "y0": 7, + "x1": 10, + "y1": 9 + } + }, + { + "name": "lass", + "kind": "npc", + "x": 75, + "y": 3, + "facing": "east", + "trainer": { + "sight": 4 + } + }, + { + "name": "item_ball", + "kind": "item", + "x": 67, + "y": 5, + "hide_flag": "FLAG_HIDE_ROUTE4_TM05" + }, + { + "name": "boy", + "kind": "npc", + "x": 15, + "y": 14, + "wander": { + "x0": 14, + "y0": 14, + "x1": 16, + "y1": 14 + } + }, + { + "name": "black_belt", + "kind": "npc", + "x": 47, + "y": 3 + }, + { + "name": "black_belt", + "kind": "npc", + "x": 50, + "y": 3 + } + ], + "flag_sets": {}, + "connections": [ + { + "side": "south", + "to_map": "Route3", + "offset": -60 + }, + { + "side": "east", + "to_map": "CeruleanCity", + "offset": -10 + } + ] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route4_PokemonCenter_1F.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route4_PokemonCenter_1F.json new file mode 100644 index 0000000000..c3fe2d586c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/Route4_PokemonCenter_1F.json @@ -0,0 +1,112 @@ +{ + "name": "Route4_PokemonCenter_1F", + "source": { + "decomp_file": "data/maps/Route4_PokemonCenter_1F/map.json", + "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", + "date": "2026-10-31" + }, + "allow_running": false, + "tiles": [ + "#.#############", + "###############", + "....###..##....", + "....#######....", + "...............", + "...............", + "#..........##..", + "...........##..", + "...............", + "###############" + ], + "elevation": [ + "030000000000000", + "000000000000000", + "333300033003333", + "333300000003333", + "333333333333333", + "330333333333333", + "044033333330033", + "330333333330033", + "333333333333333", + "000000000000000" + ], + "points": { + "nurse_front": [7, 4], + "salesman_front": [2, 3], + "warp_1": [7, 8] + }, + "warps": [ + { + "x": 6, + "y": 8, + "enter": "walk_into", + "to_map": "Route4", + "to_point": "warp_2" + }, + { + "x": 7, + "y": 8, + "enter": "walk_south", + "to_map": "Route4", + "to_point": "warp_2" + }, + { + "x": 8, + "y": 8, + "enter": "walk_into", + "to_map": "Route4", + "to_point": "warp_2" + }, + { + "x": 1, + "y": 6, + "enter": "step_on" + } + ], + "objects": [ + { + "name": "nurse", + "kind": "npc", + "x": 7, + "y": 2 + }, + { + "name": "balding_man", + "kind": "npc", + "x": 1, + "y": 3 + }, + { + "name": "gentleman", + "kind": "npc", + "x": 12, + "y": 5 + }, + { + "name": "boy", + "kind": "npc", + "x": 5, + "y": 4, + "wander": { + "x0": 4, + "y0": 3, + "x1": 6, + "y1": 5 + } + }, + { + "name": "youngster", + "kind": "npc", + "x": 14, + "y": 4 + }, + { + "name": "clipboard", + "kind": "npc", + "x": 12, + "y": 6 + } + ], + "flag_sets": {}, + "connections": [] +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json index 1078ec3405..9b3e8509a4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_Mart.json @@ -5,6 +5,7 @@ "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", "date": "2026-10-31" }, + "allow_running": false, "tiles": [ "###########", "###########", 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 63a2707d8f..e0341f1440 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_PokemonCenter_1F.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianCity_PokemonCenter_1F.json @@ -5,6 +5,7 @@ "revision": "ce6406d8c2eaf46d543c8a2606de0c3cb1951982", "date": "2026-10-31" }, + "allow_running": false, "tiles": [ "#.#############", "###############", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json index 93352339c5..a6e51104b3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps/ViridianForest.json @@ -141,19 +141,31 @@ "name": "bug_catcher", "kind": "npc", "x": 47, - "y": 45 + "y": 45, + "facing": "west", + "trainer": { + "sight": 5 + } }, { "name": "bug_catcher", "kind": "npc", "x": 47, - "y": 29 + "y": 29, + "facing": "west", + "trainer": { + "sight": 4 + } }, { "name": "bug_catcher", "kind": "npc", "x": 7, - "y": 22 + "y": 22, + "facing": "west", + "trainer": { + "sight": 4 + } }, { "name": "item_ball", @@ -180,13 +192,24 @@ "name": "bug_catcher", "kind": "npc", "x": 43, - "y": 6 + "y": 6, + "trainer": { + "sight": 1, + "looks": [ + "south", + "north" + ] + } }, { "name": "bug_catcher", "kind": "npc", "x": 16, - "y": 5 + "y": 5, + "facing": "north", + "trainer": { + "sight": 1 + } }, { "name": "item_ball", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp index 0f7514fe28..a1aaeda292 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.cpp @@ -37,6 +37,10 @@ const char* const MAP_NAMES[] = { "PewterCity_Mart", "PewterCity_Museum_1F", "PewterCity_Gym", + // Route 3 to the Magikarp salesman in Route 4's Pokemon Center. + "Route3", + "Route4", + "Route4_PokemonCenter_1F", // Cerulean Cave, for Mewtwo. "CeruleanCity_PokemonCenter_1F", "CeruleanCity", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp index b9c82f093f..1c621ce1e8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps_Tests.cpp @@ -4,6 +4,8 @@ * */ +#include +#include #include #include #include @@ -11,6 +13,7 @@ #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" #include "PokemonFRLG_OverworldMaps.h" +#include "PokemonFRLG_OverworldReanchor.h" #include "PokemonFRLG_OverworldRoute.h" namespace PokemonAutomation{ @@ -208,6 +211,95 @@ UnitTestResult test_not_json(){ return true; } +const MapData* built_in(const std::vector& maps, const std::string& name){ + for (const MapData& map : maps){ + if (map.name == name){ + return ↦ + } + } + return nullptr; +} + +// Route 3, Route 4 and its Pokemon Center load, joined to Pewter City; the +// Center doesn't let the player run, the routes do. +UnitTestResult test_route3_route4_maps(){ + const std::vector maps = overworld_maps(); + for (const char* name : {"Route3", "Route4", "Route4_PokemonCenter_1F"}){ + if (built_in(maps, name) == nullptr){ + return std::string("Missing map ") + name + "."; + } + } + if (!built_in(maps, "Route3")->allow_running || !built_in(maps, "PewterCity")->allow_running + || built_in(maps, "Route4_PokemonCenter_1F")->allow_running || built_in(maps, "PewterCity_PokemonCenter_1F")->allow_running + ){ + return "Expected running on the routes and Pewter City, not in the Pokemon Centers."; + } + const MapPosition nurse{"Route4_PokemonCenter_1F", map_point(maps, "Route4_PokemonCenter_1F", "nurse_front")}; + const MapPosition salesman{"Route4_PokemonCenter_1F", map_point(maps, "Route4_PokemonCenter_1F", "salesman_front")}; + if (nurse.point != TilePos{7, 4} || salesman.point != TilePos{2, 3}){ + return "Unexpected nurse_front or salesman_front."; + } + const MapPosition pewter{"PewterCity", {45, 21}}; + if (!plan_overworld_route(maps, pewter, RouteGoal{nurse, Direction::NORTH})){ + return "No route from Pewter City over Route 3 to Route 4's Pokemon Center."; + } + return true; +} + +// A planned step walks where its map doesn't let the player run, and only +// there: out of Pewter's Pokemon Center to the Gym. +UnitTestResult test_walk_only_indoors(){ + const std::vector maps = overworld_maps(); + MapPosition from{"PewterCity_PokemonCenter_1F", map_point(maps, "PewterCity_PokemonCenter_1F", "nurse_front")}; + const std::optional> route = plan_overworld_route( + maps, from, RouteGoal{MapPosition{"PewterCity", map_point(maps, "PewterCity", "gym_front")}, Direction::NORTH} + ); + if (!route){ + return "No route from Pewter's Pokemon Center to the Gym."; + } + bool indoors = false; + bool outdoors = false; + for (const RouteStep& step : *route){ + const bool in_center = from.map == "PewterCity_PokemonCenter_1F"; + if (step.action == RouteAction::WALK && step.walk_only != in_center){ + return "Wrong walk_only on " + to_string(step) + ", from " + to_string(from) + "."; + } + indoors = indoors || in_center; + outdoors = outdoors || !in_center; + from = step.end; + } + if (!indoors || !outdoors){ + return "Expected steps inside the Center and outside."; + } + const std::optional hold = hold_to_wall(maps, {"PewterCity_PokemonCenter_1F", {7, 4}}, false, Direction::WEST); + if (!hold || !hold->walk_only){ + return "Expected a hold to a wall in the Center to walk."; + } + return true; +} + +// From (7, 6) in Route 4's Pokemon Center to the salesman, no leg holds +// west along row 6: the escalator at (1, 6) rides up to 2F, which isn't +// loaded (console B, 2026-11-02, "west 5 (to wall)"). +UnitTestResult test_route4_center_escalator(){ + const std::vector maps = overworld_maps(); + const MapPosition start{"Route4_PokemonCenter_1F", {7, 6}}; + const MapPosition salesman{"Route4_PokemonCenter_1F", {2, 3}}; + if (hold_to_wall(maps, start, false, Direction::WEST)){ + return "Expected no hold west from (7, 6) along the escalator's row."; + } + const std::optional> route = plan_overworld_route(maps, start, RouteGoal{salesman, Direction::WEST}); + if (!route || !(follow_overworld_route(maps, start, *route) == salesman)){ + return "Expected a route from (7, 6) to the salesman."; + } + for (const RouteStep& step : *route){ + if (step.to_wall && step.direction == Direction::WEST && step.end.point == TilePos{2, 6}){ + return "Expected no hold west next to the escalator: " + to_string(step); + } + } + 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"({ @@ -236,6 +328,111 @@ UnitTestResult test_no_hold_onto_escalator(){ return true; } + +// Whether the player, `walked` tiles into `step` from `at` when stopped, +// is found again and walked back to the leg's end. +UnitTestResult check_found_again( + const std::vector& maps, const MapPosition& at, const RouteStep& step, WalkedTiles walked +){ + const std::vector candidates = stop_candidates(maps, at, step, walked); + const std::optional anchor = plan_reanchor(maps, candidates, step); + if (!anchor || !(follow_overworld_route(maps, anchor->found, anchor->back) == step.end)){ + return std::format( + "Not found again on {} from {}, stopped {} to {} tiles in ({} candidates).", + to_string(step), to_string(at), walked.min, walked.max, candidates.size() + ); + } + return true; +} + +// Every open leg from `start` to `goal`, stopped wherever the timing may +// put it, walking or running, or anywhere on it: the player is found again. +// A leg to a warp off the grass is held on to its warp instead. +UnitTestResult check_found_again(const std::vector& maps, const MapPosition& start, const MapPosition& goal){ + const std::optional> route = plan_overworld_route(maps, start, RouteGoal{goal, std::nullopt}); + if (!route){ + return "No route from " + to_string(start) + "."; + } + MapPosition at = start; + for (const RouteStep& step : *route){ + std::vector stops; + if (step.action == RouteAction::WALK && !step.to_wall && !(step.warps && !step.wild)){ + stops.push_back(whole_leg(step)); + for (int estimate = 0; estimate <= step.tiles; estimate++){ + stops.push_back(walked_near(step, estimate, std::chrono::milliseconds(267))); + stops.push_back(walked_near(step, estimate, std::chrono::milliseconds(133))); + } + } + for (const WalkedTiles& walked : stops){ + const UnitTestResult result = check_found_again(maps, at, step, walked); + if (result.result != UnitTestResult::PASSED){ + return result; + } + } + at = step.end; + } + return true; +} + +// 00.11's way from Pewter into Route 3 and 00.12's over Route 3 and 4. +UnitTestResult test_found_again_route3_route4(){ + const std::vector maps = overworld_maps(); + const UnitTestResult into_route3 = check_found_again(maps, {"PewterCity", {17, 26}}, {"Route3", {13, 8}}); + if (into_route3.result != UnitTestResult::PASSED){ + return into_route3; + } + return check_found_again(maps, {"Route3", {36, 8}}, {"Route4_PokemonCenter_1F", {7, 4}}); +} + +// A leg off the grass that crosses one trainer's sight, on the maps the +// story walks: a stop on it is that trainer's, on the tile they see, and +// they stand next to the player afterwards. +UnitTestResult test_trainer_stops(){ + const std::vector maps = overworld_maps(); + struct Case{ + const char* name; + MapPosition start; + Direction direction; + int tiles; + bool to_wall; + MapPosition player; + MapPosition trainer; + }; + const Case cases[] = { + { + .name = "Route 3, Lass Robin, east along row 9 (00.12)", + .start = {"Route3", {36, 9}}, .direction = Direction::EAST, .tiles = 11, .to_wall = true, + .player = {"Route3", {40, 9}}, .trainer = {"Route3", {40, 10}}, + }, + { + .name = "Viridian Forest, the Bug Catcher at (47, 45), north up column 42", + .start = {"ViridianForest", {42, 61}}, .direction = Direction::NORTH, .tiles = 17, .to_wall = false, + .player = {"ViridianForest", {42, 45}}, .trainer = {"ViridianForest", {43, 45}}, + }, + }; + for (const Case& c : cases){ + RouteStep step; + step.direction = c.direction; + step.tiles = c.tiles; + step.to_wall = c.to_wall; + step.end = c.start; + step.end.point = TilePos{ + c.start.point.x + (c.direction == Direction::EAST ? c.tiles : 0), + c.start.point.y - (c.direction == Direction::NORTH ? c.tiles : 0), + }; + const std::vector candidates = stop_candidates(maps, c.start, step, whole_leg(step)); + if (candidates.size() != 1 || !(candidates[0].player == c.player) || !candidates[0].trainer || !(candidates[0].trainer->at == c.trainer)){ + return std::format("{}: expected one stop, at {} with the trainer at {}; got {} candidates.", + c.name, to_string(c.player), to_string(c.trainer), candidates.size()); + } + const std::optional anchor = plan_reanchor(maps, candidates, step); + if (!anchor || !anchor->holds.empty() || !(follow_overworld_route(maps, c.player, anchor->back) == step.end)){ + return std::string(c.name) + ": expected a way on from the stop, with no holds."; + } + } + return true; +} + } @@ -247,8 +444,13 @@ 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("Route 3, Route 4 and its Pokemon Center", test_route3_route4_maps); + database.add("walks where running isn't allowed", test_walk_only_indoors); + database.add("Route 4's Pokemon Center escalator", test_route4_center_escalator); database.add("trainer sight", test_trainer_sight); database.add("no hold onto an escalator", test_no_hold_onto_escalator); + database.add("found again on Route 3 and 4", test_found_again_route3_route4); + database.add("trainer stops on the story's maps", test_trainer_stops); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldReanchor.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldReanchor.cpp index 27b28bb54d..4c162db4bf 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldReanchor.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldReanchor.cpp @@ -177,6 +177,7 @@ std::optional, RouteStep>> hold_all( add_unique(ends, Hypothesis{position.world, wall->end}); hold.tiles = std::max(hold.tiles, wall->tiles); hold.wild = hold.wild || wall->wild; + hold.walk_only = hold.walk_only || wall->walk_only; hold.end = wall->end; } return std::make_pair(std::move(ends), hold); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp index 6e63bc8ed4..89262939fb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp @@ -350,6 +350,7 @@ RouteStep to_route_step(const std::vector& maps, const Pokemon::Leg hold_to_wall( ){ std::optional player = locate(maps, from, surfing); WallHold hold; + hold.walk_only = player && !maps[player->map].allow_running; 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}; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h index ce5d6f872b..900862e44e 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h @@ -49,6 +49,9 @@ struct RouteStep{ bool warps = false; // WALK: on the water, where the player moves twice as fast. bool surfing = false; + // WALK: on a map where the game doesn't let the player run (indoors, + // MapData::allow_running): B held there still walks. + bool walk_only = 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; @@ -110,12 +113,13 @@ std::optional> plan_overworld_route( ); // 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. +// stops the player, how many tiles on, whether any tile on the way is tall +// grass or water, and whether the map lets the player run. struct WallHold{ MapPosition end; int tiles = 0; bool wild = false; + bool walk_only = 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 diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp index 348b57bcf6..e9b9f55bba 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.cpp @@ -179,15 +179,19 @@ void hold_dpad_running(ProControllerContext& context, Direction direction, Milli pbf_wait(context, STEP_RELEASE); } +MoveSpeed step_speed(const RouteStep& step, MoveSpeed speed){ + return step.walk_only ? MoveSpeed::WALK : speed; +} + Milliseconds tile_time(const RouteStep& step, MoveSpeed speed){ if (step.surfing){ return SURF_TILE_TIME; } - return speed == MoveSpeed::RUN ? RUN_TILE_TIME : TILE_TIME; + return step_speed(step, speed) == MoveSpeed::RUN ? RUN_TILE_TIME : TILE_TIME; } Pokemon::LegMover leg_mover(const RouteStep& step, MoveSpeed speed){ - if (speed == MoveSpeed::RUN && !step.surfing){ + if (step_speed(step, speed) == MoveSpeed::RUN && !step.surfing){ return hold_dpad_running; } return hold_dpad; @@ -203,7 +207,7 @@ std::string speed_note(const RouteStep& step, MoveSpeed speed){ } return std::format( "[Speed] {} {}: {} tiles in {} ms, held {} ms", - move_speed_name(speed), Pokemon::direction_name(step.direction), step.tiles, + move_speed_name(step_speed(step, speed)), Pokemon::direction_name(step.direction), step.tiles, (tile_time(step, speed) * step.tiles).count(), leg_hold_time(step, speed).count() ); } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h index 2c3b665033..6ea5c1542f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h @@ -128,12 +128,17 @@ void hold_dpad(ProControllerContext& context, Direction direction, Milliseconds // Turn taps go without B: a tap only turns the player. void hold_dpad_running(ProControllerContext& context, Direction direction, Milliseconds duration); +// The speed `step` moves at when the walker goes at `speed`: a walk where +// the map doesn't let the player run (RouteStep::walk_only). +MoveSpeed step_speed(const RouteStep& step, MoveSpeed speed); + // How long one tile of `step` takes at `speed`: on the water, the Surf -// pace whatever the speed. +// pace whatever the speed; where running isn't allowed, the walking pace. Milliseconds tile_time(const RouteStep& step, MoveSpeed speed); -// The mover for `step` at `speed`: hold_dpad_running() for a run on foot, -// hold_dpad() otherwise (B does nothing on the water). +// The mover for `step` at `speed`: hold_dpad_running() for a run on foot +// where the map allows it, hold_dpad() otherwise (B does nothing on the +// water). Pokemon::LegMover leg_mover(const RouteStep& step, MoveSpeed speed); // How long the walker holds the D-pad for a WALK `step` at `speed` diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk_Tests.cpp index 8265cb6bd2..0e88570121 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk_Tests.cpp @@ -45,6 +45,10 @@ struct HoldCase{ Milliseconds hold; // speed_note()'s line, or empty. std::string note; + // On a map where the player can't run (a Pokemon Center). + bool walk_only = false; + // Whether the leg is held with B. + bool runs = false; }; // An open leg lets go half a tile before its last step would end; a leg @@ -57,9 +61,13 @@ const std::vector& hold_cases(){ {.name = "walk, to a wall", .speed = MoveSpeed::WALK, .tiles = 5, .to_wall = true, .surfing = false, .hold = Milliseconds(7 * 267), .note = "[Speed] walk west: 5 tiles in 1335 ms, held 1869 ms"}, {.name = "run, open", .speed = MoveSpeed::RUN, .tiles = 5, .to_wall = false, .surfing = false, - .hold = Milliseconds(4 * 133 + 66), .note = ""}, + .hold = Milliseconds(4 * 133 + 66), .note = "", .runs = true}, {.name = "run, to a wall", .speed = MoveSpeed::RUN, .tiles = 40, .to_wall = true, .surfing = false, - .hold = Milliseconds(42 * 133), .note = "[Speed] run west: 40 tiles in 5320 ms, held 5586 ms"}, + .hold = Milliseconds(42 * 133), .note = "[Speed] run west: 40 tiles in 5320 ms, held 5586 ms", .runs = true}, + {.name = "run, indoors: walks", .speed = MoveSpeed::RUN, .tiles = 5, .to_wall = true, .surfing = false, + .hold = Milliseconds(7 * 267), .note = "[Speed] walk west: 5 tiles in 1335 ms, held 1869 ms", .walk_only = true}, + {.name = "run, indoors, open: walks", .speed = MoveSpeed::RUN, .tiles = 5, .to_wall = false, .surfing = false, + .hold = Milliseconds(4 * 267 + 133), .note = "", .walk_only = true}, {.name = "run, surfing to a wall", .speed = MoveSpeed::RUN, .tiles = 3, .to_wall = true, .surfing = true, .hold = Milliseconds(5 * 133), .note = ""}, {.name = "walk, surfing", .speed = MoveSpeed::WALK, .tiles = 3, .to_wall = false, .surfing = true, @@ -68,12 +76,20 @@ const std::vector& hold_cases(){ return cases; } +// Whether `mover` is hold_dpad_running(), which holds B. +bool holds_b(const Pokemon::LegMover& mover){ + using Mover = void (*)(ProControllerContext&, Direction, Milliseconds); + const Mover* target = mover.target(); + return target != nullptr && *target == hold_dpad_running; +} + UnitTestResult check_hold(const HoldCase& test){ RouteStep step; step.direction = Direction::WEST; step.tiles = test.tiles; step.to_wall = test.to_wall; step.surfing = test.surfing; + step.walk_only = test.walk_only; const Milliseconds hold = leg_hold_time(step, test.speed); if (hold != test.hold){ return std::format("Expected a hold of {}ms, got {}ms.", test.hold.count(), hold.count()); @@ -82,6 +98,9 @@ UnitTestResult check_hold(const HoldCase& test){ if (note != test.note){ return "Expected the note \"" + test.note + "\", got \"" + note + "\"."; } + if (holds_b(leg_mover(step, test.speed)) != test.runs){ + return test.runs ? "Expected the leg held with B." : "Expected the leg held without B."; + } return true; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index a39e555328..d5df6173eb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -354,6 +354,7 @@ std::optional> fixed_route( step.direction = leg.direction; step.tiles = leg.tiles; step.facing_after = leg.direction; + step.walk_only = !map->allow_running; for (int c = 0; c < leg.tiles; c++){ const StepKind kind = classify_step(*map, player, leg.direction); const TilePos next = player.position.next(leg.direction); diff --git a/devtools/maps/frlg_maps.py b/devtools/maps/frlg_maps.py index 3a4ef4a25a..f0fd8b921a 100644 --- a/devtools/maps/frlg_maps.py +++ b/devtools/maps/frlg_maps.py @@ -4,21 +4,24 @@ Usage: python3 devtools/maps/frlg_maps.py --out SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/Maps \ - CeruleanCity_PokemonCenter_1F CeruleanCity Route24 \ - CeruleanCave_1F CeruleanCave_2F CeruleanCave_B1F + Route3 Route4 Route4_PokemonCenter_1F 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 /.json in the schema of Pokemon::MapData (Pokemon_MapData.h). +A map whose header doesn't allow running (indoors) says so; a trainer has +their sight and the ways they look. 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 +Without map names, the maps are the ones already in --out; with them, those +maps are added to the ones in --out, so warps and connections still join +them all. --check writes 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. """ @@ -70,6 +73,8 @@ 'PewterCity': {'gym_front': (15, 17)}, 'PewterCity_PokemonCenter_1F': {'nurse_front': (7, 4)}, 'PewterCity_Gym': {'brock_front': (6, 6)}, + # The Magikarp salesman is at (1, 3), west of `salesman_front`. + 'Route4_PokemonCenter_1F': {'nurse_front': (7, 4), 'salesman_front': (2, 3)}, # 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. @@ -189,12 +194,50 @@ def wander_box(obj, tiles): } +# Which way a person stands, by how they move. +FACINGS = { + 'MOVEMENT_TYPE_FACE_UP': 'north', 'MOVEMENT_TYPE_FACE_DOWN': 'south', + 'MOVEMENT_TYPE_FACE_LEFT': 'west', 'MOVEMENT_TYPE_FACE_RIGHT': 'east', +} +# The ways a trainer who turns looks. A trainer who moves some other way +# (wanders, looks around) may look any way. +TURNING_LOOKS = { + 'MOVEMENT_TYPE_FACE_DOWN_AND_UP': ['south', 'north'], + 'MOVEMENT_TYPE_FACE_LEFT_AND_RIGHT': ['west', 'east'], + 'MOVEMENT_TYPE_FACE_UP_AND_LEFT': ['north', 'west'], + 'MOVEMENT_TYPE_FACE_UP_AND_RIGHT': ['north', 'east'], + 'MOVEMENT_TYPE_FACE_DOWN_AND_LEFT': ['south', 'west'], + 'MOVEMENT_TYPE_FACE_DOWN_AND_RIGHT': ['south', 'east'], + 'MOVEMENT_TYPE_WANDER_UP_AND_DOWN': ['north', 'south'], + 'MOVEMENT_TYPE_WANDER_LEFT_AND_RIGHT': ['west', 'east'], +} +ALL_LOOKS = ['north', 'east', 'south', 'west'] + + +def trainer(obj): + """A trainer's sight and, unless they only face one way, the ways they + look; None for anyone who doesn't battle on sight.""" + sight = int(obj.get('trainer_sight_or_berry_tree_id') or 0) + if obj.get('trainer_type') != 'TRAINER_TYPE_NORMAL' or sight < 1: + return None + movement = obj.get('movement_type', '') + if movement in FACINGS: + return {'sight': sight} + return {'sight': sight, 'looks': TURNING_LOOKS.get(movement, ALL_LOOKS)} + + 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 + sight = trainer(obj) + if sight: + # A trainer who faces one way looks that way. + if 'looks' not in sight: + data['facing'] = FACINGS[obj['movement_type']] + data['trainer'] = sight flag = obj.get('flag') or '0' if flag != '0': data['hide_flag'] = flag @@ -251,6 +294,7 @@ def map_json(decomp, name, sources, layouts, names, loaded, unhandled): data = { 'name': name, 'source': {'decomp_file': f'data/maps/{name}/map.json', 'revision': COMMIT, 'date': COMMIT_DATE}, + 'allow_running': source.get('allow_running', True), 'tiles': tiles, 'elevation': elevation, 'points': points, 'warps': [warp(event, entries, loaded, sources) for event in warp_events], @@ -267,6 +311,8 @@ def map_json(decomp, name, sources, layouts, names, loaded, unhandled): } if ground_only(tiles, elevation): del data['elevation'] + if data['allow_running']: + del data['allow_running'] return data @@ -284,8 +330,8 @@ def main(): 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 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 os.path.isdir(args.out): + args.maps = sorted(set(args.maps) | {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') diff --git a/devtools/maps/tests/test_frlg_maps.py b/devtools/maps/tests/test_frlg_maps.py new file mode 100644 index 0000000000..70256f8216 --- /dev/null +++ b/devtools/maps/tests/test_frlg_maps.py @@ -0,0 +1,40 @@ +import unittest + +from devtools.maps import frlg_maps + +TILES = ['.....'] * 5 + + +def event(**fields): + obj = {'graphics_id': 'OBJ_EVENT_GFX_BUG_CATCHER', 'x': 2, 'y': 2, 'movement_type': 'MOVEMENT_TYPE_FACE_RIGHT', + 'movement_range_x': 1, 'movement_range_y': 1, 'trainer_type': 'TRAINER_TYPE_NORMAL', + 'trainer_sight_or_berry_tree_id': '3', 'flag': '0'} + obj.update(fields) + return obj + + +class TrainerTest(unittest.TestCase): + def test_facing_trainer_looks_ahead(self): + data = frlg_maps.map_object(event(), TILES) + self.assertEqual(data['facing'], 'east') + self.assertEqual(data['trainer'], {'sight': 3}) + + def test_wandering_trainer_looks_both_ways(self): + data = frlg_maps.map_object(event(movement_type='MOVEMENT_TYPE_WANDER_UP_AND_DOWN'), TILES) + self.assertNotIn('facing', data) + self.assertEqual(data['trainer'], {'sight': 3, 'looks': ['north', 'south']}) + self.assertEqual(data['wander'], {'x0': 2, 'y0': 1, 'x1': 2, 'y1': 3}) + + def test_trainer_looking_around_looks_every_way(self): + data = frlg_maps.map_object(event(movement_type='MOVEMENT_TYPE_LOOK_AROUND'), TILES) + self.assertEqual(data['trainer']['looks'], frlg_maps.ALL_LOOKS) + + def test_others_are_no_trainers(self): + for fields in ({'trainer_type': 'TRAINER_TYPE_NONE'}, {'trainer_sight_or_berry_tree_id': '0'}): + data = frlg_maps.map_object(event(**fields), TILES) + self.assertNotIn('trainer', data) + self.assertNotIn('facing', data) + + +if __name__ == '__main__': + unittest.main()