# 380ItemOption

This configuration file defines the available option types for 380-level enhanced items and their default bonus values.

## File Location

```
GameServer/Data/Item/380ItemOption.xml
```

## Dependencies

| Depended On By  | Purpose                                           |
| --------------- | ------------------------------------------------- |
| 380ItemType.xml | References option indices and uses default values |

## How It Works

1. 380ItemType.xml references option indices from this file
2. When OptionValue is `*` (wildcard) in 380ItemType.xml, it's stored internally as `-1` and the server uses the default Value from this file
3. When 380 items are equipped, InsertOption applies bonuses to player stats (flag=false adds bonuses, flag=true removes them)
4. Most bonuses are PvP-specific (attack/defense rates in PvP combat)

## Structure

```xml
<Item380OptionList>
    <Option Index="1" Name="Add Attack Success Rate PvP" Value="10"/>
</Item380OptionList>
```

## Attributes

| Attribute | Type   | Description                            |
| --------- | ------ | -------------------------------------- |
| `Index`   | int    | Option index (1-8, see e380ItemOption) |
| `Name`    | string | Display name for the option            |
| `Value`   | int    | Default bonus value                    |

## Option Types (e380ItemOption)

| Index | Enum Name                                           | Effect                              | Typical Use |
| ----- | --------------------------------------------------- | ----------------------------------- | ----------- |
| 1     | ITEM\_380\_OPTION\_ADD\_ATTACK\_SUCCESS\_RATE\_PVP  | +value% attack success rate in PvP  | Weapons     |
| 2     | ITEM\_380\_OPTION\_ADD\_DAMAGE\_PVP                 | +value damage in PvP                | Weapons     |
| 3     | ITEM\_380\_OPTION\_ADD\_DEFENSE\_SUCCESS\_RATE\_PVP | +value% defense success rate in PvP | All armor   |
| 4     | ITEM\_380\_OPTION\_ADD\_DEFENSE\_PVP                | +value defense in PvP               | Pants       |
| 5     | ITEM\_380\_OPTION\_ADD\_MAX\_HP                     | +value maximum HP                   | Gloves      |
| 6     | ITEM\_380\_OPTION\_ADD\_MAX\_SD                     | +value maximum SD                   | Boots       |
| 7     | ITEM\_380\_OPTION\_SET\_SD\_RECOVERY\_TYPE          | Sets SD recovery mode               | Armor       |
| 8     | ITEM\_380\_OPTION\_ADD\_SD\_RECOVERY\_RATE          | +value SD recovery rate             | Helms       |

### Effect Details

| Index | Player Field Modified          | Notes                   |
| ----- | ------------------------------ | ----------------------- |
| 1     | `lpObj->AttackSuccessRatePvP`  | Only affects PvP        |
| 2     | `lpObj->DamagePvP`             | Only affects PvP        |
| 3     | `lpObj->DefenseSuccessRatePvP` | Only affects PvP        |
| 4     | `lpObj->DefensePvP`            | Only affects PvP        |
| 5     | `lpObj->AddLife`               | Affects all combat      |
| 6     | `lpObj->AddShield`             | Affects all combat      |
| 7     | `lpObj->SDRecoveryType`        | Sets mode, not additive |
| 8     | `lpObj->SDRecoveryRate`        | Affects all combat      |

## Examples

{% tabs %}
{% tab title="Correct Format" %}

```xml
<Item380OptionList>
    <Option Index="1" Name="Add Attack Success Rate PvP" Value="10"/>
    <Option Index="2" Name="Add Damage PvP" Value="15"/>
    <Option Index="3" Name="Add Defense Success Rate PvP" Value="10"/>
    <Option Index="4" Name="Add Defense PvP" Value="20"/>
    <Option Index="5" Name="Add Max HP" Value="100"/>
    <Option Index="6" Name="Add Max SD" Value="50"/>
    <Option Index="7" Name="Set SD Recovery Type" Value="1"/>
    <Option Index="8" Name="Add SD Recovery Rate" Value="5"/>
</Item380OptionList>
```

All Value attributes must be **integers**.
{% endtab %}

{% tab title="Balanced PvP Values" %}

```xml
<Item380OptionList>
    <!-- PvP combat bonuses -->
    <Option Index="1" Name="Add Attack Success Rate PvP" Value="5"/>
    <Option Index="2" Name="Add Damage PvP" Value="10"/>
    <Option Index="3" Name="Add Defense Success Rate PvP" Value="5"/>
    <Option Index="4" Name="Add Defense PvP" Value="10"/>

    <!-- Survivability bonuses -->
    <Option Index="5" Name="Add Max HP" Value="50"/>
    <Option Index="6" Name="Add Max SD" Value="25"/>
    <Option Index="7" Name="Set SD Recovery Type" Value="1"/>
    <Option Index="8" Name="Add SD Recovery Rate" Value="3"/>
</Item380OptionList>
```

{% endtab %}
{% endtabs %}

## Important Behavior

{% hint style="info" %}
**Default Values**: These values are used when 380ItemType.xml specifies `*` for OptionValue. The `*` wildcard is internally stored as `-1`, which triggers the server to use the default Value from this file. Specific numeric values in 380ItemType.xml override these defaults.
{% endhint %}

{% hint style="info" %}
**Index 0 Reserved**: ITEM\_380\_OPTION\_NONE (0) is used internally to indicate no option. Valid options start at index 1.
{% endhint %}

{% hint style="info" %}
**MAX\_380\_ITEM\_OPTION**: The server supports up to 10 option indices (0-9), but only indices 1-8 are defined in the enum.
{% endhint %}

{% hint style="info" %}
**Equipment State**: When a 380 item is equipped, bonuses are applied with `flag=false`. When unequipped, the same function is called with `flag=true` to prevent applying bonuses (effectively removing them from totals).
{% endhint %}

{% hint style="warning" %}
**SD Recovery Type (Index 7)**: This option SETS the recovery type rather than adding to it. The value determines the SD recovery behavior mode.
{% endhint %}

## Common Issues

{% hint style="warning" %}
**Missing Option Index**: If 380ItemType references an OptionIndex not defined here, GetInfo returns NULL and no bonus is applied.
{% endhint %}

{% hint style="warning" %}
**Value of 0**: A Value of 0 means the option provides no bonus even when equipped.
{% endhint %}

{% hint style="danger" %}
**Value Must Be Integer**: The source code uses `as_int()` to parse Value. Non-numeric strings will be parsed as 0, providing no bonus.
{% endhint %}
