# Vitals
The numbers of one living thing — hp, maxHp, level, xp, xpToNext, attack,
invuln and dead — as one synced component, plus the rules that own them.
Attach it to anything that can be hurt: a player's body with `{ player = true }`,
a slime root with `{ maxHp = Rules.SLIME_MAX_HP, hp = Rules.SLIME_MAX_HP }` and
`player` left false. Every read and every change from outside goes through
`game.combat.vitals`, which decides whether this peer may write it; the
component body only ever runs on the peer that owns the entity, and that is
what keeps health correct across four peers.
Methods: `applyDamage(amount, attackerId)`, `applyHeal(amount)`, `addXp(amount)`
(which resolves every level-up it earns: max HP +20, attack +5, full heal),
`die(attackerId)` and `respawn()` (full bar, Rules.INVULN_TIME of invulnerability).
It has no sibling components; nothing else is required beside it.
# Warrior
What the local player's body does as a warrior in Slime Arena: the walk speed on
its CharacterController, the Shift dash, the left-mouse greatsword swing through
`game.combat.attack`, being beaten and coming back on its spawn mark after
Rules.RESPAWN_DELAY with Rules.INVULN_TIME of blinking invulnerability, and the
blue/white/orange armour and greatsword it wears.
It needs, on the same entity: the engine's `Humanoid` and `CharacterController`
(the humanoid avatar brings both) and a `Vitals` component. It reads the
`game.player.warrior` input map for its two combat controls and places its
armour on the humanoid's bones through `game.player.dress`. It is attached by
`game.player.bootstrap` when play starts, and it only writes on the peer that
owns the body.
# Slime
One slime: its faceted lime body, its hop, its chase, its touch and its death.
Attach to a **synced root entity** together with `Vitals`
(`{ maxHp = Rules.SLIME_MAX_HP, hp = Rules.SLIME_MAX_HP }`, `player = false`).
`game/slimes/spawner.luau` does that for every slime the arena has; nothing
needs to place one by hand.
## What it does
- Builds the body under the root on **every peer** — dome, skirt, deeper core,
dot eyes and smile — from `game/slimes/body.luau` and the meshes in
`game/slimes/domeMesh.luau`. Only the root replicates, so the look is free.
- On the peer that owns the root: hops (`SLIME_HOP_PERIOD`, `SLIME_HOP_HEIGHT`)
with a squash-and-stretch cycle, seeks the nearest living player within
`SLIME_CHASE_RANGE` at `SLIME_SPEED`, and touches for `SLIME_DAMAGE` no more
often than `SLIME_TOUCH_COOLDOWN`, through `game.combat.vitals`.
- On every peer: flashes white when hurt, and on death plays the splat and the
`slime_die` cue. The owner despawns the root.
Health, damage, death, the 10 XP a kill pays and everything about leveling are
`game.combat.vitals`' business. This component only listens.
## Fields
| Field | Meaning |
|---|---|
| `zone` | which of `Rules.SLIME_ZONES` (1-based) it was born at — the spawner's bookkeeping |
| `squash` | the vertical squash the owner is playing, so other peers draw the same hop |
## Notes
- `Slimes.all()` / `onSpawn` / `onDespawn` (`game/slimes/registry.luau`) is how
other slices find slimes; this registers on `awake` and unregisters on
`onDestroy` and on death.
- Its `awake` calls `require("game.slimes.spawner").ensure()`, so a slime that
exists at all keeps the zones filling.
# hit
A greatsword chopping into a body: a wet thud and squelch with a bright metallic ring. Played at the point of contact when a swing lands on a slime or on another player.
# respawn
A gentle swell of soft sparkles rising into place. Played at the moment a beaten player stands back up on their mark, whole and briefly untouchable.
# swing
The warrior greatsword cutting through air: a low dry whoosh with a metallic shimmer on top. Played at the moment a swing starts, so the commitment is heard before the blade lands.
# hop
A small jelly creature springing off packed sand, a soft cartoon boing. Played when a slime hops, rate-limited so a crowded zone does not become a wall of noise.
# hurt
A short cartoon grunt with a muffled impact behind it. Played when the local player takes damage from a slime touch or from another player sword.
# arenaambience
Light wind over dry sand with distant birdsong, no music: the bed the arena sits in. Loops for as long as the play session runs, heard under every other cue.
# death
A descending groan ending in a soft thump: the warrior being knocked out. Played where a player is beaten, as the three-second countdown to their return starts.
# levelup
Four quick rising notes with a sparkle on top: cheerful, clean and short. Played when a player experience fills their level and they gain health, attack and a full bar.
# slime_die
A blob bursting apart: a wet splat with a cartoon pop on the end. Played where a slime dies, as it comes apart into its splat.