Skip to content

Add portable wild and static battle scripts - #115

Closed
Roxas2712 wants to merge 28 commits into
UNDERdecoded:mainfrom
Roxas2712:codex/portable-script-battles
Closed

Roxas2712 wants to merge 28 commits into
UNDERdecoded:mainfrom
Roxas2712:codex/portable-script-battles

Conversation

@Roxas2712

@Roxas2712 Roxas2712 commented Oct 22, 2026 •

Copy link
Copy Markdown

Adds API-3 start_battle("wild", speciesId, level), static_battle(speciesId, level, beatFlag?) and check_battle_result(...) on Gen1–3.

Whole-program preflight resolves canonical species and optional beat flags before any prefix runs. A private owned-script admission guard reuses the public encounter adapter's native construction, transition and afterBattle cleanup without relaxing ordinary public admission. Static encounters set their beat flag and hide the talking NPC on win/catch/flee, and skip both on loss. Results can drive portable conditional jumps.

Cancellation leaves native battle screens and same-session cleanup intact while retiring the script continuation. Changed sessions, native failures, cleanup errors, unloads during construction, replayed callbacks and foreign overlays cannot run later script effects.

Dependency: merge #114 and prerequisites first. Focused change 7e62026…7f46d4d.

Validation at clean head 7f46d4d0a6164ab6101816ebdf09ee8dc7253640:

  • 201 focused checks, including real native BattleState/Pokémon construction, all static outcomes with native object visibility, private flags, replays, cancellation/session changes and cleanup failures.
  • Existing 135 public wild-battle and 5,283 portable checks pass.
  • 128 cross-engine comparisons / 256 isolated loader runs against Gen1 79ea62f45fb2ea8f65d081a109431e4eb1bbdb36.
  • Full headless: 89/99 engine suites, SDK 3/3, B30 pass.
  • All-PR integration d69167fc542c6ba680e551632706a6a9e30df82f: 94/104 engine suites, SDK 3/3, B30 and 128/256 cross-engine checks.
  • Both full commands exit 1 with exactly the same 27 prerequisite baseline FAIL lines; no additional failures. StyLua and git diff --check pass.

The pinned Gen1 implementation delegates Gen1 static encounters to its native command, which does not namespace private beat flags. Shared Gen1 static cases use a real native beat flag; this host's consistent namespaced behavior is covered separately. Tests are ROM-free with native entry/timing seams; no ROM gameplay/pixel equivalence claim. Trainer encounters are the next separate slice.

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
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