Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

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.

Registrymanifold:damage-hooks
Filesdata/damage_hooks/*.ron, *.update.ron, *.final.ron
Sidesserver: only the server loads it
Readsmanifold:predicate, manifold:stat
ContractGameplay framework, data stage

Entry

A record, written DamageHooks(..); the name before the parentheses is optional.

FieldTypeRequiredDefaultDescription
idstringyesThe set’s key, <mod-id>:<name>.
hookslist of DamageHookyesThe 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 (..).

FieldTypeRequiredDefaultDescription
stageDamageStageyesThe pipeline stage it runs at, which limits its actions.
sideHookSideyesWhich 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.
priorityi16no0Higher runs first, -32768 to 32767.
whencondition or NonenoalwaysA condition that must hold.
actionDamageActionyesWhat it does.

DamageStage

A stage of the damage pipeline.

VariantWrittenDescription
AdmitAdmitBefore anything: Cancel.
GatherGatherThe attacker’s part: Add, Multiply, Set, AddContextTag.
ConvertConvertBetween elements: Convert.
MitigateMitigateThe victim’s part: Add, Multiply, Set.
PreApplyPreApplyLast changes (blocks, parries, shields): all of the above and Cancel.
PreDeathPreDeathA killing hit only: Cancel (the victim survives), ApplyEffect.
PostHitPostHitAfter the hit: ApplyEffect, Reflect, Leech, Knockback, Cue.
PostKillPostKillAfter a kill: as PostHit.

HookSide

The participant a hook belongs to.

VariantWrittenDescription
AttackerAttackerThe attacker.
DirectDirectThe direct source (an arrow).
OwnerOwnerThe attacker’s owner.
VictimVictimThe 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>).

VariantWrittenDescription
AddAdd(value: .., element: ..)Adds to an element’s amount.
MultiplyMultiply(value: .., element: ..)Multiplies by 1 + value, on one element or all of them.
SetSet(value: .., element: ..)Sets one element’s amount, or the total (rescaling the elements).
ConvertConvert(from: .., to: .., fraction: ..)Moves a fraction of one element’s amount into another.
CancelCancel(reason: ..)Stops the hit, with a reason tag (manifold:cancel.* or the game’s).
AddContextTagAddContextTag(tag: ..)Adds a tag to the hit’s context tags.
ApplyEffectApplyEffect(to: .., effect: .., level: ..)Applies an effect to a participant, with the hook’s holder as source.
ReflectReflect(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).
LeechLeech(fraction: .., resource: ..)Lifesteal: heals the attacker by a fraction of the applied amount.
KnockbackKnockback(add: ..)Adds to the hit’s horizontal knockback, m/s.
CueCue(cue: ..)Plays a cue at the hit.

Add fields:

FieldTypeRequiredDefaultDescription
valuenumberyesThe amount, a number.
elementstring or Nonenothe hit’s primary elementThe element (manifold:element key).

Multiply fields:

FieldTypeRequiredDefaultDescription
valuenumberyesThe change (-0.5 halves).
elementstring or Nonenoevery elementThe element.

Set fields:

FieldTypeRequiredDefaultDescription
valuenumberyesThe amount.
elementstring or Nonenothe totalThe element.

Convert fields:

FieldTypeRequiredDefaultDescription
fromstringyesThe element taken from.
tostringyesThe element given to.
fractionnumberyesThe fraction, clamped to 0..=1.

Cancel fields:

FieldTypeRequiredDefaultDescription
reasonstringyesThe reason tag.

AddContextTag fields:

FieldTypeRequiredDefaultDescription
tagstringyesThe tag.

ApplyEffect fields:

FieldTypeRequiredDefaultDescription
tosubjectyesThe participant.
effectstringyesThe effect (manifold:effect key).
levelnumbernothe holding effect’sThe effect’s level.

Reflect fields:

FieldTypeRequiredDefaultDescription
fractionnumberyesThe fraction.
damage_typestringyesThe reflected hit’s damage type.

Leech fields:

FieldTypeRequiredDefaultDescription
fractionnumberyesThe fraction.
resourcestringnomanifold:healthThe resource healed (manifold:stat key).

Knockback fields:

FieldTypeRequiredDefaultDescription
addnumberyesThe speed added.

Cue fields:

FieldTypeRequiredDefaultDescription
cuestringyesThe cue (manifold:cue key).

Value forms used here: condition, number, subject.