# ItemValue

This configuration file defines custom prices for items, including support for alternative currencies (WCoinC, WCoinP, GoblinPoints).

## File Location

```
GameServer/Data/Item/ItemValue.xml
```

## Dependencies

| Depends On | Purpose                             |
| ---------- | ----------------------------------- |
| Item.xml   | Item definitions and default prices |

## How It Works

1. When item is bought/sold, server checks ItemValue for custom pricing
2. If item is found, uses Value and currency toggles from config
3. If not found, uses default calculated price from Item.xml attributes

## Structure

```xml
<Item Index="7181" Level="*" Grade="*" Value="90000000"
      WCoinC="0" WCoinP="0" GoblinPoint="0" Sell="100"
      Name="Jewel of Bless"/>
```

## Attributes

| Attribute     | Type   | Description                                   |
| ------------- | ------ | --------------------------------------------- |
| `Index`       | int    | Item index (Category \* 512 + Type)           |
| `Level`       | string | `*` for any level, or 0-15 for specific level |
| `Grade`       | string | `*` for any grade, or excellent option value  |
| `Value`       | int    | Buy price                                     |
| `WCoinC`      | int    | 1 = use WCoinC, 0 = don't use                 |
| `WCoinP`      | int    | 1 = use WCoinP, 0 = don't use                 |
| `GoblinPoint` | int    | 1 = use GoblinPoints, 0 = don't use           |
| `Sell`        | int    | Sell price (0 = Value / 3)                    |
| `Name`        | string | Item name (optional, for reference)           |

### Currency Priority

When multiple currency toggles are set to 1:

```
GoblinPoint > WCoinP > WCoinC > Zen
```

If all toggles are 0, price is in Zen.

## Examples

{% tabs %}
{% tab title="Zen Price" %}

```xml
<!-- Jewel of Bless: Buy 90M Zen, Sell 100 Zen -->
<Item Index="7181" Level="*" Grade="*" Value="90000000"
      WCoinC="0" WCoinP="0" GoblinPoint="0" Sell="100"
      Name="Jewel of Bless"/>
```

All currency toggles = 0 means Zen is used.
{% endtab %}

{% tab title="WCoin Price" %}

```xml
<!-- Buy with WCoinC -->
<Item Index="26" Level="0" Grade="*" Value="30"
      WCoinC="1" WCoinP="0" GoblinPoint="0" Sell="7"
      Name="Sword"/>

<!-- Buy with WCoinP -->
<Item Index="6693" Level="*" Grade="*" Value="50"
      WCoinC="0" WCoinP="1" GoblinPoint="0" Sell="0"
      Name="Horn of Fenrir"/>
```

{% endtab %}

{% tab title="GoblinPoint Price" %}

```xml
<!-- Buy with GoblinPoints -->
<Item Index="7168" Level="0" Grade="*" Value="12"
      WCoinC="0" WCoinP="0" GoblinPoint="1" Sell="6"
      Name="Sword"/>
```

{% endtab %}

{% tab title="Level-Specific Pricing" %}

```xml
<!-- Different prices per item level -->
<Item Index="2055" Level="0" Grade="*" Value="100" ... Name="Bolt"/>
<Item Index="2055" Level="1" Grade="*" Value="1400" ... Name="Bolt"/>
<Item Index="2055" Level="2" Grade="*" Value="2200" ... Name="Bolt"/>
<Item Index="2055" Level="3" Grade="*" Value="3000" ... Name="Bolt"/>
```

Higher level = higher price.
{% endtab %}

{% tab title="Grade-Specific Pricing" %}

```xml
<!-- Different prices for excellent options -->
<Item Index="6659" Level="*" Grade="0" Value="960000" ... Name="Horn of Dinorant"/>
<Item Index="6659" Level="*" Grade="1" Value="1260000" ... Name="Horn of Dinorant"/>
<Item Index="6659" Level="*" Grade="3" Value="1560000" ... Name="Horn of Dinorant"/>
```

Grade = NewOption (excellent) value. Higher grade = more valuable.
{% endtab %}
{% endtabs %}

## Important Behavior

{% hint style="info" %}
**Default Sell Price**: If Sell="0", the sell price is automatically calculated as Value / 3.
{% endhint %}

{% hint style="info" %}
**Match Priority**: The server tries matches in this order:

1. Exact Level + Exact Grade match
2. Exact Level + Wildcard Grade (`*`)
3. Wildcard Level + Exact Grade
4. Both Wildcards (final fallback)

The first matching entry is used.
{% endhint %}

{% hint style="info" %}
**Unlisted Items**: Items not in this file use their default calculated prices from Item.xml Money attribute.
{% endhint %}

{% hint style="warning" %}
**Currency Toggle Priority**: If multiple toggles are set to 1, only the highest priority currency is used. Don't set multiple toggles unless intentional.
{% endhint %}

## Common Issues

{% hint style="warning" %}
**Wrong Price Applied**: Check Level and Grade matching. Use `*` wildcards to match all values of that attribute.
{% endhint %}

{% hint style="warning" %}
**Currency Not Working**: Verify the currency system is enabled in ServerInfo.xml. Check that only one currency toggle is set to 1.
{% endhint %}

{% hint style="danger" %}
**Index Calculation**: Ensure Index = Category \* 512 + Type matches the item in Item.xml.
{% endhint %}
