# ItemDrop

This configuration file defines specific items that can drop from monsters with full control over their options. This is a **separate system** from normal monster drops (MonsterItem.txt).

## File Location

```
GameServer/Data/Item/ItemDrop.xml
```

## Dependencies

| Depends On              | Purpose                                   |
| ----------------------- | ----------------------------------------- |
| ItemOptionRate.xml      | Option indices reference rate tables here |
| ExcellentOptionRate.xml | Determines which excellent bits apply     |
| Item.xml                | Item definitions that can be dropped      |

| Depended On By | Purpose                                               |
| -------------- | ----------------------------------------------------- |
| MapManager.xml | ExcItemDropRate affects normal drops, not this system |

## How It Works

When a monster dies, the server:

1. **Filters by map** - RuleDrop MapNumber (-1 = all maps)
2. **Filters by monster** - MonsterIndex (-1 = any monster)
3. **Filters by monster level** - MonsterMinLevel/MonsterMaxLevel
4. **Rolls against DropRate** - Chance out of 1,000,000
5. **Selects item** - If multiple items pass, weighted random by inverse DropRate
6. **Resolves options** - Uses ItemOptionRate.xml for each option type
7. **Drops item** - Creates the item on the ground

{% hint style="info" %}
**Weighted Selection**: When multiple items pass all filters, items with LOWER DropRate have HIGHER weight. This means rare items are more likely to be selected when the roll succeeds.
{% endhint %}

## Structure

```xml
<ItemDrop>
    <RuleDrop MapNumber="-1">
        <Item Cat="14" Index="13" Level="0"
              LevelOption="-1" SkillOption="-1" LuckOption="-1"
              JoLOption="-1" ExcOption="-1" SetOption="-1" SocketOption="-1"
              Duration="0" MonsterIndex="-1"
              MonsterMinLevel="25" MonsterMaxLevel="-1"
              DropRate="100" />
    </RuleDrop>
</ItemDrop>
```

## Attributes

### RuleDrop Container

| Attribute   | Type    | Values       | Description                      |
| ----------- | ------- | ------------ | -------------------------------- |
| `MapNumber` | int/`*` | -1 or map ID | Map filter (-1 or \* = all maps) |

### Item Attributes

#### Item Identification

| Attribute | Type | Description                                 |
| --------- | ---- | ------------------------------------------- |
| `Cat`     | int  | Item category (0-15)                        |
| `Index`   | int  | Item index within category (0-511)          |
| `Level`   | int  | Item level (0-15), used when LevelOption=-1 |

{% hint style="info" %}
**Item Index Calculation**: Internal index = Cat *512 + Index. For example, Jewel of Bless (Cat=14, Index=13) = 14* 512 + 13 = 7181.
{% endhint %}

#### Option Indices

These reference sections in [ItemOptionRate.xml](https://axiomemu.gitbook.io/docs/gameserver/item/itemoptionrate). Use -1 to disable that option type.

| Attribute      | Type | Description                                      |
| -------------- | ---- | ------------------------------------------------ |
| `LevelOption`  | int  | Level rate table index (-1 = use Level directly) |
| `SkillOption`  | int  | Skill option rate table index                    |
| `LuckOption`   | int  | Luck option rate table index                     |
| `JoLOption`    | int  | JoL (additional damage/defense) rate table index |
| `ExcOption`    | int  | Excellent options count rate table index         |
| `SetOption`    | int  | Set tier rate table index                        |
| `SocketOption` | int  | Socket count rate table index                    |

#### Common Option Index Values

| Value | Effect                                              |
| ----- | --------------------------------------------------- |
| -1    | Disabled - no option or use default value           |
| 0     | Common rates (from Index 0 in ItemOptionRate)       |
| 1     | Excellent rates (typically guaranteed/high quality) |
| 2     | Set rates                                           |
| 12-15 | Guaranteed 1-4 excellent options (for ExcOption)    |

{% hint style="warning" %}
**Skill Option Note**: If SkillOption resolves to "has skill" but the item doesn't support skills (SkillIndex=0 in Item.xml), the skill option is automatically removed.
{% endhint %}

#### Drop Filters

| Attribute         | Type    | Default  | Description                                            |
| ----------------- | ------- | -------- | ------------------------------------------------------ |
| `Duration`        | int     | 0        | Item duration in seconds (0 = permanent)               |
| `MonsterIndex`    | int/`*` | -1       | Monster class ID (-1 or \* = any monster)              |
| `MonsterMinLevel` | int/`*` | -1       | Minimum monster level (-1 or \* = no minimum)          |
| `MonsterMaxLevel` | int/`*` | -1       | Maximum monster level (-1 or \* = no maximum)          |
| `DropRate`        | int/`*` | Required | Chance out of 1,000,000 (-1 or \* = 100% when checked) |

## DropRate Scale

| DropRate | Percentage | Example Use                |
| -------- | ---------- | -------------------------- |
| 1000000  | 100%       | Testing / guaranteed drops |
| 100000   | 10%        | Very common drops          |
| 10000    | 1%         | Common drops               |
| 1000     | 0.1%       | Uncommon drops             |
| 100      | 0.01%      | Rare drops                 |
| 10       | 0.001%     | Very rare drops            |

{% hint style="info" %}
**Crywolf Penalty**: Jewel of Chaos, Bless, Soul, Life, Creation, and Guardian are affected by Crywolf occupation state. If Crywolf is occupied by Balgass and penalty is active, these jewels have reduced drop chance.
{% endhint %}

## Examples

{% tabs %}
{% tab title="Jewel Drops" %}

```xml
<!-- Jewel of Bless from monsters level 25+ -->
<Item Cat="14" Index="13" Level="0"
      LevelOption="-1" SkillOption="-1" LuckOption="-1"
      JoLOption="-1" ExcOption="-1" SetOption="-1" SocketOption="-1"
      Duration="0" MonsterIndex="-1"
      MonsterMinLevel="25" MonsterMaxLevel="-1"
      DropRate="100" />

<!-- Jewel of Chaos from level 12+ -->
<Item Cat="12" Index="15" Level="0"
      LevelOption="-1" SkillOption="-1" LuckOption="-1"
      JoLOption="-1" ExcOption="-1" SetOption="-1" SocketOption="-1"
      Duration="0" MonsterIndex="-1"
      MonsterMinLevel="12" MonsterMaxLevel="-1"
      DropRate="100" />
```

All option indices are -1 because jewels don't have options.
{% endtab %}

{% tab title="Level-Scaled Items" %}

```xml
<!-- Scroll of Archangel - level scales with monster level -->
<Item Cat="13" Index="16" Level="1" ...
      MonsterMinLevel="-1" MonsterMaxLevel="32" DropRate="100" />
<Item Cat="13" Index="16" Level="2" ...
      MonsterMinLevel="33" MonsterMaxLevel="45" DropRate="100" />
<Item Cat="13" Index="16" Level="3" ...
      MonsterMinLevel="46" MonsterMaxLevel="57" DropRate="100" />
<Item Cat="13" Index="16" Level="4" ...
      MonsterMinLevel="58" MonsterMaxLevel="68" DropRate="100" />
```

Different item levels drop based on monster level ranges.
{% endtab %}

{% tab title="Boss-Specific Drop" %}

```xml
<!-- Invitation to Santa Village - only from monster 466 -->
<Item Cat="13" Index="66" Level="0"
      LevelOption="-1" SkillOption="-1" LuckOption="-1"
      JoLOption="-1" ExcOption="-1" SetOption="-1" SocketOption="-1"
      Duration="0" MonsterIndex="466"
      MonsterMinLevel="-1" MonsterMaxLevel="-1"
      DropRate="100" />
```

Using MonsterIndex to restrict drops to a specific monster.
{% endtab %}

{% tab title="Excellent Equipment" %}

```xml
<!-- Excellent sword with randomized options -->
<Item Cat="0" Index="5" Level="0"
      LevelOption="1" SkillOption="1" LuckOption="1"
      JoLOption="1" ExcOption="1" SetOption="-1" SocketOption="-1"
      Duration="0" MonsterIndex="-1"
      MonsterMinLevel="50" MonsterMaxLevel="-1"
      DropRate="50" />
```

* LevelOption=1: Uses excellent level rates (guaranteed +0)
* SkillOption=1: Guaranteed skill
* LuckOption=1: Low luck chance (1% for luck)
* JoLOption=1: No JoL bonus (guaranteed 0)
* ExcOption=1: 75% one exc, 25% two exc
  {% endtab %}

{% tab title="Map-Specific" %}

```xml
<!-- Drops only in Icarus (map 10) -->
<RuleDrop MapNumber="10">
    <Item Cat="12" Index="0" Level="0"
          LevelOption="0" SkillOption="0" LuckOption="0"
          JoLOption="0" ExcOption="-1" SetOption="-1" SocketOption="-1"
          Duration="0" MonsterIndex="-1"
          MonsterMinLevel="-1" MonsterMaxLevel="-1"
          DropRate="500" />
</RuleDrop>
```

Using RuleDrop MapNumber to restrict drops to specific maps.
{% endtab %}
{% endtabs %}

## Important Behavior

{% hint style="info" %}
**Separate from MonsterItem.txt**: This system runs independently from the normal monster drop system. Items configured here are additional drop chances, not replacements.
{% endhint %}

{% hint style="info" %}
**Multiple Items Passing**: If multiple items pass all filters and their DropRate rolls, ONE is randomly selected. Items with lower DropRate have higher selection weight (inverse weighting).
{% endhint %}

{% hint style="warning" %}
**Option Index -1 vs 0**: Using -1 disables that option type entirely. Using 0 uses the "Common" rate table from ItemOptionRate.xml, which typically has low chances for good options.
{% endhint %}

## Common Issues

{% hint style="warning" %}
**Item Not Dropping**: Check all filters - MapNumber, MonsterIndex, MonsterMinLevel, MonsterMaxLevel must ALL match. A single mismatch prevents the drop.
{% endhint %}

{% hint style="warning" %}
**Wrong Item Level**: If you set Level="5" but LevelOption="0", the level will be randomized using Common rates (mostly +0). Use LevelOption="-1" to use the Level value directly.
{% endhint %}

{% hint style="danger" %}
**Duration Confusion**: Duration is in SECONDS, not minutes. A value of 3600 = 1 hour. Use 0 for permanent items.
{% endhint %}

{% hint style="warning" %}
**Excellent Options Not Appearing**: ExcOption controls the COUNT of options. The actual option types are determined by ExcellentOptionRate.xml based on item index ranges.
{% endhint %}
