Design and build boss fights. Phases triggered by health thresholds, attack patterns chosen from a per-phase pool with no immediate repeats, telegraphs and safe windows, vulnerable moments, arena design, intro and defeat sequences, health bars, difficulty and checkpoints, preventing cheese, and testing the fight. Builds on the enemy AI state machine. Use for "add a boss", "boss phases", "boss a...
Download skill (.zip) Files on GitHubBoss battles
A boss is a test of what the player learned, as a performance with readable patterns. Build it from enemy-ai’s
StateMachine, combat-system’s damage, and projectile-system patterns.
Structure
const PHASES = [
{ until: 0.66, attacks: ["slam", "spray"], speed: 1 },
{ until: 0.33, attacks: ["slam", "spray", "charge"], speed: 1.2, enter: (b) => roar(b) },
{ until: 0, attacks: ["charge", "spiral", "summon"], speed: 1.4, enter: (b) => { roar(b); arena.crumble(); } },
];
const ATTACKS = {
slam: { windup: 0.7, active: 0.2, recover: 1.0, run: (b) => shockwave(b) }, // recover = player's damage window
spray: { windup: 0.5, active: 1.5, recover: 0.6, run: (b, t) => fireRing(b, 12, t * 2) },
charge: { windup: 0.6, active: 0.8, recover: 1.2, run: (b) => dashAtPlayer(b) },
};
function phaseFor(b) { const f = b.hp / b.maxHp; return PHASES.findIndex((p) => f > p.until); }
function nextAttack(b) { // no immediate repeats
const pool = PHASES[b.phase].attacks.filter((a) => a !== b.lastAttack);
b.lastAttack = pool[Math.floor(rng.next() * pool.length)]; return b.lastAttack;
}
// states: intro → choose → windup → active → recover → choose … → transition (on phase change) → dying
On a phase change: interrupt the current attack, play a transition (roar, brief invincibility, arena change), and give the player a moment.
Design rules
- Telegraph everything (pose, flash, sound, ground markers). The windup is long enough to react: 0.5–1 s early, shorter later.
- Clear damage windows: the boss is vulnerable during recovery (or only at a weak point). Show it (glow, stagger).
- Each phase adds one new idea and remixes earlier ones. Phase 3 is the hardest but shortest.
- Patterns, not randomness: a small pool per phase, no immediate repeats, sometimes fixed combos.
- Arena: room to dodge; hazards that matter; no spots where the boss can’t reach you (cheese).
- Length: 1–3 minutes for a small game. HP from player DPS × target time.
- Health bar at the top with phase markers; name on intro.
- Feel: big hits get hit-stop and shake; the death sequence (slow-mo, flashes, explosion, pause) is the reward.
- Retry fast: checkpoint right before the boss; skip the intro on retry.
Test
Play it many times: can a new player read every attack? Is there a safe answer to each? Does any strategy trivialize it (standing in a corner, spamming one move)? Use game-balance-testing for HP and damage numbers and game-playability-audit for fairness.