> For the complete documentation index, see [llms.txt](https://oph3zdev.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://oph3zdev.gitbook.io/docs/paid-scripts/inventory/configuration/rarity.md).

# Rarity

Everything in <mark style="color:$primary;">config/rarity.lua</mark>. Rarity gives items a tier with its own colour that shows on tiles and tooltips. Tiers come from crafting rolls, trash finds, shop metadata or an item's own definition, and they can change wear speed and shop prices.

### Master settings

* `enabled` - master switch, `false` = no colours, no rolls, no rarity anywhere.
* `default` - the tier used when an item has no rarity of its own.
* `degradeByRarity` - `true` = higher tiers lose durability slower.

```lua
Config.Rarity = {
    enabled = true,
    default = "common",
    degradeByRarity = true,
    tiers = { ... },
    craft = { perfectBump = 100 }
}
```

### Tiers

The tier list, ordered low to high. Add, remove or rename tiers freely - `id` is what gets stored on items.

* `label` + `color` - what players see.
* `degrade` - durability loss multiplier when `degradeByRarity` is on, lower = slower wear.
* `priceMultiplier` - used by shops that set `rarityPricing = true`.

```lua
tiers = {
    { id = "common", label = "Common", color = "#9aa3ab", degrade = 1.0, priceMultiplier = 1.0 },
    { id = "uncommon", label = "Uncommon", color = "#5fd07a", degrade = 0.9, priceMultiplier = 1.5 },
    { id = "rare", label = "Rare", color = "#4aa3ff", degrade = 0.75, priceMultiplier = 2.5 },
    { id = "epic", label = "Epic", color = "#b06cf0", degrade = 0.6, priceMultiplier = 5.0 },
    { id = "legendary", label = "Legendary", color = "#f0a33c", degrade = 0.45, priceMultiplier = 10.0 }
}
```

### Crafting

The percent chance that a perfect minigame result bumps the crafted item one tier up.

```lua
craft = {
    perfectBump = 100
}
```

### Where tiers come from

* **Items** - an item in <mark style="color:$primary;">items.lua</mark> can carry a fixed rarity.
* **Crafting** - a recipe rolls its `rarity` list per crafted item, and skill tree nodes with the `rarity` effect improve the roll.
* **Trash searching** - loot entries roll their own `rarity` lists.
* **Shops** - a shop item can stamp a tier through its `metadata`.
* **Spoilage** - with `rarityShelfLife` on in <mark style="color:$primary;">config/config.lua</mark>, rarer crafted items stay fresh longer.
