Skip to content

Add native portable trainer battle scripts - #116

Closed
Roxas2712 wants to merge 29 commits into
UNDERdecoded:mainfrom
Roxas2712:codex/portable-script-trainers
Closed

Roxas2712 wants to merge 29 commits into
UNDERdecoded:mainfrom
Roxas2712:codex/portable-script-trainers

Conversation

@Roxas2712

@Roxas2712 Roxas2712 commented Oct 22, 2026 •

Copy link
Copy Markdown

Adds portable API-3 start_battle("trainer", trainerRef, partyIndex?) using this host's native trainer constructor, entry and cleanup paths.

Preflight and dispatch validate the selected roster, species/levels, native class aliases and Gen3 trainer/flag metadata. Numeric Gen2 classes resolve to canonical host class records; Gen3 numbers resolve through trainerOrder. Ambiguous/missing references are refused rather than guessed from display names. Gen3 wins reuse the native victory-flag and Match Call helpers. Same-session native cleanup survives mod retirement, while stale script continuations cannot run later effects.

Dependency: merge #115 and prerequisites first. Focused change 7f46d4d…089a4c9.

Validation at clean head 089a4c9c1dbdbbbd65fd02bee19ad3af3f356d00:

  • 160 focused checks, including actual native trainer/Pokémon constructors for five versions, canonical alias selection, malformed/changed rosters, constructor/admission/cleanup failures, session retirement, native Gen3 win flags and cleanup after unloading.
  • Existing 201 wild/static, 135 public wild and 5,283 portable checks pass.
  • 136 cross-engine comparisons / 272 isolated loader runs against Gen1 79ea62f45fb2ea8f65d081a109431e4eb1bbdb36.
  • Full headless: 90/100 engine suites, SDK 3/3, B30 pass.
  • All-PR integration 9a978d5f4302aed6748c2092d4ceee3666013b25: 95/105 engine suites, SDK 3/3, B30 and 136/272 cross-engine checks.
  • Both full runs have the same 17 baseline failing assertions and 10 failed suites (27 FAIL lines). The integration log split one buffered driver line; a second T1/T2 run with unbuffered parent output confirms the exact same 27 FAIL lines. No additional failures. Full command still exits 1.
  • StyLua and git diff --check pass.

Trainer selectors remain game-specific. Use a native trainer number for shared Gen3 scripts; display names are not treated as reference constant aliases. Use an explicit member index in shared Gen2 scripts because the pinned reference requires it. Tests are ROM-free with native data/entry seams; no ROM gameplay, story-reward or pixel equivalence claim.

Hosted Actions: API 3 contracts and ci are action_required (fork workflow approval). Hosted tests have not run; the results above are local.

# Conflicts:
#	src/mods/Loader.lua
# Conflicts:
#	docs/modding.md
#	src/mods/Loader.lua
#	src/world/WorldAPI.lua
@Roxas2712 Roxas2712 closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant