Files
gen1recomp/src/core/game3/scripting/multichoice.lua
T
1jamie aed3bbced7 fix(game3): battle animation timing, RNG parity, pokedex habitats, multichoice UI and overworld events
- Battle Animation Pipeline:
  * Eliminate 90-frame audio polling stall in anim_vm end/waitsound opcodes,
    allowing attack animations to transition instantly into target hit flicker
    and HP bar drain.
  * Correct visual task counting in AnimVm:visualCount to match pret gAnimVisualTaskCount.
  * Signal bg task completion on restorebg (vm.args[7] = -1).
  * Fix termination conditions on shake tasks (ShakeMon, ShakeMon2, ShakeBattleTerrain),
    WaterSport droplet arcs, and StartSinAnimTimer.
  * Handle RGB555 color args in start_blend_anim_sprite_color and route P.destroyTask
    to AnimTasks.destroy.

- RNG System & Seeding Parity:
  * Replace math.random in Party.giveMon with Rng.Random32() for personality values
    and Rng.Random() for IV bitfield extraction (HP/Atk/Def/Spe/SpA/SpD) matching GBA format.
  * Seed RNG on Title Screen A/Start press via Rng.seedNewGame() (matching SeedRngAndSetTrainerId)
    and perturb RNG state on title menu inputs.
  * Route NPC overworld idle/wander timers and wild encounter slot rolls through Rng.compat.

- Pokédex Habitat & Area Maps:
  * Fix encounter tables extraction and map indexing to resolve Pokemon habitat
    locations across Kanto/Sevii maps rather than showing Area Unknown.
  * Render steady semi-transparent red overlays for Pokédex area map locations.

- Multichoice Menus & UI:
  * Implement multichoice table extraction and data population for Viridian blackboard
    status ailments and special dialog interactions.
  * Improve choice box borders, pagination, and Town Map wall viewing.

- Overworld Events & Flags:
  * Fix Route 1 entrance girl NPC spawning and script triggers after starter selection.
  * Ensure consistent save reload state in Oak's Lab.
2026-09-19 01:30:46 -05:00

61 lines
1.9 KiB
Lua

-- Multichoice list strings for Sevii scripts (pret gMultichoiceLists subset).
-- Filled for Island 1 / common FRLG lists; expand via ROM extract later.
-- Keyed by listId (script operand). Each entry: { labels = {...}, left?, top? }.
local Multichoice = {}
Multichoice.LISTS = {}
--- Override/merge from extract cache if present.
function Multichoice.loadExtract(tbl)
if type(tbl) ~= "table" then return end
for id, entry in pairs(tbl) do
local n = tonumber(id) or id
if type(entry) == "table" and entry.labels then
Multichoice.LISTS[n] = entry
elseif type(entry) == "table" and entry[1] then
Multichoice.LISTS[n] = { labels = entry }
end
end
end
function Multichoice.tryLoadCache()
local ok, data = pcall(require, "src.import.gba.multichoice_data_stub")
if ok and type(data) == "table" then
Multichoice.loadExtract(data)
return true
end
-- CacheFS fallback for offline / test loads.
local okE, Extract = pcall(require, "src.import.gba.extract_island1")
local root = ((okE and Extract and Extract.CACHE_ROOT) or "data/generated/gba") .. "/scripts/multichoice.lua"
local chunk = loadfile(root)
if chunk then
local d = chunk()
if type(d) == "table" then Multichoice.loadExtract(d) return true end
end
return false
end
-- Preload cache immediately
Multichoice.tryLoadCache()
function Multichoice.resolve(listId, countHint)
if not next(Multichoice.LISTS) then
Multichoice.tryLoadCache()
end
local id = tonumber(listId) or 0
local entry = Multichoice.LISTS[id]
if entry and entry.labels and #entry.labels > 0 then
return entry.labels, { left = entry.left, top = entry.top }
end
-- Fallback synthetic labels (legacy).
local n = tonumber(countHint) or 3
local labels = {}
for i = 1, math.max(1, n) do
labels[i] = "OPTION " .. (i - 1)
end
return labels, { left = 20, top = 5 }
end
return Multichoice