item_stats defense - magemonkeystudio/divinity GitHub Wiki

🛡️ item_stats/defense.yml

This file defines all defense types used by Divinity to reduce damage from specific sources. Each defense can block one or more custom damage types and reduce incoming damage based on its protection-factor.

Divinity uses these entries to determine how players resist different types of attacks, such as magical, fire, poison, or even custom types you define.


🧾 Default Defense Types

physical:
  priority: 100
  name: Physical Defense
  format: '&6▸ %name%: &f%value% %condition%'
  block-damage-types:
    - physical
  protection-factor: 0.8

magical:
  priority: 10
  name: Magical Defense
  format: '&d▸ %name%: &f%value% %condition%'
  block-damage-types:
    - magical
  protection-factor: 0.8

fire:
  priority: 10
  name: Fire Defense
  format: '&c▸ %name%: &f%value% %condition%'
  block-damage-types:
    - fire
  protection-factor: 0.8

poison:
  priority: 10
  name: Poison Defense
  format: '&a▸ %name%: &f%value% %condition%'
  block-damage-types:
    - poison
  protection-factor: 0.8

water:
  priority: 10
  name: Water Defense
  format: '&9▸ %name%: &f%value% %condition%'
  block-damage-types:
    - water
  protection-factor: 0.8

wind:
  priority: 10
  name: Wind Defense
  format: '&7▸ %name%: &f%value% %condition%'
  block-damage-types:
    - wind
  protection-factor: 0.8
```

---

## 📌 Key Settings

| Setting             | Description |
|---------------------|-------------|
| `priority`          | **Determines which defense type is applied when more than one could block the same damage.** Only the highest-priority matching defense is used. |
| `block-damage-types`| List of damage types (from `damage.yml`) that this defense protects against. |
| `protection-factor` | Multiplier applied to reduce damage. `0.8` means 80% of damage is blocked. |
| `format`            | How this defense appears in item lore. Supports `%name%`, `%value%`, and `%condition%`. |
| `name`              | Display name of the defense stat shown in item tooltips. |

---

## ⚠️ About `priority`

When multiple defenses match the incoming damage type, **only the one with the highest `priority` is used** to calculate damage reduction. This ensures no stacking of multiple defenses for the same hit.

For example:
- If both `magical` and `fire` defenses block a hit from fire damage:
  - Only the one with the **higher `priority`** takes effect
  - The others are ignored

If you want one defense to always "win" in case of overlap, give it a higher priority.

---

## ➕ Custom Defense Example

````yaml
shadow:
  priority: 50
  name: Shadow Defense
  format: '&8▸ %name%: &f%value%'
  block-damage-types:
    - shadow
  protection-factor: 0.75
```

---

## 💬 Notes

- You can safely rename or remove any unused default defenses.
- Each damage type should ideally be covered by **exactly one defense** to avoid confusion.
- There is no limit to how many defense types you can define.