Combat
Systems
Physics-driven melee, run as a batch ECS simulation. Coordinated, readable, deliberately fair — the AI wins on decisions, never on information it shouldn't have. The combat brain behind Masuki Quest.
Physics-driven melee, run as a batch ECS simulation. Coordinated, readable, deliberately fair — the AI wins on decisions, never on information it shouldn't have. The combat brain behind Masuki Quest.
Logic lives in stateless systems, presentation in Godot nodes. Order is load-bearing — each stage consumes what the last produced.
The fight is an Arch ECS simulation: thousands of small components, a handful of systems that sweep them in a fixed order every physics tick. A CombatCharacter node is only a body — the decisions happen in data. That keeps 14+ agents cheap, deterministic, and debuggable: you can log any component and replay a frame.
Crucially, perception runs first and everything downstream trusts only its output. No system peeks at the raw scene to find an enemy behind a wall — if perception didn't see it, the AI doesn't know it. That single rule is what makes the fights feel fair.
Fighters know only what they can see. A spatial grid finds candidates; capped raycasts confirm them. Three rules turn raw sightings into something that feels intelligent:
The "movie fight" layer. Allies converging on one target take turns: only the nearest few hold an attack permit; the rest flank to slots around the target.
Ranks recompute every frame, so turn-taking emerges instead of being scripted — as the front fighter recovers, the next in line is promoted into the opening. Nobody piles in at once, and nobody stands idle.
Confidence, seeded from personality and moved by events. It multiplies aggression and adds evasiveness — rattled fighters turn timid, bold ones press the advantage.
Because morale feeds back into the AI's action weights, a fight has a psychological arc: land a couple of clean hits and the line wavers; lose an ally and the whole squad pulls back.
Query-driven, not resident. Capsules on labelled bones (head ×2, torso ×1, limbs ×0.7) cost nothing until a swing's contact frame sweeps the blade against them — returning the struck bone, the point, and the multiplier.
Miss the geometry and you miss for real: there is no aim-assist, no "close enough." Aiming the swing is the skill.
Struck fighters flinch from the real contact point — a procedural bone kick for everyone (Tier A), a partial ragdoll up close (Tier B). Nothing snaps to a canned "hit" clip.
Attacks are full-body committed: the swing owns the body until it finishes and can't be cancelled back into a walk mid-strike, so whiffing has weight and punishing an over-commit is real.
Every weapon carries its own attack-speed multiplier, so one move-set reads differently in different hands — a sword snaps at ×1.3, a war‑hammer lands heavy at ×0.9. Reach, knockback and cooldown ride along on the same weapon definition.
When a foe finally drops, fighters don't blink back to calm. A tunable corpse-aggro window lets them keep swinging at the body — 0 disengages instantly, a few seconds means "make sure", and -1 never lets up — then they fall back to their guard post or patrol.
Behaviour derives from Pathfinder abilities + OCEAN traits — not hand-authored trees. Tune the stats, get a fighter.
Damage, knockback, desperation when wounded.
Move speed, dodge, evasion window.
Max HP and poise — resists stagger.
Assertiveness — presses the attack.
Tactical variety — longer, less predictable combos.
Fear — evades and flees when hurt.
Movement blends a walk/run space by speed, with an upper-body mask layering a weapon-ready pose over the arms. Reactions and attacks travel a state machine (Movement ↔ Attack1..5 / Block / Hit1..3 / Dodge*), so the same rig serves the whole move-set without bespoke transitions.
Everyone gets the cheap procedural flinch. Near the camera — where it reads — a PhysicalBoneSimulator3D takes over the struck limbs for a partial ragdoll, then blends back to animation. Lethal hits hand the whole body to physics with the killing impulse.
The same faction, perception and morale foundations drive new combat surfaces.
Self-driving CombatVehicles hunt hostiles, circle to keep guns on target, and fire leading shells — and they sense edges and danger zones, steering around ledges and hazards instead of driving off. A crew AI walks up, boards, and the tank fights under its faction; it ejects when the wreck dies.
A motion-tracked weapon judges strikes by real movement: block by putting the weapon in the attack's path (it costs stamina), parry by striking the incoming blade just before it lands, and heavy attacks gated on a genuine swing arc and grip travel — a wrist-flick never counts. Each weapon type maps horizontal/vertical/thrust arcs to its own heavy.
Freeze all combat with one call — everyone holds mid-frame, then resumes exactly where they left off. Fighters keep hacking a downed foe for a tunable window (per-enemy, -1 = forever) before returning to guard.