Skip to content

Dev tools

The dev runner and the checks in tools/dev/, and the documentation helpers in tools/docs/. See Dev runner for how they fit together.

amfp_dev

AMFP-2026 dev cycle driver: stage the build into _stage, launch straight into a map (no logos, profile screen or main menu), and drive the game through the dev bridge (Game/src/game/LuxDevBridge.cpp) instead of mouse clicks.

pixi run dev -- --map 00_rainy_hall.map --wait-active --shot out.png
pixi run dev -- --tour tools/dev/tours/menus.tour   # scripted run -> _tour/menus/sheet.png
pixi run dev -- --no-build --script "GiveHint(\"a\", \"Hints\", \"x\", 0);" --shot out.png

Everything runs in the _stage sandbox with its own save folder; the Steam install is never written to.

Bridge

Bridge(folder: Path, timeout: float = 10.0)

Writes " " to dev_bridge_in.txt, waits for " ".

use_x64

use_x64() -> None

Kept for older scripts: Windows is always the 64-bit build now.

dev_main_settings

dev_main_settings(text: str, language: str | None = None, width: int = 1280, height: int = 720, extra: list[str] | None = None) -> str

Sandbox main_settings.cfg: no pre-menu or menu, default profile, windowed, bridge on.

documents_dir

documents_dir() -> Path

Parent of the game's Amnesia/ (Windows: Documents; Linux: ~/.frictionalgames; macOS: ~/Library/Application Support/Frictional Games).

stage_links() -> None

A sandbox linked to the game's data (Linux ~/amfp_stage, Windows 64-bit _stage64): links to the game folders, copies of its small root files, its own Enhanced config (test profile). The game's exes and DLLs stay out, so only the build under test and its libraries run.

set_user_settings

set_user_settings(values: list[str] | tuple[str, ...]) -> Path

Write Section.Key=value items into the dev profile's user_settings.cfg (created from the Enhanced defaults when the profile has none yet).

kill

kill() -> None

Force-close the game (it ignores a polite stop).

start_watchdog

start_watchdog(seconds: float) -> None

Hard limit for a run: the game is force-closed after this many seconds, whatever it is doing.

bring_to_front

bring_to_front(delay: float = 4.0) -> None

macOS: a game started from a script stays behind the terminal; ask it to activate (an Apple Event to the running app, so no Accessibility permission is needed) once its window is up.

flatten_screenshot

flatten_screenshot(path: Path) -> None

The framebuffer's alpha is 0 in most of the scene; keep RGB only so viewers show it.

player_in_control

player_in_control(state: str) -> bool

Active, allowed to move (scripted standstills set move_mul 0) and not fast-forwarding.

skip_story

skip_story(bridge: Bridge, timeout: float = 300.0, poll: float = 0.5) -> str

Skip story scenes (the in-game Esc / B skip, pressed twice) until the player has control.

tour

Scripted dev tours: drive the game through the dev bridge from a small step file, waiting on game state (never on guesses), screenshot as you go, and finish with one contact sheet.

pixi run dev --tour tools/dev/tours/menus.tour            # build, run, sheet in _tour/menus/

Step file, one step per line, '#' comments: pad

doc_shots

Documentation screenshots: Original vs Enhanced pairs and single shots for the guide.

pixi run docs-shots                       # build, run the game three times, write the WebP files
pixi run docs-shots --no-build            # use the current build
pixi run docs-shots --only comfort-roll   # re-take some shots (their runs still play in full)
pixi run docs-shots --convert-only        # convert the last runs' PNGs again (no game)

It drives the game with the dev runner (amfp_dev.py) and the step file tools/dev/tours/doc_shots.tour, once per run in RUNS, each with its own settings: the Original run uses the Original preset, the Enhanced run the Modern preset. Every run starts from the same place, so a pair differs only in the settings. The PNGs land in tour/doc_shots/; the WebP files the guide uses go to guide/assets/shots/:

<id>-original.webp, <id>-enhanced.webp   a pair, shown with the before / after slider
<id>.webp                                a single shot
comfort-headbob.svg                      a chart of the camera height while walking

The guide shows a marked placeholder for every shot that has no file yet (tools/docs/macros.py), so the docs build without any of them.

The shots show the game's own art: keep them few and small (max 1280 px wide, WebP).

Run dataclass

Run(name: str, section: str, comfort: str, main: tuple[str, ...] = (), user: tuple[str, ...] = (), skip_story: bool = True, lang: str = 'english.lang', optional: str | None = None)

One game run: a tour section with its settings.

Shot dataclass

Shot(id: str, what: str, where: str, runs: tuple[str, ...] = ('enhanced',), page: str = '', chart: bool = False, clip: bool = False, caption_below: bool = False)

One figure in the guide. A pair has an Original and an Enhanced side.

files

files() -> list[str]

The file names the guide expects in guide/assets/shots/.

tour_for

tour_for(text: str, run: Run) -> str

The tour for one run: its #@section, its #@original / #@enhanced lines, and {comfort} filled in.

shots_in

shots_in(tour_text: str) -> list[str]

Shot names of a plain tour, in order.

check

check(text: str) -> list[str]

Problems between SHOTS and the tour: each screenshot taken in exactly its runs.

missing

missing() -> list[str]

Files the guide expects that are not in guide/assets/shots yet.

find_clip

find_clip(run_dir: Path, shot_id: str) -> tuple[list[Path], list[float]] | None

Frames and their times (s) of the last clip of a shot, or None if it was a still.

clip_to_webp

clip_to_webp(frames: list[Path], times: list[float], dest: Path) -> None

An endlessly looping animated WebP that plays at the captured speed.

headbob_svg

headbob_svg(original: list[list[float]], comfort: list[list[float]], reduced: list[list[float]] | None = None) -> str

A small line chart of the camera height (cm, trend removed) over time: Original, Comfort and (when traced) Reduced.

Mid-tone colours that read on the guide's light and dark themes alike (an SVG shown as an image cannot use the page's CSS).

convert

convert(only: set[str] | None = None) -> list[str]

Write the WebP / SVG files from the last runs' output; returns the files written.

set_user_settings

set_user_settings(values: tuple[str, ...]) -> Path

The run's values in the dev profile's user_settings.cfg (amfp_dev.set_user_settings).

comfort_check

Check the comfort tour's camera traces (tools/dev/tours/comfort.tour).

Each trace line: step yaw pitch roll fov aspect x y z (degrees, one line per logic step, 60/s). Prints a table per effect for Original, Reduced and Comfort and checks the Comfort limits: level horizon, forced turns under the cap, a small hit jolt, gentle zoom pulses. pixi run python tools/dev/comfort_check.py _tour/comfort

physics_check

Physics parity: the same scripted pushes on two builds, compared step by step.

Each build starts the first map, skips to the point the player can move, then pushes a door, a chair, a bottle and a lever (AddPropImpulse) while the dev bridge records the object's main physics body every logic step (trace). Tumbling objects never follow identical paths on two physics engines, so the comparison looks at behaviour: did it move, how far, how far did it swing, when did it settle, and where did it come to rest.

pixi run python tools/dev/physics_check.py --baseline <32-bit exe> [--steps 300]

The baseline is the 32-bit exe with Frictional's original Newton; the other run is the 64-bit CMake build (--x64 sandbox). Traces and the report go to _tour/physics/.

record

record(label: str, exe: str | None, x64: bool, out: Path, steps: int) -> None

Start one build, skip to player control, run every scenario, keep the traces.

summary

summary(rows: list[list[float]]) -> dict

Travel, peak swing, settle step and final pose of one trace.

fbx_oracle

Check the ufbx FBX loader against the original Autodesk SDK loader's output.

The game ships .anm files that the original exe cached for most of its FBX animations. For each FBX that has one, the game (through the dev bridge) loads the animation both ways and reports the differences: missing tracks, key counts, key times, positions, rotations, length.

pixi run dev --keep --menu          # start a game to talk to (any screen)
pixi run python tools/dev/fbx_oracle.py [--limit N]

Nothing from the game is copied into the repository; results go to _tour/fbx_oracle.txt.

fbx_with_cache

fbx_with_cache(game: Path) -> list[str]

Paths (relative to the game folder) of FBX files that have an .anm next to them.

build_api

Build the C++ and Rust API reference for the documentation website.

pixi run -e docs docs-api       # -> build/docs-api/cpp (Doxygen), build/docs-api/rust (rustdoc)

The MkDocs hook (tools/docs/hooks.py) copies both folders into the built site under api/; the Reference pages link to them. Only the code AMFP Enhanced added is documented:

  • C++: every header under Game/src/game and HPL2/core whose first comment starts with AMFP-2026: (the files the fork added; stock engine files that only carry a marked change are left out), plus the C header of the Rust text library.
  • Rust: the hpl-cjk-text crate (no dependencies are documented).
  • Python: the text module's type stub, copied to build/docs-api/py for mkdocstrings.

is_fork_file

is_fork_file(path: Path) -> bool

True for a file the fork added: its first comment starts with AMFP-2026:.

Added files open with /* and * AMFP-2026: ... or with // AMFP-2026: .... Stock engine files carry the marker only next to a change, so they are left out.

cpp_inputs

cpp_inputs() -> list[Path]

The C++ files to document, sorted, as paths relative to the repository root.

build_py_stub

build_py_stub() -> Path

The text module's type stub as a stub-only package, the form mkdocstrings (griffe) reads.

maturin wants the stub as hpl_cjk_text.pyi next to pyproject.toml; griffe finds a compiled module's stub only as <name>/__init__.pyi. mkdocs.yml lists this folder.

doxy_filter

Doxygen INPUT_FILTER for the files AMFP Enhanced added (the source files stay unchanged).

  • The leading header comment becomes the file's description. The files open with a plain block comment (/* then * AMFP-2026: ...) or a run of // AMFP-2026: ... lines, which Doxygen would ignore; the filter turns it into a @file block.
  • Placeholders in comments such as <game>/amfp_enhanced/bin or <map> are escaped, so Doxygen does not read them as unknown HTML tags.

Doxygen runs it as python tools/docs/doxy_filter.py <file> and reads the result.

filter_text

filter_text(text: str) -> str

The file text with its header comment made a @file block and placeholders escaped.

Check every local link and anchor in the built documentation site.

pixi run -e docs docs-check            # builds first, then checks site/
python tools/docs/check_links.py site  # an existing build

MkDocs' strict mode checks links between Markdown pages, but not links written as HTML (the API reference links), nor anchors inside the generated API pages. This walks every page the guide itself produced (everything outside api/) and checks each href and src that points inside the site: the file must exist and, for #anchor links, the target page must have an element with that id. External links (http, https, mailto) are not fetched.

site_base

site_base(root: Path) -> str

The path the site is served under, from site_url in mkdocs.yml ("/amfp-enhanced/").

resolve

resolve(site: Path, page: Path, link: str, base: str = '/') -> tuple[Path | None, str]

The file a link points to (None for external links) and its anchor.

Absolute paths count from base, the path the site is served under.

check

check(site: Path, base: str = '/') -> list[str]

All broken local links of the guide's pages, as readable lines.