From 51cb26677a5a5b1ae58362329cb42e31045fffcb Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 09:58:23 -0800 Subject: [PATCH 1/8] FRLG AutoStory: checkpoints 00.01-00.10 as authored JSON, on #312's action/args steps The FRLG stack stopped building after #312: the C++ rows set step.target, legs, direction, fight_wild and may_lose directly, StoryChecks became StoryCheckLevel, Pokemon_StorySteps.h moved to Pokemon_StoryStepExecutor.h and the JSON codecs to Data/. - Each checkpoint is StoryData/frlg-.plan.json (pokesim-authored- checkpoint/1), read with read_authored_checkpoint() against FRLG's actions: the built-in ones plus ROUTE/LEGS "run". The parser fills in the fallbacks (fight_wild, may_lose, yes), so the files give only what differs. FRLG's execution object carries the START menu, the supplies, the lead after Brock and the notes that were C++ comments. - The executor, the step-table, sim and route tests read typed args (story_arg()); the sim's fake game dispatches by kind in run(). - Check levels: DEFAULT and above check the screen as THOROUGH did; FAST and SPEEDRUN trust counts as FAST did. - AutoStory: StoryRunOptions with the FRLG languages, the check level and language into StoryEnv, record_story_counts(). The old C++ rows stay in PokemonFRLG_AutoStoryTableParity_Tests.cpp for this commit only: each file loads to the same steps, args, poses, supplies and START menu. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- SerialPrograms/CMakeLists.txt | 2 + .../PokemonFRLG_OverworldRecovery.cpp | 10 +- .../PokemonFRLG/PokemonFRLG_Tests.cpp | 1 + .../AutoStory/PokemonFRLG_AutoStory.cpp | 27 +- .../PokemonFRLG_AutoStoryActions.cpp | 4 +- .../AutoStory/PokemonFRLG_AutoStoryActions.h | 21 +- .../AutoStory/PokemonFRLG_AutoStoryBattle.cpp | 26 +- .../AutoStory/PokemonFRLG_AutoStoryBattle.h | 6 +- .../AutoStory/PokemonFRLG_AutoStoryEvents.cpp | 52 ++- .../AutoStory/PokemonFRLG_AutoStoryEvents.h | 6 +- .../AutoStory/PokemonFRLG_AutoStoryExport.cpp | 2 +- .../PokemonFRLG_AutoStoryExport_Tests.cpp | 2 +- .../PokemonFRLG_AutoStorySimulation_Tests.cpp | 79 ++-- .../PokemonFRLG_AutoStoryStepInterrupts.h | 2 +- .../PokemonFRLG_AutoStoryStepTable.cpp | 20 +- .../PokemonFRLG_AutoStoryStepTable.h | 13 +- .../PokemonFRLG_AutoStoryStepTable_Tests.cpp | 4 +- .../AutoStory/PokemonFRLG_AutoStoryTable.cpp | 369 +++++------------- .../AutoStory/PokemonFRLG_AutoStoryTable.h | 32 +- ...PokemonFRLG_AutoStoryTableParity_Tests.cpp | 344 ++++++++++++++++ .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 13 +- .../AutoStory/StoryData/frlg-00.01.plan.json | 29 ++ .../AutoStory/StoryData/frlg-00.02.plan.json | 22 ++ .../AutoStory/StoryData/frlg-00.03.plan.json | 41 ++ .../AutoStory/StoryData/frlg-00.04.plan.json | 76 ++++ .../AutoStory/StoryData/frlg-00.05.plan.json | 41 ++ .../AutoStory/StoryData/frlg-00.06.plan.json | 33 ++ .../AutoStory/StoryData/frlg-00.07.plan.json | 95 +++++ .../AutoStory/StoryData/frlg-00.08.plan.json | 82 ++++ .../AutoStory/StoryData/frlg-00.09.plan.json | 79 ++++ .../AutoStory/StoryData/frlg-00.10.plan.json | 48 +++ SerialPrograms/cmake/SourceFiles.cmake | 1 + 32 files changed, 1212 insertions(+), 370 deletions(-) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.01.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.02.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.03.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.04.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.05.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.06.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.07.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.08.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.09.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.10.plan.json diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index 73729ebde9..5a90664df8 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -231,6 +231,8 @@ pa_embed_text_files(SerialProgramsLib Source/VideoGames/PokemonFRLG/Overworld/Ma VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h PokemonAutomation::NintendoSwitch::PokemonFRLG overworld_map_json) pa_embed_text_files(SerialProgramsLib Source/VideoGames/PokemonFRLG/Programs/AutoStory/BattleData VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattleData.h PokemonAutomation::NintendoSwitch::PokemonFRLG autostory_battle_json) +pa_embed_text_files(SerialProgramsLib Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData + VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h PokemonAutomation::NintendoSwitch::PokemonFRLG autostory_checkpoint_json) # Create binary target diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp index 7e37bafded..ce552195c7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp @@ -71,20 +71,20 @@ class RouteLogLines{ for (const RouteStep& step : steps){ legs.push_back({.leg = route_log_leg(step), .after = route_tiles(step.end)}); } - m_calls.log(ROUTE_LOG_TAG + Pokemon::route_plan_line(m_label, route_tiles(from), legs)); + m_calls.log(std::string(ROUTE_LOG_TAG) + Pokemon::route_plan_line(m_label, route_tiles(from), legs)); } void leg(size_t index, const std::vector& steps) const{ const RouteStep& step = steps[index]; - m_calls.log(ROUTE_LOG_TAG + Pokemon::route_leg_line(index + 1, steps.size(), {.leg = route_log_leg(step), .after = route_tiles(step.end)})); + m_calls.log(std::string(ROUTE_LOG_TAG) + Pokemon::route_leg_line(index + 1, steps.size(), {.leg = route_log_leg(step), .after = route_tiles(step.end)})); } void end(const RouteStep& step, const std::optional& at, EndBasis basis, const std::string& why) const{ - m_calls.log(ROUTE_LOG_TAG + Pokemon::route_leg_end_line(m_label, route_log_leg(step), route_tiles(at), basis, why)); + m_calls.log(std::string(ROUTE_LOG_TAG) + Pokemon::route_leg_end_line(m_label, route_log_leg(step), route_tiles(at), basis, why)); } void trainer_stopped(const RouteStep& step, const MapPosition& at) const{ - m_calls.log(ROUTE_LOG_TAG + Pokemon::route_replan_line(m_label, route_log_leg(step), "stopped by a trainer who saw the player", route_tiles(at))); + m_calls.log(std::string(ROUTE_LOG_TAG) + Pokemon::route_replan_line(m_label, route_log_leg(step), "stopped by a trainer who saw the player", route_tiles(at))); } void found(const MapPosition& at, size_t holds) const{ - m_calls.log(ROUTE_LOG_TAG + Pokemon::route_found_line(m_label, route_tiles(at), holds)); + m_calls.log(std::string(ROUTE_LOG_TAG) + Pokemon::route_found_line(m_label, route_tiles(at), holds)); } // Step `number` (from 1) of a plan whose first `holds` steps are holds // to walls, walked to its end. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index cea4ff7bc9..4a5a0b5310 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -319,6 +319,7 @@ void add_tests(UnitTestDatabase& database){ add_tests_OverworldRecovery(database); add_tests_PlayerFacingReader(database); add_tests_AutoStory(database); + add_tests_AutoStoryTableParity(database); add_tests_AutoStoryExport(database); add_tests_AutoStorySimulation(database); add_tests_AutoStoryItems(database); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp index 6dab6ec05e..431de98ad7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory.cpp @@ -11,7 +11,9 @@ #include "CommonFramework/Notifications/ProgramNotifications.h" #include "CommonFramework/VideoPipeline/VideoOverlay.h" #include "Pokemon/AutoStory/Pokemon_AutoStoryStats.h" +#include "Pokemon/AutoStory/Pokemon_StoryLog.h" #include "Pokemon/AutoStory/Pokemon_StorySegments.h" +#include "Pokemon/Options/Pokemon_GameLanguages.h" #include "Pokemon/Pokemon_Strings.h" #include "VideoGames/PokemonFRLG/PokemonFRLG_Navigation.h" #include "PokemonFRLG_AutoStoryEvents.h" @@ -46,7 +48,14 @@ namespace{ // The start and end dropdowns' entries: the table's checkpoints, 00.01 to // 00.10. The options hold a reference to it. const StringSelectDatabase& checkpoint_database(){ - static const StringSelectDatabase database = Pokemon::story_checkpoint_database(story_checkpoints()); + static const std::vector labels = []{ + std::vector result; + for (const StoryCheckpoint& checkpoint : story_checkpoints()){ + result.push_back(Pokemon::story_checkpoint_label(checkpoint)); + } + return result; + }(); + static const StringSelectDatabase database = Pokemon::story_checkpoint_database(labels); return database; } @@ -58,7 +67,7 @@ const char* const KEEP_START_FRAME_TEXT = } // namespace AutoStory::AutoStory() - : RUN(checkpoint_database()) + : RUN(checkpoint_database(), Pokemon::FireRedLeafGreenLanguages_Database()) , NEW_GAME_FROM_TITLE( "New game from the title screen:
The game is on its title screen with no save data. " "Needed to start at 00.01. Otherwise the program loads the save, which must be the one the start checkpoint begins from.", @@ -101,7 +110,7 @@ namespace{ // the screen as its frame if `keep_start_frame` (a save made by hand). StoryEnv story_env( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - const StoryCheckpoint& checkpoint, StoryChecks checks, bool keep_start_frame + const StoryCheckpoint& checkpoint, Pokemon::StoryCheckLevel checks, bool keep_start_frame ){ StoryEnv story{env.console, context, checkpoint.supplies, checkpoint.supplies, false, checks}; story.start_frames = program_start_frames(); @@ -173,11 +182,10 @@ void verify_story_checkpoint( ){ const std::vector& checkpoints = story_checkpoints(); const StoryCheckpoint& checkpoint = checkpoints[run.start_index()]; - StoryEnv story = story_env(env, context, checkpoint, run.checks(), false); + StoryEnv story = story_env(env, context, checkpoint, run.check_level(), false); load_verify_save(env, context, story, checkpoint); + story.language = run.language(); StoryExecutor executor(story); - executor.set_checks(run.checks()); - executor.set_language(run.language()); Pokemon::Segment segment = make_story_segment(checkpoints, executor); Pokemon::SegmentHooks hooks = story_hooks(env, story); @@ -211,7 +219,7 @@ void AutoStory::program(SingleSwitchProgramEnvironment& env, ProControllerContex throw UserSetupError(env.console, "Checkpoint 00.01 starts a new game: start on the title screen with no save."); } - StoryEnv story = story_env(env, context, checkpoints[first], RUN.checks(), KEEP_START_FRAME); + StoryEnv story = story_env(env, context, checkpoints[first], RUN.check_level(), KEEP_START_FRAME); if (!(first == 0 && NEW_GAME_FROM_TITLE)){ env.console.log("Loading the save for " + checkpoints[first].id + "."); soft_reset(env.console, context); @@ -221,9 +229,8 @@ void AutoStory::program(SingleSwitchProgramEnvironment& env, ProControllerContex read_bag_supplies(story, checkpoints[first].menu); } + story.language = RUN.language(); StoryExecutor executor(story); - executor.set_checks(RUN.checks()); - executor.set_language(RUN.language()); Pokemon::Segment segment = make_story_segment(checkpoints, executor); Pokemon::SegmentHooks hooks = story_hooks(env, story); @@ -231,7 +238,7 @@ void AutoStory::program(SingleSwitchProgramEnvironment& env, ProControllerContex const Pokemon::SegmentReport report = run_segment( state, segment, Pokemon::SegmentRange{checkpoints[first].id, checkpoints[last].id}, RUN.policy(), hooks ); - Pokemon::record_story_stats(env.current_stats(), report); + Pokemon::record_story_counts(env.current_stats(), report.story_counts()); env.update_stats(); if (!report.completed){ throw OperationFailedException( diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp index e484701c7d..d38e145428 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.cpp @@ -796,7 +796,7 @@ static void check_mart_row(ConsoleHandle& console, ProControllerContext& context void buy_items( ConsoleHandle& console, ProControllerContext& context, - const std::vector& orders, StoryChecks checks, Language language + const std::vector& orders, Pokemon::StoryCheckLevel checks, Language language ){ // "May I help you?" with BUY on top, then the list, cursor on its top. press(context, BUTTON_A, 2000ms); @@ -813,7 +813,7 @@ void buy_items( } cursor = order.row; mart_shot(console, context, std::format("row{}-list", order.row + 1)); - if (checks == StoryChecks::THOROUGH){ + if (checks_screen(checks)){ check_mart_row(console, context, order, language); } // "How many?" drops presses while its text prints. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h index 27eeb690b3..31d2a99fbf 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryActions.h @@ -23,7 +23,8 @@ #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" +#include "Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h" #include "Pokemon/Navigation/Pokemon_Grid.h" namespace PokemonAutomation{ @@ -31,13 +32,15 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -// How much the story checks the screen before and after it acts: the -// shared level (Pokemon_StorySteps.h, set by StoryRunOptions). For FRLG, -// THOROUGH reads a Mart row's item before buying it, the bag's Items -// pocket after shopping (the counts the story then keeps), and an item's -// name in the bag before using it. FAST trusts the counts it keeps and the -// timings. -using StoryChecks = Pokemon::StoryChecks; +// Whether the shared check level (Types/Pokemon_StoryCheckLevel.h, set by +// StoryRunOptions) has the story check the screen before and after it +// acts: DEFAULT and above (TESTING, THOROUGH). Then FRLG reads a Mart +// row's item before buying it, the bag's Items pocket after shopping (the +// counts the story then keeps), and an item's name in the bag before +// using it. FAST and SPEEDRUN trust the counts it keeps and the timings. +inline bool checks_screen(Pokemon::StoryCheckLevel level){ + return level <= Pokemon::StoryCheckLevel::DEFAULT; +} // The START menu as the story grows it. Before the starter: BAG, the // player, SAVE, OPTION, EXIT; the starter adds POKEMON on top, the Pokedex @@ -214,7 +217,7 @@ int mart_cursor_moves(int cursor, int row); // bought by position only. void buy_items( ConsoleHandle& console, ProControllerContext& context, - const std::vector& orders, StoryChecks checks, Language language + const std::vector& orders, Pokemon::StoryCheckLevel checks, Language language ); // From the title screen of a game with no save, to the bedroom: the diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp index 555ecccfbe..8e02ced513 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.cpp @@ -164,9 +164,9 @@ void tap(ProControllerContext& context, DpadPosition position){ // no names for) is taken by its position; only another item's name stops it. bool bag_row_is( ConsoleHandle& console, ProControllerContext& context, - int row, const std::string& item, StoryChecks checks, Language language + int row, const std::string& item, Pokemon::StoryCheckLevel checks, Language language ){ - if (checks == StoryChecks::FAST){ + if (!checks_screen(checks)){ return true; } context.wait_for_all_requests(); @@ -190,7 +190,7 @@ bool bag_row_is( // backs out to the battle menu. Not run on the console yet. bool use_item( ConsoleHandle& console, ProControllerContext& context, - int row, const std::string& item, StoryChecks checks, Language language + int row, const std::string& item, Pokemon::StoryCheckLevel checks, Language language ){ console.log(std::format("Battle: using the {} in row {} of the Items pocket.", item, row + 1)); tap(context, DPAD_LEFT); @@ -321,7 +321,7 @@ class BattleLoop{ public: BattleLoop( ConsoleHandle& console, ProControllerContext& context, - Supplies& supplies, BattleKind kind, StoryChecks checks, Language language + Supplies& supplies, BattleKind kind, Pokemon::StoryCheckLevel checks, Language language ) : m_console(console) , m_context(context) @@ -659,7 +659,7 @@ class BattleLoop{ BattleEndWatch m_end; MoveRefusalWatch m_refusal; const BattleKind m_kind; - const StoryChecks m_checks; + const Pokemon::StoryCheckLevel m_checks; const Language m_language; const WallClock m_start; WallClock m_last_battle; @@ -694,7 +694,7 @@ void open_items_pocket(ConsoleHandle& console, ProControllerContext& context){ // Not run on the console yet. bool use_item_on_overworld( ConsoleHandle& console, ProControllerContext& context, - int row, const std::string& item, StoryChecks checks, Language language + int row, const std::string& item, Pokemon::StoryCheckLevel checks, Language language ){ console.log(std::format("Story: using a {} from the bag (Items pocket, row {}).", item, row + 1)); open_items_pocket(console, context); @@ -727,7 +727,7 @@ void fail_on_blackout(ConsoleHandle& console, BattleEnd end){ // appeared!". class StoryWildBattle : public OverworldInterrupt{ public: - StoryWildBattle(Supplies& supplies, bool fight, bool late, StoryChecks checks, Language language) + StoryWildBattle(Supplies& supplies, bool fight, bool late, Pokemon::StoryCheckLevel checks, Language language) : m_supplies(supplies) , m_checks(checks) , m_language(language) @@ -758,7 +758,7 @@ class StoryWildBattle : public OverworldInterrupt{ private: Supplies& m_supplies; - const StoryChecks m_checks; + const Pokemon::StoryCheckLevel m_checks; const Language m_language; const bool m_fight; const bool m_late; @@ -767,7 +767,7 @@ class StoryWildBattle : public OverworldInterrupt{ // A message: read to its end, then a trainer's battle if one starts. class StoryMessage : public OverworldInterrupt{ public: - StoryMessage(Supplies& supplies, StoryChecks checks, Language language) + StoryMessage(Supplies& supplies, Pokemon::StoryCheckLevel checks, Language language) : m_supplies(supplies) , m_checks(checks) , m_language(language) @@ -793,7 +793,7 @@ class StoryMessage : public OverworldInterrupt{ private: Supplies& m_supplies; - const StoryChecks m_checks; + const Pokemon::StoryCheckLevel m_checks; const Language m_language; }; @@ -932,7 +932,7 @@ std::vector read_items_pocket(ConsoleHandle& console, ProControllerConte void recover_after_battle( ConsoleHandle& console, ProControllerContext& context, - Supplies& supplies, StoryChecks checks, Language language + Supplies& supplies, Pokemon::StoryCheckLevel checks, Language language ){ if (supplies.status == StatusCondition::POISON && supplies.antidotes > 0){ if (use_item_on_overworld(console, context, item_row(supplies, "antidote"), "antidote", checks, language)){ @@ -959,12 +959,12 @@ void recover_after_battle( BattleEnd fight_battle( ConsoleHandle& console, ProControllerContext& context, - Supplies& supplies, BattleKind kind, StoryChecks checks, Language language + Supplies& supplies, BattleKind kind, Pokemon::StoryCheckLevel checks, Language language ){ return BattleLoop(console, context, supplies, kind, checks, language).run(); } -OverworldInterruptSet story_interrupts(Supplies& supplies, bool fight_wild, StoryChecks checks, Language language){ +OverworldInterruptSet story_interrupts(Supplies& supplies, bool fight_wild, Pokemon::StoryCheckLevel checks, Language language){ // Battles first: their screens are checked before the message box's. OverworldInterruptSet ret; ret.wild.emplace_back(std::make_unique(supplies, fight_wild, false, checks, language)); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h index b0cca42e3c..7f65bf3d0b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryBattle.h @@ -179,7 +179,7 @@ bool battle_shows(const ImageViewRGB32& screen); // different one isn't used. BattleEnd fight_battle( ConsoleHandle& console, ProControllerContext& context, - Supplies& supplies, BattleKind kind, StoryChecks checks, Language language + Supplies& supplies, BattleKind kind, Pokemon::StoryCheckLevel checks, Language language ); @@ -188,7 +188,7 @@ BattleEnd fight_battle( // The bag's inputs are not checked on the console yet. void recover_after_battle( ConsoleHandle& console, ProControllerContext& context, - Supplies& supplies, StoryChecks checks, Language language + Supplies& supplies, Pokemon::StoryCheckLevel checks, Language language ); @@ -196,7 +196,7 @@ void recover_after_battle( // fought if `fight_wild`. A message is advanced until the overworld is // back; a battle that starts after it (a trainer who saw the player) is // fought. A battle lost (a blackout) throws OperationFailedException. -OverworldInterruptSet story_interrupts(Supplies& supplies, bool fight_wild, StoryChecks checks, Language language); +OverworldInterruptSet story_interrupts(Supplies& supplies, bool fight_wild, Pokemon::StoryCheckLevel checks, Language language); // Registers AutoStory item usage unit tests. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index 5a2baefcf1..7756577c90 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -51,6 +51,20 @@ Outcome guarded(Body&& body){ } } +// The step's arg `key`, which its action declares. +template +const Type& arg(const StoryStep& step, std::string_view key){ + return Pokemon::story_arg(step.args, key); +} + +// A checkpoint's start as the engine's Pose: nothing for a new game. +std::optional start_pose(const StoryCheckpoint& checkpoint){ + if (!checkpoint.start){ + return std::nullopt; + } + return Pokemon::pose_of(*checkpoint.start); +} + const MapData* find_story_map(const std::string& name){ for (const MapData& map : story_maps()){ if (map.name == name){ @@ -78,13 +92,13 @@ std::optional face_a_wall(StoryEnv& env, const MapPosition& position) // The shared route log's arrival line (Pokemon_RouteLog.h), as BDSP's walker // writes it: where the route was walked to. void log_arrival(StoryEnv& env, const std::string& label, const std::string& map, const TilePos& tile){ - env.console.log(Pokemon::ROUTE_LOG_TAG + Pokemon::route_arrived_line(label, {{map, tile}})); + env.console.log(std::string(Pokemon::ROUTE_LOG_TAG) + Pokemon::route_arrived_line(label, {{map, tile}})); } // The walker's check that each leg to a wall ended at it (a diagnostic): // with Thorough checks only, as Fast trusts the walk. WallCheck wall_check(const StoryEnv& env){ - return env.checks == StoryChecks::THOROUGH ? WallCheck::TAP : WallCheck::SKIP; + return checks_screen(env.checks) ? WallCheck::TAP : WallCheck::SKIP; } Outcome walk_route(StoryEnv& env, RunState& state, const StoryStep& step){ @@ -100,9 +114,10 @@ Outcome walk_route(StoryEnv& env, RunState& state, const StoryStep& step){ if (!facing){ return Pokemon::outcome_failed("unknown_facing", to_string(start)); } - const std::optional target = step.target ? story_pose(*step.target) : std::nullopt; + const Pokemon::Pose target_pose = Pokemon::pose_of(arg(step, "target")); + const std::optional target = story_pose(target_pose); if (!target){ - return Pokemon::outcome_failed("bad_target", step.target ? Pokemon::to_string(*step.target) : "none"); + return Pokemon::outcome_failed("bad_target", Pokemon::to_string(target_pose)); } const RouteGoal goal{{target->map, target->tile}, target->facing}; const std::optional> route = plan_overworld_route( @@ -111,7 +126,7 @@ Outcome walk_route(StoryEnv& env, RunState& state, const StoryStep& step){ if (!route){ return Pokemon::outcome_failed("no_route", to_string(start) + " to " + to_string(goal.position)); } - const OverworldInterruptSet interrupts = story_interrupts(env.supplies, step.fight_wild, env.checks, env.language); + const OverworldInterruptSet interrupts = story_interrupts(env.supplies, arg(step, "fight_wild"), env.checks, env.language); // Planning lets the walker recover a stopped open leg: it plans back to // the leg's end, then walks the rest as given. const RoutePlanning planning{.maps = &story_maps(), .costs = default_route_costs(), .start = start, .label = step.name, .wall_check = wall_check(env)}; @@ -131,11 +146,11 @@ Outcome walk_legs(StoryEnv& env, RunState& state, const StoryStep& step){ if (!facing){ facing = face_a_wall(env, start); } - const std::optional> route = fixed_route(story_maps(), start, step.legs); + const std::optional> route = fixed_route(story_maps(), start, arg>(step, "legs")); if (!facing || !route || route->empty()){ return Pokemon::outcome_failed("bad_legs", to_string(start)); } - const OverworldInterruptSet interrupts = story_interrupts(env.supplies, step.fight_wild, env.checks, env.language); + const OverworldInterruptSet interrupts = story_interrupts(env.supplies, arg(step, "fight_wild"), env.checks, env.language); // Planning lets the walker recover a stopped open leg: it plans back to // the leg's end, then walks the rest as given. const RoutePlanning planning{.maps = &story_maps(), .costs = default_route_costs(), .start = start, .label = step.name, .wall_check = wall_check(env)}; @@ -145,19 +160,20 @@ Outcome walk_legs(StoryEnv& env, RunState& state, const StoryStep& step){ } Outcome take_step(StoryEnv& env, RunState& state, const StoryStep& step){ - step_once(env.context, step.direction, facing_of(state.pose)); + const Direction direction = arg(step, "direction"); + step_once(env.context, direction, facing_of(state.pose)); const std::vector tiles = Pokemon::tiles_of(state.pose); if (tiles.size() != 1){ return Pokemon::outcome_ok(); } - return Pokemon::outcome_ok(to_pose(StoryPose{state.pose.map, tiles[0].next(step.direction), step.direction})); + return Pokemon::outcome_ok(to_pose(StoryPose{state.pose.map, tiles[0].next(direction), direction})); } // Before a BattleRisk::HIGH battle the story may lose: the sim's win // chance, the HP as the last bar read left it. Why not to fight, if so. std::optional refuse_battle(StoryEnv& env, const StoryStep& step, std::string_view trainer){ const Supplies& supplies = env.supplies; - if (step.may_lose || supplies.risk != BattleRisk::HIGH){ + if (arg(step, "may_lose") || supplies.risk != BattleRisk::HIGH){ return std::nullopt; } const std::optional estimate = story_win_chance(supplies.lead, supplies.potions, supplies.hp_fill, trainer); @@ -194,7 +210,7 @@ Outcome battle(StoryEnv& env, const StoryStep& step){ env.supplies.foes.clear(); env.supplies.trainer.clear(); env.supplies.foe_out.reset(); - if (end == BattleEnd::LOST && !step.may_lose){ + if (end == BattleEnd::LOST && !arg(step, "may_lose")){ return Pokemon::outcome_failed("blackout"); } mash_until_overworld(env.console, env.context, SCENE_TIMEOUT); @@ -249,16 +265,16 @@ const MartItem* viridian_mart_item(const std::string& name){ } Outcome shop(StoryEnv& env, const StoryStep& step){ - const std::optional> orders = viridian_mart_orders(step.items); + const std::optional> orders = viridian_mart_orders(arg>(step, "items")); if (!orders){ return Pokemon::outcome_failed("unknown_item", step.name); } // 2000 of the 3000 a new game starts with, plus the rival's prize. buy_items(env.console, env.context, *orders, env.checks, env.language); - for (const Pokemon::StoryItem& item : step.items){ + for (const Pokemon::StoryItem& item : arg>(step, "items")){ env.supplies.*viridian_mart_item(item.item)->count += (int)item.quantity; } - if (env.checks == StoryChecks::FAST){ + if (!checks_screen(env.checks)){ return Pokemon::outcome_ok(); } // The counts from the bag, not from the orders: a wrong row once bought @@ -298,7 +314,7 @@ const std::vector& story_maps(){ } MoveSpeed move_speed(const StoryStep& step){ - return step.variant == RUN_VARIANT ? MoveSpeed::RUN : MoveSpeed::WALK; + return step.action == RUN_VARIANT ? MoveSpeed::RUN : MoveSpeed::WALK; } Pokemon::Pose to_pose(const StoryPose& pose){ @@ -435,7 +451,7 @@ ConsoleAction console_action_of(StoryActionId id){ }; case StoryActionId::ANSWER: return [](StoryEnv& env, RunState&, const StoryStep& step){ - answer_yes_no(env.console, env.context, step.yes, BUTTON_B, YES_NO_TIMEOUT); + answer_yes_no(env.console, env.context, arg(step, "yes"), BUTTON_B, YES_NO_TIMEOUT); return Pokemon::outcome_ok(); }; case StoryActionId::MASH: @@ -493,7 +509,7 @@ Pokemon::StoryAction StoryExecutor::console_action(StoryActionId id){ }, .needs_console = true}; } if (id == StoryActionId::GAME){ - return {.act = [this](RunState& state, const StoryStep& step){ return game(state, step); }, .needs_console = true}; + return {.act = [](RunState&, const StoryStep& step){ return Pokemon::unsupported_step(step); }, .needs_console = true}; } const ConsoleAction action = console_action_of(id); return {.act = [this, action](RunState& state, const StoryStep& step){ return action(m_env, state, step); }, .needs_console = true}; @@ -582,7 +598,7 @@ Pokemon::Checkpoint build_checkpoint(const StoryCheckpoint& data, StoryExecutor& // program last saved there. With none kept, it passes. Pokemon::Checkpoint checkpoint = Pokemon::build_story_checkpoint(data, executor); add_start_check( - checkpoint, data.start, + checkpoint, start_pose(data), [&env, id = data.id]{ return read_console_start(env, id); }, [&env](const std::string& line){ env.console.log(line, COLOR_ORANGE); } ); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h index f8f006c849..d9f357e718 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h @@ -5,7 +5,7 @@ * The FRLG story as data for the shared story engine * (Pokemon/AutoStory/Pokemon_StoryEvents.h, Pokemon_StorySegments.h). * A checkpoint is a list of the shared StorySteps - * (Pokemon/AutoStory/Pokemon_StorySteps.h), each one kind of event (a + * (Pokemon/AutoStory/Pokemon_StoryStepExecutor.h), each one kind of event (a * route, a talk, text read to its end, a YES/NO, a battle, the nurse, the * Mart); StoryExecutor does each kind on the console, and * make_story_segment() turns the table into engine checkpoints. Routes @@ -29,7 +29,7 @@ #include "Pokemon/AutoStory/Pokemon_StoryActions.h" #include "Pokemon/AutoStory/Pokemon_StoryEvents.h" #include "Pokemon/AutoStory/Pokemon_StorySegments.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMap.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h" @@ -143,7 +143,7 @@ struct StoryEnv{ Supplies saved_supplies; // Whether the game has a save to reload. bool has_save = false; - StoryChecks checks = StoryChecks::THOROUGH; + Pokemon::StoryCheckLevel checks = Pokemon::StoryCheckLevel::DEFAULT; // The game's language, for reading item names. In one the readers have // no names for, the checks fall back to positions and counts. Language language = Language::English; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport.cpp index a0b85c21ea..3d7dd7f18a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport.cpp @@ -6,7 +6,7 @@ #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/Json/JsonArray.h" #include "Common/Cpp/Json/JsonObject.h" -#include "Pokemon/AutoStory/Pokemon_StoryStepJson.h" +#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" #include "PokemonFRLG_AutoStoryExport.h" namespace PokemonAutomation{ namespace NintendoSwitch{ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport_Tests.cpp index bc4e0f3f12..7f3757d020 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport_Tests.cpp @@ -3,7 +3,7 @@ */ #include "Common/Cpp/Json/JsonArray.h" #include "Common/Cpp/Json/JsonObject.h" -#include "Pokemon/AutoStory/Pokemon_StoryStepJson.h" +#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" #include "PokemonFRLG_AutoStoryExport.h" #include "PokemonFRLG_AutoStoryTable.h" #include "PokemonFRLG_AutoStoryExport_Tests.h" diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp index 6148a1211b..9199c2478e 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp @@ -22,7 +22,7 @@ #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/TestRunners/UnitTest.h" #include "Pokemon/AutoStory/Pokemon_StorySegments.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h" #include "PokemonFRLG_AutoStoryStepTable.h" #include "PokemonFRLG_AutoStoryTable.h" @@ -45,6 +45,14 @@ std::string joined(const std::vector& lines){ return text; } +// A checkpoint's start as the engine's Pose: nothing for a new game. +std::optional start_pose(const StoryCheckpoint& checkpoint){ + if (!checkpoint.start){ + return std::nullopt; + } + return Pokemon::pose_of(*checkpoint.start); +} + const MapData* map_named(const std::string& name){ for (const MapData& map : story_maps()){ if (map.name == name){ @@ -133,48 +141,66 @@ class FakeGame : public Pokemon::StoryStepExecutor{ failure->second.times--; return Pokemon::outcome_failed(failure->second.failure, key); } - return Pokemon::StoryStepExecutor::run(state, step); + return act(state, step); } -protected: - virtual Outcome route(RunState& state, const StoryStep& step) override{ - return walk_to(state.pose, step); +private: + // The step by its kind, as the console does it (StoryExecutor), with + // nothing done on a screen. + Outcome act(RunState& state, const StoryStep& step){ + switch (step.kind){ + case StoryStepKind::ROUTE: + return walk_to(state.pose, step); + case StoryStepKind::LEGS: + return legs(state, step); + case StoryStepKind::STEP: + return take_step(state, step); + case StoryStepKind::READY: + return ready(state, step); + case StoryStepKind::SHOP: + return shop(step); + case StoryStepKind::NEW_GAME: + case StoryStepKind::OPTIONS: + case StoryStepKind::TALK: + case StoryStepKind::ANSWER: + case StoryStepKind::MASH: + case StoryStepKind::BATTLE: + case StoryStepKind::HEAL: + return Pokemon::outcome_ok(); + default: + return Pokemon::unsupported_step(step); + } } - virtual Outcome legs(RunState& state, const StoryStep& step) override{ + Outcome legs(RunState& state, const StoryStep& step){ const Standing at = standing(state.pose); if (!at.error.empty()){ return Pokemon::outcome_failed("no_pose", at.error); } - const std::optional> route = fixed_route(story_maps(), at.position, step.legs); + const std::optional> route = fixed_route(story_maps(), at.position, Pokemon::story_arg>(step.args, "legs")); if (!route || route->empty()){ return Pokemon::outcome_failed("bad_legs", to_string(at.position)); } return Pokemon::outcome_ok(to_pose(StoryPose{route->back().end.map, route->back().end.point, route->back().facing_after})); } - virtual Outcome step(RunState& state, const StoryStep& step) override{ + Outcome take_step(RunState& state, const StoryStep& step){ const std::optional at = story_pose(state.pose); if (!at){ return Pokemon::outcome_failed("no_pose", Pokemon::to_string(state.pose)); } - return Pokemon::outcome_ok(to_pose(StoryPose{at->map, at->tile.next(step.direction), step.direction})); + const Direction direction = Pokemon::story_arg(step.args, "direction"); + return Pokemon::outcome_ok(to_pose(StoryPose{at->map, at->tile.next(direction), direction})); } // The nurse's way must plan too, but the run goes on from where it stands. - virtual Outcome ready(RunState& state, const StoryStep& step) override{ + Outcome ready(RunState& state, const StoryStep& step){ const Outcome to_nurse = walk_to(state.pose, step); return to_nurse.succeeded() ? Pokemon::outcome_ok() : to_nurse; } - virtual Outcome new_game(RunState&, const StoryStep&) override{ return Pokemon::outcome_ok(); } - virtual Outcome options(RunState&, const StoryStep&) override{ return Pokemon::outcome_ok(); } - virtual Outcome talk(RunState&, const StoryStep&) override{ return Pokemon::outcome_ok(); } - virtual Outcome answer(RunState&, const StoryStep&) override{ return Pokemon::outcome_ok(); } - virtual Outcome mash(RunState&, const StoryStep&) override{ return Pokemon::outcome_ok(); } - virtual Outcome battle(RunState&, const StoryStep&) override{ return Pokemon::outcome_ok(); } - virtual Outcome heal(RunState&, const StoryStep&) override{ return Pokemon::outcome_ok(); } // The Viridian Mart's list as the game shows it. After a purchase the // cursor stays on the row bought (console B, 2026-11-01), so each // order moves it from there, as buy_items() does since ad5d40885. - virtual Outcome shop(RunState&, const StoryStep& step) override{ + Outcome shop(const StoryStep& step){ + const std::vector& items = Pokemon::story_arg>(step.args, "items"); static const std::vector LIST{"poke_ball", "potion", "antidote", "parlyz_heal", "cancel"}; - const std::optional> orders = viridian_mart_orders(step.items); + const std::optional> orders = viridian_mart_orders(items); if (!orders){ return Pokemon::outcome_failed("unknown_item", step.name); } @@ -186,21 +212,20 @@ class FakeGame : public Pokemon::StoryStepExecutor{ if (cursor < 0 || cursor >= (int)LIST.size() || LIST[cursor] == "cancel"){ return Pokemon::outcome_failed("mart_cancel", std::format("order {} ends on row {}", c + 1, cursor + 1)); } - if (LIST[cursor] != step.items[c].item){ - return Pokemon::outcome_failed("wrong_item", std::format("{} instead of {}", LIST[cursor], step.items[c].item)); + if (LIST[cursor] != items[c].item){ + return Pokemon::outcome_failed("wrong_item", std::format("{} instead of {}", LIST[cursor], items[c].item)); } bag[LIST[cursor]] += order.quantity; } return Pokemon::outcome_ok(); } -private: Outcome walk_to(const Pokemon::Pose& pose, const StoryStep& step){ const Standing at = standing(pose); if (!at.error.empty()){ return Pokemon::outcome_failed("no_pose", at.error); } - const std::optional target = story_pose(*step.target); + const std::optional target = story_pose(Pokemon::pose_of(Pokemon::story_arg(step.args, "target"))); const RouteGoal goal{{target->map, target->tile}, target->facing}; const std::optional> route = plan_overworld_route( story_maps(), at.position, goal, default_route_costs(), at.facing @@ -232,9 +257,7 @@ struct Simulation{ std::vector> saves; Pokemon::SegmentPolicy policy; - // A language no reader supports, so a step that needed text would show. Pokemon::SegmentReport run(const Pokemon::SegmentRange& range){ - game.set_language(Language::Japanese); Pokemon::Segment segment; segment.id = "00"; for (const StoryCheckpoint& data : story_checkpoints()){ @@ -242,7 +265,7 @@ struct Simulation{ .id = data.id, .title = data.title, .saves = true, .build = [this, &data]{ Pokemon::Checkpoint checkpoint = Pokemon::build_story_checkpoint(data, game); - add_start_pose_check(checkpoint, data.start, [this]{ return game.save_stands; }, [this](const std::string& line){ lines.push_back(line); }); + add_start_pose_check(checkpoint, start_pose(data), [this]{ return game.save_stands; }, [this](const std::string& line){ lines.push_back(line); }); return checkpoint; }, }); @@ -333,13 +356,13 @@ UnitTestResult test_whole_story(){ // Each checkpoint starts where the save before it stands. for (size_t c = 1; c < story_checkpoints().size(); c++){ const StoryCheckpoint& data = story_checkpoints()[c]; - const std::optional start = story_pose(*data.start); + const std::optional start = story_pose(*start_pose(data)); const std::optional saved = story_pose(sim.saves[c - 1].second); const bool same = start && saved && start->map == saved->map && start->tile == saved->tile && (!start->facing || start->facing == saved->facing); if (!same){ return std::format("{} starts at {}, but {} saved at {}.", data.id, - Pokemon::to_string(*data.start), sim.saves[c - 1].first, Pokemon::to_string(sim.saves[c - 1].second)); + Pokemon::to_string(*start_pose(data)), sim.saves[c - 1].first, Pokemon::to_string(sim.saves[c - 1].second)); } } if (report.one_shot_passes() != report.checkpoints_run){ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h index d1d3e5d32a..a396b790c7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepInterrupts.h @@ -32,7 +32,7 @@ #include "Pokemon/AutoStory/Pokemon_ScreenEvents.h" #include "Pokemon/AutoStory/Pokemon_StoryActions.h" #include "Pokemon/AutoStory/Pokemon_StoryInterrupts.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h" #include "PokemonFRLG_AutoStoryScreenEvents.h" diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp index 2869e1c299..7d9da2e079 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.cpp @@ -52,10 +52,28 @@ const std::vector& story_action_rows(){ return ROWS; } +std::span story_action_specs(){ + static const std::vector SPECS = []{ + const std::span builtin = Pokemon::builtin_story_actions(); + std::vector specs(builtin.begin(), builtin.end()); + for (StoryStepKind kind : {StoryStepKind::ROUTE, StoryStepKind::LEGS}){ + Pokemon::StoryActionSpec run = *Pokemon::find_story_action(builtin, kind, ""); + run.name = "run"; + specs.push_back(std::move(run)); + } + return specs; + }(); + return SPECS; +} + Pokemon::StoryActionTable make_story_action_table(const StoryActionBinding& bind){ Pokemon::StoryActionTable table; for (const StoryActionRow& row : story_action_rows()){ - table.add(row.kind, row.variant, bind(row.id)); + Pokemon::StoryAction action = bind(row.id); + if (const Pokemon::StoryActionSpec* spec = Pokemon::find_story_action(story_action_specs(), row.kind, row.variant)){ + action.args = spec->args; + } + table.add(row.kind, row.variant, std::move(action)); } return table; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.h index 002e749cb3..3743d498a2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable.h @@ -14,11 +14,13 @@ #define PokemonAutomation_PokemonFRLG_AutoStoryStepTable_H #include +#include #include #include #include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" #include "Pokemon/AutoStory/Pokemon_StoryActions.h" -#include "Pokemon/AutoStory/Pokemon_StorySteps.h" +#include "Pokemon/AutoStory/Pokemon_StoryStepExecutor.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -55,9 +57,16 @@ struct StoryActionRow{ // Every row. TRAIN and SAVE have none: FRLG's story doesn't use them. const std::vector& story_action_rows(); +// The actions FRLG's steps name, with the args each takes: the built-in +// ones (Pokemon_BuiltinStoryActions.h), then a ROUTE and a LEGS named +// "run" (RUN_VARIANT), which take the same args and run with B held. +// A story file is read against these. +std::span story_action_specs(); + // How one binding (the console, a test) does each action. using StoryActionBinding = std::function; -// The rows as a table, each with `bind`'s action for its id. +// The rows as a table, each with `bind`'s action for its id and its +// spec's args. Pokemon::StoryActionTable make_story_action_table(const StoryActionBinding& bind); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp index ef2de6078e..e1903cfcf4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryStepTable_Tests.cpp @@ -98,7 +98,7 @@ std::string parity_error(FakeGame& game, const StoryStep& step){ std::vector trace; const Pokemon::Outcome outcome = game.run(step, trace); const std::optional expected = old_dispatch(step); - const std::string label = std::format("{} '{}' ({})", Pokemon::story_step_kind_name(step.kind), step.variant, step.name); + const std::string label = std::format("{} '{}' ({})", Pokemon::story_step_kind_name(step.kind), step.action, step.name); if (!expected){ if (!trace.empty() || outcome.failure != "unsupported_step"){ return label + ": expected unsupported, ran " + (trace.empty() ? outcome.failure : trace[0]); @@ -126,7 +126,7 @@ std::vector every_kind_and_variant(){ StoryStep step; step.kind = kind; step.name = "synthetic"; - step.variant = variant; + step.action = variant; steps.push_back(std::move(step)); } } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp index 5a88824d81..88573b08af 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp @@ -4,6 +4,14 @@ * */ +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Json/JsonArray.h" +#include "Common/Cpp/Json/JsonObject.h" +#include "Pokemon/AutoStory/Data/Pokemon_AuthoredCheckpointJson.h" +#include "PokemonFRLG_AutoStoryParty.h" +#include "PokemonFRLG_AutoStoryStepTable.h" #include "PokemonFRLG_AutoStoryTable.h" namespace PokemonAutomation{ @@ -13,280 +21,115 @@ namespace PokemonFRLG{ namespace{ -constexpr Direction NORTH = Direction::NORTH; -constexpr Direction SOUTH = Direction::SOUTH; -constexpr Direction EAST = Direction::EAST; -constexpr Direction WEST = Direction::WEST; - -const char* const BEDROOM = "PalletTown_PlayersHouse_2F"; -const char* const PALLET = "PalletTown"; -const char* const LAB = "PalletTown_ProfessorOaksLab"; -const char* const VIRIDIAN = "ViridianCity"; -const char* const VIRIDIAN_MART = "ViridianCity_Mart"; -const char* const VIRIDIAN_CENTER = "ViridianCity_PokemonCenter_1F"; -const char* const FOREST = "ViridianForest"; -const char* const FOREST_GATE = "Route2_ViridianForest_NorthEntrance"; -const char* const PEWTER = "PewterCity"; -const char* const PEWTER_CENTER = "PewterCity_PokemonCenter_1F"; -const char* const GYM = "PewterCity_Gym"; - -Pokemon::Pose at(const char* map, int x, int y, std::optional facing = std::nullopt){ - return to_pose(StoryPose{map, {x, y}, facing}); -} - -StoryCheckpoint row( - std::string id, std::string title, std::optional start, - Supplies supplies, StartMenu menu, std::vector steps -){ - StoryCheckpoint checkpoint; - checkpoint.id = std::move(id); - checkpoint.title = std::move(title); - checkpoint.start = std::move(start); - checkpoint.steps = std::move(steps); - checkpoint.supplies = supplies; - checkpoint.menu = menu; - return checkpoint; -} - -// At the rows after Brock: no items counted, the starter with the moves -// the story gave it by Lv13. A run that loads a save reads the moves off -// the lead's summary instead (read_lead_moves()), so a save whose moves -// differ from these (console B, 2026-11-02: Water Gun where Tackle was) -// is fought with the moves it has. -Supplies after_brock(){ +// The wire names of the START menus. +StartMenu read_start_menu(std::string_view name, std::string_view source){ + if (name == "before_pokemon"){ + return StartMenu::BEFORE_POKEMON; + } + if (name == "before_pokedex"){ + return StartMenu::BEFORE_POKEDEX; + } + if (name == "full"){ + return StartMenu::FULL; + } + throw ParseException(std::format("{}: unknown START menu {}", source, name)); +} + +// `object`'s fields, each of which must be one of `keys`. +void only_fields(const JsonObject& object, std::initializer_list keys, std::string_view source){ + for (const auto& [key, unused] : object){ + bool known = false; + for (std::string_view allowed : keys){ + known |= key == allowed; + } + if (!known){ + throw ParseException(std::format("{}: unsupported execution field {}", source, key)); + } + } +} + +int read_count(const JsonObject& object, const std::string& key, std::string_view source){ + const JsonValue* value = object.get_value(key); + if (value == nullptr){ + return 0; + } + const int64_t count = value->to_integer_throw(std::string(source)); + if (count < 0 || count > 999){ + throw ParseException(std::format("{}: {} out of range", source, key)); + } + return (int)count; +} + +Supplies read_supplies(const JsonObject& execution, std::string_view source){ Supplies supplies; - supplies.lead = story_lead_after_brock(); + if (const JsonObject* items = execution.get_object("supplies")){ + only_fields(*items, {"potions", "antidotes", "parlyz_heals"}, source); + supplies.potions = read_count(*items, "potions", source); + supplies.antidotes = read_count(*items, "antidotes", source); + supplies.parlyz_heals = read_count(*items, "parlyz_heals", source); + } + if (const std::string* lead = execution.get_string("lead")){ + if (*lead != "after_brock"){ + throw ParseException(std::format("{}: unknown lead {}", source, *lead)); + } + supplies.lead = story_lead_after_brock(); + }else if (execution.get_value("lead") != nullptr){ + throw ParseException(std::format("{}: lead must be a string", source)); + } return supplies; } -// What a walk does about wild Pokemon: runs, or fights them for EXP. -enum class WildBattles{ - RUN, - FIGHT, -}; - -StoryStep make(StoryStepKind kind, std::string name, std::string why){ - StoryStep step; - step.kind = kind; - step.name = std::move(name); - step.why = std::move(why); - return step; -} - -StoryStep route(std::string name, Pokemon::Pose target, std::string why, WildBattles wild = WildBattles::RUN){ - StoryStep step = make(StoryStepKind::ROUTE, std::move(name), std::move(why)); - step.target = std::move(target); - step.fight_wild = wild == WildBattles::FIGHT; - return step; -} - -StoryStep step_into(std::string name, Direction direction, std::string why){ - StoryStep step = make(StoryStepKind::STEP, std::move(name), std::move(why)); - step.direction = direction; - return step; -} - -StoryStep answer(std::string name, bool yes, std::string why){ - StoryStep step = make(StoryStepKind::ANSWER, std::move(name), std::move(why)); - step.yes = yes; - return step; -} - -StoryStep scene(std::string name, std::optional pose_after, std::string why){ - StoryStep step = make(StoryStepKind::MASH, std::move(name), std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep battle(std::string name, Pokemon::Pose pose_after, bool may_lose, std::string why){ - StoryStep step = make(StoryStepKind::BATTLE, std::move(name), std::move(why)); - step.pose_after = std::move(pose_after); - step.may_lose = may_lose; - return step; -} - -StoryStep legs(std::string name, std::vector legs, std::string why, WildBattles wild = WildBattles::RUN){ - StoryStep step = make(StoryStepKind::LEGS, std::move(name), std::move(why)); - step.legs = std::move(legs); - step.fight_wild = wild == WildBattles::FIGHT; - return step; -} - -// `step`, a ROUTE or LEGS, run with B held: from the Running Shoes on. No -// checkpoint after 00.10 is in the table yet. -[[maybe_unused]] StoryStep running(StoryStep step){ - step.variant = RUN_VARIANT; - return step; -} - -StoryStep new_game_intro(Pokemon::Pose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::NEW_GAME, "intro", std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep talk(std::string name, std::string why){ - return make(StoryStepKind::TALK, std::move(name), std::move(why)); -} - -StoryStep ready(std::string name, Pokemon::Pose nurse, std::string why){ - StoryStep step = make(StoryStepKind::READY, std::move(name), std::move(why)); - step.target = std::move(nurse); - return step; +// The keys of the notes: "checkpoint" or a step's id, each a list of lines. +std::set read_note_keys(const JsonObject& execution, std::string_view source){ + std::set keys; + const JsonValue* notes = execution.get_value("notes"); + if (notes == nullptr){ + return keys; + } + for (const auto& [key, lines] : notes->to_object_throw(std::string(source))){ + for (const JsonValue& line : lines.to_array_throw(std::string(source))){ + line.to_string_throw(std::string(source)); + } + keys.insert(key); + } + return keys; } -StoryStep heal(std::string name){ - return make(StoryStepKind::HEAL, std::move(name), "full HP"); -} - -StoryStep shop(std::string name, std::vector items, std::string why){ - StoryStep step = make(StoryStepKind::SHOP, std::move(name), std::move(why)); - step.items = std::move(items); - return step; -} - - -StoryCheckpoint new_game(){ - return row("00.01", "new game to the bedroom", std::nullopt, {}, StartMenu::BEFORE_POKEMON, { - // new_game.c: the bedroom at (6, 6), facing the TV. - new_game_intro(at(BEDROOM, 6, 6, NORTH), "Oak's speech, BOY, default names, rival GREEN"), - make(StoryStepKind::OPTIONS, "options", "fast text; no switch prompt between a trainer's Pokemon"), - }); -} - -StoryCheckpoint leave_house(){ - return row("00.02", "bedroom to Pallet Town", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("front_door", at(PALLET, 6, 8), "down the stairs and out of the house"), - }); -} - -StoryCheckpoint oaks_trigger(){ - return row("00.03", "Oak stops the player and walks them to the lab", at(PALLET, 6, 8, SOUTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_oaks_trigger", at(PALLET, 12, 2, NORTH), "below the north exit, short of Oak's trigger at (12, 1)"), - step_into("oaks_trigger", NORTH, "the trigger: \"Don't go out!\""), - // PlayerEnter walks the player up 8 tiles from the lab's door. - scene("to_the_lab", at(LAB, 6, 4, NORTH), "Oak walks the player into the lab; the scene ends at the table"), - }); -} - -StoryCheckpoint starter(){ - return row("00.04", "Squirtle, then the rival's battle", at(LAB, 6, 4, NORTH), {}, StartMenu::BEFORE_POKEDEX, { - route("below_squirtle", at(LAB, 9, 5, NORTH), "under Squirtle's ball (9, 4)"), - talk("squirtle_ball", "\"So, you want the WATER POKEMON SQUIRTLE?\""), - answer("choose_squirtle", true, "take Squirtle"), - answer("no_nickname", false, "\"give a nickname?\" NO"), - scene("rival_takes_bulbasaur", at(LAB, 9, 5, NORTH), "the rival picks his ball; the player still faces the table (console B, 2026-11-01)"), - route("above_rival_trigger", at(LAB, 7, 7, SOUTH), "short of the rival's trigger row 8"), - step_into("rival_trigger", SOUTH, "\"Wait, let's check out our POKEMON!\""), - // The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down. - battle("rival_battle", at(LAB, 7, 8, SOUTH), true, "the tutorial battle; losing goes on too"), - }); -} - -StoryCheckpoint parcel(){ - return row("00.05", "Route 1 to Viridian Mart: Oak's Parcel", at(LAB, 7, 8, SOUTH), {}, StartMenu::BEFORE_POKEDEX, { - route("below_mart_door", at(VIRIDIAN, 36, 20, NORTH), "Route 1, running from wild battles"), - step_into("mart_door", NORTH, "the clerk's scene starts on entering"), - // ApproachCounter: up 4 from the mat, then faces the clerk. - scene("parcel_from_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "the clerk gives OAK'S PARCEL"), - }); -} - -StoryCheckpoint pokedex(){ - return row("00.06", "Oak's Parcel to the Pokedex", at(VIRIDIAN_MART, 4, 3, WEST), {}, StartMenu::FULL, { - route("below_oak", at(LAB, 6, 4, NORTH), "back down Route 1 to Oak"), - talk("give_parcel", "Oak takes the parcel"), - scene("pokedex_scene", at(LAB, 6, 4, SOUTH), "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)"), - }); -} - -StoryCheckpoint shopping(){ - return row("00.07", "Viridian shopping, then into Viridian Forest", at(LAB, 6, 4, SOUTH), {}, StartMenu::FULL, { - route("mart_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "Route 1 again"), - // 2000 of the 3000 a new game starts with, plus the rival's prize. - shop("potions_and_antidotes", {{"potion", 5}, {"antidote", 3}, {"parlyz_heal", 1}}, "5 Potions, 3 Antidotes, 1 Parlyz Heal"), - route("viridian_nurse", at(VIRIDIAN_CENTER, 7, 4, NORTH), "heal before the forest"), - heal("heal_viridian"), - route("below_old_man_trigger", at(VIRIDIAN, 20, 9, NORTH), "short of the tutorial trigger (20, 8)"), - step_into("old_man_trigger", NORTH, "the old man's catching tutorial can't be walked around"), - // TutorialTriggerLeft turns the player right, to the old man. - scene("old_man_tutorial", at(VIRIDIAN, 20, 8, EAST), "about 60 lines and his demo battle; TEACHY TV"), - // After his demo the old man stands east of the player, beside (20, 8), where - // the map doesn't have him: "east 2" from there didn't move, and the walk north - // ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first. - route("past_old_man", at(VIRIDIAN, 20, 5, NORTH), "north along column 20, clear of the old man"), - // The gate's north warp lands on the forest's exit mat (29, 62), facing - // north. The save there keeps a forest failure from going back to Pallet. - route("forest_entrance", at(FOREST, 29, 62, NORTH), "Route 2 and the south gate, running from wild battles"), - }); -} - -StoryCheckpoint forest(){ - // The supplies bought in 00.07. - return row("00.08", "Viridian Forest to Pewter Center", at(FOREST, 29, 62, NORTH), {5, 3, 1}, StartMenu::FULL, { - // Wild battles are fought for EXP. Straight up the east side from the - // entrance, each leg ending on a wall (the Boy at (45, 58) stops the - // east one). Rick (47, 45) sees (42..46, 45), so the last leg meets - // his battle and is held on to its wall after it. The by-hand run's - // detour west to (13, 46) and back is dropped. - legs("forest_east", {{EAST, 1}, {NORTH, 4}, {EAST, 14}, {NORTH, 15}}, "up the east side to (44, 43)", WildBattles::FIGHT), - route("forest_north", at(FOREST, 39, 25), "north part", WildBattles::FIGHT), - // To the gate by legs that end on walls, which the walker holds again - // after a battle instead of estimating where it stopped: planned - // routes with open legs lost the player in the north of the forest - // (console B, 2026-11-01). The two 1-tile legs are single steps. - legs("forest_exit", { - {NORTH, 10}, {WEST, 12}, {SOUTH, 10}, {WEST, 6}, {NORTH, 20}, - {SOUTH, 1}, {WEST, 10}, {SOUTH, 27}, {WEST, 8}, {NORTH, 20}, {EAST, 1}, - }, "walls all the way to the gate's column", WildBattles::FIGHT), - route("forest_gate", at(FOREST_GATE, 7, 10, NORTH), "north onto the exit, arriving on the gate's mat", WildBattles::FIGHT), - // Out of the forest, wild battles are run from; trainers are still fought. - route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "Route 2 north to Pewter's Center"), - heal("heal_pewter"), - }); -} +} // namespace -StoryCheckpoint brock(){ - // The by-hand save: 2 Potions and 1 Antidote left after the forest. - return row("00.09", "Pewter Gym: Camper Liam, then Brock", at(PEWTER_CENTER, 7, 4, NORTH), {2, 1}, StartMenu::FULL, { - // Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight - // 4) and sees (4..7, 8): walking north up column 6 from the door, - // the step onto (6, 8) starts his battle. He walks up to the player, - // who stays put and keeps facing north (FRLG doesn't turn the player - // to a trainer). That step is taken on its own, so no leg is cut. - route("below_liam_line", at(GYM, 6, 9, NORTH), "in by the door, up column 6 to below Liam's row"), - step_into("liam_line", NORTH, "onto (6, 8), in Liam's line"), - battle("camper_liam", at(GYM, 6, 8, NORTH), false, "Geodude and Sandshrew; EXP before Brock"), - // On to Brock unless red HP or a status is left that no item cures. - ready("ready_for_brock", at(PEWTER_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - route("before_brock", at(GYM, 6, 6, NORTH), "below Brock (6, 5); Liam, beaten, stands at (5, 8)"), - talk("challenge_brock", "Brock's speech"), - battle("brock", at(GYM, 6, 6, NORTH), false, "Geodude and Onix, with Bubble; Boulder Badge and TM39"), - }); -} -StoryCheckpoint running_shoes(){ - return row("00.10", "Pewter: the Running Shoes from Oak's aide", at(GYM, 6, 6, NORTH), after_brock(), StartMenu::FULL, { - // Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at - // (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The - // Gym guide's triggers at (42..43, 21..23) need the scene at 0. - route("before_aide_trigger", at(PEWTER, 45, 21, EAST), "out of the Gym, east along row 21, short of the top trigger"), - step_into("aide_trigger", EAST, "onto (46, 21), below the aide"), - // RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; - // the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH - // is set (console B, 2026-11-02: about 20 B presses to the overworld). - scene("shoes_from_aide", at(PEWTER, 46, 21, NORTH), "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north"), - }); +StoryCheckpoint read_story_checkpoint_file(const JsonValue& value, std::string_view source){ + StoryCheckpoint checkpoint; + std::set note_keys; + const Pokemon::ExecutionReader read_execution = [&](const JsonObject& execution, std::string_view where){ + only_fields(execution, {"menu", "supplies", "lead", "notes"}, where); + checkpoint.menu = read_start_menu(execution.get_string_throw("menu", std::string(where)), where); + checkpoint.supplies = read_supplies(execution, where); + note_keys = read_note_keys(execution, where); + }; + static_cast(checkpoint) = Pokemon::read_authored_checkpoint( + value, "frlg", source, read_execution, story_action_specs() + ); + for (const std::string& key : note_keys){ + bool found = key == "checkpoint"; + for (const StoryStep& step : checkpoint.steps){ + found |= step.name == key; + } + if (!found){ + throw ParseException(std::format("{}: notes for unknown step {}", source, key)); + } + } + return checkpoint; } -} // namespace - - const std::vector& story_checkpoints(){ - static const std::vector checkpoints{ - new_game(), leave_house(), oaks_trigger(), starter(), parcel(), pokedex(), shopping(), forest(), brock(), - running_shoes(), - }; + static const std::vector checkpoints = []{ + std::vector result; + for (const auto& [name, text] : autostory_checkpoint_json()){ + result.push_back(read_story_checkpoint_file(parse_json(text), name)); + } + return result; + }(); return checkpoints; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h index ab7731466e..d89e1dcf30 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -7,12 +7,31 @@ * every route and leg runs. Taken from a by-hand run on * console B (2026-11-01) and the pokefirered map scripts. * + * Each checkpoint is an authored JSON file in StoryData/ + * (frlg-.plan.json, format pokesim-authored-checkpoint/1): the shared + * checkpoint, its steps each an action with args, read against FRLG's + * actions (story_action_specs()), and FRLG's execution object: + * + * "menu" before_pokemon, before_pokedex or full: the START menu + * at its end (StoryCheckpoint::menu); + * "supplies" optional: {"potions", "antidotes", "parlyz_heals"} at + * its start, for a run that loads its save; + * "lead" optional: "after_brock", the starter as the story left + * it by Brock (story_lead_after_brock()); + * "notes" optional: {"checkpoint" or a step's id: [lines]}, the + * reasons behind a step that a reader of the file needs. + * The program doesn't read them. + * */ #ifndef PokemonAutomation_PokemonFRLG_AutoStoryTable_H #define PokemonAutomation_PokemonFRLG_AutoStoryTable_H +#include +#include +#include #include +#include "Common/Cpp/Json/JsonValue.h" #include "Common/Cpp/TestRunners/UnitTestDatabase.h" #include "PokemonFRLG_AutoStoryEvents.h" @@ -21,12 +40,23 @@ namespace NintendoSwitch{ namespace PokemonFRLG{ -// Checkpoints 00.01 to 00.10, in order. +// (name, JSON text) of each file in StoryData/, sorted by name. +// Generated at build time (SerialPrograms/cmake/EmbedTextFiles.cmake). +const std::vector>& autostory_checkpoint_json(); + +// The checkpoint of an authored FRLG file. Throws ParseException when +// the file is malformed, names an action FRLG doesn't have, gives an +// action args it doesn't take, or has notes for a step it doesn't have. +StoryCheckpoint read_story_checkpoint_file(const JsonValue& value, std::string_view source); + +// Checkpoints 00.01 to 00.10, in order: every file in StoryData/. const std::vector& story_checkpoints(); // Registers AutoStory table validation unit tests. void add_tests_AutoStory(UnitTestDatabase& database); +// The story files against the C++ rows they replace. +void add_tests_AutoStoryTableParity(UnitTestDatabase& database); // The table run end to end against a fake game (PokemonFRLG_AutoStorySimulation_Tests.cpp). void add_tests_AutoStorySimulation(UnitTestDatabase& database); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp new file mode 100644 index 0000000000..9b592aeed1 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp @@ -0,0 +1,344 @@ +/* AutoStory Table Parity Tests + * + * From: https://github.com/PokemonAutomation/ + * + * The C++ rows the story table had before StoryData/, built with the + * shared step API, against the checkpoints read from the files: each + * loads to the same steps, args (with the fallbacks the reader fills in), + * poses, supplies and START menu. Removed with the C++ rows. + * + */ + +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" +#include "PokemonFRLG_AutoStoryParty.h" +#include "PokemonFRLG_AutoStoryTable.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +constexpr Direction NORTH = Direction::NORTH; +constexpr Direction SOUTH = Direction::SOUTH; +constexpr Direction EAST = Direction::EAST; +constexpr Direction WEST = Direction::WEST; + +constexpr std::string_view BEDROOM = "PalletTown_PlayersHouse_2F"; +constexpr std::string_view PALLET = "PalletTown"; +constexpr std::string_view LAB = "PalletTown_ProfessorOaksLab"; +constexpr std::string_view VIRIDIAN = "ViridianCity"; +constexpr std::string_view VIRIDIAN_MART = "ViridianCity_Mart"; +constexpr std::string_view VIRIDIAN_CENTER = "ViridianCity_PokemonCenter_1F"; +constexpr std::string_view FOREST = "ViridianForest"; +constexpr std::string_view FOREST_GATE = "Route2_ViridianForest_NorthEntrance"; +constexpr std::string_view PEWTER = "PewterCity"; +constexpr std::string_view PEWTER_CENTER = "PewterCity_PokemonCenter_1F"; +constexpr std::string_view GYM = "PewterCity_Gym"; + +Pokemon::GridPose at(std::string_view map, int x, int y, std::optional facing = std::nullopt){ + return Pokemon::GridPose{std::string(map), {{x, y}}, facing}; +} + +StoryCheckpoint row( + std::string id, std::string title, std::optional start, + Supplies supplies, StartMenu menu, std::vector steps +){ + StoryCheckpoint checkpoint; + checkpoint.id = std::move(id); + checkpoint.title = std::move(title); + checkpoint.start = std::move(start); + checkpoint.steps = std::move(steps); + checkpoint.supplies = supplies; + checkpoint.menu = menu; + return checkpoint; +} + +Supplies after_brock(){ + Supplies supplies; + supplies.lead = story_lead_after_brock(); + return supplies; +} + +// What a walk does about wild Pokemon: runs, or fights them for EXP. +enum class WildBattles{ + RUN, + FIGHT, +}; + +StoryStep make(StoryStepKind kind, std::string name, std::string why, Pokemon::StoryActionArgs args = {}){ + StoryStep step; + step.kind = kind; + step.name = std::move(name); + step.why = std::move(why); + step.args = std::move(args); + return step; +} + +StoryStep route(std::string name, Pokemon::GridPose target, std::string why, WildBattles wild = WildBattles::RUN){ + return make(StoryStepKind::ROUTE, std::move(name), std::move(why), { + {"target", std::move(target)}, {"fight_wild", wild == WildBattles::FIGHT}, + }); +} + +StoryStep step_into(std::string name, Direction direction, std::string why){ + return make(StoryStepKind::STEP, std::move(name), std::move(why), {{"direction", direction}}); +} + +StoryStep answer(std::string name, bool yes, std::string why){ + return make(StoryStepKind::ANSWER, std::move(name), std::move(why), {{"yes", yes}}); +} + +StoryStep scene(std::string name, std::optional pose_after, std::string why){ + StoryStep step = make(StoryStepKind::MASH, std::move(name), std::move(why)); + step.pose_after = std::move(pose_after); + return step; +} + +StoryStep battle(std::string name, Pokemon::GridPose pose_after, bool may_lose, std::string why){ + StoryStep step = make(StoryStepKind::BATTLE, std::move(name), std::move(why), {{"may_lose", may_lose}}); + step.pose_after = std::move(pose_after); + return step; +} + +StoryStep legs(std::string name, std::vector legs, std::string why, WildBattles wild = WildBattles::RUN){ + return make(StoryStepKind::LEGS, std::move(name), std::move(why), { + {"legs", std::move(legs)}, {"fight_wild", wild == WildBattles::FIGHT}, + }); +} + +StoryStep new_game_intro(Pokemon::GridPose pose_after, std::string why){ + StoryStep step = make(StoryStepKind::NEW_GAME, "intro", std::move(why)); + step.pose_after = std::move(pose_after); + return step; +} + +StoryStep talk(std::string name, std::string why){ + return make(StoryStepKind::TALK, std::move(name), std::move(why)); +} + +StoryStep ready(std::string name, Pokemon::GridPose nurse, std::string why){ + return make(StoryStepKind::READY, std::move(name), std::move(why), {{"target", std::move(nurse)}}); +} + +StoryStep heal(std::string name){ + return make(StoryStepKind::HEAL, std::move(name), "full HP"); +} + +StoryStep shop(std::string name, std::vector items, std::string why){ + return make(StoryStepKind::SHOP, std::move(name), std::move(why), {{"items", std::move(items)}}); +} + + +StoryCheckpoint new_game(){ + return row("00.01", "new game to the bedroom", std::nullopt, {}, StartMenu::BEFORE_POKEMON, { + // new_game.c: the bedroom at (6, 6), facing the TV. + new_game_intro(at(BEDROOM, 6, 6, NORTH), "Oak's speech, BOY, default names, rival GREEN"), + make(StoryStepKind::OPTIONS, "options", "fast text; no switch prompt between a trainer's Pokemon"), + }); +} + +StoryCheckpoint leave_house(){ + return row("00.02", "bedroom to Pallet Town", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { + route("front_door", at(PALLET, 6, 8), "down the stairs and out of the house"), + }); +} + +StoryCheckpoint oaks_trigger(){ + return row("00.03", "Oak stops the player and walks them to the lab", at(PALLET, 6, 8, SOUTH), {}, StartMenu::BEFORE_POKEMON, { + route("below_oaks_trigger", at(PALLET, 12, 2, NORTH), "below the north exit, short of Oak's trigger at (12, 1)"), + step_into("oaks_trigger", NORTH, "the trigger: \"Don't go out!\""), + // PlayerEnter walks the player up 8 tiles from the lab's door. + scene("to_the_lab", at(LAB, 6, 4, NORTH), "Oak walks the player into the lab; the scene ends at the table"), + }); +} + +StoryCheckpoint starter(){ + return row("00.04", "Squirtle, then the rival's battle", at(LAB, 6, 4, NORTH), {}, StartMenu::BEFORE_POKEDEX, { + route("below_squirtle", at(LAB, 9, 5, NORTH), "under Squirtle's ball (9, 4)"), + talk("squirtle_ball", "\"So, you want the WATER POKEMON SQUIRTLE?\""), + answer("choose_squirtle", true, "take Squirtle"), + answer("no_nickname", false, "\"give a nickname?\" NO"), + scene("rival_takes_bulbasaur", at(LAB, 9, 5, NORTH), "the rival picks his ball; the player still faces the table (console B, 2026-11-01)"), + route("above_rival_trigger", at(LAB, 7, 7, SOUTH), "short of the rival's trigger row 8"), + step_into("rival_trigger", SOUTH, "\"Wait, let's check out our POKEMON!\""), + // The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down. + battle("rival_battle", at(LAB, 7, 8, SOUTH), true, "the tutorial battle; losing goes on too"), + }); +} + +StoryCheckpoint parcel(){ + return row("00.05", "Route 1 to Viridian Mart: Oak's Parcel", at(LAB, 7, 8, SOUTH), {}, StartMenu::BEFORE_POKEDEX, { + route("below_mart_door", at(VIRIDIAN, 36, 20, NORTH), "Route 1, running from wild battles"), + step_into("mart_door", NORTH, "the clerk's scene starts on entering"), + // ApproachCounter: up 4 from the mat, then faces the clerk. + scene("parcel_from_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "the clerk gives OAK'S PARCEL"), + }); +} + +StoryCheckpoint pokedex(){ + return row("00.06", "Oak's Parcel to the Pokedex", at(VIRIDIAN_MART, 4, 3, WEST), {}, StartMenu::FULL, { + route("below_oak", at(LAB, 6, 4, NORTH), "back down Route 1 to Oak"), + talk("give_parcel", "Oak takes the parcel"), + scene("pokedex_scene", at(LAB, 6, 4, SOUTH), "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)"), + }); +} + +StoryCheckpoint shopping(){ + return row("00.07", "Viridian shopping, then into Viridian Forest", at(LAB, 6, 4, SOUTH), {}, StartMenu::FULL, { + route("mart_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "Route 1 again"), + // 2000 of the 3000 a new game starts with, plus the rival's prize. + shop("potions_and_antidotes", {{"potion", 5}, {"antidote", 3}, {"parlyz_heal", 1}}, "5 Potions, 3 Antidotes, 1 Parlyz Heal"), + route("viridian_nurse", at(VIRIDIAN_CENTER, 7, 4, NORTH), "heal before the forest"), + heal("heal_viridian"), + route("below_old_man_trigger", at(VIRIDIAN, 20, 9, NORTH), "short of the tutorial trigger (20, 8)"), + step_into("old_man_trigger", NORTH, "the old man's catching tutorial can't be walked around"), + // TutorialTriggerLeft turns the player right, to the old man. + scene("old_man_tutorial", at(VIRIDIAN, 20, 8, EAST), "about 60 lines and his demo battle; TEACHY TV"), + // After his demo the old man stands east of the player, beside (20, 8), where + // the map doesn't have him: "east 2" from there didn't move, and the walk north + // ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first. + route("past_old_man", at(VIRIDIAN, 20, 5, NORTH), "north along column 20, clear of the old man"), + // The gate's north warp lands on the forest's exit mat (29, 62), facing + // north. The save there keeps a forest failure from going back to Pallet. + route("forest_entrance", at(FOREST, 29, 62, NORTH), "Route 2 and the south gate, running from wild battles"), + }); +} + +StoryCheckpoint forest(){ + // The supplies bought in 00.07. + return row("00.08", "Viridian Forest to Pewter Center", at(FOREST, 29, 62, NORTH), {5, 3, 1}, StartMenu::FULL, { + // Wild battles are fought for EXP. Straight up the east side from the + // entrance, each leg ending on a wall (the Boy at (45, 58) stops the + // east one). Rick (47, 45) sees (42..46, 45), so the last leg meets + // his battle and is held on to its wall after it. The by-hand run's + // detour west to (13, 46) and back is dropped. + legs("forest_east", {{EAST, 1}, {NORTH, 4}, {EAST, 14}, {NORTH, 15}}, "up the east side to (44, 43)", WildBattles::FIGHT), + route("forest_north", at(FOREST, 39, 25), "north part", WildBattles::FIGHT), + // To the gate by legs that end on walls, which the walker holds again + // after a battle instead of estimating where it stopped: planned + // routes with open legs lost the player in the north of the forest + // (console B, 2026-11-01). The two 1-tile legs are single steps. + legs("forest_exit", { + {NORTH, 10}, {WEST, 12}, {SOUTH, 10}, {WEST, 6}, {NORTH, 20}, + {SOUTH, 1}, {WEST, 10}, {SOUTH, 27}, {WEST, 8}, {NORTH, 20}, {EAST, 1}, + }, "walls all the way to the gate's column", WildBattles::FIGHT), + route("forest_gate", at(FOREST_GATE, 7, 10, NORTH), "north onto the exit, arriving on the gate's mat", WildBattles::FIGHT), + // Out of the forest, wild battles are run from; trainers are still fought. + route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "Route 2 north to Pewter's Center"), + heal("heal_pewter"), + }); +} + +StoryCheckpoint brock(){ + // The by-hand save: 2 Potions and 1 Antidote left after the forest. + return row("00.09", "Pewter Gym: Camper Liam, then Brock", at(PEWTER_CENTER, 7, 4, NORTH), {2, 1}, StartMenu::FULL, { + // Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight + // 4) and sees (4..7, 8): walking north up column 6 from the door, + // the step onto (6, 8) starts his battle. He walks up to the player, + // who stays put and keeps facing north (FRLG doesn't turn the player + // to a trainer). That step is taken on its own, so no leg is cut. + route("below_liam_line", at(GYM, 6, 9, NORTH), "in by the door, up column 6 to below Liam's row"), + step_into("liam_line", NORTH, "onto (6, 8), in Liam's line"), + battle("camper_liam", at(GYM, 6, 8, NORTH), false, "Geodude and Sandshrew; EXP before Brock"), + // On to Brock unless red HP or a status is left that no item cures. + ready("ready_for_brock", at(PEWTER_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), + route("before_brock", at(GYM, 6, 6, NORTH), "below Brock (6, 5); Liam, beaten, stands at (5, 8)"), + talk("challenge_brock", "Brock's speech"), + battle("brock", at(GYM, 6, 6, NORTH), false, "Geodude and Onix, with Bubble; Boulder Badge and TM39"), + }); +} + +StoryCheckpoint running_shoes(){ + return row("00.10", "Pewter: the Running Shoes from Oak's aide", at(GYM, 6, 6, NORTH), after_brock(), StartMenu::FULL, { + // Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at + // (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The + // Gym guide's triggers at (42..43, 21..23) need the scene at 0. + route("before_aide_trigger", at(PEWTER, 45, 21, EAST), "out of the Gym, east along row 21, short of the top trigger"), + step_into("aide_trigger", EAST, "onto (46, 21), below the aide"), + // RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; + // the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH + // is set (console B, 2026-11-02: about 20 B presses to the overworld). + scene("shoes_from_aide", at(PEWTER, 46, 21, NORTH), "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north"), + }); +} + + +std::vector cpp_rows(){ + return { + new_game(), leave_house(), oaks_trigger(), starter(), parcel(), pokedex(), shopping(), forest(), brock(), + running_shoes(), + }; +} + +// Why `loaded` differs from `row`, or empty. Steps compare as their +// shared JSON, which writes every field. +std::string checkpoint_difference(const StoryCheckpoint& row, const StoryCheckpoint& loaded){ + const std::string row_json = Pokemon::story_checkpoint_json(row).dump(); + const std::string loaded_json = Pokemon::story_checkpoint_json(loaded).dump(); + if (row_json != loaded_json){ + return std::format("{}: the file loads to\n{}\nbut the C++ row is\n{}", row.id, loaded_json, row_json); + } + if (row.menu != loaded.menu){ + return row.id + ": a different START menu."; + } + const Supplies& a = row.supplies; + const Supplies& b = loaded.supplies; + if (a.potions != b.potions || a.antidotes != b.antidotes || a.parlyz_heals != b.parlyz_heals){ + return row.id + ": different supplies."; + } + if (a.lead.species != b.lead.species || a.lead.level != b.lead.level || a.lead.moves.size() != b.lead.moves.size()){ + return row.id + ": a different lead."; + } + for (size_t c = 0; c < a.lead.moves.size(); c++){ + if (a.lead.moves[c].move != b.lead.moves[c].move || a.lead.moves[c].pp != b.lead.moves[c].pp){ + return row.id + ": a different lead move " + std::to_string(c + 1) + "."; + } + } + return ""; +} + +class Test_AutoStoryTableParity : public UnitTest{ +public: + Test_AutoStoryTableParity() + : UnitTest("PokemonFRLG::AutoStory - the story files load to the C++ rows") + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + try{ + const std::vector rows = cpp_rows(); + const std::vector& loaded = story_checkpoints(); + if (rows.size() != loaded.size()){ + return std::format("{} C++ rows, {} files.", rows.size(), loaded.size()); + } + for (size_t c = 0; c < rows.size(); c++){ + const std::string difference = checkpoint_difference(rows[c], loaded[c]); + if (!difference.empty()){ + return difference; + } + } + return true; + }catch (Exception& e){ + return std::string(e.name()) + ": " + e.message(); + } + } +}; + +} // namespace + + +void add_tests_AutoStoryTableParity(UnitTestDatabase& database){ + database.add(); +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp index ee7c0f43c7..9aa3be8596 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -84,7 +84,8 @@ std::string describe(const StoryPose& pose){ } // A table pose as a StoryPose; FRLG's table has one-tile poses only. -StoryPose one_tile(const Pokemon::Pose& pose){ +StoryPose one_tile(const Pokemon::GridPose& grid_pose){ + const Pokemon::Pose pose = Pokemon::pose_of(grid_pose); const std::optional ret = story_pose(pose); if (!ret){ throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Not a one-tile pose: " + Pokemon::to_string(pose)); @@ -138,7 +139,7 @@ UnitTestResult check_held_legs(const std::string& name, const std::vector> route = fixed_route(story_maps(), MapPosition{pose.map, pose.tile}, step.legs); + const std::optional> route = fixed_route(story_maps(), MapPosition{pose.map, pose.tile}, Pokemon::story_arg>(step.args, "legs")); if (!route || route->empty()){ return step.name + ": the legs can't be walked from " + describe(pose) + "."; } @@ -163,10 +164,7 @@ UnitTestResult check_route(StoryPose& pose, const StoryStep& step){ return step.name + ": the facing is unknown at " + describe(pose) + " and no wall is beside it."; } } - if (!step.target){ - return step.name + ": no target."; - } - const StoryPose target = one_tile(*step.target); + const StoryPose target = one_tile(Pokemon::story_arg(step.args, "target")); const RouteGoal goal{{target.map, target.tile}, target.facing}; const std::optional> route = plan_overworld_route(story_maps(), start, goal, default_route_costs(), facing); if (!route){ @@ -214,7 +212,8 @@ UnitTestResult check_checkpoint(const StoryCheckpoint& checkpoint, StoryPose& po return checkpoint.id + " " + result.message; } }else if (step.kind == StoryStepKind::STEP){ - pose = StoryPose{pose.map, pose.tile.next(step.direction), step.direction}; + const Direction direction = Pokemon::story_arg(step.args, "direction"); + pose = StoryPose{pose.map, pose.tile.next(direction), direction}; } if (step.pose_after){ pose = one_tile(*step.pose_after); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.01.plan.json new file mode 100644 index 0000000000..31eea5b1d0 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.01.plan.json @@ -0,0 +1,29 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.01", + "title": "new game to the bedroom", + "events": [ + { + "id": "intro", + "kind": "new_game", + "declared_after": {"map": "PalletTown_PlayersHouse_2F", "tiles": [[6, 6]], "facing": "north"}, + "why": "Oak's speech, BOY, default names, rival GREEN" + }, + { + "id": "options", + "kind": "options", + "why": "fast text; no switch prompt between a trainer's Pokemon" + } + ] + }, + "execution": { + "menu": "before_pokemon", + "notes": { + "intro": [ + "new_game.c: the bedroom at (6, 6), facing the TV." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.02.plan.json new file mode 100644 index 0000000000..2f09e7db16 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.02.plan.json @@ -0,0 +1,22 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.02", + "title": "bedroom to Pallet Town", + "start": {"map": "PalletTown_PlayersHouse_2F", "tiles": [[6, 6]], "facing": "north"}, + "events": [ + { + "id": "front_door", + "kind": "route", + "args": { + "target": {"map": "PalletTown", "tiles": [[6, 8]]} + }, + "why": "down the stairs and out of the house" + } + ] + }, + "execution": { + "menu": "before_pokemon" + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.03.plan.json new file mode 100644 index 0000000000..b44478b878 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.03.plan.json @@ -0,0 +1,41 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.03", + "title": "Oak stops the player and walks them to the lab", + "start": {"map": "PalletTown", "tiles": [[6, 8]], "facing": "south"}, + "events": [ + { + "id": "below_oaks_trigger", + "kind": "route", + "args": { + "target": {"map": "PalletTown", "tiles": [[12, 2]], "facing": "north"} + }, + "why": "below the north exit, short of Oak's trigger at (12, 1)" + }, + { + "id": "oaks_trigger", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "the trigger: \"Don't go out!\"" + }, + { + "id": "to_the_lab", + "kind": "scene", + "declared_after": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[6, 4]], "facing": "north"}, + "why": "Oak walks the player into the lab; the scene ends at the table" + } + ] + }, + "execution": { + "menu": "before_pokemon", + "notes": { + "to_the_lab": [ + "PlayerEnter walks the player up 8 tiles from the lab's door." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.04.plan.json new file mode 100644 index 0000000000..af5c28173a --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.04.plan.json @@ -0,0 +1,76 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.04", + "title": "Squirtle, then the rival's battle", + "start": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[6, 4]], "facing": "north"}, + "events": [ + { + "id": "below_squirtle", + "kind": "route", + "args": { + "target": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[9, 5]], "facing": "north"} + }, + "why": "under Squirtle's ball (9, 4)" + }, + { + "id": "squirtle_ball", + "kind": "talk", + "why": "\"So, you want the WATER POKEMON SQUIRTLE?\"" + }, + { + "id": "choose_squirtle", + "kind": "answer", + "why": "take Squirtle" + }, + { + "id": "no_nickname", + "kind": "answer", + "args": { + "yes": false + }, + "why": "\"give a nickname?\" NO" + }, + { + "id": "rival_takes_bulbasaur", + "kind": "scene", + "declared_after": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[9, 5]], "facing": "north"}, + "why": "the rival picks his ball; the player still faces the table (console B, 2026-11-01)" + }, + { + "id": "above_rival_trigger", + "kind": "route", + "args": { + "target": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[7, 7]], "facing": "south"} + }, + "why": "short of the rival's trigger row 8" + }, + { + "id": "rival_trigger", + "kind": "step", + "args": { + "direction": "south" + }, + "why": "\"Wait, let's check out our POKEMON!\"" + }, + { + "id": "rival_battle", + "kind": "battle", + "args": { + "may_lose": true + }, + "declared_after": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[7, 8]], "facing": "south"}, + "why": "the tutorial battle; losing goes on too" + } + ] + }, + "execution": { + "menu": "before_pokedex", + "notes": { + "rival_battle": [ + "The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.05.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.05.plan.json new file mode 100644 index 0000000000..d3923d0565 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.05.plan.json @@ -0,0 +1,41 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.05", + "title": "Route 1 to Viridian Mart: Oak's Parcel", + "start": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[7, 8]], "facing": "south"}, + "events": [ + { + "id": "below_mart_door", + "kind": "route", + "args": { + "target": {"map": "ViridianCity", "tiles": [[36, 20]], "facing": "north"} + }, + "why": "Route 1, running from wild battles" + }, + { + "id": "mart_door", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "the clerk's scene starts on entering" + }, + { + "id": "parcel_from_clerk", + "kind": "scene", + "declared_after": {"map": "ViridianCity_Mart", "tiles": [[4, 3]], "facing": "west"}, + "why": "the clerk gives OAK'S PARCEL" + } + ] + }, + "execution": { + "menu": "before_pokedex", + "notes": { + "parcel_from_clerk": [ + "ApproachCounter: up 4 from the mat, then faces the clerk." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.06.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.06.plan.json new file mode 100644 index 0000000000..431917879d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.06.plan.json @@ -0,0 +1,33 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.06", + "title": "Oak's Parcel to the Pokedex", + "start": {"map": "ViridianCity_Mart", "tiles": [[4, 3]], "facing": "west"}, + "events": [ + { + "id": "below_oak", + "kind": "route", + "args": { + "target": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[6, 4]], "facing": "north"} + }, + "why": "back down Route 1 to Oak" + }, + { + "id": "give_parcel", + "kind": "talk", + "why": "Oak takes the parcel" + }, + { + "id": "pokedex_scene", + "kind": "scene", + "declared_after": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[6, 4]], "facing": "south"}, + "why": "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)" + } + ] + }, + "execution": { + "menu": "full" + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.07.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.07.plan.json new file mode 100644 index 0000000000..4abe1885aa --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.07.plan.json @@ -0,0 +1,95 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.07", + "title": "Viridian shopping, then into Viridian Forest", + "start": {"map": "PalletTown_ProfessorOaksLab", "tiles": [[6, 4]], "facing": "south"}, + "events": [ + { + "id": "mart_clerk", + "kind": "route", + "args": { + "target": {"map": "ViridianCity_Mart", "tiles": [[4, 3]], "facing": "west"} + }, + "why": "Route 1 again" + }, + { + "id": "potions_and_antidotes", + "kind": "shop", + "args": { + "items": [{"item": "potion", "quantity": 5}, {"item": "antidote", "quantity": 3}, {"item": "parlyz_heal", "quantity": 1}] + }, + "why": "5 Potions, 3 Antidotes, 1 Parlyz Heal" + }, + { + "id": "viridian_nurse", + "kind": "route", + "args": { + "target": {"map": "ViridianCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "heal before the forest" + }, + { + "id": "heal_viridian", + "kind": "heal", + "why": "full HP" + }, + { + "id": "below_old_man_trigger", + "kind": "route", + "args": { + "target": {"map": "ViridianCity", "tiles": [[20, 9]], "facing": "north"} + }, + "why": "short of the tutorial trigger (20, 8)" + }, + { + "id": "old_man_trigger", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "the old man's catching tutorial can't be walked around" + }, + { + "id": "old_man_tutorial", + "kind": "scene", + "declared_after": {"map": "ViridianCity", "tiles": [[20, 8]], "facing": "east"}, + "why": "about 60 lines and his demo battle; TEACHY TV" + }, + { + "id": "past_old_man", + "kind": "route", + "args": { + "target": {"map": "ViridianCity", "tiles": [[20, 5]], "facing": "north"} + }, + "why": "north along column 20, clear of the old man" + }, + { + "id": "forest_entrance", + "kind": "route", + "args": { + "target": {"map": "ViridianForest", "tiles": [[29, 62]], "facing": "north"} + }, + "why": "Route 2 and the south gate, running from wild battles" + } + ] + }, + "execution": { + "menu": "full", + "notes": { + "potions_and_antidotes": [ + "2000 of the 3000 a new game starts with, plus the rival's prize." + ], + "old_man_tutorial": [ + "TutorialTriggerLeft turns the player right, to the old man." + ], + "past_old_man": [ + "After his demo the old man stands east of the player, beside (20, 8), where the map doesn't have him: \"east 2\" from there didn't move, and the walk north ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first." + ], + "forest_entrance": [ + "The gate's north warp lands on the forest's exit mat (29, 62), facing north. The save there keeps a forest failure from going back to Pallet." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.08.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.08.plan.json new file mode 100644 index 0000000000..c02e6e877f --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.08.plan.json @@ -0,0 +1,82 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.08", + "title": "Viridian Forest to Pewter Center", + "start": {"map": "ViridianForest", "tiles": [[29, 62]], "facing": "north"}, + "events": [ + { + "id": "forest_east", + "kind": "legs", + "args": { + "legs": [{"direction": "east", "tiles": 1}, {"direction": "north", "tiles": 4}, {"direction": "east", "tiles": 14}, {"direction": "north", "tiles": 15}], + "fight_wild": true + }, + "why": "up the east side to (44, 43)" + }, + { + "id": "forest_north", + "kind": "route", + "args": { + "target": {"map": "ViridianForest", "tiles": [[39, 25]]}, + "fight_wild": true + }, + "why": "north part" + }, + { + "id": "forest_exit", + "kind": "legs", + "args": { + "legs": [{"direction": "north", "tiles": 10}, {"direction": "west", "tiles": 12}, {"direction": "south", "tiles": 10}, {"direction": "west", "tiles": 6}, {"direction": "north", "tiles": 20}, {"direction": "south", "tiles": 1}, {"direction": "west", "tiles": 10}, {"direction": "south", "tiles": 27}, {"direction": "west", "tiles": 8}, {"direction": "north", "tiles": 20}, {"direction": "east", "tiles": 1}], + "fight_wild": true + }, + "why": "walls all the way to the gate's column" + }, + { + "id": "forest_gate", + "kind": "route", + "args": { + "target": {"map": "Route2_ViridianForest_NorthEntrance", "tiles": [[7, 10]], "facing": "north"}, + "fight_wild": true + }, + "why": "north onto the exit, arriving on the gate's mat" + }, + { + "id": "pewter_nurse", + "kind": "route", + "args": { + "target": {"map": "PewterCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "Route 2 north to Pewter's Center" + }, + { + "id": "heal_pewter", + "kind": "heal", + "why": "full HP" + } + ] + }, + "execution": { + "menu": "full", + "supplies": { + "potions": 5, + "antidotes": 3, + "parlyz_heals": 1 + }, + "notes": { + "checkpoint": [ + "The supplies bought in 00.07." + ], + "forest_east": [ + "Wild battles are fought for EXP. Straight up the east side from the entrance, each leg ending on a wall (the Boy at (45, 58) stops the east one). Rick (47, 45) sees (42..46, 45), so the last leg meets his battle and is held on to its wall after it. The by-hand run's detour west to (13, 46) and back is dropped." + ], + "forest_exit": [ + "To the gate by legs that end on walls, which the walker holds again after a battle instead of estimating where it stopped: planned routes with open legs lost the player in the north of the forest (console B, 2026-11-01). The two 1-tile legs are single steps." + ], + "pewter_nurse": [ + "Out of the forest, wild battles are run from; trainers are still fought." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.09.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.09.plan.json new file mode 100644 index 0000000000..28b36cc3e4 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.09.plan.json @@ -0,0 +1,79 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.09", + "title": "Pewter Gym: Camper Liam, then Brock", + "start": {"map": "PewterCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"}, + "events": [ + { + "id": "below_liam_line", + "kind": "route", + "args": { + "target": {"map": "PewterCity_Gym", "tiles": [[6, 9]], "facing": "north"} + }, + "why": "in by the door, up column 6 to below Liam's row" + }, + { + "id": "liam_line", + "kind": "step", + "args": { + "direction": "north" + }, + "why": "onto (6, 8), in Liam's line" + }, + { + "id": "camper_liam", + "kind": "battle", + "declared_after": {"map": "PewterCity_Gym", "tiles": [[6, 8]], "facing": "north"}, + "why": "Geodude and Sandshrew; EXP before Brock" + }, + { + "id": "ready_for_brock", + "kind": "ready", + "args": { + "target": {"map": "PewterCity_PokemonCenter_1F", "tiles": [[7, 4]], "facing": "north"} + }, + "why": "items for a status or low HP; the nurse only if they can't" + }, + { + "id": "before_brock", + "kind": "route", + "args": { + "target": {"map": "PewterCity_Gym", "tiles": [[6, 6]], "facing": "north"} + }, + "why": "below Brock (6, 5); Liam, beaten, stands at (5, 8)" + }, + { + "id": "challenge_brock", + "kind": "talk", + "why": "Brock's speech" + }, + { + "id": "brock", + "kind": "battle", + "declared_after": {"map": "PewterCity_Gym", "tiles": [[6, 6]], "facing": "north"}, + "why": "Geodude and Onix, with Bubble; Boulder Badge and TM39" + } + ] + }, + "execution": { + "menu": "full", + "supplies": { + "potions": 2, + "antidotes": 1, + "parlyz_heals": 0 + }, + "notes": { + "checkpoint": [ + "The by-hand save: 2 Potions and 1 Antidote left after the forest." + ], + "below_liam_line": [ + "Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight 4) and sees (4..7, 8): walking north up column 6 from the door, the step onto (6, 8) starts his battle. He walks up to the player, who stays put and keeps facing north (FRLG doesn't turn the player to a trainer). That step is taken on its own, so no leg is cut." + ], + "ready_for_brock": [ + "On to Brock unless red HP or a status is left that no item cures." + ] + } + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.10.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.10.plan.json new file mode 100644 index 0000000000..b8cf6a8ccd --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-00.10.plan.json @@ -0,0 +1,48 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "frlg", + "checkpoint": { + "id": "00.10", + "title": "Pewter: the Running Shoes from Oak's aide", + "start": {"map": "PewterCity_Gym", "tiles": [[6, 6]], "facing": "north"}, + "events": [ + { + "id": "before_aide_trigger", + "kind": "route", + "args": { + "target": {"map": "PewterCity", "tiles": [[45, 21]], "facing": "east"} + }, + "why": "out of the Gym, east along row 21, short of the top trigger" + }, + { + "id": "aide_trigger", + "kind": "step", + "args": { + "direction": "east" + }, + "why": "onto (46, 21), below the aide" + }, + { + "id": "shoes_from_aide", + "kind": "scene", + "declared_after": {"map": "PewterCity", "tiles": [[46, 21]], "facing": "north"}, + "why": "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north" + } + ] + }, + "execution": { + "menu": "full", + "lead": "after_brock", + "notes": { + "checkpoint": [ + "At the rows after Brock: no items counted, the starter with the moves the story gave it by Lv13. A run that loads a save reads the moves off the lead's summary instead (read_lead_moves()), so a save whose moves differ from these (console B, 2026-11-02: Water Gun where Tackle was) is fought with the moves it has." + ], + "before_aide_trigger": [ + "Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The Gym guide's triggers at (42..43, 21..23) need the scene at 0." + ], + "shoes_from_aide": [ + "RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH is set (console B, 2026-11-02: about 20 B presses to the overworld)." + ] + } + } +} diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 9de1bf1a1f..cb22d12626 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1947,6 +1947,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryWinChance.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryWinChance.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp From 3f0b338f11daad2b62feae9ecccc12791313815a Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 09:59:00 -0800 Subject: [PATCH 2/8] FRLG AutoStory: delete the C++ story rows, parity proven The previous commit's parity test passed: every StoryData file loads to its old C++ row. The rows and the test go; StoryData/ is the table. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG/PokemonFRLG_Tests.cpp | 1 - .../AutoStory/PokemonFRLG_AutoStoryTable.h | 2 - ...PokemonFRLG_AutoStoryTableParity_Tests.cpp | 344 ------------------ SerialPrograms/cmake/SourceFiles.cmake | 1 - 4 files changed, 348 deletions(-) delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 4a5a0b5310..cea4ff7bc9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -319,7 +319,6 @@ void add_tests(UnitTestDatabase& database){ add_tests_OverworldRecovery(database); add_tests_PlayerFacingReader(database); add_tests_AutoStory(database); - add_tests_AutoStoryTableParity(database); add_tests_AutoStoryExport(database); add_tests_AutoStorySimulation(database); add_tests_AutoStoryItems(database); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h index d89e1dcf30..99d5ed45d4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -55,8 +55,6 @@ const std::vector& story_checkpoints(); // Registers AutoStory table validation unit tests. void add_tests_AutoStory(UnitTestDatabase& database); -// The story files against the C++ rows they replace. -void add_tests_AutoStoryTableParity(UnitTestDatabase& database); // The table run end to end against a fake game (PokemonFRLG_AutoStorySimulation_Tests.cpp). void add_tests_AutoStorySimulation(UnitTestDatabase& database); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp deleted file mode 100644 index 9b592aeed1..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/* AutoStory Table Parity Tests - * - * From: https://github.com/PokemonAutomation/ - * - * The C++ rows the story table had before StoryData/, built with the - * shared step API, against the checkpoints read from the files: each - * loads to the same steps, args (with the fallbacks the reader fills in), - * poses, supplies and START menu. Removed with the C++ rows. - * - */ - -#include -#include -#include -#include -#include "Common/Cpp/Exceptions.h" -#include "Common/Cpp/TestRunners/UnitTest.h" -#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" -#include "PokemonFRLG_AutoStoryParty.h" -#include "PokemonFRLG_AutoStoryTable.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -namespace{ - -constexpr Direction NORTH = Direction::NORTH; -constexpr Direction SOUTH = Direction::SOUTH; -constexpr Direction EAST = Direction::EAST; -constexpr Direction WEST = Direction::WEST; - -constexpr std::string_view BEDROOM = "PalletTown_PlayersHouse_2F"; -constexpr std::string_view PALLET = "PalletTown"; -constexpr std::string_view LAB = "PalletTown_ProfessorOaksLab"; -constexpr std::string_view VIRIDIAN = "ViridianCity"; -constexpr std::string_view VIRIDIAN_MART = "ViridianCity_Mart"; -constexpr std::string_view VIRIDIAN_CENTER = "ViridianCity_PokemonCenter_1F"; -constexpr std::string_view FOREST = "ViridianForest"; -constexpr std::string_view FOREST_GATE = "Route2_ViridianForest_NorthEntrance"; -constexpr std::string_view PEWTER = "PewterCity"; -constexpr std::string_view PEWTER_CENTER = "PewterCity_PokemonCenter_1F"; -constexpr std::string_view GYM = "PewterCity_Gym"; - -Pokemon::GridPose at(std::string_view map, int x, int y, std::optional facing = std::nullopt){ - return Pokemon::GridPose{std::string(map), {{x, y}}, facing}; -} - -StoryCheckpoint row( - std::string id, std::string title, std::optional start, - Supplies supplies, StartMenu menu, std::vector steps -){ - StoryCheckpoint checkpoint; - checkpoint.id = std::move(id); - checkpoint.title = std::move(title); - checkpoint.start = std::move(start); - checkpoint.steps = std::move(steps); - checkpoint.supplies = supplies; - checkpoint.menu = menu; - return checkpoint; -} - -Supplies after_brock(){ - Supplies supplies; - supplies.lead = story_lead_after_brock(); - return supplies; -} - -// What a walk does about wild Pokemon: runs, or fights them for EXP. -enum class WildBattles{ - RUN, - FIGHT, -}; - -StoryStep make(StoryStepKind kind, std::string name, std::string why, Pokemon::StoryActionArgs args = {}){ - StoryStep step; - step.kind = kind; - step.name = std::move(name); - step.why = std::move(why); - step.args = std::move(args); - return step; -} - -StoryStep route(std::string name, Pokemon::GridPose target, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::ROUTE, std::move(name), std::move(why), { - {"target", std::move(target)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -StoryStep step_into(std::string name, Direction direction, std::string why){ - return make(StoryStepKind::STEP, std::move(name), std::move(why), {{"direction", direction}}); -} - -StoryStep answer(std::string name, bool yes, std::string why){ - return make(StoryStepKind::ANSWER, std::move(name), std::move(why), {{"yes", yes}}); -} - -StoryStep scene(std::string name, std::optional pose_after, std::string why){ - StoryStep step = make(StoryStepKind::MASH, std::move(name), std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep battle(std::string name, Pokemon::GridPose pose_after, bool may_lose, std::string why){ - StoryStep step = make(StoryStepKind::BATTLE, std::move(name), std::move(why), {{"may_lose", may_lose}}); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep legs(std::string name, std::vector legs, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::LEGS, std::move(name), std::move(why), { - {"legs", std::move(legs)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -StoryStep new_game_intro(Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::NEW_GAME, "intro", std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep talk(std::string name, std::string why){ - return make(StoryStepKind::TALK, std::move(name), std::move(why)); -} - -StoryStep ready(std::string name, Pokemon::GridPose nurse, std::string why){ - return make(StoryStepKind::READY, std::move(name), std::move(why), {{"target", std::move(nurse)}}); -} - -StoryStep heal(std::string name){ - return make(StoryStepKind::HEAL, std::move(name), "full HP"); -} - -StoryStep shop(std::string name, std::vector items, std::string why){ - return make(StoryStepKind::SHOP, std::move(name), std::move(why), {{"items", std::move(items)}}); -} - - -StoryCheckpoint new_game(){ - return row("00.01", "new game to the bedroom", std::nullopt, {}, StartMenu::BEFORE_POKEMON, { - // new_game.c: the bedroom at (6, 6), facing the TV. - new_game_intro(at(BEDROOM, 6, 6, NORTH), "Oak's speech, BOY, default names, rival GREEN"), - make(StoryStepKind::OPTIONS, "options", "fast text; no switch prompt between a trainer's Pokemon"), - }); -} - -StoryCheckpoint leave_house(){ - return row("00.02", "bedroom to Pallet Town", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("front_door", at(PALLET, 6, 8), "down the stairs and out of the house"), - }); -} - -StoryCheckpoint oaks_trigger(){ - return row("00.03", "Oak stops the player and walks them to the lab", at(PALLET, 6, 8, SOUTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_oaks_trigger", at(PALLET, 12, 2, NORTH), "below the north exit, short of Oak's trigger at (12, 1)"), - step_into("oaks_trigger", NORTH, "the trigger: \"Don't go out!\""), - // PlayerEnter walks the player up 8 tiles from the lab's door. - scene("to_the_lab", at(LAB, 6, 4, NORTH), "Oak walks the player into the lab; the scene ends at the table"), - }); -} - -StoryCheckpoint starter(){ - return row("00.04", "Squirtle, then the rival's battle", at(LAB, 6, 4, NORTH), {}, StartMenu::BEFORE_POKEDEX, { - route("below_squirtle", at(LAB, 9, 5, NORTH), "under Squirtle's ball (9, 4)"), - talk("squirtle_ball", "\"So, you want the WATER POKEMON SQUIRTLE?\""), - answer("choose_squirtle", true, "take Squirtle"), - answer("no_nickname", false, "\"give a nickname?\" NO"), - scene("rival_takes_bulbasaur", at(LAB, 9, 5, NORTH), "the rival picks his ball; the player still faces the table (console B, 2026-11-01)"), - route("above_rival_trigger", at(LAB, 7, 7, SOUTH), "short of the rival's trigger row 8"), - step_into("rival_trigger", SOUTH, "\"Wait, let's check out our POKEMON!\""), - // The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down. - battle("rival_battle", at(LAB, 7, 8, SOUTH), true, "the tutorial battle; losing goes on too"), - }); -} - -StoryCheckpoint parcel(){ - return row("00.05", "Route 1 to Viridian Mart: Oak's Parcel", at(LAB, 7, 8, SOUTH), {}, StartMenu::BEFORE_POKEDEX, { - route("below_mart_door", at(VIRIDIAN, 36, 20, NORTH), "Route 1, running from wild battles"), - step_into("mart_door", NORTH, "the clerk's scene starts on entering"), - // ApproachCounter: up 4 from the mat, then faces the clerk. - scene("parcel_from_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "the clerk gives OAK'S PARCEL"), - }); -} - -StoryCheckpoint pokedex(){ - return row("00.06", "Oak's Parcel to the Pokedex", at(VIRIDIAN_MART, 4, 3, WEST), {}, StartMenu::FULL, { - route("below_oak", at(LAB, 6, 4, NORTH), "back down Route 1 to Oak"), - talk("give_parcel", "Oak takes the parcel"), - scene("pokedex_scene", at(LAB, 6, 4, SOUTH), "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)"), - }); -} - -StoryCheckpoint shopping(){ - return row("00.07", "Viridian shopping, then into Viridian Forest", at(LAB, 6, 4, SOUTH), {}, StartMenu::FULL, { - route("mart_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "Route 1 again"), - // 2000 of the 3000 a new game starts with, plus the rival's prize. - shop("potions_and_antidotes", {{"potion", 5}, {"antidote", 3}, {"parlyz_heal", 1}}, "5 Potions, 3 Antidotes, 1 Parlyz Heal"), - route("viridian_nurse", at(VIRIDIAN_CENTER, 7, 4, NORTH), "heal before the forest"), - heal("heal_viridian"), - route("below_old_man_trigger", at(VIRIDIAN, 20, 9, NORTH), "short of the tutorial trigger (20, 8)"), - step_into("old_man_trigger", NORTH, "the old man's catching tutorial can't be walked around"), - // TutorialTriggerLeft turns the player right, to the old man. - scene("old_man_tutorial", at(VIRIDIAN, 20, 8, EAST), "about 60 lines and his demo battle; TEACHY TV"), - // After his demo the old man stands east of the player, beside (20, 8), where - // the map doesn't have him: "east 2" from there didn't move, and the walk north - // ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first. - route("past_old_man", at(VIRIDIAN, 20, 5, NORTH), "north along column 20, clear of the old man"), - // The gate's north warp lands on the forest's exit mat (29, 62), facing - // north. The save there keeps a forest failure from going back to Pallet. - route("forest_entrance", at(FOREST, 29, 62, NORTH), "Route 2 and the south gate, running from wild battles"), - }); -} - -StoryCheckpoint forest(){ - // The supplies bought in 00.07. - return row("00.08", "Viridian Forest to Pewter Center", at(FOREST, 29, 62, NORTH), {5, 3, 1}, StartMenu::FULL, { - // Wild battles are fought for EXP. Straight up the east side from the - // entrance, each leg ending on a wall (the Boy at (45, 58) stops the - // east one). Rick (47, 45) sees (42..46, 45), so the last leg meets - // his battle and is held on to its wall after it. The by-hand run's - // detour west to (13, 46) and back is dropped. - legs("forest_east", {{EAST, 1}, {NORTH, 4}, {EAST, 14}, {NORTH, 15}}, "up the east side to (44, 43)", WildBattles::FIGHT), - route("forest_north", at(FOREST, 39, 25), "north part", WildBattles::FIGHT), - // To the gate by legs that end on walls, which the walker holds again - // after a battle instead of estimating where it stopped: planned - // routes with open legs lost the player in the north of the forest - // (console B, 2026-11-01). The two 1-tile legs are single steps. - legs("forest_exit", { - {NORTH, 10}, {WEST, 12}, {SOUTH, 10}, {WEST, 6}, {NORTH, 20}, - {SOUTH, 1}, {WEST, 10}, {SOUTH, 27}, {WEST, 8}, {NORTH, 20}, {EAST, 1}, - }, "walls all the way to the gate's column", WildBattles::FIGHT), - route("forest_gate", at(FOREST_GATE, 7, 10, NORTH), "north onto the exit, arriving on the gate's mat", WildBattles::FIGHT), - // Out of the forest, wild battles are run from; trainers are still fought. - route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "Route 2 north to Pewter's Center"), - heal("heal_pewter"), - }); -} - -StoryCheckpoint brock(){ - // The by-hand save: 2 Potions and 1 Antidote left after the forest. - return row("00.09", "Pewter Gym: Camper Liam, then Brock", at(PEWTER_CENTER, 7, 4, NORTH), {2, 1}, StartMenu::FULL, { - // Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight - // 4) and sees (4..7, 8): walking north up column 6 from the door, - // the step onto (6, 8) starts his battle. He walks up to the player, - // who stays put and keeps facing north (FRLG doesn't turn the player - // to a trainer). That step is taken on its own, so no leg is cut. - route("below_liam_line", at(GYM, 6, 9, NORTH), "in by the door, up column 6 to below Liam's row"), - step_into("liam_line", NORTH, "onto (6, 8), in Liam's line"), - battle("camper_liam", at(GYM, 6, 8, NORTH), false, "Geodude and Sandshrew; EXP before Brock"), - // On to Brock unless red HP or a status is left that no item cures. - ready("ready_for_brock", at(PEWTER_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - route("before_brock", at(GYM, 6, 6, NORTH), "below Brock (6, 5); Liam, beaten, stands at (5, 8)"), - talk("challenge_brock", "Brock's speech"), - battle("brock", at(GYM, 6, 6, NORTH), false, "Geodude and Onix, with Bubble; Boulder Badge and TM39"), - }); -} - -StoryCheckpoint running_shoes(){ - return row("00.10", "Pewter: the Running Shoes from Oak's aide", at(GYM, 6, 6, NORTH), after_brock(), StartMenu::FULL, { - // Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at - // (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The - // Gym guide's triggers at (42..43, 21..23) need the scene at 0. - route("before_aide_trigger", at(PEWTER, 45, 21, EAST), "out of the Gym, east along row 21, short of the top trigger"), - step_into("aide_trigger", EAST, "onto (46, 21), below the aide"), - // RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; - // the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH - // is set (console B, 2026-11-02: about 20 B presses to the overworld). - scene("shoes_from_aide", at(PEWTER, 46, 21, NORTH), "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north"), - }); -} - - -std::vector cpp_rows(){ - return { - new_game(), leave_house(), oaks_trigger(), starter(), parcel(), pokedex(), shopping(), forest(), brock(), - running_shoes(), - }; -} - -// Why `loaded` differs from `row`, or empty. Steps compare as their -// shared JSON, which writes every field. -std::string checkpoint_difference(const StoryCheckpoint& row, const StoryCheckpoint& loaded){ - const std::string row_json = Pokemon::story_checkpoint_json(row).dump(); - const std::string loaded_json = Pokemon::story_checkpoint_json(loaded).dump(); - if (row_json != loaded_json){ - return std::format("{}: the file loads to\n{}\nbut the C++ row is\n{}", row.id, loaded_json, row_json); - } - if (row.menu != loaded.menu){ - return row.id + ": a different START menu."; - } - const Supplies& a = row.supplies; - const Supplies& b = loaded.supplies; - if (a.potions != b.potions || a.antidotes != b.antidotes || a.parlyz_heals != b.parlyz_heals){ - return row.id + ": different supplies."; - } - if (a.lead.species != b.lead.species || a.lead.level != b.lead.level || a.lead.moves.size() != b.lead.moves.size()){ - return row.id + ": a different lead."; - } - for (size_t c = 0; c < a.lead.moves.size(); c++){ - if (a.lead.moves[c].move != b.lead.moves[c].move || a.lead.moves[c].pp != b.lead.moves[c].pp){ - return row.id + ": a different lead move " + std::to_string(c + 1) + "."; - } - } - return ""; -} - -class Test_AutoStoryTableParity : public UnitTest{ -public: - Test_AutoStoryTableParity() - : UnitTest("PokemonFRLG::AutoStory - the story files load to the C++ rows") - {} - virtual UnitTestResult run(Logger&, CancellableScope&) const override{ - try{ - const std::vector rows = cpp_rows(); - const std::vector& loaded = story_checkpoints(); - if (rows.size() != loaded.size()){ - return std::format("{} C++ rows, {} files.", rows.size(), loaded.size()); - } - for (size_t c = 0; c < rows.size(); c++){ - const std::string difference = checkpoint_difference(rows[c], loaded[c]); - if (!difference.empty()){ - return difference; - } - } - return true; - }catch (Exception& e){ - return std::string(e.name()) + ": " + e.message(); - } - } -}; - -} // namespace - - -void add_tests_AutoStoryTableParity(UnitTestDatabase& database){ - database.add(); -} - - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index cb22d12626..9de1bf1a1f 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1947,7 +1947,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryWinChance.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryWinChance.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp From 9d54f1bd4d91f279edaad19b6d8cc48bbe4df1b5 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 10:03:35 -0800 Subject: [PATCH 3/8] FRLG AutoStory: delete stage 2's C++ story rows, parity proven The merge's parity test passed: every StoryData file, 00.01b and the 00.04/00.04b split included, loads to its C++ row. The rows and the test go. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG/PokemonFRLG_Tests.cpp | 1 - .../AutoStory/PokemonFRLG_AutoStoryTable.h | 2 - ...PokemonFRLG_AutoStoryTableParity_Tests.cpp | 379 ------------------ SerialPrograms/cmake/SourceFiles.cmake | 1 - 4 files changed, 383 deletions(-) delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 5c65e8ee28..bc405956b3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -911,7 +911,6 @@ void add_tests(UnitTestDatabase& database){ add_tests_OverworldRecovery(database); add_tests_PlayerFacingReader(database); add_tests_AutoStory(database); - add_tests_AutoStoryTableParity(database); add_tests_AutoStoryExport(database); add_tests_AutoStorySimulation(database); add_tests_AutoStoryItems(database); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h index 50bfe92342..0201a8e65f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -61,8 +61,6 @@ const std::vector& story_checkpoints(); // Registers AutoStory table validation unit tests. void add_tests_AutoStory(UnitTestDatabase& database); -// The story files against the C++ rows they replace. -void add_tests_AutoStoryTableParity(UnitTestDatabase& database); // The table run end to end against a fake game (PokemonFRLG_AutoStorySimulation_Tests.cpp). void add_tests_AutoStorySimulation(UnitTestDatabase& database); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp deleted file mode 100644 index d4853c8a49..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp +++ /dev/null @@ -1,379 +0,0 @@ -/* AutoStory Table Parity Tests - * - * From: https://github.com/PokemonAutomation/ - * - * The C++ rows the story table had before StoryData/, built with the - * shared step API, against the checkpoints read from the files: each - * loads to the same steps, args (with the fallbacks the reader fills in), - * poses, supplies and START menu. Removed with the C++ rows. - * - */ - -#include -#include -#include -#include -#include "Common/Cpp/Exceptions.h" -#include "Common/Cpp/TestRunners/UnitTest.h" -#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" -#include "PokemonFRLG_AutoStoryParty.h" -#include "PokemonFRLG_AutoStoryTable.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -namespace{ - -constexpr Direction NORTH = Direction::NORTH; -constexpr Direction SOUTH = Direction::SOUTH; -constexpr Direction EAST = Direction::EAST; -constexpr Direction WEST = Direction::WEST; - -constexpr std::string_view BEDROOM = "PalletTown_PlayersHouse_2F"; -constexpr std::string_view PALLET = "PalletTown"; -constexpr std::string_view LAB = "PalletTown_ProfessorOaksLab"; -constexpr std::string_view VIRIDIAN = "ViridianCity"; -constexpr std::string_view VIRIDIAN_MART = "ViridianCity_Mart"; -constexpr std::string_view VIRIDIAN_CENTER = "ViridianCity_PokemonCenter_1F"; -constexpr std::string_view FOREST = "ViridianForest"; -constexpr std::string_view FOREST_GATE = "Route2_ViridianForest_NorthEntrance"; -constexpr std::string_view PEWTER = "PewterCity"; -constexpr std::string_view PEWTER_CENTER = "PewterCity_PokemonCenter_1F"; -constexpr std::string_view GYM = "PewterCity_Gym"; - -Pokemon::GridPose at(std::string_view map, int x, int y, std::optional facing = std::nullopt){ - return Pokemon::GridPose{std::string(map), {{x, y}}, facing}; -} - -StoryCheckpoint row( - std::string id, std::string title, std::optional start, - Supplies supplies, StartMenu menu, std::vector steps -){ - StoryCheckpoint checkpoint; - checkpoint.id = std::move(id); - checkpoint.title = std::move(title); - checkpoint.start = std::move(start); - checkpoint.steps = std::move(steps); - checkpoint.supplies = supplies; - checkpoint.menu = menu; - return checkpoint; -} - -Supplies after_brock(){ - Supplies supplies; - supplies.lead = story_lead_after_brock(); - return supplies; -} - -// What a walk does about wild Pokemon: runs, or fights them for EXP. -enum class WildBattles{ - RUN, - FIGHT, -}; - -StoryStep make(StoryStepKind kind, std::string name, std::string why, Pokemon::StoryActionArgs args = {}){ - StoryStep step; - step.kind = kind; - step.name = std::move(name); - step.why = std::move(why); - step.args = std::move(args); - return step; -} - -StoryStep route(std::string name, Pokemon::GridPose target, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::ROUTE, std::move(name), std::move(why), { - {"target", std::move(target)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -StoryStep step_into(std::string name, Direction direction, std::string why){ - return make(StoryStepKind::STEP, std::move(name), std::move(why), {{"direction", direction}}); -} - -StoryStep answer(std::string name, bool yes, std::string why){ - return make(StoryStepKind::ANSWER, std::move(name), std::move(why), {{"yes", yes}}); -} - -StoryStep scene(std::string name, std::optional pose_after, std::string why){ - StoryStep step = make(StoryStepKind::MASH, std::move(name), std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep battle(std::string name, Pokemon::GridPose pose_after, bool may_lose, std::string why){ - StoryStep step = make(StoryStepKind::BATTLE, std::move(name), std::move(why), {{"may_lose", may_lose}}); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep legs(std::string name, std::vector legs, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::LEGS, std::move(name), std::move(why), { - {"legs", std::move(legs)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -StoryStep new_game_intro(Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::NEW_GAME, "intro", std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep talk(std::string name, std::string why){ - return make(StoryStepKind::TALK, std::move(name), std::move(why)); -} - -StoryStep ready(std::string name, Pokemon::GridPose nurse, std::string why){ - return make(StoryStepKind::READY, std::move(name), std::move(why), {{"target", std::move(nurse)}}); -} - -StoryStep heal(std::string name){ - return make(StoryStepKind::HEAL, std::move(name), "full HP"); -} - -StoryStep shop(std::string name, std::vector items, std::string why){ - return make(StoryStepKind::SHOP, std::move(name), std::move(why), {{"items", std::move(items)}}); -} - -StoryStep game_step(std::string action, Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::GAME, action, std::move(why)); - step.action = std::move(action); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep options_step(){ - return make(StoryStepKind::OPTIONS, "options", "fast text; no switch prompt between a trainer's Pokemon"); -} - - -StoryCheckpoint new_game(){ - StoryCheckpoint checkpoint = row("00.01", "new game to the bedroom", std::nullopt, {}, StartMenu::BEFORE_POKEMON, { - // new_game.c: the bedroom at (6, 6), facing the TV. - new_game_intro(at(BEDROOM, 6, 6, NORTH), "Oak's speech, BOY, the player's name (default if none is set), rival GREEN"), - options_step(), - }); - checkpoint.handoff = StoryHandoff::SID_HELPER; - return checkpoint; -} - -// SID Helper confirms the name, finishes the intro and reads the Trainer -// Card from the START menu, without moving the player or saving. -StoryCheckpoint after_sid_helper(){ - StoryCheckpoint checkpoint = row("00.01b", "after SID Helper: close the Trainer Card, save in the bedroom", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - game_step(CLOSE_TRAINER_CARD, at(BEDROOM, 6, 6, NORTH), "the Trainer Card SID Helper left open, or HOME"), - options_step(), - }); - checkpoint.live_start = true; - return checkpoint; -} - -StoryCheckpoint leave_house(){ - return row("00.02", "bedroom to Pallet Town", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("front_door", at(PALLET, 6, 8), "down the stairs and out of the house"), - }); -} - -StoryCheckpoint oaks_trigger(){ - return row("00.03", "Oak stops the player and walks them to the lab", at(PALLET, 6, 8, SOUTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_oaks_trigger", at(PALLET, 12, 2, NORTH), "below the north exit, short of Oak's trigger at (12, 1)"), - step_into("oaks_trigger", NORTH, "the trigger: \"Don't go out!\""), - // PlayerEnter walks the player up 8 tiles from the lab's door. - scene("to_the_lab", at(LAB, 6, 4, NORTH), "Oak walks the player into the lab; the scene ends at the table"), - }); -} - -// Starter RNG starts from a save south of the table, facing the ball. -StoryCheckpoint to_starter_ball(){ - StoryCheckpoint checkpoint = row("00.04", "to Squirtle's ball, south of the table", at(LAB, 6, 4, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_squirtle", at(LAB, 9, 5, NORTH), "under Squirtle's ball (9, 4)"), - }); - checkpoint.handoff = StoryHandoff::STARTER_RNG; - return checkpoint; -} - -StoryCheckpoint starter(){ - return row("00.04b", "Squirtle, then the rival's battle", at(LAB, 9, 5, NORTH), {}, StartMenu::BEFORE_POKEDEX, { - talk("squirtle_ball", "\"So, you want the WATER POKEMON SQUIRTLE?\""), - answer("choose_squirtle", true, "take Squirtle"), - answer("no_nickname", false, "\"give a nickname?\" NO"), - scene("rival_takes_bulbasaur", at(LAB, 9, 5, NORTH), "the rival picks his ball; the player still faces the table (console B, 2026-11-01)"), - route("above_rival_trigger", at(LAB, 7, 7, SOUTH), "short of the rival's trigger row 8"), - step_into("rival_trigger", SOUTH, "\"Wait, let's check out our POKEMON!\""), - // The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down. - battle("rival_battle", at(LAB, 7, 8, SOUTH), true, "the tutorial battle; losing goes on too"), - }); -} - -StoryCheckpoint parcel(){ - return row("00.05", "Route 1 to Viridian Mart: Oak's Parcel", at(LAB, 7, 8, SOUTH), {}, StartMenu::BEFORE_POKEDEX, { - route("below_mart_door", at(VIRIDIAN, 36, 20, NORTH), "Route 1, running from wild battles"), - step_into("mart_door", NORTH, "the clerk's scene starts on entering"), - // ApproachCounter: up 4 from the mat, then faces the clerk. - scene("parcel_from_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "the clerk gives OAK'S PARCEL"), - }); -} - -StoryCheckpoint pokedex(){ - return row("00.06", "Oak's Parcel to the Pokedex", at(VIRIDIAN_MART, 4, 3, WEST), {}, StartMenu::FULL, { - route("below_oak", at(LAB, 6, 4, NORTH), "back down Route 1 to Oak"), - talk("give_parcel", "Oak takes the parcel"), - scene("pokedex_scene", at(LAB, 6, 4, SOUTH), "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)"), - }); -} - -StoryCheckpoint shopping(){ - return row("00.07", "Viridian shopping, then into Viridian Forest", at(LAB, 6, 4, SOUTH), {}, StartMenu::FULL, { - route("mart_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "Route 1 again"), - // 2000 of the 3000 a new game starts with, plus the rival's prize. - shop("potions_and_antidotes", {{"potion", 5}, {"antidote", 3}, {"parlyz_heal", 1}}, "5 Potions, 3 Antidotes, 1 Parlyz Heal"), - route("viridian_nurse", at(VIRIDIAN_CENTER, 7, 4, NORTH), "heal before the forest"), - heal("heal_viridian"), - route("below_old_man_trigger", at(VIRIDIAN, 20, 9, NORTH), "short of the tutorial trigger (20, 8)"), - step_into("old_man_trigger", NORTH, "the old man's catching tutorial can't be walked around"), - // TutorialTriggerLeft turns the player right, to the old man. - scene("old_man_tutorial", at(VIRIDIAN, 20, 8, EAST), "about 60 lines and his demo battle; TEACHY TV"), - // After his demo the old man stands east of the player, beside (20, 8), where - // the map doesn't have him: "east 2" from there didn't move, and the walk north - // ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first. - route("past_old_man", at(VIRIDIAN, 20, 5, NORTH), "north along column 20, clear of the old man"), - // The gate's north warp lands on the forest's exit mat (29, 62), facing - // north. The save there keeps a forest failure from going back to Pallet. - route("forest_entrance", at(FOREST, 29, 62, NORTH), "Route 2 and the south gate, running from wild battles"), - }); -} - -StoryCheckpoint forest(){ - // The supplies bought in 00.07. - return row("00.08", "Viridian Forest to Pewter Center", at(FOREST, 29, 62, NORTH), {5, 3, 1}, StartMenu::FULL, { - // Wild battles are fought for EXP. Straight up the east side from the - // entrance, each leg ending on a wall (the Boy at (45, 58) stops the - // east one). Rick (47, 45) sees (42..46, 45), so the last leg meets - // his battle and is held on to its wall after it. The by-hand run's - // detour west to (13, 46) and back is dropped. - legs("forest_east", {{EAST, 1}, {NORTH, 4}, {EAST, 14}, {NORTH, 15}}, "up the east side to (44, 43)", WildBattles::FIGHT), - route("forest_north", at(FOREST, 39, 25), "north part", WildBattles::FIGHT), - // To the gate by legs that end on walls, which the walker holds again - // after a battle instead of estimating where it stopped: planned - // routes with open legs lost the player in the north of the forest - // (console B, 2026-11-01). The two 1-tile legs are single steps. - legs("forest_exit", { - {NORTH, 10}, {WEST, 12}, {SOUTH, 10}, {WEST, 6}, {NORTH, 20}, - {SOUTH, 1}, {WEST, 10}, {SOUTH, 27}, {WEST, 8}, {NORTH, 20}, {EAST, 1}, - }, "walls all the way to the gate's column", WildBattles::FIGHT), - route("forest_gate", at(FOREST_GATE, 7, 10, NORTH), "north onto the exit, arriving on the gate's mat", WildBattles::FIGHT), - // Out of the forest, wild battles are run from; trainers are still fought. - route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "Route 2 north to Pewter's Center"), - heal("heal_pewter"), - }); -} - -StoryCheckpoint brock(){ - // The by-hand save: 2 Potions and 1 Antidote left after the forest. - return row("00.09", "Pewter Gym: Camper Liam, then Brock", at(PEWTER_CENTER, 7, 4, NORTH), {2, 1}, StartMenu::FULL, { - // Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight - // 4) and sees (4..7, 8): walking north up column 6 from the door, - // the step onto (6, 8) starts his battle. He walks up to the player, - // who stays put and keeps facing north (FRLG doesn't turn the player - // to a trainer). That step is taken on its own, so no leg is cut. - route("below_liam_line", at(GYM, 6, 9, NORTH), "in by the door, up column 6 to below Liam's row"), - step_into("liam_line", NORTH, "onto (6, 8), in Liam's line"), - battle("camper_liam", at(GYM, 6, 8, NORTH), false, "Geodude and Sandshrew; EXP before Brock"), - // On to Brock unless red HP or a status is left that no item cures. - ready("ready_for_brock", at(PEWTER_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - route("before_brock", at(GYM, 6, 6, NORTH), "below Brock (6, 5); Liam, beaten, stands at (5, 8)"), - talk("challenge_brock", "Brock's speech"), - battle("brock", at(GYM, 6, 6, NORTH), false, "Geodude and Onix, with Bubble; Boulder Badge and TM39"), - }); -} - -StoryCheckpoint running_shoes(){ - return row("00.10", "Pewter: the Running Shoes from Oak's aide", at(GYM, 6, 6, NORTH), after_brock(), StartMenu::FULL, { - // Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at - // (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The - // Gym guide's triggers at (42..43, 21..23) need the scene at 0. - route("before_aide_trigger", at(PEWTER, 45, 21, EAST), "out of the Gym, east along row 21, short of the top trigger"), - step_into("aide_trigger", EAST, "onto (46, 21), below the aide"), - // RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; - // the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH - // is set (console B, 2026-11-02: about 20 B presses to the overworld). - scene("shoes_from_aide", at(PEWTER, 46, 21, NORTH), "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north"), - }); -} - - -std::vector cpp_rows(){ - return { - new_game(), after_sid_helper(), leave_house(), oaks_trigger(), to_starter_ball(), starter(), parcel(), pokedex(), shopping(), forest(), brock(), - running_shoes(), - }; -} - -// Why `loaded` differs from `row`, or empty. Steps compare as their -// shared JSON, which writes every field. -std::string checkpoint_difference(const StoryCheckpoint& row, const StoryCheckpoint& loaded){ - const std::string row_json = Pokemon::story_checkpoint_json(row).dump(); - const std::string loaded_json = Pokemon::story_checkpoint_json(loaded).dump(); - if (row_json != loaded_json){ - return std::format("{}: the file loads to\n{}\nbut the C++ row is\n{}", row.id, loaded_json, row_json); - } - if (row.handoff != loaded.handoff || row.live_start != loaded.live_start){ - return row.id + ": a different handoff or live start."; - } - if (row.menu != loaded.menu){ - return row.id + ": a different START menu."; - } - const Supplies& a = row.supplies; - const Supplies& b = loaded.supplies; - if (a.potions != b.potions || a.antidotes != b.antidotes || a.parlyz_heals != b.parlyz_heals){ - return row.id + ": different supplies."; - } - if (a.lead.species != b.lead.species || a.lead.level != b.lead.level || a.lead.moves.size() != b.lead.moves.size()){ - return row.id + ": a different lead."; - } - for (size_t c = 0; c < a.lead.moves.size(); c++){ - if (a.lead.moves[c].move != b.lead.moves[c].move || a.lead.moves[c].pp != b.lead.moves[c].pp){ - return row.id + ": a different lead move " + std::to_string(c + 1) + "."; - } - } - return ""; -} - -class Test_AutoStoryTableParity : public UnitTest{ -public: - Test_AutoStoryTableParity() - : UnitTest("PokemonFRLG::AutoStory - the story files load to the C++ rows") - {} - virtual UnitTestResult run(Logger&, CancellableScope&) const override{ - try{ - const std::vector rows = cpp_rows(); - const std::vector& loaded = story_checkpoints(); - if (rows.size() != loaded.size()){ - return std::format("{} C++ rows, {} files.", rows.size(), loaded.size()); - } - for (size_t c = 0; c < rows.size(); c++){ - const std::string difference = checkpoint_difference(rows[c], loaded[c]); - if (!difference.empty()){ - return difference; - } - } - return true; - }catch (Exception& e){ - return std::string(e.name()) + ": " + e.message(); - } - } -}; - -} // namespace - - -void add_tests_AutoStoryTableParity(UnitTestDatabase& database){ - database.add(); -} - - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 3b11728b46..37529b52c5 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1953,7 +1953,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryWinChance.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryWinChance.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp From 68b113ffc0ff0912a1e765eeed81a1568ee3944d Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 10:27:33 -0800 Subject: [PATCH 4/8] FRLG AutoStory: delete stage 3's C++ story rows, parity proven The parity test passed on the merge before this commit: every StoryData file through 00.13 loads to the C++ row it replaces. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonFRLG_AutoStoryTable.h | 2 - ...PokemonFRLG_AutoStoryTableParity_Tests.cpp | 540 ------------------ .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 1 - SerialPrograms/cmake/SourceFiles.cmake | 1 - 4 files changed, 544 deletions(-) delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h index e8ae1e3c80..e9dcead69c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -67,8 +67,6 @@ const std::vector& story_checkpoints(); // Registers AutoStory table validation unit tests. void add_tests_AutoStory(UnitTestDatabase& database); -// The story files against the C++ rows they replace. -void add_tests_AutoStoryTableParity(UnitTestDatabase& database); // Which rows a run takes (PokemonFRLG_AutoStoryRunPlan_Tests.cpp). void add_tests_AutoStoryRunPlan(UnitTestDatabase& database); // The table run end to end against a fake game (PokemonFRLG_AutoStorySimulation_Tests.cpp). diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp deleted file mode 100644 index 487b77d73b..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp +++ /dev/null @@ -1,540 +0,0 @@ -/* AutoStory Table Parity Tests - * - * From: https://github.com/PokemonAutomation/ - * - * The C++ rows the story table had before StoryData/, built with the - * shared step API, against the checkpoints read from the files: each - * loads to the same steps, args (with the fallbacks the reader fills in), - * poses, supplies and START menu. Removed with the C++ rows. - * - */ - -#include -#include -#include -#include -#include "Common/Cpp/Exceptions.h" -#include "Common/Cpp/TestRunners/UnitTest.h" -#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" -#include "PokemonFRLG_AutoStoryCapture.h" -#include "PokemonFRLG_AutoStoryChoice.h" -#include "PokemonFRLG_AutoStoryParty.h" -#include "PokemonFRLG_AutoStoryTable.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -namespace{ - -constexpr Direction NORTH = Direction::NORTH; -constexpr Direction SOUTH = Direction::SOUTH; -constexpr Direction EAST = Direction::EAST; -constexpr Direction WEST = Direction::WEST; - -constexpr std::string_view BEDROOM = "PalletTown_PlayersHouse_2F"; -constexpr std::string_view PALLET = "PalletTown"; -constexpr std::string_view LAB = "PalletTown_ProfessorOaksLab"; -constexpr std::string_view VIRIDIAN = "ViridianCity"; -constexpr std::string_view VIRIDIAN_MART = "ViridianCity_Mart"; -constexpr std::string_view VIRIDIAN_CENTER = "ViridianCity_PokemonCenter_1F"; -constexpr std::string_view FOREST = "ViridianForest"; -constexpr std::string_view FOREST_GATE = "Route2_ViridianForest_NorthEntrance"; -constexpr std::string_view PEWTER = "PewterCity"; -constexpr std::string_view PEWTER_CENTER = "PewterCity_PokemonCenter_1F"; -constexpr std::string_view GYM = "PewterCity_Gym"; -constexpr std::string_view ROUTE3 = "Route3"; -constexpr std::string_view ROUTE4 = "Route4"; -constexpr std::string_view ROUTE4_CENTER = "Route4_PokemonCenter_1F"; -constexpr std::string_view MT_MOON_1F = "MtMoon_1F"; -constexpr std::string_view MT_MOON_B2F = "MtMoon_B2F"; - -Pokemon::GridPose at(std::string_view map, int x, int y, std::optional facing = std::nullopt){ - return Pokemon::GridPose{std::string(map), {{x, y}}, facing}; -} - -StoryCheckpoint row( - std::string id, std::string title, std::optional start, - Supplies supplies, StartMenu menu, std::vector steps -){ - StoryCheckpoint checkpoint; - checkpoint.id = std::move(id); - checkpoint.title = std::move(title); - checkpoint.start = std::move(start); - checkpoint.steps = std::move(steps); - checkpoint.supplies = supplies; - checkpoint.menu = menu; - return checkpoint; -} - -Supplies after_brock(){ - Supplies supplies; - supplies.lead = story_lead_after_brock(); - return supplies; -} - -// What a walk does about wild Pokemon: runs, or fights them for EXP. -enum class WildBattles{ - RUN, - FIGHT, -}; - -StoryStep make(StoryStepKind kind, std::string name, std::string why, Pokemon::StoryActionArgs args = {}){ - StoryStep step; - step.kind = kind; - step.name = std::move(name); - step.why = std::move(why); - step.args = std::move(args); - return step; -} - -StoryStep route(std::string name, Pokemon::GridPose target, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::ROUTE, std::move(name), std::move(why), { - {"target", std::move(target)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -StoryStep step_into(std::string name, Direction direction, std::string why){ - return make(StoryStepKind::STEP, std::move(name), std::move(why), {{"direction", direction}}); -} - -StoryStep answer(std::string name, bool yes, std::string why){ - return make(StoryStepKind::ANSWER, std::move(name), std::move(why), {{"yes", yes}}); -} - -StoryStep scene(std::string name, std::optional pose_after, std::string why){ - StoryStep step = make(StoryStepKind::MASH, std::move(name), std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep battle(std::string name, Pokemon::GridPose pose_after, bool may_lose, std::string why){ - StoryStep step = make(StoryStepKind::BATTLE, std::move(name), std::move(why), {{"may_lose", may_lose}}); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep legs(std::string name, std::vector legs, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::LEGS, std::move(name), std::move(why), { - {"legs", std::move(legs)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -// `step`, a ROUTE or LEGS, run with B held: from the Running Shoes on. -StoryStep running(StoryStep step){ - step.action = RUN_VARIANT; - return step; -} - -StoryStep new_game_intro(Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::NEW_GAME, "intro", std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep talk(std::string name, std::string why){ - return make(StoryStepKind::TALK, std::move(name), std::move(why)); -} - -StoryStep ready(std::string name, Pokemon::GridPose nurse, std::string why){ - return make(StoryStepKind::READY, std::move(name), std::move(why), {{"target", std::move(nurse)}}); -} - -StoryStep heal(std::string name){ - return make(StoryStepKind::HEAL, std::move(name), "full HP"); -} - -StoryStep shop(std::string name, std::vector items, std::string why){ - return make(StoryStepKind::SHOP, std::move(name), std::move(why), {{"items", std::move(items)}}); -} - -StoryStep game_step(std::string action, Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::GAME, action, std::move(why)); - step.action = std::move(action); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep options_step(){ - return make(StoryStepKind::OPTIONS, "options", "fast text; no switch prompt between a trainer's Pokemon"); -} - - -StoryCheckpoint new_game(){ - StoryCheckpoint checkpoint = row("00.01", "new game to the bedroom", std::nullopt, {}, StartMenu::BEFORE_POKEMON, { - // new_game.c: the bedroom at (6, 6), facing the TV. - new_game_intro(at(BEDROOM, 6, 6, NORTH), "Oak's speech, BOY, the player's name (default if none is set), rival GREEN"), - options_step(), - }); - checkpoint.handoff = StoryHandoff::SID_HELPER; - return checkpoint; -} - -// SID Helper confirms the name, finishes the intro and reads the Trainer -// Card from the START menu, without moving the player or saving. -StoryCheckpoint after_sid_helper(){ - StoryCheckpoint checkpoint = row("00.01b", "after SID Helper: close the Trainer Card, save in the bedroom", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - game_step(CLOSE_TRAINER_CARD, at(BEDROOM, 6, 6, NORTH), "the Trainer Card SID Helper left open, or HOME"), - options_step(), - }); - checkpoint.live_start = true; - return checkpoint; -} - -StoryCheckpoint leave_house(){ - return row("00.02", "bedroom to Pallet Town", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("front_door", at(PALLET, 6, 8), "down the stairs and out of the house"), - }); -} - -StoryCheckpoint oaks_trigger(){ - return row("00.03", "Oak stops the player and walks them to the lab", at(PALLET, 6, 8, SOUTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_oaks_trigger", at(PALLET, 12, 2, NORTH), "below the north exit, short of Oak's trigger at (12, 1)"), - step_into("oaks_trigger", NORTH, "the trigger: \"Don't go out!\""), - // PlayerEnter walks the player up 8 tiles from the lab's door. - scene("to_the_lab", at(LAB, 6, 4, NORTH), "Oak walks the player into the lab; the scene ends at the table"), - }); -} - -// Starter RNG starts from a save south of the table, facing the ball. -StoryCheckpoint to_starter_ball(){ - StoryCheckpoint checkpoint = row("00.04", "to Squirtle's ball, south of the table", at(LAB, 6, 4, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_squirtle", at(LAB, 9, 5, NORTH), "under Squirtle's ball (9, 4)"), - }); - checkpoint.handoff = StoryHandoff::STARTER_RNG; - return checkpoint; -} - -StoryCheckpoint starter(){ - return row("00.04b", "Squirtle, then the rival's battle", at(LAB, 9, 5, NORTH), {}, StartMenu::BEFORE_POKEDEX, { - talk("squirtle_ball", "\"So, you want the WATER POKEMON SQUIRTLE?\""), - answer("choose_squirtle", true, "take Squirtle"), - answer("no_nickname", false, "\"give a nickname?\" NO"), - scene("rival_takes_bulbasaur", at(LAB, 9, 5, NORTH), "the rival picks his ball; the player still faces the table (console B, 2026-11-01)"), - route("above_rival_trigger", at(LAB, 7, 7, SOUTH), "short of the rival's trigger row 8"), - step_into("rival_trigger", SOUTH, "\"Wait, let's check out our POKEMON!\""), - // The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down. - battle("rival_battle", at(LAB, 7, 8, SOUTH), true, "the tutorial battle; losing goes on too"), - }); -} - -StoryCheckpoint parcel(){ - return row("00.05", "Route 1 to Viridian Mart: Oak's Parcel", at(LAB, 7, 8, SOUTH), {}, StartMenu::BEFORE_POKEDEX, { - route("below_mart_door", at(VIRIDIAN, 36, 20, NORTH), "Route 1, running from wild battles"), - step_into("mart_door", NORTH, "the clerk's scene starts on entering"), - // ApproachCounter: up 4 from the mat, then faces the clerk. - scene("parcel_from_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "the clerk gives OAK'S PARCEL"), - }); -} - -StoryCheckpoint pokedex(){ - return row("00.06", "Oak's Parcel to the Pokedex", at(VIRIDIAN_MART, 4, 3, WEST), {}, StartMenu::FULL, { - route("below_oak", at(LAB, 6, 4, NORTH), "back down Route 1 to Oak"), - talk("give_parcel", "Oak takes the parcel"), - scene("pokedex_scene", at(LAB, 6, 4, SOUTH), "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)"), - }); -} - -StoryCheckpoint shopping(){ - return row("00.07", "Viridian shopping, then into Viridian Forest", at(LAB, 6, 4, SOUTH), {}, StartMenu::FULL, { - route("mart_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "Route 1 again"), - // 2000 of the 3000 a new game starts with, plus the rival's prize. - shop("potions_and_antidotes", {{"potion", 5}, {"antidote", 3}, {"parlyz_heal", 1}}, "5 Potions, 3 Antidotes, 1 Parlyz Heal"), - route("viridian_nurse", at(VIRIDIAN_CENTER, 7, 4, NORTH), "heal before the forest"), - heal("heal_viridian"), - route("below_old_man_trigger", at(VIRIDIAN, 20, 9, NORTH), "short of the tutorial trigger (20, 8)"), - step_into("old_man_trigger", NORTH, "the old man's catching tutorial can't be walked around"), - // TutorialTriggerLeft turns the player right, to the old man. - scene("old_man_tutorial", at(VIRIDIAN, 20, 8, EAST), "about 60 lines and his demo battle; TEACHY TV"), - // After his demo the old man stands east of the player, beside (20, 8), where - // the map doesn't have him: "east 2" from there didn't move, and the walk north - // ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first. - route("past_old_man", at(VIRIDIAN, 20, 5, NORTH), "north along column 20, clear of the old man"), - // The gate's north warp lands on the forest's exit mat (29, 62), facing - // north. The save there keeps a forest failure from going back to Pallet. - route("forest_entrance", at(FOREST, 29, 62, NORTH), "Route 2 and the south gate, running from wild battles"), - }); -} - -StoryCheckpoint forest(){ - // The supplies bought in 00.07. - return row("00.08", "Viridian Forest to Pewter Center", at(FOREST, 29, 62, NORTH), {5, 3, 1}, StartMenu::FULL, { - // Wild battles are fought for EXP. Straight up the east side from the - // entrance, each leg ending on a wall (the Boy at (45, 58) stops the - // east one). Rick (47, 45) sees (42..46, 45), so the last leg meets - // his battle and is held on to its wall after it. The by-hand run's - // detour west to (13, 46) and back is dropped. - legs("forest_east", {{EAST, 1}, {NORTH, 4}, {EAST, 14}, {NORTH, 15}}, "up the east side to (44, 43)", WildBattles::FIGHT), - route("forest_north", at(FOREST, 39, 25), "north part", WildBattles::FIGHT), - // To the gate by legs that end on walls, which the walker holds again - // after a battle instead of estimating where it stopped: planned - // routes with open legs lost the player in the north of the forest - // (console B, 2026-11-01). The two 1-tile legs are single steps. - legs("forest_exit", { - {NORTH, 10}, {WEST, 12}, {SOUTH, 10}, {WEST, 6}, {NORTH, 20}, - {SOUTH, 1}, {WEST, 10}, {SOUTH, 27}, {WEST, 8}, {NORTH, 20}, {EAST, 1}, - }, "walls all the way to the gate's column", WildBattles::FIGHT), - route("forest_gate", at(FOREST_GATE, 7, 10, NORTH), "north onto the exit, arriving on the gate's mat", WildBattles::FIGHT), - // Out of the forest, wild battles are run from; trainers are still fought. - route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "Route 2 north to Pewter's Center"), - heal("heal_pewter"), - }); -} - -StoryCheckpoint brock(){ - // The by-hand save: 2 Potions and 1 Antidote left after the forest. - return row("00.09", "Pewter Gym: Camper Liam, then Brock", at(PEWTER_CENTER, 7, 4, NORTH), {2, 1}, StartMenu::FULL, { - // Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight - // 4) and sees (4..7, 8): walking north up column 6 from the door, - // the step onto (6, 8) starts his battle. He walks up to the player, - // who stays put and keeps facing north (FRLG doesn't turn the player - // to a trainer). That step is taken on its own, so no leg is cut. - route("below_liam_line", at(GYM, 6, 9, NORTH), "in by the door, up column 6 to below Liam's row"), - step_into("liam_line", NORTH, "onto (6, 8), in Liam's line"), - battle("camper_liam", at(GYM, 6, 8, NORTH), false, "Geodude and Sandshrew; EXP before Brock"), - // On to Brock unless red HP or a status is left that no item cures. - ready("ready_for_brock", at(PEWTER_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - route("before_brock", at(GYM, 6, 6, NORTH), "below Brock (6, 5); Liam, beaten, stands at (5, 8)"), - talk("challenge_brock", "Brock's speech"), - battle("brock", at(GYM, 6, 6, NORTH), false, "Geodude and Onix, with Bubble; Boulder Badge and TM39"), - }); -} - -StoryCheckpoint running_shoes(){ - return row("00.10", "Pewter: the Running Shoes from Oak's aide", at(GYM, 6, 6, NORTH), after_brock(), StartMenu::FULL, { - // Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at - // (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The - // Gym guide's triggers at (42..43, 21..23) need the scene at 0. - route("before_aide_trigger", at(PEWTER, 45, 21, EAST), "out of the Gym, east along row 21, short of the top trigger"), - step_into("aide_trigger", EAST, "onto (46, 21), below the aide"), - // RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; - // the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH - // is set (console B, 2026-11-02: about 20 B presses to the overworld). - scene("shoes_from_aide", at(PEWTER, 46, 21, NORTH), "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north"), - // Where the by-hand walk stopped to start 00.11 (console B, 2026-11-02). - route("below_pewter_center", at(PEWTER, 17, 26, SOUTH), "west along row 21 and down to below the Pokemon Center's door (17, 25)"), - }); -} - -// Route 3's trainers (Route3 map.json): the way east meets three of them. -// Bug Catcher Colton (12, 6) faces east, sight 3: the only way north past -// the row 7 ledges is the gap at x 14..15, below his line. Youngster Ben -// (17, 4) faces south, sight 2, so the way east keeps to row 3 past him. -// Bug Catcher Greg (25, 4) faces south, sight 2, over the way east along -// row 5. Bug Catcher James (32, 6) faces east, sight 4, over the way down -// at x 35..36. The others are kept out of: Lass Janice (19, 9) sees west -// along row 9 to x 14, Lass Sally (30, 3) west along row 3 to x 25, and -// Youngster Calvin (29, 10) west along row 10. Each line is stepped into on -// its own, so no leg is cut; the trainer walks up to the player, who stays -// put facing the way they stepped. -StoryCheckpoint route3(){ - return row("00.11", "Pewter Center, then Route 3's trainers", at(PEWTER, 17, 26, SOUTH), after_brock(), StartMenu::FULL, { - running(route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "in by the door below the player")), - heal("heal_pewter"), - // Up from row 9 west of Janice's line, which ends at x 14. - running(route("west_of_janice_line", at(ROUTE3, 13, 8), "out of Pewter by row 21, east into Route 3, short of Janice's line")), - running(legs("below_colton_line", {{EAST, 1}, {NORTH, 1}}, "to (14, 7), in the ledges' gap")), - step_into("colton_line", NORTH, "onto (14, 6), in Colton's line"), - battle("bug_catcher_colton", at(ROUTE3, 14, 6, NORTH), false, "his Bug Pokemon; Colton stops at (13, 6)"), - running(legs("past_ben", {{NORTH, 3}, {EAST, 4}, {SOUTH, 2}, {EAST, 6}}, "up to row 3 above Ben, down at x 18 east of his line, to (24, 5)")), - step_into("greg_line", EAST, "onto (25, 5), below Greg"), - battle("bug_catcher_greg", at(ROUTE3, 25, 5, EAST), false, "his Bug Pokemon; Greg is already next to the player"), - running(legs("above_james_line", {{EAST, 11}}, "along row 5 to the wall at (36, 5)")), - step_into("james_line", SOUTH, "onto (36, 6), at the end of James's line"), - battle("bug_catcher_james", at(ROUTE3, 36, 6, SOUTH), false, "his Bug Pokemon; James stops at (35, 6)"), - // Saved here, the trainers behind, so a failure on the way to Route 4 - // doesn't fight them again. - running(legs("save_spot", {{SOUTH, 2}}, "down to (36, 8), beside the wall east of it")), - }); -} - -// Route 3's north exit (x 68..75) joins Route 4 (offset 60) at x 8..15, up -// which column 12 leads to the Pokemon Center's door (12, 5). Lass Robin -// (40, 11) wanders up and down at x 40, looking north and south, sight 3. -// Rock above (y <= 8) and grass below (y >= 12) leave every way east -// across her column at y 9..11, so whether she sees the player depends on -// her facing. The walk watches for her after the leg along row 9, which -// crosses her sight on (40, 9) only; if she saw the player, her message -// goes to story_interrupts(), which fight her, and the route goes on from -// (40, 9) (run_route(); console B, 2026-11-02, she stopped the player -// there and spoke after the leg's short watch). -StoryCheckpoint magikarp_salesman(){ - StoryCheckpoint checkpoint = row("00.12", "Route 3 and 4 to the Magikarp salesman", at(ROUTE3, 36, 8, SOUTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "east over Route 3, off the grass, north into Route 4 and its Pokemon Center")), - heal("heal_route4"), - // Gift RNG starts from a save facing the salesman (1, 3). - running(route("before_salesman", at(ROUTE4_CENTER, 2, 3, WEST), "beside the Magikarp salesman, facing him")), - }); - checkpoint.handoff = StoryHandoff::GIFT_RNG; - return checkpoint; -} - -// Gift RNG buys the Magikarp (500 of the money 00.12 brings) without -// moving the player and leaves its summary open, or HOME. This saves the -// shiny where 00.12 ended. A run started here with Gift RNG's handoff on -// loads the save beside the salesman and runs Gift RNG first. -StoryCheckpoint after_gift_rng(){ - StoryCheckpoint checkpoint = row("00.12b", "after Gift RNG: save with the Magikarp", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - game_step(LEAVE_GIFT_SUMMARY, at(ROUTE4_CENTER, 2, 3, WEST), "the Magikarp's summary Gift RNG left open, or HOME"), - }); - checkpoint.live_start = true; - return checkpoint; -} - -// The Magikarp goes to BOX 1 at the Center's PC (11, 1), so Mt. Moon is -// fought with the starter alone (console B, 2026-11-02: done by hand and -// saved at (11, 2), facing the PC, where this row ends). The wandering -// boy (4..6, 3..5) is walked around. The Magikarp comes from Gift RNG: -// with Gift RNG off the party is the starter alone, and the deposit is -// skipped. -StoryCheckpoint magikarp_to_box(){ - return row("00.12c", "Route 4 Center: the Magikarp into BOX 1", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - running(route("pc_front", at(ROUTE4_CENTER, 11, 2, NORTH), "below the PC (11, 1), facing it")), - pc_step("magikarp_to_box", "DEPOSIT the party's second slot into BOX 1, if it has one", PcTransfer{ - .action = PcAction::DEPOSIT, .party_slot = 1, .box = 0, .if_missing = PcMissing::SKIP, - }), - }); -} - -// Mt. Moon (pokefirered data/maps/MtMoon_1F, _B1F, _B2F). Every floor tile -// of the cave has wild encounters, which are run from, so its legs end on -// walls, ladders or someone standing still, which the walker holds again -// after a battle; the few open ones are short. The way through: up 1F's -// middle and west side, its north-west ladder, B1F's west ladder down to -// B2F's south-east, round B2F's south edge to its west, north past -// Miguel and the fossils, and the ladder up to B1F's east end, which -// leads out to Route 4 east of the mountain. -// - 1F's trainers are walked around: Youngster Josh (13, 17) sees east -// along row 17 to x 17, so the way west into the west room is down -// column 18 and up column 11; Lass Miriam walks round (32..33, 4..5), -// sight 2, so the way east keeps to row 9 and columns 38 and 40; Hiker -// Marcos wanders (5..9, 8..12) and sees one tile, so the way north is -// column 11 and row 3. -// - The Moon Stone ball (3, 2) on 1F (FLAG_HIDE_MT_MOON_1F_MOON_STONE) is -// a few tiles off the way to the ladder (5, 6). -// - The Grunt at (37, 21) on B2F looks around (sight 3) over the only way -// east round B2F. His room is crossed on legs to walls, at one tile of -// his sight each, (37, 22) and (40, 21); if he looks the player's way, -// he walks up beside the leg, story_interrupts() fights him, and the -// leg is held on to its wall. -// - The Grunt at (12, 20) faces south (sight 2) over (12, 21..22), across -// rows 21..22, the only way north to Miguel: stepped into from the -// west, he is next to the player and doesn't walk. -// - Super Nerd Miguel (13, 11) battles on the step onto (14, 11) -// (MtMoon_B2F_EventScript_MiguelTrigger, VAR_MAP_SCENE_MT_MOON_B2F 0), -// then "We'll each take one!" -// - The fossils: DOME (13, 7), HELIX (14, 7). After the HELIX, Miguel -// walks up to (13, 8) and takes the DOME, which opens the gap north. -// The save is on Route 4: the save card's places don't include Mt. Moon. -StoryCheckpoint mt_moon(){ - return row("00.13", "Mt. Moon: a Moon Stone, a Rocket, Miguel and the Helix Fossil", at(ROUTE4_CENTER, 11, 2, NORTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "the nurse, below the counter")), - heal("heal_route4"), - running(route("mt_moon_entrance", at(MT_MOON_1F, 18, 37, NORTH), "out of the Center, west into Mt. Moon")), - running(legs("mt_moon_1f", { - {NORTH, 12}, {EAST, 8}, {NORTH, 12}, {EAST, 3}, {SOUTH, 1}, {EAST, 9}, - {NORTH, 1}, {EAST, 2}, {NORTH, 4}, {WEST, 24}, {EAST, 2}, {SOUTH, 12}, - {WEST, 7}, {NORTH, 18}, {WEST, 9}, {EAST, 1}, - }, "up the middle, east of Miriam, west along row 9, down column 18 past Josh, up column 11 past Marcos, to (3, 3)")), - running(route("below_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "facing the Moon Stone (3, 2)")), - talk("moon_stone_ball", "A on the item ball"), - // No reader for the text yet: the scene's end is the overworld. - scene("found_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "\" found a MOON STONE!\", then the pocket line; the ball is gone"), - running(route("b2f_ladder_foot", at(MT_MOON_B2F, 26, 21, EAST), "1F's ladder (5, 6), down B1F's west side to its ladder (22, 18), onto B2F")), - running(legs("b2f_south", { - {NORTH, 4}, {EAST, 8}, {WEST, 2}, {SOUTH, 5}, {EAST, 8}, {NORTH, 3}, {WEST, 1}, {NORTH, 5}, - {EAST, 7}, {SOUTH, 14}, {WEST, 9}, {SOUTH, 10}, {WEST, 29}, {EAST, 3}, {NORTH, 17}, - }, "through the Grunt's room at (37, 21), round the south edge, up column 11 to (11, 21)")), - step_into("grunt_line", EAST, "onto (12, 21), below the Grunt at (12, 20)"), - battle("rocket_grunt", at(MT_MOON_B2F, 12, 21, EAST), false, "Rattata and Zubat, Lv13"), - ready("ready_for_miguel", at(ROUTE4_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse, back through the cave, only if they can't"), - // Up column 13 to Miguel, who stops the leg on (13, 12), then east - // to the wall: the tile below his trigger. - running(legs("below_miguel_trigger", {{EAST, 1}, {NORTH, 9}, {EAST, 1}}, "to (14, 12), below Miguel's trigger (14, 11)")), - step_into("miguel_trigger", NORTH, "onto (14, 11), beside Miguel"), - battle("super_nerd_miguel", at(MT_MOON_B2F, 14, 11, NORTH), false, "Grimer, Voltorb and Koffing, Lv12; \"We'll each take one!\""), - running(legs("below_helix_fossil", {{NORTH, 3}}, "up column 14 to the HELIX FOSSIL (14, 7)")), - fossil_step("helix_fossil", "the HELIX FOSSIL; Miguel takes the DOME FOSSIL", Fossil::HELIX), - // The maps keep the fossils, which the game removes after the - // choice: the step onto the HELIX's tile is taken on its own. - step_into("helix_gap", NORTH, "onto (14, 7), where the HELIX FOSSIL lay"), - running(route("route4_east", at(ROUTE4, 32, 6, SOUTH), "west to B2F's ladder (5, 10), up to B1F, east to its exit onto Route 4")), - }); -} - - -std::vector cpp_rows(){ - return { - new_game(), after_sid_helper(), leave_house(), oaks_trigger(), to_starter_ball(), starter(), parcel(), pokedex(), shopping(), forest(), brock(), - running_shoes(), route3(), magikarp_salesman(), after_gift_rng(), magikarp_to_box(), mt_moon(), - }; -} - -// Why `loaded` differs from `row`, or empty. Steps compare as their -// shared JSON, which writes every field. -std::string checkpoint_difference(const StoryCheckpoint& row, const StoryCheckpoint& loaded){ - const std::string row_json = Pokemon::story_checkpoint_json(row).dump(); - const std::string loaded_json = Pokemon::story_checkpoint_json(loaded).dump(); - if (row_json != loaded_json){ - return std::format("{}: the file loads to\n{}\nbut the C++ row is\n{}", row.id, loaded_json, row_json); - } - if (row.handoff != loaded.handoff || row.live_start != loaded.live_start){ - return row.id + ": a different handoff or live start."; - } - if (row.menu != loaded.menu){ - return row.id + ": a different START menu."; - } - const Supplies& a = row.supplies; - const Supplies& b = loaded.supplies; - if (a.potions != b.potions || a.antidotes != b.antidotes || a.parlyz_heals != b.parlyz_heals){ - return row.id + ": different supplies."; - } - if (a.lead.species != b.lead.species || a.lead.level != b.lead.level || a.lead.moves.size() != b.lead.moves.size()){ - return row.id + ": a different lead."; - } - for (size_t c = 0; c < a.lead.moves.size(); c++){ - if (a.lead.moves[c].move != b.lead.moves[c].move || a.lead.moves[c].pp != b.lead.moves[c].pp){ - return row.id + ": a different lead move " + std::to_string(c + 1) + "."; - } - } - return ""; -} - -class Test_AutoStoryTableParity : public UnitTest{ -public: - Test_AutoStoryTableParity() - : UnitTest("PokemonFRLG::AutoStory - the story files load to the C++ rows") - {} - virtual UnitTestResult run(Logger&, CancellableScope&) const override{ - try{ - const std::vector rows = cpp_rows(); - const std::vector& loaded = story_checkpoints(); - if (rows.size() != loaded.size()){ - return std::format("{} C++ rows, {} files.", rows.size(), loaded.size()); - } - for (size_t c = 0; c < rows.size(); c++){ - const std::string difference = checkpoint_difference(rows[c], loaded[c]); - if (!difference.empty()){ - return difference; - } - } - return true; - }catch (Exception& e){ - return std::string(e.name()) + ": " + e.message(); - } - } -}; - -} // namespace - - -void add_tests_AutoStoryTableParity(UnitTestDatabase& database){ - database.add(); -} - - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp index eaf3c9c626..570d879d17 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -909,7 +909,6 @@ const AutoStoryTestCase AUTO_STORY_CASES[] = { void add_tests_AutoStory(UnitTestDatabase& database){ add_tests_AutoStoryRunPlan(database); - add_tests_AutoStoryTableParity(database); for (const auto& scenario : AUTO_STORY_CASES){ database.add(scenario); } diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index f8e8216b7f..b0e515e80c 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1985,7 +1985,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach_Tests.cpp From 25ce096ea9d530dfadca1eb9b49f86a55ca623a3 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 10:39:45 -0800 Subject: [PATCH 5/8] FRLG AutoStory: delete stage 4's C++ story rows, parity proven The parity test passed in the merge before this commit: every story file loads to the C++ row it replaces. The rows went with the merge's Table.cpp; this removes the parity test that held them. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonFRLG_AutoStoryTable.h | 2 - ...PokemonFRLG_AutoStoryTableParity_Tests.cpp | 783 ------------------ .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 1 - SerialPrograms/cmake/SourceFiles.cmake | 1 - 4 files changed, 787 deletions(-) delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h index 2d57d3c272..9aeaf0fcb3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -70,8 +70,6 @@ const std::vector& story_checkpoints(); // Registers AutoStory table validation unit tests. void add_tests_AutoStory(UnitTestDatabase& database); -// The story files against the C++ rows they replace. -void add_tests_AutoStoryTableParity(UnitTestDatabase& database); // Which rows a run takes (PokemonFRLG_AutoStoryRunPlan_Tests.cpp). void add_tests_AutoStoryRunPlan(UnitTestDatabase& database); // The table run end to end against a fake game (PokemonFRLG_AutoStorySimulation_Tests.cpp). diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp deleted file mode 100644 index 82b52f527a..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp +++ /dev/null @@ -1,783 +0,0 @@ -/* AutoStory Table Parity Tests - * - * From: https://github.com/PokemonAutomation/ - * - * The C++ rows the story table had before StoryData/, built with the - * shared step API, against the checkpoints read from the files: each - * loads to the same steps, args (with the fallbacks the reader fills in), - * poses, supplies and START menu. Removed with the C++ rows. - * - */ - -#include -#include -#include -#include -#include "Common/Cpp/Exceptions.h" -#include "Common/Cpp/TestRunners/UnitTest.h" -#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" -#include "PokemonFRLG_AutoStoryCapture.h" -#include "PokemonFRLG_AutoStoryChoice.h" -#include "PokemonFRLG_AutoStoryBattleData.h" -#include "PokemonFRLG_AutoStoryGrind.h" -#include "PokemonFRLG_AutoStoryMart.h" -#include "PokemonFRLG_AutoStoryParty.h" -#include "PokemonFRLG_AutoStoryTable.h" -#include "PokemonFRLG_AutoStoryTeach.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -namespace{ - -constexpr Direction NORTH = Direction::NORTH; -constexpr Direction SOUTH = Direction::SOUTH; -constexpr Direction EAST = Direction::EAST; -constexpr Direction WEST = Direction::WEST; - -constexpr std::string_view BEDROOM = "PalletTown_PlayersHouse_2F"; -constexpr std::string_view PALLET = "PalletTown"; -constexpr std::string_view LAB = "PalletTown_ProfessorOaksLab"; -constexpr std::string_view VIRIDIAN = "ViridianCity"; -constexpr std::string_view VIRIDIAN_MART = "ViridianCity_Mart"; -constexpr std::string_view VIRIDIAN_CENTER = "ViridianCity_PokemonCenter_1F"; -constexpr std::string_view FOREST = "ViridianForest"; -constexpr std::string_view FOREST_GATE = "Route2_ViridianForest_NorthEntrance"; -constexpr std::string_view PEWTER = "PewterCity"; -constexpr std::string_view PEWTER_CENTER = "PewterCity_PokemonCenter_1F"; -constexpr std::string_view GYM = "PewterCity_Gym"; -constexpr std::string_view ROUTE3 = "Route3"; -constexpr std::string_view ROUTE4 = "Route4"; -constexpr std::string_view ROUTE4_CENTER = "Route4_PokemonCenter_1F"; -constexpr std::string_view MT_MOON_1F = "MtMoon_1F"; -constexpr std::string_view MT_MOON_B2F = "MtMoon_B2F"; -constexpr std::string_view CERULEAN = "CeruleanCity"; -constexpr std::string_view CERULEAN_CENTER = "CeruleanCity_PokemonCenter_1F"; -constexpr std::string_view CERULEAN_MART = "CeruleanCity_Mart"; -constexpr std::string_view CERULEAN_GYM = "CeruleanCity_Gym"; -constexpr std::string_view ROUTE24 = "Route24"; - -Pokemon::GridPose at(std::string_view map, int x, int y, std::optional facing = std::nullopt){ - return Pokemon::GridPose{std::string(map), {{x, y}}, facing}; -} - -StoryCheckpoint row( - std::string id, std::string title, std::optional start, - Supplies supplies, StartMenu menu, std::vector steps -){ - StoryCheckpoint checkpoint; - checkpoint.id = std::move(id); - checkpoint.title = std::move(title); - checkpoint.start = std::move(start); - checkpoint.steps = std::move(steps); - checkpoint.supplies = supplies; - checkpoint.menu = menu; - return checkpoint; -} - -Supplies after_brock(){ - Supplies supplies; - supplies.lead = story_lead_after_brock(); - return supplies; -} - -// What a walk does about wild Pokemon: runs, or fights them for EXP. -enum class WildBattles{ - RUN, - FIGHT, -}; - -StoryStep make(StoryStepKind kind, std::string name, std::string why, Pokemon::StoryActionArgs args = {}){ - StoryStep step; - step.kind = kind; - step.name = std::move(name); - step.why = std::move(why); - step.args = std::move(args); - return step; -} - -StoryStep route(std::string name, Pokemon::GridPose target, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::ROUTE, std::move(name), std::move(why), { - {"target", std::move(target)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -StoryStep step_into(std::string name, Direction direction, std::string why){ - return make(StoryStepKind::STEP, std::move(name), std::move(why), {{"direction", direction}}); -} - -StoryStep into_line(std::string name, Direction direction, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.action = TRAINER_LINE_VARIANT; - return step; -} - -StoryStep hop(std::string name, Direction direction, Pokemon::GridPose landing, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.pose_after = std::move(landing); - return step; -} - -StoryStep answer(std::string name, bool yes, std::string why){ - return make(StoryStepKind::ANSWER, std::move(name), std::move(why), {{"yes", yes}}); -} - -StoryStep scene(std::string name, std::optional pose_after, std::string why){ - StoryStep step = make(StoryStepKind::MASH, std::move(name), std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep battle(std::string name, Pokemon::GridPose pose_after, bool may_lose, std::string why){ - StoryStep step = make(StoryStepKind::BATTLE, std::move(name), std::move(why), {{"may_lose", may_lose}}); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep legs(std::string name, std::vector legs, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::LEGS, std::move(name), std::move(why), { - {"legs", std::move(legs)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -// `step`, a ROUTE or LEGS, run with B held: from the Running Shoes on. -StoryStep running(StoryStep step){ - step.action = RUN_VARIANT; - return step; -} - -StoryStep new_game_intro(Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::NEW_GAME, "intro", std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep talk(std::string name, std::string why){ - return make(StoryStepKind::TALK, std::move(name), std::move(why)); -} - -StoryStep ready(std::string name, Pokemon::GridPose nurse, std::string why){ - return make(StoryStepKind::READY, std::move(name), std::move(why), {{"target", std::move(nurse)}}); -} - -StoryStep heal(std::string name){ - return make(StoryStepKind::HEAL, std::move(name), "full HP"); -} - -StoryStep shop(std::string name, std::vector items, std::string why){ - return make(StoryStepKind::SHOP, std::move(name), std::move(why), {{"items", std::move(items)}}); -} - -StoryStep game_step(std::string action, Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::GAME, action, std::move(why)); - step.action = std::move(action); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep options_step(){ - return make(StoryStepKind::OPTIONS, "options", "fast text; no switch prompt between a trainer's Pokemon"); -} - - -StoryCheckpoint new_game(){ - StoryCheckpoint checkpoint = row("00.01", "new game to the bedroom", std::nullopt, {}, StartMenu::BEFORE_POKEMON, { - // new_game.c: the bedroom at (6, 6), facing the TV. - new_game_intro(at(BEDROOM, 6, 6, NORTH), "Oak's speech, BOY, the player's name (default if none is set), rival GREEN"), - options_step(), - }); - checkpoint.handoff = StoryHandoff::SID_HELPER; - return checkpoint; -} - -// SID Helper confirms the name, finishes the intro and reads the Trainer -// Card from the START menu, without moving the player or saving. -StoryCheckpoint after_sid_helper(){ - StoryCheckpoint checkpoint = row("00.01b", "after SID Helper: close the Trainer Card, save in the bedroom", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - game_step(CLOSE_TRAINER_CARD, at(BEDROOM, 6, 6, NORTH), "the Trainer Card SID Helper left open, or HOME"), - options_step(), - }); - checkpoint.live_start = true; - return checkpoint; -} - -StoryCheckpoint leave_house(){ - return row("00.02", "bedroom to Pallet Town", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("front_door", at(PALLET, 6, 8), "down the stairs and out of the house"), - }); -} - -StoryCheckpoint oaks_trigger(){ - return row("00.03", "Oak stops the player and walks them to the lab", at(PALLET, 6, 8, SOUTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_oaks_trigger", at(PALLET, 12, 2, NORTH), "below the north exit, short of Oak's trigger at (12, 1)"), - step_into("oaks_trigger", NORTH, "the trigger: \"Don't go out!\""), - // PlayerEnter walks the player up 8 tiles from the lab's door. - scene("to_the_lab", at(LAB, 6, 4, NORTH), "Oak walks the player into the lab; the scene ends at the table"), - }); -} - -// Starter RNG starts from a save south of the table, facing the ball. -StoryCheckpoint to_starter_ball(){ - StoryCheckpoint checkpoint = row("00.04", "to Squirtle's ball, south of the table", at(LAB, 6, 4, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_squirtle", at(LAB, 9, 5, NORTH), "under Squirtle's ball (9, 4)"), - }); - checkpoint.handoff = StoryHandoff::STARTER_RNG; - return checkpoint; -} - -StoryCheckpoint starter(){ - return row("00.04b", "Squirtle, then the rival's battle", at(LAB, 9, 5, NORTH), {}, StartMenu::BEFORE_POKEDEX, { - talk("squirtle_ball", "\"So, you want the WATER POKEMON SQUIRTLE?\""), - answer("choose_squirtle", true, "take Squirtle"), - answer("no_nickname", false, "\"give a nickname?\" NO"), - scene("rival_takes_bulbasaur", at(LAB, 9, 5, NORTH), "the rival picks his ball; the player still faces the table (console B, 2026-11-01)"), - route("above_rival_trigger", at(LAB, 7, 7, SOUTH), "short of the rival's trigger row 8"), - step_into("rival_trigger", SOUTH, "\"Wait, let's check out our POKEMON!\""), - // The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down. - battle("rival_battle", at(LAB, 7, 8, SOUTH), true, "the tutorial battle; losing goes on too"), - }); -} - -StoryCheckpoint parcel(){ - return row("00.05", "Route 1 to Viridian Mart: Oak's Parcel", at(LAB, 7, 8, SOUTH), {}, StartMenu::BEFORE_POKEDEX, { - route("below_mart_door", at(VIRIDIAN, 36, 20, NORTH), "Route 1, running from wild battles"), - step_into("mart_door", NORTH, "the clerk's scene starts on entering"), - // ApproachCounter: up 4 from the mat, then faces the clerk. - scene("parcel_from_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "the clerk gives OAK'S PARCEL"), - }); -} - -StoryCheckpoint pokedex(){ - return row("00.06", "Oak's Parcel to the Pokedex", at(VIRIDIAN_MART, 4, 3, WEST), {}, StartMenu::FULL, { - route("below_oak", at(LAB, 6, 4, NORTH), "back down Route 1 to Oak"), - talk("give_parcel", "Oak takes the parcel"), - scene("pokedex_scene", at(LAB, 6, 4, SOUTH), "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)"), - }); -} - -StoryCheckpoint shopping(){ - return row("00.07", "Viridian shopping, then into Viridian Forest", at(LAB, 6, 4, SOUTH), {}, StartMenu::FULL, { - route("mart_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "Route 1 again"), - // 2000 of the 3000 a new game starts with, plus the rival's prize. - shop("potions_and_antidotes", {{"potion", 5}, {"antidote", 3}, {"parlyz_heal", 1}}, "5 Potions, 3 Antidotes, 1 Parlyz Heal"), - route("viridian_nurse", at(VIRIDIAN_CENTER, 7, 4, NORTH), "heal before the forest"), - heal("heal_viridian"), - route("below_old_man_trigger", at(VIRIDIAN, 20, 9, NORTH), "short of the tutorial trigger (20, 8)"), - step_into("old_man_trigger", NORTH, "the old man's catching tutorial can't be walked around"), - // TutorialTriggerLeft turns the player right, to the old man. - scene("old_man_tutorial", at(VIRIDIAN, 20, 8, EAST), "about 60 lines and his demo battle; TEACHY TV"), - // After his demo the old man stands east of the player, beside (20, 8), where - // the map doesn't have him: "east 2" from there didn't move, and the walk north - // ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first. - route("past_old_man", at(VIRIDIAN, 20, 5, NORTH), "north along column 20, clear of the old man"), - // The gate's north warp lands on the forest's exit mat (29, 62), facing - // north. The save there keeps a forest failure from going back to Pallet. - route("forest_entrance", at(FOREST, 29, 62, NORTH), "Route 2 and the south gate, running from wild battles"), - }); -} - -StoryCheckpoint forest(){ - // The supplies bought in 00.07. - return row("00.08", "Viridian Forest to Pewter Center", at(FOREST, 29, 62, NORTH), {5, 3, 1}, StartMenu::FULL, { - // Wild battles are fought for EXP. Straight up the east side from the - // entrance, each leg ending on a wall (the Boy at (45, 58) stops the - // east one). Rick (47, 45) sees (42..46, 45), so the last leg meets - // his battle and is held on to its wall after it. The by-hand run's - // detour west to (13, 46) and back is dropped. - legs("forest_east", {{EAST, 1}, {NORTH, 4}, {EAST, 14}, {NORTH, 15}}, "up the east side to (44, 43)", WildBattles::FIGHT), - route("forest_north", at(FOREST, 39, 25), "north part", WildBattles::FIGHT), - // To the gate by legs that end on walls, which the walker holds again - // after a battle instead of estimating where it stopped: planned - // routes with open legs lost the player in the north of the forest - // (console B, 2026-11-01). The two 1-tile legs are single steps. - legs("forest_exit", { - {NORTH, 10}, {WEST, 12}, {SOUTH, 10}, {WEST, 6}, {NORTH, 20}, - {SOUTH, 1}, {WEST, 10}, {SOUTH, 27}, {WEST, 8}, {NORTH, 20}, {EAST, 1}, - }, "walls all the way to the gate's column", WildBattles::FIGHT), - route("forest_gate", at(FOREST_GATE, 7, 10, NORTH), "north onto the exit, arriving on the gate's mat", WildBattles::FIGHT), - // Out of the forest, wild battles are run from; trainers are still fought. - route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "Route 2 north to Pewter's Center"), - heal("heal_pewter"), - }); -} - -StoryCheckpoint brock(){ - // The by-hand save: 2 Potions and 1 Antidote left after the forest. - return row("00.09", "Pewter Gym: Camper Liam, then Brock", at(PEWTER_CENTER, 7, 4, NORTH), {2, 1}, StartMenu::FULL, { - // Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight - // 4) and sees (4..7, 8): walking north up column 6 from the door, - // the step onto (6, 8) starts his battle. He walks up to the player, - // who stays put and keeps facing north (FRLG doesn't turn the player - // to a trainer). That step is taken on its own, so no leg is cut. - route("below_liam_line", at(GYM, 6, 9, NORTH), "in by the door, up column 6 to below Liam's row"), - step_into("liam_line", NORTH, "onto (6, 8), in Liam's line"), - battle("camper_liam", at(GYM, 6, 8, NORTH), false, "Geodude and Sandshrew; EXP before Brock"), - // On to Brock unless red HP or a status is left that no item cures. - ready("ready_for_brock", at(PEWTER_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - route("before_brock", at(GYM, 6, 6, NORTH), "below Brock (6, 5); Liam, beaten, stands at (5, 8)"), - talk("challenge_brock", "Brock's speech"), - battle("brock", at(GYM, 6, 6, NORTH), false, "Geodude and Onix, with Bubble; Boulder Badge and TM39"), - }); -} - -StoryCheckpoint running_shoes(){ - return row("00.10", "Pewter: the Running Shoes from Oak's aide", at(GYM, 6, 6, NORTH), after_brock(), StartMenu::FULL, { - // Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at - // (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The - // Gym guide's triggers at (42..43, 21..23) need the scene at 0. - route("before_aide_trigger", at(PEWTER, 45, 21, EAST), "out of the Gym, east along row 21, short of the top trigger"), - step_into("aide_trigger", EAST, "onto (46, 21), below the aide"), - // RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; - // the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH - // is set (console B, 2026-11-02: about 20 B presses to the overworld). - scene("shoes_from_aide", at(PEWTER, 46, 21, NORTH), "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north"), - // Where the by-hand walk stopped to start 00.11 (console B, 2026-11-02). - route("below_pewter_center", at(PEWTER, 17, 26, SOUTH), "west along row 21 and down to below the Pokemon Center's door (17, 25)"), - }); -} - -// Route 3's trainers (Route3 map.json): the way east meets three of them. -// Bug Catcher Colton (12, 6) faces east, sight 3: the only way north past -// the row 7 ledges is the gap at x 14..15, below his line. Youngster Ben -// (17, 4) faces south, sight 2, so the way east keeps to row 3 past him. -// Bug Catcher Greg (25, 4) faces south, sight 2, over the way east along -// row 5. Bug Catcher James (32, 6) faces east, sight 4, over the way down -// at x 35..36. The others are kept out of: Lass Janice (19, 9) sees west -// along row 9 to x 14, Lass Sally (30, 3) west along row 3 to x 25, and -// Youngster Calvin (29, 10) west along row 10. Each line is stepped into on -// its own, so no leg is cut; the trainer walks up to the player, who stays -// put facing the way they stepped. -StoryCheckpoint route3(){ - return row("00.11", "Pewter Center, then Route 3's trainers", at(PEWTER, 17, 26, SOUTH), after_brock(), StartMenu::FULL, { - running(route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "in by the door below the player")), - heal("heal_pewter"), - // Up from row 9 west of Janice's line, which ends at x 14. - running(route("west_of_janice_line", at(ROUTE3, 13, 8), "out of Pewter by row 21, east into Route 3, short of Janice's line")), - running(legs("below_colton_line", {{EAST, 1}, {NORTH, 1}}, "to (14, 7), in the ledges' gap")), - step_into("colton_line", NORTH, "onto (14, 6), in Colton's line"), - battle("bug_catcher_colton", at(ROUTE3, 14, 6, NORTH), false, "his Bug Pokemon; Colton stops at (13, 6)"), - running(legs("past_ben", {{NORTH, 3}, {EAST, 4}, {SOUTH, 2}, {EAST, 6}}, "up to row 3 above Ben, down at x 18 east of his line, to (24, 5)")), - step_into("greg_line", EAST, "onto (25, 5), below Greg"), - battle("bug_catcher_greg", at(ROUTE3, 25, 5, EAST), false, "his Bug Pokemon; Greg is already next to the player"), - running(legs("above_james_line", {{EAST, 11}}, "along row 5 to the wall at (36, 5)")), - step_into("james_line", SOUTH, "onto (36, 6), at the end of James's line"), - battle("bug_catcher_james", at(ROUTE3, 36, 6, SOUTH), false, "his Bug Pokemon; James stops at (35, 6)"), - // Saved here, the trainers behind, so a failure on the way to Route 4 - // doesn't fight them again. - running(legs("save_spot", {{SOUTH, 2}}, "down to (36, 8), beside the wall east of it")), - }); -} - -// Route 3's north exit (x 68..75) joins Route 4 (offset 60) at x 8..15, up -// which column 12 leads to the Pokemon Center's door (12, 5). Lass Robin -// (40, 11) wanders up and down at x 40, looking north and south, sight 3. -// Rock above (y <= 8) and grass below (y >= 12) leave every way east -// across her column at y 9..11, so whether she sees the player depends on -// her facing. The walk watches for her after the leg along row 9, which -// crosses her sight on (40, 9) only; if she saw the player, her message -// goes to story_interrupts(), which fight her, and the route goes on from -// (40, 9) (run_route(); console B, 2026-11-02, she stopped the player -// there and spoke after the leg's short watch). -StoryCheckpoint magikarp_salesman(){ - StoryCheckpoint checkpoint = row("00.12", "Route 3 and 4 to the Magikarp salesman", at(ROUTE3, 36, 8, SOUTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "east over Route 3, off the grass, north into Route 4 and its Pokemon Center")), - heal("heal_route4"), - // Gift RNG starts from a save facing the salesman (1, 3). - running(route("before_salesman", at(ROUTE4_CENTER, 2, 3, WEST), "beside the Magikarp salesman, facing him")), - }); - checkpoint.handoff = StoryHandoff::GIFT_RNG; - return checkpoint; -} - -// Gift RNG buys the Magikarp (500 of the money 00.12 brings) without -// moving the player and leaves its summary open, or HOME. This saves the -// shiny where 00.12 ended. A run started here with Gift RNG's handoff on -// loads the save beside the salesman and runs Gift RNG first. -StoryCheckpoint after_gift_rng(){ - StoryCheckpoint checkpoint = row("00.12b", "after Gift RNG: save with the Magikarp", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - game_step(LEAVE_GIFT_SUMMARY, at(ROUTE4_CENTER, 2, 3, WEST), "the Magikarp's summary Gift RNG left open, or HOME"), - }); - checkpoint.live_start = true; - return checkpoint; -} - -// The Magikarp goes to BOX 1 at the Center's PC (11, 1), so Mt. Moon is -// fought with the starter alone (console B, 2026-11-02: done by hand and -// saved at (11, 2), facing the PC, where this row ends). The wandering -// boy (4..6, 3..5) is walked around. The Magikarp comes from Gift RNG: -// with Gift RNG off the party is the starter alone, and the deposit is -// skipped. -StoryCheckpoint magikarp_to_box(){ - return row("00.12c", "Route 4 Center: the Magikarp into BOX 1", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - running(route("pc_front", at(ROUTE4_CENTER, 11, 2, NORTH), "below the PC (11, 1), facing it")), - pc_step("magikarp_to_box", "DEPOSIT the party's second slot into BOX 1, if it has one", PcTransfer{ - .action = PcAction::DEPOSIT, .party_slot = 1, .box = 0, .if_missing = PcMissing::SKIP, - }), - }); -} - -// Mt. Moon (pokefirered data/maps/MtMoon_1F, _B1F, _B2F). Every floor tile -// of the cave has wild encounters, which are run from, so its legs end on -// walls, ladders or someone standing still, which the walker holds again -// after a battle; the few open ones are short. The way through: up 1F's -// middle and west side, its north-west ladder, B1F's west ladder down to -// B2F's south-east, round B2F's south edge to its west, north past -// Miguel and the fossils, and the ladder up to B1F's east end, which -// leads out to Route 4 east of the mountain. -// - 1F's trainers are walked around: Youngster Josh (13, 17) sees east -// along row 17 to x 17, so the way west into the west room is down -// column 18 and up column 11; Lass Miriam walks round (32..33, 4..5), -// sight 2, so the way east keeps to row 9 and columns 38 and 40; Hiker -// Marcos wanders (5..9, 8..12) and sees one tile, so the way north is -// column 11 and row 3. -// - The Moon Stone ball (3, 2) on 1F (FLAG_HIDE_MT_MOON_1F_MOON_STONE) is -// a few tiles off the way to the ladder (5, 6). -// - The Grunt at (37, 21) on B2F looks around (sight 3) over the only way -// east round B2F. His room is crossed on legs to walls, at one tile of -// his sight each, (37, 22) and (40, 21); if he looks the player's way, -// he walks up beside the leg, story_interrupts() fights him, and the -// leg is held on to its wall. -// - The Grunt at (12, 20) faces south (sight 2) over (12, 21..22), across -// rows 21..22, the only way north to Miguel: stepped into from the -// west, he is next to the player and doesn't walk. -// - Super Nerd Miguel (13, 11) battles on the step onto (14, 11) -// (MtMoon_B2F_EventScript_MiguelTrigger, VAR_MAP_SCENE_MT_MOON_B2F 0), -// then "We'll each take one!" -// - The fossils: DOME (13, 7), HELIX (14, 7). After the HELIX, Miguel -// walks up to (13, 8) and takes the DOME, which opens the gap north. -// The save is on Route 4: the save card's places don't include Mt. Moon. -StoryCheckpoint mt_moon(){ - return row("00.13", "Mt. Moon: a Moon Stone, a Rocket, Miguel and the Helix Fossil", at(ROUTE4_CENTER, 11, 2, NORTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "the nurse, below the counter")), - heal("heal_route4"), - running(route("mt_moon_entrance", at(MT_MOON_1F, 18, 37, NORTH), "out of the Center, west into Mt. Moon")), - running(legs("mt_moon_1f", { - {NORTH, 12}, {EAST, 8}, {NORTH, 12}, {EAST, 3}, {SOUTH, 1}, {EAST, 9}, - {NORTH, 1}, {EAST, 2}, {NORTH, 4}, {WEST, 24}, {EAST, 2}, {SOUTH, 12}, - {WEST, 7}, {NORTH, 18}, {WEST, 9}, {EAST, 1}, - }, "up the middle, east of Miriam, west along row 9, down column 18 past Josh, up column 11 past Marcos, to (3, 3)")), - running(route("below_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "facing the Moon Stone (3, 2)")), - talk("moon_stone_ball", "A on the item ball"), - // No reader for the text yet: the scene's end is the overworld. - scene("found_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "\" found a MOON STONE!\", then the pocket line; the ball is gone"), - running(route("b2f_ladder_foot", at(MT_MOON_B2F, 26, 21, EAST), "1F's ladder (5, 6), down B1F's west side to its ladder (22, 18), onto B2F")), - running(legs("b2f_south", { - {NORTH, 4}, {EAST, 8}, {WEST, 2}, {SOUTH, 5}, {EAST, 8}, {NORTH, 3}, {WEST, 1}, {NORTH, 5}, - {EAST, 7}, {SOUTH, 14}, {WEST, 9}, {SOUTH, 10}, {WEST, 29}, {EAST, 3}, {NORTH, 17}, - }, "through the Grunt's room at (37, 21), round the south edge, up column 11 to (11, 21)")), - step_into("grunt_line", EAST, "onto (12, 21), below the Grunt at (12, 20)"), - battle("rocket_grunt", at(MT_MOON_B2F, 12, 21, EAST), false, "Rattata and Zubat, Lv13"), - ready("ready_for_miguel", at(ROUTE4_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse, back through the cave, only if they can't"), - // Up column 13 to Miguel, who stops the leg on (13, 12), then east - // to the wall: the tile below his trigger. - running(legs("below_miguel_trigger", {{EAST, 1}, {NORTH, 9}, {EAST, 1}}, "to (14, 12), below Miguel's trigger (14, 11)")), - step_into("miguel_trigger", NORTH, "onto (14, 11), beside Miguel"), - battle("super_nerd_miguel", at(MT_MOON_B2F, 14, 11, NORTH), false, "Grimer, Voltorb and Koffing, Lv12; \"We'll each take one!\""), - running(legs("below_helix_fossil", {{NORTH, 3}}, "up column 14 to the HELIX FOSSIL (14, 7)")), - fossil_step("helix_fossil", "the HELIX FOSSIL; Miguel takes the DOME FOSSIL", Fossil::HELIX), - // The maps keep the fossils, which the game removes after the - // choice: the step onto the HELIX's tile is taken on its own. - step_into("helix_gap", NORTH, "onto (14, 7), where the HELIX FOSSIL lay"), - running(route("route4_east", at(ROUTE4, 32, 6, SOUTH), "west to B2F's ladder (5, 10), up to B1F, east to its exit onto Route 4")), - }); -} - - -// Route 4 east of Mt. Moon (Route4 map.json) joins Cerulean City at its -// east end (x 107; Route 4's row 3 is the city's row 13). Its upper road -// (rows 2..8) reaches the city only by water: the way on by land is down -// the ledge row 9 at x 90..96 to the lower road (rows 10..12), which -// joins the city's rows 20..22. Lass Crissy (75, 3) faces east, sight 4, -// over row 3 from x 76 to 79; the way east keeps out of her line and off -// the grass south of the road (75..87, 11..17). -// -// The open leg east across the city's edge ended a tile short on the -// console (2026-11-03: on (6, 20), not (7, 20)), and no hold to a wall -// in the city's west end finds the player from there: the next hold -// south met the fence on (6, 23) and the walk went on a column off. So -// the entry ends on (9, 20), and only legs to walls follow: north up -// column 9 (or 8, a tile short) to row 12, west to (8, 12), east to -// (30, 12) beside the policeman (31, 12), south to (30, 17), west to -// (25, 17), and down the ledge row 18 to (25, 19), a few tiles from the -// door (22, 19). The way keeps out of the boy's (16, 18..24) and the -// balding man's (8..10, 22..24) wander boxes. -StoryCheckpoint route4_to_cerulean(){ - return row("00.14", "Route 4 east to Cerulean's Pokemon Center", at(ROUTE4, 32, 6, SOUTH), after_brock(), StartMenu::FULL, { - running(route("above_ledge", at(ROUTE4, 93, 8, SOUTH), "east along Route 4's upper road to above the ledge row 9")), - hop("ledge_hop", SOUTH, at(ROUTE4, 93, 10, SOUTH), "down the ledge (93, 9) to the lower road"), - running(route("cerulean_entry", at(CERULEAN, 9, 20, EAST), "east into Cerulean City, to (9, 20) below column 9")), - running(legs("above_city_ledge", {{NORTH, 8}, {WEST, 1}, {EAST, 22}, {SOUTH, 5}, {WEST, 5}}, "to walls: (9, 12), (8, 12), (30, 12), (30, 17), (25, 17)")), - hop("city_ledge_hop", SOUTH, at(CERULEAN, 25, 19, SOUTH), "down the ledge (25, 18)"), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "west along row 20 to the Pokemon Center's door (22, 19)")), - heal("heal_cerulean"), - }); -} - -// Cerulean Gym (pokefirered CeruleanCity_Gym map.json and scripts.inc): -// a pool with walkways. Misty (8, 6) stands on a platform (7..9, 6) above -// row 7. Picnicker Diana (4, 7) faces east, sight 4, over (5..8, 7), so -// misty_front (8, 7) is in her line; Swimmer Luis (10, 12) in the water -// faces west, sight 1, over (9, 12), on column 9 north of the door. No -// gym trainer has to be fought for Misty, so neither is: from the door up -// column 9 to row 13 (a route there, so the planner's walk to a wall -// doesn't run on past it through (9, 12)), west to (4, 13), and to walls -// round the pool's west and north sides, (4, 10), (12, 10), (12, 7), then -// west to (9, 7), the tile below the platform's east end, out of Diana's -// line. 00.14c steps up onto (9, 6) and talks to Misty from beside her. -// -// Misty beat a Lv20 Wartortle (console B, run m51), so first a GRIND to -// Lv23 on 00.15's patch. Gen 3 numbers (pokefirered: her mons have IV 0; -// Wartortle taken at IV 15, no EVs): Starmie Lv21 has 56 HP, Atk 36, SpA -// 47, SpD 40. Bite is Dark, special in Gen 3, no STAB, x2 on Psychic: at -// Lv23 (SpA 39) it does 23..28, three hits (two on top rolls); at Lv20, -// 20..24. Her Swift (physical, 60) does 9..11 to a Lv23 Wartortle (about -// 67 HP, Def 45) and Water Pulse (STAB, resisted) 8..10: 6 or more hits, -// though m51 saw about 20 a turn. Her Recover (28) and Super Potion undo -// a Bite, so the margin is in Bite's damage. -// -// The Mart comes before the GRIND: its wild battles are fought only with -// 2 or more Potions, and 00.14's save has none (m51 met Misty with only -// the 5 this row bought). 5 Potions (row 3, 300 each), then up to 3 Super -// Potions (row 2, 700), last so they take the Items pocket's last row; -// the battle doesn't use them yet. The money box can't be read, so the -// floor stands for it, and a floor above the money fails the step (the -// quantity box wraps). Prizes (pokefirered: 4 x last level x the class's -// factor) from a new game's 3000, less Viridian's 2000 and the Magikarp's -// 500: Liam 220, Brock 1400, Route 3's bug catchers 360, the Mt. Moon -// grunt 416 and Miguel 288 (the first rival's 80 only if won), at least -// 3184 here. Floor and budget 3000: 5 Potions and 2 Super Potions, 2900. -// Misty's 2100 (4 x 21 x 25) then leaves 00.15 its floor of 1500. Then the -// nurse, and the save before Misty, so her battle is its own checkpoint, -// 00.14c, verified and retried from it. 00.15's GRIND then fights -// until the sim beats the Cerulean rival often enough. -StoryCheckpoint cerulean_gym(){ - const MartPlan supplies{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "potion", .quantity = 5}, {.item = "super-potion", .quantity = 3}}, - .budget = 3000, - .money_floor = 3000, - }; - const GrindPlan to_lv23{.member = 0, .level = 23, .max_encounters = 100, .pace = WEST, .heal_every = 0}; - return row("00.14b", "Cerulean: Potions, a GRIND to Lv23, then into the Gym, saved below Misty's platform", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_potions", "5 Potions for the GRIND's wild battles, then Super Potions as the money allows", supplies), - running(route("grind_patch", at(ROUTE4, 86, 16, WEST), "west out of the city along Route 4's lower road onto its grass's east edge")), - grind_step("grind_to_lv23", "wild battles until the lead is Lv23, where Bite takes Starmie in three", to_lv23, at(CERULEAN_CENTER, 7, 4, NORTH)), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center: Misty's battle starts at full HP and PP")), - heal("heal_cerulean"), - running(route("gym_below_luis", at(CERULEAN_GYM, 9, 13), "into the Gym, up column 9 to row 13, short of Luis's (9, 12)")), - running(legs("gym_west_walkway", {{WEST, 5}}, "west to the wall (4, 13)")), - running(legs("below_misty_platform", {{NORTH, 3}, {EAST, 8}, {NORTH, 3}, {WEST, 3}}, "walls (4, 10), (12, 10), (12, 7), then to (9, 7), out of Diana's line")), - }); -} - -// Misty (TRAINER_LEADER_MISTY: Staryu Lv18, Starmie Lv21), talked to from -// (9, 6), beside her on the platform. Her win text runs on to the CASCADE -// BADGE, TM03 (Water Pulse) and its explanation, all read with the -// battle's. Bite is chosen against her party (Starmie is Water/Psychic). -// Back to the nurse round the pool's west side, out of Luis's line; then -// Water Pulse in place of Tail Whip, last, at the Center, from the bag's -// TM CASE. Ends where 00.15 starts. -StoryCheckpoint misty(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - return row("00.14c", "Cerulean Gym: Misty, then Water Pulse", at(CERULEAN_GYM, 9, 7, WEST), after_brock(), StartMenu::FULL, { - running(route("beside_misty", at(CERULEAN_GYM, 9, 6, WEST), "up onto (9, 6), facing Misty (8, 6)")), - talk("challenge_misty", "Misty's speech"), - battle("misty", at(CERULEAN_GYM, 9, 6, WEST), false, "Staryu and Starmie, with Bite; CASCADE BADGE and TM03"), - running(legs("gym_way_out", {{SOUTH, 1}, {EAST, 3}, {SOUTH, 3}, {WEST, 8}, {SOUTH, 3}, {EAST, 5}}, "walls (12, 7), (12, 10), (4, 10), (4, 13), (9, 13), round Luis's (9, 12)")), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "down column 9 out of the Gym, to the Center")), - heal("heal_cerulean"), - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip", water_pulse), - }); -} - -// Before the rival north of Cerulean (cerulean_rival()), from the -// Center: first TM03 Water Pulse over Tail Whip, if the lead doesn't know -// it yet, so the GRIND's sim plays it (a run without TM03 from Misty -// skips the step). Then 3 Potions at the Mart -// (CeruleanCity_Mart_Items: POTION is row 3, 300 each; Mt. Moon's -// trainers leave well over the floor) and 2 Awakenings (row 6, 250 each; -// pokefirered items.json) for the rival's Bulbasaur's Sleep Powder -// (console B, m56: asleep at 34/65 HP, it fainted two turns later with -// 15 Potions), 1400 of the floor's 1500. Then a GRIND on Route 4's grass -// east of Mt. Moon (75..86, 11..17; Spearow, Rattata, Ekans and Mankey -// around Lv10, about 80 EXP each), healing at the Center, until the -// battle sim beats the rival 00.15b fights 50% or more: the win chance -// his battle refuses below. Console B's Wartortle (Lv22, 65 HP, Water -// Pulse) is about 42% there and 62% at Lv23; Lv28 (about 88%, some 120 -// battles from Lv22) is the cap. Then the nurse, and the save on (23, 7), -// the tile below his trigger: his battle is its own checkpoint, 00.15b, -// verified and retried from this save. -StoryCheckpoint cerulean_grind(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - const MartPlan potions{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "potion", .quantity = 3}, {.item = "awakening", .quantity = 2}}, - .budget = 1500, - .money_floor = 1500, - }; - const GrindPlan for_rival{ - .member = 0, .level = 28, .max_encounters = 150, .pace = WEST, .heal_every = 0, - .trainer = std::string(story_trainer(CERULEAN, "rival_cerulean").value_or("")), .min_chance = MIN_WIN_CHANCE, - }; - return row("00.15", "Cerulean: Water Pulse, Potions, a GRIND until the rival is winnable, then saved below his trigger", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip, unless the lead knows it or there is no TM03", water_pulse), - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_potions", "3 Potions: the GRIND fights wild battles only with 2 or more; 2 Awakenings for the rival's Sleep Powder", potions), - running(route("grind_patch", at(ROUTE4, 86, 16, WEST), "west out of the city along Route 4's lower road onto its grass's east edge")), - grind_step("grind_for_rival", "wild battles until the sim beats the rival 50% or more, Lv28 at most; the nurse when hurt or low on PP", for_rival, at(CERULEAN_CENTER, 7, 4, NORTH)), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center: the rival's battle starts at full HP and PP")), - heal("heal_cerulean"), - running(route("below_rival_trigger", at(CERULEAN, 23, 7, NORTH), "out of the Center, north up to (23, 7), short of the trigger row 6")), - }); -} - -// The rival north of Cerulean (CeruleanCity scripts.inc): the only way -// north to Nugget Bridge is columns 22..24, and a step onto row 6 there -// (CeruleanCity_EventScript_RivalTrigger*, VAR_MAP_SCENE_CERULEAN_CITY_RIVAL -// 0) brings him down to the player. From the middle, (23, 6), he stops -// at (23, 5); after the battle he walks round the player and off south, -// and the player, turning to watch him, ends facing south. His FAME -// CHECKER's text is read to the overworld with the battle's. For a player -// who took Squirtle he has Pidgeotto Lv17, Abra Lv16, Rattata Lv15 and -// Bulbasaur Lv18 (sParty_RivalCeruleanBulbasaur), whose Vine Whip and -// Sleep Powder are the danger. The row starts from 00.15's save below the -// trigger, and saves after him. First TM03 Water Pulse over Tail Whip (from -// the bag, where the player stands), if the lead doesn't know it yet: -// console B's save (2026-11-03) is past Misty's TEACH, which failed there. -// Where she taught it, the step reads the moves and does nothing. -StoryCheckpoint cerulean_rival(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - return row("00.15b", "Cerulean: Water Pulse if not known, then the rival north of the city", at(CERULEAN, 23, 7, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip, unless the lead knows it", water_pulse), - step_into("rival_trigger", NORTH, "onto (23, 6), the middle trigger: \"Yo! !\""), - battle("rival_cerulean", at(CERULEAN, 23, 6, SOUTH), false, "Pidgeotto, Abra, Rattata and Bulbasaur; then the FAME CHECKER"), - }); -} - -// Nugget Bridge (Route24 map.json) is x 10..12 from row 32 north to row -// 16, the city's columns 22..24 (offset 12). Its five trainers stand on -// it facing across, sight 2, so each line crosses the middle column 11 -// on the trainer's row: Bug Catcher Cale (12, 31), Lass Ali (10, 28), -// Youngster Timmy (12, 25), Lass Reli (10, 22) and Camper Ethan (12, 19). -// Each is fought on the step onto their row, beside them: they don't -// walk, and the player keeps facing north. Two tiles separate the rows, -// walked as one short leg; the step onto a row goes on a tile at a time -// until the trainer sees the player (into_line()), as the open leg onto -// the bridge ended a tile short twice on console B (2026-11-03), on -// (11, 33), and one step left the player out of Cale's sight. Then the -// Rocket (12, 15): the step onto (11, 15) -// (Route24_EventScript_RocketTriggerRight, VAR_MAP_SCENE_ROUTE24 0) gives -// the NUGGET, "join Team Rocket", and his battle; he only turns, and the -// player turns east to him. Camper Shane (5, 21) looks north from the -// west bank, off the way. -StoryCheckpoint nugget_bridge(){ - return row("00.16", "Nugget Bridge: the nurse, five trainers and the Rocket", at(CERULEAN, 23, 6, SOUTH), after_brock(), StartMenu::FULL, { - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center after the rival, before Nugget Bridge")), - heal("heal_cerulean"), - running(route("below_cale_line", at(ROUTE24, 11, 32, NORTH), "out of the Center, north past the rival's row onto the bridge, below Cale's row")), - into_line("cale_line", NORTH, "onto (11, 31), beside Cale"), - battle("bug_catcher_cale", at(ROUTE24, 11, 31, NORTH), false, "his Bug Pokemon"), - running(legs("below_ali_line", {{NORTH, 2}}, "up to (11, 29)")), - into_line("ali_line", NORTH, "onto (11, 28), beside Ali"), - battle("lass_ali", at(ROUTE24, 11, 28, NORTH), false, "her Pokemon"), - running(legs("below_timmy_line", {{NORTH, 2}}, "up to (11, 26)")), - into_line("timmy_line", NORTH, "onto (11, 25), beside Timmy"), - battle("youngster_timmy", at(ROUTE24, 11, 25, NORTH), false, "his Pokemon"), - running(legs("below_reli_line", {{NORTH, 2}}, "up to (11, 23)")), - into_line("reli_line", NORTH, "onto (11, 22), beside Reli"), - battle("lass_reli", at(ROUTE24, 11, 22, NORTH), false, "her Pokemon"), - running(legs("below_ethan_line", {{NORTH, 2}}, "up to (11, 20)")), - into_line("ethan_line", NORTH, "onto (11, 19), beside Ethan"), - battle("camper_ethan", at(ROUTE24, 11, 19, NORTH), false, "his Pokemon"), - // A route, not legs: the nurse may have been needed. - ready("ready_for_rocket", at(CERULEAN_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - running(route("below_rocket_trigger", at(ROUTE24, 11, 16, NORTH), "up the bridge to below the Rocket's trigger (11, 15)")), - step_into("rocket_trigger", NORTH, "onto (11, 15), beside the Rocket"), - battle("rocket_grunt", at(ROUTE24, 11, 15, EAST), false, "the NUGGET, then Ekans and Zubat, Lv15"), - }); -} - - -std::vector cpp_rows(){ - return { - new_game(), after_sid_helper(), leave_house(), oaks_trigger(), to_starter_ball(), starter(), parcel(), pokedex(), shopping(), forest(), brock(), - running_shoes(), route3(), magikarp_salesman(), after_gift_rng(), magikarp_to_box(), mt_moon(), - route4_to_cerulean(), cerulean_gym(), misty(), cerulean_grind(), cerulean_rival(), nugget_bridge(), - }; -} - -// Why `loaded` differs from `row`, or empty. Steps compare as their -// shared JSON, which writes every field. -std::string checkpoint_difference(const StoryCheckpoint& row, const StoryCheckpoint& loaded){ - const std::string row_json = Pokemon::story_checkpoint_json(row).dump(); - const std::string loaded_json = Pokemon::story_checkpoint_json(loaded).dump(); - if (row_json != loaded_json){ - return std::format("{}: the file loads to\n{}\nbut the C++ row is\n{}", row.id, loaded_json, row_json); - } - if (row.handoff != loaded.handoff || row.live_start != loaded.live_start){ - return row.id + ": a different handoff or live start."; - } - for (size_t c = 0; c < row.steps.size() && c < loaded.steps.size(); c++){ - if (row.steps[c].once_per_save != loaded.steps[c].once_per_save){ - return row.id + "/" + row.steps[c].name + ": a different once_per_save."; - } - } - if (row.menu != loaded.menu){ - return row.id + ": a different START menu."; - } - const Supplies& a = row.supplies; - const Supplies& b = loaded.supplies; - if (a.potions != b.potions || a.antidotes != b.antidotes || a.parlyz_heals != b.parlyz_heals){ - return row.id + ": different supplies."; - } - if (a.lead.species != b.lead.species || a.lead.level != b.lead.level || a.lead.moves.size() != b.lead.moves.size()){ - return row.id + ": a different lead."; - } - for (size_t c = 0; c < a.lead.moves.size(); c++){ - if (a.lead.moves[c].move != b.lead.moves[c].move || a.lead.moves[c].pp != b.lead.moves[c].pp){ - return row.id + ": a different lead move " + std::to_string(c + 1) + "."; - } - } - return ""; -} - -class Test_AutoStoryTableParity : public UnitTest{ -public: - Test_AutoStoryTableParity() - : UnitTest("PokemonFRLG::AutoStory - the story files load to the C++ rows") - {} - virtual UnitTestResult run(Logger&, CancellableScope&) const override{ - try{ - const std::vector rows = cpp_rows(); - const std::vector& loaded = story_checkpoints(); - if (rows.size() != loaded.size()){ - return std::format("{} C++ rows, {} files.", rows.size(), loaded.size()); - } - for (size_t c = 0; c < rows.size(); c++){ - const std::string difference = checkpoint_difference(rows[c], loaded[c]); - if (!difference.empty()){ - return difference; - } - } - return true; - }catch (Exception& e){ - return std::string(e.name()) + ": " + e.message(); - } - } -}; - -} // namespace - - -void add_tests_AutoStoryTableParity(UnitTestDatabase& database){ - database.add(); -} - - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp index bab531a963..4026d032b6 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -990,7 +990,6 @@ const AutoStoryTestCase AUTO_STORY_CASES[] = { void add_tests_AutoStory(UnitTestDatabase& database){ add_tests_AutoStoryRunPlan(database); - add_tests_AutoStoryTableParity(database); for (const auto& scenario : AUTO_STORY_CASES){ database.add(scenario); } diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index f8e8216b7f..b0e515e80c 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1985,7 +1985,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach_Tests.cpp From 0d47b006e3477e53d11d4fc2ebc3a21b0a31c2de Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 10:47:45 -0800 Subject: [PATCH 6/8] FRLG AutoStory: delete stage 5's C++ story rows, parity proven The parity test passed in the merge before this commit: every story file loads to the C++ row it replaces. This removes it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonFRLG_AutoStoryTable.h | 2 - ...PokemonFRLG_AutoStoryTableParity_Tests.cpp | 949 ------------------ .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 1 - SerialPrograms/cmake/SourceFiles.cmake | 1 - 4 files changed, 953 deletions(-) delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h index 2d57d3c272..9aeaf0fcb3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -70,8 +70,6 @@ const std::vector& story_checkpoints(); // Registers AutoStory table validation unit tests. void add_tests_AutoStory(UnitTestDatabase& database); -// The story files against the C++ rows they replace. -void add_tests_AutoStoryTableParity(UnitTestDatabase& database); // Which rows a run takes (PokemonFRLG_AutoStoryRunPlan_Tests.cpp). void add_tests_AutoStoryRunPlan(UnitTestDatabase& database); // The table run end to end against a fake game (PokemonFRLG_AutoStorySimulation_Tests.cpp). diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp deleted file mode 100644 index d5f7483cf7..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp +++ /dev/null @@ -1,949 +0,0 @@ -/* AutoStory Table Parity Tests - * - * From: https://github.com/PokemonAutomation/ - * - * The C++ rows the story table had before StoryData/, built with the - * shared step API, against the checkpoints read from the files: each - * loads to the same steps, args (with the fallbacks the reader fills in), - * poses, supplies and START menu. Removed with the C++ rows. - * - */ - -#include -#include -#include -#include -#include "Common/Cpp/Exceptions.h" -#include "Common/Cpp/TestRunners/UnitTest.h" -#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" -#include "PokemonFRLG_AutoStoryCapture.h" -#include "PokemonFRLG_AutoStoryChoice.h" -#include "PokemonFRLG_AutoStoryBattleData.h" -#include "PokemonFRLG_AutoStoryGrind.h" -#include "PokemonFRLG_AutoStoryMart.h" -#include "PokemonFRLG_AutoStoryParty.h" -#include "PokemonFRLG_AutoStoryTable.h" -#include "PokemonFRLG_AutoStoryTeach.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -namespace{ - -constexpr Direction NORTH = Direction::NORTH; -constexpr Direction SOUTH = Direction::SOUTH; -constexpr Direction EAST = Direction::EAST; -constexpr Direction WEST = Direction::WEST; - -constexpr std::string_view BEDROOM = "PalletTown_PlayersHouse_2F"; -constexpr std::string_view PALLET = "PalletTown"; -constexpr std::string_view LAB = "PalletTown_ProfessorOaksLab"; -constexpr std::string_view VIRIDIAN = "ViridianCity"; -constexpr std::string_view VIRIDIAN_MART = "ViridianCity_Mart"; -constexpr std::string_view VIRIDIAN_CENTER = "ViridianCity_PokemonCenter_1F"; -constexpr std::string_view FOREST = "ViridianForest"; -constexpr std::string_view FOREST_GATE = "Route2_ViridianForest_NorthEntrance"; -constexpr std::string_view PEWTER = "PewterCity"; -constexpr std::string_view PEWTER_CENTER = "PewterCity_PokemonCenter_1F"; -constexpr std::string_view GYM = "PewterCity_Gym"; -constexpr std::string_view ROUTE3 = "Route3"; -constexpr std::string_view ROUTE4 = "Route4"; -constexpr std::string_view ROUTE4_CENTER = "Route4_PokemonCenter_1F"; -constexpr std::string_view MT_MOON_1F = "MtMoon_1F"; -constexpr std::string_view MT_MOON_B2F = "MtMoon_B2F"; -constexpr std::string_view CERULEAN = "CeruleanCity"; -constexpr std::string_view CERULEAN_CENTER = "CeruleanCity_PokemonCenter_1F"; -constexpr std::string_view CERULEAN_MART = "CeruleanCity_Mart"; -constexpr std::string_view CERULEAN_GYM = "CeruleanCity_Gym"; -constexpr std::string_view ROUTE24 = "Route24"; -constexpr std::string_view ROUTE25 = "Route25"; -constexpr std::string_view SEA_COTTAGE = "Route25_SeaCottage"; - -Pokemon::GridPose at(std::string_view map, int x, int y, std::optional facing = std::nullopt){ - return Pokemon::GridPose{std::string(map), {{x, y}}, facing}; -} - -StoryCheckpoint row( - std::string id, std::string title, std::optional start, - Supplies supplies, StartMenu menu, std::vector steps -){ - StoryCheckpoint checkpoint; - checkpoint.id = std::move(id); - checkpoint.title = std::move(title); - checkpoint.start = std::move(start); - checkpoint.steps = std::move(steps); - checkpoint.supplies = supplies; - checkpoint.menu = menu; - return checkpoint; -} - -Supplies after_brock(){ - Supplies supplies; - supplies.lead = story_lead_after_brock(); - return supplies; -} - -// What a walk does about wild Pokemon: runs, or fights them for EXP. -enum class WildBattles{ - RUN, - FIGHT, -}; - -StoryStep make(StoryStepKind kind, std::string name, std::string why, Pokemon::StoryActionArgs args = {}){ - StoryStep step; - step.kind = kind; - step.name = std::move(name); - step.why = std::move(why); - step.args = std::move(args); - return step; -} - -StoryStep route(std::string name, Pokemon::GridPose target, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::ROUTE, std::move(name), std::move(why), { - {"target", std::move(target)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -StoryStep step_into(std::string name, Direction direction, std::string why){ - return make(StoryStepKind::STEP, std::move(name), std::move(why), {{"direction", direction}}); -} - -StoryStep into_line(std::string name, Direction direction, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.action = TRAINER_LINE_VARIANT; - return step; -} - -StoryStep hop(std::string name, Direction direction, Pokemon::GridPose landing, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.pose_after = std::move(landing); - return step; -} - -StoryStep answer(std::string name, bool yes, std::string why){ - return make(StoryStepKind::ANSWER, std::move(name), std::move(why), {{"yes", yes}}); -} - -StoryStep scene(std::string name, std::optional pose_after, std::string why){ - StoryStep step = make(StoryStepKind::MASH, std::move(name), std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep battle(std::string name, Pokemon::GridPose pose_after, bool may_lose, std::string why){ - StoryStep step = make(StoryStepKind::BATTLE, std::move(name), std::move(why), {{"may_lose", may_lose}}); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep legs(std::string name, std::vector legs, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::LEGS, std::move(name), std::move(why), { - {"legs", std::move(legs)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -// `step`, a ROUTE or LEGS, run with B held: from the Running Shoes on. -StoryStep running(StoryStep step){ - step.action = RUN_VARIANT; - return step; -} - -StoryStep new_game_intro(Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::NEW_GAME, "intro", std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep talk(std::string name, std::string why){ - return make(StoryStepKind::TALK, std::move(name), std::move(why)); -} - -StoryStep ready(std::string name, Pokemon::GridPose nurse, std::string why){ - return make(StoryStepKind::READY, std::move(name), std::move(why), {{"target", std::move(nurse)}}); -} - -StoryStep heal(std::string name){ - return make(StoryStepKind::HEAL, std::move(name), "full HP"); -} - -StoryStep shop(std::string name, std::vector items, std::string why){ - return make(StoryStepKind::SHOP, std::move(name), std::move(why), {{"items", std::move(items)}}); -} - -StoryStep game_step(std::string action, Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::GAME, action, std::move(why)); - step.action = std::move(action); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep options_step(){ - return make(StoryStepKind::OPTIONS, "options", "fast text; no switch prompt between a trainer's Pokemon"); -} - - -StoryCheckpoint new_game(){ - StoryCheckpoint checkpoint = row("00.01", "new game to the bedroom", std::nullopt, {}, StartMenu::BEFORE_POKEMON, { - // new_game.c: the bedroom at (6, 6), facing the TV. - new_game_intro(at(BEDROOM, 6, 6, NORTH), "Oak's speech, BOY, the player's name (default if none is set), rival GREEN"), - options_step(), - }); - checkpoint.handoff = StoryHandoff::SID_HELPER; - return checkpoint; -} - -// SID Helper confirms the name, finishes the intro and reads the Trainer -// Card from the START menu, without moving the player or saving. -StoryCheckpoint after_sid_helper(){ - StoryCheckpoint checkpoint = row("00.01b", "after SID Helper: close the Trainer Card, save in the bedroom", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - game_step(CLOSE_TRAINER_CARD, at(BEDROOM, 6, 6, NORTH), "the Trainer Card SID Helper left open, or HOME"), - options_step(), - }); - checkpoint.live_start = true; - return checkpoint; -} - -StoryCheckpoint leave_house(){ - return row("00.02", "bedroom to Pallet Town", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("front_door", at(PALLET, 6, 8), "down the stairs and out of the house"), - }); -} - -StoryCheckpoint oaks_trigger(){ - return row("00.03", "Oak stops the player and walks them to the lab", at(PALLET, 6, 8, SOUTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_oaks_trigger", at(PALLET, 12, 2, NORTH), "below the north exit, short of Oak's trigger at (12, 1)"), - step_into("oaks_trigger", NORTH, "the trigger: \"Don't go out!\""), - // PlayerEnter walks the player up 8 tiles from the lab's door. - scene("to_the_lab", at(LAB, 6, 4, NORTH), "Oak walks the player into the lab; the scene ends at the table"), - }); -} - -// Starter RNG starts from a save south of the table, facing the ball. -StoryCheckpoint to_starter_ball(){ - StoryCheckpoint checkpoint = row("00.04", "to Squirtle's ball, south of the table", at(LAB, 6, 4, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_squirtle", at(LAB, 9, 5, NORTH), "under Squirtle's ball (9, 4)"), - }); - checkpoint.handoff = StoryHandoff::STARTER_RNG; - return checkpoint; -} - -StoryCheckpoint starter(){ - return row("00.04b", "Squirtle, then the rival's battle", at(LAB, 9, 5, NORTH), {}, StartMenu::BEFORE_POKEDEX, { - talk("squirtle_ball", "\"So, you want the WATER POKEMON SQUIRTLE?\""), - answer("choose_squirtle", true, "take Squirtle"), - answer("no_nickname", false, "\"give a nickname?\" NO"), - scene("rival_takes_bulbasaur", at(LAB, 9, 5, NORTH), "the rival picks his ball; the player still faces the table (console B, 2026-11-01)"), - route("above_rival_trigger", at(LAB, 7, 7, SOUTH), "short of the rival's trigger row 8"), - step_into("rival_trigger", SOUTH, "\"Wait, let's check out our POKEMON!\""), - // The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down. - battle("rival_battle", at(LAB, 7, 8, SOUTH), true, "the tutorial battle; losing goes on too"), - }); -} - -StoryCheckpoint parcel(){ - return row("00.05", "Route 1 to Viridian Mart: Oak's Parcel", at(LAB, 7, 8, SOUTH), {}, StartMenu::BEFORE_POKEDEX, { - route("below_mart_door", at(VIRIDIAN, 36, 20, NORTH), "Route 1, running from wild battles"), - step_into("mart_door", NORTH, "the clerk's scene starts on entering"), - // ApproachCounter: up 4 from the mat, then faces the clerk. - scene("parcel_from_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "the clerk gives OAK'S PARCEL"), - }); -} - -StoryCheckpoint pokedex(){ - return row("00.06", "Oak's Parcel to the Pokedex", at(VIRIDIAN_MART, 4, 3, WEST), {}, StartMenu::FULL, { - route("below_oak", at(LAB, 6, 4, NORTH), "back down Route 1 to Oak"), - talk("give_parcel", "Oak takes the parcel"), - scene("pokedex_scene", at(LAB, 6, 4, SOUTH), "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)"), - }); -} - -StoryCheckpoint shopping(){ - return row("00.07", "Viridian shopping, then into Viridian Forest", at(LAB, 6, 4, SOUTH), {}, StartMenu::FULL, { - route("mart_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "Route 1 again"), - // 2000 of the 3000 a new game starts with, plus the rival's prize. - shop("potions_and_antidotes", {{"potion", 5}, {"antidote", 3}, {"parlyz_heal", 1}}, "5 Potions, 3 Antidotes, 1 Parlyz Heal"), - route("viridian_nurse", at(VIRIDIAN_CENTER, 7, 4, NORTH), "heal before the forest"), - heal("heal_viridian"), - route("below_old_man_trigger", at(VIRIDIAN, 20, 9, NORTH), "short of the tutorial trigger (20, 8)"), - step_into("old_man_trigger", NORTH, "the old man's catching tutorial can't be walked around"), - // TutorialTriggerLeft turns the player right, to the old man. - scene("old_man_tutorial", at(VIRIDIAN, 20, 8, EAST), "about 60 lines and his demo battle; TEACHY TV"), - // After his demo the old man stands east of the player, beside (20, 8), where - // the map doesn't have him: "east 2" from there didn't move, and the walk north - // ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first. - route("past_old_man", at(VIRIDIAN, 20, 5, NORTH), "north along column 20, clear of the old man"), - // The gate's north warp lands on the forest's exit mat (29, 62), facing - // north. The save there keeps a forest failure from going back to Pallet. - route("forest_entrance", at(FOREST, 29, 62, NORTH), "Route 2 and the south gate, running from wild battles"), - }); -} - -StoryCheckpoint forest(){ - // The supplies bought in 00.07. - return row("00.08", "Viridian Forest to Pewter Center", at(FOREST, 29, 62, NORTH), {5, 3, 1}, StartMenu::FULL, { - // Wild battles are fought for EXP. Straight up the east side from the - // entrance, each leg ending on a wall (the Boy at (45, 58) stops the - // east one). Rick (47, 45) sees (42..46, 45), so the last leg meets - // his battle and is held on to its wall after it. The by-hand run's - // detour west to (13, 46) and back is dropped. - legs("forest_east", {{EAST, 1}, {NORTH, 4}, {EAST, 14}, {NORTH, 15}}, "up the east side to (44, 43)", WildBattles::FIGHT), - route("forest_north", at(FOREST, 39, 25), "north part", WildBattles::FIGHT), - // To the gate by legs that end on walls, which the walker holds again - // after a battle instead of estimating where it stopped: planned - // routes with open legs lost the player in the north of the forest - // (console B, 2026-11-01). The two 1-tile legs are single steps. - legs("forest_exit", { - {NORTH, 10}, {WEST, 12}, {SOUTH, 10}, {WEST, 6}, {NORTH, 20}, - {SOUTH, 1}, {WEST, 10}, {SOUTH, 27}, {WEST, 8}, {NORTH, 20}, {EAST, 1}, - }, "walls all the way to the gate's column", WildBattles::FIGHT), - route("forest_gate", at(FOREST_GATE, 7, 10, NORTH), "north onto the exit, arriving on the gate's mat", WildBattles::FIGHT), - // Out of the forest, wild battles are run from; trainers are still fought. - route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "Route 2 north to Pewter's Center"), - heal("heal_pewter"), - }); -} - -StoryCheckpoint brock(){ - // The by-hand save: 2 Potions and 1 Antidote left after the forest. - return row("00.09", "Pewter Gym: Camper Liam, then Brock", at(PEWTER_CENTER, 7, 4, NORTH), {2, 1}, StartMenu::FULL, { - // Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight - // 4) and sees (4..7, 8): walking north up column 6 from the door, - // the step onto (6, 8) starts his battle. He walks up to the player, - // who stays put and keeps facing north (FRLG doesn't turn the player - // to a trainer). That step is taken on its own, so no leg is cut. - route("below_liam_line", at(GYM, 6, 9, NORTH), "in by the door, up column 6 to below Liam's row"), - step_into("liam_line", NORTH, "onto (6, 8), in Liam's line"), - battle("camper_liam", at(GYM, 6, 8, NORTH), false, "Geodude and Sandshrew; EXP before Brock"), - // On to Brock unless red HP or a status is left that no item cures. - ready("ready_for_brock", at(PEWTER_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - route("before_brock", at(GYM, 6, 6, NORTH), "below Brock (6, 5); Liam, beaten, stands at (5, 8)"), - talk("challenge_brock", "Brock's speech"), - battle("brock", at(GYM, 6, 6, NORTH), false, "Geodude and Onix, with Bubble; Boulder Badge and TM39"), - }); -} - -StoryCheckpoint running_shoes(){ - return row("00.10", "Pewter: the Running Shoes from Oak's aide", at(GYM, 6, 6, NORTH), after_brock(), StartMenu::FULL, { - // Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at - // (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The - // Gym guide's triggers at (42..43, 21..23) need the scene at 0. - route("before_aide_trigger", at(PEWTER, 45, 21, EAST), "out of the Gym, east along row 21, short of the top trigger"), - step_into("aide_trigger", EAST, "onto (46, 21), below the aide"), - // RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; - // the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH - // is set (console B, 2026-11-02: about 20 B presses to the overworld). - scene("shoes_from_aide", at(PEWTER, 46, 21, NORTH), "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north"), - // Where the by-hand walk stopped to start 00.11 (console B, 2026-11-02). - route("below_pewter_center", at(PEWTER, 17, 26, SOUTH), "west along row 21 and down to below the Pokemon Center's door (17, 25)"), - }); -} - -// Route 3's trainers (Route3 map.json): the way east meets three of them. -// Bug Catcher Colton (12, 6) faces east, sight 3: the only way north past -// the row 7 ledges is the gap at x 14..15, below his line. Youngster Ben -// (17, 4) faces south, sight 2, so the way east keeps to row 3 past him. -// Bug Catcher Greg (25, 4) faces south, sight 2, over the way east along -// row 5. Bug Catcher James (32, 6) faces east, sight 4, over the way down -// at x 35..36. The others are kept out of: Lass Janice (19, 9) sees west -// along row 9 to x 14, Lass Sally (30, 3) west along row 3 to x 25, and -// Youngster Calvin (29, 10) west along row 10. Each line is stepped into on -// its own, so no leg is cut; the trainer walks up to the player, who stays -// put facing the way they stepped. -StoryCheckpoint route3(){ - return row("00.11", "Pewter Center, then Route 3's trainers", at(PEWTER, 17, 26, SOUTH), after_brock(), StartMenu::FULL, { - running(route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "in by the door below the player")), - heal("heal_pewter"), - // Up from row 9 west of Janice's line, which ends at x 14. - running(route("west_of_janice_line", at(ROUTE3, 13, 8), "out of Pewter by row 21, east into Route 3, short of Janice's line")), - running(legs("below_colton_line", {{EAST, 1}, {NORTH, 1}}, "to (14, 7), in the ledges' gap")), - step_into("colton_line", NORTH, "onto (14, 6), in Colton's line"), - battle("bug_catcher_colton", at(ROUTE3, 14, 6, NORTH), false, "his Bug Pokemon; Colton stops at (13, 6)"), - running(legs("past_ben", {{NORTH, 3}, {EAST, 4}, {SOUTH, 2}, {EAST, 6}}, "up to row 3 above Ben, down at x 18 east of his line, to (24, 5)")), - step_into("greg_line", EAST, "onto (25, 5), below Greg"), - battle("bug_catcher_greg", at(ROUTE3, 25, 5, EAST), false, "his Bug Pokemon; Greg is already next to the player"), - running(legs("above_james_line", {{EAST, 11}}, "along row 5 to the wall at (36, 5)")), - step_into("james_line", SOUTH, "onto (36, 6), at the end of James's line"), - battle("bug_catcher_james", at(ROUTE3, 36, 6, SOUTH), false, "his Bug Pokemon; James stops at (35, 6)"), - // Saved here, the trainers behind, so a failure on the way to Route 4 - // doesn't fight them again. - running(legs("save_spot", {{SOUTH, 2}}, "down to (36, 8), beside the wall east of it")), - }); -} - -// Route 3's north exit (x 68..75) joins Route 4 (offset 60) at x 8..15, up -// which column 12 leads to the Pokemon Center's door (12, 5). Lass Robin -// (40, 11) wanders up and down at x 40, looking north and south, sight 3. -// Rock above (y <= 8) and grass below (y >= 12) leave every way east -// across her column at y 9..11, so whether she sees the player depends on -// her facing. The walk watches for her after the leg along row 9, which -// crosses her sight on (40, 9) only; if she saw the player, her message -// goes to story_interrupts(), which fight her, and the route goes on from -// (40, 9) (run_route(); console B, 2026-11-02, she stopped the player -// there and spoke after the leg's short watch). -StoryCheckpoint magikarp_salesman(){ - StoryCheckpoint checkpoint = row("00.12", "Route 3 and 4 to the Magikarp salesman", at(ROUTE3, 36, 8, SOUTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "east over Route 3, off the grass, north into Route 4 and its Pokemon Center")), - heal("heal_route4"), - // Gift RNG starts from a save facing the salesman (1, 3). - running(route("before_salesman", at(ROUTE4_CENTER, 2, 3, WEST), "beside the Magikarp salesman, facing him")), - }); - checkpoint.handoff = StoryHandoff::GIFT_RNG; - return checkpoint; -} - -// Gift RNG buys the Magikarp (500 of the money 00.12 brings) without -// moving the player and leaves its summary open, or HOME. This saves the -// shiny where 00.12 ended. A run started here with Gift RNG's handoff on -// loads the save beside the salesman and runs Gift RNG first. -StoryCheckpoint after_gift_rng(){ - StoryCheckpoint checkpoint = row("00.12b", "after Gift RNG: save with the Magikarp", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - game_step(LEAVE_GIFT_SUMMARY, at(ROUTE4_CENTER, 2, 3, WEST), "the Magikarp's summary Gift RNG left open, or HOME"), - }); - checkpoint.live_start = true; - return checkpoint; -} - -// The Magikarp goes to BOX 1 at the Center's PC (11, 1), so Mt. Moon is -// fought with the starter alone (console B, 2026-11-02: done by hand and -// saved at (11, 2), facing the PC, where this row ends). The wandering -// boy (4..6, 3..5) is walked around. The Magikarp comes from Gift RNG: -// with Gift RNG off the party is the starter alone, and the deposit is -// skipped. -StoryCheckpoint magikarp_to_box(){ - return row("00.12c", "Route 4 Center: the Magikarp into BOX 1", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - running(route("pc_front", at(ROUTE4_CENTER, 11, 2, NORTH), "below the PC (11, 1), facing it")), - pc_step("magikarp_to_box", "DEPOSIT the party's second slot into BOX 1, if it has one", PcTransfer{ - .action = PcAction::DEPOSIT, .party_slot = 1, .box = 0, .if_missing = PcMissing::SKIP, - }), - }); -} - -// Mt. Moon (pokefirered data/maps/MtMoon_1F, _B1F, _B2F). Every floor tile -// of the cave has wild encounters, which are run from, so its legs end on -// walls, ladders or someone standing still, which the walker holds again -// after a battle; the few open ones are short. The way through: up 1F's -// middle and west side, its north-west ladder, B1F's west ladder down to -// B2F's south-east, round B2F's south edge to its west, north past -// Miguel and the fossils, and the ladder up to B1F's east end, which -// leads out to Route 4 east of the mountain. -// - 1F's trainers are walked around: Youngster Josh (13, 17) sees east -// along row 17 to x 17, so the way west into the west room is down -// column 18 and up column 11; Lass Miriam walks round (32..33, 4..5), -// sight 2, so the way east keeps to row 9 and columns 38 and 40; Hiker -// Marcos wanders (5..9, 8..12) and sees one tile, so the way north is -// column 11 and row 3. -// - The Moon Stone ball (3, 2) on 1F (FLAG_HIDE_MT_MOON_1F_MOON_STONE) is -// a few tiles off the way to the ladder (5, 6). -// - The Grunt at (37, 21) on B2F looks around (sight 3) over the only way -// east round B2F. His room is crossed on legs to walls, at one tile of -// his sight each, (37, 22) and (40, 21); if he looks the player's way, -// he walks up beside the leg, story_interrupts() fights him, and the -// leg is held on to its wall. -// - The Grunt at (12, 20) faces south (sight 2) over (12, 21..22), across -// rows 21..22, the only way north to Miguel: stepped into from the -// west, he is next to the player and doesn't walk. -// - Super Nerd Miguel (13, 11) battles on the step onto (14, 11) -// (MtMoon_B2F_EventScript_MiguelTrigger, VAR_MAP_SCENE_MT_MOON_B2F 0), -// then "We'll each take one!" -// - The fossils: DOME (13, 7), HELIX (14, 7). After the HELIX, Miguel -// walks up to (13, 8) and takes the DOME, which opens the gap north. -// The save is on Route 4: the save card's places don't include Mt. Moon. -StoryCheckpoint mt_moon(){ - return row("00.13", "Mt. Moon: a Moon Stone, a Rocket, Miguel and the Helix Fossil", at(ROUTE4_CENTER, 11, 2, NORTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "the nurse, below the counter")), - heal("heal_route4"), - running(route("mt_moon_entrance", at(MT_MOON_1F, 18, 37, NORTH), "out of the Center, west into Mt. Moon")), - running(legs("mt_moon_1f", { - {NORTH, 12}, {EAST, 8}, {NORTH, 12}, {EAST, 3}, {SOUTH, 1}, {EAST, 9}, - {NORTH, 1}, {EAST, 2}, {NORTH, 4}, {WEST, 24}, {EAST, 2}, {SOUTH, 12}, - {WEST, 7}, {NORTH, 18}, {WEST, 9}, {EAST, 1}, - }, "up the middle, east of Miriam, west along row 9, down column 18 past Josh, up column 11 past Marcos, to (3, 3)")), - running(route("below_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "facing the Moon Stone (3, 2)")), - talk("moon_stone_ball", "A on the item ball"), - // No reader for the text yet: the scene's end is the overworld. - scene("found_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "\" found a MOON STONE!\", then the pocket line; the ball is gone"), - running(route("b2f_ladder_foot", at(MT_MOON_B2F, 26, 21, EAST), "1F's ladder (5, 6), down B1F's west side to its ladder (22, 18), onto B2F")), - running(legs("b2f_south", { - {NORTH, 4}, {EAST, 8}, {WEST, 2}, {SOUTH, 5}, {EAST, 8}, {NORTH, 3}, {WEST, 1}, {NORTH, 5}, - {EAST, 7}, {SOUTH, 14}, {WEST, 9}, {SOUTH, 10}, {WEST, 29}, {EAST, 3}, {NORTH, 17}, - }, "through the Grunt's room at (37, 21), round the south edge, up column 11 to (11, 21)")), - step_into("grunt_line", EAST, "onto (12, 21), below the Grunt at (12, 20)"), - battle("rocket_grunt", at(MT_MOON_B2F, 12, 21, EAST), false, "Rattata and Zubat, Lv13"), - ready("ready_for_miguel", at(ROUTE4_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse, back through the cave, only if they can't"), - // Up column 13 to Miguel, who stops the leg on (13, 12), then east - // to the wall: the tile below his trigger. - running(legs("below_miguel_trigger", {{EAST, 1}, {NORTH, 9}, {EAST, 1}}, "to (14, 12), below Miguel's trigger (14, 11)")), - step_into("miguel_trigger", NORTH, "onto (14, 11), beside Miguel"), - battle("super_nerd_miguel", at(MT_MOON_B2F, 14, 11, NORTH), false, "Grimer, Voltorb and Koffing, Lv12; \"We'll each take one!\""), - running(legs("below_helix_fossil", {{NORTH, 3}}, "up column 14 to the HELIX FOSSIL (14, 7)")), - fossil_step("helix_fossil", "the HELIX FOSSIL; Miguel takes the DOME FOSSIL", Fossil::HELIX), - // The maps keep the fossils, which the game removes after the - // choice: the step onto the HELIX's tile is taken on its own. - step_into("helix_gap", NORTH, "onto (14, 7), where the HELIX FOSSIL lay"), - running(route("route4_east", at(ROUTE4, 32, 6, SOUTH), "west to B2F's ladder (5, 10), up to B1F, east to its exit onto Route 4")), - }); -} - - -// Route 4 east of Mt. Moon (Route4 map.json) joins Cerulean City at its -// east end (x 107; Route 4's row 3 is the city's row 13). Its upper road -// (rows 2..8) reaches the city only by water: the way on by land is down -// the ledge row 9 at x 90..96 to the lower road (rows 10..12), which -// joins the city's rows 20..22. Lass Crissy (75, 3) faces east, sight 4, -// over row 3 from x 76 to 79; the way east keeps out of her line and off -// the grass south of the road (75..87, 11..17). -// -// On the way, the Mega Kick tutor (Black Belt (50, 3), facing west, -// Route4_EventScript_MegaKickTutor) stands in a pen (46..51, 2..4) north -// of the road, beside the Mega Punch tutor (47, 3); the pen opens south -// only on (48, 5) and (49, 5), the rest of row 5 ledges out of it. From -// Mt. Moon's exit the walk goes east and up into the pen to (50, 4), -// below the tutor, and Mega Kick takes Withdraw's slot. Cerulean can't -// be walked back to Route 4's upper road without Surf, so it is now or -// much later. -// -// The open leg east across the city's edge ended a tile short on the -// console (2026-11-03: on (6, 20), not (7, 20)), and no hold to a wall -// in the city's west end finds the player from there: the next hold -// south met the fence on (6, 23) and the walk went on a column off. So -// the entry ends on (9, 20), and only legs to walls follow: north up -// column 9 (or 8, a tile short) to row 12, west to (8, 12), east to -// (30, 12) beside the policeman (31, 12), south to (30, 17), west to -// (25, 17), and down the ledge row 18 to (25, 19), a few tiles from the -// door (22, 19). The way keeps out of the boy's (16, 18..24) and the -// balding man's (8..10, 22..24) wander boxes. -StoryCheckpoint route4_to_cerulean(){ - const TeachPlan mega_kick{.item = std::string(TEACH_TUTOR), .move = "mega-kick", .member = 0, .forget_move = "withdraw"}; - return row("00.14", "Route 4: Mega Kick from its tutor, then east to Cerulean's Pokemon Center", at(ROUTE4, 32, 6, SOUTH), after_brock(), StartMenu::FULL, { - running(route("mega_kick_tutor", at(ROUTE4, 50, 4, NORTH), "east and up through (48, 5) into the tutors' pen, below the Mega Kick tutor (50, 3)")), - teach_step("teach_mega_kick", "the tutor's Mega Kick in place of Withdraw, unless the lead knows it", mega_kick), - running(route("above_ledge", at(ROUTE4, 93, 8, SOUTH), "east along Route 4's upper road to above the ledge row 9")), - hop("ledge_hop", SOUTH, at(ROUTE4, 93, 10, SOUTH), "down the ledge (93, 9) to the lower road"), - running(route("cerulean_entry", at(CERULEAN, 9, 20, EAST), "east into Cerulean City, to (9, 20) below column 9")), - running(legs("above_city_ledge", {{NORTH, 8}, {WEST, 1}, {EAST, 22}, {SOUTH, 5}, {WEST, 5}}, "to walls: (9, 12), (8, 12), (30, 12), (30, 17), (25, 17)")), - hop("city_ledge_hop", SOUTH, at(CERULEAN, 25, 19, SOUTH), "down the ledge (25, 18)"), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "west along row 20 to the Pokemon Center's door (22, 19)")), - heal("heal_cerulean"), - }); -} - -// Cerulean Gym (pokefirered CeruleanCity_Gym map.json and scripts.inc): -// a pool with walkways. Misty (8, 6) stands on a platform (7..9, 6) above -// row 7. Picnicker Diana (4, 7) faces east, sight 4, over (5..8, 7), so -// misty_front (8, 7) is in her line; Swimmer Luis (10, 12) in the water -// faces west, sight 1, over (9, 12), on column 9 north of the door. No -// gym trainer has to be fought for Misty, so neither is: from the door up -// column 9 to row 13 (a route there, so the planner's walk to a wall -// doesn't run on past it through (9, 12)), west to (4, 13), and to walls -// round the pool's west and north sides, (4, 10), (12, 10), (12, 7), then -// west to (9, 7), the tile below the platform's east end, out of Diana's -// line. 00.14c steps up onto (9, 6) and talks to Misty from beside her. -// -// Misty beat a Lv20 Wartortle (console B, run m51), so first a GRIND to -// Lv23 on 00.15's patch. Gen 3 numbers (pokefirered: her mons have IV 0; -// Wartortle taken at IV 15, no EVs): Starmie Lv21 has 56 HP, Atk 36, SpA -// 47, SpD 40. Bite is Dark, special in Gen 3, no STAB, x2 on Psychic: at -// Lv23 (SpA 39) it does 23..28, three hits (two on top rolls); at Lv20, -// 20..24. Her Swift (physical, 60) does 9..11 to a Lv23 Wartortle (about -// 67 HP, Def 45) and Water Pulse (STAB, resisted) 8..10: 6 or more hits, -// though m51 saw about 20 a turn. Her Recover (28) and Super Potion undo -// a Bite, so the margin is in Bite's damage. -// -// The Mart comes before the GRIND: its wild battles are fought only with -// 2 or more Potions, and 00.14's save has none (m51 met Misty with only -// the 5 this row bought). 5 Potions (row 3, 300 each), then up to 3 Super -// Potions (row 2, 700), last so they take the Items pocket's last row; -// the battle doesn't use them yet. The money box can't be read, so the -// floor stands for it, and a floor above the money fails the step (the -// quantity box wraps). Prizes (pokefirered: 4 x last level x the class's -// factor) from a new game's 3000, less Viridian's 2000 and the Magikarp's -// 500: Liam 220, Brock 1400, Route 3's bug catchers 360, the Mt. Moon -// grunt 416 and Miguel 288 (the first rival's 80 only if won), at least -// 3184 here. Floor and budget 3000: 5 Potions and 2 Super Potions, 2900. -// Misty's 2100 (4 x 21 x 25) then leaves 00.15 its floor of 1500. Then the -// nurse, and the save before Misty, so her battle is its own checkpoint, -// 00.14c, verified and retried from it. 00.15's GRIND then fights -// until the sim beats the Cerulean rival often enough. -StoryCheckpoint cerulean_gym(){ - const MartPlan supplies{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "potion", .quantity = 5}, {.item = "super-potion", .quantity = 3}}, - .budget = 3000, - .money_floor = 3000, - }; - const GrindPlan to_lv23{.member = 0, .level = 23, .max_encounters = 100, .pace = WEST, .heal_every = 0}; - return row("00.14b", "Cerulean: Potions, a GRIND to Lv23, then into the Gym, saved below Misty's platform", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_potions", "5 Potions for the GRIND's wild battles, then Super Potions as the money allows", supplies), - running(route("grind_patch", at(ROUTE4, 86, 16, WEST), "west out of the city along Route 4's lower road onto its grass's east edge")), - grind_step("grind_to_lv23", "wild battles until the lead is Lv23, where Bite takes Starmie in three", to_lv23, at(CERULEAN_CENTER, 7, 4, NORTH)), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center: Misty's battle starts at full HP and PP")), - heal("heal_cerulean"), - running(route("gym_below_luis", at(CERULEAN_GYM, 9, 13), "into the Gym, up column 9 to row 13, short of Luis's (9, 12)")), - running(legs("gym_west_walkway", {{WEST, 5}}, "west to the wall (4, 13)")), - running(legs("below_misty_platform", {{NORTH, 3}, {EAST, 8}, {NORTH, 3}, {WEST, 3}}, "walls (4, 10), (12, 10), (12, 7), then to (9, 7), out of Diana's line")), - }); -} - -// Misty (TRAINER_LEADER_MISTY: Staryu Lv18, Starmie Lv21), talked to from -// (9, 6), beside her on the platform. Her win text runs on to the CASCADE -// BADGE, TM03 (Water Pulse) and its explanation, all read with the -// battle's. Bite is chosen against her party (Starmie is Water/Psychic). -// Back to the nurse round the pool's west side, out of Luis's line; then -// Water Pulse in place of Tail Whip, last, at the Center, from the bag's -// TM CASE. Ends where 00.15 starts. -StoryCheckpoint misty(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - return row("00.14c", "Cerulean Gym: Misty, then Water Pulse", at(CERULEAN_GYM, 9, 7, WEST), after_brock(), StartMenu::FULL, { - running(route("beside_misty", at(CERULEAN_GYM, 9, 6, WEST), "up onto (9, 6), facing Misty (8, 6)")), - talk("challenge_misty", "Misty's speech"), - battle("misty", at(CERULEAN_GYM, 9, 6, WEST), false, "Staryu and Starmie, with Bite; CASCADE BADGE and TM03"), - running(legs("gym_way_out", {{SOUTH, 1}, {EAST, 3}, {SOUTH, 3}, {WEST, 8}, {SOUTH, 3}, {EAST, 5}}, "walls (12, 7), (12, 10), (4, 10), (4, 13), (9, 13), round Luis's (9, 12)")), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "down column 9 out of the Gym, to the Center")), - heal("heal_cerulean"), - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip", water_pulse), - }); -} - -// Before the rival north of Cerulean (cerulean_rival()), from the -// Center: first TM03 Water Pulse over Tail Whip, if the lead doesn't know -// it yet, so the GRIND's sim plays it (a run without TM03 from Misty -// skips the step). Then 3 Potions at the Mart -// (CeruleanCity_Mart_Items: POTION is row 3, 300 each; Mt. Moon's -// trainers leave well over the floor) and 2 Awakenings (row 6, 250 each; -// pokefirered items.json) for the rival's Bulbasaur's Sleep Powder -// (console B, m56: asleep at 34/65 HP, it fainted two turns later with -// 15 Potions), 1400 of the floor's 1500. Then a GRIND on Route 4's grass -// east of Mt. Moon (75..86, 11..17; Spearow, Rattata, Ekans and Mankey -// around Lv10, about 80 EXP each), healing at the Center, until the -// battle sim beats the rival 00.15b fights 50% or more: the win chance -// his battle refuses below. Console B's Wartortle (Lv22, 65 HP, Water -// Pulse) is about 42% there and 62% at Lv23; Lv28 (about 88%, some 120 -// battles from Lv22) is the cap. Then the nurse, and the save on (23, 7), -// the tile below his trigger: his battle is its own checkpoint, 00.15b, -// verified and retried from this save. -StoryCheckpoint cerulean_grind(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - const MartPlan potions{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "potion", .quantity = 3}, {.item = "awakening", .quantity = 2}}, - .budget = 1500, - .money_floor = 1500, - }; - const GrindPlan for_rival{ - .member = 0, .level = 28, .max_encounters = 150, .pace = WEST, .heal_every = 0, - .trainer = std::string(story_trainer(CERULEAN, "rival_cerulean").value_or("")), .min_chance = MIN_WIN_CHANCE, - }; - return row("00.15", "Cerulean: Water Pulse, Potions, a GRIND until the rival is winnable, then saved below his trigger", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip, unless the lead knows it or there is no TM03", water_pulse), - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_potions", "3 Potions: the GRIND fights wild battles only with 2 or more; 2 Awakenings for the rival's Sleep Powder", potions), - running(route("grind_patch", at(ROUTE4, 86, 16, WEST), "west out of the city along Route 4's lower road onto its grass's east edge")), - grind_step("grind_for_rival", "wild battles until the sim beats the rival 50% or more, Lv28 at most; the nurse when hurt or low on PP", for_rival, at(CERULEAN_CENTER, 7, 4, NORTH)), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center: the rival's battle starts at full HP and PP")), - heal("heal_cerulean"), - running(route("below_rival_trigger", at(CERULEAN, 23, 7, NORTH), "out of the Center, north up to (23, 7), short of the trigger row 6")), - }); -} - -// The rival north of Cerulean (CeruleanCity scripts.inc): the only way -// north to Nugget Bridge is columns 22..24, and a step onto row 6 there -// (CeruleanCity_EventScript_RivalTrigger*, VAR_MAP_SCENE_CERULEAN_CITY_RIVAL -// 0) brings him down to the player. From the middle, (23, 6), he stops -// at (23, 5); after the battle he walks round the player and off south, -// and the player, turning to watch him, ends facing south. His FAME -// CHECKER's text is read to the overworld with the battle's. For a player -// who took Squirtle he has Pidgeotto Lv17, Abra Lv16, Rattata Lv15 and -// Bulbasaur Lv18 (sParty_RivalCeruleanBulbasaur), whose Vine Whip and -// Sleep Powder are the danger. The row starts from 00.15's save below the -// trigger, and saves after him. First TM03 Water Pulse over Tail Whip (from -// the bag, where the player stands), if the lead doesn't know it yet: -// console B's save (2026-11-03) is past Misty's TEACH, which failed there. -// Where she taught it, the step reads the moves and does nothing. -StoryCheckpoint cerulean_rival(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - return row("00.15b", "Cerulean: Water Pulse if not known, then the rival north of the city", at(CERULEAN, 23, 7, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip, unless the lead knows it", water_pulse), - step_into("rival_trigger", NORTH, "onto (23, 6), the middle trigger: \"Yo! !\""), - battle("rival_cerulean", at(CERULEAN, 23, 6, SOUTH), false, "Pidgeotto, Abra, Rattata and Bulbasaur; then the FAME CHECKER"), - }); -} - -// Nugget Bridge (Route24 map.json) is x 10..12 from row 32 north to row -// 16, the city's columns 22..24 (offset 12). Its five trainers stand on -// it facing across, sight 2, so each line crosses the middle column 11 -// on the trainer's row: Bug Catcher Cale (12, 31), Lass Ali (10, 28), -// Youngster Timmy (12, 25), Lass Reli (10, 22) and Camper Ethan (12, 19). -// Each is fought on the step onto their row, beside them: they don't -// walk, and the player keeps facing north. Two tiles separate the rows, -// walked as one short leg; the step onto a row goes on a tile at a time -// until the trainer sees the player (into_line()), as the open leg onto -// the bridge ended a tile short twice on console B (2026-11-03), on -// (11, 33), and one step left the player out of Cale's sight. Then the -// Rocket (12, 15): the step onto (11, 15) -// (Route24_EventScript_RocketTriggerRight, VAR_MAP_SCENE_ROUTE24 0) gives -// the NUGGET, "join Team Rocket", and his battle; he only turns, and the -// player turns east to him. Camper Shane (5, 21) looks north from the -// west bank, off the way. -StoryCheckpoint nugget_bridge(){ - return row("00.16", "Nugget Bridge: the nurse, five trainers and the Rocket", at(CERULEAN, 23, 6, SOUTH), after_brock(), StartMenu::FULL, { - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center after the rival, before Nugget Bridge")), - heal("heal_cerulean"), - running(route("below_cale_line", at(ROUTE24, 11, 32, NORTH), "out of the Center, north past the rival's row onto the bridge, below Cale's row")), - into_line("cale_line", NORTH, "onto (11, 31), beside Cale"), - battle("bug_catcher_cale", at(ROUTE24, 11, 31, NORTH), false, "his Bug Pokemon"), - running(legs("below_ali_line", {{NORTH, 2}}, "up to (11, 29)")), - into_line("ali_line", NORTH, "onto (11, 28), beside Ali"), - battle("lass_ali", at(ROUTE24, 11, 28, NORTH), false, "her Pokemon"), - running(legs("below_timmy_line", {{NORTH, 2}}, "up to (11, 26)")), - into_line("timmy_line", NORTH, "onto (11, 25), beside Timmy"), - battle("youngster_timmy", at(ROUTE24, 11, 25, NORTH), false, "his Pokemon"), - running(legs("below_reli_line", {{NORTH, 2}}, "up to (11, 23)")), - into_line("reli_line", NORTH, "onto (11, 22), beside Reli"), - battle("lass_reli", at(ROUTE24, 11, 22, NORTH), false, "her Pokemon"), - running(legs("below_ethan_line", {{NORTH, 2}}, "up to (11, 20)")), - into_line("ethan_line", NORTH, "onto (11, 19), beside Ethan"), - battle("camper_ethan", at(ROUTE24, 11, 19, NORTH), false, "his Pokemon"), - // A route, not legs: the nurse may have been needed. - ready("ready_for_rocket", at(CERULEAN_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - running(route("below_rocket_trigger", at(ROUTE24, 11, 16, NORTH), "up the bridge to below the Rocket's trigger (11, 15)")), - step_into("rocket_trigger", NORTH, "onto (11, 15), beside the Rocket"), - battle("rocket_grunt", at(ROUTE24, 11, 15, EAST), false, "the NUGGET, then Ekans and Zubat, Lv15"), - }); -} - -// Route 24 north of Nugget Bridge (Route24 map.json) joins Route 25 by -// its rows 7..9; the ledges on Route 25's row 6 (x 0..9) leave the way -// north at x 12..13. Route 25 (Route25 map.json, scripts.inc) to Bill's -// Sea Cottage door (51, 4): of its nine trainers, four can't be walked -// around. -// - Hiker Franklin (11, 4) faces east, sight 4, over (12..15, 4), and -// Hiker Wayne (17, 7) east over (18..19, 7): the only ways east past -// x 15. Franklin is fought, from (15, 5) on the step onto (15, 4), the -// end of his line: he walks up to (14, 4). -// - Youngster Joey (18, 2) faces south over (18, 3..4): the way keeps -// off column 18, south round Wayne to (19, 6) and up to (19, 4). -// - Youngster Dan (22, 4) looks around, sight 2, over the only way east, -// (20..21, 4). On (20, 4), a one-tile leg, he may see the player and -// walk up to (21, 4); so the way goes north from there to row 2, east, -// and down column 23 past him to (23, 5), off every tile he may walk -// up to. Where his sight is crossed, the leg ends on a wall or is one -// tile; if he looks the player's way, story_interrupts() fight him. -// - Picnicker Kelsey (22, 8) faces east over (23..24, 8), across the -// only way on: fought on the step onto (24, 8); she walks up to (23, 8). -// - Hiker Nob (27, 9) faces north over (27, 6..8), Camper Flint (28, 4) -// south over (28, 5..7): every way east crosses one. Nob is fought on -// the step onto (27, 8), beside him; the way on keeps off Flint's -// column, by one-tile legs and legs to walls. -// - Youngster Chad (36, 4) walks up and down column 36 (rows 2..7), so -// he may see any tile of it down to row 9. The way crosses his column -// on row 9, a leg to the water at (42, 9), where he can only walk up -// beside it. -// - Lass Haley (42, 5) faces south over (42, 6..8), the only way east of -// x 42: fought on the step onto (42, 8); she walks up to (42, 7). -// The row saves inside the Sea Cottage, which the save card names -// ROUTE 25. -StoryCheckpoint route25(){ - return row("00.17", "Route 24 and 25 to Bill's Sea Cottage: Franklin, Kelsey, Nob and Haley", at(ROUTE24, 11, 15, EAST), after_brock(), StartMenu::FULL, { - running(route("below_franklin_line", at(ROUTE25, 15, 5, NORTH), "north off Nugget Bridge, east into Route 25, round its ledges to (15, 5), below the end of Franklin's line")), - into_line("franklin_line", NORTH, "onto (15, 4), at the end of Franklin's line"), - battle("hiker_franklin", at(ROUTE25, 15, 4, NORTH), false, "Machop and Geodude, Lv15; Franklin stops at (14, 4)"), - running(legs("west_of_dan", {{EAST, 2}, {SOUTH, 2}, {EAST, 2}, {NORTH, 2}}, "to (17, 4), short of Joey's (18, 4); round Wayne (17, 7) to (19, 6); up to (19, 4)")), - running(legs("round_dan", { - {EAST, 1}, {NORTH, 2}, {EAST, 4}, {WEST, 1}, {SOUTH, 3}, {EAST, 1}, {SOUTH, 2}, - }, "onto (20, 4); up to (20, 2), east to (24, 2), down column 23 past Dan to (23, 5), to (24, 7) above Kelsey's line")), - into_line("kelsey_line", SOUTH, "onto (24, 8), at the end of Kelsey's line"), - battle("picnicker_kelsey", at(ROUTE25, 24, 8, SOUTH), false, "Nidoran M and Nidoran F, Lv15; Kelsey stops at (23, 8)"), - running(legs("west_of_nob_line", {{EAST, 2}}, "along row 8 to (26, 8)")), - into_line("nob_line", EAST, "onto (27, 8), above Nob"), - battle("hiker_nob", at(ROUTE25, 27, 8, EAST), false, "three Geodude and a Machop, Lv13"), - running(legs("below_haley_line", { - {EAST, 1}, {SOUTH, 1}, {EAST, 1}, {NORTH, 3}, {EAST, 5}, {SOUTH, 3}, {EAST, 8}, - }, "below Flint's column to (29, 9), up to (29, 6), east to (34, 6), down to (34, 9), east along row 9 past Chad's column to the water, (42, 9)")), - into_line("haley_line", NORTH, "onto (42, 8), at the end of Haley's line"), - battle("lass_haley", at(ROUTE25, 42, 8, NORTH), false, "Oddish, Pidgey and Oddish, Lv13; Haley stops at (42, 7)"), - running(route("sea_cottage", at(SEA_COTTAGE, 7, 8, NORTH), "east along row 8, up column 51 into the Sea Cottage (51, 4), a step in from its mat")), - }); -} - -// Bill's Sea Cottage (Route25_SeaCottage scripts.inc). Bill is the -// Clefairy at (10, 6) (FLAG_HELPED_BILL_IN_SEA_COTTAGE unset): talked to -// from (10, 7), below him, he asks "Help me out!" (YES/NO; NO goes on the -// same), says to run the Cell Separation on the PC, and walks up into -// the right teleporter (10, 3); with the player facing north he walks -// straight up. The PC (4, 5) answers only from the south, (4, 6). Its -// scene: the teleporters run, Bill comes out of the left one (3, 3) and -// walks to (7, 6) (BillWalkToMiddleOfRoom); the player isn't moved. -// Talked to from (6, 6), Bill gives the S.S. TICKET, no YES/NO, and goes -// on about the S.S. ANNE (FLAG_GOT_SS_TICKET, which also hides Nugget -// Bridge's Rocket). Out by the mat (7, 9); the door puts the player on -// (51, 5), facing south. The maps keep Bill at (7, 5), but after his -// scene he stands on (7, 6), in the way from (6, 6) to the mat (console -// B, 2026-11-03), so the walk out goes around him to (7, 8) first. -StoryCheckpoint bill(){ - return row("00.18", "Bill's Sea Cottage: the Cell Separator and the S.S. Ticket", at(SEA_COTTAGE, 7, 8, NORTH), after_brock(), StartMenu::FULL, { - running(route("below_bill_clefairy", at(SEA_COTTAGE, 10, 7, NORTH), "below the Clefairy (10, 6), facing it")), - talk("bill_clefairy", "\"Hiya! I'm a POKEMON... ...No I'm not!\" ... \"Help me out!\""), - answer("help_bill", true, "YES: \"run the Cell Separation on the PC\""), - scene("bill_into_teleporter", at(SEA_COTTAGE, 10, 7, NORTH), "the Clefairy walks up into the right teleporter"), - running(route("pc_front", at(SEA_COTTAGE, 4, 6, NORTH), "below the PC (4, 5), facing it")), - talk("cell_separator", "the PC: \" initiated the TELEPORTER's CELL SEPARATOR!\""), - scene("bill_comes_out", at(SEA_COTTAGE, 4, 6, NORTH), "the teleporters run; Bill comes out of the left one and walks to (7, 6)"), - running(legs("beside_bill", {{EAST, 2}}, "to (6, 6), west of Bill, facing him")), - talk("thank_bill", "\"Thanks, bud! ... take this\""), - scene("ss_ticket", at(SEA_COTTAGE, 6, 6, EAST), "the S.S. TICKET; \"... the S.S. ANNE ... go instead\""), - running(legs("around_bill", {{SOUTH, 2}, {EAST, 1}}, "to (7, 8), above the mat; Bill stands on (7, 6) after his scene")), - running(route("out_of_cottage", at(ROUTE25, 51, 5, SOUTH), "down to the mat and out; the door puts the player below it")), - }); -} - -// Back to Cerulean by Route 25's south path (Route25 map.json): from -// below the cottage down column 51 to row 12, west along row 12 and row -// 11 into Route 24 (x 14..23, row 11), and down its column 14..16 east -// of Nugget Bridge to Cerulean's north edge (x 26..28, offset 12). No -// trainer stands on it. Cerulean's row 1 there is a ledge (26..28, 1), -// hopped south from (27, 0); then on into the city to the Pokemon Center. -StoryCheckpoint back_to_cerulean(){ - return row("00.19", "Route 25's south path back to Cerulean's Pokemon Center", at(ROUTE25, 51, 5, SOUTH), after_brock(), StartMenu::FULL, { - running(route("above_cerulean_ledge", at(CERULEAN, 27, 0, SOUTH), "Route 25's south path west, Route 24 east of the bridge south, to above Cerulean's ledge (27, 1)")), - hop("cerulean_ledge_hop", SOUTH, at(CERULEAN, 27, 2, SOUTH), "down the ledge (27, 1)"), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "into the city to the Pokemon Center")), - heal("heal_cerulean"), - }); -} - -// Stopgap for console B's save, which caught nothing on Route 1. A new -// playthrough should instead catch a Rattata on Route 1 or 22 early, as -// its Cut user and spare member, and drop this row (and its walk over -// Nugget Bridge and back). -// -// An Oddish for HM01 Cut, and a second member behind the lead -// (docs/design/AutoStory-FRLG-FutureEvents.md, "Console B run choices"). -// Route 24's grass (Route24 map.json: x 3..5, rows 19..31, west of Nugget -// Bridge) is the nearest to the Center with Oddish: FireRed's -// sRoute24_FireRed (pokefirered wild_encounters.json) has it in 25% of -// battles, Lv12..14, as Route 25's grass; Routes 5 and 6 aren't on the -// story's maps yet. Up the bridge, whose trainers 00.16 beat, west along -// rows 10..15 to the cliff (3, 15) and down column 3 to the grass's first -// row, (3, 19); the step paces east to (4, 19) and back. Camper Shane -// (5, 21) faces north, sight 5, over (5, 16..20): column 5 is kept off. -// The leg west ends on the cliff, not open: on console B (m63) an open -// leg west to (4, 15) ended a tile short, and the walk down column 5 -// came into Shane's sight. -// -// First 7 Poke Balls at the Mart (row 1, 200 each; the bag isn't read, so -// the step buys them whatever the bag holds). The floor, from 00.15's -// 1500 less its 1400: the rival's 288 (4 x 18 x 4), the Rocket's 480 (4 -// x 15 x 8), Franklin's 540 and Nob's 468 (hikers, 9) alone make 1876 -// (pokefirered gTrainerMoneyTable). An Oddish at full HP (catch rate 255) -// stays in a Poke Ball about 1 time in 3 (Gen 3: a = 85, four shakes of -// 0.76), so 7 balls catch it about 94% of the time; the step throws 7 at -// most, in 30 battles (none an Oddish: 0.02%). Nothing weakens it: the HP -// bar isn't read on the console yet. -// -// The Oddish joins the party second. Battles keep the lead in -// (PokemonFRLG_AutoStoryBattleDecisions.h): the Oddish is sent only when -// the lead faints in a trainer's battle, which counts as lost. Back to -// the nurse, and the save in the Center. -StoryCheckpoint oddish(){ - const MartPlan balls{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "poke-ball", .quantity = 7}}, - .budget = 1400, - .money_floor = 1500, - }; - const CapturePlan catch_oddish{.species = "oddish", .catches = 1, .max_encounters = 30, .max_balls = 7, .pace = EAST}; - return row("00.20", "Route 24's grass: an Oddish for Cut, then the Center", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_poke_balls", "7 Poke Balls for the Oddish", balls), - running(route("oddish_patch", at(ROUTE24, 3, 19), "north over Nugget Bridge, west to the cliff and down column 3 onto the grass's first row, out of Shane's column 5")), - capture_step("catch_oddish", "wild battles until an Oddish, then Poke Balls; any other species is run from", catch_oddish), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back over the bridge to the Center")), - heal("heal_cerulean"), - }); -} - - -std::vector cpp_rows(){ - return { - new_game(), after_sid_helper(), leave_house(), oaks_trigger(), to_starter_ball(), starter(), parcel(), pokedex(), shopping(), forest(), brock(), - running_shoes(), route3(), magikarp_salesman(), after_gift_rng(), magikarp_to_box(), mt_moon(), - route4_to_cerulean(), cerulean_gym(), misty(), cerulean_grind(), cerulean_rival(), nugget_bridge(), - route25(), bill(), back_to_cerulean(), oddish(), - }; -} - -// Why `loaded` differs from `row`, or empty. Steps compare as their -// shared JSON, which writes every field. -std::string checkpoint_difference(const StoryCheckpoint& row, const StoryCheckpoint& loaded){ - const std::string row_json = Pokemon::story_checkpoint_json(row).dump(); - const std::string loaded_json = Pokemon::story_checkpoint_json(loaded).dump(); - if (row_json != loaded_json){ - return std::format("{}: the file loads to\n{}\nbut the C++ row is\n{}", row.id, loaded_json, row_json); - } - if (row.handoff != loaded.handoff || row.live_start != loaded.live_start){ - return row.id + ": a different handoff or live start."; - } - for (size_t c = 0; c < row.steps.size() && c < loaded.steps.size(); c++){ - if (row.steps[c].once_per_save != loaded.steps[c].once_per_save){ - return row.id + "/" + row.steps[c].name + ": a different once_per_save."; - } - } - if (row.menu != loaded.menu){ - return row.id + ": a different START menu."; - } - const Supplies& a = row.supplies; - const Supplies& b = loaded.supplies; - if (a.potions != b.potions || a.antidotes != b.antidotes || a.parlyz_heals != b.parlyz_heals){ - return row.id + ": different supplies."; - } - if (a.lead.species != b.lead.species || a.lead.level != b.lead.level || a.lead.moves.size() != b.lead.moves.size()){ - return row.id + ": a different lead."; - } - for (size_t c = 0; c < a.lead.moves.size(); c++){ - if (a.lead.moves[c].move != b.lead.moves[c].move || a.lead.moves[c].pp != b.lead.moves[c].pp){ - return row.id + ": a different lead move " + std::to_string(c + 1) + "."; - } - } - return ""; -} - -class Test_AutoStoryTableParity : public UnitTest{ -public: - Test_AutoStoryTableParity() - : UnitTest("PokemonFRLG::AutoStory - the story files load to the C++ rows") - {} - virtual UnitTestResult run(Logger&, CancellableScope&) const override{ - try{ - const std::vector rows = cpp_rows(); - const std::vector& loaded = story_checkpoints(); - if (rows.size() != loaded.size()){ - return std::format("{} C++ rows, {} files.", rows.size(), loaded.size()); - } - for (size_t c = 0; c < rows.size(); c++){ - const std::string difference = checkpoint_difference(rows[c], loaded[c]); - if (!difference.empty()){ - return difference; - } - } - return true; - }catch (Exception& e){ - return std::string(e.name()) + ": " + e.message(); - } - } -}; - -} // namespace - - -void add_tests_AutoStoryTableParity(UnitTestDatabase& database){ - database.add(); -} - - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp index cd7aa88f1d..8cafb29f3d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -979,7 +979,6 @@ const AutoStoryTestCase AUTO_STORY_CASES[] = { void add_tests_AutoStory(UnitTestDatabase& database){ add_tests_AutoStoryRunPlan(database); - add_tests_AutoStoryTableParity(database); for (const auto& scenario : AUTO_STORY_CASES){ database.add(scenario); } diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 0cb003ef24..107f9bf6d4 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1988,7 +1988,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach_Tests.cpp From e3ab8e15577121845540a747489b8dd2109346cc Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 10:58:55 -0800 Subject: [PATCH 7/8] FRLG AutoStory: delete stage 6's C++ story rows, parity proven The parity test passed in the merge before this commit: every story file loads to the C++ row it replaces. This removes it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonFRLG_AutoStoryTable.h | 2 - ...PokemonFRLG_AutoStoryTableParity_Tests.cpp | 1156 ----------------- .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 1 - SerialPrograms/cmake/SourceFiles.cmake | 1 - 4 files changed, 1160 deletions(-) delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h index 182c4fea67..467da1a4f3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -71,8 +71,6 @@ const std::vector& story_checkpoints(); // Registers AutoStory table validation unit tests. void add_tests_AutoStory(UnitTestDatabase& database); -// The story files against the C++ rows they replace. -void add_tests_AutoStoryTableParity(UnitTestDatabase& database); // Which rows a run takes (PokemonFRLG_AutoStoryRunPlan_Tests.cpp). void add_tests_AutoStoryRunPlan(UnitTestDatabase& database); // The table run end to end against a fake game (PokemonFRLG_AutoStorySimulation_Tests.cpp). diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp deleted file mode 100644 index a67976fba6..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp +++ /dev/null @@ -1,1156 +0,0 @@ -/* AutoStory Table Parity Tests - * - * From: https://github.com/PokemonAutomation/ - * - * The C++ rows the story table had before StoryData/, built with the - * shared step API, against the checkpoints read from the files: each - * loads to the same steps, args (with the fallbacks the reader fills in), - * poses, supplies and START menu. Removed with the C++ rows. - * - */ - -#include -#include -#include -#include -#include "Common/Cpp/Exceptions.h" -#include "Common/Cpp/TestRunners/UnitTest.h" -#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" -#include "PokemonFRLG_AutoStoryCapture.h" -#include "PokemonFRLG_AutoStoryChoice.h" -#include "PokemonFRLG_AutoStoryBattleData.h" -#include "PokemonFRLG_AutoStoryGrind.h" -#include "PokemonFRLG_AutoStoryMart.h" -#include "PokemonFRLG_AutoStoryParty.h" -#include "PokemonFRLG_AutoStoryTable.h" -#include "PokemonFRLG_AutoStoryTeach.h" -#include "PokemonFRLG_AutoStoryTrashCans.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -namespace{ - -constexpr Direction NORTH = Direction::NORTH; -constexpr Direction SOUTH = Direction::SOUTH; -constexpr Direction EAST = Direction::EAST; -constexpr Direction WEST = Direction::WEST; - -constexpr std::string_view BEDROOM = "PalletTown_PlayersHouse_2F"; -constexpr std::string_view PALLET = "PalletTown"; -constexpr std::string_view LAB = "PalletTown_ProfessorOaksLab"; -constexpr std::string_view VIRIDIAN = "ViridianCity"; -constexpr std::string_view VIRIDIAN_MART = "ViridianCity_Mart"; -constexpr std::string_view VIRIDIAN_CENTER = "ViridianCity_PokemonCenter_1F"; -constexpr std::string_view FOREST = "ViridianForest"; -constexpr std::string_view FOREST_GATE = "Route2_ViridianForest_NorthEntrance"; -constexpr std::string_view PEWTER = "PewterCity"; -constexpr std::string_view PEWTER_CENTER = "PewterCity_PokemonCenter_1F"; -constexpr std::string_view GYM = "PewterCity_Gym"; -constexpr std::string_view ROUTE3 = "Route3"; -constexpr std::string_view ROUTE4 = "Route4"; -constexpr std::string_view ROUTE4_CENTER = "Route4_PokemonCenter_1F"; -constexpr std::string_view MT_MOON_1F = "MtMoon_1F"; -constexpr std::string_view MT_MOON_B2F = "MtMoon_B2F"; -constexpr std::string_view CERULEAN = "CeruleanCity"; -constexpr std::string_view CERULEAN_CENTER = "CeruleanCity_PokemonCenter_1F"; -constexpr std::string_view CERULEAN_MART = "CeruleanCity_Mart"; -constexpr std::string_view CERULEAN_GYM = "CeruleanCity_Gym"; -constexpr std::string_view ROUTE24 = "Route24"; -constexpr std::string_view ROUTE25 = "Route25"; -constexpr std::string_view SEA_COTTAGE = "Route25_SeaCottage"; -constexpr std::string_view ROUTE6 = "Route6"; -constexpr std::string_view VERMILION = "VermilionCity"; -constexpr std::string_view VERMILION_CENTER = "VermilionCity_PokemonCenter_1F"; -constexpr std::string_view VERMILION_GYM = "VermilionCity_Gym"; -constexpr std::string_view SS_ANNE_1F = "SSAnne_1F_Corridor"; -constexpr std::string_view SS_ANNE_2F = "SSAnne_2F_Corridor"; -constexpr std::string_view CAPTAINS_OFFICE = "SSAnne_CaptainsOffice"; - -Pokemon::GridPose at(std::string_view map, int x, int y, std::optional facing = std::nullopt){ - return Pokemon::GridPose{std::string(map), {{x, y}}, facing}; -} - -StoryCheckpoint row( - std::string id, std::string title, std::optional start, - Supplies supplies, StartMenu menu, std::vector steps -){ - StoryCheckpoint checkpoint; - checkpoint.id = std::move(id); - checkpoint.title = std::move(title); - checkpoint.start = std::move(start); - checkpoint.steps = std::move(steps); - checkpoint.supplies = supplies; - checkpoint.menu = menu; - return checkpoint; -} - -Supplies after_brock(){ - Supplies supplies; - supplies.lead = story_lead_after_brock(); - return supplies; -} - -// What a walk does about wild Pokemon: runs, or fights them for EXP. -enum class WildBattles{ - RUN, - FIGHT, -}; - -StoryStep make(StoryStepKind kind, std::string name, std::string why, Pokemon::StoryActionArgs args = {}){ - StoryStep step; - step.kind = kind; - step.name = std::move(name); - step.why = std::move(why); - step.args = std::move(args); - return step; -} - -StoryStep route(std::string name, Pokemon::GridPose target, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::ROUTE, std::move(name), std::move(why), { - {"target", std::move(target)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -StoryStep step_into(std::string name, Direction direction, std::string why){ - return make(StoryStepKind::STEP, std::move(name), std::move(why), {{"direction", direction}}); -} - -StoryStep into_line(std::string name, Direction direction, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.action = TRAINER_LINE_VARIANT; - return step; -} - -StoryStep hop(std::string name, Direction direction, Pokemon::GridPose landing, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.pose_after = std::move(landing); - return step; -} - -StoryStep into_sight(std::string name, Direction direction, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.action = TRAINER_WAIT_VARIANT; - return step; -} - -StoryStep cut_tree(std::string name, Pokemon::GridPose tree, std::string why){ - StoryStep step = make(StoryStepKind::GAME, std::move(name), std::move(why), {{"direction", tree.facing.value_or(Direction::NORTH)}}); - step.action = CUT_TREE_VARIANT; - step.pose_after = std::move(tree); - return step; -} - -StoryStep trash_cans(std::string name, std::string why){ - StoryStep step = make(StoryStepKind::GAME, std::move(name), std::move(why)); - step.action = TRASH_CANS_VARIANT; - return step; -} - -StoryStep unless(const char* flag, StoryStep step){ - step.skip_if.emplace_back(flag); - return step; -} - -StoryStep answer(std::string name, bool yes, std::string why){ - return make(StoryStepKind::ANSWER, std::move(name), std::move(why), {{"yes", yes}}); -} - -StoryStep scene(std::string name, std::optional pose_after, std::string why){ - StoryStep step = make(StoryStepKind::MASH, std::move(name), std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep battle(std::string name, Pokemon::GridPose pose_after, bool may_lose, std::string why){ - StoryStep step = make(StoryStepKind::BATTLE, std::move(name), std::move(why), {{"may_lose", may_lose}}); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep legs(std::string name, std::vector legs, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::LEGS, std::move(name), std::move(why), { - {"legs", std::move(legs)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -// `step`, a ROUTE or LEGS, run with B held: from the Running Shoes on. -StoryStep running(StoryStep step){ - step.action = RUN_VARIANT; - return step; -} - -StoryStep new_game_intro(Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::NEW_GAME, "intro", std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep talk(std::string name, std::string why){ - return make(StoryStepKind::TALK, std::move(name), std::move(why)); -} - -StoryStep ready(std::string name, Pokemon::GridPose nurse, std::string why){ - return make(StoryStepKind::READY, std::move(name), std::move(why), {{"target", std::move(nurse)}}); -} - -StoryStep heal(std::string name){ - return make(StoryStepKind::HEAL, std::move(name), "full HP"); -} - -StoryStep shop(std::string name, std::vector items, std::string why){ - return make(StoryStepKind::SHOP, std::move(name), std::move(why), {{"items", std::move(items)}}); -} - -StoryStep game_step(std::string action, Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::GAME, action, std::move(why)); - step.action = std::move(action); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep options_step(){ - return make(StoryStepKind::OPTIONS, "options", "fast text; no switch prompt between a trainer's Pokemon"); -} - - -StoryCheckpoint new_game(){ - StoryCheckpoint checkpoint = row("00.01", "new game to the bedroom", std::nullopt, {}, StartMenu::BEFORE_POKEMON, { - // new_game.c: the bedroom at (6, 6), facing the TV. - new_game_intro(at(BEDROOM, 6, 6, NORTH), "Oak's speech, BOY, the player's name (default if none is set), rival GREEN"), - options_step(), - }); - checkpoint.handoff = StoryHandoff::SID_HELPER; - return checkpoint; -} - -// SID Helper confirms the name, finishes the intro and reads the Trainer -// Card from the START menu, without moving the player or saving. -StoryCheckpoint after_sid_helper(){ - StoryCheckpoint checkpoint = row("00.01b", "after SID Helper: close the Trainer Card, save in the bedroom", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - game_step(CLOSE_TRAINER_CARD, at(BEDROOM, 6, 6, NORTH), "the Trainer Card SID Helper left open, or HOME"), - options_step(), - }); - checkpoint.live_start = true; - return checkpoint; -} - -StoryCheckpoint leave_house(){ - return row("00.02", "bedroom to Pallet Town", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("front_door", at(PALLET, 6, 8), "down the stairs and out of the house"), - }); -} - -StoryCheckpoint oaks_trigger(){ - return row("00.03", "Oak stops the player and walks them to the lab", at(PALLET, 6, 8, SOUTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_oaks_trigger", at(PALLET, 12, 2, NORTH), "below the north exit, short of Oak's trigger at (12, 1)"), - step_into("oaks_trigger", NORTH, "the trigger: \"Don't go out!\""), - // PlayerEnter walks the player up 8 tiles from the lab's door. - scene("to_the_lab", at(LAB, 6, 4, NORTH), "Oak walks the player into the lab; the scene ends at the table"), - }); -} - -// Starter RNG starts from a save south of the table, facing the ball. -StoryCheckpoint to_starter_ball(){ - StoryCheckpoint checkpoint = row("00.04", "to Squirtle's ball, south of the table", at(LAB, 6, 4, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_squirtle", at(LAB, 9, 5, NORTH), "under Squirtle's ball (9, 4)"), - }); - checkpoint.handoff = StoryHandoff::STARTER_RNG; - return checkpoint; -} - -StoryCheckpoint starter(){ - return row("00.04b", "Squirtle, then the rival's battle", at(LAB, 9, 5, NORTH), {}, StartMenu::BEFORE_POKEDEX, { - talk("squirtle_ball", "\"So, you want the WATER POKEMON SQUIRTLE?\""), - answer("choose_squirtle", true, "take Squirtle"), - answer("no_nickname", false, "\"give a nickname?\" NO"), - scene("rival_takes_bulbasaur", at(LAB, 9, 5, NORTH), "the rival picks his ball; the player still faces the table (console B, 2026-11-01)"), - route("above_rival_trigger", at(LAB, 7, 7, SOUTH), "short of the rival's trigger row 8"), - step_into("rival_trigger", SOUTH, "\"Wait, let's check out our POKEMON!\""), - // The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down. - battle("rival_battle", at(LAB, 7, 8, SOUTH), true, "the tutorial battle; losing goes on too"), - }); -} - -StoryCheckpoint parcel(){ - return row("00.05", "Route 1 to Viridian Mart: Oak's Parcel", at(LAB, 7, 8, SOUTH), {}, StartMenu::BEFORE_POKEDEX, { - route("below_mart_door", at(VIRIDIAN, 36, 20, NORTH), "Route 1, running from wild battles"), - step_into("mart_door", NORTH, "the clerk's scene starts on entering"), - // ApproachCounter: up 4 from the mat, then faces the clerk. - scene("parcel_from_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "the clerk gives OAK'S PARCEL"), - }); -} - -StoryCheckpoint pokedex(){ - return row("00.06", "Oak's Parcel to the Pokedex", at(VIRIDIAN_MART, 4, 3, WEST), {}, StartMenu::FULL, { - route("below_oak", at(LAB, 6, 4, NORTH), "back down Route 1 to Oak"), - talk("give_parcel", "Oak takes the parcel"), - scene("pokedex_scene", at(LAB, 6, 4, SOUTH), "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)"), - }); -} - -StoryCheckpoint shopping(){ - return row("00.07", "Viridian shopping, then into Viridian Forest", at(LAB, 6, 4, SOUTH), {}, StartMenu::FULL, { - route("mart_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "Route 1 again"), - // 2000 of the 3000 a new game starts with, plus the rival's prize. - shop("potions_and_antidotes", {{"potion", 5}, {"antidote", 3}, {"parlyz_heal", 1}}, "5 Potions, 3 Antidotes, 1 Parlyz Heal"), - route("viridian_nurse", at(VIRIDIAN_CENTER, 7, 4, NORTH), "heal before the forest"), - heal("heal_viridian"), - route("below_old_man_trigger", at(VIRIDIAN, 20, 9, NORTH), "short of the tutorial trigger (20, 8)"), - step_into("old_man_trigger", NORTH, "the old man's catching tutorial can't be walked around"), - // TutorialTriggerLeft turns the player right, to the old man. - scene("old_man_tutorial", at(VIRIDIAN, 20, 8, EAST), "about 60 lines and his demo battle; TEACHY TV"), - // After his demo the old man stands east of the player, beside (20, 8), where - // the map doesn't have him: "east 2" from there didn't move, and the walk north - // ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first. - route("past_old_man", at(VIRIDIAN, 20, 5, NORTH), "north along column 20, clear of the old man"), - // The gate's north warp lands on the forest's exit mat (29, 62), facing - // north. The save there keeps a forest failure from going back to Pallet. - route("forest_entrance", at(FOREST, 29, 62, NORTH), "Route 2 and the south gate, running from wild battles"), - }); -} - -StoryCheckpoint forest(){ - // The supplies bought in 00.07. - return row("00.08", "Viridian Forest to Pewter Center", at(FOREST, 29, 62, NORTH), {5, 3, 1}, StartMenu::FULL, { - // Wild battles are fought for EXP. Straight up the east side from the - // entrance, each leg ending on a wall (the Boy at (45, 58) stops the - // east one). Rick (47, 45) sees (42..46, 45), so the last leg meets - // his battle and is held on to its wall after it. The by-hand run's - // detour west to (13, 46) and back is dropped. - legs("forest_east", {{EAST, 1}, {NORTH, 4}, {EAST, 14}, {NORTH, 15}}, "up the east side to (44, 43)", WildBattles::FIGHT), - route("forest_north", at(FOREST, 39, 25), "north part", WildBattles::FIGHT), - // To the gate by legs that end on walls, which the walker holds again - // after a battle instead of estimating where it stopped: planned - // routes with open legs lost the player in the north of the forest - // (console B, 2026-11-01). The two 1-tile legs are single steps. - legs("forest_exit", { - {NORTH, 10}, {WEST, 12}, {SOUTH, 10}, {WEST, 6}, {NORTH, 20}, - {SOUTH, 1}, {WEST, 10}, {SOUTH, 27}, {WEST, 8}, {NORTH, 20}, {EAST, 1}, - }, "walls all the way to the gate's column", WildBattles::FIGHT), - route("forest_gate", at(FOREST_GATE, 7, 10, NORTH), "north onto the exit, arriving on the gate's mat", WildBattles::FIGHT), - // Out of the forest, wild battles are run from; trainers are still fought. - route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "Route 2 north to Pewter's Center"), - heal("heal_pewter"), - }); -} - -StoryCheckpoint brock(){ - // The by-hand save: 2 Potions and 1 Antidote left after the forest. - return row("00.09", "Pewter Gym: Camper Liam, then Brock", at(PEWTER_CENTER, 7, 4, NORTH), {2, 1}, StartMenu::FULL, { - // Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight - // 4) and sees (4..7, 8): walking north up column 6 from the door, - // the step onto (6, 8) starts his battle. He walks up to the player, - // who stays put and keeps facing north (FRLG doesn't turn the player - // to a trainer). That step is taken on its own, so no leg is cut. - route("below_liam_line", at(GYM, 6, 9, NORTH), "in by the door, up column 6 to below Liam's row"), - step_into("liam_line", NORTH, "onto (6, 8), in Liam's line"), - battle("camper_liam", at(GYM, 6, 8, NORTH), false, "Geodude and Sandshrew; EXP before Brock"), - // On to Brock unless red HP or a status is left that no item cures. - ready("ready_for_brock", at(PEWTER_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - route("before_brock", at(GYM, 6, 6, NORTH), "below Brock (6, 5); Liam, beaten, stands at (5, 8)"), - talk("challenge_brock", "Brock's speech"), - battle("brock", at(GYM, 6, 6, NORTH), false, "Geodude and Onix, with Bubble; Boulder Badge and TM39"), - }); -} - -StoryCheckpoint running_shoes(){ - return row("00.10", "Pewter: the Running Shoes from Oak's aide", at(GYM, 6, 6, NORTH), after_brock(), StartMenu::FULL, { - // Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at - // (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The - // Gym guide's triggers at (42..43, 21..23) need the scene at 0. - route("before_aide_trigger", at(PEWTER, 45, 21, EAST), "out of the Gym, east along row 21, short of the top trigger"), - step_into("aide_trigger", EAST, "onto (46, 21), below the aide"), - // RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; - // the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH - // is set (console B, 2026-11-02: about 20 B presses to the overworld). - scene("shoes_from_aide", at(PEWTER, 46, 21, NORTH), "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north"), - // Where the by-hand walk stopped to start 00.11 (console B, 2026-11-02). - route("below_pewter_center", at(PEWTER, 17, 26, SOUTH), "west along row 21 and down to below the Pokemon Center's door (17, 25)"), - }); -} - -// Route 3's trainers (Route3 map.json): the way east meets three of them. -// Bug Catcher Colton (12, 6) faces east, sight 3: the only way north past -// the row 7 ledges is the gap at x 14..15, below his line. Youngster Ben -// (17, 4) faces south, sight 2, so the way east keeps to row 3 past him. -// Bug Catcher Greg (25, 4) faces south, sight 2, over the way east along -// row 5. Bug Catcher James (32, 6) faces east, sight 4, over the way down -// at x 35..36. The others are kept out of: Lass Janice (19, 9) sees west -// along row 9 to x 14, Lass Sally (30, 3) west along row 3 to x 25, and -// Youngster Calvin (29, 10) west along row 10. Each line is stepped into on -// its own, so no leg is cut; the trainer walks up to the player, who stays -// put facing the way they stepped. -StoryCheckpoint route3(){ - return row("00.11", "Pewter Center, then Route 3's trainers", at(PEWTER, 17, 26, SOUTH), after_brock(), StartMenu::FULL, { - running(route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "in by the door below the player")), - heal("heal_pewter"), - // Up from row 9 west of Janice's line, which ends at x 14. - running(route("west_of_janice_line", at(ROUTE3, 13, 8), "out of Pewter by row 21, east into Route 3, short of Janice's line")), - running(legs("below_colton_line", {{EAST, 1}, {NORTH, 1}}, "to (14, 7), in the ledges' gap")), - step_into("colton_line", NORTH, "onto (14, 6), in Colton's line"), - battle("bug_catcher_colton", at(ROUTE3, 14, 6, NORTH), false, "his Bug Pokemon; Colton stops at (13, 6)"), - running(legs("past_ben", {{NORTH, 3}, {EAST, 4}, {SOUTH, 2}, {EAST, 6}}, "up to row 3 above Ben, down at x 18 east of his line, to (24, 5)")), - step_into("greg_line", EAST, "onto (25, 5), below Greg"), - battle("bug_catcher_greg", at(ROUTE3, 25, 5, EAST), false, "his Bug Pokemon; Greg is already next to the player"), - running(legs("above_james_line", {{EAST, 11}}, "along row 5 to the wall at (36, 5)")), - step_into("james_line", SOUTH, "onto (36, 6), at the end of James's line"), - battle("bug_catcher_james", at(ROUTE3, 36, 6, SOUTH), false, "his Bug Pokemon; James stops at (35, 6)"), - // Saved here, the trainers behind, so a failure on the way to Route 4 - // doesn't fight them again. - running(legs("save_spot", {{SOUTH, 2}}, "down to (36, 8), beside the wall east of it")), - }); -} - -// Route 3's north exit (x 68..75) joins Route 4 (offset 60) at x 8..15, up -// which column 12 leads to the Pokemon Center's door (12, 5). Lass Robin -// (40, 11) wanders up and down at x 40, looking north and south, sight 3. -// Rock above (y <= 8) and grass below (y >= 12) leave every way east -// across her column at y 9..11, so whether she sees the player depends on -// her facing. The walk watches for her after the leg along row 9, which -// crosses her sight on (40, 9) only; if she saw the player, her message -// goes to story_interrupts(), which fight her, and the route goes on from -// (40, 9) (run_route(); console B, 2026-11-02, she stopped the player -// there and spoke after the leg's short watch). -StoryCheckpoint magikarp_salesman(){ - StoryCheckpoint checkpoint = row("00.12", "Route 3 and 4 to the Magikarp salesman", at(ROUTE3, 36, 8, SOUTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "east over Route 3, off the grass, north into Route 4 and its Pokemon Center")), - heal("heal_route4"), - // Gift RNG starts from a save facing the salesman (1, 3). - running(route("before_salesman", at(ROUTE4_CENTER, 2, 3, WEST), "beside the Magikarp salesman, facing him")), - }); - checkpoint.handoff = StoryHandoff::GIFT_RNG; - return checkpoint; -} - -// Gift RNG buys the Magikarp (500 of the money 00.12 brings) without -// moving the player and leaves its summary open, or HOME. This saves the -// shiny where 00.12 ended. A run started here with Gift RNG's handoff on -// loads the save beside the salesman and runs Gift RNG first. -StoryCheckpoint after_gift_rng(){ - StoryCheckpoint checkpoint = row("00.12b", "after Gift RNG: save with the Magikarp", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - game_step(LEAVE_GIFT_SUMMARY, at(ROUTE4_CENTER, 2, 3, WEST), "the Magikarp's summary Gift RNG left open, or HOME"), - }); - checkpoint.live_start = true; - return checkpoint; -} - -// The Magikarp goes to BOX 1 at the Center's PC (11, 1), so Mt. Moon is -// fought with the starter alone (console B, 2026-11-02: done by hand and -// saved at (11, 2), facing the PC, where this row ends). The wandering -// boy (4..6, 3..5) is walked around. The Magikarp comes from Gift RNG: -// with Gift RNG off the party is the starter alone, and the deposit is -// skipped. -StoryCheckpoint magikarp_to_box(){ - return row("00.12c", "Route 4 Center: the Magikarp into BOX 1", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - running(route("pc_front", at(ROUTE4_CENTER, 11, 2, NORTH), "below the PC (11, 1), facing it")), - pc_step("magikarp_to_box", "DEPOSIT the party's second slot into BOX 1, if it has one", PcTransfer{ - .action = PcAction::DEPOSIT, .party_slot = 1, .box = 0, .if_missing = PcMissing::SKIP, - }), - }); -} - -// Mt. Moon (pokefirered data/maps/MtMoon_1F, _B1F, _B2F). Every floor tile -// of the cave has wild encounters, which are run from, so its legs end on -// walls, ladders or someone standing still, which the walker holds again -// after a battle; the few open ones are short. The way through: up 1F's -// middle and west side, its north-west ladder, B1F's west ladder down to -// B2F's south-east, round B2F's south edge to its west, north past -// Miguel and the fossils, and the ladder up to B1F's east end, which -// leads out to Route 4 east of the mountain. -// - 1F's trainers are walked around: Youngster Josh (13, 17) sees east -// along row 17 to x 17, so the way west into the west room is down -// column 18 and up column 11; Lass Miriam walks round (32..33, 4..5), -// sight 2, so the way east keeps to row 9 and columns 38 and 40; Hiker -// Marcos wanders (5..9, 8..12) and sees one tile, so the way north is -// column 11 and row 3. -// - The Moon Stone ball (3, 2) on 1F (FLAG_HIDE_MT_MOON_1F_MOON_STONE) is -// a few tiles off the way to the ladder (5, 6). -// - The Grunt at (37, 21) on B2F looks around (sight 3) over the only way -// east round B2F. His room is crossed on legs to walls, at one tile of -// his sight each, (37, 22) and (40, 21); if he looks the player's way, -// he walks up beside the leg, story_interrupts() fights him, and the -// leg is held on to its wall. -// - The Grunt at (12, 20) faces south (sight 2) over (12, 21..22), across -// rows 21..22, the only way north to Miguel: stepped into from the -// west, he is next to the player and doesn't walk. -// - Super Nerd Miguel (13, 11) battles on the step onto (14, 11) -// (MtMoon_B2F_EventScript_MiguelTrigger, VAR_MAP_SCENE_MT_MOON_B2F 0), -// then "We'll each take one!" -// - The fossils: DOME (13, 7), HELIX (14, 7). After the HELIX, Miguel -// walks up to (13, 8) and takes the DOME, which opens the gap north. -// The save is on Route 4: the save card's places don't include Mt. Moon. -StoryCheckpoint mt_moon(){ - return row("00.13", "Mt. Moon: a Moon Stone, a Rocket, Miguel and the Helix Fossil", at(ROUTE4_CENTER, 11, 2, NORTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "the nurse, below the counter")), - heal("heal_route4"), - running(route("mt_moon_entrance", at(MT_MOON_1F, 18, 37, NORTH), "out of the Center, west into Mt. Moon")), - running(legs("mt_moon_1f", { - {NORTH, 12}, {EAST, 8}, {NORTH, 12}, {EAST, 3}, {SOUTH, 1}, {EAST, 9}, - {NORTH, 1}, {EAST, 2}, {NORTH, 4}, {WEST, 24}, {EAST, 2}, {SOUTH, 12}, - {WEST, 7}, {NORTH, 18}, {WEST, 9}, {EAST, 1}, - }, "up the middle, east of Miriam, west along row 9, down column 18 past Josh, up column 11 past Marcos, to (3, 3)")), - running(route("below_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "facing the Moon Stone (3, 2)")), - talk("moon_stone_ball", "A on the item ball"), - // No reader for the text yet: the scene's end is the overworld. - scene("found_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "\" found a MOON STONE!\", then the pocket line; the ball is gone"), - running(route("b2f_ladder_foot", at(MT_MOON_B2F, 26, 21, EAST), "1F's ladder (5, 6), down B1F's west side to its ladder (22, 18), onto B2F")), - running(legs("b2f_south", { - {NORTH, 4}, {EAST, 8}, {WEST, 2}, {SOUTH, 5}, {EAST, 8}, {NORTH, 3}, {WEST, 1}, {NORTH, 5}, - {EAST, 7}, {SOUTH, 14}, {WEST, 9}, {SOUTH, 10}, {WEST, 29}, {EAST, 3}, {NORTH, 17}, - }, "through the Grunt's room at (37, 21), round the south edge, up column 11 to (11, 21)")), - step_into("grunt_line", EAST, "onto (12, 21), below the Grunt at (12, 20)"), - battle("rocket_grunt", at(MT_MOON_B2F, 12, 21, EAST), false, "Rattata and Zubat, Lv13"), - ready("ready_for_miguel", at(ROUTE4_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse, back through the cave, only if they can't"), - // Up column 13 to Miguel, who stops the leg on (13, 12), then east - // to the wall: the tile below his trigger. - running(legs("below_miguel_trigger", {{EAST, 1}, {NORTH, 9}, {EAST, 1}}, "to (14, 12), below Miguel's trigger (14, 11)")), - step_into("miguel_trigger", NORTH, "onto (14, 11), beside Miguel"), - battle("super_nerd_miguel", at(MT_MOON_B2F, 14, 11, NORTH), false, "Grimer, Voltorb and Koffing, Lv12; \"We'll each take one!\""), - running(legs("below_helix_fossil", {{NORTH, 3}}, "up column 14 to the HELIX FOSSIL (14, 7)")), - fossil_step("helix_fossil", "the HELIX FOSSIL; Miguel takes the DOME FOSSIL", Fossil::HELIX), - // The maps keep the fossils, which the game removes after the - // choice: the step onto the HELIX's tile is taken on its own. - step_into("helix_gap", NORTH, "onto (14, 7), where the HELIX FOSSIL lay"), - running(route("route4_east", at(ROUTE4, 32, 6, SOUTH), "west to B2F's ladder (5, 10), up to B1F, east to its exit onto Route 4")), - }); -} - - -// Route 4 east of Mt. Moon (Route4 map.json) joins Cerulean City at its -// east end (x 107; Route 4's row 3 is the city's row 13). Its upper road -// (rows 2..8) reaches the city only by water: the way on by land is down -// the ledge row 9 at x 90..96 to the lower road (rows 10..12), which -// joins the city's rows 20..22. Lass Crissy (75, 3) faces east, sight 4, -// over row 3 from x 76 to 79; the way east keeps out of her line and off -// the grass south of the road (75..87, 11..17). -// -// On the way, the Mega Kick tutor (Black Belt (50, 3), facing west, -// Route4_EventScript_MegaKickTutor) stands in a pen (46..51, 2..4) north -// of the road, beside the Mega Punch tutor (47, 3); the pen opens south -// only on (48, 5) and (49, 5), the rest of row 5 ledges out of it. From -// Mt. Moon's exit the walk goes east and up into the pen to (50, 4), -// below the tutor, and Mega Kick takes Withdraw's slot. Cerulean can't -// be walked back to Route 4's upper road without Surf, so it is now or -// much later. -// -// The open leg east across the city's edge ended a tile short on the -// console (2026-11-03: on (6, 20), not (7, 20)), and no hold to a wall -// in the city's west end finds the player from there: the next hold -// south met the fence on (6, 23) and the walk went on a column off. So -// the entry ends on (9, 20), and only legs to walls follow: north up -// column 9 (or 8, a tile short) to row 12, west to (8, 12), east to -// (30, 12) beside the policeman (31, 12), south to (30, 17), west to -// (25, 17), and down the ledge row 18 to (25, 19), a few tiles from the -// door (22, 19). The way keeps out of the boy's (16, 18..24) and the -// balding man's (8..10, 22..24) wander boxes. -StoryCheckpoint route4_to_cerulean(){ - const TeachPlan mega_kick{.item = std::string(TEACH_TUTOR), .move = "mega-kick", .member = 0, .forget_move = "withdraw"}; - return row("00.14", "Route 4: Mega Kick from its tutor, then east to Cerulean's Pokemon Center", at(ROUTE4, 32, 6, SOUTH), after_brock(), StartMenu::FULL, { - running(route("mega_kick_tutor", at(ROUTE4, 50, 4, NORTH), "east and up through (48, 5) into the tutors' pen, below the Mega Kick tutor (50, 3)")), - teach_step("teach_mega_kick", "the tutor's Mega Kick in place of Withdraw, unless the lead knows it", mega_kick), - running(route("above_ledge", at(ROUTE4, 93, 8, SOUTH), "east along Route 4's upper road to above the ledge row 9")), - hop("ledge_hop", SOUTH, at(ROUTE4, 93, 10, SOUTH), "down the ledge (93, 9) to the lower road"), - running(route("cerulean_entry", at(CERULEAN, 9, 20, EAST), "east into Cerulean City, to (9, 20) below column 9")), - running(legs("above_city_ledge", {{NORTH, 8}, {WEST, 1}, {EAST, 22}, {SOUTH, 5}, {WEST, 5}}, "to walls: (9, 12), (8, 12), (30, 12), (30, 17), (25, 17)")), - hop("city_ledge_hop", SOUTH, at(CERULEAN, 25, 19, SOUTH), "down the ledge (25, 18)"), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "west along row 20 to the Pokemon Center's door (22, 19)")), - heal("heal_cerulean"), - }); -} - -// Cerulean Gym (pokefirered CeruleanCity_Gym map.json and scripts.inc): -// a pool with walkways. Misty (8, 6) stands on a platform (7..9, 6) above -// row 7. Picnicker Diana (4, 7) faces east, sight 4, over (5..8, 7), so -// misty_front (8, 7) is in her line; Swimmer Luis (10, 12) in the water -// faces west, sight 1, over (9, 12), on column 9 north of the door. No -// gym trainer has to be fought for Misty, so neither is: from the door up -// column 9 to row 13 (a route there, so the planner's walk to a wall -// doesn't run on past it through (9, 12)), west to (4, 13), and to walls -// round the pool's west and north sides, (4, 10), (12, 10), (12, 7), then -// west to (9, 7), the tile below the platform's east end, out of Diana's -// line. 00.14c steps up onto (9, 6) and talks to Misty from beside her. -// -// Misty beat a Lv20 Wartortle (console B, run m51), so first a GRIND to -// Lv23 on 00.15's patch. Gen 3 numbers (pokefirered: her mons have IV 0; -// Wartortle taken at IV 15, no EVs): Starmie Lv21 has 56 HP, Atk 36, SpA -// 47, SpD 40. Bite is Dark, special in Gen 3, no STAB, x2 on Psychic: at -// Lv23 (SpA 39) it does 23..28, three hits (two on top rolls); at Lv20, -// 20..24. Her Swift (physical, 60) does 9..11 to a Lv23 Wartortle (about -// 67 HP, Def 45) and Water Pulse (STAB, resisted) 8..10: 6 or more hits, -// though m51 saw about 20 a turn. Her Recover (28) and Super Potion undo -// a Bite, so the margin is in Bite's damage. -// -// The Mart comes before the GRIND: its wild battles are fought only with -// 2 or more Potions, and 00.14's save has none (m51 met Misty with only -// the 5 this row bought). 5 Potions (row 3, 300 each), then up to 3 Super -// Potions (row 2, 700), last so they take the Items pocket's last row; -// the battle doesn't use them yet. The money box can't be read, so the -// floor stands for it, and a floor above the money fails the step (the -// quantity box wraps). Prizes (pokefirered: 4 x last level x the class's -// factor) from a new game's 3000, less Viridian's 2000 and the Magikarp's -// 500: Liam 220, Brock 1400, Route 3's bug catchers 360, the Mt. Moon -// grunt 416 and Miguel 288 (the first rival's 80 only if won), at least -// 3184 here. Floor and budget 3000: 5 Potions and 2 Super Potions, 2900. -// Misty's 2100 (4 x 21 x 25) then leaves 00.15 its floor of 1500. Then the -// nurse, and the save before Misty, so her battle is its own checkpoint, -// 00.14c, verified and retried from it. 00.15's GRIND then fights -// until the sim beats the Cerulean rival often enough. -StoryCheckpoint cerulean_gym(){ - const MartPlan supplies{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "potion", .quantity = 5}, {.item = "super-potion", .quantity = 3}}, - .budget = 3000, - .money_floor = 3000, - }; - const GrindPlan to_lv23{.member = 0, .level = 23, .max_encounters = 100, .pace = WEST, .heal_every = 0}; - return row("00.14b", "Cerulean: Potions, a GRIND to Lv23, then into the Gym, saved below Misty's platform", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_potions", "5 Potions for the GRIND's wild battles, then Super Potions as the money allows", supplies), - running(route("grind_patch", at(ROUTE4, 86, 16, WEST), "west out of the city along Route 4's lower road onto its grass's east edge")), - grind_step("grind_to_lv23", "wild battles until the lead is Lv23, where Bite takes Starmie in three", to_lv23, at(CERULEAN_CENTER, 7, 4, NORTH)), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center: Misty's battle starts at full HP and PP")), - heal("heal_cerulean"), - running(route("gym_below_luis", at(CERULEAN_GYM, 9, 13), "into the Gym, up column 9 to row 13, short of Luis's (9, 12)")), - running(legs("gym_west_walkway", {{WEST, 5}}, "west to the wall (4, 13)")), - running(legs("below_misty_platform", {{NORTH, 3}, {EAST, 8}, {NORTH, 3}, {WEST, 3}}, "walls (4, 10), (12, 10), (12, 7), then to (9, 7), out of Diana's line")), - }); -} - -// Misty (TRAINER_LEADER_MISTY: Staryu Lv18, Starmie Lv21), talked to from -// (9, 6), beside her on the platform. Her win text runs on to the CASCADE -// BADGE, TM03 (Water Pulse) and its explanation, all read with the -// battle's. Bite is chosen against her party (Starmie is Water/Psychic). -// Back to the nurse round the pool's west side, out of Luis's line; then -// Water Pulse in place of Tail Whip, last, at the Center, from the bag's -// TM CASE. Ends where 00.15 starts. -StoryCheckpoint misty(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - return row("00.14c", "Cerulean Gym: Misty, then Water Pulse", at(CERULEAN_GYM, 9, 7, WEST), after_brock(), StartMenu::FULL, { - running(route("beside_misty", at(CERULEAN_GYM, 9, 6, WEST), "up onto (9, 6), facing Misty (8, 6)")), - talk("challenge_misty", "Misty's speech"), - battle("misty", at(CERULEAN_GYM, 9, 6, WEST), false, "Staryu and Starmie, with Bite; CASCADE BADGE and TM03"), - running(legs("gym_way_out", {{SOUTH, 1}, {EAST, 3}, {SOUTH, 3}, {WEST, 8}, {SOUTH, 3}, {EAST, 5}}, "walls (12, 7), (12, 10), (4, 10), (4, 13), (9, 13), round Luis's (9, 12)")), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "down column 9 out of the Gym, to the Center")), - heal("heal_cerulean"), - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip", water_pulse), - }); -} - -// Before the rival north of Cerulean (cerulean_rival()), from the -// Center: first TM03 Water Pulse over Tail Whip, if the lead doesn't know -// it yet, so the GRIND's sim plays it (a run without TM03 from Misty -// skips the step). Then 3 Potions at the Mart -// (CeruleanCity_Mart_Items: POTION is row 3, 300 each; Mt. Moon's -// trainers leave well over the floor) and 2 Awakenings (row 6, 250 each; -// pokefirered items.json) for the rival's Bulbasaur's Sleep Powder -// (console B, m56: asleep at 34/65 HP, it fainted two turns later with -// 15 Potions), 1400 of the floor's 1500. Then a GRIND on Route 4's grass -// east of Mt. Moon (75..86, 11..17; Spearow, Rattata, Ekans and Mankey -// around Lv10, about 80 EXP each), healing at the Center, until the -// battle sim beats the rival 00.15b fights 50% or more: the win chance -// his battle refuses below. Console B's Wartortle (Lv22, 65 HP, Water -// Pulse) is about 42% there and 62% at Lv23; Lv28 (about 88%, some 120 -// battles from Lv22) is the cap. Then the nurse, and the save on (23, 7), -// the tile below his trigger: his battle is its own checkpoint, 00.15b, -// verified and retried from this save. -StoryCheckpoint cerulean_grind(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - const MartPlan potions{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "potion", .quantity = 3}, {.item = "awakening", .quantity = 2}}, - .budget = 1500, - .money_floor = 1500, - }; - const GrindPlan for_rival{ - .member = 0, .level = 28, .max_encounters = 150, .pace = WEST, .heal_every = 0, - .trainer = std::string(story_trainer(CERULEAN, "rival_cerulean").value_or("")), .min_chance = MIN_WIN_CHANCE, - }; - return row("00.15", "Cerulean: Water Pulse, Potions, a GRIND until the rival is winnable, then saved below his trigger", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip, unless the lead knows it or there is no TM03", water_pulse), - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_potions", "3 Potions: the GRIND fights wild battles only with 2 or more; 2 Awakenings for the rival's Sleep Powder", potions), - running(route("grind_patch", at(ROUTE4, 86, 16, WEST), "west out of the city along Route 4's lower road onto its grass's east edge")), - grind_step("grind_for_rival", "wild battles until the sim beats the rival 50% or more, Lv28 at most; the nurse when hurt or low on PP", for_rival, at(CERULEAN_CENTER, 7, 4, NORTH)), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center: the rival's battle starts at full HP and PP")), - heal("heal_cerulean"), - running(route("below_rival_trigger", at(CERULEAN, 23, 7, NORTH), "out of the Center, north up to (23, 7), short of the trigger row 6")), - }); -} - -// The rival north of Cerulean (CeruleanCity scripts.inc): the only way -// north to Nugget Bridge is columns 22..24, and a step onto row 6 there -// (CeruleanCity_EventScript_RivalTrigger*, VAR_MAP_SCENE_CERULEAN_CITY_RIVAL -// 0) brings him down to the player. From the middle, (23, 6), he stops -// at (23, 5); after the battle he walks round the player and off south, -// and the player, turning to watch him, ends facing south. His FAME -// CHECKER's text is read to the overworld with the battle's. For a player -// who took Squirtle he has Pidgeotto Lv17, Abra Lv16, Rattata Lv15 and -// Bulbasaur Lv18 (sParty_RivalCeruleanBulbasaur), whose Vine Whip and -// Sleep Powder are the danger. The row starts from 00.15's save below the -// trigger, and saves after him. First TM03 Water Pulse over Tail Whip (from -// the bag, where the player stands), if the lead doesn't know it yet: -// console B's save (2026-11-03) is past Misty's TEACH, which failed there. -// Where she taught it, the step reads the moves and does nothing. -StoryCheckpoint cerulean_rival(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - return row("00.15b", "Cerulean: Water Pulse if not known, then the rival north of the city", at(CERULEAN, 23, 7, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip, unless the lead knows it", water_pulse), - step_into("rival_trigger", NORTH, "onto (23, 6), the middle trigger: \"Yo! !\""), - battle("rival_cerulean", at(CERULEAN, 23, 6, SOUTH), false, "Pidgeotto, Abra, Rattata and Bulbasaur; then the FAME CHECKER"), - }); -} - -// Nugget Bridge (Route24 map.json) is x 10..12 from row 32 north to row -// 16, the city's columns 22..24 (offset 12). Its five trainers stand on -// it facing across, sight 2, so each line crosses the middle column 11 -// on the trainer's row: Bug Catcher Cale (12, 31), Lass Ali (10, 28), -// Youngster Timmy (12, 25), Lass Reli (10, 22) and Camper Ethan (12, 19). -// Each is fought on the step onto their row, beside them: they don't -// walk, and the player keeps facing north. Two tiles separate the rows, -// walked as one short leg; the step onto a row goes on a tile at a time -// until the trainer sees the player (into_line()), as the open leg onto -// the bridge ended a tile short twice on console B (2026-11-03), on -// (11, 33), and one step left the player out of Cale's sight. Then the -// Rocket (12, 15): the step onto (11, 15) -// (Route24_EventScript_RocketTriggerRight, VAR_MAP_SCENE_ROUTE24 0) gives -// the NUGGET, "join Team Rocket", and his battle; he only turns, and the -// player turns east to him. Camper Shane (5, 21) looks north from the -// west bank, off the way. -StoryCheckpoint nugget_bridge(){ - return row("00.16", "Nugget Bridge: the nurse, five trainers and the Rocket", at(CERULEAN, 23, 6, SOUTH), after_brock(), StartMenu::FULL, { - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center after the rival, before Nugget Bridge")), - heal("heal_cerulean"), - running(route("below_cale_line", at(ROUTE24, 11, 32, NORTH), "out of the Center, north past the rival's row onto the bridge, below Cale's row")), - into_line("cale_line", NORTH, "onto (11, 31), beside Cale"), - battle("bug_catcher_cale", at(ROUTE24, 11, 31, NORTH), false, "his Bug Pokemon"), - running(legs("below_ali_line", {{NORTH, 2}}, "up to (11, 29)")), - into_line("ali_line", NORTH, "onto (11, 28), beside Ali"), - battle("lass_ali", at(ROUTE24, 11, 28, NORTH), false, "her Pokemon"), - running(legs("below_timmy_line", {{NORTH, 2}}, "up to (11, 26)")), - into_line("timmy_line", NORTH, "onto (11, 25), beside Timmy"), - battle("youngster_timmy", at(ROUTE24, 11, 25, NORTH), false, "his Pokemon"), - running(legs("below_reli_line", {{NORTH, 2}}, "up to (11, 23)")), - into_line("reli_line", NORTH, "onto (11, 22), beside Reli"), - battle("lass_reli", at(ROUTE24, 11, 22, NORTH), false, "her Pokemon"), - running(legs("below_ethan_line", {{NORTH, 2}}, "up to (11, 20)")), - into_line("ethan_line", NORTH, "onto (11, 19), beside Ethan"), - battle("camper_ethan", at(ROUTE24, 11, 19, NORTH), false, "his Pokemon"), - // A route, not legs: the nurse may have been needed. - ready("ready_for_rocket", at(CERULEAN_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - running(route("below_rocket_trigger", at(ROUTE24, 11, 16, NORTH), "up the bridge to below the Rocket's trigger (11, 15)")), - step_into("rocket_trigger", NORTH, "onto (11, 15), beside the Rocket"), - battle("rocket_grunt", at(ROUTE24, 11, 15, EAST), false, "the NUGGET, then Ekans and Zubat, Lv15"), - }); -} - -// Route 24 north of Nugget Bridge (Route24 map.json) joins Route 25 by -// its rows 7..9; the ledges on Route 25's row 6 (x 0..9) leave the way -// north at x 12..13. Route 25 (Route25 map.json, scripts.inc) to Bill's -// Sea Cottage door (51, 4): of its nine trainers, four can't be walked -// around. -// - Hiker Franklin (11, 4) faces east, sight 4, over (12..15, 4), and -// Hiker Wayne (17, 7) east over (18..19, 7): the only ways east past -// x 15. Franklin is fought, from (15, 5) on the step onto (15, 4), the -// end of his line: he walks up to (14, 4). -// - Youngster Joey (18, 2) faces south over (18, 3..4): the way keeps -// off column 18, south round Wayne to (19, 6) and up to (19, 4). -// - Youngster Dan (22, 4) looks around, sight 2, over the only way east, -// (20..21, 4). On (20, 4), a one-tile leg, he may see the player and -// walk up to (21, 4); so the way goes north from there to row 2, east, -// and down column 23 past him to (23, 5), off every tile he may walk -// up to. Where his sight is crossed, the leg ends on a wall or is one -// tile; if he looks the player's way, story_interrupts() fight him. -// - Picnicker Kelsey (22, 8) faces east over (23..24, 8), across the -// only way on: fought on the step onto (24, 8); she walks up to (23, 8). -// - Hiker Nob (27, 9) faces north over (27, 6..8), Camper Flint (28, 4) -// south over (28, 5..7): every way east crosses one. Nob is fought on -// the step onto (27, 8), beside him; the way on keeps off Flint's -// column, by one-tile legs and legs to walls. -// - Youngster Chad (36, 4) walks up and down column 36 (rows 2..7), so -// he may see any tile of it down to row 9. The way crosses his column -// on row 9, a leg to the water at (42, 9), where he can only walk up -// beside it. -// - Lass Haley (42, 5) faces south over (42, 6..8), the only way east of -// x 42: fought on the step onto (42, 8); she walks up to (42, 7). -// The row saves inside the Sea Cottage, which the save card names -// ROUTE 25. -StoryCheckpoint route25(){ - return row("00.17", "Route 24 and 25 to Bill's Sea Cottage: Franklin, Kelsey, Nob and Haley", at(ROUTE24, 11, 15, EAST), after_brock(), StartMenu::FULL, { - running(route("below_franklin_line", at(ROUTE25, 15, 5, NORTH), "north off Nugget Bridge, east into Route 25, round its ledges to (15, 5), below the end of Franklin's line")), - into_line("franklin_line", NORTH, "onto (15, 4), at the end of Franklin's line"), - battle("hiker_franklin", at(ROUTE25, 15, 4, NORTH), false, "Machop and Geodude, Lv15; Franklin stops at (14, 4)"), - running(legs("west_of_dan", {{EAST, 2}, {SOUTH, 2}, {EAST, 2}, {NORTH, 2}}, "to (17, 4), short of Joey's (18, 4); round Wayne (17, 7) to (19, 6); up to (19, 4)")), - running(legs("round_dan", { - {EAST, 1}, {NORTH, 2}, {EAST, 4}, {WEST, 1}, {SOUTH, 3}, {EAST, 1}, {SOUTH, 2}, - }, "onto (20, 4); up to (20, 2), east to (24, 2), down column 23 past Dan to (23, 5), to (24, 7) above Kelsey's line")), - into_line("kelsey_line", SOUTH, "onto (24, 8), at the end of Kelsey's line"), - battle("picnicker_kelsey", at(ROUTE25, 24, 8, SOUTH), false, "Nidoran M and Nidoran F, Lv15; Kelsey stops at (23, 8)"), - running(legs("west_of_nob_line", {{EAST, 2}}, "along row 8 to (26, 8)")), - into_line("nob_line", EAST, "onto (27, 8), above Nob"), - battle("hiker_nob", at(ROUTE25, 27, 8, EAST), false, "three Geodude and a Machop, Lv13"), - running(legs("below_haley_line", { - {EAST, 1}, {SOUTH, 1}, {EAST, 1}, {NORTH, 3}, {EAST, 5}, {SOUTH, 3}, {EAST, 8}, - }, "below Flint's column to (29, 9), up to (29, 6), east to (34, 6), down to (34, 9), east along row 9 past Chad's column to the water, (42, 9)")), - into_line("haley_line", NORTH, "onto (42, 8), at the end of Haley's line"), - battle("lass_haley", at(ROUTE25, 42, 8, NORTH), false, "Oddish, Pidgey and Oddish, Lv13; Haley stops at (42, 7)"), - running(route("sea_cottage", at(SEA_COTTAGE, 7, 8, NORTH), "east along row 8, up column 51 into the Sea Cottage (51, 4), a step in from its mat")), - }); -} - -// Bill's Sea Cottage (Route25_SeaCottage scripts.inc). Bill is the -// Clefairy at (10, 6) (FLAG_HELPED_BILL_IN_SEA_COTTAGE unset): talked to -// from (10, 7), below him, he asks "Help me out!" (YES/NO; NO goes on the -// same), says to run the Cell Separation on the PC, and walks up into -// the right teleporter (10, 3); with the player facing north he walks -// straight up. The PC (4, 5) answers only from the south, (4, 6). Its -// scene: the teleporters run, Bill comes out of the left one (3, 3) and -// walks to (7, 6) (BillWalkToMiddleOfRoom); the player isn't moved. -// Talked to from (6, 6), Bill gives the S.S. TICKET, no YES/NO, and goes -// on about the S.S. ANNE (FLAG_GOT_SS_TICKET, which also hides Nugget -// Bridge's Rocket). Out by the mat (7, 9); the door puts the player on -// (51, 5), facing south. The maps keep Bill at (7, 5), but after his -// scene he stands on (7, 6), in the way from (6, 6) to the mat (console -// B, 2026-11-03), so the walk out goes around him to (7, 8) first. -StoryCheckpoint bill(){ - return row("00.18", "Bill's Sea Cottage: the Cell Separator and the S.S. Ticket", at(SEA_COTTAGE, 7, 8, NORTH), after_brock(), StartMenu::FULL, { - running(route("below_bill_clefairy", at(SEA_COTTAGE, 10, 7, NORTH), "below the Clefairy (10, 6), facing it")), - talk("bill_clefairy", "\"Hiya! I'm a POKEMON... ...No I'm not!\" ... \"Help me out!\""), - answer("help_bill", true, "YES: \"run the Cell Separation on the PC\""), - scene("bill_into_teleporter", at(SEA_COTTAGE, 10, 7, NORTH), "the Clefairy walks up into the right teleporter"), - running(route("pc_front", at(SEA_COTTAGE, 4, 6, NORTH), "below the PC (4, 5), facing it")), - talk("cell_separator", "the PC: \" initiated the TELEPORTER's CELL SEPARATOR!\""), - scene("bill_comes_out", at(SEA_COTTAGE, 4, 6, NORTH), "the teleporters run; Bill comes out of the left one and walks to (7, 6)"), - running(legs("beside_bill", {{EAST, 2}}, "to (6, 6), west of Bill, facing him")), - talk("thank_bill", "\"Thanks, bud! ... take this\""), - scene("ss_ticket", at(SEA_COTTAGE, 6, 6, EAST), "the S.S. TICKET; \"... the S.S. ANNE ... go instead\""), - running(legs("around_bill", {{SOUTH, 2}, {EAST, 1}}, "to (7, 8), above the mat; Bill stands on (7, 6) after his scene")), - running(route("out_of_cottage", at(ROUTE25, 51, 5, SOUTH), "down to the mat and out; the door puts the player below it")), - }); -} - -// Back to Cerulean by Route 25's south path (Route25 map.json): from -// below the cottage down column 51 to row 12, west along row 12 and row -// 11 into Route 24 (x 14..23, row 11), and down its column 14..16 east -// of Nugget Bridge to Cerulean's north edge (x 26..28, offset 12). No -// trainer stands on it. Cerulean's row 1 there is a ledge (26..28, 1), -// hopped south from (27, 0); then on into the city to the Pokemon Center. -StoryCheckpoint back_to_cerulean(){ - return row("00.19", "Route 25's south path back to Cerulean's Pokemon Center", at(ROUTE25, 51, 5, SOUTH), after_brock(), StartMenu::FULL, { - running(route("above_cerulean_ledge", at(CERULEAN, 27, 0, SOUTH), "Route 25's south path west, Route 24 east of the bridge south, to above Cerulean's ledge (27, 1)")), - hop("cerulean_ledge_hop", SOUTH, at(CERULEAN, 27, 2, SOUTH), "down the ledge (27, 1)"), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "into the city to the Pokemon Center")), - heal("heal_cerulean"), - }); -} - -// Stopgap for console B's save, which caught nothing on Route 1. A new -// playthrough should instead catch a Rattata on Route 1 or 22 early, as -// its Cut user and spare member, and drop this row (and its walk over -// Nugget Bridge and back). -// -// An Oddish for HM01 Cut, and a second member behind the lead -// (docs/design/AutoStory-FRLG-FutureEvents.md, "Console B run choices"). -// Route 24's grass (Route24 map.json: x 3..5, rows 19..31, west of Nugget -// Bridge) is the nearest to the Center with Oddish: FireRed's -// sRoute24_FireRed (pokefirered wild_encounters.json) has it in 25% of -// battles, Lv12..14, as Route 25's grass; Routes 5 and 6 aren't on the -// story's maps yet. Up the bridge, whose trainers 00.16 beat, west along -// rows 10..15 to the cliff (3, 15) and down column 3 to the grass's first -// row, (3, 19); the step paces east to (4, 19) and back. Camper Shane -// (5, 21) faces north, sight 5, over (5, 16..20): column 5 is kept off. -// The leg west ends on the cliff, not open: on console B (m63) an open -// leg west to (4, 15) ended a tile short, and the walk down column 5 -// came into Shane's sight. -// -// First 7 Poke Balls at the Mart (row 1, 200 each; the bag isn't read, so -// the step buys them whatever the bag holds). The floor, from 00.15's -// 1500 less its 1400: the rival's 288 (4 x 18 x 4), the Rocket's 480 (4 -// x 15 x 8), Franklin's 540 and Nob's 468 (hikers, 9) alone make 1876 -// (pokefirered gTrainerMoneyTable). An Oddish at full HP (catch rate 255) -// stays in a Poke Ball about 1 time in 3 (Gen 3: a = 85, four shakes of -// 0.76), so 7 balls catch it about 94% of the time; the step throws 7 at -// most, in 30 battles (none an Oddish: 0.02%). Nothing weakens it: the HP -// bar isn't read on the console yet. -// -// The Oddish joins the party second. Battles keep the lead in -// (PokemonFRLG_AutoStoryBattleDecisions.h): the Oddish is sent only when -// the lead faints in a trainer's battle, which counts as lost. Back to -// the nurse, and the save in the Center. -StoryCheckpoint oddish(){ - const MartPlan balls{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "poke-ball", .quantity = 7}}, - .budget = 1400, - .money_floor = 1500, - }; - const CapturePlan catch_oddish{.species = "oddish", .catches = 1, .max_encounters = 30, .max_balls = 7, .pace = EAST}; - return row("00.20", "Route 24's grass: an Oddish for Cut, then the Center", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_poke_balls", "7 Poke Balls for the Oddish", balls), - running(route("oddish_patch", at(ROUTE24, 3, 19), "north over Nugget Bridge, west to the cliff and down column 3 onto the grass's first row, out of Shane's column 5")), - capture_step("catch_oddish", "wild battles until an Oddish, then Poke Balls; any other species is run from", catch_oddish), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back over the bridge to the Center")), - heal("heal_cerulean"), - }); -} - - -// Cerulean's only way south without Cut (CeruleanCity map.json, -// scripts.inc) is through the burgled house (30, 11), whose door the -// policeman leaves once the S.S. TICKET is had, out of the hole in its -// back wall into the yard (31, 8). The Rocket there (33, 6) stops the -// player on (33, 5) or (33, 7) (CeruleanCity_EventScript_GruntTrigger*): -// from (32, 7), the step east onto (33, 7) turns the player to him; -// Machop and Drowzee, Lv17, then TM28 Dig, and he is gone. Then east -// round the yard, down to the city's south edge by the path along its -// east side (39..40, 20..31), down Route 5's east side to the -// Underground Path's north house (31, 31), through its tunnel and out of -// the south house onto Route 6, below its door (19, 14). Route 6: -// - Bug Catcher Keigo (3, 16) faces east, sight 5, over the middle path -// (4..8, 16); Bug Catcher Elijah (20, 25) faces west, sight 3, over -// the east path (17..19, 25). The way goes down column 15, through the -// grass to the wall (15, 33), out of both lines; the open leg west to -// it, a tile short, leaves the player on column 16, out of them too. -// - Camper Ricky and Picnicker Nancy (12..13, 21) battle only when -// talked to. -// - Picnicker Isabelle (13, 32) and Camper Jeff (13, 33) face west, sight -// 3, over (10..12, 32) and (10..12, 33); the only way south, (10..12, -// 34), is from Jeff's row. Up to (15, 31), west to the wall (7, 31), -// down to the wall (7, 33), east: Jeff is fought on the step onto -// (10, 33) and walks up to (11, 33). Isabelle's row is kept off. -// Then down into Vermilion City (offset 12) to its Pokemon Center. -StoryCheckpoint to_vermilion(){ - return row("00.21", "The Cerulean Rocket, Route 5, the Underground Path and Route 6 to Vermilion's Pokemon Center: Jeff", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("west_of_rocket", at(CERULEAN, 32, 7, EAST), "through the burgled house and out of the hole in its back wall, west of the Rocket (33, 6)")), - step_into("rocket_trigger", EAST, "onto (33, 7), below the Rocket"), - battle("rocket_grunt", at(CERULEAN, 33, 7, NORTH), false, "Machop and Drowzee, Lv17; TM28 Dig"), - running(route("route6_column15", at(ROUTE6, 15, 14), "round the yard and down Cerulean's east side, Route 5 into the Underground Path, through it onto Route 6, west to column 15")), - running(legs("round_keigo_and_elijah", { - {SOUTH, 19}, {NORTH, 1}, {NORTH, 1}, {WEST, 8}, {SOUTH, 2}, {EAST, 2}, - }, "down column 15 to the wall (15, 33); up to (15, 31), west to the wall (7, 31), down to the wall (7, 33), east to (9, 33)")), - into_line("jeff_line", EAST, "onto (10, 33), in Jeff's line"), - battle("camper_jeff", at(ROUTE6, 10, 33, EAST), false, "Spearow and Raticate, Lv16; Jeff stops at (11, 33)"), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "down Route 6's south path into Vermilion City, to the Pokemon Center")), - heal("heal_vermilion"), - }); -} - -// The S.S. Anne (VermilionCity, SSAnne_* scripts.inc). The step onto -// (23, 33) (VermilionCity_EventScript_CheckTicket) has the sailor (24, 33) -// ask for a ticket; the S.S. TICKET (00.18) is shown and the player turns -// east to him. Then onto the pier (23, 34), along the gangway, through -// 1F, by legs off its cabins' doormats on row 10, which planned routes -// cross, and up its stairs (3, 8) to 2F. The step onto (30, 6), below the -// Captain's door (30, 2) (SSAnne_2F_Corridor_EventScript_RivalTriggerLeft), -// brings the rival out and down to (30, 5); the player keeps facing -// north, and after the battle he walks round the player and off. For a -// player who took Squirtle: Pidgeotto Lv19, Raticate Lv16, Kadabra Lv18, -// Ivysaur Lv20. The ship's trainers are in its cabins and on its deck, -// off the way. The Captain (5, 4) faces up; talked to from (5, 5) he is -// rubbed on the back and gives HM01 (VAR_MAP_SCENE_VERMILION_CITY 1). -// Back out through 1F's door (19, 1): on the gangway the ship sails -// (SSAnne_Exterior_ExitSSAnne), the player is put on (23, 34) and walked -// up to (23, 32) (VermilionCity_EventScript_ExitSSAnne). Cut is taught -// later, to the Oddish. -StoryCheckpoint ss_anne(){ - return row("00.22", "The S.S. Anne: the rival, HM01 Cut from the Captain, back to Vermilion's Pokemon Center", at(VERMILION_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("above_ticket_check", at(VERMILION, 23, 32, SOUTH), "out of the Center down to the harbor, above the ticket check (23, 33)")), - step_into("ticket_check", SOUTH, "onto (23, 33): \"Do you have a ticket?\""), - scene("show_ss_ticket", at(VERMILION, 23, 33, EAST), "the S.S. TICKET; the player turns to the sailor"), - running(route("aboard", at(SS_ANNE_1F, 19, 2, SOUTH), "onto the pier, along the gangway and in by 1F's door, a step below it")), - running(legs("past_the_cabins", {{SOUTH, 8}, {NORTH, 1}, {WEST, 6}, {NORTH, 1}}, "to the wall (19, 10), up a step, west to the worker (12, 9), up a step to (13, 8): off the cabins' mats on row 10")), - running(route("below_rival_trigger", at(SS_ANNE_2F, 30, 7, NORTH), "west along 1F, up the stairs (3, 8) and along 2F below the Captain's door")), - step_into("rival_trigger", NORTH, "onto (30, 6): the rival comes out of the Captain's door"), - battle("rival_ss_anne", at(SS_ANNE_2F, 30, 6, NORTH), false, "Pidgeotto, Raticate, Kadabra and Ivysaur"), - running(route("behind_captain", at(CAPTAINS_OFFICE, 5, 5, NORTH), "into the Captain's office, behind the Captain (5, 4)")), - talk("captain", "\"Ooargh... I feel hideous... Urrp! Seasick...\""), - scene("hm01_cut", at(CAPTAINS_OFFICE, 5, 5, NORTH), "the player rubs his back; HM01, and what Cut does"), - running(route("off_2f", at(SS_ANNE_1F, 13, 8), "back along 2F, down the stairs and east along 1F's row 8")), - running(legs("round_the_sailor", {{EAST, 4}, {SOUTH, 1}, {EAST, 2}}, "to the sailor (18, 8), down a step, east to (19, 9): off the cabins' mats on row 10")), - running(route("below_ship_door", at(SS_ANNE_1F, 19, 2, NORTH), "up below the door to the gangway")), - step_into("off_the_ship", NORTH, "out onto the gangway"), - scene("ss_anne_sails", at(VERMILION, 23, 32, NORTH), "the ship sails; the player is walked off the pier to (23, 32)"), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "back to the Pokemon Center")), - heal("heal_vermilion"), - }); -} - - -// HM01 Cut, from the S.S. Anne (00.22), to the Oddish (00.20), second in -// the party: a wild Oddish of Lv12 to 14 knows 2 or 3 moves (Absorb, -// Sweet Scent, Poison Powder at 14), so it has room. TM28 Dig, from the -// Cerulean Rocket (00.21), to the lead in place of Withdraw: Ground, twice -// as strong on Lt. Surge's three, it takes the sim's chance against him -// for a Lv28 Wartortle with 14 Potions from 6% to 47%. Vermilion's tree -// (19, 24) (EventScript_CutTree) is the only way into the gym's yard, -// row 24 being walls but for it; the gym's door is (14, 25). In the gym, -// the trainers as above, then the trash cans until the door opens; out, -// the tree cut again from below, and back to the nurse. -StoryCheckpoint vermilion_gym(){ - const TeachPlan cut{.item = "hm01", .move = "cut", .member = 1}; - const TeachPlan dig{.item = "tm28", .move = "dig", .member = 0, .forget_move = "withdraw"}; - return row("00.23", "Vermilion Gym: Cut and Dig, the tree, Dwayne, Baily and Tucker, the trash cans", at(VERMILION_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_cut", "HM01 Cut to the Oddish, second in the party, unless it knows it", cut), - teach_step("teach_dig", "TM28 Dig in place of Withdraw, for Lt. Surge, unless the lead knows it or there is no TM28", dig), - running(route("above_gym_tree", at(VERMILION, 19, 23, SOUTH), "out of the Center, south through the city to above the tree (19, 24)")), - cut_tree("cut_gym_tree", at(VERMILION, 19, 24, SOUTH), "the Oddish cuts the tree; a step onto its tile"), - running(route("gym_door", at(VERMILION_GYM, 5, 19, NORTH), "down into the yard and in by the gym's door (14, 25)")), - running(legs("west_of_dwayne_line", {{NORTH, 4}, {EAST, 2}}, "up column 5 to the can (5, 14), east to (7, 15): out of Dwayne's and Baily's sight")), - into_sight("dwayne_sight", EAST, "onto (8, 15), two below Dwayne (8, 13): he turns to the player and walks up to (8, 14)"), - battle("sailor_dwayne", at(VERMILION_GYM, 8, 15, NORTH), false, "two Pikachu, Lv21"), - running(legs("east_of_baily_line", {{WEST, 4}, {NORTH, 2}, {WEST, 1}}, "west along row 15 to (4, 15), up to (4, 13), west to (3, 13): out of Baily's sight")), - into_sight("baily_sight", WEST, "onto (2, 13), two below Baily (2, 11): he turns to the player and walks up to (2, 12)"), - battle("engineer_baily", at(VERMILION_GYM, 2, 13, NORTH), false, "Voltorb and Magnemite, Lv21"), - running(legs("below_tucker_line", {{EAST, 2}, {NORTH, 4}, {EAST, 1}}, "east to (4, 13), up column 4 past Baily's row to (4, 9), east to (5, 9): below Tucker's line, not on it")), - into_line("tucker_line", NORTH, "onto (5, 8), in Tucker's line: he walks up to (6, 8)"), - battle("gentleman_tucker", at(VERMILION_GYM, 5, 8, EAST), false, "Pikachu, Lv23"), - trash_cans("trash_cans", "the cans until both locks open; a wrong second can resets them"), - running(route("below_gym_tree", at(VERMILION, 19, 25, NORTH), "out of the gym, east to below the tree, grown back")), - cut_tree("cut_tree_out", at(VERMILION, 19, 24, NORTH), "the tree again; a step onto its tile"), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "north through the city to the Pokemon Center")), - heal("heal_vermilion"), - }); -} - -// Wild battles on Route 6 until the sim beats Lt. Surge half the time: -// with Dig, 47% at Lv28 and 51% at Lv29, so a lead the gym's trainers -// have brought to Lv29 passes at once, and a Lv28 one after a level. The grass nearest the city is Route 6's -// south patch (13..16, 30..33); Picnicker Isabelle (13, 32) faces west -// over (10..12, 32), on the way north from the city, so the walk goes -// along Jeff's row 33 (he is beaten) to the wall (7, 33), up to row 31 -// and east along it onto the patch's west edge, (13, 31), above -// Isabelle, out of her line. Back to the nurse the same way. -// All that is skipped when the lead, read in the Center, passes already. -// Then the tree, the gym, whose trainers stand where the map has them, -// beaten, and whose beams stay off (FLAG_FOUND_BOTH_VERMILION_GYM_SWITCHES): -// up column 5 to below Lt. Surge, and saved there. -StoryCheckpoint to_lt_surge(){ - constexpr const char* SURGE_WINNABLE = "surge_winnable"; - const GrindPlan for_surge{ - .member = 0, .level = 32, .max_encounters = 150, .pace = EAST, .heal_every = 0, - .trainer = std::string(story_trainer(VERMILION_GYM, "lt_surge").value_or("")), .min_chance = MIN_WIN_CHANCE, - }; - return row("00.24", "Route 6's grass until Lt. Surge is winnable, then through the open beams to him", at(VERMILION_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - grind_check_step(SURGE_WINNABLE, "the lead as it is: if the sim beats Lt. Surge 50% or more already, no trip to Route 6", for_surge), - unless(SURGE_WINNABLE, running(route("route6_south_path", at(ROUTE6, 11, 34, NORTH), "out of the Center, north out of the city onto Route 6's path, below Jeff's row"))), - unless(SURGE_WINNABLE, running(legs("round_isabelle_line", {{NORTH, 1}, {WEST, 4}, {NORTH, 2}, {EAST, 5}, {EAST, 1}}, "onto Jeff's row (11, 33), west to the wall (7, 33), up to (7, 31), east along row 31 to (12, 31) and a step onto the grass, (13, 31): out of Isabelle's line"))), - unless(SURGE_WINNABLE, grind_step("grind_for_surge", "wild battles until the sim beats Lt. Surge 50% or more, Lv32 at most; the nurse when hurt or low on PP", for_surge, at(VERMILION_CENTER, 7, 4, NORTH))), - unless(SURGE_WINNABLE, running(route("west_on_row_31", at(ROUTE6, 7, 31), "west along row 31, out of the grass, to the wall (7, 31)"))), - unless(SURGE_WINNABLE, running(legs("down_to_jeff_row", {{SOUTH, 2}, {EAST, 4}}, "down to the wall (7, 33), east along Jeff's row to (11, 33): out of Isabelle's line"))), - unless(SURGE_WINNABLE, running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "south into the city to the Pokemon Center"))), - unless(SURGE_WINNABLE, heal("heal_vermilion")), - running(route("above_gym_tree", at(VERMILION, 19, 23, SOUTH), "out of the Center, south through the city to above the tree (19, 24)")), - cut_tree("cut_gym_tree", at(VERMILION, 19, 24, SOUTH), "the tree; a step onto its tile"), - running(route("below_lt_surge", at(VERMILION_GYM, 5, 3, NORTH), "into the gym, up round the cans and through the beams, off, to below Surge (5, 2)")), - }); -} - -// Lt. Surge (5, 2), talked to from below, from the save in front of him: -// Voltorb Lv21, Pikachu Lv18 and Raichu Lv24, Shock Wave and Thunder -// Wave, a Super Potion and a Full Heal (sParty_LeaderLtSurge); then the -// THUNDERBADGE and TM34, read to the overworld with the battle's text. -// Out, the tree, and the nurse. Surge's win also puts Oak's aide on -// Vermilion City's (25, 7) (VermilionCity_Gym_EventScript_ShowOaksAide), -// where he stays until talked to; the story's maps don't have him. The -// way to the nurse along row 7 runs into him (console B, 2026-11-03: the -// leg west stopped beside him and the step into the Center's door went -// into a house), so it goes along row 10 to the water instead, clear of -// him, and up column 14 from there. -StoryCheckpoint lt_surge(){ - return row("00.25", "Vermilion Gym: Lt. Surge, the THUNDERBADGE, then the Center", at(VERMILION_GYM, 5, 3, NORTH), after_brock(), StartMenu::FULL, { - talk("challenge_lt_surge", "\"Hey, kid! What do you think you're doing here?\""), - battle("lt_surge", at(VERMILION_GYM, 5, 3, NORTH), false, "Voltorb, Pikachu and Raichu; THUNDERBADGE and TM34"), - running(route("below_gym_tree", at(VERMILION, 19, 25, NORTH), "down through the beams, out of the gym, east to below the tree, grown back")), - cut_tree("cut_tree_out", at(VERMILION, 19, 24, NORTH), "the tree; a step onto its tile"), - running(route("below_oaks_aide", at(VERMILION, 14, 10), "north through the city and west along row 10 to the water, (14, 10): off Oak's aide's row 7")), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "up to the Pokemon Center")), - heal("heal_vermilion"), - }); -} - - -std::vector cpp_rows(){ - return { - new_game(), after_sid_helper(), leave_house(), oaks_trigger(), to_starter_ball(), starter(), parcel(), pokedex(), shopping(), forest(), brock(), - running_shoes(), route3(), magikarp_salesman(), after_gift_rng(), magikarp_to_box(), mt_moon(), - route4_to_cerulean(), cerulean_gym(), misty(), cerulean_grind(), cerulean_rival(), nugget_bridge(), - route25(), bill(), back_to_cerulean(), oddish(), to_vermilion(), ss_anne(), - vermilion_gym(), to_lt_surge(), lt_surge(), - }; -} - -// Why `loaded` differs from `row`, or empty. Steps compare as their -// shared JSON, which writes every field. -std::string checkpoint_difference(const StoryCheckpoint& row, const StoryCheckpoint& loaded){ - const std::string row_json = Pokemon::story_checkpoint_json(row).dump(); - const std::string loaded_json = Pokemon::story_checkpoint_json(loaded).dump(); - if (row_json != loaded_json){ - return std::format("{}: the file loads to\n{}\nbut the C++ row is\n{}", row.id, loaded_json, row_json); - } - if (row.handoff != loaded.handoff || row.live_start != loaded.live_start){ - return row.id + ": a different handoff or live start."; - } - for (size_t c = 0; c < row.steps.size() && c < loaded.steps.size(); c++){ - if (row.steps[c].once_per_save != loaded.steps[c].once_per_save){ - return row.id + "/" + row.steps[c].name + ": a different once_per_save."; - } - } - if (row.menu != loaded.menu){ - return row.id + ": a different START menu."; - } - const Supplies& a = row.supplies; - const Supplies& b = loaded.supplies; - if (a.potions != b.potions || a.antidotes != b.antidotes || a.parlyz_heals != b.parlyz_heals){ - return row.id + ": different supplies."; - } - if (a.lead.species != b.lead.species || a.lead.level != b.lead.level || a.lead.moves.size() != b.lead.moves.size()){ - return row.id + ": a different lead."; - } - for (size_t c = 0; c < a.lead.moves.size(); c++){ - if (a.lead.moves[c].move != b.lead.moves[c].move || a.lead.moves[c].pp != b.lead.moves[c].pp){ - return row.id + ": a different lead move " + std::to_string(c + 1) + "."; - } - } - return ""; -} - -class Test_AutoStoryTableParity : public UnitTest{ -public: - Test_AutoStoryTableParity() - : UnitTest("PokemonFRLG::AutoStory - the story files load to the C++ rows") - {} - virtual UnitTestResult run(Logger&, CancellableScope&) const override{ - try{ - const std::vector rows = cpp_rows(); - const std::vector& loaded = story_checkpoints(); - if (rows.size() != loaded.size()){ - return std::format("{} C++ rows, {} files.", rows.size(), loaded.size()); - } - for (size_t c = 0; c < rows.size(); c++){ - const std::string difference = checkpoint_difference(rows[c], loaded[c]); - if (!difference.empty()){ - return difference; - } - } - return true; - }catch (Exception& e){ - return std::string(e.name()) + ": " + e.message(); - } - } -}; - -} // namespace - - -void add_tests_AutoStoryTableParity(UnitTestDatabase& database){ - database.add(); -} - - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp index f0b505add0..cf0a82699c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -985,7 +985,6 @@ const AutoStoryTestCase AUTO_STORY_CASES[] = { void add_tests_AutoStory(UnitTestDatabase& database){ add_tests_AutoStoryRunPlan(database); - add_tests_AutoStoryTableParity(database); for (const auto& scenario : AUTO_STORY_CASES){ database.add(scenario); } diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 724e12a3fe..326d413f92 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1990,7 +1990,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryExport_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach_Tests.cpp From 9d78b8251afa04ddeb4001aa1913e6ca66ffea93 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 11:15:58 -0800 Subject: [PATCH 8/8] FRLG AutoStory: delete stage 7's C++ story rows, parity proven The parity test passed on the merge before this commit: every StoryData file through 00.27 loads to the C++ row it replaces. The row tests' registrations move to PokemonFRLG_AutoStoryRows_Tests.h and Viridian's SHOP step to PokemonFRLG_AutoStoryViridianMart, which keeps the story table header and the events file within their size limits; the shop is moved unchanged but for reading its args through story_arg. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonFRLG/PokemonFRLG_Tests.cpp | 2 +- .../PokemonFRLG_AutoStoryCeladon_Tests.cpp | 1 + .../AutoStory/PokemonFRLG_AutoStoryEvents.cpp | 69 +- .../AutoStory/PokemonFRLG_AutoStoryEvents.h | 4 - .../AutoStory/PokemonFRLG_AutoStoryRowSim.cpp | 1 + .../PokemonFRLG_AutoStoryRows_Tests.h | 31 + .../AutoStory/PokemonFRLG_AutoStoryTable.h | 10 +- ...PokemonFRLG_AutoStoryTableParity_Tests.cpp | 1308 ----------------- ...okemonFRLG_AutoStoryVermilionGym_Tests.cpp | 1 + .../PokemonFRLG_AutoStoryVermilion_Tests.cpp | 1 + .../PokemonFRLG_AutoStoryViridianMart.cpp | 94 ++ .../PokemonFRLG_AutoStoryViridianMart.h | 36 + .../AutoStory/PokemonFRLG_AutoStory_Tests.cpp | 1 - SerialPrograms/cmake/SourceFiles.cmake | 4 +- 14 files changed, 172 insertions(+), 1391 deletions(-) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h delete mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.h diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp index 2bf7183092..89651ccde3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/PokemonFRLG_Tests.cpp @@ -51,6 +51,7 @@ #include "Programs/AutoStory/PokemonFRLG_AutoStoryPaceSim.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryPcStorage.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryRngLoop.h" +#include "Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryTable.h" #include "Programs/AutoStory/PokemonFRLG_AutoStoryTrashCans.h" #include "Programs/AutoStory/Data/Json_Tests.h" @@ -890,7 +891,6 @@ static void add_tests_Naming(UnitTestDatabase& database){ add_tests_NamingText(database); } -// The story's rows on the overworld sim, a file of tests per stage. static void add_tests_AutoStoryRows(UnitTestDatabase& database){ add_tests_AutoStoryVermilion(database); add_tests_AutoStoryVermilionGym(database); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladon_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladon_Tests.cpp index 39596cdcdc..d82280fc15 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladon_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryCeladon_Tests.cpp @@ -29,6 +29,7 @@ #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryMart.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryTable.h" namespace PokemonAutomation{ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp index 74993619c9..b6ee0a71ab 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp @@ -28,6 +28,7 @@ #include "PokemonFRLG_AutoStoryTable.h" #include "PokemonFRLG_AutoStoryTeachScreens.h" #include "PokemonFRLG_AutoStoryTrashCans.h" +#include "PokemonFRLG_AutoStoryViridianMart.h" #include "PokemonFRLG_AutoStoryWinChance.h" namespace PokemonAutomation{ @@ -290,75 +291,9 @@ Outcome get_ready(StoryEnv& env, RunState& state, const StoryStep& step){ return walked; } -// Viridian Mart before the Boulder Badge (pokefirered ViridianCity_Mart_Items): -// POKE BALL, POTION (300), ANTIDOTE (100), PARLYZ HEAL (200). Each item -// the story buys: its row, and where the bag's count is kept. -struct MartItem{ - const char* item; - int row; - int Supplies::* count; - // The name the item list reader reads (read_item_list_name()). - const char* slug; -}; -constexpr MartItem VIRIDIAN_MART_ITEMS[] = { - {.item = "potion", .row = 1, .count = &Supplies::potions, .slug = "potion"}, - {.item = "antidote", .row = 2, .count = &Supplies::antidotes, .slug = "antidote"}, - {.item = "parlyz_heal", .row = 3, .count = &Supplies::parlyz_heals, .slug = "parlyz-heal"}, -}; - -const MartItem* viridian_mart_item(const std::string& name){ - for (const MartItem& item : VIRIDIAN_MART_ITEMS){ - if (name == item.item){ - return &item; - } - } - return nullptr; -} - -Outcome shop(StoryEnv& env, const StoryStep& step){ - const std::optional> orders = viridian_mart_orders(arg>(step, "items")); - if (!orders){ - return Pokemon::outcome_failed("unknown_item", step.name); - } - // 2000 of the 3000 a new game starts with, plus the rival's prize. - buy_items(env.console, env.context, *orders, env.checks, env.language); - for (const Pokemon::StoryItem& item : arg>(step, "items")){ - env.supplies.*viridian_mart_item(item.item)->count += (int)item.quantity; - } - if (!checks_screen(env.checks)){ - return Pokemon::outcome_ok(); - } - // The counts from the bag, not from the orders: a wrong row once bought - // Parlyz Heals for Antidotes unnoticed (console B, 2026-11-01). - const std::vector rows = read_items_pocket(env.console, env.context, env.language); - if (rows.empty()){ - env.console.log("Story: couldn't read the Items pocket; keeping the counts ordered.", COLOR_ORANGE); - return Pokemon::outcome_ok(); - } - for (const std::string& item : set_from_bag(env.supplies, rows)){ - env.console.log(std::format( - "Story: couldn't read how many {} the bag holds; counting {}.", - item, item_count(env.supplies, item) - ), COLOR_ORANGE); - } - return Pokemon::outcome_ok(); -} - } // namespace -std::optional> viridian_mart_orders(const std::vector& items){ - std::vector orders; - for (const Pokemon::StoryItem& wanted : items){ - const MartItem* found = viridian_mart_item(wanted.item); - if (found == nullptr){ - return std::nullopt; - } - orders.push_back(MartOrder{found->row, (int)wanted.quantity, found->slug}); - } - return orders; -} - const RouteCosts& story_route_costs(){ static const RouteCosts COSTS = []{ RouteCosts costs = default_route_costs(); @@ -786,7 +721,7 @@ ConsoleAction console_action_of(StoryActionId id){ return Pokemon::outcome_ok(); }; case StoryActionId::SHOP: - return [](StoryEnv& env, RunState&, const StoryStep& step){ return shop(env, step); }; + return [](StoryEnv& env, RunState&, const StoryStep& step){ return viridian_shop(env, step); }; case StoryActionId::READY: return get_ready; default: diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h index 05845a4d70..e025560140 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.h @@ -239,10 +239,6 @@ std::optional> plan_story_route( // into a sign would read it. std::optional wall_beside(const MapData& map, const TilePos& tile); -// `items` as orders at the Viridian Mart before the Boulder Badge: the -// rows of POKE BALL, POTION, ANTIDOTE, PARLYZ HEAL. Nothing if it does -// not sell one of them. -std::optional> viridian_mart_orders(const std::vector& items); // What the story's events act on. `supplies` are what the bag holds now, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp index 2362756420..fa86f58335 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp @@ -15,6 +15,7 @@ #include "Pokemon/AutoStory/Pokemon_TilePose.h" #include "PokemonFRLG_AutoStoryActions.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryViridianMart.h" namespace PokemonAutomation{ namespace NintendoSwitch{ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h new file mode 100644 index 0000000000..2d07d000b6 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h @@ -0,0 +1,31 @@ +/* AutoStory Row Tests + * + * From: https://github.com/PokemonAutomation/ + * + * Registration of the tests that run story rows on the overworld sim, + * one file per stretch of the story. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryRows_Tests_H +#define PokemonAutomation_PokemonFRLG_AutoStoryRows_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// Rows 00.21 and 00.22 on the overworld sim (PokemonFRLG_AutoStoryVermilion_Tests.cpp). +void add_tests_AutoStoryVermilion(UnitTestDatabase& database); +// Rows 00.23 to 00.25 on the overworld sim (PokemonFRLG_AutoStoryVermilionGym_Tests.cpp). +void add_tests_AutoStoryVermilionGym(UnitTestDatabase& database); +// Rows from 00.26 on on the overworld sim (PokemonFRLG_AutoStoryCeladon_Tests.cpp). +void add_tests_AutoStoryCeladon(UnitTestDatabase& database); + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h index 51d8b8d18d..ec960d1f99 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h @@ -59,7 +59,7 @@ const std::vector>& autostory_checkpoint_jso // action args it doesn't take, or has notes for a step it doesn't have. StoryCheckpoint read_story_checkpoint_file(const JsonValue& value, std::string_view source); -// Checkpoints 00.01 to 00.25, in order: every file in StoryData/. With +// Checkpoints 00.01 to 00.27, in order: every file in StoryData/. With // 00.01b, the way back in after SID Helper, after 00.01, 00.04 split in two at Squirtle's ball for // Starter RNG: 00.04 and 00.04b, 00.12b, the way back in after Gift RNG, // after 00.12, 00.12c, the Magikarp put in BOX 1, after it, 00.14b and @@ -71,18 +71,10 @@ const std::vector& story_checkpoints(); // Registers AutoStory table validation unit tests. void add_tests_AutoStory(UnitTestDatabase& database); -// The story files against the C++ rows they replace. -void add_tests_AutoStoryTableParity(UnitTestDatabase& database); // Which rows a run takes (PokemonFRLG_AutoStoryRunPlan_Tests.cpp). void add_tests_AutoStoryRunPlan(UnitTestDatabase& database); // The table run end to end against a fake game (PokemonFRLG_AutoStorySimulation_Tests.cpp). void add_tests_AutoStorySimulation(UnitTestDatabase& database); -// Rows 00.21 and 00.22 on the overworld sim (PokemonFRLG_AutoStoryVermilion_Tests.cpp). -void add_tests_AutoStoryVermilion(UnitTestDatabase& database); -// Rows 00.23 to 00.25 on the overworld sim (PokemonFRLG_AutoStoryVermilionGym_Tests.cpp). -void add_tests_AutoStoryVermilionGym(UnitTestDatabase& database); -// Rows from 00.26 on on the overworld sim (PokemonFRLG_AutoStoryCeladon_Tests.cpp). -void add_tests_AutoStoryCeladon(UnitTestDatabase& database); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp deleted file mode 100644 index f2bb2ee056..0000000000 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp +++ /dev/null @@ -1,1308 +0,0 @@ -/* AutoStory Table Parity Tests - * - * From: https://github.com/PokemonAutomation/ - * - * The C++ rows the story table had before StoryData/, built with the - * shared step API, against the checkpoints read from the files: each - * loads to the same steps, args (with the fallbacks the reader fills in), - * poses, supplies and START menu. Removed with the C++ rows. - * - */ - -#include -#include -#include -#include -#include "Common/Cpp/Exceptions.h" -#include "Common/Cpp/TestRunners/UnitTest.h" -#include "Pokemon/AutoStory/Data/Pokemon_StoryStepJson.h" -#include "PokemonFRLG_AutoStoryCapture.h" -#include "PokemonFRLG_AutoStoryChoice.h" -#include "PokemonFRLG_AutoStoryBattleData.h" -#include "PokemonFRLG_AutoStoryGrind.h" -#include "PokemonFRLG_AutoStoryMart.h" -#include "PokemonFRLG_AutoStoryParty.h" -#include "PokemonFRLG_AutoStoryTable.h" -#include "PokemonFRLG_AutoStoryTeach.h" -#include "PokemonFRLG_AutoStoryTrashCans.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonFRLG{ - - -namespace{ - -constexpr Direction NORTH = Direction::NORTH; -constexpr Direction SOUTH = Direction::SOUTH; -constexpr Direction EAST = Direction::EAST; -constexpr Direction WEST = Direction::WEST; - -constexpr std::string_view BEDROOM = "PalletTown_PlayersHouse_2F"; -constexpr std::string_view PALLET = "PalletTown"; -constexpr std::string_view LAB = "PalletTown_ProfessorOaksLab"; -constexpr std::string_view VIRIDIAN = "ViridianCity"; -constexpr std::string_view VIRIDIAN_MART = "ViridianCity_Mart"; -constexpr std::string_view VIRIDIAN_CENTER = "ViridianCity_PokemonCenter_1F"; -constexpr std::string_view FOREST = "ViridianForest"; -constexpr std::string_view FOREST_GATE = "Route2_ViridianForest_NorthEntrance"; -constexpr std::string_view PEWTER = "PewterCity"; -constexpr std::string_view PEWTER_CENTER = "PewterCity_PokemonCenter_1F"; -constexpr std::string_view GYM = "PewterCity_Gym"; -constexpr std::string_view ROUTE3 = "Route3"; -constexpr std::string_view ROUTE4 = "Route4"; -constexpr std::string_view ROUTE4_CENTER = "Route4_PokemonCenter_1F"; -constexpr std::string_view MT_MOON_1F = "MtMoon_1F"; -constexpr std::string_view MT_MOON_B2F = "MtMoon_B2F"; -constexpr std::string_view CERULEAN = "CeruleanCity"; -constexpr std::string_view CERULEAN_CENTER = "CeruleanCity_PokemonCenter_1F"; -constexpr std::string_view CERULEAN_MART = "CeruleanCity_Mart"; -constexpr std::string_view CERULEAN_GYM = "CeruleanCity_Gym"; -constexpr std::string_view ROUTE24 = "Route24"; -constexpr std::string_view ROUTE25 = "Route25"; -constexpr std::string_view SEA_COTTAGE = "Route25_SeaCottage"; -constexpr std::string_view ROUTE6 = "Route6"; -constexpr std::string_view VERMILION = "VermilionCity"; -constexpr std::string_view VERMILION_CENTER = "VermilionCity_PokemonCenter_1F"; -constexpr std::string_view VERMILION_GYM = "VermilionCity_Gym"; -constexpr std::string_view SS_ANNE_1F = "SSAnne_1F_Corridor"; -constexpr std::string_view SS_ANNE_2F = "SSAnne_2F_Corridor"; -constexpr std::string_view CAPTAINS_OFFICE = "SSAnne_CaptainsOffice"; -constexpr std::string_view FAN_CLUB = "VermilionCity_PokemonFanClub"; -constexpr std::string_view BIKE_SHOP = "CeruleanCity_BikeShop"; -constexpr std::string_view ROUTE9 = "Route9"; -constexpr std::string_view ROUTE10 = "Route10"; -constexpr std::string_view ROUTE10_CENTER = "Route10_PokemonCenter_1F"; - -Pokemon::GridPose at(std::string_view map, int x, int y, std::optional facing = std::nullopt){ - return Pokemon::GridPose{std::string(map), {{x, y}}, facing}; -} - -StoryCheckpoint row( - std::string id, std::string title, std::optional start, - Supplies supplies, StartMenu menu, std::vector steps -){ - StoryCheckpoint checkpoint; - checkpoint.id = std::move(id); - checkpoint.title = std::move(title); - checkpoint.start = std::move(start); - checkpoint.steps = std::move(steps); - checkpoint.supplies = supplies; - checkpoint.menu = menu; - return checkpoint; -} - -Supplies after_brock(){ - Supplies supplies; - supplies.lead = story_lead_after_brock(); - return supplies; -} - -// What a walk does about wild Pokemon: runs, or fights them for EXP. -enum class WildBattles{ - RUN, - FIGHT, -}; - -StoryStep make(StoryStepKind kind, std::string name, std::string why, Pokemon::StoryActionArgs args = {}){ - StoryStep step; - step.kind = kind; - step.name = std::move(name); - step.why = std::move(why); - step.args = std::move(args); - return step; -} - -StoryStep route(std::string name, Pokemon::GridPose target, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::ROUTE, std::move(name), std::move(why), { - {"target", std::move(target)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -StoryStep step_into(std::string name, Direction direction, std::string why){ - return make(StoryStepKind::STEP, std::move(name), std::move(why), {{"direction", direction}}); -} - -StoryStep into_line(std::string name, Direction direction, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.action = TRAINER_LINE_VARIANT; - return step; -} - -StoryStep hop(std::string name, Direction direction, Pokemon::GridPose landing, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.pose_after = std::move(landing); - return step; -} - -StoryStep step_onto(std::string name, Direction direction, Pokemon::GridPose tile, std::string why){ - return hop(std::move(name), direction, std::move(tile), std::move(why)); -} - -StoryStep into_sight(std::string name, Direction direction, std::string why){ - StoryStep step = step_into(std::move(name), direction, std::move(why)); - step.action = TRAINER_WAIT_VARIANT; - return step; -} - -StoryStep cut_tree(std::string name, Pokemon::GridPose tree, std::string why){ - StoryStep step = make(StoryStepKind::GAME, std::move(name), std::move(why), {{"direction", tree.facing.value_or(Direction::NORTH)}}); - step.action = CUT_TREE_VARIANT; - step.pose_after = std::move(tree); - return step; -} - -StoryStep trash_cans(std::string name, std::string why){ - StoryStep step = make(StoryStepKind::GAME, std::move(name), std::move(why)); - step.action = TRASH_CANS_VARIANT; - return step; -} - -StoryStep unless(const char* flag, StoryStep step){ - step.skip_if.emplace_back(flag); - return step; -} - -StoryStep answer(std::string name, bool yes, std::string why){ - return make(StoryStepKind::ANSWER, std::move(name), std::move(why), {{"yes", yes}}); -} - -StoryStep scene(std::string name, std::optional pose_after, std::string why){ - StoryStep step = make(StoryStepKind::MASH, std::move(name), std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep battle(std::string name, Pokemon::GridPose pose_after, bool may_lose, std::string why){ - StoryStep step = make(StoryStepKind::BATTLE, std::move(name), std::move(why), {{"may_lose", may_lose}}); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep legs(std::string name, std::vector legs, std::string why, WildBattles wild = WildBattles::RUN){ - return make(StoryStepKind::LEGS, std::move(name), std::move(why), { - {"legs", std::move(legs)}, {"fight_wild", wild == WildBattles::FIGHT}, - }); -} - -// `step`, a ROUTE or LEGS, run with B held: from the Running Shoes on. -StoryStep running(StoryStep step){ - step.action = RUN_VARIANT; - return step; -} - -StoryStep new_game_intro(Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::NEW_GAME, "intro", std::move(why)); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep talk(std::string name, std::string why){ - return make(StoryStepKind::TALK, std::move(name), std::move(why)); -} - -StoryStep ready(std::string name, Pokemon::GridPose nurse, std::string why){ - return make(StoryStepKind::READY, std::move(name), std::move(why), {{"target", std::move(nurse)}}); -} - -StoryStep heal(std::string name){ - return make(StoryStepKind::HEAL, std::move(name), "full HP"); -} - -StoryStep shop(std::string name, std::vector items, std::string why){ - return make(StoryStepKind::SHOP, std::move(name), std::move(why), {{"items", std::move(items)}}); -} - -StoryStep game_step(std::string action, Pokemon::GridPose pose_after, std::string why){ - StoryStep step = make(StoryStepKind::GAME, action, std::move(why)); - step.action = std::move(action); - step.pose_after = std::move(pose_after); - return step; -} - -StoryStep options_step(){ - return make(StoryStepKind::OPTIONS, "options", "fast text; no switch prompt between a trainer's Pokemon"); -} - - -StoryCheckpoint new_game(){ - StoryCheckpoint checkpoint = row("00.01", "new game to the bedroom", std::nullopt, {}, StartMenu::BEFORE_POKEMON, { - // new_game.c: the bedroom at (6, 6), facing the TV. - new_game_intro(at(BEDROOM, 6, 6, NORTH), "Oak's speech, BOY, the player's name (default if none is set), rival GREEN"), - options_step(), - }); - checkpoint.handoff = StoryHandoff::SID_HELPER; - return checkpoint; -} - -// SID Helper confirms the name, finishes the intro and reads the Trainer -// Card from the START menu, without moving the player or saving. -StoryCheckpoint after_sid_helper(){ - StoryCheckpoint checkpoint = row("00.01b", "after SID Helper: close the Trainer Card, save in the bedroom", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - game_step(CLOSE_TRAINER_CARD, at(BEDROOM, 6, 6, NORTH), "the Trainer Card SID Helper left open, or HOME"), - options_step(), - }); - checkpoint.live_start = true; - return checkpoint; -} - -StoryCheckpoint leave_house(){ - return row("00.02", "bedroom to Pallet Town", at(BEDROOM, 6, 6, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("front_door", at(PALLET, 6, 8), "down the stairs and out of the house"), - }); -} - -StoryCheckpoint oaks_trigger(){ - return row("00.03", "Oak stops the player and walks them to the lab", at(PALLET, 6, 8, SOUTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_oaks_trigger", at(PALLET, 12, 2, NORTH), "below the north exit, short of Oak's trigger at (12, 1)"), - step_into("oaks_trigger", NORTH, "the trigger: \"Don't go out!\""), - // PlayerEnter walks the player up 8 tiles from the lab's door. - scene("to_the_lab", at(LAB, 6, 4, NORTH), "Oak walks the player into the lab; the scene ends at the table"), - }); -} - -// Starter RNG starts from a save south of the table, facing the ball. -StoryCheckpoint to_starter_ball(){ - StoryCheckpoint checkpoint = row("00.04", "to Squirtle's ball, south of the table", at(LAB, 6, 4, NORTH), {}, StartMenu::BEFORE_POKEMON, { - route("below_squirtle", at(LAB, 9, 5, NORTH), "under Squirtle's ball (9, 4)"), - }); - checkpoint.handoff = StoryHandoff::STARTER_RNG; - return checkpoint; -} - -StoryCheckpoint starter(){ - return row("00.04b", "Squirtle, then the rival's battle", at(LAB, 9, 5, NORTH), {}, StartMenu::BEFORE_POKEDEX, { - talk("squirtle_ball", "\"So, you want the WATER POKEMON SQUIRTLE?\""), - answer("choose_squirtle", true, "take Squirtle"), - answer("no_nickname", false, "\"give a nickname?\" NO"), - scene("rival_takes_bulbasaur", at(LAB, 9, 5, NORTH), "the rival picks his ball; the player still faces the table (console B, 2026-11-01)"), - route("above_rival_trigger", at(LAB, 7, 7, SOUTH), "short of the rival's trigger row 8"), - step_into("rival_trigger", SOUTH, "\"Wait, let's check out our POKEMON!\""), - // The rival leaves; PlayerWatchRivalExitAfterBattleRight ends facing down. - battle("rival_battle", at(LAB, 7, 8, SOUTH), true, "the tutorial battle; losing goes on too"), - }); -} - -StoryCheckpoint parcel(){ - return row("00.05", "Route 1 to Viridian Mart: Oak's Parcel", at(LAB, 7, 8, SOUTH), {}, StartMenu::BEFORE_POKEDEX, { - route("below_mart_door", at(VIRIDIAN, 36, 20, NORTH), "Route 1, running from wild battles"), - step_into("mart_door", NORTH, "the clerk's scene starts on entering"), - // ApproachCounter: up 4 from the mat, then faces the clerk. - scene("parcel_from_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "the clerk gives OAK'S PARCEL"), - }); -} - -StoryCheckpoint pokedex(){ - return row("00.06", "Oak's Parcel to the Pokedex", at(VIRIDIAN_MART, 4, 3, WEST), {}, StartMenu::FULL, { - route("below_oak", at(LAB, 6, 4, NORTH), "back down Route 1 to Oak"), - talk("give_parcel", "Oak takes the parcel"), - scene("pokedex_scene", at(LAB, 6, 4, SOUTH), "the rival comes in, Pokedexes from the desk; the player ends facing south (console B, 2026-11-01)"), - }); -} - -StoryCheckpoint shopping(){ - return row("00.07", "Viridian shopping, then into Viridian Forest", at(LAB, 6, 4, SOUTH), {}, StartMenu::FULL, { - route("mart_clerk", at(VIRIDIAN_MART, 4, 3, WEST), "Route 1 again"), - // 2000 of the 3000 a new game starts with, plus the rival's prize. - shop("potions_and_antidotes", {{"potion", 5}, {"antidote", 3}, {"parlyz_heal", 1}}, "5 Potions, 3 Antidotes, 1 Parlyz Heal"), - route("viridian_nurse", at(VIRIDIAN_CENTER, 7, 4, NORTH), "heal before the forest"), - heal("heal_viridian"), - route("below_old_man_trigger", at(VIRIDIAN, 20, 9, NORTH), "short of the tutorial trigger (20, 8)"), - step_into("old_man_trigger", NORTH, "the old man's catching tutorial can't be walked around"), - // TutorialTriggerLeft turns the player right, to the old man. - scene("old_man_tutorial", at(VIRIDIAN, 20, 8, EAST), "about 60 lines and his demo battle; TEACHY TV"), - // After his demo the old man stands east of the player, beside (20, 8), where - // the map doesn't have him: "east 2" from there didn't move, and the walk north - // ended under Route 2's ledge in column 8 (console B, 2026-11-01). Go north first. - route("past_old_man", at(VIRIDIAN, 20, 5, NORTH), "north along column 20, clear of the old man"), - // The gate's north warp lands on the forest's exit mat (29, 62), facing - // north. The save there keeps a forest failure from going back to Pallet. - route("forest_entrance", at(FOREST, 29, 62, NORTH), "Route 2 and the south gate, running from wild battles"), - }); -} - -StoryCheckpoint forest(){ - // The supplies bought in 00.07. - return row("00.08", "Viridian Forest to Pewter Center", at(FOREST, 29, 62, NORTH), {5, 3, 1}, StartMenu::FULL, { - // Wild battles are fought for EXP. Straight up the east side from the - // entrance, each leg ending on a wall (the Boy at (45, 58) stops the - // east one). Rick (47, 45) sees (42..46, 45), so the last leg meets - // his battle and is held on to its wall after it. The by-hand run's - // detour west to (13, 46) and back is dropped. - legs("forest_east", {{EAST, 1}, {NORTH, 4}, {EAST, 14}, {NORTH, 15}}, "up the east side to (44, 43)", WildBattles::FIGHT), - route("forest_north", at(FOREST, 39, 25), "north part", WildBattles::FIGHT), - // To the gate by legs that end on walls, which the walker holds again - // after a battle instead of estimating where it stopped: planned - // routes with open legs lost the player in the north of the forest - // (console B, 2026-11-01). The two 1-tile legs are single steps. - legs("forest_exit", { - {NORTH, 10}, {WEST, 12}, {SOUTH, 10}, {WEST, 6}, {NORTH, 20}, - {SOUTH, 1}, {WEST, 10}, {SOUTH, 27}, {WEST, 8}, {NORTH, 20}, {EAST, 1}, - }, "walls all the way to the gate's column", WildBattles::FIGHT), - route("forest_gate", at(FOREST_GATE, 7, 10, NORTH), "north onto the exit, arriving on the gate's mat", WildBattles::FIGHT), - // Out of the forest, wild battles are run from; trainers are still fought. - route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "Route 2 north to Pewter's Center"), - heal("heal_pewter"), - }); -} - -StoryCheckpoint brock(){ - // The by-hand save: 2 Potions and 1 Antidote left after the forest. - return row("00.09", "Pewter Gym: Camper Liam, then Brock", at(PEWTER_CENTER, 7, 4, NORTH), {2, 1}, StartMenu::FULL, { - // Camper Liam (3, 8) always faces east (MOVEMENT_TYPE_FACE_RIGHT, sight - // 4) and sees (4..7, 8): walking north up column 6 from the door, - // the step onto (6, 8) starts his battle. He walks up to the player, - // who stays put and keeps facing north (FRLG doesn't turn the player - // to a trainer). That step is taken on its own, so no leg is cut. - route("below_liam_line", at(GYM, 6, 9, NORTH), "in by the door, up column 6 to below Liam's row"), - step_into("liam_line", NORTH, "onto (6, 8), in Liam's line"), - battle("camper_liam", at(GYM, 6, 8, NORTH), false, "Geodude and Sandshrew; EXP before Brock"), - // On to Brock unless red HP or a status is left that no item cures. - ready("ready_for_brock", at(PEWTER_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - route("before_brock", at(GYM, 6, 6, NORTH), "below Brock (6, 5); Liam, beaten, stands at (5, 8)"), - talk("challenge_brock", "Brock's speech"), - battle("brock", at(GYM, 6, 6, NORTH), false, "Geodude and Onix, with Bubble; Boulder Badge and TM39"), - }); -} - -StoryCheckpoint running_shoes(){ - return row("00.10", "Pewter: the Running Shoes from Oak's aide", at(GYM, 6, 6, NORTH), after_brock(), StartMenu::FULL, { - // Brock's win sets VAR_MAP_SCENE_PEWTER_CITY to 1 and shows the aide at - // (46, 20); his triggers are (46, 21..23) (PewterCity map.json). The - // Gym guide's triggers at (42..43, 21..23) need the scene at 0. - route("before_aide_trigger", at(PEWTER, 45, 21, EAST), "out of the Gym, east along row 21, short of the top trigger"), - step_into("aide_trigger", EAST, "onto (46, 21), below the aide"), - // RunningShoesAideTriggerTop: the aide talks from (46, 20), no YES/NO; - // the player only turns up. He walks off and is removed; FLAG_SYS_B_DASH - // is set (console B, 2026-11-02: about 20 B presses to the overworld). - scene("shoes_from_aide", at(PEWTER, 46, 21, NORTH), "\"Oh, PLAYER!\" ... the Running Shoes; ends facing north"), - // Where the by-hand walk stopped to start 00.11 (console B, 2026-11-02). - route("below_pewter_center", at(PEWTER, 17, 26, SOUTH), "west along row 21 and down to below the Pokemon Center's door (17, 25)"), - }); -} - -// Route 3's trainers (Route3 map.json): the way east meets three of them. -// Bug Catcher Colton (12, 6) faces east, sight 3: the only way north past -// the row 7 ledges is the gap at x 14..15, below his line. Youngster Ben -// (17, 4) faces south, sight 2, so the way east keeps to row 3 past him. -// Bug Catcher Greg (25, 4) faces south, sight 2, over the way east along -// row 5. Bug Catcher James (32, 6) faces east, sight 4, over the way down -// at x 35..36. The others are kept out of: Lass Janice (19, 9) sees west -// along row 9 to x 14, Lass Sally (30, 3) west along row 3 to x 25, and -// Youngster Calvin (29, 10) west along row 10. Each line is stepped into on -// its own, so no leg is cut; the trainer walks up to the player, who stays -// put facing the way they stepped. -StoryCheckpoint route3(){ - return row("00.11", "Pewter Center, then Route 3's trainers", at(PEWTER, 17, 26, SOUTH), after_brock(), StartMenu::FULL, { - running(route("pewter_nurse", at(PEWTER_CENTER, 7, 4, NORTH), "in by the door below the player")), - heal("heal_pewter"), - // Up from row 9 west of Janice's line, which ends at x 14. - running(route("west_of_janice_line", at(ROUTE3, 13, 8), "out of Pewter by row 21, east into Route 3, short of Janice's line")), - running(legs("below_colton_line", {{EAST, 1}, {NORTH, 1}}, "to (14, 7), in the ledges' gap")), - step_into("colton_line", NORTH, "onto (14, 6), in Colton's line"), - battle("bug_catcher_colton", at(ROUTE3, 14, 6, NORTH), false, "his Bug Pokemon; Colton stops at (13, 6)"), - running(legs("past_ben", {{NORTH, 3}, {EAST, 4}, {SOUTH, 2}, {EAST, 6}}, "up to row 3 above Ben, down at x 18 east of his line, to (24, 5)")), - step_into("greg_line", EAST, "onto (25, 5), below Greg"), - battle("bug_catcher_greg", at(ROUTE3, 25, 5, EAST), false, "his Bug Pokemon; Greg is already next to the player"), - running(legs("above_james_line", {{EAST, 11}}, "along row 5 to the wall at (36, 5)")), - step_into("james_line", SOUTH, "onto (36, 6), at the end of James's line"), - battle("bug_catcher_james", at(ROUTE3, 36, 6, SOUTH), false, "his Bug Pokemon; James stops at (35, 6)"), - // Saved here, the trainers behind, so a failure on the way to Route 4 - // doesn't fight them again. - running(legs("save_spot", {{SOUTH, 2}}, "down to (36, 8), beside the wall east of it")), - }); -} - -// Route 3's north exit (x 68..75) joins Route 4 (offset 60) at x 8..15, up -// which column 12 leads to the Pokemon Center's door (12, 5). Lass Robin -// (40, 11) wanders up and down at x 40, looking north and south, sight 3. -// Rock above (y <= 8) and grass below (y >= 12) leave every way east -// across her column at y 9..11, so whether she sees the player depends on -// her facing. The walk watches for her after the leg along row 9, which -// crosses her sight on (40, 9) only; if she saw the player, her message -// goes to story_interrupts(), which fight her, and the route goes on from -// (40, 9) (run_route(); console B, 2026-11-02, she stopped the player -// there and spoke after the leg's short watch). -StoryCheckpoint magikarp_salesman(){ - StoryCheckpoint checkpoint = row("00.12", "Route 3 and 4 to the Magikarp salesman", at(ROUTE3, 36, 8, SOUTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "east over Route 3, off the grass, north into Route 4 and its Pokemon Center")), - heal("heal_route4"), - // Gift RNG starts from a save facing the salesman (1, 3). - running(route("before_salesman", at(ROUTE4_CENTER, 2, 3, WEST), "beside the Magikarp salesman, facing him")), - }); - checkpoint.handoff = StoryHandoff::GIFT_RNG; - return checkpoint; -} - -// Gift RNG buys the Magikarp (500 of the money 00.12 brings) without -// moving the player and leaves its summary open, or HOME. This saves the -// shiny where 00.12 ended. A run started here with Gift RNG's handoff on -// loads the save beside the salesman and runs Gift RNG first. -StoryCheckpoint after_gift_rng(){ - StoryCheckpoint checkpoint = row("00.12b", "after Gift RNG: save with the Magikarp", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - game_step(LEAVE_GIFT_SUMMARY, at(ROUTE4_CENTER, 2, 3, WEST), "the Magikarp's summary Gift RNG left open, or HOME"), - }); - checkpoint.live_start = true; - return checkpoint; -} - -// The Magikarp goes to BOX 1 at the Center's PC (11, 1), so Mt. Moon is -// fought with the starter alone (console B, 2026-11-02: done by hand and -// saved at (11, 2), facing the PC, where this row ends). The wandering -// boy (4..6, 3..5) is walked around. The Magikarp comes from Gift RNG: -// with Gift RNG off the party is the starter alone, and the deposit is -// skipped. -StoryCheckpoint magikarp_to_box(){ - return row("00.12c", "Route 4 Center: the Magikarp into BOX 1", at(ROUTE4_CENTER, 2, 3, WEST), after_brock(), StartMenu::FULL, { - running(route("pc_front", at(ROUTE4_CENTER, 11, 2, NORTH), "below the PC (11, 1), facing it")), - pc_step("magikarp_to_box", "DEPOSIT the party's second slot into BOX 1, if it has one", PcTransfer{ - .action = PcAction::DEPOSIT, .party_slot = 1, .box = 0, .if_missing = PcMissing::SKIP, - }), - }); -} - -// Mt. Moon (pokefirered data/maps/MtMoon_1F, _B1F, _B2F). Every floor tile -// of the cave has wild encounters, which are run from, so its legs end on -// walls, ladders or someone standing still, which the walker holds again -// after a battle; the few open ones are short. The way through: up 1F's -// middle and west side, its north-west ladder, B1F's west ladder down to -// B2F's south-east, round B2F's south edge to its west, north past -// Miguel and the fossils, and the ladder up to B1F's east end, which -// leads out to Route 4 east of the mountain. -// - 1F's trainers are walked around: Youngster Josh (13, 17) sees east -// along row 17 to x 17, so the way west into the west room is down -// column 18 and up column 11; Lass Miriam walks round (32..33, 4..5), -// sight 2, so the way east keeps to row 9 and columns 38 and 40; Hiker -// Marcos wanders (5..9, 8..12) and sees one tile, so the way north is -// column 11 and row 3. -// - The Moon Stone ball (3, 2) on 1F (FLAG_HIDE_MT_MOON_1F_MOON_STONE) is -// a few tiles off the way to the ladder (5, 6). -// - The Grunt at (37, 21) on B2F looks around (sight 3) over the only way -// east round B2F. His room is crossed on legs to walls, at one tile of -// his sight each, (37, 22) and (40, 21); if he looks the player's way, -// he walks up beside the leg, story_interrupts() fights him, and the -// leg is held on to its wall. -// - The Grunt at (12, 20) faces south (sight 2) over (12, 21..22), across -// rows 21..22, the only way north to Miguel: stepped into from the -// west, he is next to the player and doesn't walk. -// - Super Nerd Miguel (13, 11) battles on the step onto (14, 11) -// (MtMoon_B2F_EventScript_MiguelTrigger, VAR_MAP_SCENE_MT_MOON_B2F 0), -// then "We'll each take one!" -// - The fossils: DOME (13, 7), HELIX (14, 7). After the HELIX, Miguel -// walks up to (13, 8) and takes the DOME, which opens the gap north. -// The save is on Route 4: the save card's places don't include Mt. Moon. -StoryCheckpoint mt_moon(){ - return row("00.13", "Mt. Moon: a Moon Stone, a Rocket, Miguel and the Helix Fossil", at(ROUTE4_CENTER, 11, 2, NORTH), after_brock(), StartMenu::FULL, { - running(route("route4_nurse", at(ROUTE4_CENTER, 7, 4, NORTH), "the nurse, below the counter")), - heal("heal_route4"), - running(route("mt_moon_entrance", at(MT_MOON_1F, 18, 37, NORTH), "out of the Center, west into Mt. Moon")), - running(legs("mt_moon_1f", { - {NORTH, 12}, {EAST, 8}, {NORTH, 12}, {EAST, 3}, {SOUTH, 1}, {EAST, 9}, - {NORTH, 1}, {EAST, 2}, {NORTH, 4}, {WEST, 24}, {EAST, 2}, {SOUTH, 12}, - {WEST, 7}, {NORTH, 18}, {WEST, 9}, {EAST, 1}, - }, "up the middle, east of Miriam, west along row 9, down column 18 past Josh, up column 11 past Marcos, to (3, 3)")), - running(route("below_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "facing the Moon Stone (3, 2)")), - talk("moon_stone_ball", "A on the item ball"), - // No reader for the text yet: the scene's end is the overworld. - scene("found_moon_stone", at(MT_MOON_1F, 3, 3, NORTH), "\" found a MOON STONE!\", then the pocket line; the ball is gone"), - running(route("b2f_ladder_foot", at(MT_MOON_B2F, 26, 21, EAST), "1F's ladder (5, 6), down B1F's west side to its ladder (22, 18), onto B2F")), - running(legs("b2f_south", { - {NORTH, 4}, {EAST, 8}, {WEST, 2}, {SOUTH, 5}, {EAST, 8}, {NORTH, 3}, {WEST, 1}, {NORTH, 5}, - {EAST, 7}, {SOUTH, 14}, {WEST, 9}, {SOUTH, 10}, {WEST, 29}, {EAST, 3}, {NORTH, 17}, - }, "through the Grunt's room at (37, 21), round the south edge, up column 11 to (11, 21)")), - step_into("grunt_line", EAST, "onto (12, 21), below the Grunt at (12, 20)"), - battle("rocket_grunt", at(MT_MOON_B2F, 12, 21, EAST), false, "Rattata and Zubat, Lv13"), - ready("ready_for_miguel", at(ROUTE4_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse, back through the cave, only if they can't"), - // Up column 13 to Miguel, who stops the leg on (13, 12), then east - // to the wall: the tile below his trigger. - running(legs("below_miguel_trigger", {{EAST, 1}, {NORTH, 9}, {EAST, 1}}, "to (14, 12), below Miguel's trigger (14, 11)")), - step_into("miguel_trigger", NORTH, "onto (14, 11), beside Miguel"), - battle("super_nerd_miguel", at(MT_MOON_B2F, 14, 11, NORTH), false, "Grimer, Voltorb and Koffing, Lv12; \"We'll each take one!\""), - running(legs("below_helix_fossil", {{NORTH, 3}}, "up column 14 to the HELIX FOSSIL (14, 7)")), - fossil_step("helix_fossil", "the HELIX FOSSIL; Miguel takes the DOME FOSSIL", Fossil::HELIX), - // The maps keep the fossils, which the game removes after the - // choice: the step onto the HELIX's tile is taken on its own. - step_into("helix_gap", NORTH, "onto (14, 7), where the HELIX FOSSIL lay"), - running(route("route4_east", at(ROUTE4, 32, 6, SOUTH), "west to B2F's ladder (5, 10), up to B1F, east to its exit onto Route 4")), - }); -} - - -// Route 4 east of Mt. Moon (Route4 map.json) joins Cerulean City at its -// east end (x 107; Route 4's row 3 is the city's row 13). Its upper road -// (rows 2..8) reaches the city only by water: the way on by land is down -// the ledge row 9 at x 90..96 to the lower road (rows 10..12), which -// joins the city's rows 20..22. Lass Crissy (75, 3) faces east, sight 4, -// over row 3 from x 76 to 79; the way east keeps out of her line and off -// the grass south of the road (75..87, 11..17). -// -// On the way, the Mega Kick tutor (Black Belt (50, 3), facing west, -// Route4_EventScript_MegaKickTutor) stands in a pen (46..51, 2..4) north -// of the road, beside the Mega Punch tutor (47, 3); the pen opens south -// only on (48, 5) and (49, 5), the rest of row 5 ledges out of it. From -// Mt. Moon's exit the walk goes east and up into the pen to (50, 4), -// below the tutor, and Mega Kick takes Withdraw's slot. Cerulean can't -// be walked back to Route 4's upper road without Surf, so it is now or -// much later. -// -// The open leg east across the city's edge ended a tile short on the -// console (2026-11-03: on (6, 20), not (7, 20)), and no hold to a wall -// in the city's west end finds the player from there: the next hold -// south met the fence on (6, 23) and the walk went on a column off. So -// the entry ends on (9, 20), and only legs to walls follow: north up -// column 9 (or 8, a tile short) to row 12, west to (8, 12), east to -// (30, 12) beside the policeman (31, 12), south to (30, 17), west to -// (25, 17), and down the ledge row 18 to (25, 19), a few tiles from the -// door (22, 19). The way keeps out of the boy's (16, 18..24) and the -// balding man's (8..10, 22..24) wander boxes. -StoryCheckpoint route4_to_cerulean(){ - const TeachPlan mega_kick{.item = std::string(TEACH_TUTOR), .move = "mega-kick", .member = 0, .forget_move = "withdraw"}; - return row("00.14", "Route 4: Mega Kick from its tutor, then east to Cerulean's Pokemon Center", at(ROUTE4, 32, 6, SOUTH), after_brock(), StartMenu::FULL, { - running(route("mega_kick_tutor", at(ROUTE4, 50, 4, NORTH), "east and up through (48, 5) into the tutors' pen, below the Mega Kick tutor (50, 3)")), - teach_step("teach_mega_kick", "the tutor's Mega Kick in place of Withdraw, unless the lead knows it", mega_kick), - running(route("above_ledge", at(ROUTE4, 93, 8, SOUTH), "east along Route 4's upper road to above the ledge row 9")), - hop("ledge_hop", SOUTH, at(ROUTE4, 93, 10, SOUTH), "down the ledge (93, 9) to the lower road"), - running(route("cerulean_entry", at(CERULEAN, 9, 20, EAST), "east into Cerulean City, to (9, 20) below column 9")), - running(legs("above_city_ledge", {{NORTH, 8}, {WEST, 1}, {EAST, 22}, {SOUTH, 5}, {WEST, 5}}, "to walls: (9, 12), (8, 12), (30, 12), (30, 17), (25, 17)")), - hop("city_ledge_hop", SOUTH, at(CERULEAN, 25, 19, SOUTH), "down the ledge (25, 18)"), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "west along row 20 to the Pokemon Center's door (22, 19)")), - heal("heal_cerulean"), - }); -} - -// Cerulean Gym (pokefirered CeruleanCity_Gym map.json and scripts.inc): -// a pool with walkways. Misty (8, 6) stands on a platform (7..9, 6) above -// row 7. Picnicker Diana (4, 7) faces east, sight 4, over (5..8, 7), so -// misty_front (8, 7) is in her line; Swimmer Luis (10, 12) in the water -// faces west, sight 1, over (9, 12), on column 9 north of the door. No -// gym trainer has to be fought for Misty, so neither is: from the door up -// column 9 to row 13 (a route there, so the planner's walk to a wall -// doesn't run on past it through (9, 12)), west to (4, 13), and to walls -// round the pool's west and north sides, (4, 10), (12, 10), (12, 7), then -// west to (9, 7), the tile below the platform's east end, out of Diana's -// line. 00.14c steps up onto (9, 6) and talks to Misty from beside her. -// -// Misty beat a Lv20 Wartortle (console B, run m51), so first a GRIND to -// Lv23 on 00.15's patch. Gen 3 numbers (pokefirered: her mons have IV 0; -// Wartortle taken at IV 15, no EVs): Starmie Lv21 has 56 HP, Atk 36, SpA -// 47, SpD 40. Bite is Dark, special in Gen 3, no STAB, x2 on Psychic: at -// Lv23 (SpA 39) it does 23..28, three hits (two on top rolls); at Lv20, -// 20..24. Her Swift (physical, 60) does 9..11 to a Lv23 Wartortle (about -// 67 HP, Def 45) and Water Pulse (STAB, resisted) 8..10: 6 or more hits, -// though m51 saw about 20 a turn. Her Recover (28) and Super Potion undo -// a Bite, so the margin is in Bite's damage. -// -// The Mart comes before the GRIND: its wild battles are fought only with -// 2 or more Potions, and 00.14's save has none (m51 met Misty with only -// the 5 this row bought). 5 Potions (row 3, 300 each), then up to 3 Super -// Potions (row 2, 700), last so they take the Items pocket's last row; -// the battle doesn't use them yet. The money box can't be read, so the -// floor stands for it, and a floor above the money fails the step (the -// quantity box wraps). Prizes (pokefirered: 4 x last level x the class's -// factor) from a new game's 3000, less Viridian's 2000 and the Magikarp's -// 500: Liam 220, Brock 1400, Route 3's bug catchers 360, the Mt. Moon -// grunt 416 and Miguel 288 (the first rival's 80 only if won), at least -// 3184 here. Floor and budget 3000: 5 Potions and 2 Super Potions, 2900. -// Misty's 2100 (4 x 21 x 25) then leaves 00.15 its floor of 1500. Then the -// nurse, and the save before Misty, so her battle is its own checkpoint, -// 00.14c, verified and retried from it. 00.15's GRIND then fights -// until the sim beats the Cerulean rival often enough. -StoryCheckpoint cerulean_gym(){ - const MartPlan supplies{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "potion", .quantity = 5}, {.item = "super-potion", .quantity = 3}}, - .budget = 3000, - .money_floor = 3000, - }; - const GrindPlan to_lv23{.member = 0, .level = 23, .max_encounters = 100, .pace = WEST, .heal_every = 0}; - return row("00.14b", "Cerulean: Potions, a GRIND to Lv23, then into the Gym, saved below Misty's platform", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_potions", "5 Potions for the GRIND's wild battles, then Super Potions as the money allows", supplies), - running(route("grind_patch", at(ROUTE4, 86, 16, WEST), "west out of the city along Route 4's lower road onto its grass's east edge")), - grind_step("grind_to_lv23", "wild battles until the lead is Lv23, where Bite takes Starmie in three", to_lv23, at(CERULEAN_CENTER, 7, 4, NORTH)), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center: Misty's battle starts at full HP and PP")), - heal("heal_cerulean"), - running(route("gym_below_luis", at(CERULEAN_GYM, 9, 13), "into the Gym, up column 9 to row 13, short of Luis's (9, 12)")), - running(legs("gym_west_walkway", {{WEST, 5}}, "west to the wall (4, 13)")), - running(legs("below_misty_platform", {{NORTH, 3}, {EAST, 8}, {NORTH, 3}, {WEST, 3}}, "walls (4, 10), (12, 10), (12, 7), then to (9, 7), out of Diana's line")), - }); -} - -// Misty (TRAINER_LEADER_MISTY: Staryu Lv18, Starmie Lv21), talked to from -// (9, 6), beside her on the platform. Her win text runs on to the CASCADE -// BADGE, TM03 (Water Pulse) and its explanation, all read with the -// battle's. Bite is chosen against her party (Starmie is Water/Psychic). -// Back to the nurse round the pool's west side, out of Luis's line; then -// Water Pulse in place of Tail Whip, last, at the Center, from the bag's -// TM CASE. Ends where 00.15 starts. -StoryCheckpoint misty(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - return row("00.14c", "Cerulean Gym: Misty, then Water Pulse", at(CERULEAN_GYM, 9, 7, WEST), after_brock(), StartMenu::FULL, { - running(route("beside_misty", at(CERULEAN_GYM, 9, 6, WEST), "up onto (9, 6), facing Misty (8, 6)")), - talk("challenge_misty", "Misty's speech"), - battle("misty", at(CERULEAN_GYM, 9, 6, WEST), false, "Staryu and Starmie, with Bite; CASCADE BADGE and TM03"), - running(legs("gym_way_out", {{SOUTH, 1}, {EAST, 3}, {SOUTH, 3}, {WEST, 8}, {SOUTH, 3}, {EAST, 5}}, "walls (12, 7), (12, 10), (4, 10), (4, 13), (9, 13), round Luis's (9, 12)")), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "down column 9 out of the Gym, to the Center")), - heal("heal_cerulean"), - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip", water_pulse), - }); -} - -// Before the rival north of Cerulean (cerulean_rival()), from the -// Center: first TM03 Water Pulse over Tail Whip, if the lead doesn't know -// it yet, so the GRIND's sim plays it (a run without TM03 from Misty -// skips the step). Then 3 Potions at the Mart -// (CeruleanCity_Mart_Items: POTION is row 3, 300 each; Mt. Moon's -// trainers leave well over the floor) and 2 Awakenings (row 6, 250 each; -// pokefirered items.json) for the rival's Bulbasaur's Sleep Powder -// (console B, m56: asleep at 34/65 HP, it fainted two turns later with -// 15 Potions), 1400 of the floor's 1500. Then a GRIND on Route 4's grass -// east of Mt. Moon (75..86, 11..17; Spearow, Rattata, Ekans and Mankey -// around Lv10, about 80 EXP each), healing at the Center, until the -// battle sim beats the rival 00.15b fights 50% or more: the win chance -// his battle refuses below. Console B's Wartortle (Lv22, 65 HP, Water -// Pulse) is about 42% there and 62% at Lv23; Lv28 (about 88%, some 120 -// battles from Lv22) is the cap. Then the nurse, and the save on (23, 7), -// the tile below his trigger: his battle is its own checkpoint, 00.15b, -// verified and retried from this save. -StoryCheckpoint cerulean_grind(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - const MartPlan potions{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "potion", .quantity = 3}, {.item = "awakening", .quantity = 2}}, - .budget = 1500, - .money_floor = 1500, - }; - const GrindPlan for_rival{ - .member = 0, .level = 28, .max_encounters = 150, .pace = WEST, .heal_every = 0, - .trainer = std::string(story_trainer(CERULEAN, "rival_cerulean").value_or("")), .min_chance = MIN_WIN_CHANCE, - }; - return row("00.15", "Cerulean: Water Pulse, Potions, a GRIND until the rival is winnable, then saved below his trigger", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip, unless the lead knows it or there is no TM03", water_pulse), - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_potions", "3 Potions: the GRIND fights wild battles only with 2 or more; 2 Awakenings for the rival's Sleep Powder", potions), - running(route("grind_patch", at(ROUTE4, 86, 16, WEST), "west out of the city along Route 4's lower road onto its grass's east edge")), - grind_step("grind_for_rival", "wild battles until the sim beats the rival 50% or more, Lv28 at most; the nurse when hurt or low on PP", for_rival, at(CERULEAN_CENTER, 7, 4, NORTH)), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center: the rival's battle starts at full HP and PP")), - heal("heal_cerulean"), - running(route("below_rival_trigger", at(CERULEAN, 23, 7, NORTH), "out of the Center, north up to (23, 7), short of the trigger row 6")), - }); -} - -// The rival north of Cerulean (CeruleanCity scripts.inc): the only way -// north to Nugget Bridge is columns 22..24, and a step onto row 6 there -// (CeruleanCity_EventScript_RivalTrigger*, VAR_MAP_SCENE_CERULEAN_CITY_RIVAL -// 0) brings him down to the player. From the middle, (23, 6), he stops -// at (23, 5); after the battle he walks round the player and off south, -// and the player, turning to watch him, ends facing south. His FAME -// CHECKER's text is read to the overworld with the battle's. For a player -// who took Squirtle he has Pidgeotto Lv17, Abra Lv16, Rattata Lv15 and -// Bulbasaur Lv18 (sParty_RivalCeruleanBulbasaur), whose Vine Whip and -// Sleep Powder are the danger. The row starts from 00.15's save below the -// trigger, and saves after him. First TM03 Water Pulse over Tail Whip (from -// the bag, where the player stands), if the lead doesn't know it yet: -// console B's save (2026-11-03) is past Misty's TEACH, which failed there. -// Where she taught it, the step reads the moves and does nothing. -StoryCheckpoint cerulean_rival(){ - const TeachPlan water_pulse{.item = "tm03", .move = "water-pulse", .member = 0, .forget_move = "tail-whip"}; - return row("00.15b", "Cerulean: Water Pulse if not known, then the rival north of the city", at(CERULEAN, 23, 7, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_water_pulse", "TM03 Water Pulse in place of Tail Whip, unless the lead knows it", water_pulse), - step_into("rival_trigger", NORTH, "onto (23, 6), the middle trigger: \"Yo! !\""), - battle("rival_cerulean", at(CERULEAN, 23, 6, SOUTH), false, "Pidgeotto, Abra, Rattata and Bulbasaur; then the FAME CHECKER"), - }); -} - -// Nugget Bridge (Route24 map.json) is x 10..12 from row 32 north to row -// 16, the city's columns 22..24 (offset 12). Its five trainers stand on -// it facing across, sight 2, so each line crosses the middle column 11 -// on the trainer's row: Bug Catcher Cale (12, 31), Lass Ali (10, 28), -// Youngster Timmy (12, 25), Lass Reli (10, 22) and Camper Ethan (12, 19). -// Each is fought on the step onto their row, beside them: they don't -// walk, and the player keeps facing north. Two tiles separate the rows, -// walked as one short leg; the step onto a row goes on a tile at a time -// until the trainer sees the player (into_line()), as the open leg onto -// the bridge ended a tile short twice on console B (2026-11-03), on -// (11, 33), and one step left the player out of Cale's sight. Then the -// Rocket (12, 15): the step onto (11, 15) -// (Route24_EventScript_RocketTriggerRight, VAR_MAP_SCENE_ROUTE24 0) gives -// the NUGGET, "join Team Rocket", and his battle; he only turns, and the -// player turns east to him. Camper Shane (5, 21) looks north from the -// west bank, off the way. -StoryCheckpoint nugget_bridge(){ - return row("00.16", "Nugget Bridge: the nurse, five trainers and the Rocket", at(CERULEAN, 23, 6, SOUTH), after_brock(), StartMenu::FULL, { - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back to the Center after the rival, before Nugget Bridge")), - heal("heal_cerulean"), - running(route("below_cale_line", at(ROUTE24, 11, 32, NORTH), "out of the Center, north past the rival's row onto the bridge, below Cale's row")), - into_line("cale_line", NORTH, "onto (11, 31), beside Cale"), - battle("bug_catcher_cale", at(ROUTE24, 11, 31, NORTH), false, "his Bug Pokemon"), - running(legs("below_ali_line", {{NORTH, 2}}, "up to (11, 29)")), - into_line("ali_line", NORTH, "onto (11, 28), beside Ali"), - battle("lass_ali", at(ROUTE24, 11, 28, NORTH), false, "her Pokemon"), - running(legs("below_timmy_line", {{NORTH, 2}}, "up to (11, 26)")), - into_line("timmy_line", NORTH, "onto (11, 25), beside Timmy"), - battle("youngster_timmy", at(ROUTE24, 11, 25, NORTH), false, "his Pokemon"), - running(legs("below_reli_line", {{NORTH, 2}}, "up to (11, 23)")), - into_line("reli_line", NORTH, "onto (11, 22), beside Reli"), - battle("lass_reli", at(ROUTE24, 11, 22, NORTH), false, "her Pokemon"), - running(legs("below_ethan_line", {{NORTH, 2}}, "up to (11, 20)")), - into_line("ethan_line", NORTH, "onto (11, 19), beside Ethan"), - battle("camper_ethan", at(ROUTE24, 11, 19, NORTH), false, "his Pokemon"), - // A route, not legs: the nurse may have been needed. - ready("ready_for_rocket", at(CERULEAN_CENTER, 7, 4, NORTH), "items for a status or low HP; the nurse only if they can't"), - running(route("below_rocket_trigger", at(ROUTE24, 11, 16, NORTH), "up the bridge to below the Rocket's trigger (11, 15)")), - step_into("rocket_trigger", NORTH, "onto (11, 15), beside the Rocket"), - battle("rocket_grunt", at(ROUTE24, 11, 15, EAST), false, "the NUGGET, then Ekans and Zubat, Lv15"), - }); -} - -// Route 24 north of Nugget Bridge (Route24 map.json) joins Route 25 by -// its rows 7..9; the ledges on Route 25's row 6 (x 0..9) leave the way -// north at x 12..13. Route 25 (Route25 map.json, scripts.inc) to Bill's -// Sea Cottage door (51, 4): of its nine trainers, four can't be walked -// around. -// - Hiker Franklin (11, 4) faces east, sight 4, over (12..15, 4), and -// Hiker Wayne (17, 7) east over (18..19, 7): the only ways east past -// x 15. Franklin is fought, from (15, 5) on the step onto (15, 4), the -// end of his line: he walks up to (14, 4). -// - Youngster Joey (18, 2) faces south over (18, 3..4): the way keeps -// off column 18, south round Wayne to (19, 6) and up to (19, 4). -// - Youngster Dan (22, 4) looks around, sight 2, over the only way east, -// (20..21, 4). On (20, 4), a one-tile leg, he may see the player and -// walk up to (21, 4); so the way goes north from there to row 2, east, -// and down column 23 past him to (23, 5), off every tile he may walk -// up to. Where his sight is crossed, the leg ends on a wall or is one -// tile; if he looks the player's way, story_interrupts() fight him. -// - Picnicker Kelsey (22, 8) faces east over (23..24, 8), across the -// only way on: fought on the step onto (24, 8); she walks up to (23, 8). -// - Hiker Nob (27, 9) faces north over (27, 6..8), Camper Flint (28, 4) -// south over (28, 5..7): every way east crosses one. Nob is fought on -// the step onto (27, 8), beside him; the way on keeps off Flint's -// column, by one-tile legs and legs to walls. -// - Youngster Chad (36, 4) walks up and down column 36 (rows 2..7), so -// he may see any tile of it down to row 9. The way crosses his column -// on row 9, a leg to the water at (42, 9), where he can only walk up -// beside it. -// - Lass Haley (42, 5) faces south over (42, 6..8), the only way east of -// x 42: fought on the step onto (42, 8); she walks up to (42, 7). -// The row saves inside the Sea Cottage, which the save card names -// ROUTE 25. -StoryCheckpoint route25(){ - return row("00.17", "Route 24 and 25 to Bill's Sea Cottage: Franklin, Kelsey, Nob and Haley", at(ROUTE24, 11, 15, EAST), after_brock(), StartMenu::FULL, { - running(route("below_franklin_line", at(ROUTE25, 15, 5, NORTH), "north off Nugget Bridge, east into Route 25, round its ledges to (15, 5), below the end of Franklin's line")), - into_line("franklin_line", NORTH, "onto (15, 4), at the end of Franklin's line"), - battle("hiker_franklin", at(ROUTE25, 15, 4, NORTH), false, "Machop and Geodude, Lv15; Franklin stops at (14, 4)"), - running(legs("west_of_dan", {{EAST, 2}, {SOUTH, 2}, {EAST, 2}, {NORTH, 2}}, "to (17, 4), short of Joey's (18, 4); round Wayne (17, 7) to (19, 6); up to (19, 4)")), - running(legs("round_dan", { - {EAST, 1}, {NORTH, 2}, {EAST, 4}, {WEST, 1}, {SOUTH, 3}, {EAST, 1}, {SOUTH, 2}, - }, "onto (20, 4); up to (20, 2), east to (24, 2), down column 23 past Dan to (23, 5), to (24, 7) above Kelsey's line")), - into_line("kelsey_line", SOUTH, "onto (24, 8), at the end of Kelsey's line"), - battle("picnicker_kelsey", at(ROUTE25, 24, 8, SOUTH), false, "Nidoran M and Nidoran F, Lv15; Kelsey stops at (23, 8)"), - running(legs("west_of_nob_line", {{EAST, 2}}, "along row 8 to (26, 8)")), - into_line("nob_line", EAST, "onto (27, 8), above Nob"), - battle("hiker_nob", at(ROUTE25, 27, 8, EAST), false, "three Geodude and a Machop, Lv13"), - running(legs("below_haley_line", { - {EAST, 1}, {SOUTH, 1}, {EAST, 1}, {NORTH, 3}, {EAST, 5}, {SOUTH, 3}, {EAST, 8}, - }, "below Flint's column to (29, 9), up to (29, 6), east to (34, 6), down to (34, 9), east along row 9 past Chad's column to the water, (42, 9)")), - into_line("haley_line", NORTH, "onto (42, 8), at the end of Haley's line"), - battle("lass_haley", at(ROUTE25, 42, 8, NORTH), false, "Oddish, Pidgey and Oddish, Lv13; Haley stops at (42, 7)"), - running(route("sea_cottage", at(SEA_COTTAGE, 7, 8, NORTH), "east along row 8, up column 51 into the Sea Cottage (51, 4), a step in from its mat")), - }); -} - -// Bill's Sea Cottage (Route25_SeaCottage scripts.inc). Bill is the -// Clefairy at (10, 6) (FLAG_HELPED_BILL_IN_SEA_COTTAGE unset): talked to -// from (10, 7), below him, he asks "Help me out!" (YES/NO; NO goes on the -// same), says to run the Cell Separation on the PC, and walks up into -// the right teleporter (10, 3); with the player facing north he walks -// straight up. The PC (4, 5) answers only from the south, (4, 6). Its -// scene: the teleporters run, Bill comes out of the left one (3, 3) and -// walks to (7, 6) (BillWalkToMiddleOfRoom); the player isn't moved. -// Talked to from (6, 6), Bill gives the S.S. TICKET, no YES/NO, and goes -// on about the S.S. ANNE (FLAG_GOT_SS_TICKET, which also hides Nugget -// Bridge's Rocket). Out by the mat (7, 9); the door puts the player on -// (51, 5), facing south. The maps keep Bill at (7, 5), but after his -// scene he stands on (7, 6), in the way from (6, 6) to the mat (console -// B, 2026-11-03), so the walk out goes around him to (7, 8) first. -StoryCheckpoint bill(){ - return row("00.18", "Bill's Sea Cottage: the Cell Separator and the S.S. Ticket", at(SEA_COTTAGE, 7, 8, NORTH), after_brock(), StartMenu::FULL, { - running(route("below_bill_clefairy", at(SEA_COTTAGE, 10, 7, NORTH), "below the Clefairy (10, 6), facing it")), - talk("bill_clefairy", "\"Hiya! I'm a POKEMON... ...No I'm not!\" ... \"Help me out!\""), - answer("help_bill", true, "YES: \"run the Cell Separation on the PC\""), - scene("bill_into_teleporter", at(SEA_COTTAGE, 10, 7, NORTH), "the Clefairy walks up into the right teleporter"), - running(route("pc_front", at(SEA_COTTAGE, 4, 6, NORTH), "below the PC (4, 5), facing it")), - talk("cell_separator", "the PC: \" initiated the TELEPORTER's CELL SEPARATOR!\""), - scene("bill_comes_out", at(SEA_COTTAGE, 4, 6, NORTH), "the teleporters run; Bill comes out of the left one and walks to (7, 6)"), - running(legs("beside_bill", {{EAST, 2}}, "to (6, 6), west of Bill, facing him")), - talk("thank_bill", "\"Thanks, bud! ... take this\""), - scene("ss_ticket", at(SEA_COTTAGE, 6, 6, EAST), "the S.S. TICKET; \"... the S.S. ANNE ... go instead\""), - running(legs("around_bill", {{SOUTH, 2}, {EAST, 1}}, "to (7, 8), above the mat; Bill stands on (7, 6) after his scene")), - running(route("out_of_cottage", at(ROUTE25, 51, 5, SOUTH), "down to the mat and out; the door puts the player below it")), - }); -} - -// Back to Cerulean by Route 25's south path (Route25 map.json): from -// below the cottage down column 51 to row 12, west along row 12 and row -// 11 into Route 24 (x 14..23, row 11), and down its column 14..16 east -// of Nugget Bridge to Cerulean's north edge (x 26..28, offset 12). No -// trainer stands on it. Cerulean's row 1 there is a ledge (26..28, 1), -// hopped south from (27, 0); then on into the city to the Pokemon Center. -StoryCheckpoint back_to_cerulean(){ - return row("00.19", "Route 25's south path back to Cerulean's Pokemon Center", at(ROUTE25, 51, 5, SOUTH), after_brock(), StartMenu::FULL, { - running(route("above_cerulean_ledge", at(CERULEAN, 27, 0, SOUTH), "Route 25's south path west, Route 24 east of the bridge south, to above Cerulean's ledge (27, 1)")), - hop("cerulean_ledge_hop", SOUTH, at(CERULEAN, 27, 2, SOUTH), "down the ledge (27, 1)"), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "into the city to the Pokemon Center")), - heal("heal_cerulean"), - }); -} - -// Stopgap for console B's save, which caught nothing on Route 1. A new -// playthrough should instead catch a Rattata on Route 1 or 22 early, as -// its Cut user and spare member, and drop this row (and its walk over -// Nugget Bridge and back). -// -// An Oddish for HM01 Cut, and a second member behind the lead -// (docs/design/AutoStory-FRLG-FutureEvents.md, "Console B run choices"). -// Route 24's grass (Route24 map.json: x 3..5, rows 19..31, west of Nugget -// Bridge) is the nearest to the Center with Oddish: FireRed's -// sRoute24_FireRed (pokefirered wild_encounters.json) has it in 25% of -// battles, Lv12..14, as Route 25's grass; Routes 5 and 6 aren't on the -// story's maps yet. Up the bridge, whose trainers 00.16 beat, west along -// rows 10..15 to the cliff (3, 15) and down column 3 to the grass's first -// row, (3, 19); the step paces east to (4, 19) and back. Camper Shane -// (5, 21) faces north, sight 5, over (5, 16..20): column 5 is kept off. -// The leg west ends on the cliff, not open: on console B (m63) an open -// leg west to (4, 15) ended a tile short, and the walk down column 5 -// came into Shane's sight. -// -// First 7 Poke Balls at the Mart (row 1, 200 each; the bag isn't read, so -// the step buys them whatever the bag holds). The floor, from 00.15's -// 1500 less its 1400: the rival's 288 (4 x 18 x 4), the Rocket's 480 (4 -// x 15 x 8), Franklin's 540 and Nob's 468 (hikers, 9) alone make 1876 -// (pokefirered gTrainerMoneyTable). An Oddish at full HP (catch rate 255) -// stays in a Poke Ball about 1 time in 3 (Gen 3: a = 85, four shakes of -// 0.76), so 7 balls catch it about 94% of the time; the step throws 7 at -// most, in 30 battles (none an Oddish: 0.02%). Nothing weakens it: the HP -// bar isn't read on the console yet. -// -// The Oddish joins the party second. Battles keep the lead in -// (PokemonFRLG_AutoStoryBattleDecisions.h): the Oddish is sent only when -// the lead faints in a trainer's battle, which counts as lost. Back to -// the nurse, and the save in the Center. -StoryCheckpoint oddish(){ - const MartPlan balls{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "poke-ball", .quantity = 7}}, - .budget = 1400, - .money_floor = 1500, - }; - const CapturePlan catch_oddish{.species = "oddish", .catches = 1, .max_encounters = 30, .max_balls = 7, .pace = EAST}; - return row("00.20", "Route 24's grass: an Oddish for Cut, then the Center", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Center to the Mart's clerk")), - mart_step("buy_poke_balls", "7 Poke Balls for the Oddish", balls), - running(route("oddish_patch", at(ROUTE24, 3, 19), "north over Nugget Bridge, west to the cliff and down column 3 onto the grass's first row, out of Shane's column 5")), - capture_step("catch_oddish", "wild battles until an Oddish, then Poke Balls; any other species is run from", catch_oddish), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "back over the bridge to the Center")), - heal("heal_cerulean"), - }); -} - - -// Cerulean's only way south without Cut (CeruleanCity map.json, -// scripts.inc) is through the burgled house (30, 11), whose door the -// policeman leaves once the S.S. TICKET is had, out of the hole in its -// back wall into the yard (31, 8). The Rocket there (33, 6) stops the -// player on (33, 5) or (33, 7) (CeruleanCity_EventScript_GruntTrigger*): -// from (32, 7), the step east onto (33, 7) turns the player to him; -// Machop and Drowzee, Lv17, then TM28 Dig, and he is gone. Then east -// round the yard, down to the city's south edge by the path along its -// east side (39..40, 20..31), down Route 5's east side to the -// Underground Path's north house (31, 31), through its tunnel and out of -// the south house onto Route 6, below its door (19, 14). Route 6: -// - Bug Catcher Keigo (3, 16) faces east, sight 5, over the middle path -// (4..8, 16); Bug Catcher Elijah (20, 25) faces west, sight 3, over -// the east path (17..19, 25). The way goes down column 15, through the -// grass to the wall (15, 33), out of both lines; the open leg west to -// it, a tile short, leaves the player on column 16, out of them too. -// - Camper Ricky and Picnicker Nancy (12..13, 21) battle only when -// talked to. -// - Picnicker Isabelle (13, 32) and Camper Jeff (13, 33) face west, sight -// 3, over (10..12, 32) and (10..12, 33); the only way south, (10..12, -// 34), is from Jeff's row. Up to (15, 31), west to the wall (7, 31), -// down to the wall (7, 33), east: Jeff is fought on the step onto -// (10, 33) and walks up to (11, 33). Isabelle's row is kept off. -// Then down into Vermilion City (offset 12) to its Pokemon Center. -StoryCheckpoint to_vermilion(){ - return row("00.21", "The Cerulean Rocket, Route 5, the Underground Path and Route 6 to Vermilion's Pokemon Center: Jeff", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("west_of_rocket", at(CERULEAN, 32, 7, EAST), "through the burgled house and out of the hole in its back wall, west of the Rocket (33, 6)")), - step_into("rocket_trigger", EAST, "onto (33, 7), below the Rocket"), - battle("rocket_grunt", at(CERULEAN, 33, 7, NORTH), false, "Machop and Drowzee, Lv17; TM28 Dig"), - running(route("route6_column15", at(ROUTE6, 15, 14), "round the yard and down Cerulean's east side, Route 5 into the Underground Path, through it onto Route 6, west to column 15")), - running(legs("round_keigo_and_elijah", { - {SOUTH, 19}, {NORTH, 1}, {NORTH, 1}, {WEST, 8}, {SOUTH, 2}, {EAST, 2}, - }, "down column 15 to the wall (15, 33); up to (15, 31), west to the wall (7, 31), down to the wall (7, 33), east to (9, 33)")), - into_line("jeff_line", EAST, "onto (10, 33), in Jeff's line"), - battle("camper_jeff", at(ROUTE6, 10, 33, EAST), false, "Spearow and Raticate, Lv16; Jeff stops at (11, 33)"), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "down Route 6's south path into Vermilion City, to the Pokemon Center")), - heal("heal_vermilion"), - }); -} - -// The S.S. Anne (VermilionCity, SSAnne_* scripts.inc). The step onto -// (23, 33) (VermilionCity_EventScript_CheckTicket) has the sailor (24, 33) -// ask for a ticket; the S.S. TICKET (00.18) is shown and the player turns -// east to him. Then onto the pier (23, 34), along the gangway, through -// 1F, by legs off its cabins' doormats on row 10, which planned routes -// cross, and up its stairs (3, 8) to 2F. The step onto (30, 6), below the -// Captain's door (30, 2) (SSAnne_2F_Corridor_EventScript_RivalTriggerLeft), -// brings the rival out and down to (30, 5); the player keeps facing -// north, and after the battle he walks round the player and off. For a -// player who took Squirtle: Pidgeotto Lv19, Raticate Lv16, Kadabra Lv18, -// Ivysaur Lv20. The ship's trainers are in its cabins and on its deck, -// off the way. The Captain (5, 4) faces up; talked to from (5, 5) he is -// rubbed on the back and gives HM01 (VAR_MAP_SCENE_VERMILION_CITY 1). -// Back out through 1F's door (19, 1): on the gangway the ship sails -// (SSAnne_Exterior_ExitSSAnne), the player is put on (23, 34) and walked -// up to (23, 32) (VermilionCity_EventScript_ExitSSAnne). Cut is taught -// later, to the Oddish. -StoryCheckpoint ss_anne(){ - return row("00.22", "The S.S. Anne: the rival, HM01 Cut from the Captain, back to Vermilion's Pokemon Center", at(VERMILION_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("above_ticket_check", at(VERMILION, 23, 32, SOUTH), "out of the Center down to the harbor, above the ticket check (23, 33)")), - step_into("ticket_check", SOUTH, "onto (23, 33): \"Do you have a ticket?\""), - scene("show_ss_ticket", at(VERMILION, 23, 33, EAST), "the S.S. TICKET; the player turns to the sailor"), - running(route("aboard", at(SS_ANNE_1F, 19, 2, SOUTH), "onto the pier, along the gangway and in by 1F's door, a step below it")), - running(legs("past_the_cabins", {{SOUTH, 8}, {NORTH, 1}, {WEST, 6}, {NORTH, 1}}, "to the wall (19, 10), up a step, west to the worker (12, 9), up a step to (13, 8): off the cabins' mats on row 10")), - running(route("below_rival_trigger", at(SS_ANNE_2F, 30, 7, NORTH), "west along 1F, up the stairs (3, 8) and along 2F below the Captain's door")), - step_into("rival_trigger", NORTH, "onto (30, 6): the rival comes out of the Captain's door"), - battle("rival_ss_anne", at(SS_ANNE_2F, 30, 6, NORTH), false, "Pidgeotto, Raticate, Kadabra and Ivysaur"), - running(route("behind_captain", at(CAPTAINS_OFFICE, 5, 5, NORTH), "into the Captain's office, behind the Captain (5, 4)")), - talk("captain", "\"Ooargh... I feel hideous... Urrp! Seasick...\""), - scene("hm01_cut", at(CAPTAINS_OFFICE, 5, 5, NORTH), "the player rubs his back; HM01, and what Cut does"), - running(route("off_2f", at(SS_ANNE_1F, 13, 8), "back along 2F, down the stairs and east along 1F's row 8")), - running(legs("round_the_sailor", {{EAST, 4}, {SOUTH, 1}, {EAST, 2}}, "to the sailor (18, 8), down a step, east to (19, 9): off the cabins' mats on row 10")), - running(route("below_ship_door", at(SS_ANNE_1F, 19, 2, NORTH), "up below the door to the gangway")), - step_into("off_the_ship", NORTH, "out onto the gangway"), - scene("ss_anne_sails", at(VERMILION, 23, 32, NORTH), "the ship sails; the player is walked off the pier to (23, 32)"), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "back to the Pokemon Center")), - heal("heal_vermilion"), - }); -} - - -// HM01 Cut, from the S.S. Anne (00.22), to the Oddish (00.20), second in -// the party: a wild Oddish of Lv12 to 14 knows 2 or 3 moves (Absorb, -// Sweet Scent, Poison Powder at 14), so it has room. TM28 Dig, from the -// Cerulean Rocket (00.21), to the lead in place of Withdraw: Ground, twice -// as strong on Lt. Surge's three, it takes the sim's chance against him -// for a Lv28 Wartortle with 14 Potions from 6% to 47%. Vermilion's tree -// (19, 24) (EventScript_CutTree) is the only way into the gym's yard, -// row 24 being walls but for it; the gym's door is (14, 25). In the gym, -// the trainers as above, then the trash cans until the door opens; out, -// the tree cut again from below, and back to the nurse. -StoryCheckpoint vermilion_gym(){ - const TeachPlan cut{.item = "hm01", .move = "cut", .member = 1}; - const TeachPlan dig{.item = "tm28", .move = "dig", .member = 0, .forget_move = "withdraw"}; - return row("00.23", "Vermilion Gym: Cut and Dig, the tree, Dwayne, Baily and Tucker, the trash cans", at(VERMILION_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - teach_step("teach_cut", "HM01 Cut to the Oddish, second in the party, unless it knows it", cut), - teach_step("teach_dig", "TM28 Dig in place of Withdraw, for Lt. Surge, unless the lead knows it or there is no TM28", dig), - running(route("above_gym_tree", at(VERMILION, 19, 23, SOUTH), "out of the Center, south through the city to above the tree (19, 24)")), - cut_tree("cut_gym_tree", at(VERMILION, 19, 24, SOUTH), "the Oddish cuts the tree; a step onto its tile"), - running(route("gym_door", at(VERMILION_GYM, 5, 19, NORTH), "down into the yard and in by the gym's door (14, 25)")), - running(legs("west_of_dwayne_line", {{NORTH, 4}, {EAST, 2}}, "up column 5 to the can (5, 14), east to (7, 15): out of Dwayne's and Baily's sight")), - into_sight("dwayne_sight", EAST, "onto (8, 15), two below Dwayne (8, 13): he turns to the player and walks up to (8, 14)"), - battle("sailor_dwayne", at(VERMILION_GYM, 8, 15, NORTH), false, "two Pikachu, Lv21"), - running(legs("east_of_baily_line", {{WEST, 4}, {NORTH, 2}, {WEST, 1}}, "west along row 15 to (4, 15), up to (4, 13), west to (3, 13): out of Baily's sight")), - into_sight("baily_sight", WEST, "onto (2, 13), two below Baily (2, 11): he turns to the player and walks up to (2, 12)"), - battle("engineer_baily", at(VERMILION_GYM, 2, 13, NORTH), false, "Voltorb and Magnemite, Lv21"), - running(legs("below_tucker_line", {{EAST, 2}, {NORTH, 4}, {EAST, 1}}, "east to (4, 13), up column 4 past Baily's row to (4, 9), east to (5, 9): below Tucker's line, not on it")), - into_line("tucker_line", NORTH, "onto (5, 8), in Tucker's line: he walks up to (6, 8)"), - battle("gentleman_tucker", at(VERMILION_GYM, 5, 8, EAST), false, "Pikachu, Lv23"), - trash_cans("trash_cans", "the cans until both locks open; a wrong second can resets them"), - running(route("below_gym_tree", at(VERMILION, 19, 25, NORTH), "out of the gym, east to below the tree, grown back")), - cut_tree("cut_tree_out", at(VERMILION, 19, 24, NORTH), "the tree again; a step onto its tile"), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "north through the city to the Pokemon Center")), - heal("heal_vermilion"), - }); -} - -// Wild battles on Route 6 until the sim beats Lt. Surge half the time: -// with Dig, 47% at Lv28 and 51% at Lv29, so a lead the gym's trainers -// have brought to Lv29 passes at once, and a Lv28 one after a level. The grass nearest the city is Route 6's -// south patch (13..16, 30..33); Picnicker Isabelle (13, 32) faces west -// over (10..12, 32), on the way north from the city, so the walk goes -// along Jeff's row 33 (he is beaten) to the wall (7, 33), up to row 31 -// and east along it onto the patch's west edge, (13, 31), above -// Isabelle, out of her line. Back to the nurse the same way. -// All that is skipped when the lead, read in the Center, passes already. -// Then the tree, the gym, whose trainers stand where the map has them, -// beaten, and whose beams stay off (FLAG_FOUND_BOTH_VERMILION_GYM_SWITCHES): -// up column 5 to below Lt. Surge, and saved there. -StoryCheckpoint to_lt_surge(){ - constexpr const char* SURGE_WINNABLE = "surge_winnable"; - const GrindPlan for_surge{ - .member = 0, .level = 32, .max_encounters = 150, .pace = EAST, .heal_every = 0, - .trainer = std::string(story_trainer(VERMILION_GYM, "lt_surge").value_or("")), .min_chance = MIN_WIN_CHANCE, - }; - return row("00.24", "Route 6's grass until Lt. Surge is winnable, then through the open beams to him", at(VERMILION_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - grind_check_step(SURGE_WINNABLE, "the lead as it is: if the sim beats Lt. Surge 50% or more already, no trip to Route 6", for_surge), - unless(SURGE_WINNABLE, running(route("route6_south_path", at(ROUTE6, 11, 34, NORTH), "out of the Center, north out of the city onto Route 6's path, below Jeff's row"))), - unless(SURGE_WINNABLE, running(legs("round_isabelle_line", {{NORTH, 1}, {WEST, 4}, {NORTH, 2}, {EAST, 5}, {EAST, 1}}, "onto Jeff's row (11, 33), west to the wall (7, 33), up to (7, 31), east along row 31 to (12, 31) and a step onto the grass, (13, 31): out of Isabelle's line"))), - unless(SURGE_WINNABLE, grind_step("grind_for_surge", "wild battles until the sim beats Lt. Surge 50% or more, Lv32 at most; the nurse when hurt or low on PP", for_surge, at(VERMILION_CENTER, 7, 4, NORTH))), - unless(SURGE_WINNABLE, running(route("west_on_row_31", at(ROUTE6, 7, 31), "west along row 31, out of the grass, to the wall (7, 31)"))), - unless(SURGE_WINNABLE, running(legs("down_to_jeff_row", {{SOUTH, 2}, {EAST, 4}}, "down to the wall (7, 33), east along Jeff's row to (11, 33): out of Isabelle's line"))), - unless(SURGE_WINNABLE, running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "south into the city to the Pokemon Center"))), - unless(SURGE_WINNABLE, heal("heal_vermilion")), - running(route("above_gym_tree", at(VERMILION, 19, 23, SOUTH), "out of the Center, south through the city to above the tree (19, 24)")), - cut_tree("cut_gym_tree", at(VERMILION, 19, 24, SOUTH), "the tree; a step onto its tile"), - running(route("below_lt_surge", at(VERMILION_GYM, 5, 3, NORTH), "into the gym, up round the cans and through the beams, off, to below Surge (5, 2)")), - }); -} - -// Lt. Surge (5, 2), talked to from below, from the save in front of him: -// Voltorb Lv21, Pikachu Lv18 and Raichu Lv24, Shock Wave and Thunder -// Wave, a Super Potion and a Full Heal (sParty_LeaderLtSurge); then the -// THUNDERBADGE and TM34, read to the overworld with the battle's text. -// Out, the tree, and the nurse. Surge's win also puts Oak's aide on -// Vermilion City's (25, 7) (VermilionCity_Gym_EventScript_ShowOaksAide), -// where he stays until talked to; the story's maps don't have him. The -// way to the nurse along row 7 runs into him (console B, 2026-11-03: the -// leg west stopped beside him and the step into the Center's door went -// into a house), so it goes along row 10 to the water instead, clear of -// him, and up column 14 from there. -StoryCheckpoint lt_surge(){ - return row("00.25", "Vermilion Gym: Lt. Surge, the THUNDERBADGE, then the Center", at(VERMILION_GYM, 5, 3, NORTH), after_brock(), StartMenu::FULL, { - talk("challenge_lt_surge", "\"Hey, kid! What do you think you're doing here?\""), - battle("lt_surge", at(VERMILION_GYM, 5, 3, NORTH), false, "Voltorb, Pikachu and Raichu; THUNDERBADGE and TM34"), - running(route("below_gym_tree", at(VERMILION, 19, 25, NORTH), "down through the beams, out of the gym, east to below the tree, grown back")), - cut_tree("cut_tree_out", at(VERMILION, 19, 24, NORTH), "the tree; a step onto its tile"), - running(route("below_oaks_aide", at(VERMILION, 14, 10), "north through the city and west along row 10 to the water, (14, 10): off Oak's aide's row 7")), - running(route("vermilion_nurse", at(VERMILION_CENTER, 7, 4, NORTH), "up to the Pokemon Center")), - heal("heal_vermilion"), - }); -} - -// The BIKE VOUCHER and the BICYCLE, from Vermilion's Center to -// Cerulean's (pokeguy 43:50 to 45:00). -// - The Pokemon Fan Club (VermilionCity_PokemonFanClub map.json, -// scripts.inc), in by Vermilion's (12, 17): the chairman (5, 4) sits -// above a table (5..6, 5..6) with the worker (6, 4) east of him, so he -// is talked to from (4, 4), west of him. "Did you come to hear about -// my POKEMON?" YES: his story, then the BIKE VOUCHER -// (FLAG_GOT_BIKE_VOUCHER). Oak's aide stands on Vermilion's (25, 7) -// since Lt. Surge, where the story's maps don't have him: the way -// planned from the Center's door goes east along his row 7, so the -// walk goes down to the water (14, 10) first, as 00.25 came up from -// it. From the Fan Club, up to (22, 10) first, so that the way on to -// Route 6 goes up column 22, west of him, not round by column 27. -// - Route 6 north, the trainers as 00.21 left them: Jeff (13, 33) -// beaten, Isabelle (13, 32) and Elijah (20, 25) not. As in 00.24, onto -// Jeff's row, west to the wall (7, 33) and up to row 31, above -// Isabelle's line; then east along row 31 to the wall (17, 31) and up -// column 16, west of Elijah's line (17..19, 25) and east of Keigo's -// (4..8, 16), to the ledge (16, 11). The first three legs are 00.24's, -// walked on console B; the two after end on walls, which the walker -// holds again after a wild battle in the grass. -// - The Underground Path north, Route 5's sides, which have no trainer, -// and Cerulean's south edge, whose way into the city without the -// burgled house is the tree (26, 32) (pokeguy 44:42). -// - The Bike Shop (CeruleanCity_BikeShop), in by (13, 28): the clerk -// (9, 3) is across the counter (8, 3), talked to from (7, 3). With the -// voucher he gives the BICYCLE (FLAG_GOT_BICYCLE) with no YES/NO; it -// isn't registered or ridden yet. -// - The Mart: 5 Repels (row 9, 350 each) and 2 Escape Ropes (row 8, -// 550 each; pokefirered items.json), 2850 in all. Console B had about -// 9000 after Lt. Surge (2026-11-03); the floor of 6000 leaves 3000 or -// more after them. -// - The nurse, and the save in Cerulean's Center. -StoryCheckpoint bike_voucher(){ - const MartPlan repels{ - .map = std::string(CERULEAN_MART), - .lines = {{.item = "repel", .quantity = 5}, {.item = "escape-rope", .quantity = 2}}, - .budget = 2850, - .money_floor = 6000, - }; - return row("00.26", "The BIKE VOUCHER from the Fan Club, back north to Cerulean, the BICYCLE, Repels and Escape Ropes", at(VERMILION_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("below_center", at(VERMILION, 14, 10), "out of the Center, down to the water (14, 10): off Oak's aide's row 7")), - running(route("beside_chairman", at(FAN_CLUB, 4, 4, EAST), "east along row 10, down to the Fan Club's door (12, 17), in, and up its west side beside the chairman (5, 4)")), - talk("chairman", "\"I chair the POKEMON Fan Club!\" ... \"Did you come to hear about my POKEMON?\""), - answer("hear_story", true, "YES: his story"), - scene("bike_voucher", at(FAN_CLUB, 4, 4, EAST), "the story of his Rapidash; the BIKE VOUCHER"), - running(route("west_of_oaks_aide", at(VERMILION, 22, 10), "out of the Fan Club, east along row 18 and up column 22 to (22, 10)")), - running(route("route6_south_path", at(ROUTE6, 11, 34, NORTH), "up column 22 west of Oak's aide (25, 7), out of the city onto Route 6's path, below Jeff's row")), - running(legs("round_isabelle_and_elijah", {{NORTH, 1}, {WEST, 4}, {NORTH, 2}, {EAST, 9}, {NORTH, 19}}, "onto Jeff's row (11, 33), west to the wall (7, 33), up to (7, 31), east along row 31 to the wall (16, 31), up column 16 to the ledge (16, 12): out of Isabelle's and Elijah's lines")), - running(route("below_cerulean_tree", at(CERULEAN, 26, 33, NORTH), "the Underground Path north, up Route 5's side into Cerulean, below the tree (26, 32)")), - cut_tree("cut_cerulean_tree", at(CERULEAN, 26, 32, NORTH), "the tree; a step onto its tile"), - running(route("bike_clerk", at(BIKE_SHOP, 7, 3, EAST), "west into the Bike Shop (13, 28), across the counter from the clerk (9, 3)")), - talk("talk_bike_clerk", "\"Oh, that's... A BIKE VOUCHER!\""), - scene("bicycle", at(BIKE_SHOP, 7, 3, EAST), "the voucher exchanged for a BICYCLE"), - running(route("mart_clerk", at(CERULEAN_MART, 4, 3, WEST), "out of the Bike Shop to the Mart's clerk")), - mart_step("buy_repels", "5 Repels and 2 Escape Ropes, 2850 at most", repels), - running(route("cerulean_nurse", at(CERULEAN_CENTER, 7, 4, NORTH), "out of the Mart to the Center")), - heal("heal_cerulean"), - }); -} - -// East out of Cerulean over Route 9 to Route 10's Pokemon Center -// (pokeguy 45:12 to 47:27), on foot: the Bicycle isn't registered yet. -// - Cerulean (CeruleanCity map.json): the way east, column 39..40 up -// from row 33 to rows 18..19 and out of the city's east edge, is -// reached from the city only through the tree (26, 32), grown back -// since 00.26 (its flag is a FLAG_TEMP), or the burgled house. Cut -// from above. Route 9 joins the city's rows 18..19 by its rows 8..9 -// (offset -10); its tree (2, 8) (FLAG_TEMP_12) closes them, (2, 9) -// being rock: cut from (1, 8), west of it. -// - Route 9 (Route9 map.json, scripts.inc), its ledges all facing south. -// Of its nine trainers, three can't be walked around, as in pokeguy's -// run, where Jeremy happened to look away: -// - Picnicker Alicia (14, 10) faces west, sight 3, over (11..13, 10), -// the only tiles above the ledge row 11 the way west goes down by: -// fought on the step onto (11, 10); she walks up to (12, 10). Then -// down the ledge (11, 11). -// - Hiker Jeremy (20, 17) looks north and west (FACE_UP_AND_LEFT), -// sight 4: north over (20, 13..16), every way east of column 19 -// below the rocks of row 12. Fought on (20, 13), waiting for him to -// look north (TRAINER_WAIT_VARIANT); he walks up to (20, 14). -// - Bug Catcher Conner (49, 7) faces east, sight 3, over (50..52, 7): -// the way north from row 13 is column 52 alone (the ledges of row -// 11 face south), and row 7 is the way onto the ridge. Fought on the -// step onto (52, 7); he walks up to (51, 7). -// - Hiker Brice wanders row 2 (50..56), looking west and east, sight -// 1, over (49..57, 2), and the way up from the ledges of row 4 is -// (50..51, 4) below him. The leg up column 51 ends on row 3 if he -// stands at (51, 2), else it goes on to (51, 1) past him, and he may -// see the player there; either way the legs to walls after it meet -// on (48, 1): west to the rock (48, 3) or (48, 1), up to (48, 1). -// Row 1 is clear of his sight; east along it to the rock (64, 1) -// and down column 64 past the hidden Rare Candy (63, 2), not picked -// up. A held leg down to (64, 3) would hop the ledge (64, 4) and go -// on, so the last tile is one step, then the hop. -// - Picnicker Caitlin (60, 9) faces east over (61..64, 9): the way to -// Route 10 goes along row 8, above her line, by legs to (70, 8), a -// tile short of the edge. Camper Chris (26, 7), -// Bug Catcher Brent (26, 1), Camper Drew (36, 6) and Hiker Alan (61, -// 16) are off the way; TM40 (12, 17) is left. -// - Route 10 (Route10 map.json) joins Route 9's rows 8..10 by its own; -// its north part, down to the Center's door (13, 20), has no trainer -// on the way and its grass is walked round. The trees west of the -// door (10, 20..26) stay. The walk there ends its open legs where a -// tile of error can't reach a blocker, and finds its place again on -// walls (console B, 2026-11-09, two runs "no fade" at the door): the -// step onto Route 10 is not always held up, so the player may stand a -// tile further east, and the leg along row 11 holds to the wall -// (17, 11) instead of ending on (16, 11) by count. The 12 tiles down -// column 16 may end a tile short or long: from rows 22..29 a tile west -// and up to the Center's wall (15, 20) all end on (15, 21). West along -// row 21 to the wall (9, 21) ends on (10, 21), three west of the -// door's column: the only count no wall after it checks. -// - The nurse, and the save in Route 10's Center: the save card names -// ROUTE 10. -StoryCheckpoint route10_center(){ - return row("00.27", "East over Route 9 to Route 10's Pokemon Center: the two trees, Alicia, Jeremy and Conner", at(CERULEAN_CENTER, 7, 4, NORTH), after_brock(), StartMenu::FULL, { - running(route("above_cerulean_tree", at(CERULEAN, 26, 31, SOUTH), "out of the Center, south through the city to above the tree (26, 32), grown back")), - cut_tree("cut_cerulean_tree", at(CERULEAN, 26, 32, SOUTH), "the tree; a step onto its tile"), - running(route("west_of_route9_tree", at(ROUTE9, 1, 8, EAST), "down to row 33, east and up column 39 or 40 to row 18, east out of the city onto Route 9, west of its tree (2, 8)")), - cut_tree("cut_route9_tree", at(ROUTE9, 2, 8, EAST), "Route 9's tree; a step onto its tile"), - running(route("above_alicia_line", at(ROUTE9, 11, 9, SOUTH), "east to (11, 9), above the west end of Alicia's line")), - into_line("alicia_line", SOUTH, "onto (11, 10), in Alicia's line: she walks up to (12, 10)"), - battle("picnicker_alicia", at(ROUTE9, 11, 10, EAST), false, "Oddish, Bellsprout, Oddish and Bellsprout, Lv18"), - hop("alicia_ledge_hop", SOUTH, at(ROUTE9, 11, 12, SOUTH), "down the ledge (11, 11)"), - running(route("west_of_jeremy_sight", at(ROUTE9, 19, 13, EAST), "down to row 13 and east along it to (19, 13), west of Jeremy's north line")), - into_sight("jeremy_sight", EAST, "onto (20, 13), four above Jeremy (20, 17): when he looks north he walks up to (20, 14)"), - battle("hiker_jeremy", at(ROUTE9, 20, 13, SOUTH), false, "Machop and Onix, Lv20"), - running(route("below_conner_line", at(ROUTE9, 52, 8, NORTH), "east along row 13 and up column 52 to (52, 8), below the east end of Conner's line")), - into_line("conner_line", NORTH, "onto (52, 7), the end of Conner's line: he walks up to (51, 7)"), - battle("bug_catcher_conner", at(ROUTE9, 52, 7, WEST), false, "Caterpie, Weedle and Venonat, Lv20"), - running(legs("round_brice", {{NORTH, 2}, {WEST, 1}, {NORTH, 2}, {WEST, 3}, {NORTH, 2}, {EAST, 16}, {SOUTH, 1}}, "up to the ledge (52, 4), up column 51 to Brice's row, west to the rock (48, 3) (or (48, 1)), up to (48, 1), east along row 1 to the rock (64, 1), down to (64, 2)")), - step_onto("above_east_ledge", SOUTH, at(ROUTE9, 64, 3, SOUTH), "onto (64, 3), above the ledge (64, 4)"), - hop("east_ledge_hop", SOUTH, at(ROUTE9, 64, 5, SOUTH), "down the ledge (64, 4)"), - running(legs("above_caitlin_line", {{SOUTH, 3}, {EAST, 6}}, "down column 64 to row 8, east along it to (70, 8): above Caitlin's line (61..64, 9)")), - running(route("route10_ledge_end", at(ROUTE10, 17, 11, EAST), "east onto Route 10, down to row 11 west of the grass and east along it to the wall (17, 11), above the fence post (17, 12)")), - running(legs("below_center_door", {{WEST, 1}, {SOUTH, 12}, {WEST, 1}, {NORTH, 2}, {WEST, 5}, {EAST, 3}}, "into the ledge's gap (16, 11), down column 16 to row 23, a tile west, up to the Center's wall (15, 21), west along row 21 to the wall (10, 21), east to (13, 21), below the door")), - running(route("route10_nurse", at(ROUTE10_CENTER, 7, 4, NORTH), "up onto the Center's door (13, 20), to the nurse")), - heal("heal_route10"), - }); -} - - - -std::vector cpp_rows(){ - return { - new_game(), after_sid_helper(), leave_house(), oaks_trigger(), to_starter_ball(), starter(), parcel(), pokedex(), shopping(), forest(), brock(), - running_shoes(), route3(), magikarp_salesman(), after_gift_rng(), magikarp_to_box(), mt_moon(), - route4_to_cerulean(), cerulean_gym(), misty(), cerulean_grind(), cerulean_rival(), nugget_bridge(), - route25(), bill(), back_to_cerulean(), oddish(), to_vermilion(), ss_anne(), - vermilion_gym(), to_lt_surge(), lt_surge(), bike_voucher(), route10_center(), - }; -} - -// Why `loaded` differs from `row`, or empty. Steps compare as their -// shared JSON, which writes every field. -std::string checkpoint_difference(const StoryCheckpoint& row, const StoryCheckpoint& loaded){ - const std::string row_json = Pokemon::story_checkpoint_json(row).dump(); - const std::string loaded_json = Pokemon::story_checkpoint_json(loaded).dump(); - if (row_json != loaded_json){ - return std::format("{}: the file loads to\n{}\nbut the C++ row is\n{}", row.id, loaded_json, row_json); - } - if (row.handoff != loaded.handoff || row.live_start != loaded.live_start){ - return row.id + ": a different handoff or live start."; - } - for (size_t c = 0; c < row.steps.size() && c < loaded.steps.size(); c++){ - if (row.steps[c].once_per_save != loaded.steps[c].once_per_save){ - return row.id + "/" + row.steps[c].name + ": a different once_per_save."; - } - } - if (row.menu != loaded.menu){ - return row.id + ": a different START menu."; - } - const Supplies& a = row.supplies; - const Supplies& b = loaded.supplies; - if (a.potions != b.potions || a.antidotes != b.antidotes || a.parlyz_heals != b.parlyz_heals){ - return row.id + ": different supplies."; - } - if (a.lead.species != b.lead.species || a.lead.level != b.lead.level || a.lead.moves.size() != b.lead.moves.size()){ - return row.id + ": a different lead."; - } - for (size_t c = 0; c < a.lead.moves.size(); c++){ - if (a.lead.moves[c].move != b.lead.moves[c].move || a.lead.moves[c].pp != b.lead.moves[c].pp){ - return row.id + ": a different lead move " + std::to_string(c + 1) + "."; - } - } - return ""; -} - -class Test_AutoStoryTableParity : public UnitTest{ -public: - Test_AutoStoryTableParity() - : UnitTest("PokemonFRLG::AutoStory - the story files load to the C++ rows") - {} - virtual UnitTestResult run(Logger&, CancellableScope&) const override{ - try{ - const std::vector rows = cpp_rows(); - const std::vector& loaded = story_checkpoints(); - if (rows.size() != loaded.size()){ - return std::format("{} C++ rows, {} files.", rows.size(), loaded.size()); - } - for (size_t c = 0; c < rows.size(); c++){ - const std::string difference = checkpoint_difference(rows[c], loaded[c]); - if (!difference.empty()){ - return difference; - } - } - return true; - }catch (Exception& e){ - return std::string(e.name()) + ": " + e.message(); - } - } -}; - -} // namespace - - -void add_tests_AutoStoryTableParity(UnitTestDatabase& database){ - database.add(); -} - - - -} // namespace PokemonFRLG -} // namespace NintendoSwitch -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilionGym_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilionGym_Tests.cpp index 7f8f8ca8d3..ae79696202 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilionGym_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilionGym_Tests.cpp @@ -30,6 +30,7 @@ #include "PokemonFRLG_AutoStoryGrind.h" #include "PokemonFRLG_AutoStoryParty.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryTable.h" #include "PokemonFRLG_AutoStoryTrashCans.h" #include "PokemonFRLG_AutoStoryWinChance.h" diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilion_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilion_Tests.cpp index f8db770fe1..835d15a2a0 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilion_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilion_Tests.cpp @@ -20,6 +20,7 @@ #include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.h" #include "PokemonFRLG_AutoStoryEvents.h" #include "PokemonFRLG_AutoStoryRowSim.h" +#include "PokemonFRLG_AutoStoryRows_Tests.h" #include "PokemonFRLG_AutoStoryTable.h" namespace PokemonAutomation{ diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp new file mode 100644 index 0000000000..0c02e86a0d --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp @@ -0,0 +1,94 @@ +/* AutoStory Viridian Mart + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "Pokemon/AutoStory/Pokemon_BuiltinStoryActions.h" +#include "PokemonFRLG_AutoStoryActions.h" +#include "PokemonFRLG_AutoStoryBattle.h" +#include "PokemonFRLG_AutoStoryViridianMart.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +namespace{ + +// Viridian Mart before the Boulder Badge (pokefirered ViridianCity_Mart_Items): +// POKE BALL, POTION (300), ANTIDOTE (100), PARLYZ HEAL (200). Each item +// the story buys: its row, and where the bag's count is kept. +struct MartItem{ + std::string_view item; + int row; + int Supplies::* count; + // The name the item list reader reads (read_item_list_name()). + std::string_view slug; +}; +constexpr MartItem VIRIDIAN_MART_ITEMS[] = { + {.item = "potion", .row = 1, .count = &Supplies::potions, .slug = "potion"}, + {.item = "antidote", .row = 2, .count = &Supplies::antidotes, .slug = "antidote"}, + {.item = "parlyz_heal", .row = 3, .count = &Supplies::parlyz_heals, .slug = "parlyz-heal"}, +}; + +const MartItem* viridian_mart_item(const std::string& name){ + for (const MartItem& item : VIRIDIAN_MART_ITEMS){ + if (name == item.item){ + return &item; + } + } + return nullptr; +} + +} // namespace + + +Pokemon::Outcome viridian_shop(StoryEnv& env, const StoryStep& step){ + const std::optional> orders = viridian_mart_orders(Pokemon::story_arg>(step.args, "items")); + if (!orders){ + return Pokemon::outcome_failed("unknown_item", step.name); + } + // 2000 of the 3000 a new game starts with, plus the rival's prize. + buy_items(env.console, env.context, *orders, env.checks, env.language); + for (const Pokemon::StoryItem& item : Pokemon::story_arg>(step.args, "items")){ + env.supplies.*viridian_mart_item(item.item)->count += (int)item.quantity; + } + if (!checks_screen(env.checks)){ + return Pokemon::outcome_ok(); + } + // The counts from the bag, not from the orders: a wrong row once bought + // Parlyz Heals for Antidotes unnoticed (console B, 2026-11-01). + const std::vector rows = read_items_pocket(env.console, env.context, env.language); + if (rows.empty()){ + env.console.log("Story: couldn't read the Items pocket; keeping the counts ordered.", COLOR_ORANGE); + return Pokemon::outcome_ok(); + } + for (const std::string& item : set_from_bag(env.supplies, rows)){ + env.console.log(std::format( + "Story: couldn't read how many {} the bag holds; counting {}.", + item, item_count(env.supplies, item) + ), COLOR_ORANGE); + } + return Pokemon::outcome_ok(); +} + +std::optional> viridian_mart_orders(const std::vector& items){ + std::vector orders; + for (const Pokemon::StoryItem& wanted : items){ + const MartItem* found = viridian_mart_item(wanted.item); + if (found == nullptr){ + return std::nullopt; + } + orders.push_back(MartOrder{found->row, (int)wanted.quantity, found->slug.data()}); + } + return orders; +} + + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.h new file mode 100644 index 0000000000..6582d62ecb --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.h @@ -0,0 +1,36 @@ +/* AutoStory Viridian Mart + * + * From: https://github.com/PokemonAutomation/ + * + * The SHOP step: Viridian Mart before the Boulder Badge, whose rows the + * story knows, and the bag's counts read back after it. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_AutoStoryViridianMart_H +#define PokemonAutomation_PokemonFRLG_AutoStoryViridianMart_H + +#include +#include +#include "PokemonFRLG_AutoStoryActions.h" +#include "PokemonFRLG_AutoStoryEvents.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// `items` as orders at the Viridian Mart before the Boulder Badge: the +// rows of POKE BALL, POTION, ANTIDOTE, PARLYZ HEAL. Nothing if it does +// not sell one of them. +std::optional> viridian_mart_orders(const std::vector& items); + +// A SHOP step: its "items" bought at the Viridian Mart, counted into +// `env.supplies`, and with Thorough checks the counts read from the bag. +Pokemon::Outcome viridian_shop(StoryEnv& env, const StoryStep& step); + + +} // namespace PokemonFRLG +} // namespace NintendoSwitch +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp index 7bb167bf66..640c85548a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp @@ -985,7 +985,6 @@ const AutoStoryTestCase AUTO_STORY_CASES[] = { void add_tests_AutoStory(UnitTestDatabase& database){ add_tests_AutoStoryRunPlan(database); - add_tests_AutoStoryTableParity(database); for (const auto& scenario : AUTO_STORY_CASES){ database.add(scenario); } diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 57d221dd20..6bffa66c1c 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1975,6 +1975,7 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRngOptions.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRowSim.h + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRows_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryRunPlan_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySimulation_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySummary.cpp @@ -1995,7 +1996,6 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/Data/Json_Tests.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTable.h - Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTableParity_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTeach_Tests.cpp @@ -2007,6 +2007,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryTrashCans_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilion_Tests.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryVermilionGym_Tests.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.cpp + Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryViridianMart.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryWinChance.cpp Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryWinChance.h Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStory_Tests.cpp