diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp index 2393cf8600..9793952810 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim.cpp @@ -342,10 +342,9 @@ bool OverworldSim::trainer_sees(Milliseconds pressed){ trainer.x = stop.x; trainer.y = stop.y; trainer.wander.reset(); - // The player turns to face the trainer. - for (Direction direction : {Direction::NORTH, Direction::EAST, Direction::SOUTH, Direction::WEST}){ - m_state.facing = m_player.position.next(direction) == stop ? direction : m_state.facing; - } + // The player keeps their facing: the game doesn't turn them to the + // trainer (pokefirered TrainerSeeFunc_PrepareToEngage(), the turn + // commented out). m_trainer_speaking = c; m_frozen = true; schedule(pressed + m_script.timing.tile * (1 + approach) + m_script.timing.trainer_notice, SimScreen::MESSAGE, false); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEndpoints_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEndpoints_Tests.cpp index 3e60b055e3..a5472871d3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEndpoints_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEndpoints_Tests.cpp @@ -339,6 +339,12 @@ const AutoStoryEndpointCase AUTO_STORY_ENDPOINT_CASES[] = { .input = {.checkpoint = "06.01"}, .expectation = {.map = "VermilionCity_PokemonCenter_1F", .tile = {7, 4}, .facing = Direction::NORTH}, }, + { + .name = "06.03 Route 6's grass until the lead is Lv31, then through the open beams to Lt. Surge", + // 06.02 fights Dwayne, Baily and Tucker. + .input = {.checkpoint = "06.03", .trainers_beaten_on = "VermilionCity_Gym"}, + .expectation = {.map = "VermilionCity_Gym", .tile = {5, 3}, .facing = Direction::NORTH}, + }, { .name = "06.04 Vermilion Gym: Lt. Surge, the THUNDERBADGE, then the Center", .input = {.checkpoint = "06.04"}, @@ -399,6 +405,11 @@ const AutoStoryEndpointCase AUTO_STORY_ENDPOINT_CASES[] = { .input = {.checkpoint = "10.03"}, .expectation = {.map = "PokemonTower_2F", .tile = {16, 6}, .facing = Direction::NORTH}, }, + { + .name = "10.04 Pokemon Tower 3F to 5F: a Super Repel, Ruth and Tammy", + .input = {.checkpoint = "10.04"}, + .expectation = {.map = "PokemonTower_5F", .tile = {18, 7}, .facing = Direction::SOUTH}, + }, { .name = "10.05 Pokemon Tower 6F: Jennifer, Emilia, the Rare Candy and the Marowak ghost", .input = {.checkpoint = "10.05"}, @@ -439,6 +450,11 @@ const AutoStoryEndpointCase AUTO_STORY_ENDPOINT_CASES[] = { .input = {.checkpoint = "12.02b"}, .expectation = {.map = "FuchsiaCity_PokemonCenter_1F", .tile = {7, 4}, .facing = Direction::NORTH}, }, + { + .name = "13.01 Cinnabar to the Pokemon Mansion: 1F and 2F up to 3F's room of holes, the statue switch pressed on the way", + .input = {.checkpoint = "13.01"}, + .expectation = {.map = "PokemonMansion_3F", .tile = {19, 13}, .facing = Direction::SOUTH}, + }, { .name = "13.02 Pokemon Mansion 3F's hole to 1F, 1F's stairs to B1F", .input = {.checkpoint = "13.02"}, @@ -489,6 +505,16 @@ const AutoStoryEndpointCase AUTO_STORY_ENDPOINT_CASES[] = { .input = {.checkpoint = "16.04"}, .expectation = {.map = "SilphCo_7F", .tile = {1, 7}, .facing = Direction::WEST}, }, + { + .name = "17.02 Saffron to Viridian Gym: Fly, Warren", + .input = {.checkpoint = "17.02"}, + .expectation = {.map = "ViridianCity_Gym", .tile = {15, 7}, .facing = Direction::NORTH}, + }, + { + .name = "17.03 Viridian Gym: Takashi, to Giovanni", + .input = {.checkpoint = "17.03"}, + .expectation = {.map = "ViridianCity_Gym", .tile = {2, 3}, .facing = Direction::NORTH}, + }, { .name = "17.04 Viridian Gym: Giovanni and the EARTHBADGE", .input = {.checkpoint = "17.04"}, @@ -576,11 +602,8 @@ const EndpointExemption ENDPOINT_EXEMPTIONS[] = { {.checkpoint = "04.05", .reason = "its helix_gap step is a plain step the sim reads as a trainer's line, and no trainer is there"}, {.checkpoint = "05.01", .reason = "ends on LEGS taps (Cerulean Gym): no declared end (checkpoint_end_pose())"}, {.checkpoint = "06.02", .reason = "Vermilion Gym's Cut tree and trash cans: PokemonFRLG_AutoStoryVermilionGym_Tests.cpp"}, - {.checkpoint = "06.03", .reason = "red: the walk to Lt. Surge ends on (5, 4), one tile short of the declared (5, 3)"}, {.checkpoint = "09.01", .reason = "the poster guard's step ends on (11, 3), not (11, 2): PokemonFRLG_AutoStoryHideout_Tests.cpp"}, - {.checkpoint = "10.04", .reason = "red: the sim turns the player to the trainer who walks up (OverworldSim::trainer_sees), so Tammy leaves them facing east; pokefirered's TrainerSeeFunc_PrepareToEngage does not turn the player, the plan's south stands"}, {.checkpoint = "12.03", .reason = "Route 21's Surf landing on the sand bar needs the Surf state the generic walk lacks: PokemonFRLG_AutoStorySurf_Tests.cpp"}, - {.checkpoint = "13.01", .reason = "red: the Mansion's holes leave the sim facing north, the plan declares south"}, {.checkpoint = "14.01", .reason = "ends on LEGS taps (the quiz machines): no declared end (checkpoint_end_pose())"}, {.checkpoint = "14.02b", .reason = "the quiz doors' gates are shut on a fresh sim: PokemonFRLG_AutoStoryCinnabarGym_Tests.cpp"}, {.checkpoint = "14.04b", .reason = "Celadon Gym's legs need the cut tree: PokemonFRLG_AutoStoryCeladonGym_Tests.cpp"}, @@ -588,8 +611,6 @@ const EndpointExemption ENDPOINT_EXEMPTIONS[] = { {.checkpoint = "16.03", .reason = "Silph Co.'s card-key doors and pads: PokemonFRLG_AutoStorySilph_Tests.cpp"}, {.checkpoint = "16.05", .reason = "Silph Co.'s card-key doors and pads: PokemonFRLG_AutoStorySilph_Tests.cpp"}, {.checkpoint = "16.06", .reason = "Silph Co.'s card-key doors and pads: PokemonFRLG_AutoStorySilph_Tests.cpp"}, - {.checkpoint = "17.02", .reason = "red: the sim turns the player to Warren as he walks up (OverworldSim::trainer_sees), so the row ends on (15, 7) facing west; pokefirered's TrainerSeeFunc_PrepareToEngage does not turn the player, the plan's north stands. The tile is checked by PokemonFRLG_AutoStoryViridian_Tests.cpp"}, - {.checkpoint = "17.03", .reason = "red, known: Takashi stands in the way after his battle, and below_giovanni stops on (10, 5) (the fault sweep's known-failing clean run)"}, {.checkpoint = "19.03", .reason = "the soul guard's gate scene moves the player: PokemonFRLG_AutoStoryGates_Tests.cpp"}, {.checkpoint = "19.04b", .reason = "Victory Road's boulders and floor switches: PokemonFRLG_AutoStoryBoulders_Tests.cpp"}, {.checkpoint = "19.04c", .reason = "Victory Road's boulders and floor switches: PokemonFRLG_AutoStoryBoulders_Tests.cpp"}, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp index 9ff539b5c6..b76c11681c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryFaultSweep_Tests.cpp @@ -76,6 +76,7 @@ #include "PokemonFRLG_AutoStoryFieldMoves.h" #include "PokemonFRLG_AutoStoryHideoutLift.h" #include "PokemonFRLG_AutoStoryItemUse.h" +#include "PokemonFRLG_AutoStoryMovedTrainers.h" #include "PokemonFRLG_AutoStoryPacedRoute.h" #include "PokemonFRLG_AutoStoryRowSim.h" #include "PokemonFRLG_AutoStoryTable.h" @@ -107,8 +108,6 @@ const std::map KNOWN_FAILING{ "below_gym_tree walks onto the gym's door warp and sees no fade (VermilionCity_Gym (4, 12)): the door's warp on the sim after trash_cans, which the sim stubs, not yet looked at"}, {"PokemonFRLG::AutoStory - Fault sweep: 09.02, clean run", "b2f_arrows_to_lift_room moves nothing twice from RocketHideout_B2F (1, 4) after moon_stone, a talk the sim stubs: the arrow tiles' spin from that tile on the sim, not yet looked at"}, - {"PokemonFRLG::AutoStory - Fault sweep: 17.03, clean run", - "Takashi (10, 2) walks up to (10, 4) when he sees the player on (10, 5) and stays there after the battle, so below_giovanni's way north up column 10 is blocked (moved nothing twice); on the console too: the route after a line battle planned with the trainer who walked up as a wall (with_trainers()), or a way to Takashi from row 3"}, {"PokemonFRLG::AutoStory - Fault sweep: 08.03, mount lost", "riding with no fault, route7_underground_exit's warp to UndergroundPath_EastEntrance is not confirmed on the sim (the screen after the fade reads as before the hold): the sim's warp off the Bicycle, before this class can sweep 08.03"}, }; @@ -199,11 +198,12 @@ std::set start_flag_set(const StoryCheckpoint& row){ // sweep_maps() as row `row` starts: the gyms cleared before it with no // trainer left to see the player, nor the trainers its start_flags have // beaten (16.03: the Rocket by 5F's corridor, whom 16.02's walk fights), -// and no Rocket left once its start_flags have Silph Co. cleared. +// each standing where its start_flags say he walked up to (17.03: Warren +// on (14, 7)), and no Rocket left once its start_flags have Silph Co. cleared. std::vector row_maps(const StoryCheckpoint& row){ - const std::set start_flags = start_flag_set(row); - const std::vector& base = start_flags.contains(std::string(SILPH_CLEARED_FLAG)) ? cleared_sweep_maps() : sweep_maps(); - std::vector maps = with_trainers_beaten(base, beaten_trainers(start_flags)); + const std::set flags = start_flag_set(row); + const std::vector& base = flags.contains(std::string(SILPH_CLEARED_FLAG)) ? cleared_sweep_maps() : sweep_maps(); + std::vector maps = with_trainers_beaten(with_trainers_moved(base, moved_trainers(flags)), beaten_trainers(flags)); const std::set cleared = gyms_cleared_before(row); for (MapData& map : maps){ if (!cleared.contains(map.name)){ @@ -308,17 +308,18 @@ bool hide_talk_battle_trainer(std::vector& maps, const StoryStep& step) return true; } -// Row `row`'s step `c` on `sim` from `at`, recorded in `out`. Returns -// whether it failed as unscripted() and was let pass (run_row()). +// Row `row`'s step `c` on `sim` from `at`, with the run flags the steps +// before it left (`run_flags`), recorded in `out`. Returns whether it +// failed as unscripted() and was let pass (run_row()). bool run_row_step( RowRun& out, OverworldSim& sim, StoryPose& at, const StoryCheckpoint& row, size_t c, - const std::optional>& scripted + const std::set& run_flags, const std::optional>& scripted ){ out.before.emplace(c, sim.state().position); out.facing_before.emplace(c, sim.state().facing); out.gates_before.emplace(c, sim.state().gates); const size_t warps_before = sim.state().warped_from.size(); - out.failure = row_step_on_sim(sim, at, row.steps[c], row.id, start_flag_set(row)); + out.failure = row_step_on_sim(sim, at, row.steps[c], row.id, run_flags); const std::vector& warped = sim.state().warped_from; out.warped_from[c].assign(warped.begin() + warps_before, warped.end()); const bool let_pass = unscripted(out.failure) && (!scripted || scripted->contains(c)); @@ -374,6 +375,8 @@ RowRun run_row( StoryPose at = *story_pose(Pokemon::pose_of(*row.start)); std::vector maps = row_maps(row); auto sim = std::make_unique(maps, MapPosition{at.map, at.tile}, at.facing.value_or(Direction::SOUTH), script); + // The run's flags: the start's, then each step's flags_after (trainer_at). + std::set flags = start_flag_set(row); const auto add = [&out](const SimState& state){ out.time += state.time; out.steps += state.steps; @@ -384,8 +387,9 @@ RowRun run_row( }; for (size_t c = 0; c < row.steps.size() && out.failure.empty(); c++){ const StoryStep& step = row.steps[c]; - const bool let_pass = run_row_step(out, *sim, at, row, c, scripted); + const bool let_pass = run_row_step(out, *sim, at, row, c, flags, scripted); play_ride_bike(*sim, script, step); + flags.insert(step.flags_after.begin(), step.flags_after.end()); if (!out.failure.empty() || (sim_plays(step) && !let_pass) || !step.pose_after){ continue; } diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h index d50829d6d9..cd658deb1a 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryPlanGolden17.h @@ -44,9 +44,16 @@ inline constexpr std::string_view FRLG_PLAN_GOLDEN_17_GYM[] = { "17.03 walk west 2 (to wall) -> ViridianCity_Gym (10, 7) [walk only]", "17.03 walk north 1 -> ViridianCity_Gym (10, 6) [walk only]", "17.03 below_giovanni from ViridianCity_Gym (10, 5) facing north to ViridianCity_Gym (2, 3) facing north", - "17.03 walk north 2 -> ViridianCity_Gym (10, 3) [walk only]", - "17.03 walk west 3 -> ViridianCity_Gym (7, 3) [walk only]", - "17.03 walk south 3 (to wall) -> ViridianCity_Gym (7, 6) [walk only]", + "17.03 walk south 2 (to wall) -> ViridianCity_Gym (10, 7) [walk only]", + "17.03 walk east 3 -> ViridianCity_Gym (13, 7) [walk only]", + "17.03 walk north 1 (to wall) -> ViridianCity_Gym (13, 6) [walk only]", + "17.03 walk east 3 (to wall) -> ViridianCity_Gym (16, 6) [walk only]", + "17.03 walk south 7 (spins 2) -> ViridianCity_Gym (16, 15) [walk only]", + "17.03 walk east 3 (to wall) -> ViridianCity_Gym (19, 15) [walk only]", + "17.03 walk north 1 (spins 11) -> ViridianCity_Gym (19, 3) [walk only]", + "17.03 walk north 1 (spins 8) -> ViridianCity_Gym (11, 2) [walk only]", + "17.03 walk west 4 -> ViridianCity_Gym (7, 2) [walk only]", + "17.03 walk south 4 (to wall) -> ViridianCity_Gym (7, 6) [walk only]", "17.03 walk west 5 -> ViridianCity_Gym (2, 6) [walk only]", "17.03 walk north 3 -> ViridianCity_Gym (2, 3) [walk only]", "17.04b gym_exit from ViridianCity_Gym (2, 3) facing north to ViridianCity (36, 11) facing south", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.02.plan.json index 32337f46e6..b060bb3e4d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.02.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.02.plan.json @@ -149,7 +149,11 @@ ], "facing": "north" }, - "why": "Warren (TRAINER_COOLTRAINER_WARREN): Marowak Lv37, Marowak Lv37, Rhyhorn Lv38, Nidorina Lv39, Nidoqueen Lv39" + "why": "Warren (TRAINER_COOLTRAINER_WARREN): Marowak Lv37, Marowak Lv37, Rhyhorn Lv38, Nidorina Lv39, Nidoqueen Lv39; he walked up from (13, 7) to (14, 7) when he saw the player on (15, 7) (pokefirered TrainerApproachPlayer: approach distance 2, one tile short) and stands there from now on (trainer_at), west of the player on row 7", + "flags_after": [ + "trainer_beaten:ViridianCity_Gym/cooltrainer_m@13,7", + "trainer_at:ViridianCity_Gym/cooltrainer_m@13,7=14,7" + ] } ] }, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.03.plan.json index 25600f94d1..f49837773c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.03.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.03.plan.json @@ -14,6 +14,10 @@ ], "facing": "north" }, + "start_flags": [ + "trainer_beaten:ViridianCity_Gym/cooltrainer_m@13,7", + "trainer_at:ViridianCity_Gym/cooltrainer_m@13,7=14,7" + ], "events": [ { "id": "below_takashi_line", @@ -64,7 +68,11 @@ ], "facing": "north" }, - "why": "Takashi (TRAINER_BLACK_BELT_TAKASHI): Machoke Lv38, Machop Lv38, Machoke Lv38, Machoke Lv43" + "why": "Takashi (TRAINER_BLACK_BELT_TAKASHI): Machoke Lv38, Machop Lv38, Machoke Lv38, Machoke Lv43; he walked up from (10, 2) to (10, 4) when he saw the player on (10, 5) (pokefirered TrainerApproachPlayer: approach distance 3, one tile short) and stands there from now on (trainer_at; TrainerSeeFunc_PrepareToEngage: OverrideTemplateCoordsForObjectEvent), across column 10 north of the player", + "flags_after": [ + "trainer_beaten:ViridianCity_Gym/black_belt@10,2", + "trainer_at:ViridianCity_Gym/black_belt@10,2=10,4" + ] }, { "id": "below_giovanni", @@ -82,7 +90,7 @@ "facing": "north" } }, - "why": "west along row 3 and down to (2, 3), facing Giovanni (2, 2)" + "why": "round Takashi, who stands on (10, 4) since his battle, to (2, 3), facing Giovanni (2, 2)" } ] }, diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04.plan.json index df66993362..c7e80f2482 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04.plan.json @@ -14,6 +14,12 @@ ], "facing": "north" }, + "start_flags": [ + "trainer_beaten:ViridianCity_Gym/cooltrainer_m@13,7", + "trainer_at:ViridianCity_Gym/cooltrainer_m@13,7=14,7", + "trainer_beaten:ViridianCity_Gym/black_belt@10,2", + "trainer_at:ViridianCity_Gym/black_belt@10,2=10,4" + ], "events": [ { "id": "lead_lv50_for_giovanni", diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04b.plan.json b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04b.plan.json index 4281616ef2..a5356963e3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04b.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/StoryData/frlg-17.04b.plan.json @@ -14,6 +14,12 @@ ], "facing": "north" }, + "start_flags": [ + "trainer_beaten:ViridianCity_Gym/cooltrainer_m@13,7", + "trainer_at:ViridianCity_Gym/cooltrainer_m@13,7=14,7", + "trainer_beaten:ViridianCity_Gym/black_belt@10,2", + "trainer_at:ViridianCity_Gym/black_belt@10,2=10,4" + ], "events": [ { "id": "gym_exit",