Skip to content

01 — Rules Basics

Goal:
Show how Damage Rules modify incoming hits via the DamageRuleHub.


🎓 What This Scene Teaches

  • How damage flows through the DamageRuleHub pipeline.
  • How different rules (Armor, Affinity, Crit) modify incoming hits.
  • How rule stacking works — order, priority, and modular design.
  • That the HealthSystem itself remains rule-agnostic: it only delegates.

🧩 What’s in This Scene

Object Description
Player Capsule Contains HealthSystem + DebugUI — can apply or receive test damage.
Enemy Capsule Contains HealthSystem, DebugUI, and a DamageRuleHub with:
- ArmorRule → Flat + % damage reduction.
- AffinityRule + SimpleAffinityProvider → Tag-based immunity/resist/weakness.
- CritRule → Random chance to apply a critical hit (damage multiplier).

⚠️ Authority Note
This scene runs with Require Authority disabled by default.
Health mutations are allowed locally for demonstration purposes.

Enabling an authority binder alone will not block mutations unless
Require Authority is enabled on the HealthSystem — this is intentional.

Why Health works this way:
https://revandrab.github.io/RevFramework/authority/#health-opt-in-authority-gameplay-state


🕹️ How to Use

  1. Press Play.
  2. Open the DebugUI (F9) for the Enemy Capsule.
  3. Use the Damage button with different tag values.
  4. Observe results in the live log and panel readout:
Example Expected Behaviour
Armor active Reduces flat + % damage.
fire tag Immune (0 damage).
poison tag Half damage (resistance).
melee tag Increased damage (weakness).
Crit chance Occasionally doubles the hit via CritRule.

⚙️ Components Used

Component Role
DamageRuleHub Runs all attached rules in priority order.
ArmorRule Applies flat and percentage damage reduction.
AffinityRule Queries IDamageAffinity providers on the victim for tag multipliers.
CritRule Applies RNG-based critical hits; supports deterministic seeding.

💡 Key Idea

DamageRuleHub is modular — add or remove rules as components.
The HealthSystem doesn’t care about the specifics; it simply asks the hub to process incoming damage.


🔧 Expanding on Rules

  • Rules are fully extensible — add your own custom modifiers or elemental logic.
  • The order of rule execution defines the final result.
  • Example: combine Armor → Affinity → Crit for rich layered behaviour.
  • Pro Tip: You can also register environmental or global rules (e.g. damage over time zones) for advanced systems.

🧠 Determinism (CritRule)

By default, CritRule uses random chance.
For deterministic results (e.g., multiplayer or replay systems):

  • Set Rng Source = InternalSystem and supply a Seed.
  • Or set Rng Source = ExternalProvider and pass an IRng implementation (e.g., from a netcode RNG).

This ensures identical crit outcomes across clients and hosts.


🧩 Demo Notes

  • Some panels auto-add missing dependencies (e.g., TeamRule or SimpleAffinityProvider) when you click demo buttons.
    This keeps the scene self-contained — in production, you’d wire these manually.

✅ Key Takeaway

The DamageRuleHub is the glue between the raw HealthSystem and your custom logic.
It’s how you teach your game what “damage” actually means —
flat reduction, elemental affinity, crits, or anything else you can imagine.