# Reset System

The Reset System allows characters to reset their level in exchange for rewards, creating an extended progression system beyond the level cap.

## File Location

```
GameServer/Data/Plugins/ResetSystem.xml
```

## Reset Types

| Type         | Command                 | Purpose                              |
| ------------ | ----------------------- | ------------------------------------ |
| Reset        | `/reset`                | Standard level reset                 |
| Grand Reset  | `/grandreset` or `/gr`  | Meta-reset after accumulating resets |
| Master Reset | `/masterreset` or `/mr` | Master level reset                   |

## Configuration Structure

```xml
<ResetSystem Enabled="true">
    <Settings>
        <!-- What happens during reset -->
    </Settings>
    <ItemRequirements>
        <!-- Items consumed during reset -->
    </ItemRequirements>
    <Rewards>
        <!-- What players receive -->
    </Rewards>
    <Requirements>
        <!-- Conditions to perform reset -->
    </Requirements>
</ResetSystem>
```

## Sections

### Root Element

```xml
<ResetSystem Enabled="true">
```

| Attribute | Type | Default | Description                      |
| --------- | ---- | ------- | -------------------------------- |
| `Enabled` | bool | false   | Enable/disable the entire plugin |

### Settings

Defines what happens when a reset is performed.

```xml
<Setting Index="0" ResetStats="true" ResetCommand="true"
         ResetLevelUpPoints="true" TeleportToBaseMap="true" />
```

| Attribute            | Type | Default  | Description                                 |
| -------------------- | ---- | -------- | ------------------------------------------- |
| `Index`              | int  | Required | Unique identifier for this setting group    |
| `ResetStats`         | bool | true     | Reset STR/AGI/VIT/ENE/CMD to class defaults |
| `ResetCommand`       | bool | true     | Reset Command stat (for Dark Lord)          |
| `ResetLevelUpPoints` | bool | true     | Clear existing level-up points              |
| `ResetInventory`     | bool | false    | Clear inventory (except equipped)           |
| `ResetSkills`        | bool | false    | Clear learned skills                        |
| `ResetSkillTree`     | bool | false    | Clear master skill tree                     |
| `TeleportToBaseMap`  | bool | true     | Teleport to class starting location         |

{% hint style="danger" %}
**ResetInventory** is dangerous! Players will lose all non-equipped items. Use with extreme caution.
{% endhint %}

### ItemRequirements

Defines items that must be consumed for reset.

```xml
<ItemReq Index="0" ItemType="-1" Count="0" />
<ItemReq Index="1" ItemType="14" ItemIndex="13" Count="10" />
```

| Attribute    | Type | Default  | Description                           |
| ------------ | ---- | -------- | ------------------------------------- |
| `Index`      | int  | Required | Unique identifier                     |
| `ItemType`   | int  | -1       | Item category (-1 = no item required) |
| `ItemIndex`  | int  | -1       | Item index within category            |
| `ItemLevel`  | int  | -1       | Required item level (-1 = any)        |
| `LifeOption` | int  | -1       | Require life option (-1 = any)        |
| `Skill`      | int  | -1       | Require skill option (-1 = any)       |
| `Luck`       | int  | -1       | Require luck option (-1 = any)        |
| `Excellent`  | int  | -1       | Require excellent (-1 = any)          |
| `Durability` | int  | -1       | Required durability (-1 = any)        |
| `Count`      | int  | 0        | Number of items required              |

**Example**: `ItemType="14" ItemIndex="13"` = Jewel of Bless

### Rewards

Defines what players receive after reset.

```xml
<Reward Index="0" PointsType="LEVEL_POINTS_MULTI_RESET"
        LevelUpPoints="500" GrandResetBonusPoints="15000"
        WCoins="500" BagIndex="100" />
```

| Attribute                | Type | Default       | Description                   |
| ------------------------ | ---- | ------------- | ----------------------------- |
| `Index`                  | int  | Required      | Unique identifier             |
| `PointsType`             | enum | LEVEL\_POINTS | How points are calculated     |
| `LevelUpPoints`          | int  | 0             | Base points per reset         |
| `GrandResetBonusPoints`  | int  | 0             | Bonus points per grand reset  |
| `MasterResetBonusPoints` | int  | 0             | Bonus points per master reset |
| `WCoins`                 | int  | 0             | WCoins awarded                |
| `WPCoins`                | int  | 0             | WPCoins awarded               |
| `GoblinPoints`           | int  | 0             | Goblin Points awarded         |
| `BagIndex`               | int  | -1            | Item bag to drop (-1 = none)  |

#### PointsType Values

| Value                            | Formula               | Use Case                  |
| -------------------------------- | --------------------- | ------------------------- |
| `LEVEL_POINTS`                   | Fixed points          | Same points every reset   |
| `LEVEL_POINTS_MULTI_RESET`       | Points × Reset#       | Scaling with resets       |
| `LEVEL_POINTS_MULTI_GRAND_RESET` | Points × GrandReset#  | Scaling with grand resets |
| `MASTER_LEVEL_POINTS`            | Fixed master points   | Master reset rewards      |
| `MASTER_LEVEL_POINTS_MULTI`      | Points × MasterReset# | Scaling master rewards    |

**Example Calculations:**

**Regular Reset:**

* Settings: `PointsType="LEVEL_POINTS_MULTI_RESET"`, `LevelUpPoints="500"`, `GrandResetBonusPoints="15000"`
* Player performing their **10th regular reset** (going from 9→10) with 2 existing Grand Resets:
  * Base points: 500 × 10 = 5,000
  * Grand Reset bonus: 15000 × 2 = 30,000
  * **Total: 35,000 points**

**Grand Reset:**

* Settings: `PointsType="LEVEL_POINTS_MULTI_GRAND_RESET"`, `LevelUpPoints="15000"`
* Player performing their **2nd Grand Reset** (going from 1→2) with 100 regular resets:
  * Base points: 15000 × 2 = 30,000
  * Grand Reset bonus: 0 (not applied to Grand Reset type)
  * **Total: 30,000 points**
  * Note: Regular reset count is zeroed AFTER the rewards are calculated

### Requirements

Defines conditions and costs for performing resets.

```xml
<Requirement Index="0" Type="RESET" AccountLevel="*"
             SettingsIndex="0" RequiredLevel="400"
             ResetRange="000-999" ZenType="REMOVE_MULTI" ZenValue="100000"
             ItemReqIndex="1" RewardIndex="0" />
```

| Attribute                 | Type   | Default    | Description                                |
| ------------------------- | ------ | ---------- | ------------------------------------------ |
| `Index`                   | int    | Required   | Unique identifier                          |
| `Type`                    | enum   | RESET      | RESET, GRAND\_RESET, or MASTER\_RESET      |
| `AccountLevel`            | string | `*`        | Account level filter (\*, AL0-AL3)         |
| `SettingsIndex`           | int    | 0          | Which Settings to apply                    |
| `RequiredLevel`           | int    | 1          | Level needed for reset                     |
| `RequiredResets`          | int    | 0          | Resets needed (for grand reset)            |
| `RequiredMasterLevel`     | int    | 0          | Master level needed                        |
| `RequiredGrandResets`     | int    | 0          | Grand resets needed (gate requirement)     |
| `RequiredMasterResets`    | int    | 0          | Master resets needed (gate requirement)    |
| `ResetRange`              | string | 000-999    | Valid reset count range                    |
| `ZenType`                 | enum   | NO\_REMOVE | How zen is consumed                        |
| `ZenValue`                | int    | 0          | Base zen cost                              |
| `WCoins`                  | int    | 0          | WCoins cost                                |
| `WPCoins`                 | int    | 0          | WPCoins cost                               |
| `GoblinPoints`            | int    | 0          | GoblinPoints cost                          |
| `ItemReqIndex`            | string | -          | Item requirement indices (comma-separated) |
| `RewardIndex`             | string | -          | Reward indices (comma-separated)           |
| `ResetResetsOnGrandReset` | bool   | false      | Zero reset count on grand reset            |

#### ZenType Values

| Value          | Behavior              | Example                                                       |
| -------------- | --------------------- | ------------------------------------------------------------- |
| `NO_REMOVE`    | No zen cost           | Free reset                                                    |
| `REMOVE_FLAT`  | Fixed cost            | Always 1,000,000 zen                                          |
| `REMOVE_MULTI` | Cost × (Current# + 1) | Player with 9 resets doing 10th: 100,000 × 10 = 1,000,000 zen |

{% hint style="info" %}
**REMOVE\_MULTI calculation**: Uses the NEW reset number (current + 1) for cost. A player with 9 resets performing their 10th reset will pay `ZenValue × 10`.
{% endhint %}

#### ResetRange

Format: `MIN-MAX`

Limits which reset counts this requirement applies to:

* `000-099` - Applies to resets 0-99
* `100-999` - Applies to resets 100+

## Important Behavior

{% hint style="info" %}
**Best-Match Algorithm**: When multiple requirements could match a player, the plugin picks the most specific one using a scoring system:

1. Specific AccountLevel over wildcard (`*`) → +1000 points
2. Higher RequiredGrandResets → +100 points per grand reset requirement
3. Narrower ResetRange → More points for smaller ranges (calculated as 1000 - range\_size)

Note: `RequiredGrandResets` and `RequiredMasterResets` also act as gate requirements (must be met to qualify), but only `RequiredGrandResets` affects scoring.
{% endhint %}

{% hint style="info" %}
**Points Calculation Timing**: Points are calculated based on the NEW reset count (after incrementing). For example:

* **Regular Reset**: If player has 9 resets and performs their 10th, points are calculated as `LevelUpPoints × 10`
* **Grand Reset**: The reset count is zeroed AFTER calculation, so the final reset count before zeroing is used for `LEVEL_POINTS_MULTI_RESET`
* **Persistent Bonuses**: `GrandResetBonusPoints` and `MasterResetBonusPoints` are ONLY applied to regular resets (Type="RESET"), not to grand or master resets. They use the current (not incremented) grand/master reset counts.
  {% endhint %}

## Examples

{% tabs %}
{% tab title="Standard Server" %}

```xml
<ResetSystem Enabled="true">
    <Settings>
        <Setting Index="0" ResetStats="true" ResetCommand="true"
                 ResetLevelUpPoints="true" TeleportToBaseMap="true" />
    </Settings>
    <ItemRequirements>
        <ItemReq Index="0" ItemType="-1" Count="0" />
    </ItemRequirements>
    <Rewards>
        <Reward Index="0" PointsType="LEVEL_POINTS_MULTI_RESET"
                LevelUpPoints="500" WCoins="100" />
    </Rewards>
    <Requirements>
        <Requirement Index="0" Type="RESET" AccountLevel="*"
                     SettingsIndex="0" RequiredLevel="400"
                     ResetRange="000-999" ZenType="REMOVE_MULTI"
                     ZenValue="100000" RewardIndex="0" />
    </Requirements>
</ResetSystem>
```

{% endtab %}

{% tab title="With Grand Reset" %}

```xml
<ResetSystem Enabled="true">
    <Settings>
        <Setting Index="0" ResetStats="true" TeleportToBaseMap="true" />
    </Settings>
    <ItemRequirements>
        <ItemReq Index="0" ItemType="-1" Count="0" />
        <ItemReq Index="1" ItemType="14" ItemIndex="13" Count="10" />
    </ItemRequirements>
    <Rewards>
        <Reward Index="0" PointsType="LEVEL_POINTS_MULTI_RESET"
                LevelUpPoints="500" GrandResetBonusPoints="15000" />
        <Reward Index="1" PointsType="LEVEL_POINTS_MULTI_GRAND_RESET"
                LevelUpPoints="15000" WCoins="500" BagIndex="101" />
    </Rewards>
    <Requirements>
        <!-- Regular Reset -->
        <Requirement Index="0" Type="RESET" SettingsIndex="0"
                     RequiredLevel="400" ResetRange="000-999"
                     ZenType="REMOVE_MULTI" ZenValue="100000"
                     ItemReqIndex="1" RewardIndex="0" />
        <!-- Grand Reset at 100 resets -->
        <Requirement Index="10" Type="GRAND_RESET" SettingsIndex="0"
                     RequiredResets="100" ResetResetsOnGrandReset="true"
                     ZenType="NO_REMOVE" RewardIndex="1" />
    </Requirements>
</ResetSystem>
```

{% endtab %}

{% tab title="VIP Tiers" %}

```xml
<Requirements>
    <!-- Free players: harder requirements -->
    <Requirement Index="0" Type="RESET" AccountLevel="AL0"
                 RequiredLevel="400" ZenType="REMOVE_MULTI"
                 ZenValue="200000" RewardIndex="0" />

    <!-- VIP players: easier requirements -->
    <Requirement Index="1" Type="RESET" AccountLevel="AL1"
                 RequiredLevel="350" ZenType="REMOVE_MULTI"
                 ZenValue="100000" RewardIndex="1" />
</Requirements>
```

{% endtab %}
{% endtabs %}

## Common Issues

{% hint style="warning" %}
**Points Not Scaling**: Verify `PointsType` is set to a MULTI variant if you want points to increase with resets.
{% endhint %}

{% hint style="warning" %}
**Grand Reset Not Zeroing Resets**: Set `ResetResetsOnGrandReset="true"` on the grand reset requirement.
{% endhint %}

{% hint style="danger" %}
**No Matching Requirement**: If the player's current state doesn't match any Requirement entry, reset will fail. Check `ResetRange` and `AccountLevel` filters.
{% endhint %}

## Chat Commands

| Command                 | Action                |
| ----------------------- | --------------------- |
| `/reset`                | Perform regular reset |
| `/grandreset` or `/gr`  | Perform grand reset   |
| `/masterreset` or `/mr` | Perform master reset  |
