Bash.tv → GitHub → itch.io

Build combat for action, RPG and arcade games. Health, damage pipelines (base, crits, damage types and resistances, armor with diminishing returns, blocking, shields), invincibility frames, status effects (burn, poison, slow, stun) with stacking rules, melee attack timing (windup, active, recovery) with hitboxes that hit once, knockback and hit feedback, enemy telegraphs, death and respawn, and...

Download skill (.zip) Files on GitHub

Combat system

Drop-in: assets/combat.js (tests: 100 armor = half damage, crits, fire resistance, shields, i-frames, kills, burn ticks, stacking slows, attack phases, one hit per swing).

import { dealDamage, heal, Effects, attackPhase, swingHits } from "./core/combat.js";
const r = dealDamage(player, enemy, { amount: 12, type: "physical", critChance: 0.1 }, rng.next, time);
if (r.dealt) { popups.add(enemy, r.dealt, r.crit); feel.hit(enemy, r.crit); }   // flash, shake, hit-stop (game-feel-engineering)
if (r.killed) game.events.emit("enemyKilled", { type: enemy.type });
enemy.effects.add({ id: "burn", duration: 3, tickEvery: 0.5, onTick: (e) => dealDamage(null, e, { amount: 2, type: "fire", minDamage: 1 }, rng.next, time) });
speed = base * player.effects.mod("speedMult");

Damage pipeline (order matters)

base × attacker multiplier → crit → resistance by type → armor (A / (A + 100): diminishing, never 100%) → block → minimum damage (1) → shield → health. Keep it in one function so every source of damage follows the same rules.

Melee timing

attackPhase(t): windup (telegraph: pose, flash, sound) → active (hitbox on) → recovery (vulnerable). Use swingHits so a swing hits each target once. Player attacks: short windup (≤ 0.1 s). Enemy attacks: readable windup (0.3–0.6 s).

Feel

Every hit: flash + sound + knockback + small shake. Big hits and kills: hit-stop (50–100 ms). Damage numbers for RPGs. Player hurt: i-frames (0.6–1 s) with blinking, red flash, and a health bar that drains visibly.

Balancing

Pitfalls

Damage applied twice per frame (collision checked from both sides), damage during death animations, invincibility never ending, effects running while paused (advance with dt only), and floating point HP shown as “13.0000001” (round damage).