feat(api): content.path, content.patrol and content.schedule, a character's walk by the game's own schedule #2620
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2620
Loading…
Reference in a new issue
No description provided.
Delete branch "snaildev99/Longshot:feat/mod-api-paths"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
A mod could not give a character a route. To have an NPC walk somewhere, a script had to move it every frame, which jitters and has none of the game's walking: no turning into a bend, no stepping around things, no finding the way back. This adds three content declarations that write the game's own data for a walker, so the game's schedule walks the character and no script moves it:
content.path: a line through a map from points of the mod's own, closed or open, a curve through the points or a corner at one. A point may hold the walker (wait,animation,face).content.patrol: a placed character walks a path at every hour, at its own walk or at a run (gait: "run").content.schedule: a character's day. Each action walks a path or goes to a place, from its hour.The character is one of the game's placed ones, or a mod's own copy of a game actor at a placement the mod adds or changes to that actor.
From them the content stage makes what the game's walkers have: a Guide rail in the map's static file, the placement's reference to it, and the actor's schedule. The routine's actions go into the default schedule and into each schedule the story's flags turn on, whose events (what the character says in that state) are left as they are. The stage reads the player's game first and stops the mod's content with the reason for a placement the map lacks, one that belongs to another actor after the mod's ordered placement changes, an actor with no schedule, or a run for an actor with no run animation.
Under it, typed patches gain a
railskind and a placementssetwithrailorlink, and the pack builder takes a component file the actor's pack lacks from the RomFS (an NPC's schedule is such a file), so a copied actor gets a schedule of its own.One fix rides along: a placement
content.placeadds with an SRTHash of 2^31 or more was written as an int64 where the game's is a uint.The forge target is
mod-api; the branch is on8efb4b3eb. Read first:game/crates/content/src/plan/outputs.rs(routine_schedules,schedule_ops),game/crates/content/src/plan/curve.rs,game/crates/content/src/patch/apply.rs(the rails and therailandlinksets),game/crates/api/src/loader/stage.rs(schedule_of,runs). The guide is "Paths and patrols" indocs/modding/content.md;docs/dev/reference/content.mdsays how the game's files were read and what a run has shown.Testing
Tested: Windows 11, GeForce RTX 3090, NVIDIA 610.88, by hand in the adult Kakariko Village. The rebased head
ed7e858b3ran with the commits offix/rust-script-cpu-budgeton top (not in this pull request: without them false script CPU faults on Windows stopped the test mod that labels the walkers), and the five walkers below were reported good. The runs before it were at5401194bf, this branch before its rebase onto8efb4b3eb, built the same way.A test mod (not in this pull request) had five walkers: two game villagers on closed loops (one over a hillside, one along a street at a run with a 3 s stop), one on an open path up a slope with stops, one on a day of four actions (a walk and three places by the hour), and the mod's own copy of a villager on a loop of its own. Over the runs before the rebase:
After the review,
53bde610echanged what the stage refuses (a map the game lacks, and a mod's own actor at a game placement the mod did not change); it is covered by the tests below and has not run in the game.Without the game, before the ordered placement validation: the content crate's 257 tests pass,
schema-gen --checkpasses,apiandmodtooltype-check with their tests. Of theschemaandmodtooltests 204 pass and one fails,emulators::tests::eden_and_ryujinx_mods_are_found_with_their_switches: it makes two folders whose names differ only in case, which are one folder on Windows, in a file this branch does not change.tests/run_all.py --changedruns four checks: two pass, andtest_parity_gates.pyandtest_dev_build.pyfail on Windows for their Linux paths and gates, in files this branch does not change. The wholemise run testhas not run on this PC.Before the rebase the stage's patches were applied to this PC's game files without the game: every op applied to the schedule files of four villagers (2 to 8 story schedules each, all with the routine's actions and their own events), and the run was refused for the villager without the animation and allowed for one with it.
Still to test:
Measurements
Nothing to measure: the stage runs once when a mod's content is made at the start, and the game walks the character with its own schedule and rail code, so no script or hook of this change runs in a frame.
Risks
Nothing changes for a player without a mod that declares a path, a patrol or a schedule; a revert is enough. With such a mod the actor's routine is replaced in every state of the story, and every placement of that actor follows it (the guide says so): a character the story moves or holds somewhere by its schedule would walk the mod's path instead, until the mod is turned off. A walker may not answer the talk button, as Testing says. A mod's
content.placeplacement with an SRTHash of 2^31 or more is now written with the game's type; its place and its id are the same. Saves,longshot_options.iniand the caches are not touched.Checklist
The integration target is
mod-api, so "currentmain" below is read as currentmod-api.Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (Not run whole on this PC; the parts that ran are in Testing.)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
A content module declares a path from points of its own and gives it to one of the game's placed characters: const loop = path({ id: "WellLoop", map: "SomeVillage", age: "adult", closed: true, points: [...] }); patrol({ path: loop, actor: "Npc_SomeVillager", placement: "00a1b2c3d4e5f607" }); The stage makes what the game's own walkers have, so the game's schedule walks the character and no script moves it: - the rail: a Guide rail in the map's static file, a curve through the points with the handles and lengths the game's own rails have (plan/curve.rs), a point with `corner: true` left a corner; - the placement's reference: its Rails names the rail, and its MoveRadius reaches the rail's farthest place; - the schedule: the actor's schedule file gets one action at every hour, the game's own walk along the rail its placement names, in place of its other actions and the schedules the story's flags turn on. Two additions to typed patches carry it, and are a mod's to use as files too: - a `rails` kind: a map's rails by hash (`add`, `set`, `remove`), an added rail's numbers written as the game's types whatever the JSON says (hashes uint64, vectors and lengths floats); - a placements `set` with `rail`: the placement follows that rail of the file. The applier writes the reference in place of one to a rail of the same kind, and the radius from the rail as the file has it. It is an op of its own because a placements `set` only changes a key the placement has, and a hash inside a list a patch adds would take its type from how the JSON wrote it. The stage reads the player's game first (GameFiles::schedule_of, the map's file): a placement the map lacks, one that is another actor's, or an actor with no schedule stops the mod's content with the reason. An NPC's schedule is a file of the RomFS its actor names, not a member of its pack, so the schedule is a keys patch of that file. Not yet: a mod's own actors and placements (a copy has the schedule file of the actor it copies), a wait or an animation at a point, a schedule by the hour. Preview: read from the game's rails and schedules and tested without the game; docs/dev/reference/content.md says what a game run has to confirm. Assisted-by: Claude Fable 5.2 Co-Authored-By: Claude Fable 5.2 <[email protected]>An NPC's schedule (its AISchedule component) is a file of the RomFS its ActorParam names, not a member of its pack, so a copy of the actor could not change it: the pack builder refused a component whose file the pack does not hold. It now reads such a file from the RomFS as the layers serve it (`read("romfs:<path>")`), changes it and puts the copy in the new actor's pack under its name, as it does a member's. The pack and merge part of e7acadb76 (feat/rust-custom-model-npc), which has run in the game there: the village's characters are copies with schedules of their own. Assisted-by: Claude Fable 5.2 Co-Authored-By: Claude Fable 5.2 <[email protected]>Three additions to paths and patrols, each the game's own data for it: - A path's point may hold the walker: `{ at, wait, animation, face }`. The rail's point gets the game's stop (its wait in frames, 30 a second; its animation; the way it stands as the point's rotation). - `content.schedule({ actor, placement, map, age, actions })`: a character's day. Each action walks a path (`walk`) or goes to a place (`go`, with `face` and `animation`) from its hour (`at`). One action holds at every hour; several are the game's free-form day, each with its start. A place is added to the map as the game's anchor of its number and the character's placement linked to it. One path and at most 9 places a schedule. - A patrol's or a schedule's actor may be one the mod made of a game actor, and its placement one the mod placed in the map's static file. The actor's schedule is then a component of its own pack (a changed copy of the copied actor's file), and the game's actor keeps its own. Typed patches get a placements `set` with `link`: the placement linked to another placement of the file, in place of its link to one of the same actor, its MoveRadius reaching it. Fix: a new placement's SRTHash of 2^31 or more was written as an int64 (a JSON whole number past an int), where the game's is a uint. About half of the placements content.place adds had it. Found by applying the stage's patches to a real map file and comparing every field's type with the game's own. A patrol is a routine of one action now; its outputs are the same but for walk-<n>.json's description. Assisted-by: Claude Fable 5.2 Co-Authored-By: Claude Fable 5.2 <[email protected]>Tested in game: Windows 11, GeForce RTX 3090, NVIDIA 610.88, by hand in the adult Kakariko Village, at 5401194bf (this branch before its rebase onto mod-api
8efb4b3eb, built with the two commits of fix/rust-script-cpu-budget on top). Five walkers of a test mod: two game villagers on closed loops (one at a run with a stop), one on an open path with stops, one on a day of four actions, and the mod's own copy of a villager. They walk their paths by the game's schedule. One of three game villagers tried answers the talk button while walking; two do not, cause unknown (see Testing). The rebased head has not run in the game.@review
Recommendation: Request changes. A routine can be accepted for the wrong placement, so its rail and schedule are applied to different actors. Missing or unreadable maps also bypass the promised placement check and can leave the mod only partly applied.
Adds paths, patrols and daily schedules using game rails and schedules, plus a typed-patch extension and a placement hash fix. It gives mod authors native walking without per-frame scripts, at the cost of replacing an actor's routine and potentially affecting its other placements.
Blocking (2): must change before merging.
game/crates/content/src/plan/outputs.rs:678: A mod-owned actor bypasses the placement's actor check without verifying that a change actually replaces that placement. (more on the line) Do: Require a matching change of that placement in the same map to the mod-owned actor, or validate the effective placement after applying the mod's changes.game/crates/content/src/plan/outputs.rs:665: An absent, unreadable, or structurally invalid map skips placement validation instead of failing the content stage. (more on the line) Do: Return a stage error when the real game's map cannot be read or has no valid Actors array; provide an explicit fake-game validation path for tests.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1 and L2.Questions (1) (not confirmed from the code; they don't hold the recommendation)
Checks: Still running:
Guide screenshots / Guide images and local UI source review (pull_request),Third-party parts / As their notes say (pull_request),Third-party parts / The same as upstream (pull_request).More: does it help, other systems, switches, what was read
Does it help: Unproven on the submitted head. The author reports five walkers working on Windows before the rebase, with two talk interactions still failing; the rebased head has not run in the game.
Other systems: The stage and typed-patch code affect modded game startup on Windows and Linux. Schedules affect every placement sharing the actor, and the reported talk failures may affect story interactions. The submitted head has no game run; Linux has not been tested.
Switches: None.
Reviewed:
ed7e858b33against8efb4b3eb4: Read the repository rules, PR template, commit log, and the principal changes in stage.rs, pack.rs, merge.rs, plan/outputs.rs, plan/declare.rs, plan/curve.rs and patch/apply.rs. Skimmed the schema, patch parser, modding guide, reference notes and test vectors. The remaining changed files and surrounding code were not read in full, so this is not a complete first-pass review.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, scripts or tests were run. The PR reports pre-rebase Windows game runs and game-free checks on the submitted head.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -568,0 +662,4 @@if own_place(self, &r.decl.name).is_none() {if !maps.iter().any(|(f, _)| *f == r.file) {maps.push((&r.file, files.file(&r.file).and_then(|b| Document::read(&b).ok())));}L2 (blocking): An absent, unreadable, or structurally invalid map skips placement validation instead of failing the content stage.
When: A patrol names a nonexistent map and a valid scheduled actor. The map read returns None, the Actors check is skipped, and the stage emits a schedule patch even though its rail and placement cannot be applied to that map.
Do: Return a stage error when the real game's map cannot be read or has no valid Actors array; provide an explicit fake-game validation path for tests.
@ -568,0 +675,4 @@return Err(fail(format!("{} has no placement of that id", r.file)));};// (a mod's own actor there is the mod's change of the placement, made after this file was read)let is = placed.get("Gyaml").and_then(Node::text).unwrap_or_default();L1 (blocking): A mod-owned actor bypasses the placement's actor check without verifying that a change actually replaces that placement.
When: A mod declares a copied actor and gives its patrol the ID of an existing game placement without a matching content.change. The stage accepts it, attaches the rail to the existing actor, and puts the routine in the copied actor's pack, so the declared walker does not follow the path.
Do: Require a matching change of that placement in the same map to the mod-owned actor, or validate the effective placement after applying the mod's changes.
Tested in game on the rebased head: Windows 11, GeForce RTX 3090, NVIDIA 610.88, by hand in the adult Kakariko Village, at
ed7e858b3with the commits of fix/rust-script-cpu-budget on top. The five walkers of the test mod (moved to this base's UI module) were reported good. The description's Testing and checklist are updated; the whole mise run test is the box still open.Thanks for the review. Both blocking points were right and are fixed in
53bde610e.L1, a mod's own actor at a game placement. The stage now looks for the mod's
change()of that placement to that actor (the same file, placement and actor) and refuses the routine without it: "the placement is Npc_X, not <the mod's actor>: place it with place(), or change this placement's actor to it". With the change it goes through as before. Test:a_mods_own_actor_at_a_game_placement_needs_its_change_of_it.L2, a map that is not there. A map the game does not have, one that cannot be read, and one with no Actors list each stop the content with the reason, so no schedule patch is made alone. The stand-ins without a game (the test vectors' and
mod test's fake game) say so withGameFiles::reads_filesand take the placement as given, which is the explicit path for tests the review asked for. Tests: the three cases and the stand-in ina_patrol_the_game_lacks_makes_nothing.The content crate's 257 tests pass,
apiandmodtooltype-check with their tests, andmodtool's fake-game tests pass. This commit changes only what the stage refuses; it has not run in the game yet, and a run of the five walkers on it is next.L3. The five walkers ran in the game on
ed7e858b3, the head the review read, after the review was written (the comment above). Still open, as the description's Still to test says: the two talk failures compared with the mod off, and a patrol on Linux. The talk failures are in the guide under "Not yet for paths".The question, a schedule kept only inside an actor's pack. Not handled for a game actor:
schedule_ofreads it from the pack, but the patch then names it as a RomFS file and would not find it. Every NPC schedule read from the game so far is a RomFS file its ActorParam names, so nothing in this change's tests or runs meets the case. A mod's own copy is not affected (the pack builder takes the component from either place). I would take it as a follow-up: refuse such an actor with the reason, or patch the member in place.@review
Recommendation: Request changes. The placement check can still accept a mod-owned walker when a later change replaces it with a different actor. The current head and the reported talk failures also need game testing.
The change lets mods give characters paths and schedules using the game's walking logic. It adds validation and tests, but conflicting placement changes can still leave the rail and schedule assigned to different actors.
Blocking (1): must change before merging.
game/crates/content/src/plan/outputs.rs:678: The placement check accepts an earlier matching change even when a later change replaces the actor again. When: A mod changes a game placement to its own actor, then changes the same placement to another actor and declares a patrol for its own actor. Validation succeeds, but the ordered placement patches leave the other actor at the rail while the schedule belongs to the mod's actor. Do: Check the final actor-setting change for that file and placement, accounting for declaration order, and reject the routine unless the resulting actor matches.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1.Since the last review (on
ed7e858b33)Resolved: L2 (An absent, unreadable, or structurally invalid map skips placement validation instead of f…)
Still open: L1 (The placement check accepts an earlier matching change even when a later change replaces t…); L3 (The submitted head has not been exercised in the game, and the reported talk failures rema…)
Checks: Still running:
Guide screenshots / Guide images and local UI source review (pull_request),Third-party parts / The same as upstream (pull_request),Third-party parts / As their notes say (pull_request).Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven on the current head. Five walkers were reported working on the preceding head on Windows, though two villagers did not answer the talk button; the latest validation changes have not run in game.
Other systems: The stage reads game map and actor files on Windows and Linux; Linux patrol behavior remains untested. A game actor whose schedule exists only inside its pack is read but the resulting patch targets a RomFS file.
Switches: None.
Reviewed:
53bde610e8against8efb4b3eb4: Read the repository rules and pull request template, the changes since the previous review, the placement validation and declaration code, the placement patch generation, and the game-file reader. The full pull request diff and all changed files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that execute project code or tests were run. The author reports game-free tests and a Windows game run on the preceding head; the current head, Linux patrol, and comparison of talk behavior with the mod disabled remain to be tested.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@fix
WIP: feat(api): content.path, content.patrol and content.schedule, a character's walk by the game's own scheduleto feat(api): content.path, content.patrol and content.schedule, a character's walk by the game's own scheduleRecommendation: Approve. The code is ready: only testing is left. The five walkers worked on the preceding tested head, but the current head has not run in the game and the reported talk failures remain unexplained. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
8e963393a3. It was already up to date withmod-api. I edited its description to match the change.Changed
Nothing was built or run: the checks run again on the new head.
The change lets mods give characters paths and daily routines using the game’s own walking and schedule data. The latest fix validates the final declared actor at a routine’s placement, adding validation and tests without removing the feature.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Checks: they run again on this head; a failure shows on the pull request.
Also noticed (3; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven on the current head. Five walkers were reported working on
ed7e858b3on Windows; the current placement-validation changes have not run in the game.Other systems: The content stage reads game maps and schedules and generates patches and actor packs for Windows and Linux. The reported game run covers Windows; the description still calls for a Linux patrol and a comparison of the talk failures with the mod disabled.
Switches: None added, changed, or removed.
Reviewed:
8e963393a3against8efb4b3eb4: Read the latest fix diff and the placement-validation and patch-generation code around it, plus the supplied description, comments, ledger, and test reports. Skimmed the broader diff and repository rules; the other changed code files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run. The author reports the five-walker Windows run on
ed7e858b3; the latest validation tests have not been run, and CI has not run on this head.Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.