> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rpg-leveling.zuxaw.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Difficulty Scaling

> Monster damage, HP scaling, and level-gap penalties (0.2.0).

# Difficulty Scaling

Monsters **scale with level** and **punish underleveled players**, but they do it by boosting their HP pools - your damage is still intact, you simply have to land more hits on higher-level foes. The system uses **true HP modification** to increase monster max HP based on their level, so stat upgrades feel rewarding while each level increases the amount of health to burn through.

**Features:**

* Higher-level monsters deal more damage and are tankier
* Fighting underleveled is dangerous (gap penalties)
* **4 difficulty presets:** Easy, Normal, Hard, Extreme
* All values configurable via preset

***

## Difficulty Presets

| Preset      | Monster→Player Dmg/Lvl | HP%/Lvl | Gap Dmg Mult | Gap Def Mult | Best For    |
| ----------- | ---------------------- | ------- | ------------ | ------------ | ----------- |
| **EASY**    | +0.5%                  | +2%     | ×0.75        | ×0.75        | New players |
| **NORMAL**  | +1%                    | +3.25%  | ×1.0         | ×1.0         | Default     |
| **HARD**    | +2%                    | +4.5%   | ×1.25        | ×1.25        | Experienced |
| **EXTREME** | +4%                    | +6.5%   | ×1.5         | ×1.5         | Hardcore    |

**Example (Level 50 monster, NORMAL):**

* **Damage:** Base × 1.5 → **1.5× harder**\
  `1 + (50 × 0.01) = 1.5`\
  If base 10 damage → **15 damage**
* **Tankiness:** Max HP × 2.63 → **2.63× tankier**\
  HP mult `1 + (50 × 0.0325) = 2.625`\
  If base 100 HP → **263 HP** (needs 2.63× more hits to kill)

***

## Monster Damage Scaling (Monster → Player)

**Formula:** `Final = Base × (1 + Level × Monster→Player Dmg%/Lvl)`

| Level | EASY   | NORMAL | HARD | EXTREME |
| ----- | ------ | ------ | ---- | ------- |
| 25    | 1.125× | 1.25×  | 1.5× | 2.0×    |
| 50    | 1.25×  | 1.5×   | 2.0× | 3.0×    |
| 75    | 1.375× | 1.75×  | 2.5× | 4.0×    |
| 100   | 1.5×   | 2.0×   | 3.0× | 5.0×    |

***

## Monster HP Scaling

**Formula:** `Max HP = Base × (1 + Level × HP%/Lvl)`\
**HP Multiplier:** `1 + (Level × HP%/Lvl)`

Monsters have their **max HP increased** based on their level. The HP bar reflects the actual increased HP.
This approach keeps player damage from being artificially reduced - instead of nerfing your hits, monsters simply require more of them as their HP grows with level.

| Level | EASY  | NORMAL | HARD  | EXTREME |
| ----- | ----- | ------ | ----- | ------- |
| 25    | 1.49× | 1.81×  | 2.14× | 2.63×   |
| 50    | 1.98× | 2.63×  | 3.28× | 4.25×   |
| 75    | 2.46× | 3.44×  | 4.41× | 5.88×   |
| 100   | 2.95× | 4.25×  | 5.55× | 7.5×    |

**Example (L87, NORMAL):**\
HP mult `1 + (87 × 0.0325) = 3.83` → if base 100 HP → **383 HP** (3.83× more HP).

***

## Gap Damage Bonus (Monster → Player)

Gap damage bonus **only applies when the monster is higher level** than the player:

**When Monster Level > Player Level (Positive Gap):**

* Monster deals **extra damage**
* Formula: `Final = Base × (1 + Gap × 0.01 × GapDmgMult)`

**When Player Level > Monster Level (Negative Gap):**

* **No damage change** - gap bonus returns 1.0× (no effect)
* Negative gaps only affect XP rewards, not damage dealt

**Base rate:** +1% per level above player (scaled by preset).

| Level Gap         | EASY             | NORMAL           | HARD             | EXTREME          |
| ----------------- | ---------------- | ---------------- | ---------------- | ---------------- |
| **+1**            | +0.75% (1.01×)   | +1% (1.01×)      | +1.25% (1.01×)   | +1.5% (1.02×)    |
| **+5**            | +3.75% (1.04×)   | +5% (1.05×)      | +6.25% (1.06×)   | +7.5% (1.08×)    |
| **+10**           | +7.5% (1.08×)    | +10% (1.10×)     | +12.5% (1.13×)   | +15% (1.15×)     |
| **+20**           | +15% (1.15×)     | +20% (1.20×)     | +25% (1.25×)     | +30% (1.30×)     |
| **+30**           | +22.5% (1.23×)   | +30% (1.30×)     | +37.5% (1.38×)   | +45% (1.45×)     |
| **+50**           | +37.5% (1.38×)   | +50% (1.50×)     | +62.5% (1.63×)   | +75% (1.75×)     |
| **0 or negative** | 1.0× (no change) | 1.0× (no change) | 1.0× (no change) | 1.0× (no change) |

Gap damage to player can be **disabled** via `EnableGapLevelDamageToPlayer: false` in config - monsters will not get bonus damage from level gap.

***

## Gap Defense (Player → Monster)

When you're **below** the monster's level, you can optionally deal **less** damage via **damage resistance**. Tiered by gap, this is an extra layer on top of the HP scaling toughness above - disable it if you prefer consistent damage and let the increased HP do the heavy lifting.

| Level Gap | EASY | NORMAL | HARD | EXTREME |
| --------- | ---- | ------ | ---- | ------- |
| **0–5**   | 100% | 100%   | 100% | 100%    |
| **6–10**  | 90%  | 85%    | 80%  | 75%     |
| **11–20** | 85%  | 75%    | 70%  | 65%     |
| **21–30** | 75%  | 70%    | 65%  | 55%     |
| **31+**   | 55%  | 50%    | 30%  | 20%     |

**Formula:** `Damage Taken = Original / Resistance Multiplier`\
**Resistance Multiplier:** `1 / Damage Taken Percentage`

Gap defense uses **damage resistance** (divide by multiplier), not percentage reduction. For example, if you deal 75% damage (gap 11–20, NORMAL), the resistance multiplier is `1 / 0.75 = 1.333×` - your damage is divided by 1.333×.

Defense cap: the highest gap tier now leaves you dealing **55%** (EASY), **50%** (NORMAL), **30%** (HARD), or **20%** (EXTREME) damage - roughly 45% / 50% / 70% / 80% reduction. Monsters stay more killable when underleveled.

***

## Combat Examples

| Scenario       | Monster Dmg | Monster Tank | Gap Dmg      | Gap Def   | Result            |
| -------------- | ----------- | ------------ | ------------ | --------- | ----------------- |
| **L50 vs L50** | 1.5×        | 2.25×        | None         | None      | Fair              |
| **L45 vs L55** | 1.55×       | 2.25×        | +10% (1.10×) | 85% taken | Harder            |
| **L45 vs L70** | 1.70×       | 2.25×        | +25% (1.25×) | 50% taken | Very hard         |
| **L45 vs L86** | 1.86×       | 2.25×        | +41% (1.41×) | 25% taken | Nearly impossible |

***

## Configuration

**File:** `mods/Zuxaw_RPGLeveling/RPGLevelingConfig.json`

```json theme={null}
{
  "difficultyPreset": "normal",
  "EnableMonsterLevelScale": true,
  "EnableGapLevelDefense": true,
  "EnableGapLevelDamageToPlayer": true,
  "EnableGapLevelXpReducer": true
}
```

| Field                            | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| -------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **difficultyPreset**             | String  | `"easy"`, `"normal"`, `"hard"`, or `"extreme"`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| **EnableMonsterLevelScale**      | Boolean | If `true` (default), monster **level scaling** is enabled: monster damage/HP scale with level (HP scaling is the primary toughness mechanic, so your damage stays consistent while higher levels require more hits), gap damage bonus (monster → you) and gap defense (you → monster) apply, and XP from kills uses the new level-based system (monster level + level gap). If `false`, all monster level scaling is **disabled**: no level-based damage/HP, no gap damage/defense, and XP from kills falls back to the old HP-based formula (only mob max HP). Monster/zone levels and level display above player head still work visually. |
| **EnableGapLevelDefense**        | Boolean | If `true` (default), extra level-gap defense is applied: you deal less damage when underleveled via damage resistance tiers. If `false`, gap defense is **disabled** - your damage to monsters is not reduced by the gap, letting you feel each stat-point increase while HP scaling handles the toughness. Use `false` for a more consistent damage feel or when HP-scaling alone provides enough challenge.                                                                                                                                                                                                                                |
| **EnableGapLevelDamageToPlayer** | Boolean | If `true` (default), level-gap damage scaling is applied: when a monster is above your level, it deals **extra** damage (gap damage bonus). If `false`, gap damage to player is **disabled** - monsters do not get bonus damage from level gap; only monster base damage/HP scaling and gap defense (you → monster) still apply. Use `false` to avoid "monsters hit harder when you're underleveled."                                                                                                                                                                                                                                        |
| **EnableGapLevelXpReducer**      | Boolean | If `true` (default), XP is reduced when you are underleveled (monster level above yours) - see the level-difference table in [Formulas](formulas). If `false`, no XP reduction for being underleveled - you get full XP (1.0×) from higher-level monsters.                                                                                                                                                                                                                                                                                                                                                                                   |

Difficulty scaling (monster damage/HP) is controlled by `EnableMonsterLevelScale`. `difficultyPreset` sets damage%, HP%, and gap multipliers. `EnableGapLevelDefense` turns off gap defense (player → monster). `EnableGapLevelDamageToPlayer` turns off gap damage (monster → player). `EnableGapLevelXpReducer` turns off XP reduction when underleveled.

***

## Formulas Summary

**Monster damage (monster → player):**\
`Final = Base × (1 + Level × Monster→Player Dmg%/Lvl)`

**Monster HP:**\
`Max HP = Base × (1 + Level × HP%/Lvl)`

**Gap damage (monster → you):**\
`Final = Base × (1 + Gap × 0.01 × GapDmgMult)` (only when Gap > 0, otherwise 1.0×)

**Gap defense (you → monster):**\
`Damage Taken = Original / Resistance Multiplier`\
`Resistance Multiplier = 1 / TierValue[Gap]`\
(capped: EASY/NORMAL min 25% damage, HARD/EXTREME min 10% damage). Disabled when `EnableGapLevelDefense` is `false`.

**Damage pipeline (you → monster):**\
`Final = (Raw + DamageStatFlat) × DamageStatMult / GapResistanceMult`\
(Note: Monster HP is increased via HP modifiers. Gap penalties use damage resistance.)

**Defense pipeline (monster → you):**\
`Final = Raw × MonsterLevelMult × (1 + Gap × 0.01 × GapDmgMult) × (1 - PlayerDefense)`\
(Note: Gap bonus only applies when Gap > 0, otherwise multiplier is 1.0×)

***

## Implementation Notes

* **Level-based HP scaling** via **true HP modification** - monsters have increased max HP based on their level
* **Level-based HP scaling** via **true HP modification** - monsters have increased max HP based on their level, so player damage stays consistent but higher-level mobs simply take more hits
* Mobs display increased HP in their HP bar (reflects actual HP)
* HP modifiers are applied via EntityStatMap modifiers (similar to HardcoreMode approach)
* **Gap penalties** use **damage resistance** (divide by multiplier) - when you're underleveled, your damage is divided by a resistance multiplier
* Gap defense capped per preset: EASY/NORMAL 75% reduction (25% min damage), HARD/EXTREME 90% reduction (10% min damage); monsters remain more killable
* Gap defense can be disabled via `EnableGapLevelDefense: false` in config
* Gap damage bonus only applies when the player is **underleveled** (positive gap)
* Negative gaps (player > monster) do not reduce damage - they only affect XP rewards
* Scaling is always enabled and controlled via `difficultyPreset`

See [Formulas](formulas) for XP and leveling, and [Configuration](configuration) for main plugin config.
