data/damage_hooks/
A damage hook set: named data hooks an archetype carries, listed in its manifold-gameplay:damage-hooks component (armour by body region, a creature’s thick hide). A hook changes, cancels or answers a hit at one stage of the damage pipeline. Effects (damage_hooks) and item kinds (grants.damage_hooks) carry the same hooks inline. Loaded by the server only.
| Registry | manifold:damage-hooks |
| Files | data/damage_hooks/*.ron, *.update.ron, *.final.ron |
| Sides | server: only the server loads it |
| Reads | manifold:predicate, manifold:stat |
| Contract | Gameplay framework, data stage |
Entry
A record, written DamageHooks(..); the name before the parentheses is optional.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
id | string | yes | The set’s key, <mod-id>:<name>. | |
hooks | list of DamageHook | yes | The hooks. |
Example
No bundled file declares one yet. From the reference’s test fixture, crates/manifold-server-state/tests/data-reference-fixture/data/damage_hooks/thick_hide.ron, which the data stage loads in its tests:
DamageHooks(
id: "dataref-fixture:thick_hide",
hooks: [
DamageHook(stage: Mitigate, side: Victim,
when: ContextTags((any: ["manifold:region.head"])), action: Multiply(value: -0.5)),
DamageHook(stage: PostHit, side: Victim,
action: Reflect(fraction: 0.25, damage_type: "manifold:generic")),
],
)
Types
DamageHook
A data hook on the damage pipeline, evaluated in the damage context (This is the victim; v.damage_amount is the stage’s amount). Within a stage, hooks run by priority, then side, then source, then list order.
A record: DamageHook(..) or (..).
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
stage | DamageStage | yes | The pipeline stage it runs at, which limits its actions. | |
side | HookSide | yes | Which participant carries it: an Attacker hook on a sword’s effect runs when its holder attacks, a Victim hook on a shield’s when its holder is hit. | |
priority | i16 | no | 0 | Higher runs first, -32768 to 32767. |
when | condition or None | no | always | A condition that must hold. |
action | DamageAction | yes | What it does. |
DamageStage
A stage of the damage pipeline.
| Variant | Written | Description |
|---|---|---|
Admit | Admit | Before anything: Cancel. |
Gather | Gather | The attacker’s part: Add, Multiply, Set, AddContextTag. |
Convert | Convert | Between elements: Convert. |
Mitigate | Mitigate | The victim’s part: Add, Multiply, Set. |
PreApply | PreApply | Last changes (blocks, parries, shields): all of the above and Cancel. |
PreDeath | PreDeath | A killing hit only: Cancel (the victim survives), ApplyEffect. |
PostHit | PostHit | After the hit: ApplyEffect, Reflect, Leech, Knockback, Cue. |
PostKill | PostKill | After a kill: as PostHit. |
HookSide
The participant a hook belongs to.
| Variant | Written | Description |
|---|---|---|
Attacker | Attacker | The attacker. |
Direct | Direct | The direct source (an arrow). |
Owner | Owner | The attacker’s owner. |
Victim | Victim | The victim. |
DamageAction
What a hook does. Actions may also be written positionally, in field order (Cancel("x:cancel.blocked")); Add, Multiply and Set take (<value>) or (<element>, <value>).
| Variant | Written | Description |
|---|---|---|
Add | Add(value: .., element: ..) | Adds to an element’s amount. |
Multiply | Multiply(value: .., element: ..) | Multiplies by 1 + value, on one element or all of them. |
Set | Set(value: .., element: ..) | Sets one element’s amount, or the total (rescaling the elements). |
Convert | Convert(from: .., to: .., fraction: ..) | Moves a fraction of one element’s amount into another. |
Cancel | Cancel(reason: ..) | Stops the hit, with a reason tag (manifold:cancel.* or the game’s). |
AddContextTag | AddContextTag(tag: ..) | Adds a tag to the hit’s context tags. |
ApplyEffect | ApplyEffect(to: .., effect: .., level: ..) | Applies an effect to a participant, with the hook’s holder as source. |
Reflect | Reflect(fraction: .., damage_type: ..) | Thorns: deals a fraction of the applied amount back to the attacker as a new hit (never more than two levels deep). |
Leech | Leech(fraction: .., resource: ..) | Lifesteal: heals the attacker by a fraction of the applied amount. |
Knockback | Knockback(add: ..) | Adds to the hit’s horizontal knockback, m/s. |
Cue | Cue(cue: ..) | Plays a cue at the hit. |
Add fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
value | number | yes | The amount, a number. | |
element | string or None | no | the hit’s primary element | The element (manifold:element key). |
Multiply fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
value | number | yes | The change (-0.5 halves). | |
element | string or None | no | every element | The element. |
Set fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
value | number | yes | The amount. | |
element | string or None | no | the total | The element. |
Convert fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
from | string | yes | The element taken from. | |
to | string | yes | The element given to. | |
fraction | number | yes | The fraction, clamped to 0..=1. |
Cancel fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
reason | string | yes | The reason tag. |
AddContextTag fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
tag | string | yes | The tag. |
ApplyEffect fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
to | subject | yes | The participant. | |
effect | string | yes | The effect (manifold:effect key). | |
level | number | no | the holding effect’s | The effect’s level. |
Reflect fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
fraction | number | yes | The fraction. | |
damage_type | string | yes | The reflected hit’s damage type. |
Leech fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
fraction | number | yes | The fraction. | |
resource | string | no | manifold:health | The resource healed (manifold:stat key). |
Knockback fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
add | number | yes | The speed added. |
Cue fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
cue | string | yes | The cue (manifold:cue key). |