From 875e3b4639d6e4e592e425c0faae0eb68507ea5b Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 15 Nov 2026 16:13:39 -0800 Subject: [PATCH 1/3] FRLG AutoStory: a lint that every Center trip from Fly on flies The user's rule (2026-11-15): once the Pidgey knows Fly (10.01), every trip to a Pokemon Center flies unless the Center is really close, such as Cinnabar Gym to Cinnabar's Center. The new test plans each row's routes from its start and checks each trip that ends at a Center step or in front of a Center's door: no more than 20 tiles walked after its last Fly, and a trip out of a building an Escape Rope works in (pokefirered map.json allow_escaping) leaves it by rope when the walk out is longer. Cinnabar's two walks and Indigo Plateau (no Fly point before the player steps onto it) are allowed, with reasons. It fails for now on 14.04b, 15.01, 17.04b and 18.02b. --- .../PokemonFRLG/PokemonFRLG_Tests.cpp | 1 + ...PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp | 332 ++++++++++++++++++ .../PokemonFRLG_AutoStoryRows_Tests.h | 2 + SerialPrograms/cmake/SourceFiles.cmake | 1 + 4 files changed, 336 insertions(+) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 274a4f8627..de92114f73 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -142,6 +142,7 @@ static void add_tests_AutoStoryRows(UnitTestDatabase& database){ add_tests_AutoStoryLaunch(database); add_tests_OverworldGateMaps(database); add_tests_AutoStorySaffronGym(database); + add_tests_AutoStoryFlyToCenter(database); } // The detectors and readers of battle, box, party and dialog screens. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp new file mode 100644 index 0000000000..c5bb095a93 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp @@ -0,0 +1,332 @@ +/* AutoStory Fly To Center Tests + * + * From: https://github.com/PokemonAutomation/ + * + * A lint over FRLG's story from 10.01, where the Pidgey learns Fly, on: + * every trip to a Pokemon Center flies there unless the Center is really + * close (user, 2026-11-15: "as soon as we can fly, every to_pc action + * should be a fly unless it's really close (cinnabar gym to cinnabar + * PC)"), and a trip that starts in a building an Escape Rope works in + * leaves it by rope. The routes are planned as the program plans them, + * each row from its own start. + * + */ + +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" +#include "PokemonFRLG_AutoStoryEvents.h" +#include "PokemonFRLG_AutoStoryItemUse.h" +#include "PokemonFRLG_AutoStoryPacedRoute.h" +#include "PokemonFRLG_AutoStoryRooms.h" +#include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" +#include "PokemonFRLG_AutoStoryTable.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// The row that teaches Fly; the lint starts there. +constexpr std::string_view FIRST_FLY_ROW = "10.01"; + +// A walk to a Center this many tiles or fewer stays a walk. A Fly costs +// about 10 s of menus and animation, more than 20 tiles of running, but +// the long walks are the ones that re-planned and failed on console B +// (2026-11-15: 18.02b's 80 tiles round Saffron's blocks). 20 keeps a walk +// down one street (Fuchsia's Warden's house to its Center, 8 tiles) and +// flags every walk across a town (Viridian Gym to its Center, 58 tiles). +constexpr int MAX_WALK_TO_CENTER = 20; + +// The story's maps from 10.01 on that let an Escape Rope work (pokefirered +// map.json: allow_escaping true). +const std::set>& escape_rope_maps(){ + static const std::set> MAPS{ + "PokemonMansion_1F", "PokemonMansion_3F", "PokemonMansion_B1F", + "PokemonTower_2F", "PokemonTower_3F", "PokemonTower_4F", "PokemonTower_5F", "PokemonTower_6F", "PokemonTower_7F", + "SaffronCity_Gym", + "SilphCo_3F", "SilphCo_5F", "SilphCo_7F", "SilphCo_11F", + "VictoryRoad_1F", "VictoryRoad_2F", "VictoryRoad_3F", + }; + return MAPS; +} + +// A Center visit that walks the whole way, and why that is right. +struct CloseCenter{ + std::string_view row; + std::string_view step; + std::string_view why; +}; + +const CloseCenter CLOSE_CENTERS[] = { + {"14.01", "cinnabar_nurse", + "Cinnabar Island: the Mansion's door (8, 4) to the Center's (14, 11) across the island's square, as close as the Gym's"}, + {"14.02b", "cinnabar_nurse", + "Cinnabar Gym's door to Cinnabar's Center, the user's own \"really close\" (2026-11-15)"}, + {"19.05", "indigo_nurse", + "Indigo Plateau is no Fly point until the player first steps onto it (IndigoPlateau_Exterior's setworldmapflag), " + "and from its south edge the Center's door is 12 tiles straight north"}, +}; + +bool close_center(std::string_view row, std::string_view step){ + for (const CloseCenter& close : CLOSE_CENTERS){ + if (close.row == row && close.step == step){ + return true; + } + } + return false; +} + +// The nurse, the Center's script in, or a walk up to her. +bool is_center_step(const StoryStep& step){ + return step.kind == StoryStepKind::HEAL || step.action == CENTER_ENTER_VARIANT || step.name.ends_with("_nurse"); +} + +// A step that moves the player without a menu or a talk in between. +bool moves(const StoryStep& step){ + static const std::set> GAME_MOVES{ + "fly", "use_item", "cut_tree", "push_boulder", "lift_floor", "surf", "ride_bike", + }; + if (is_center_step(step)){ + return false; + } + switch (step.kind){ + case StoryStepKind::ROUTE: + case StoryStepKind::LEGS: + case StoryStepKind::STEP: + return true; + case StoryStepKind::GAME: + return GAME_MOVES.contains(step.action); + default: + return false; + } +} + +// A Fly or an Escape Rope: the player lands elsewhere without walking. +bool hops(const StoryStep& step){ + return step.action == "fly" || parse_use_item_step(step) == "escape-rope"; +} + +// The maps, doors and rules a row's routes are planned on. +struct RowPlanning{ + const std::vector& maps; + Pokemon::GateState gates; + Pokemon::GateRules rules; +}; + +// One step of a row: where it starts, if known, and the tiles it walks. +struct StepWalk{ + std::optional from; + int tiles = 0; + std::string failure; +}; + +int route_tiles(const std::vector& route){ + int tiles = 0; + for (const RouteStep& leg : route){ + tiles += leg.action == RouteAction::WALK ? leg.tiles : 0; + } + return tiles; +} + +// `step` walked from `walk.from`: its tiles into `walk`. Where it leaves +// the player, if known. +std::optional walk_step(const RowPlanning& planning, const StoryStep& step, StepWalk& walk){ + std::optional at = walk.from; + if (at && (step.kind == StoryStepKind::ROUTE || step.kind == StoryStepKind::LEGS)){ + const std::optional> route = walked_route(*at, step, planning.maps, planning.gates, planning.rules); + if (!route){ + walk.failure = std::format("{}: no route from {}.", step.name, to_string(MapPosition{at->map, at->tile})); + at.reset(); + }else if (!route->empty()){ + walk.tiles = route_tiles(*route); + at = StoryPose{route->back().end.map, route->back().end.point, route->back().facing_after}; + } + }else if (at && step.kind == StoryStepKind::STEP){ + const Direction direction = Pokemon::story_arg(step.args, "direction"); + walk.tiles = 1; + at = StoryPose{at->map, at->tile.next(direction), direction}; + } + if (step.pose_after){ + at = story_pose(Pokemon::pose_of(*step.pose_after)); + } + return at; +} + +// Each of `row`'s steps walked in turn from the row's start, on the maps +// of its start flags. +std::vector walk_row(const StoryCheckpoint& row){ + const std::set flags(row.start_flags.begin(), row.start_flags.end()); + const RowPlanning planning{ + .maps = run_story_maps(flags), + .gates = row.start_gates.value_or(Pokemon::GateState()), + .rules = Pokemon::GateRules{.card_key_held = flags.contains("card_key_held")}, + }; + std::vector walks; + std::optional at = story_pose(Pokemon::pose_of(*row.start)); + for (const StoryStep& step : row.steps){ + walks.push_back(StepWalk{.from = at}); + at = walk_step(planning, step, walks.back()); + } + return walks; +} + +// The first step of the trip that ends before step `end`: the run of +// steps that only move the player. +size_t trip_start(const StoryCheckpoint& row, size_t end){ + size_t start = end; + while (start > 0 && moves(row.steps[start - 1])){ + start--; + } + return start; +} + +// The trip that ends before row `row`'s step `center` (a Center step, or +// the row's end) checked: an offender line, or empty. +std::string check_trip(const StoryCheckpoint& row, const std::vector& walks, size_t center){ + const size_t start = trip_start(row, center); + const std::optional& from = walks[start].from; + const bool in_rope_building = from && escape_rope_maps().contains(from->map); + int since_hop = 0; + int before_hop = 0; + bool hopped = false; + for (size_t c = start; c < center; c++){ + if (!walks[c].failure.empty()){ + return std::format("{}/{}", row.id, walks[c].failure); + } + if (hops(row.steps[c])){ + hopped = true; + since_hop = 0; + continue; + } + since_hop += walks[c].tiles; + before_hop += hopped ? 0 : walks[c].tiles; + } + const std::string step = center < row.steps.size() ? row.steps[center].name : "end"; + if (in_rope_building && before_hop > MAX_WALK_TO_CENTER){ + return std::format("{}/{}: walks {} tiles out of {}, where an Escape Rope works, then to the Center: use an Escape Rope and Fly.", row.id, step, before_hop, from->map); + } + if (since_hop > MAX_WALK_TO_CENTER && !close_center(row.id, step)){ + return std::format("{}/{}: walks {} tiles to the Center{}: Fly there.", row.id, step, since_hop, hopped ? " after its last Fly" : ""); + } + return ""; +} + +// The tile in front of a Pokemon Center's door: one below a warp into a +// Center. +bool below_center_door(const std::vector& maps, const StoryPose& at){ + for (const MapData& map : maps){ + if (map.name != at.map){ + continue; + } + for (const MapWarp& warp : map.warps){ + if (warp.to && warp.to->map.find("PokemonCenter") != std::string::npos && warp.x == at.tile.x && warp.y + 1 == at.tile.y){ + return true; + } + } + } + return false; +} + +// Where each Center trip of `row` ends: the first of a run of Center +// steps, or the step after a walk that ends in front of a Center's door +// with no Center step after it (the next row goes in). +std::vector center_trip_ends(const StoryCheckpoint& row, const std::vector& walks){ + std::vector ends; + const std::vector& steps = row.steps; + for (size_t c = 0; c < steps.size(); c++){ + if (is_center_step(steps[c]) && (c == 0 || !is_center_step(steps[c - 1]))){ + ends.push_back(c); + continue; + } + const bool trip_goes_on = c + 1 < steps.size() && (moves(steps[c + 1]) || is_center_step(steps[c + 1])); + const std::optional& after = c + 1 < walks.size() ? walks[c + 1].from : std::nullopt; + if (moves(steps[c]) && !trip_goes_on && after && below_center_door(story_maps(), *after)){ + ends.push_back(c + 1); + } + } + return ends; +} + +std::vector offenders_from(std::string_view first_row){ + std::vector offenders; + for (const StoryCheckpoint& row : story_checkpoints()){ + if (row.id < first_row || !row.start){ + continue; + } + const std::vector walks = walk_row(row); + for (size_t end : center_trip_ends(row, walks)){ + if (std::string offender = check_trip(row, walks, end); !offender.empty()){ + offenders.push_back(std::move(offender)); + } + } + } + return offenders; +} + +struct FlyToCenterInput{ + std::string_view first_row; +}; + +struct FlyToCenterExpectation{ + std::vector offenders; +}; + +struct FlyToCenterCase{ + std::string name; + FlyToCenterInput input; + FlyToCenterExpectation expectation; +}; + +class Test_AutoStoryFlyToCenter : public UnitTest{ +public: + explicit Test_AutoStoryFlyToCenter(FlyToCenterCase test_case) + : UnitTest(std::format("PokemonFRLG::AutoStory - Fly to Center: {}", test_case.name)) + , m_case(std::move(test_case)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + const std::vector offenders = offenders_from(m_case.input.first_row); + if (offenders == m_case.expectation.offenders){ + return true; + } + std::string message = std::format("{} offender(s), expected {}:", offenders.size(), m_case.expectation.offenders.size()); + for (const std::string& offender : offenders){ + message += " " + offender; + } + return message; + } + +private: + FlyToCenterCase m_case; +}; + +const FlyToCenterCase FLY_TO_CENTER_CASES[] = { + { + .name = "every Center trip from Fly on flies, or ropes out of a building", + .input = {.first_row = FIRST_FLY_ROW}, + .expectation = {.offenders = {}}, + }, +}; + +} // namespace + + +void add_tests_AutoStoryFlyToCenter(UnitTestDatabase& database){ + for (const FlyToCenterCase& item : FLY_TO_CENTER_CASES){ + database.add(item); + } +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h index 6c82e3a04a..586795c099 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h @@ -37,6 +37,8 @@ void add_tests_AutoStorySlope(UnitTestDatabase& database); void add_tests_AutoStorySafari(UnitTestDatabase& database); // Rows 14.03, 14.04 and 14.04b, Celadon Gym, on the overworld sim (PokemonFRLG_AutoStoryCeladonGym_Tests.cpp). void add_tests_AutoStoryCeladonGym(UnitTestDatabase& database); +// Every Center trip from 10.01 on flies, or ropes out of a building (PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp). +void add_tests_AutoStoryFlyToCenter(UnitTestDatabase& database); } // namespace PokemonFRLG } // namespace NintendoSwitch diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 39f0508f97..4d9ab81f47 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -2213,6 +2213,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyLanding.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyLanding.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyLanding_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFieldSteps.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFieldSteps.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFossil.h From bc324289310985f1e8b0d55934fa496508c3bb0b Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 15 Nov 2026 16:18:06 -0800 Subject: [PATCH 2/3] FRLG AutoStory: Fly to the Center from 14.04b, 15.01, 17.04b and 18.02b The Center trips the new lint flags, each now ending in a Fly to the town's heal spot below the Center's door and a turn to face it; the Center script step is unchanged. - 14.04b walked 79 tiles from Celadon Gym round the yard, through the regrown tree (40, 35) and up through the city. It now goes out of the gym's door onto (11, 31) and flies; the tree is left standing. - 15.01 walked 35 tiles from Route 7's gate guard round Saffron's Rocket Grunts. It now steps out of the gate onto Saffron (8, 27), which makes Saffron a Fly point (SaffronCity's setworldmapflag), and flies. - 17.04b walked 58 tiles from Viridian Gym's door north round the city's fences for a straight line of 26. It now flies from the door. - 18.02b walked about 40 tiles over Saffron Gym's four pads to its door. SaffronCity_Gym allows an Escape Rope (pokefirered map.json), so it now ropes out from Sabrina's room to below the gym's door (46, 13), where 16.06b's walk in set the escape warp, and flies. The bag's ropes go from 3 to 2. The plan goldens lose the walks and gain the short exits and turns; the sim tests of these rows run the Fly (and 18.02b's rope), and 18.02b's direct-walk test now expects nothing walked. --- .../PokemonFRLG_AutoStoryCeladonGym_Tests.cpp | 8 +- ...PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp | 21 +- .../PokemonFRLG_AutoStoryPlanGolden12.h | 15 +- .../PokemonFRLG_AutoStoryPlanGolden15.h | 6 +- .../PokemonFRLG_AutoStoryPlanGolden17.h | 9 +- .../PokemonFRLG_AutoStoryPlanGolden18.h | 18 -- .../PokemonFRLG_AutoStorySaffronGym_Tests.cpp | 63 +++--- .../PokemonFRLG_AutoStorySaffron_Tests.cpp | 8 +- .../PokemonFRLG_AutoStoryViridian_Tests.cpp | 6 +- .../AutoStory/StoryData/frlg-14.04b.plan.json | 25 +-- .../AutoStory/StoryData/frlg-15.01.plan.json | 26 ++- .../AutoStory/StoryData/frlg-17.04b.plan.json | 27 ++- .../AutoStory/StoryData/frlg-18.02b.plan.json | 185 ++---------------- 13 files changed, 146 insertions(+), 271 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp index 60c6605532..6c0792f7c4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladonGym_Tests.cpp @@ -200,9 +200,9 @@ std::string to_erika(StoryPose& at, OverworldSim& sim){ // 14.03 on the sim (to_erika()), then 14.04, Erika's battle, which ends // where it starts, then 14.04b on the same sim, the gym as 14.03 leaves it (Tamia on (2, 9), the inner tree cut): out along row // 5, a step onto the cut tree's tile, down column 1 past Tamia and -// column 2 to the wall, out of the gym, the tree again and back below -// the Center's door (the Center's way in and the nurse need the -// console), meeting no one else. +// column 2 to the wall, out of the gym's door and the Fly to below the +// Center's door (the Center's way in and the nurse need the console), +// meeting no one else. UnitTestResult test_gym_rows(){ StoryPose at = *story_pose(Pokemon::pose_of(*checkpoint("14.03").start)); OverworldSim sim(story_maps(), MapPosition{at.map, at.tile}, *at.facing); @@ -414,7 +414,7 @@ const AutoStoryCeladonGymCase AUTO_STORY_CELADON_GYM_CASES[] = { .expectation = {.description = "lands on Celadon's heal spot facing south, where the walk to the gym starts"}, }, { - .input = {.name = "14.03 to below Erika, 14.04 on the spot and 14.04b back to the nurse", .body = test_gym_rows}, + .input = {.name = "14.03 to below Erika, 14.04 on the spot and 14.04b out and by Fly to the nurse", .body = test_gym_rows}, .expectation = {.description = "Tamia and Lori fought where the table steps into their lines, no one else"}, }, { diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp index c5bb095a93..7659f7f162 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp @@ -137,15 +137,29 @@ int route_tiles(const std::vector& route){ return tiles; } +bool is_walk(const StoryStep& step){ + return step.kind == StoryStepKind::ROUTE || step.kind == StoryStepKind::LEGS; +} + +// Where a ROUTE ends whether or not it plans here: its target. A row's +// own steps may open what its start flags keep shut (a cut tree, a door), +// so a route outside a Center trip may not plan on them. +std::optional route_target(const StoryStep& step){ + if (step.kind != StoryStepKind::ROUTE){ + return std::nullopt; + } + return story_pose(Pokemon::pose_of(Pokemon::story_arg(step.args, "target"))); +} + // `step` walked from `walk.from`: its tiles into `walk`. Where it leaves // the player, if known. std::optional walk_step(const RowPlanning& planning, const StoryStep& step, StepWalk& walk){ std::optional at = walk.from; - if (at && (step.kind == StoryStepKind::ROUTE || step.kind == StoryStepKind::LEGS)){ + if (at && is_walk(step)){ const std::optional> route = walked_route(*at, step, planning.maps, planning.gates, planning.rules); if (!route){ walk.failure = std::format("{}: no route from {}.", step.name, to_string(MapPosition{at->map, at->tile})); - at.reset(); + at = route_target(step); }else if (!route->empty()){ walk.tiles = route_tiles(*route); at = StoryPose{route->back().end.map, route->back().end.point, route->back().facing_after}; @@ -202,6 +216,9 @@ std::string check_trip(const StoryCheckpoint& row, const std::vector& if (!walks[c].failure.empty()){ return std::format("{}/{}", row.id, walks[c].failure); } + if (!walks[c].from && is_walk(row.steps[c])){ + return std::format("{}/{}: where it starts is not known.", row.id, row.steps[c].name); + } if (hops(row.steps[c])){ hopped = true; since_hop = 0; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h index 4f7451e9f4..66a9190178 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden12.h @@ -166,21 +166,10 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_12_CELADON[] = { "14.03 walk north 7 -> CeladonCity_Gym (2, 11) [walk only]", "14.03 below_erika from CeladonCity_Gym (6, 5) facing east to CeladonCity_Gym (6, 5) facing north", "14.03 face north -> CeladonCity_Gym (6, 5) [walk only]", - "14.04b below_gym_tree_out from CeladonCity_Gym (2, 18) facing south to CeladonCity (40, 36) facing north", + "14.04b out_of_gym from CeladonCity_Gym (2, 18) facing south to CeladonCity (11, 31) facing south", "14.04b walk east 4 -> CeladonCity_Gym (6, 18) [walk only] [tapped]", "14.04b walk south 1 (warp) -> CeladonCity (11, 31) [walk only]", - "14.04b walk south 6 (to wall) -> CeladonCity (11, 37)", - "14.04b walk east 30 (to wall) -> CeladonCity (41, 37)", - "14.04b walk north 1 (to wall) -> CeladonCity (41, 36)", - "14.04b walk west 1 -> CeladonCity (40, 36)", - "14.04b face north -> CeladonCity (40, 36)", - "14.04b celadon_below_center from CeladonCity (40, 35) facing north to CeladonCity (48, 12) facing north", - "14.04b walk north 3 -> CeladonCity (40, 32)", - "14.04b walk west 9 -> CeladonCity (31, 32)", - "14.04b walk north 8 (to wall) -> CeladonCity (31, 24)", - "14.04b walk east 12 -> CeladonCity (43, 24)", - "14.04b walk north 12 (to wall) -> CeladonCity (43, 12)", - "14.04b walk east 5 -> CeladonCity (48, 12)", + "14.04b celadon_below_center from CeladonCity (48, 12) facing south to CeladonCity (48, 12) facing north", "14.04b face north -> CeladonCity (48, 12)", }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden15.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden15.h index e52c74bd74..6e2c781fc5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden15.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden15.h @@ -31,12 +31,10 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_15[] = { "15.01 walk east 4 -> Route7_EastEntrance (5, 5)", "15.01 walk north 1 (to wall) -> Route7_EastEntrance (5, 4)", "15.01 face east -> Route7_EastEntrance (5, 4)", - "15.01 below_center_door from Route7_EastEntrance (6, 4) facing north to SaffronCity (24, 39) facing north", + "15.01 into_saffron from Route7_EastEntrance (6, 4) facing north to SaffronCity (8, 27) facing east", "15.01 walk south 1 -> Route7_EastEntrance (6, 5)", "15.01 walk east 6 (warp) -> SaffronCity (8, 27)", - "15.01 walk east 9 -> SaffronCity (17, 27)", - "15.01 walk south 12 -> SaffronCity (17, 39)", - "15.01 walk east 7 -> SaffronCity (24, 39)", + "15.01 below_center_door from SaffronCity (24, 39) facing south to SaffronCity (24, 39) facing north", "15.01 face north -> SaffronCity (24, 39)", }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h index d50829d6d9..2f9d11625b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h @@ -60,14 +60,7 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_17_GYM[] = { "17.04b walk south 8 (to wall) -> ViridianCity_Gym (18, 22) [walk only]", "17.04b walk west 1 -> ViridianCity_Gym (17, 22) [walk only] [tapped]", "17.04b walk south 1 (warp) -> ViridianCity (36, 11) [walk only]", - "17.04b below_center_door from ViridianCity (36, 11) facing south to ViridianCity (26, 27) facing north", - "17.04b walk east 5 (to wall) -> ViridianCity (41, 11)", - "17.04b walk north 7 (to wall) -> ViridianCity (41, 4)", - "17.04b walk west 13 (to wall) -> ViridianCity (28, 4)", - "17.04b walk south 4 (to wall) -> ViridianCity (28, 8)", - "17.04b walk west 6 -> ViridianCity (22, 8)", - "17.04b walk south 19 -> ViridianCity (22, 27)", - "17.04b walk east 4 -> ViridianCity (26, 27)", + "17.04b below_center_door from ViridianCity (26, 27) facing south to ViridianCity (26, 27) facing north", "17.04b face north -> ViridianCity (26, 27)", }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden18.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden18.h index c11e1d6a5c..566d9b212d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden18.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden18.h @@ -39,24 +39,6 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_18[] = { "18.01 below_sabrina from SaffronCity_Gym (18, 15) facing south to SaffronCity_Gym (14, 12) facing north", "18.01 walk west 4 -> SaffronCity_Gym (14, 15) [walk only]", "18.01 walk north 3 -> SaffronCity_Gym (14, 12) [walk only]", - "18.02b by_pad_out_of_sabrina from SaffronCity_Gym (14, 12) facing north to SaffronCity_Gym (17, 15) facing east", - "18.02b walk south 3 (to wall) -> SaffronCity_Gym (14, 15) [walk only]", - "18.02b walk east 3 -> SaffronCity_Gym (17, 15) [walk only]", - "18.02b by_pad_from_top_left from SaffronCity_Gym (0, 7) facing east to SaffronCity_Gym (0, 5) facing north", - "18.02b walk north 2 -> SaffronCity_Gym (0, 5) [walk only]", - "18.02b along_row_6 from SaffronCity_Gym (20, 7) facing north to SaffronCity_Gym (28, 6) facing east", - "18.02b walk north 1 -> SaffronCity_Gym (20, 6) [walk only]", - "18.02b walk east 8 (to wall) -> SaffronCity_Gym (28, 6) [walk only]", - "18.02b below_pad_from_top_right from SaffronCity_Gym (28, 6) facing east to SaffronCity_Gym (28, 5) facing north", - "18.02b walk north 1 -> SaffronCity_Gym (28, 5) [walk only]", - "18.02b by_pad_from_bottom_right from SaffronCity_Gym (20, 20) facing north to SaffronCity_Gym (28, 22) facing south", - "18.02b walk south 2 -> SaffronCity_Gym (20, 22) [walk only]", - "18.02b walk east 8 (to wall) -> SaffronCity_Gym (28, 22) [walk only]", - "18.02b face south -> SaffronCity_Gym (28, 22) [walk only]", - "18.02b out_of_gym from SaffronCity_Gym (18, 20) facing south to SaffronCity (46, 13) facing south", - "18.02b walk south 3 (to wall) -> SaffronCity_Gym (18, 23) [walk only]", - "18.02b walk west 4 -> SaffronCity_Gym (14, 23) [walk only] [tapped]", - "18.02b walk south 1 (warp) -> SaffronCity (46, 13) [walk only]", "18.02b below_center_door from SaffronCity (24, 39) facing south to SaffronCity (24, 39) facing north", "18.02b face north -> SaffronCity (24, 39)", "18.03 saffron_outside from SaffronCity_PokemonCenter_1F (7, 4) facing north to SaffronCity (24, 39) facing south", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffronGym_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffronGym_Tests.cpp index 766840dcc4..50f86e0e5a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffronGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffronGym_Tests.cpp @@ -4,8 +4,8 @@ * * Rows 18.01, 18.02 and 18.02b (StoryData/frlg-18.02*.plan.json ...) on the * overworld sim: Saffron Gym's teleport pads, from the door to the tile below - * Sabrina and back out to Saffron's Center, with no trainer met on the way; - * Sabrina's battle is a checkpoint of its own. Then 18.03, the Fly to + * Sabrina, with no trainer met on the way, and out by Escape Rope and Fly to + * Saffron's Center; Sabrina's battle is a checkpoint of its own. Then 18.03, the Fly to * Celadon's X items clerk and back to Saffron's Center. Last, that the * walks through Saffron and in and out of its buildings (16.06, 16.06b, * 18.02b) stay near the straight line and never cross a tile twice. @@ -29,6 +29,7 @@ #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" #include "PokemonFRLG_AutoStoryEvents.h" +#include "PokemonFRLG_AutoStoryItemUse.h" #include "PokemonFRLG_AutoStoryMartPlan.h" #include "PokemonFRLG_AutoStoryPacedRoute.h" #include "PokemonFRLG_AutoStoryRooms.h" @@ -86,12 +87,14 @@ const StoryCheckpoint& checkpoint(std::string_view id){ // Where each of `row`'s pad steps (the STEP steps, which are only ever // onto a pad here) leaves the player, in order, after running the row's -// steps (a Fly among them) on the sim up to (not including) its Center -// step, on the maps of its start flags. Fails with the row's message if a -// step does not run. +// steps (an Escape Rope and a Fly among them) on the sim up to (not +// including) its Center step, on the maps of its start flags. Fails with +// the row's message if a step does not run. struct PadWalk{ std::string failure; std::vector landings; + // Where an Escape Rope left the player, if the row used one. + std::optional rope_landing; MapPosition end; bool clean = false; }; @@ -100,7 +103,9 @@ PadWalk walk_pads(const StoryCheckpoint& row){ PadWalk walk; StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); const std::set flags(row.start_flags.begin(), row.start_flags.end()); - OverworldSim sim(run_story_maps(flags), MapPosition{at.map, at.tile}, *at.facing); + const std::vector& maps = run_story_maps(flags); + std::optional sim; + sim.emplace(maps, MapPosition{at.map, at.tile}, *at.facing); for (const StoryStep& step : row.steps){ if (step.action == CENTER_ENTER_VARIANT){ break; @@ -108,16 +113,24 @@ PadWalk walk_pads(const StoryCheckpoint& row){ if (step.kind == StoryStepKind::TALK || step.kind == StoryStepKind::BATTLE){ continue; } - walk.failure = row_step_on_sim(sim, at, step, row.id, flags); + // The Escape Rope's script has no map: the player stands where the + // step says, as in the Silph Co. tests. + if (parse_use_item_step(step) == "escape-rope"){ + at = *story_pose(Pokemon::pose_of(*step.pose_after)); + sim.emplace(maps, MapPosition{at.map, at.tile}, *at.facing); + walk.rope_landing = sim->state().position; + continue; + } + walk.failure = row_step_on_sim(*sim, at, step, row.id, flags); if (!walk.failure.empty()){ break; } if (step.kind == StoryStepKind::STEP){ - walk.landings.push_back(sim.state().position); + walk.landings.push_back(sim->state().position); } } - walk.end = sim.state().position; - walk.clean = sim.state().trainers_beaten.empty() && sim.state().violations.empty(); + walk.end = sim->state().position; + walk.clean = sim->state().trainers_beaten.empty() && sim->state().violations.empty(); return walk; } @@ -160,18 +173,20 @@ UnitTestResult test_sabrina_own_checkpoint(){ return true; } -// The way out (18.02b): the same pads the other way, each pair linked both -// ways, then the door onto Saffron City and the Fly to below the Center's door. -UnitTestResult test_pads_out_to_center(){ +// The way out (18.02b): an Escape Rope from Sabrina's room (SaffronCity_Gym +// allows it) to below the gym's door on Saffron City, then the Fly to below +// the Center's door; no pad is taken. +UnitTestResult test_rope_out_to_center(){ const PadWalk walk = walk_pads(checkpoint("18.02b")); if (!walk.failure.empty()){ return walk.failure; } - const std::vector expected{ - {"SaffronCity_Gym", {0, 7}}, {"SaffronCity_Gym", {20, 7}}, {"SaffronCity_Gym", {20, 20}}, {"SaffronCity_Gym", {18, 20}}, - }; - if (walk.landings != expected){ - return "18.02b: the pads did not land on (0, 7), (20, 7), (20, 20) and (18, 20), in that order."; + if (!walk.landings.empty()){ + return std::format("18.02b: took {} pad(s) on the way out.", walk.landings.size()); + } + const MapPosition below_gym_door{"SaffronCity", {46, 13}}; + if (!(walk.rope_landing == below_gym_door)){ + return "18.02b: no Escape Rope to below the gym's door (46, 13), where Fly can be used."; } const MapPosition below_center{"SaffronCity", {24, 39}}; if (!(walk.end == below_center)){ @@ -345,7 +360,7 @@ const DirectRow DIRECT_16_06{"16.06", {}}; // door and back (8 tiles), and row 39 is the Lass's walk (27..37, 39), a // row down and back (2 tiles). The fewest tiles there are 58. const DirectRow DIRECT_16_06B{"16.06b", {{"SaffronCity", 10}}}; -// 18.02b's pads, then only the entrance room to the Gym's door and the Fly. +// 18.02b walks nothing: Escape Rope out of the Gym, Fly to the Center. const DirectRow DIRECT_18_02B{"18.02b", {}}; int straight_line(const TilePos& from, const TilePos& to){ @@ -403,9 +418,9 @@ const AutoStorySaffronGymCase AUTO_STORY_SAFFRON_GYM_CASES[] = { .expectation = {.description = "18.02 ends with her battle; 18.02b starts in front of her"}, }, { - .name = "18.02b Saffron Gym's pads back out to the Center's door", - .input = {.body = test_pads_out_to_center}, - .expectation = {.description = "four pads the other way, out of the door, the Fly to below Saffron's Center door, nobody met"}, + .name = "18.02b Escape Rope out of Saffron Gym and Fly to the Center's door", + .input = {.body = test_rope_out_to_center}, + .expectation = {.description = "no pad, the rope to below the gym's door, the Fly to below Saffron's Center door, nobody met"}, }, { .name = "Saffron Gym: Cameron sees a walk along row 21", @@ -428,9 +443,9 @@ const AutoStorySaffronGymCase AUTO_STORY_SAFFRON_GYM_CASES[] = { .expectation = {.description = "62 tiles on Saffron City, within 1.2 times 58 (48 straight, 10 forced), no tile twice"}, }, { - .name = "18.02b walks direct: the pads, the Gym's door, Fly", + .name = "18.02b walks direct: Escape Rope and Fly", .input = {.body = []{ return test_direct_walks(DIRECT_18_02B); }}, - .expectation = {.description = "each room's walk its straight line, no tile twice"}, + .expectation = {.description = "no walk longer than 1.2 times its straight line, no tile twice"}, }, }; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffron_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffron_Tests.cpp index cb28448a99..ca6c128a0c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffron_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySaffron_Tests.cpp @@ -77,9 +77,9 @@ const StoryCheckpoint& checkpoint(std::string_view id){ } // 15.01 on the sim from Celadon's nurse: Route 7, the gate's top trigger -// (6, 4), where the TEA scene leaves the player, and Saffron City to below -// its Center's door; the way into the Center, which has no map, is the -// console's. No trainer is met. +// (6, 4), where the TEA scene leaves the player, out of the gate onto +// Saffron City and the Fly to below its Center's door; the way into the +// Center, which has no map, is the console's. No trainer is met. UnitTestResult test_route7_to_saffron(){ const StoryCheckpoint& row = checkpoint("15.01"); StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); @@ -188,7 +188,7 @@ UnitTestResult test_route7_gate_door_turn_tap(){ const AutoStorySaffronCase AUTO_STORY_SAFFRON_CASES[] = { { .input = {.name = "15.01 Route 7's gate with the TEA to Saffron's Center", .body = test_route7_to_saffron}, - .expectation = {.description = "onto the guard's trigger, below Saffron's Center door, nobody met"}, + .expectation = {.description = "onto the guard's trigger, out of the gate, the Fly to below Saffron's Center door, nobody met"}, }, { .input = {.name = "15.01 running, the crossing onto Route 7 not held up", .body = test_route7_gate_running_crossing_not_held_up}, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridian_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridian_Tests.cpp index a7ac100c5a..15dc8cc20b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridian_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridian_Tests.cpp @@ -188,8 +188,8 @@ UnitTestResult test_row_17_02(){ } // 17.04b after Giovanni's win: back through the gym past its beaten -// trainers (Takashi's line on row 3 among them), out of the door and to -// below the Center's door (26, 27). +// trainers (Takashi's line on row 3 among them), out of the door and the +// Fly to below the Center's door (26, 27). UnitTestResult test_row_17_04b(){ return walk_row("17.04b", "", "below_center_door", beaten_gym_maps(), MapPosition{"ViridianCity", {26, 27}}); } @@ -200,7 +200,7 @@ const AutoStoryViridianCase AUTO_STORY_VIRIDIAN_CASES[] = { .expectation = {.description = "Warren's battle won on (15, 7), no other trainer met"}, }, { - .input = {.name = "17.04b: out of the beaten gym to below Viridian's Center", .body = test_row_17_04b}, + .input = {.name = "17.04b: out of the beaten gym and by Fly to below Viridian's Center", .body = test_row_17_04b}, .expectation = {.description = "on ViridianCity (26, 27), no trainer met"}, }, { diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04b.plan.json index e9cb0619b1..045a0d46df 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04b.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-14.04b.plan.json @@ -3,7 +3,7 @@ "game": "frlg", "checkpoint": { "id": "14.04b", - "title": "Out of the gym past the tree, heal at Celadon's Center", + "title": "Out of the gym, Fly to Celadon's Center and heal", "start": {"map": "CeladonCity_Gym", "tiles": [[6, 5]], "facing": "north"}, "start_gates": {"opened": ["CeladonCity_Gym/cut_tree_3_5"]}, "events": [ @@ -53,23 +53,24 @@ "why": "run down the west aisle from (2, 10) to the wall at (2, 18): behind Lass Kay (3, 11), who looks east, and clear of Beauty Bridget's line (6..8, 10) that a planned way out through the middle crosses; all are beaten since Erika's win, and the wall stops any overshoot" }, { - "id": "below_gym_tree_out", + "id": "out_of_gym", "kind": "route", "action": "run", "args": { - "target": {"map": "CeladonCity", "tiles": [[40, 36]], "facing": "north"} + "target": {"map": "CeladonCity", "tiles": [[11, 31]], "facing": "south"} }, - "why": "east along row 18 and out of the gym's door (6, 18), down through the gap in the ledges to row 36 and east along it to below the tree (40, 35), grown back" + "why": "east along row 18 and out of the gym's door onto Celadon City below it (11, 31): Fly works outdoors only" }, { - "id": "cut_tree_out", + "id": "fly_celadon", "kind": "game_action", - "action": "cut_tree", + "action": "fly", "args": { - "direction": "north" + "town": "CeladonCity", + "species": "pidgey" }, - "declared_after": {"map": "CeladonCity", "tiles": [[40, 35]], "facing": "north"}, - "why": "the tree again; a step onto its tile" + "declared_after": {"map": "CeladonCity", "tiles": [[48, 12]], "facing": "south"}, + "why": "the Pidgey flies to Celadon City, landing below the Pokemon Center's door (48, 11) on its heal spot (pokefirered heal_locations.json, HEAL_LOCATION_CELADON_CITY), as 14.03; the yard's tree (40, 35), grown back, is left standing" }, { "id": "celadon_below_center", @@ -78,7 +79,7 @@ "args": { "target": {"map": "CeladonCity", "tiles": [[48, 12]], "facing": "north"} }, - "why": "north through the city to below the Center's door (48, 11)" + "why": "turn to face the Center's door (48, 11) from the landing" }, { "id": "celadon_nurse", @@ -99,8 +100,8 @@ "notes": { "checkpoint": [ "Starts in front of Erika, where 14.04 ends after her battle and saves.", - "Out the way in: row 5 over the inner tree's tile and column 1 to their walls, Tamia standing on (2, 9) where her battle left her, the inner tree (3, 5) still cut (a save keeps the map's objects and temp flags; only a warp clears them). Leaving the gym grows the yard's tree (40, 35) back, so it is cut again from below.", - "PokeGuy flies to Celadon from the gym instead (1:27:07, same-city Fly); the walk back stands in until a Fly step is in. Either way the row ends at the nurse, where 15.01 starts." + "Out the way in: row 5 over the inner tree's tile and column 1 to their walls, Tamia standing on (2, 9) where her battle left her, the inner tree (3, 5) still cut (a save keeps the map's objects and temp flags; only a warp clears them).", + "Out of the gym's door and by Fly to the Center's door, as PokeGuy (1:27:07, same-city Fly): the walk round the yard, through the regrown tree (40, 35) and up through the city was 79 tiles (user, 2026-11-15: every Center trip flies once Fly is learned, unless the Center is really close). The row ends at the nurse, where 15.01 starts." ] } }, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-15.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-15.01.plan.json index 1ccf50304d..488c2846ed 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-15.01.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-15.01.plan.json @@ -3,7 +3,7 @@ "game": "frlg", "checkpoint": { "id": "15.01", - "title": "Celadon to Saffron: the TEA to Route 7's gate guard, heal at Saffron's Center", + "title": "Celadon to Saffron: the TEA to Route 7's gate guard, Fly to Saffron's Center and heal", "start": {"map": "CeladonCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, "events": [ { @@ -39,6 +39,26 @@ "declared_after": {"map": "Route7_EastEntrance", "tiles": [[6, 4]], "facing": "north"}, "why": "the guard takes the TEA (FLAG_GOT_TEA, Route7_EastEntrance_EventScript_GiveTea), shares it and lets the player through: VAR_MAP_SCENE_ROUTE5_ROUTE6_ROUTE7_ROUTE8_GATES 1 shuts every gate's triggers (pokeguy 1:27:30 to 1:27:43)" }, + { + "id": "into_saffron", + "kind": "route", + "action": "run", + "args": { + "target": {"map": "SaffronCity", "tiles": [[8, 27]], "facing": "east"} + }, + "why": "east out of the gate into Saffron City (8, 27), which makes Saffron a Fly point (SaffronCity scripts.inc: setworldmapflag FLAG_WORLD_MAP_SAFFRON_CITY on the map's transition)" + }, + { + "id": "fly_saffron", + "kind": "game_action", + "action": "fly", + "args": { + "town": "SaffronCity", + "species": "pidgey" + }, + "declared_after": {"map": "SaffronCity", "tiles": [[24, 39]], "facing": "south"}, + "why": "the Pidgey flies to Saffron City, landing below the Pokemon Center's door (24, 38) on its heal spot (pokefirered heal_locations.json, HEAL_LOCATION_SAFFRON_CITY), as 18.03: the walk there round the Rocket Grunts, who stand and walk in the city until Silph Co. (FLAG_HIDE_SAFFRON_ROCKETS), was 35 tiles from the guard" + }, { "id": "below_center_door", "kind": "route", @@ -46,14 +66,14 @@ "args": { "target": {"map": "SaffronCity", "tiles": [[24, 39]], "facing": "north"} }, - "why": "east out of the gate into Saffron City (8, 27), and through the city, round the Rocket Grunts who stand and walk there until Silph Co. (FLAG_HIDE_SAFFRON_ROCKETS), to below the Center's door (24, 38)" + "why": "turn to face the Center's door (24, 38) from the landing" }, { "id": "saffron_nurse", "kind": "game_action", "action": "center_enter", "declared_after": {"map": "SaffronCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, - "why": "the Center script in: through the door and up to the nurse; no map of the Center. It also makes Saffron a Fly point" + "why": "the Center script in: through the door and up to the nurse; no map of the Center" }, { "id": "heal_saffron", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04b.plan.json index 4281616ef2..97b827ff45 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04b.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04b.plan.json @@ -3,7 +3,7 @@ "game": "frlg", "checkpoint": { "id": "17.04b", - "title": "Out of the gym, heal at Viridian's Center", + "title": "Out of the gym, Fly to Viridian's Center and heal", "start": { "map": "ViridianCity_Gym", "tiles": [ @@ -33,6 +33,26 @@ }, "why": "back through the gym to the door and out onto Viridian City below it" }, + { + "id": "fly_viridian", + "kind": "game_action", + "action": "fly", + "args": { + "town": "ViridianCity", + "species": "pidgey" + }, + "declared_after": { + "map": "ViridianCity", + "tiles": [ + [ + 26, + 27 + ] + ], + "facing": "south" + }, + "why": "the Pidgey flies to Viridian City, landing below the Pokemon Center's door (26, 26) on its heal spot (pokefirered heal_locations.json, HEAL_LOCATION_VIRIDIAN_CITY), as 17.02: the walk there from the gym's door went north round the city's fences, 58 tiles for a straight line of 26" + }, { "id": "below_center_door", "kind": "route", @@ -49,7 +69,7 @@ "facing": "north" } }, - "why": "west and down to below the Center's door (26, 26)" + "why": "turn to face the Center's door (26, 26) from the landing" }, { "id": "viridian_nurse", @@ -79,7 +99,8 @@ "notes": { "checkpoint": [ "Starts in front of Giovanni, where 17.04 ends after his battle and saves.", - "Ends at Viridian's nurse (declared: the gym exit is a street tile; the Center is where the next row starts)." + "Ends at Viridian's nurse (declared: the gym exit is a street tile; the Center is where the next row starts).", + "Out of the gym's door and by Fly to the Center's door (user, 2026-11-15: every Center trip flies once Fly is learned, unless the Center is really close)." ] } }, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-18.02b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-18.02b.plan.json index 455e1e8988..cf4916a368 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-18.02b.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-18.02b.plan.json @@ -3,7 +3,7 @@ "game": "frlg", "checkpoint": { "id": "18.02b", - "title": "Out of Saffron Gym by the pads, Fly to Saffron's Center and heal", + "title": "Out of Saffron Gym by Escape Rope, Fly to Saffron's Center and heal", "start": { "map": "SaffronCity_Gym", "tiles": [ @@ -19,184 +19,23 @@ ], "events": [ { - "id": "by_pad_out_of_sabrina", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "SaffronCity_Gym", - "tiles": [ - [ - 17, - 15 - ] - ], - "facing": "east" - } - }, - "why": "back to the tile west of the pad (18, 15) the way in landed on" - }, - { - "id": "pad_out_of_sabrina", - "kind": "step", - "args": { - "direction": "east" - }, - "declared_after": { - "map": "SaffronCity_Gym", - "tiles": [ - [ - 0, - 7 - ] - ], - "facing": "east" - }, - "why": "onto the pad (18, 15), which warps to (0, 7) in the top left room" - }, - { - "id": "by_pad_from_top_left", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "SaffronCity_Gym", - "tiles": [ - [ - 0, - 5 - ] - ], - "facing": "north" - } - }, - "why": "up column 0 to a tile below the pad (0, 4)" - }, - { - "id": "pad_from_top_left", - "kind": "step", - "args": { - "direction": "north" - }, - "declared_after": { - "map": "SaffronCity_Gym", - "tiles": [ - [ - 20, - 7 - ] - ], - "facing": "north" - }, - "why": "onto the pad (0, 4), which warps to (20, 7) in the top right room" - }, - { - "id": "along_row_6", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "SaffronCity_Gym", - "tiles": [ - [ - 28, - 6 - ] - ], - "facing": "east" - } - }, - "why": "east along row 6 (Johan (24, 2) sees (24, 3) to (24, 5), so not row 5) to the room's east wall" - }, - { - "id": "below_pad_from_top_right", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "SaffronCity_Gym", - "tiles": [ - [ - 28, - 5 - ] - ], - "facing": "north" - } - }, - "why": "up to the tile below the pad (28, 4)" - }, - { - "id": "pad_from_top_right", - "kind": "step", - "args": { - "direction": "north" - }, - "declared_after": { - "map": "SaffronCity_Gym", - "tiles": [ - [ - 20, - 20 - ] - ], - "facing": "north" - }, - "why": "onto the pad (28, 4), which warps to (20, 20) in the bottom right room" - }, - { - "id": "by_pad_from_bottom_right", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "SaffronCity_Gym", - "tiles": [ - [ - 28, - 22 - ] - ], - "facing": "south" - } - }, - "why": "east along row 22, below Cameron's line (24, 19 to 21), to a tile above the pad (28, 23)" - }, - { - "id": "pad_from_bottom_right", - "kind": "step", + "id": "escape_rope", + "kind": "game_action", + "action": "use_item", "args": { - "direction": "south" + "item": "escape-rope" }, "declared_after": { - "map": "SaffronCity_Gym", + "map": "SaffronCity", "tiles": [ [ - 18, - 20 + 46, + 13 ] ], "facing": "south" }, - "why": "onto the pad (28, 23), which warps to (18, 20) in the entrance room" - }, - { - "id": "out_of_gym", - "kind": "route", - "action": "run", - "args": { - "target": { - "map": "SaffronCity", - "tiles": [ - [ - 46, - 13 - ] - ], - "facing": "south" - } - }, - "why": "down the entrance room and out of the door (14, 23) onto Saffron City below the gym's door (46, 12): Fly works outdoors only" + "why": "out of Saffron Gym from Sabrina's room, as 16.06 out of Silph Co.: SaffronCity_Gym allows it (pokefirered map.json: allow_escaping true), and the rope takes the player to the escape warp, set when 16.06b walked north into the gym's door (46, 12) from Saffron (overworld.c UpdateEscapeWarp(): the tile below the door, (46, 13)). The bag has 3 by now: 4 at 16.06, less its rope" }, { "id": "fly_saffron", @@ -264,9 +103,9 @@ "notes": { "checkpoint": [ "Starts in front of Sabrina, where 18.02 ends after her battle and saves.", - "Out by the four pads in reverse, each pair a two-way link: (18, 15) to (0, 7), (0, 4) to (20, 7), (28, 4) to (20, 20), (28, 23) to (18, 20), keeping to the same rows as the way in (18.01). No gym trainer is fought on the way out.", - "Ends at Saffron's nurse, facing her: 18.03's start. Out of the gym's door and by Fly to the Center's door, not through the city: the walk round the city's blocks to the Center was about 80 tiles for a straight line of 48 (console B, 2026-11-15).", - "Starts with silph_cleared, as 16.06b: Silph Co.'s Giovanni (16.05) sent the Rockets out of Saffron City, so a run started here plans the walk out of the gym's door onto (46, 13), where one of them stood, on maps without them." + "Out by Escape Rope and Fly, not back by the four pads and the gym's door: that walk was about 40 tiles over four pads (user, 2026-11-15: every Center trip flies once Fly is learned, and a building that allows an Escape Rope is left by rope). Before that, the walk round the city's blocks to the Center was about 80 tiles for a straight line of 48 (console B, 2026-11-15).", + "Ends at Saffron's nurse, facing her: 18.03's start.", + "Starts with silph_cleared, as 16.06b: Silph Co.'s Giovanni (16.05) sent the Rockets out of Saffron City, so the rope's landing (46, 13), where one of them stood, is free." ] } }, From da744fa57456a9131e16cc486b5c6735557e565e Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 15 Nov 2026 16:18:43 -0800 Subject: [PATCH 3/3] FRLG AutoStory: the Fly-to-Center lint registers from its own header PokemonFRLG_AutoStoryRows_Tests.h was over code health's header symbol limit with it. --- .../PokemonFRLG/PokemonFRLG_Tests.cpp | 1 + ...PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp | 4 +-- .../PokemonFRLG_AutoStoryFlyToCenter_Tests.h | 27 +++++++++++++++++++ .../PokemonFRLG_AutoStoryRows_Tests.h | 2 -- SerialPrograms/cmake/SourceFiles.cmake | 1 + 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.h diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index de92114f73..23e218aa51 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -56,6 +56,7 @@ #include "Programs/AutoStory/PokemonFRLG_AutoStoryAbilities.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryPartyRoster.h" +#include "Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStorySurf_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryHealing.h" diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp index 7659f7f162..25d9e855b2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp @@ -21,11 +21,11 @@ #include "Common/Cpp/TestRunners/UnitTest.h" #include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" #include "PokemonFRLG_AutoStoryEvents.h" +#include "PokemonFRLG_AutoStoryFlyToCenter_Tests.h" #include "PokemonFRLG_AutoStoryItemUse.h" #include "PokemonFRLG_AutoStoryPacedRoute.h" #include "PokemonFRLG_AutoStoryRooms.h" #include "PokemonFRLG_AutoStoryRowSim.h" -#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryTable.h" namespace PokemonAutomation{ @@ -316,7 +316,7 @@ class Test_AutoStoryFlyToCenter : public UnitTest{ } std::string message = std::format("{} offender(s), expected {}:", offenders.size(), m_case.expectation.offenders.size()); for (const std::string& offender : offenders){ - message += " " + offender; + message += std::format(" {}", offender); } return message; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.h new file mode 100644 index 0000000000..db225b89c2 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.h @@ -0,0 +1,27 @@ +/* AutoStory Fly To Center Tests + * + * From: https://github.com/PokemonAutomation/ + * + * Registration of the lint that every Pokemon Center trip from 10.01 on + * flies, or ropes out of a building + * (PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp). + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryFlyToCenter_Tests_H +#define PokemonAutomation_PokemonFRLG_AutoStoryFlyToCenter_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +void add_tests_AutoStoryFlyToCenter(UnitTestDatabase& database); + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h index 586795c099..6c82e3a04a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h @@ -37,8 +37,6 @@ void add_tests_AutoStorySlope(UnitTestDatabase& database); void add_tests_AutoStorySafari(UnitTestDatabase& database); // Rows 14.03, 14.04 and 14.04b, Celadon Gym, on the overworld sim (PokemonFRLG_AutoStoryCeladonGym_Tests.cpp). void add_tests_AutoStoryCeladonGym(UnitTestDatabase& database); -// Every Center trip from 10.01 on flies, or ropes out of a building (PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp). -void add_tests_AutoStoryFlyToCenter(UnitTestDatabase& database); } // namespace PokemonFRLG } // namespace NintendoSwitch diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 4d9ab81f47..bada30a983 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -2214,6 +2214,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyLanding.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyLanding_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFlyToCenter_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFieldSteps.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFieldSteps.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFossil.h