1 passive traits and procs
forgejo-actions edited this page 2026-07-13 19:05:50 +00:00

Passive Traits And Procs

What This System Is

The passive system is the shared data-driven layer for permanent traits, equipment-granted passives, conditional stat contributions, ability adjustments, and event-driven procs. The same catalog is parsed by runtime tools and authoritative services, while the server owns condition evaluation, deterministic chance rolls, cooldowns, resource changes, and status application.

Granted passives are replicated with their source and active or inactive explanation. This lets the character panel explain why a trait is working instead of presenting unexplained stat changes.

How Authors Use It

Add a definition to assets/gameplay/passive_catalog.json. Choose whether progression grants it automatically, author any level, tag, unlock, health, tool, status, combat, ability, or damage-kind requirements, and add one or more effects.

Equipment grants traits through equipment.passive_ids in the authored game-data item shard. The item editor exposes this list as Passive Traits, validates every id against the shipped catalog, and preserves it through catalog serialization and aggregate generation.

Available triggers are always, on_hit, on_critical, on_damaged, on_defeat, and on_ability_used. Effects can contribute a character stat, apply a status to self or target, restore health, mana, or stamina, or modify an authored ability's cooldown and costs.

Rules And Invariants

  • Passive ids are stable, case-insensitive lookup keys and must be unique.
  • Stat modifiers use the always trigger and enter the character-stat resolver as passive sources.
  • Proc chance is an integer percentage from 0 through 100 and is rolled deterministically from the authoritative request seed, passive id, and effect index.
  • A passive cooldown begins only after an effect is successfully applied.
  • Equipment can grant a passive, but its requirements and runtime conditions must still pass.
  • Unknown status-effect references and equipment passive ids are authoring errors.
  • Clients render replicated state; they do not decide whether a passive activates or procs.

Validation And Debugging

Catalog loading rejects unsupported schema versions, duplicate or blank ids, missing labels or effects, invalid proc chances, and event-triggered stat modifiers. Runtime hot reload validates passive status references before atomically replacing the active catalog.

Inspect PlayerStatsSnapshot.passives to see each grant source, active flag, and inactive reason. Inspect stat_sources for active passive stat contributions and the player combat snapshot for status effects created by procs. Proc cooldowns remain server-owned so clients cannot reset them.

The focused regressions cover catalog conditions, deterministic proc selection, equipment-granted critical stats, critical target-status application, low-health resource recovery, ability cost and cooldown adjustment, protocol round trips, and UI projection.

Examples

An equipment-granted critical trait:

{
  "id": "trait.ranger.precision",
  "label": "Ranger Precision",
  "conditions": [{ "kind": "equipped_tool", "tool": "bow" }],
  "effects": [
    {
      "kind": "stat_modifier",
      "trigger": "always",
      "stat": "critical_hit",
      "value": 10
    }
  ]
}

A low-health proc can use health_below_percent, on_damaged, and restore_resource, with proc_cooldown_ms preventing it from firing on every hit. Ability specialization uses ability_is plus modify_ability to adjust only the matching authored ability.