Log inGet started
Package

battle.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

battle

Persona-style turn-based combat for Amelia (HD-2D, storybook crimson/ink/parchment/gold palette).

local Battle = require("game.battle.battle")
Battle.wireEvents()                                         -- once at play start: Events "encounter"(pool, opts) -> start, then Areas.grace(4)
Battle.start({ "bramblewisp", "mossback" }, function(result) end)        -- "win" | "lose" | "flee"
Battle.start({ "frostling", "rime_wolf" }, cb, { arena = "snow" })
Battle.start({ "hush_warden" }, cb, { arena = "forest_hush", boss = true })
Battle.isActive()
Battle.stop()        -- abort, no onEnd / battleEnd
Battle.resetParty()  -- every member back to level 1, full HP/SP (in State)

opts: arena = "forest" | "forest_hush" | "snow" (default: "snow" when State.area() is rimecrest, else "forest"; a boss id forces "forest_hush"), boss (boss camera + no escape; implied by a boss id), noEscape, music (track override).

State: party = State.party() (1-3 members, layout adapts), stats in State.member(id) = {level, exp, hp, sp}; gold State.addGold, drops State.addItem, battle items consume State items (honey_tonic, moon_dew, wakebell, storm_jar).

Events emitted: battleStart(pool), battleEnd(result, pool), music("battle" | "boss" | "victory", then the area's music), sfx(name): battle_start, hit, weak, crit, null, ko, one_more, all_down, all_out, finish, victory, levelup, defeat, menu_move, menu_confirm, menu_back, menu_denied, heal, guard, cast, flee, silence, summon, boss_roar, boss_phase, boss_defeat.

Boss hush_warden: phase 1 weak Light / null Shade; at 50% HP phase 2 (sprite rekindles, weak Flame / resist Light / null Shade, acts twice, casts Silence = skills sealed 2 turns, summons 2 Gloomcaps). Rimecrest foes: frostling (weak Flame, null Frost), rime_wolf (weak Bolt, resists Gale & Frost).

The arena spawns at x=1000 (game.battle.arena), with its own camera (BattleCamera, priority 20). Themed arenas may retint Sun/Ambient/HeightFog and restore them on cleanup. Input: game.input.battle inputMap (group battle, suppresses player). UI screens: battle_hud, battle_pop, battle_flash, battle_splash.

Debug: Battle.debug.auto, .press(name), .speed, .log, .info(), .hurt(frac) (sets every foe's HP to frac of max).

Siblings: data (stats/skills/items/foes), arena (dioramas, sprites, camera rig, projection), vfx (spell effects), ui (widget trees), tools/cut.luau (sprite-sheet cutter; clear = {{x0,y0,x1,y1}} drops rects).