---
name: set-anima-derived-combat
description: The two combat modes of Set's own game on top of the Set API, kept strictly apart. Turn-based combat is led by initiative and ignores range, position, weapons and armor. Scene-based combat is spatial, so position, reach, range, weight, tempo, reload, magic areas and knockback all matter. Set's home page shows one of each: Adventure mode with party is turn-based and Battle with armies is scene-based. Use when choosing between them, building either kind of fight, or reading the schemas of their state and events.
license: Free to use when obtained from set.world, commercially too (the API, what it returns, the skills and downloaded models). The source code of Set is © Jimmy Lee under CC BY-NC 4.0 and its commercial use needs a paid waiver.
metadata:
  version: "0.8.9"
  title: Derived combat
---

# Derived combat (AnimaSystem)

Set's API does not run fights. Its one optional combat endpoint resolves a single attack or a window of turn order ([Combat](https://set.world/skills/basic-lightweight-combat)). Set's own game builds two complete combat modes on generated characters. They are different games. Choose one per fight and never mix their rules.

| | Turn-based | Scene-based |
| --- | --- | --- |
| Led by | **Initiative**: who acts next | **Space**: where everyone is and what reaches whom |
| Set's example on its home page | **Adventure mode with party**: a party of 4 meets up to 6 enemies, one at a time | **Battle with armies**: two armies of 16, all on the field at once |
| What a fight looks like | A list of turns: who acts, hit or miss, how much | Bodies moving, swinging, shooting and colliding |
| Range and position | Not measured. Any living opponent can be attacked | Decide everything: which hand is used, what it reaches, what it hits |
| Weapons and armor | Not read. Only the character's `finalStats` and `attributes` as returned | Read: each held item's weight, reach, delivery and material, and every worn item, through [Derived stats](https://set.world/skills/anima-derived-stats) |
| Stamina cost | 20 per attack, always | 20 to 36 per action, by the weight in hand |
| Stamina recovery | 10 per second of initiative time | From the body and its armor, paused after ranged actions |
| Time | Logical: it advances turn by turn | A fixed 60 Hz simulation that advances only while visible |
| What decides a hit | A dodge draw | A dodge draw, after the attack physically touches a body |
| A fight ends when | The enemy falls or the whole party does | One side has no living fighter; both at once is a draw |
| Between fights | Health persists; stamina refills while exploring | Nothing persists: a new battle is a new cast |
| Fits | Party RPGs, roguelikes, card, text and tabletop games | Action games, arenas, anything with movement |
| Rule stamps | `dungeon-initiative-1` | `anima-system-10`, `weapon-handling-10`, `weapon-tempo-6`, `weapon-reach-2`, `weapon-tactics-4`, `magic-2` |

Nothing here is an API rule, no request is sent per hit, and another game may choose differently. The scene-based rules also run `https://set.world/anima-scene` and `https://set.world/anima-all-weapons`; how each page is put together is in [Scenes](https://set.world/skills/anima-scenes).

**To build something like Adventure mode with party (turn-based):**

1. Roll the party once, then each enemy when the party is ready, one request each, with seeds from a stream of their own ([Rolling a group](https://set.world/skills/rolling-a-group)).
2. Keep only `health` and `stamina` for each fighter, as whole numbers beside its birth.
3. Make an encounter from the living party and one enemy. Schedule turns by initiative and resolve each one with part one below.
4. Draw combat randomness from one seeded stream, so a replay repeats.
5. Keep presentation apart from the rules: a turn may take any time on screen, but only initiative time restores stamina.
6. Leave equipment out. If gear should matter in your turn-based game, add your own rule; do not borrow half of the scene rules.

**To build something like Battle with armies (scene-based):**

1. Roll every fighter with `deriveSeed(base, i)`, one request at a time; Set's own battle puts even indexes on one side and odd on the other.
2. Apply [Derived stats](https://set.world/skills/anima-derived-stats) to each, then build each hand from its held item: stamina cost, tempo, range and hit power.
3. Give every fighter a position and a facing, and start only when the whole cast and its equipment are ready.
4. Step a fixed 60 Hz simulation: move, choose a hand by distance, commit one action, and resolve each contact with part two below.
5. Check for elimination after each complete step. There is no time limit and no forced damage.
6. Send no request per hit: the whole fight runs in the client.

## What both modes share: resolving one hit

Both modes resolve a hit with the same three steps on Set's attributes and whole numbers (`local-resources-1`). Only `raw`, the damage before defence, differs between them.

```text
dodgeChance = defender.dodgeRate × (1 − attacker.clarity)        drawn first; a dodge deals 0
critical    = attacker.criticalHitChance                         drawn on a hit; doubles it
landed      = max(1, floor(raw × (1 − reduction) × (1 − globalResistance) × (critical ? 2 : 1)))
healthLost  = min(defender.health, landed)
```

`reduction` is the defender's `physicalDamageReduction` for physical and projectile hits and `magicalDamageReduction` for magic. Health and stamina start at `floor(maxHealth)` and `floor(stamina)`.

---

## Part one: turn-based combat

**Initiative leads. Range does not exist.** There are no positions, so there is no reach, no line of sight, no movement and no knockback. Equipment is not read: a character fights with the attributes the API returned, unchanged. This is the whole rule set of Set's dungeon (`dungeon-initiative-1`).

### The rules

1. **Participants.** The living party members, in party order, then the enemy. An encounter starts the initiative clock at zero and does not refill health or stamina.
2. **Turn order.** Each participant acts every `1000 / initiative` milliseconds of logical time, starting one interval after zero. Schedule consecutive 5-second windows, open at the start and closed at the end. Exact ties keep participant order. A faster `initiative` means more turns in the same logical time.
3. **Recovery.** At each turn, every living participant recovers `10 × seconds since the previous turn`, capped at its maximum.
4. **The turn.** With less than 20 stamina the actor **rests**: no spend, no draw. Otherwise it spends 20 and attacks with `raw = attacker.physicalDamage`, resolved by the shared steps above. A miss still costs the stamina.
5. **Targets.** A party member attacks the enemy. The enemy attacks the surviving party members in rotation. Nothing else is checked.
6. **End.** The enemy falls or no party member survives. Defeated participants take no further turns. Between encounters health persists and stamina refills at the same rate.

Turn order is exactly the combat API's initiative schedule, so a game can call `/api/basic-lightweight-combat?mode=initiative` for each window or compute it locally ([Combat](https://set.world/skills/basic-lightweight-combat) owns the schedule and its window rule).

### What turn-based combat never reads

Position, distance, facing, reach, range, tempo, reload, weapon models, materials, weight, armor, ward, knockback, and every number in [Derived stats](https://set.world/skills/anima-derived-stats). A dagger and a ballista are the same attack. If your turn-based game wants equipment to matter, that is your rule to add, not one of these.

### One encounter, worked

The example character from [Rolling a character](https://set.world/skills/rolling-a-character) (initiative 1.108, a turn every 902.5 ms) against an all-16 enemy (initiative 1.144, every 874.1 ms). Every draw is fixed to "no dodge, no critical" so the arithmetic is visible; times are rounded to the millisecond. The first 5-second window:

| Turn | At (ms) | Actor | Stamina before | Outcome | Damage | Target health after |
| ---: | ---: | --- | ---: | --- | ---: | --- |
| 1 | 874 | enemy | 88 | hit | 20 | hero 164 |
| 2 | 903 | hero | 96 | hit | 20 | enemy 148 |
| 3 | 1,748 | enemy | 76 | hit | 20 | hero 144 |
| 4 | 1,805 | hero | 85 | hit | 20 | enemy 128 |
| 5 | 2,622 | enemy | 65 | hit | 20 | hero 124 |
| 6 | 2,708 | hero | 74 | hit | 20 | enemy 108 |
| 7 | 3,497 | enemy | 54 | hit | 20 | hero 104 |
| 8 | 3,610 | hero | 63 | hit | 20 | enemy 88 |
| 9 | 4,371 | enemy | 42 | hit | 20 | hero 84 |
| 10 | 4,513 | hero | 52 | hit | 20 | enemy 68 |

The hero's hit is `floor(25.5 × (1 − 0.128) × (1 − 0.088)) = 20`. Stamina falls faster than it returns, so attacks give way to rests: the enemy first rests on its turn at 6,993 ms, with 9 stamina.

### A schema for turn-based state

```ts
type TurnCombatant = {
  id: string;
  side: 'party' | 'enemy';
  stats: number[];                 // the nine finalStats, for the initiative schedule
  attributes: Record<string, number>;   // as the API returned them
  health: number;                  // whole numbers
  stamina: number;
};

type TurnEncounter = {
  rules: string;                   // "dungeon-initiative-1"
  seed: number;                    // your combat stream
  windowMs: number;                // 5 seconds in Set's dungeon
  clockMs: number;                 // logical initiative time; never wall time
  order: string[];                 // participant ids, ties resolved in this order
  combatants: TurnCombatant[];
  turn: number;
};

type TurnEvent = {
  turn: number;
  atMs: number;
  actorId: string;
  targetId: string | null;         // null on a rest
  outcome: 'hit' | 'miss' | 'rest';
  critical: boolean;
  damage: number;                  // health removed
  staminaAfter: number;
};
```

Source: `three-isometric-engine/dungeon/adventure.ts` and `initiative.ts`; the derivation is §14 of the reference ([Algorithms](https://set.world/skills/algorithms)).

---

## Part two: scene-based combat

**Every spatial factor matters.** Actors have positions and facings in a world, weapons have a length and a weight, attacks travel, and a hit happens only where something touches a body. This is the rule set of Set's Anima scene and army battle (`anima-system-10`).

Start from a character with its AnimaSystem stats applied ([Derived stats](https://set.world/skills/anima-derived-stats)): armor and ward are already in its reductions, worn weight is already in its speeds, and each hand has a hit power from its item's material.

### The spatial factors

| Factor | What it decides |
| --- | --- |
| Distance to the target | Which hand acts: a projectile or wave hand beyond 5 units, a melee hand inside |
| Reach (tool length) | How far a melee stroke lands and how soon it plays |
| Range | How far a shot or wave travels: at most 30 units, softening above 20 |
| Aim and contact | A shot flies to a frozen aim point; the first opposing body it touches takes the hit |
| Area | Rings, cones and waves hit everyone they cover |
| Weight in hand | The stamina an action costs and how fast it plays |
| Worn weight | Walk, attack and recovery speed |
| Knockback and bodies | Hits push; living bodies block movement |

### The idea in three lines

1. **Every stamina point buys the same damage.** A hit is priced by the stamina its action cost, so every tool sustains the same output up close. Heavy tools hit harder, cost more and swing slower.
2. **Range costs time.** After an action, stamina recovery pauses in proportion to the action's range, so output falls smoothly to about half at the 30-unit ceiling.
3. **Material is the gear's power.** Each hand's hit power comes from its item's material; armor reduces what lands.

### Weight: what an action costs

An unarmed punch costs 20 stamina and plays a 4-second authored action at `attackSpeed`. Everything else is measured against it (`weapon-handling-10`).

```text
M = log2(1 + weaponMass / m₀)         m₀ = 0.089, the Sword's measured mass   (0 when unarmed)
J = log2(1 + gripInertia / I₀)        I₀ = 0.231, the Sword's grip inertia
S = 0.25 × log2(1 + otherHandMass / m₀)                                       (0 with an empty other hand)
C = carryCapacity / 106
B = (M + J) / 2 + S
relativeRate = max(0.35, 1 / sqrt(1 + B / C))
workRate     = min(attackSpeed, 1.32) × relativeRate
cost         = 20 + 16 × (1 − exp(−(0.6 × (M + S) / C + 0.4 × J × workRate² / C)))      20 to 36
```

Weight comes from each model's geometry (a surface-shell proxy, Sword = 1) times its material's mass. Stamina is spent once, before the windup; an interrupted action is not refunded; an Anima short of stamina waits.

### A hit's raw damage

```text
melee raw      = physicalDamage × cost / 20 × hitPower
projectile raw = actionDamage   × cost / 20 × hitPower × k        k = max(1, mass^(1/3)) for projectile tools
flick raw      = magicalDamage  × cost / 20 × hitPower
```

`cost` is captured when the action commits, so a released shot keeps it. A bare punch has hit power 1. The hit is then resolved by the shared steps, after contact.

### Every held item

All 145 mainhands, measured from their models and evaluated by the formulas of this part, at all-16 stats with one steel item in hand. `mass` and `gripInertia` are in Sword units (a steel Sword is 3 lb), `reachInches` puts the Sword at 36 inches, `stamina` is the cost of one action and `seconds` how long it plays. These are formula values, not a balance study.

```csv
tool,grip,action,delivery,mass,gripInertia,reachInches,stamina,seconds
quarterstaff,handle,bash,melee,0.95,0.63,22.3,28.7,2.12
falchion,handle,slash,melee,1.73,3.28,37.8,31.5,2.90
talon,fist,jab,melee,0.24,0.03,11.8,23.0,1.87
estoc,handle,thrust,melee,0.86,0.99,36.5,28.9,2.41
bill,handle,chop,melee,1.48,1.39,26.9,30.6,2.46
guisarme,handle,slash,melee,1.30,1.11,29.8,30.1,2.43
recurve bow,bow,aim,projectile,0.66,0.23,18.7,26.7,2.12
arbalest,pistol,fire,projectile,0.82,0.31,17.3,27.6,2.23
sling,handle,whirl,projectile,0.93,1.04,34.6,29.2,2.43
francisca,handle,throw,projectile,1.01,0.25,12.7,28.1,1.85
shotel,handle,slash,melee,0.67,0.51,29.6,27.5,2.14
longsword,handle,slash,melee,0.72,0.64,35.4,28.0,2.27
shortsword,handle,slash,melee,0.83,0.40,27.2,27.9,2.11
broadsword,handle,slash,melee,1.42,1.87,37.3,30.7,2.69
flamberge,handle,slash,melee,0.72,0.77,37.6,28.2,2.34
saber,handle,slash,melee,0.62,0.82,38.3,27.9,2.33
talwar,handle,slash,melee,1.80,0.92,36.1,30.8,2.57
axe,handle,chop,melee,0.77,0.14,10.7,26.9,1.76
hatchet,handle,chop,melee,0.60,0.07,8.8,25.7,1.69
crowbar,handle,bash,melee,0.61,0.59,21.3,27.5,2.01
cleaver,handle,chop,melee,2.50,1.88,23.3,32.0,2.58
tabar,handle,chop,melee,2.38,1.91,22.3,31.9,2.55
small shield,shield,shieldBash,melee,0.49,0.03,5.7,24.9,1.64
pavise,shield,shieldBash,melee,2.38,0.65,13.3,31.3,2.15
heater,shield,shieldBash,melee,1.08,0.18,10.9,28.2,1.84
shield,shield,shieldBash,melee,3.71,0.78,11.7,32.5,2.29
door,shield,shieldBash,melee,13.47,28.96,39.1,35.0,4.07
rondache,shield,shieldBash,melee,2.19,0.36,9.7,30.8,2.06
targe,shield,shieldBash,melee,1.71,0.25,8.8,29.8,1.97
buckler,shield,shieldBash,melee,0.70,0.08,7.0,26.3,1.72
boomerang,handle,return,projectile,1.06,0.76,21.2,29.2,2.15
chakram,handle,return,projectile,0.26,0.05,9.5,23.4,1.58
bow,bow,aim,projectile,0.35,0.05,11.7,24.0,1.93
longbow,bow,aim,projectile,0.70,0.35,21.9,27.3,2.18
shortbow,bow,aim,projectile,0.29,0.03,9.7,23.4,1.89
composite bow,bow,aim,projectile,0.50,0.08,11.9,25.2,2.00
crossbow,pistol,fire,projectile,0.39,0.04,10.0,24.3,1.97
ballista,pistol,fire,projectile,2.11,2.90,28.4,31.9,2.93
claw,fist,jab,melee,0.21,0.00,6.0,22.4,1.84
club,handle,bash,melee,6.32,5.28,17.6,34.0,2.90
hammer,handle,chop,melee,4.83,1.56,11.0,33.3,2.47
maul,handle,chop,melee,10.62,20.90,23.1,34.8,3.53
cudgel,handle,bash,melee,9.11,8.12,17.7,34.6,3.09
fang,fist,jab,melee,0.26,0.01,6.0,23.0,1.87
sickle,handle,slash,melee,0.33,0.10,21.5,24.2,1.75
hand cannon,pistol,blast,projectile,7.19,7.28,21.6,34.3,3.51
whip,handle,lash,melee,0.62,2.69,90.6,29.2,3.13
morningstar,handle,chop,melee,2.98,1.25,13.6,32.2,2.31
tree trunk,handle,chop,melee,7.61,16.14,29.6,34.5,3.56
truncheon,handle,bash,melee,0.68,0.29,15.2,27.0,1.81
mace,handle,chop,melee,1.30,0.34,11.5,29.1,1.93
knuckle,fist,jab,melee,0.19,0.00,4.1,22.3,1.83
sword,handle,slash,melee,1.00,1.00,36.0,29.3,2.44
scimitar,handle,slash,melee,1.02,1.63,38.4,29.8,2.59
katana,handle,slash,melee,0.37,0.13,27.3,24.7,1.87
rapier,handle,thrust,melee,0.86,1.10,41.3,29.0,2.50
knife,handle,slash,melee,0.35,0.08,16.7,24.2,1.67
dirk,handle,thrust,melee,0.70,0.21,22.4,26.8,1.93
dagger,handle,thrust,melee,0.96,0.25,20.9,28.0,1.99
blade,handle,slash,melee,0.49,0.41,28.6,26.5,2.04
kris,handle,thrust,melee,0.81,0.41,25.3,27.8,2.08
harp,handle,strum,aura,2.55,1.42,19.0,31.9,2.79
flute,handle,play,aura,0.58,0.14,12.7,25.9,2.08
bardiche,handle,chop,melee,1.74,2.34,32.5,31.3,2.72
partizan,handle,thrust,melee,1.29,1.41,30.4,30.2,2.49
stiletto,handle,thrust,melee,0.95,0.41,22.5,28.3,2.06
tome,palm,rupture,aura,2.08,0.25,9.6,30.5,3.68
grimoire,palm,crossRupture,aura,3.31,0.52,11.0,32.1,4.03
scythe,handle,slash,melee,1.66,2.69,34.8,31.3,2.79
voulge,handle,chop,melee,1.55,2.30,34.8,31.1,2.73
poignard,handle,thrust,melee,0.76,0.19,20.9,27.0,1.92
rondel,handle,thrust,melee,2.53,0.55,21.7,31.4,2.32
kunai,handle,throw,projectile,1.54,0.82,20.1,30.3,2.23
spear,handle,thrust,melee,1.22,1.45,32.2,30.1,2.51
ice pick,handle,chop,melee,0.41,0.03,14.3,24.3,1.62
pickaxe,handle,chop,melee,0.85,0.20,11.8,27.4,1.80
trident,handle,thrust,melee,1.49,2.40,34.9,31.0,2.73
spetum,handle,thrust,melee,1.33,1.76,33.7,30.5,2.60
pike,handle,thrust,melee,1.35,2.68,40.1,30.9,2.82
spike,handle,thrust,melee,0.87,0.67,24.0,28.5,2.15
stick,handle,bash,melee,1.03,0.96,22.6,29.3,2.22
lance,handle,thrust,melee,1.36,2.04,36.4,30.7,2.69
halberd,handle,chop,melee,1.63,2.46,31.6,31.2,2.70
rifle,pistol,gunfire,projectile,1.43,0.35,14.1,29.5,2.38
rod,handle,flick,wave,1.00,0.56,15.4,28.7,2.36
cane,handle,bash,melee,0.94,0.95,23.2,29.1,2.21
wand,handle,flick,wave,0.50,0.05,10.8,25.1,2.02
staff,handle,bash,melee,0.83,0.57,19.5,28.2,2.03
javelin,handle,hurl,projectile,0.60,0.21,21.3,26.4,1.89
tomahawk,handle,throw,projectile,0.59,0.07,9.0,25.7,1.69
scepter,handle,flick,wave,1.82,0.56,13.0,30.5,2.51
glaive,handle,slash,melee,2.26,4.74,37.7,32.3,3.07
gladius,handle,thrust,melee,0.77,0.45,26.0,27.8,2.09
harpoon,pistol,skewer,projectile,3.21,0.75,23.9,32.1,2.73
pilum,handle,hurl,projectile,0.54,0.13,23.4,25.7,1.87
katar,fist,jab,melee,0.79,0.45,20.7,27.9,2.24
cinquedea,handle,thrust,melee,1.94,1.59,25.3,31.3,2.52
jo,handle,bash,melee,0.26,0.03,9.2,23.2,1.57
bokken,handle,slash,melee,0.44,0.38,26.4,26.1,1.98
baton,handle,bash,melee,0.57,0.08,11.9,25.6,1.68
tonfa,handle,bash,melee,1.18,0.23,11.5,28.6,1.88
nunchaku,handle,twirl,melee,0.24,0.06,12.9,23.2,1.57
sai,handle,thrust,melee,0.53,0.11,19.2,25.5,1.79
naginata,handle,slash,melee,1.40,2.04,35.9,30.7,2.69
yari,handle,thrust,melee,1.18,1.26,31.5,29.9,2.46
bands,wrist,jab,melee,0.20,0.01,4.7,22.5,1.84
orb,palm,repulse,aura,0.02,0.00,6.0,20.3,1.76
torch,handle,slash,melee,0.59,0.05,7.3,25.6,1.68
eye,palm,gaze,wave,2.10,0.18,6.5,30.4,2.43
chain,handle,lash,melee,0.64,4.16,66.5,29.7,3.11
rope dart,handle,lash,melee,0.52,7.71,89.7,29.8,1.17
falcata,handle,slash,melee,0.71,0.73,29.5,28.1,2.21
khopesh,handle,slash,melee,0.75,0.74,35.6,28.2,2.31
nodachi,handle,slash,melee,0.35,0.16,32.0,24.7,1.94
tetsubo,handle,bash,melee,1.35,0.66,16.8,29.7,2.08
cestus,wrist,jab,melee,0.31,0.01,4.7,23.4,1.89
kukri,handle,chop,melee,0.78,0.60,24.4,28.1,2.11
karambit,handle,slash,melee,0.97,0.71,22.0,28.9,2.14
dao,handle,slash,melee,2.04,1.42,34.6,31.4,2.67
jian,handle,thrust,melee,0.72,0.78,37.3,28.2,2.33
nagamaki,handle,slash,melee,0.25,0.01,14.2,22.9,1.55
claymore,handle,slash,melee,0.50,0.34,33.2,26.3,2.08
pata,fist,jab,melee,6.91,1.40,35.6,33.9,3.05
urumi,handle,lash,melee,2.27,10.34,52.8,32.6,3.53
mambele,handle,throw,projectile,2.15,7.17,39.5,32.4,3.21
assegai,handle,thrust,melee,1.07,0.65,23.8,29.1,2.18
ranseur,handle,thrust,melee,1.28,1.52,32.0,30.3,2.53
corseque,handle,thrust,melee,1.27,1.36,30.4,30.2,2.48
fauchard,handle,slash,melee,1.26,1.38,30.6,30.2,2.48
shashka,handle,slash,melee,0.58,0.65,36.5,27.4,2.25
seax,handle,slash,melee,0.46,0.30,24.0,26.0,1.92
pugio,handle,thrust,melee,1.00,0.40,22.5,28.4,2.07
xiphos,handle,thrust,melee,0.76,0.41,26.0,27.6,2.08
sarissa,handle,thrust,melee,1.47,4.13,46.8,31.3,3.06
messer,handle,slash,melee,0.89,0.95,35.1,28.9,2.39
goad,handle,thrust,melee,0.47,0.05,10.2,24.9,1.64
macana,handle,bash,melee,5.93,3.90,17.2,33.9,2.80
tachi,handle,slash,melee,0.38,0.16,29.1,24.9,1.91
tanto,handle,thrust,melee,0.67,0.16,18.5,26.5,1.83
jutte,handle,bash,melee,0.62,0.27,19.0,26.7,1.87
balisong,handle,slash,melee,0.11,0.02,13.3,21.6,1.50
patu,handle,chop,melee,6.17,4.11,17.8,34.0,2.84
iklwa,handle,thrust,melee,0.98,0.42,21.5,28.4,2.06
kopis,handle,slash,melee,1.44,2.83,31.8,31.0,2.72
chair,handle,throw,projectile,2.77,1.82,22.7,32.2,2.58
```

`grip` is how the hand holds the item ([Item models](https://set.world/skills/anima-item-models)), `action` the authored motion ([Animations](https://set.world/skills/anima-animations)), and `delivery` what the action does: `melee` strikes by contact, `projectile` launches something, `aura` fills a ring or a cone, `wave` sends a front along the ground. An item's material then scales its mass, and with it the cost and the time ([Derived stats](https://set.world/skills/anima-derived-stats)).

Up close every tool sustains the same output, `channel damage × recovery / 20` per second, because a hit is priced by what it cost; range then lowers it by the range pause below.

### Tempo and reach: how fast an action plays

```text
tempo = speed stat × relativeRate × 2 × reach tempo × the action's own rate
speed stat = castSpeed (aura and wave actions), chargeSpeedAction (fire, gunfire, blast, skewer), else attackSpeed
seconds    = 4 / tempo
reach      ℓ = clamp(toolReach / swordReach, 0.4, 2.5);  reach tempo = ℓ^-0.2;  windup = clamp(ℓ^0.35, 0.8, 1.35)
```

Short tools swing and throw sooner; long tools start later and pull back further. Tempo never changes cost, damage or range (`weapon-tempo-6`, `weapon-reach-2`). Rupture and Cross-rupture play 1.5 times slower; the rope dart's cast plays 3 times faster.

### Range, aim and targeting

- Ranged hands plan from `projectileRange` (speed, gravity and release height, not arc). New ranged attacks reach at most 30 world units, softening above 20.
- Beyond 5 units an Anima prefers a projectile or wave hand; inside, a melee hand. It switches only between complete actions.
- A ranged commitment freezes an aim point on the opponent. Contact decides hit or miss: there is no homing, and the first opposing body a shot touches takes the hit. No friendly fire.

### Pacing: how soon the next action starts

| Rule | Value |
| --- | --- |
| Stamina recovery | The body's rate from [Derived stats](https://set.world/skills/anima-derived-stats); no refunds |
| Range pause | After an action with plan range `R` and cost `c`, recovery pauses `(c / recovery) × max(0, R − 0.86) / 30` seconds, stacking, where 0.86 is one body width, the closest two bodies stand. Sustained output becomes `D₀ / (1 + (R − 0.86) / 30)` |
| Reload | A ranged hand waits its reload from release; never longer than the fair cycle `c / recovery + pause − release time` for light launchers, and exactly `k` fair cycles for heavy shots |
| Magic cadence | A hand waits 2 of its action durations after a ring, Repulse or Gaze, 4 after Rupture or Cross-rupture, 1 after Flick |
| Hit recovery | A damaging hit cancels the unfinished action and blocks new ones until 2.4 seconds after the latest hit |
| Winded retreat | An Anima that cannot afford its next action walks backwards at 0.5 of its pace, facing its target, out of the 5-unit front band, then re-engages (`stamina-retreat-1`) |
| Hands | One complete action at a time; two held items alternate. Each hand keeps its own reload |

### Magic: areas and stamina

A magic action's **stamina effect** is `floor(cost × hitPower)` (`magic-2`).

| Item | Action | Effect | Reaches |
| --- | --- | --- | --- |
| Wand, Rod, Scepter | Flick | A forward wave of magic damage priced by stamina | Opponents |
| Orb | Repulse | A ring: 0.70 × magic damage and the stamina effect drained | Opponents |
| Eye | Gaze | A 10-unit fan cone: the stamina effect drained and a light push, no damage | Opponents |
| Flute, Harp | Play, Strum | A ring: heals health and restores the stamina effect | Everyone inside |
| Tome | Rupture | A ring that pulls each Anima outward into a tumble | Everyone but the caster |
| Grimoire | Cross-rupture | Four waves in a plus that pull each Anima along the wave | Everyone but the caster |

Stamina drain meets the target's magic resistance ([Derived stats](https://set.world/skills/anima-derived-stats)): `drained = floor(min(stamina, drain × (1 − magicResistance)))`. Healing and restored stamina are never resisted.

### Single-weapon rules

These are written by hand from the engine as it stood at `anima-system-10`.

- **Knockback.** Every combat impulse uses one shared scale of 0.5; `knockbackPower = 1 + 0.02 × (strength − 8)` multiplies it.
- **Rifle.** 5 instant shots per action share one priced hit; the volley recovers like a Ballista.
- **Hand cannon.** Blast: a narrow wave to 30 units that hits every opponent in its path and waits 1.25 times its heavy-shot cycle.
- **Harpoon gun.** Skewer attaches when the hit leaves the target alive; the owner pulls only if its Strength is equal or greater.
- **WorldSphere.** A placed prop, not the item Orb: a fixed 222 damage with no dodge roll.
- **Death.** An Anima at zero health becomes a ragdoll and stays down.

### A schema for scene-based state and hits

```ts
type HandState = {
  item: { gear: string; material: string | null } | null;
  delivery: 'melee' | 'projectile' | 'aura' | 'wave';
  cost: number;                    // stamina per attempt, 20 to 36
  secondsPerAction: number;        // 4 / tempo
  hitPower: number;                // 1 for a bare hand
  planRange: number;               // world units
  readyAt: number;                 // the scene time when reload or cadence ends
};

type CombatantState = {
  actorId: string;
  position: [number, number, number];
  facing: number;                  // yaw, in radians
  health: number;                  // whole numbers
  maxHealth: number;
  stamina: number;
  maxStamina: number;
  staminaRecovery: number;         // per second
  recoveryPausedUntil: number;     // the range pause
  hurtUntil: number;               // hit recovery
  hands: { right: HandState; left: HandState };
  action: null | { hand: 'right' | 'left'; startedAt: number; costPaid: number; aimPoint: [number, number, number] | null };
};

type HitEvent = {
  at: number;
  attackerId: string;
  targetId: string;
  hand: 'right' | 'left';
  channel: 'physical' | 'action' | 'magical';
  distance: number;                // between the two bodies at contact
  raw: number;                     // channel damage × cost / 20 × hitPower × k
  dodged: boolean;
  critical: boolean;
  landed: number;                  // health removed, a whole number
  staminaDrained?: number;
  knockback?: [number, number, number];
};
```

A sword hit from the example character (physicalDamage 25.5, sword hand power 1.4739) on an all-16 target wearing nothing. The stamina cost is this character's own, with its dagger in the other hand; the time, the distance and the two draws are chosen for the example:

```json
{
  "at": 12.35,
  "attackerId": "hero-1",
  "targetId": "enemy-3",
  "hand": "right",
  "channel": "physical",
  "distance": 2.4,
  "raw": 55.6,
  "dodged": false,
  "critical": false,
  "landed": 44
}
```

`raw = 25.5 × 29.6 / 20 × 1.4739 = 55.6`, and `landed = floor(55.6 × (1 − 0.128) × (1 − 0.088)) = 44`. The same character's turn-based hit on the same target is 20: no weapon, no material, no stamina price.

### Build it

Commit once, pay once, run one complete action per hand, start each reload at release and resolve each contact once. The rest of a scene (movement, sight, teams, bodies, the clock) and the source files behind every rule are in [Scenes](https://set.world/skills/anima-scenes). Full derivations: §13 of the reference, especially §13.2, §13.47, §13.71 and §13.72 ([Algorithms](https://set.world/skills/algorithms)). The rules show no proven weapon balance and no proven end to every battle.

---

## The combat API beside both modes

| | Combat API | Turn-based | Scene-based |
| --- | --- | --- | --- |
| Runs | On Set's server, one GET per attack or window | In your client | In your client |
| Turn order | Initiative windows | The same schedule | None: actions start when stamina, reload and distance allow |
| Damage rounding | `round` | `floor` | `floor` |
| Stats accepted | Nine integers from 8 to 24 | The same | Any scaled values |
| Keeps state | No | You keep health, stamina and the clock | You keep the whole scene |

A game with no combat of its own can start with the API alone, grow into the turn-based rules, and move to a scene only when it has positions to simulate.
