build(combat): numbers foundation — formulas→Lua hot-reload + CombatSim + a CI band #216
Labels
No labels
alpha:wave-0
alpha:wave-1
alpha:wave-2
alpha:wave-3
area:assets
area:combat
area:ecology
area:infra
area:render
area:scripting
area:ui
area:world
enhancement
epic
migration
post-alpha
roadmap
tech-debt
type:bug
type:chore
type:design
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
marco/IsoMmo#216
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Build phase 1 of the combat rework (design: #214 ·
docs/game-design/systems/combat.md): the demonstrable-numbers foundation. Server-only, no combat-behaviour change — proves the "edit a Lua formula → hot-reload → CombatSim → CI band" loop on the real code, on the existingHitChancefirst. The combat-model rework (spacing, stats, counter-web) builds on this in later phases.Reviewed via
critical-design-review(Invariants Check below; no✗).What to build (in order)
content/scripts/combat/formulas.lua— a pure-function module, starting withhitChance(atkSkillTenths, defSkillTenths)identical to today (constants inline in the Lua). No behaviour change — only where the number comes from.ScriptHostto compile a module and hand itsClosures to C# (compile-once cache + hot-reload swap on the sim thread — reuse the existingCompile/reload). This is the one genuinely new capability (today the host only does content registration + handlers).LuaCombatFormulas(GameServer) behind the currentCombatFormulassurface: calls the closure and clamps/validates the result (a NaN/out-of-range return must never reach the tick — fatal pre-online, isolated online, per the scripting validation-symmetry).CombatSystemuses it; the staticCombatFormulasstays as a fallback/test-double.IsoMmo.CombatSim.Core(lib) — the seeded Tier-1 duel harness (calls the Lua formulas).tools/IsoMmo.CombatSim(console + HTML report) and the CI tests both reuse it.even-fight winrate ∈ [45,55]%), reproducible. More bands land as the model does.Accepted decisions
.d.luafor the formula-module signatures (editor types when tuningformulas.lua).IsoMmo.CombatSim.Corelib (tool + tests reuse it).Invariants Check (delta beyond the base DoD)
Server-authoritative ✓ (formulas are pure math called server-side; the sim is dev-only). Single-threaded sim ✓ (closure called in-thread; hot-reload swap on the sim thread, no lock). World.cs / Screen HARD GATE ✓ / N/A. Typed options ✓ (deliberate divergence: formula curves become Lua content; non-formula options stay typed — justified by the owner's hard "demonstrable + fast-iterate" requirement). ModernUO reference ✓ (divergence: MUO keeps formulas in compiled C#; we hot-reload them in Lua, pipeline stays C#). Content-in-Lua gate ✓ (refines the gate: combat pipeline stays C#, tunable formulas are Lua content — update
Scripting/CLAUDE.mdwording in the same change). Layering ✓ (formulas.lualoaded by the host;CombatSimrefsIsoMmo.Scripting, not GameServer). Protocol/AoI/String-catalog/Persistence/GM/Identity — N/A (no wire, no user text, no persisted state, no admin). API self-describing ✓ (.d.luagenerated for the module). Multi-platform ✓ (MoonSharp pure-managed; .NET tool).Server-side validation (trust boundary)
The
CombatSimis dev-only — no player surface, no intents, no authoritative state. The only untrusted input is the value returned by a Lua formula: the C# call-site validates/clamps it (a NaN/negative never reaches the tick). Pre-online a broken formula is fatal (like any script), online it is isolated (the tick survives).Verification plan
LuaCombatFormulas.hitChance== the static formula across an input grid (migration changes no numbers); the guard clamps a NaN/out-of-range return.formulas.lua, call it, rewrite the file, reload, see the number change (proves the tuning loop).just combatsimruns and produces the HTML report (win-rate / TTK).Definition of Done
hitChancefromcontent/scripts/combat/formulas.lua(compiled/cached), with identical numbers to before — proven by a unit test comparing to the old static formula.formulas.luaand reloading changes the number at runtime with no recompile (a hot-reload test proves it).just combatsimruns the seeded Tier-1 harness on the shared Lua formulas and emits a visible HTML report (win-rate + fight-duration).Scripting/CLAUDE.mdgate updated (pipeline C# / formulas Lua);docs/scripting.mddocuments the function-module capability; a.d.luafor the module is generated.dotnet testgreen, whole-solution build (client + tools), zero warnings; multi-platform preserved.Refs #214.