> For the complete documentation index, see [llms.txt](https://axiomemu.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://axiomemu.gitbook.io/docs/data/monster/monsterskillunit.md).

# MonsterSkillUnit

Monster skill definitions. Each Unit picks a target mode, a scope mode, and up to 5 Elements (from MonsterSkillElement.xml) that all fire together when the monster casts the Unit.

## File Location

```
Data/Monster/MonsterSkillUnit.xml
```

Loaded once at GameServer startup. Changes require a restart.

## Role in the Monster Skill Pipeline

```
MonsterSkill.xml       assigns skill Units to monsters and maps them to trigger IDs
         |
         v
MonsterSkillUnit.xml   <-- this file (target mode + scope + element chain)
         |
         v
MonsterSkillElement.xml    (atomic effects)
```

## Dependencies

| Referenced by                                          | Purpose                                      |
| ------------------------------------------------------ | -------------------------------------------- |
| [MonsterSkill.xml](/docs/data/monster/monsterskill.md) | Assigns Unit `Number` to monster skill slots |

| Depends on                                                           | Purpose                                                   |
| -------------------------------------------------------------------- | --------------------------------------------------------- |
| [MonsterSkillElement.xml](/docs/data/monster/monsterskillelement.md) | Each `Element0`-`Element4` references an Element `Number` |

## Schema

```xml
<MonsterSkillUnit>
    <Unit Number="..." Name="..."
          TargetType="..." ScopeType="..." ScopeValue="..."
          Delay="..."
          Element0="..." Element1="..." Element2="..." Element3="..." Element4="..." />
</MonsterSkillUnit>
```

## Attributes

| Attribute             | Type       | Effect                                                                                                                                                                               |
| --------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Number`              | int        | Unique Unit ID (0-199). Values outside this range are ignored at load.                                                                                                               |
| `Name`                | string     | Human-readable label. Not used by logic.                                                                                                                                             |
| `TargetType`          | int        | `1` = cast on the passed-in target (enemy). `2` = redirect target to the caster (self / ally-self buffs and respawns).                                                               |
| `ScopeType`           | int or `*` | `0` = viewport scan with circular distance check. `1` = viewport scan with directional hitbox. `*` stores -1 and means "apply only to the single resolved target, no viewport scan". |
| `ScopeValue`          | int        | Tile radius used for `ScopeType="0"` only (strict `<` compare against distance). `ScopeType="1"` uses a fixed hitbox shape and ignores this value. `ScopeType="*"` ignores it.       |
| `Delay`               | int        | Stored on the Unit but not consulted by the skill pipeline. The AI layer controls cast cadence via MonsterAI timers, not this field. TODO: verify whether any AI path reads `Delay`. |
| `Element0`-`Element4` | int or `*` | Element `Number` from [MonsterSkillElement.xml](/docs/data/monster/monsterskillelement.md). `*` leaves the slot empty. Empty slots skip.                                             |

## Target and Scope Combinations

| TargetType | ScopeType | What Happens                                                                                                                                                        |
| ---------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1          | `*`       | Single-target: all Elements resolve on the caller-supplied target.                                                                                                  |
| 1          | 0         | Area: viewport is scanned, every live player within `ScopeValue` tiles of the caster receives all Elements. The originally passed target is ignored in this branch. |
| 1          | 1         | Hitbox: directional hitbox oriented from caster toward the passed target; every live player the hitbox hits receives all Elements.                                  |
| 2          | `*`       | Self/ally: target is rewritten to the caster. Elements apply to the caster.                                                                                         |
| 2          | 0 or 1    | Self-target is rewritten to the caster first, then the scan runs against the caster's viewport. In practice used with `*`.                                          |

Only Units with `TargetType="1"` run the per-monster special attack handler that calls the combat system. `TargetType="2"` Units only run Element logic on the caster.

## Element Chain

When a Unit fires against a resolved target, each non-empty `Element0`-`Element4` slot calls its Element handler in order. Every Element rolls its own `SuccessRate` independently; partial success is normal. A Unit with zero valid Elements still broadcasts the cast animation but has no gameplay effect beyond the attack handler's damage.

## Important Behavior

* Only 200 Unit slots exist (`Number` 0-199). Entries outside this range are dropped at load.
* `TargetType` does not map to "enemy vs single target". A `TargetType="1"` Unit can still AoE via `ScopeType="0"` or `ScopeType="1"`.
* `ScopeType="0"` uses a strict less-than compare, so `ScopeValue="6"` covers distances 0 through 5.
* `ScopeType="1"` uses a skill hitbox evaluator; `ScopeValue` is not a radius in this branch.
* `Delay` is loaded but the skill dispatcher does not read it. Cast cadence is controlled upstream by monster AI timers and per-skill cooldowns, not this field.
* `Name` is free-form and never compared.
* A Unit casts its broadcast packet first, then runs Elements. If the Unit points at invalid Elements, the cast animation still plays.

## Examples

{% tabs %}
{% tab title="Single-target Stun" %}

```xml
<Unit Number="8" Name="Single Stun"
      TargetType="1" ScopeType="*" ScopeValue="0"
      Delay="300"
      Element0="1" Element1="*" Element2="*" Element3="*" Element4="*"/>
```

Applies Element 1 to the passed target only. No viewport scan.
{% endtab %}

{% tab title="Circular AoE" %}

```xml
<Unit Number="1" Name="AoE Stun"
      TargetType="1" ScopeType="0" ScopeValue="6"
      Delay="300"
      Element0="1" Element1="*" Element2="*" Element3="*" Element4="*"/>
```

Every live player within 5 tiles (`< 6`) of the caster is rolled for Element 1.
{% endtab %}

{% tab title="Line Hitbox" %}

```xml
<Unit Number="14" Name="Line Attack"
      TargetType="1" ScopeType="1" ScopeValue="6"
      Delay="300"
      Element0="24" Element1="*" Element2="*" Element3="*" Element4="*"/>
```

Directional hitbox oriented from the caster toward the passed target. Every player the hitbox intersects rolls Element 24. `ScopeValue` is not the hitbox length for this branch.
{% endtab %}

{% tab title="Self Buff" %}

```xml
<Unit Number="42" Name="Berserk"
      TargetType="2" ScopeType="*" ScopeValue="0"
      Delay="300"
      Element0="56" Element1="*" Element2="*" Element3="*" Element4="*"/>
```

Target is redirected to the caster and Element 56 (Berserk) is applied to the caster itself.
{% endtab %}

{% tab title="Chained Debuffs" %}

```xml
<Unit Number="28" Name="Multi-Debuff"
      TargetType="1" ScopeType="*" ScopeValue="0"
      Delay="300"
      Element0="8" Element1="1" Element2="*" Element3="*" Element4="*"/>
```

Two Elements on the same cast. Each rolls its own `SuccessRate`; one, both, or neither can land.
{% endtab %}
{% endtabs %}

## Common Issues

* **Skill hits only one target when it should splash** - `ScopeType="*"`. Set `ScopeType="0"` with a tile radius in `ScopeValue`.
* **AoE radius feels one tile short** - the compare is strict `<`. Use `ScopeValue="N+1"` for an N-tile radius.
* **Self-buff hits enemies instead** - `TargetType` must be `2` for self-application.
* **Line skill ignores `ScopeValue`** - the hitbox branch does not use `ScopeValue` as a length. Hitbox shape is fixed in the engine.
* **Delay tuning has no effect** - the field is not consumed by the skill dispatcher. Change cast cadence through monster AI timing (see [MonsterAIUnit.xml](/docs/data/monster/monsteraiunit.md)) instead.
* **Unit does nothing on cast** - all `Element0`-`Element4` are `*` or point at missing Element Numbers.
* **Unit number ignored** - Numbers must be 0-199.
