# SetItemType

This configuration file defines which items can be set (ancient) items and maps them to their corresponding set bonuses in SetItemOption.xml.

## File Location

```
GameServer/Data/Item/SetItemType.xml
```

## Dependencies

| Depends On        | Purpose                              |
| ----------------- | ------------------------------------ |
| Item.xml          | Item definitions by Section/Type     |
| SetItemOption.xml | Set bonus definitions by OptionIndex |

| Depended On By     | Purpose                                        |
| ------------------ | ---------------------------------------------- |
| ItemOptionRate.xml | SetOptions section determines set tier on drop |

## How It Works

When a player equips items:

1. Server checks if item is a set item (bits 0-1 of `m_SetOption` must be 1 or 2)
2. Looks up item in SetItemType by Section/Type
3. Uses bits 0-1 to select OptionIndex: value 1 = OptionIndex1, value 2 = OptionIndex2
4. Counts matching set pieces across equipment for that OptionIndex
5. Applies bonuses from SetItemOption based on piece count

## Structure

```xml
<SetItemTypeList>
    <Item Section="7" Type="1" StatType="3"
          OptionIndex1="11" OptionIndex2="12"/>
</SetItemTypeList>
```

## Attributes

| Attribute      | Type | Description                                     |
| -------------- | ---- | ----------------------------------------------- |
| `Section`      | int  | Item category (0-13, see table below)           |
| `Type`         | int  | Item type index within category                 |
| `StatType`     | int  | Stat bonus type (see below)                     |
| `OptionIndex1` | int  | First set ID reference (from SetItemOption.xml) |
| `OptionIndex2` | int  | Second set ID reference (0 = none)              |

### StatType Values

| Value | Stat      | Effect                      |
| ----- | --------- | --------------------------- |
| 0     | None      | No stat bonus from set tier |
| 1     | Strength  | Adds STR based on stat tier |
| 2     | Dexterity | Adds AGI based on stat tier |
| 3     | Energy    | Adds ENE based on stat tier |

{% hint style="info" %}
**Stat Tier Multiplier**: The item's SetOption byte contains stat tier info in bits 2-3. The bonus is calculated as `((m_SetOption >> 2) & 3) * 5`. Valid stat tier values: 0 = +0 stat, 1 = +5 stat, 2 = +10 stat, 3 = +15 stat. This is independent of which set the item belongs to (bits 0-1).
{% endhint %}

### Item Index Calculation

```
ItemIndex = Section * 512 + Type
```

| Section | Category           |
| ------- | ------------------ |
| 0       | Swords             |
| 1       | Axes               |
| 2       | Maces              |
| 3       | Spears             |
| 4       | Bows               |
| 5       | Staffs             |
| 6       | Shields            |
| 7       | Helms              |
| 8       | Armor              |
| 9       | Pants/Gloves/Boots |
| 10      | Rings              |
| 11      | Amulets            |
| 12      | Wings              |
| 13      | Misc               |

## OptionIndex Reference

The OptionIndex values reference set definitions in [SetItemOption.xml](https://axiomemu.gitbook.io/docs/gameserver/item/setitemoption):

| OptionIndex | Set Name  | Typical Items                          |
| ----------- | --------- | -------------------------------------- |
| 1           | Warrior   | Morning Star, Leather set, Ring of Ice |
| 2           | Anonymous | Buckler                                |
| 3           | Hyperion  | Skull Staff                            |
| 4           | Mist      | Bronze set                             |
| 5           | Eplete    | Skull Shield, Bone set, Pendant of Ice |
| ...         | ...       | ...                                    |

{% hint style="info" %}
**Dual Set Membership**: Items with both OptionIndex1 and OptionIndex2 can contribute to TWO different sets simultaneously.
{% endhint %}

## Examples

{% tabs %}
{% tab title="Armor Piece" %}

```xml
<!-- Dragon Helm (Section 7, Type 1) belongs to Hyon set (11) and Vicious set (12) -->
<Item Section="7" Type="1" StatType="3" OptionIndex1="11" OptionIndex2="12"/>
```

* StatType=3: Gains +5 ENE per tier level
* Can contribute to either Hyon or Vicious set bonuses
  {% endtab %}

{% tab title="Weapon" %}

```xml
<!-- Blade (Section 0, Type 14) belongs to Hyon set -->
<Item Section="0" Type="14" StatType="0" OptionIndex1="11" OptionIndex2="0"/>
```

* StatType=0: No stat bonus from tier
* Only contributes to Hyon set (OptionIndex2=0)
  {% endtab %}

{% tab title="Accessory" %}

```xml
<!-- Ring of Ice (Section 13, Type 8) belongs to Warrior set -->
<Item Section="13" Type="8" StatType="1" OptionIndex1="1" OptionIndex2="0"/>
```

* StatType=1: Gains +5 STR per tier level
* Contributes to Warrior set
  {% endtab %}
  {% endtabs %}

## Important Behavior

{% hint style="info" %}
**Duplicate Prevention**: If two identical items are equipped in both weapon slots or both ring slots with the same OptionIndex, only one counts toward the set bonus.
{% endhint %}

{% hint style="info" %}
**SetOption Byte Structure**: The SetOption byte encodes two pieces of information:

* **Bits 0-1**: Which set (1 = OptionIndex1, 2 = OptionIndex2). Must be 1 or 2 for valid set items.
* **Bits 2-3**: Stat bonus tier (0-3). Multiplied by 5 to get the bonus: 0=+0, 1=+5, 2=+10, 3=+15.

This is determined when the item drops based on ItemOptionRate.xml SetOptions section.
{% endhint %}

{% hint style="warning" %}
**OptionIndex 0**: Using OptionIndex=0 means "no set contribution" for that slot. Don't confuse with set ID 0 which doesn't exist.
{% endhint %}

## Common Issues

{% hint style="warning" %}
**Item Not Recognized as Set**: Verify the item has SetOption set (from ItemOptionRate SetOptions). An item listed here but without SetOption on the actual item instance won't activate set bonuses.
{% endhint %}

{% hint style="danger" %}
**Wrong Section/Type**: Double-check your Section and Type values match Item.xml exactly. A mismatch means the item won't be found.
{% endhint %}
