# ItemOptionRate

This configuration file defines the probability tables used when determining item options (level, skill, luck, excellent options, etc.) during item generation.

## File Location

```
GameServer/Data/Item/ItemOptionRate.xml
```

## Dependencies

| Depends On     | Purpose                                        |
| -------------- | ---------------------------------------------- |
| Item.xml       | Item definitions that receive these options    |
| ItemOption.xml | Stat bonuses applied based on selected options |

## How It Works

When an item is generated, the server:

1. Looks up the appropriate **Index** based on the source (monster drop, chaos mix, event, etc.)
2. Uses **weighted random selection** to pick an option value
3. Applies that option to the item

{% hint style="info" %}
**Weighted Selection**: If Rate0=7000, Rate1=2000, Rate2=1000, the system has 70% chance for option 0, 20% for option 1, 10% for option 2. These are NOT cumulative - they are relative weights.
{% endhint %}

## Configuration Sections

### LevelOptions

Controls item enhancement level (+0 to +15) when items drop.

```xml
<LevelOptions>
    <Level Index="0" Rate0="7000" Rate1="1500" Rate2="1000" Rate3="500"
           Rate4="0" ... Rate15="0" Name="Level Option (Common)"/>
</LevelOptions>
```

| Attribute          | Type   | Range   | Description                                   |
| ------------------ | ------ | ------- | --------------------------------------------- |
| `Index`            | int    | 0-53    | Source identifier (see Index Reference below) |
| `Rate0` - `Rate15` | int    | 0-10000 | Weight for each level (+0 to +15)             |
| `Name`             | string | -       | Human-readable description                    |

<details>

<summary>Level Index Reference</summary>

| Index | Source               | Typical Use                                |
| ----- | -------------------- | ------------------------------------------ |
| 0     | Common drops         | Regular monster kills                      |
| 1     | Excellent items      | Forces +0 for excellent drops              |
| 2     | Set items            | Forces +0 for set items                    |
| 3     | Chaos mix            | Equal chance +0 to +4                      |
| 9     | Moss Merchant        | NPC-sold items                             |
| 10    | Lucky items          | Higher level distribution                  |
| 11-26 | EventItemBag (fixed) | Forces specific level (11=+0, 12=+1, etc.) |
| 27-53 | EventItemBag (range) | Random within level range                  |

</details>

**Example - Common Drop Distribution:**

```xml
<Level Index="0" Rate0="7000" Rate1="1500" Rate2="1000" Rate3="500"
       Rate4="0" Rate5="0" ... Name="Level Option (Common)"/>
```

* 70% chance for +0
* 15% chance for +1
* 10% chance for +2
* 5% chance for +3
* 0% chance for +4 through +15

### SkillOptions

Controls whether items spawn with skill option (for weapons).

```xml
<SkillOptions>
    <Skill Index="0" Rate0="9400" Rate1="600" Name="Skill Option (Common)"/>
</SkillOptions>
```

| Attribute | Type | Range   | Description          |
| --------- | ---- | ------- | -------------------- |
| `Index`   | int  | 0-13    | Source identifier    |
| `Rate0`   | int  | 0-10000 | Weight for NO skill  |
| `Rate1`   | int  | 0-10000 | Weight for HAS skill |

**Common Values:**

* Index 0 (Common): 94% no skill, 6% has skill
* Index 1 (Excellent): 100% has skill
* Index 2 (Set): 100% has skill

### LuckOptions

Controls whether items spawn with luck option (+critical damage rate).

```xml
<LuckOptions>
    <Luck Index="0" Rate0="9600" Rate1="400" Name="Luck Option (Common)"/>
</LuckOptions>
```

| Attribute | Type | Range   | Description         |
| --------- | ---- | ------- | ------------------- |
| `Index`   | int  | 0-13    | Source identifier   |
| `Rate0`   | int  | 0-10000 | Weight for NO luck  |
| `Rate1`   | int  | 0-10000 | Weight for HAS luck |

### JoLOptions

Controls Jewel of Life additional option value (+0 to +7 additional damage/defense).

```xml
<JoLOptions>
    <JoL Index="0" Rate0="9600" Rate1="150" Rate2="100" Rate3="50"
         Rate4="0" Rate5="0" Rate6="0" Rate7="0" Name="JoL Option (Common)"/>
</JoLOptions>
```

| Attribute         | Type | Range   | Description               |
| ----------------- | ---- | ------- | ------------------------- |
| `Index`           | int  | 0-31    | Source identifier         |
| `Rate0` - `Rate7` | int  | 0-10000 | Weight for each JoL value |

{% hint style="info" %}
JoL values add flat damage (weapons) or defense (armor). Each point is significant for early-game balance.
{% endhint %}

### ExcOptions

Controls how many excellent options spawn on excellent items (0-6 options).

```xml
<ExcOptions>
    <Exc Index="1" Rate0="0" Rate1="7500" Rate2="2500" Rate3="0"
         Rate4="0" Rate5="0" Rate6="0" Name="Exc Option (Exc)"/>
</ExcOptions>
```

| Attribute         | Type | Range   | Description                  |
| ----------------- | ---- | ------- | ---------------------------- |
| `Index`           | int  | 0-28    | Source identifier            |
| `Rate0` - `Rate6` | int  | 0-10000 | Weight for each option count |

**For Excellent Drops (Index 1):**

* 75% chance for 1 excellent option
* 25% chance for 2 excellent options

{% hint style="warning" %}
This controls the **count** of excellent options, not which specific options. The actual options are determined by ExcellentOptionRate.xml.
{% endhint %}

### SetOptions

Controls set item tier when set items drop.

```xml
<SetOptions>
    <Set Index="2" Rate0="0" Rate1="8000" Rate2="2000" Name="Set Option (Set)"/>
</SetOptions>
```

| Attribute | Type | Range   | Description       |
| --------- | ---- | ------- | ----------------- |
| `Index`   | int  | 0-14    | Source identifier |
| `Rate0`   | int  | 0-10000 | Weight for tier 0 |
| `Rate1`   | int  | 0-10000 | Weight for tier 1 |
| `Rate2`   | int  | 0-10000 | Weight for tier 2 |

### SocketOptions

Controls socket count for socket weapons and pentagram items.

```xml
<SocketOptions>
    <Socket Index="3" Rate0="0" Rate1="8400" Rate2="1550" Rate3="50"
            Rate4="0" Rate5="0" Name="Socket Option (OneHand)"/>
</SocketOptions>
```

| Attribute         | Type | Range   | Description                  |
| ----------------- | ---- | ------- | ---------------------------- |
| `Index`           | int  | 0-23    | Source identifier            |
| `Rate0` - `Rate5` | int  | 0-10000 | Weight for each socket count |

## Index Reference (All Sections)

| Index | Name                                 | Usage                              |
| ----- | ------------------------------------ | ---------------------------------- |
| 0     | Common                               | Regular monster drops              |
| 1     | Exc                                  | Excellent item generation          |
| 2     | Set                                  | Set item generation                |
| 3     | ChaosItemMix / DinorantMix / OneHand | Chaos machine mixes                |
| 4     | Wing2Mix / TwoHand                   | Second wing mix / Two-hand weapons |
| 5     | Wing1Mix / Pentagram                 | First wing mix / Pentagram items   |
| 6     | Wing3Mix / SocketWeaponMix           | Third wing mix                     |
| 7     | MonsterWingMix                       | Monster wing mix                   |
| 8     | SocketWeaponMix                      | Socket weapon mix                  |
| 9     | MossMerchant                         | Moss NPC purchases                 |
| 10    | Lucky                                | Lucky item drops                   |
| 11+   | EventItemBag                         | Specific event configurations      |

## Examples

{% tabs %}
{% tab title="High-Quality Server" %}
Increase base item quality for a more rewarding experience:

```xml
<!-- More common +3 to +5 drops -->
<Level Index="0" Rate0="4000" Rate1="2500" Rate2="1500" Rate3="1000"
       Rate4="500" Rate5="500" Rate6="0" ... Name="Level Option (Common)"/>

<!-- Higher luck chance -->
<Luck Index="0" Rate0="9000" Rate1="1000" Name="Luck Option (Common)"/>
```

{% endtab %}

{% tab title="Hardcore Server" %}
Make items rarer for challenging gameplay:

```xml
<!-- Almost all drops are +0 -->
<Level Index="0" Rate0="9500" Rate1="400" Rate2="100" Rate3="0"
       Rate4="0" ... Name="Level Option (Common)"/>

<!-- Very rare luck -->
<Luck Index="0" Rate0="9900" Rate1="100" Name="Luck Option (Common)"/>
```

{% endtab %}

{% tab title="Event Rewards" %}
Create custom event reward tiers:

```xml
<!-- Guaranteed +7 to +9 items -->
<Level Index="41" Rate0="0" Rate1="0" ... Rate7="3334" Rate8="3333"
       Rate9="3333" ... Name="Level Option (EventItemBag) (7~9)"/>

<!-- Always 2-3 excellent options -->
<Exc Index="20" Rate0="0" Rate1="0" Rate2="5000" Rate3="5000"
     Rate4="0" ... Name="Exc Option (EventItemBag) (2~3)"/>
```

{% endtab %}
{% endtabs %}

## Common Issues

{% hint style="warning" %}
**Rates Don't Add to 10000**: While rates work as relative weights even if they don't sum to 10000, inconsistent totals can make balance calculations confusing. Keep totals at 10000 for clarity.
{% endhint %}

{% hint style="warning" %}
**Wrong Index Used**: If items aren't dropping with expected options, verify you're using the correct Index for the item source (drops, mixes, events).
{% endhint %}

{% hint style="danger" %}
**All Rates Zero**: If all rates for an option type are 0, the item will receive option value 0. This can cause issues for socket items that expect at least 1 socket.
{% endhint %}
