# SetItemOption

This configuration file defines the bonuses granted by set items based on how many pieces of the set are equipped.

## File Location

```
GameServer/Data/Item/SetItemOption.xml
```

## Dependencies

| Depends On      | Purpose                             |
| --------------- | ----------------------------------- |
| SetItemType.xml | Maps items to set IDs (OptionIndex) |

## How It Works

1. Player equips set items
2. Server counts pieces matching each set ID
3. For N pieces, applies bonuses from PieceBonus1 through PieceBonus(N-1)
4. If all pieces equipped, also applies FullSetBonus

{% hint style="info" %}
**Piece Count Logic**: PieceBonus1 requires 2 pieces, PieceBonus2 requires 3 pieces, etc. The bonus number is one less than the piece count.
{% endhint %}

## Structure

```xml
<SetItemOptionList>
    <Set Index="1" Name="Warrior">
        <PieceBonus1 OptionIndex1="0" OptionValue1="10" OptionIndex2="-1" OptionValue2="-1"/>
        <PieceBonus2 OptionIndex1="19" OptionValue1="10" OptionIndex2="-1" OptionValue2="-1"/>
        <PieceBonus3 OptionIndex1="13" OptionValue1="20" OptionIndex2="-1" OptionValue2="-1"/>
        <PieceBonus4 OptionIndex1="14" OptionValue1="5" OptionIndex2="-1" OptionValue2="-1"/>
        <PieceBonus5 OptionIndex1="10" OptionValue1="20" OptionIndex2="-1" OptionValue2="-1"/>
        <PieceBonus6 OptionIndex1="1" OptionValue1="10" OptionIndex2="-1" OptionValue2="-1"/>
        <FullSetBonus OptionIndex1="15" OptionValue1="5" OptionIndex2="17" OptionValue2="5"
                      OptionIndex3="0" OptionValue3="25" OptionIndex4="-1" OptionValue4="-1"
                      OptionIndex5="-1" OptionValue5="-1"/>
    </Set>
</SetItemOptionList>
```

## Attributes

### Set Element

| Attribute | Type   | Description                                  |
| --------- | ------ | -------------------------------------------- |
| `Index`   | int    | Set ID (0-99, referenced by SetItemType.xml) |
| `Name`    | string | Set name (for display/logs)                  |

### PieceBonus1-6

| Attribute      | Type | Description                   |
| -------------- | ---- | ----------------------------- |
| `OptionIndex1` | int  | First bonus type (-1 = none)  |
| `OptionValue1` | int  | First bonus value             |
| `OptionIndex2` | int  | Second bonus type (-1 = none) |
| `OptionValue2` | int  | Second bonus value            |

### FullSetBonus

| Attribute        | Type | Description             |
| ---------------- | ---- | ----------------------- |
| `OptionIndex1-5` | int  | Bonus types (-1 = none) |
| `OptionValue1-5` | int  | Bonus values            |

## Option Types (eSetItemOption)

| Index | Name                              | Effect                                    |
| ----- | --------------------------------- | ----------------------------------------- |
| 0     | Add Strength                      | +value STR                                |
| 1     | Add Dexterity                     | +value AGI                                |
| 2     | Add Energy                        | +value ENE                                |
| 3     | Add Vitality                      | +value VIT                                |
| 4     | Add Leadership                    | +value CMD                                |
| 5     | Add Min Physical Damage           | +value min damage                         |
| 6     | Add Max Physical Damage           | +value max damage                         |
| 7     | Multiply Magic Damage             | +value% magic damage                      |
| 8     | Add Physical Damage               | +value min AND max damage                 |
| 9     | Multiply Attack Success Rate      | +value% attack rate                       |
| 10    | Add Defense                       | +value defense                            |
| 11    | Add Max Life                      | +value HP                                 |
| 12    | Add Max Mana                      | +value MP                                 |
| 13    | Add Max BP                        | +value AG (Stamina)                       |
| 14    | Add BP Recovery                   | +value AG recovery                        |
| 15    | Add Critical Damage Rate          | +value% critical rate                     |
| 16    | Add Critical Damage               | +value critical damage                    |
| 17    | Add Excellent Damage Rate         | +value% excellent rate                    |
| 18    | Add Excellent Damage              | +value excellent damage                   |
| 19    | Add Skill Damage                  | +value skill damage                       |
| 20    | Add Double Damage Rate            | +value% double damage rate                |
| 21    | Add Ignore Defense Rate           | +value% ignore defense                    |
| 22    | Multiply Shield Defense           | +value% defense (shield required)         |
| 23    | Multiply Two-Hand Physical Damage | +value% damage (two-hand weapon required) |

### Conditional Options (Division-Based)

| Index | Name                             | Effect                  |
| ----- | -------------------------------- | ----------------------- |
| 24    | Add Physical Damage by Strength  | +STR/value damage       |
| 25    | Add Physical Damage by Dexterity | +AGI/value damage       |
| 26    | Add Defense by Dexterity         | +AGI/value defense      |
| 27    | Add Defense by Vitality          | +VIT/value defense      |
| 28    | Add Magic Damage by Energy       | +ENE/value magic damage |

### Elemental Resistance

| Index | Name                     | Effect                      |
| ----- | ------------------------ | --------------------------- |
| 29    | Add Ice Resistance       | +value ice resistance       |
| 30    | Add Poison Resistance    | +value poison resistance    |
| 31    | Add Lightning Resistance | +value lightning resistance |
| 32    | Add Fire Resistance      | +value fire resistance      |
| 33    | Add Earth Resistance     | +value earth resistance     |
| 34    | Add Wind Resistance      | +value wind resistance      |
| 35    | Add Water Resistance     | +value water resistance     |

{% hint style="warning" %}
**Division Options (24-28)**: These divide your stat by the value. OptionValue=10 with 200 STR = +20 damage. Higher value = LESS bonus.
{% endhint %}

## Examples

{% tabs %}
{% tab title="Warrior Set" %}

```xml
<Set Index="1" Name="Warrior">
    <!-- 2 pieces: +10 STR -->
    <PieceBonus1 OptionIndex1="0" OptionValue1="10" OptionIndex2="-1" OptionValue2="-1"/>
    <!-- 3 pieces: +10 Skill Damage -->
    <PieceBonus2 OptionIndex1="19" OptionValue1="10" OptionIndex2="-1" OptionValue2="-1"/>
    <!-- 4 pieces: +20 Max AG -->
    <PieceBonus3 OptionIndex1="13" OptionValue1="20" OptionIndex2="-1" OptionValue2="-1"/>
    <!-- 5 pieces: +5 AG Recovery -->
    <PieceBonus4 OptionIndex1="14" OptionValue1="5" OptionIndex2="-1" OptionValue2="-1"/>
    <!-- 6 pieces: +20 Defense -->
    <PieceBonus5 OptionIndex1="10" OptionValue1="20" OptionIndex2="-1" OptionValue2="-1"/>
    <!-- 7 pieces: +10 AGI -->
    <PieceBonus6 OptionIndex1="1" OptionValue1="10" OptionIndex2="-1" OptionValue2="-1"/>
    <!-- Full set: +5% Crit Rate, +5% Exc Rate, +25 STR -->
    <FullSetBonus OptionIndex1="15" OptionValue1="5" OptionIndex2="17" OptionValue2="5"
                  OptionIndex3="0" OptionValue3="25" OptionIndex4="-1" OptionValue4="-1"
                  OptionIndex5="-1" OptionValue5="-1"/>
</Set>
```

{% endtab %}

{% tab title="Simple 2-Piece Set" %}

```xml
<Set Index="24" Name="Fase">
    <!-- 2 pieces: +100 HP -->
    <PieceBonus1 OptionIndex1="11" OptionValue1="100" OptionIndex2="-1" OptionValue2="-1"/>
    <!-- 3 pieces: +100 MP -->
    <PieceBonus2 OptionIndex1="12" OptionValue1="100" OptionIndex2="-1" OptionValue2="-1"/>
    <!-- No more piece bonuses -->
    <PieceBonus3 OptionIndex1="-1" OptionValue1="-1" OptionIndex2="-1" OptionValue2="-1"/>
    <PieceBonus4 OptionIndex1="-1" OptionValue1="-1" OptionIndex2="-1" OptionValue2="-1"/>
    <PieceBonus5 OptionIndex1="-1" OptionValue1="-1" OptionIndex2="-1" OptionValue2="-1"/>
    <PieceBonus6 OptionIndex1="-1" OptionValue1="-1" OptionIndex2="-1" OptionValue2="-1"/>
    <!-- Full set: +100 Defense -->
    <FullSetBonus OptionIndex1="10" OptionValue1="100" OptionIndex2="-1" OptionValue2="-1"
                  OptionIndex3="-1" OptionValue3="-1" OptionIndex4="-1" OptionValue4="-1"
                  OptionIndex5="-1" OptionValue5="-1"/>
</Set>
```

{% endtab %}

{% tab title="Conditional Bonus" %}

```xml
<Set Index="10" Name="Rave">
    <!-- 2 pieces: +20 Skill Damage -->
    <PieceBonus1 OptionIndex1="19" OptionValue1="20" OptionIndex2="-1" OptionValue2="-1"/>
    <!-- 3 pieces: +10% Double Damage Rate -->
    <PieceBonus2 OptionIndex1="20" OptionValue1="10" OptionIndex2="-1" OptionValue2="-1"/>
    <PieceBonus3 OptionIndex1="-1" OptionValue1="-1" OptionIndex2="-1" OptionValue2="-1"/>
    <PieceBonus4 OptionIndex1="-1" OptionValue1="-1" OptionIndex2="-1" OptionValue2="-1"/>
    <PieceBonus5 OptionIndex1="-1" OptionValue1="-1" OptionIndex2="-1" OptionValue2="-1"/>
    <PieceBonus6 OptionIndex1="-1" OptionValue1="-1" OptionIndex2="-1" OptionValue2="-1"/>
    <!-- Full set: +30% Two-Hand Damage, +5% Ignore Defense -->
    <FullSetBonus OptionIndex1="23" OptionValue1="30" OptionIndex2="21" OptionValue2="5"
                  OptionIndex3="-1" OptionValue3="-1" OptionIndex4="-1" OptionValue4="-1"
                  OptionIndex5="-1" OptionValue5="-1"/>
</Set>
```

Option 23 (Two-Hand Damage) only applies if player has a two-handed weapon equipped.
{% endtab %}
{% endtabs %}

## Important Behavior

{% hint style="info" %}
**Cumulative Bonuses**: All PieceBonus entries up to (piece\_count - 1) are applied cumulatively. With 4 pieces, you get PieceBonus1 + PieceBonus2 + PieceBonus3.
{% endhint %}

{% hint style="info" %}
**Full Set Detection**: Full set bonus triggers when equipped piece count equals the maximum option count for that set (based on how many PieceBonus entries have valid options).
{% endhint %}

{% hint style="warning" %}
**Shield/Two-Hand Requirements**: Options 22 (Shield Defense) and 23 (Two-Hand Damage) only apply if the player has the required equipment. Otherwise the bonus is silently ignored.
{% endhint %}

{% hint style="info" %}
**IsFullSetItem Flag**: When full set is equipped, `lpObj->IsFullSetItem` is set to 1. This can trigger other game effects.
{% endhint %}

## Common Issues

{% hint style="warning" %}
**Bonuses Not Stacking**: Remember piece bonuses are cumulative. If 4-piece bonus seems weak, check that you're accounting for 2+3+4 piece bonuses combined.
{% endhint %}

{% hint style="warning" %}
**OptionIndex -1**: Using -1 disables that bonus slot. All unused PieceBonus entries and FullSetBonus slots should use -1.
{% endhint %}

{% hint style="danger" %}
**Invalid Index**: Set Index must be 0-99 and match references in SetItemType.xml OptionIndex values.
{% endhint %}
