cfgrandompresets.xml
Configures random loot generation patterns and presets. Useful for creating varied and dynamic loot experiences with randomized item selections.
Overview
The cfgrandompresets.xml file defines named presets of items that can be randomly selected by cfgspawnabletypes.xml. Instead of listing every possible attachment or cargo item directly, you create a preset and reference it by name.
This keeps your spawnable types configuration clean and allows you to reuse the same item pools across multiple weapons or containers.
XML Structure
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<randompresets>
<cargo chance="0.50" name="foodVillage">
<item name="Apple" chance="0.30" />
<item name="Pear" chance="0.30" />
<item name="Can_Beans" chance="0.20" />
<item name="Can_Sardines" chance="0.20" />
</cargo>
<attachments chance="1.00" name="rifleOptics">
<item name="ACOGOptic" chance="0.20" />
<item name="M68Optic" chance="0.40" />
<item name="ReflexOptic" chance="0.40" />
</attachments>
</randompresets>
Preset Types
There are two types of presets:
| Type | Used For | Description |
|---|---|---|
| <cargo> | Items inside containers | Defines items that spawn inside the inventory of a container, backpack, or clothing item |
| <attachments> | Weapon/item attachments | Defines attachments that spawn already attached to a weapon or item |
Chance System
Chances are defined at two levels:
- Preset chance — The probability that this preset is used at all (on the
<cargo>or<attachments>element). A value of1.00means always used. - Item chance — The relative weight of each item within the preset. These are relative to each other, not absolute percentages.
<!-- 70% chance this preset activates; when it does, equal chance for each item -->
<cargo chance="0.70" name="medicalSupplies">
<item name="BandageDressing" chance="0.30" />
<item name="Morphine" chance="0.10" />
<item name="SalineBagIV" chance="0.15" />
<item name="Epinephrine" chance="0.10" />
<item name="PainkillerTablets" chance="0.35" />
</cargo>
Cargo Preset Examples
Cargo presets define items that spawn inside containers:
<!-- Ammo that spawns inside military clothing -->
<cargo chance="0.40" name="ammoMilitary">
<item name="Ammo_556x45" chance="0.25" />
<item name="Ammo_762x39" chance="0.30" />
<item name="Ammo_308Win" chance="0.15" />
<item name="Ammo_9x19" chance="0.30" />
</cargo>
<!-- Tools found in industrial backpacks -->
<cargo chance="0.60" name="toolsIndustrial">
<item name="Pliers" chance="0.30" />
<item name="Screwdriver" chance="0.30" />
<item name="Wrench" chance="0.20" />
<item name="Hacksaw" chance="0.20" />
</cargo>
Attachment Preset Examples
Attachment presets define items that spawn already attached to weapons:
<!-- Optics for assault rifles -->
<attachments chance="0.30" name="opticAR">
<item name="ACOGOptic" chance="0.15" />
<item name="M68Optic" chance="0.35" />
<item name="ReflexOptic" chance="0.50" />
</attachments>
<!-- Suppressors -->
<attachments chance="0.10" name="suppressorEast">
<item name="AKSuppressor" chance="0.60" />
<item name="NormSuppressor" chance="0.40" />
</attachments>
<!-- Buttstocks for AK platform -->
<attachments chance="0.50" name="buttstockAK">
<item name="AK_WoodBttstck" chance="0.40" />
<item name="AK_PlasticBttstck" chance="0.35" />
<item name="AK_FoldingBttstck" chance="0.25" />
</attachments>
How Presets Are Referenced
Presets are referenced by name in cfgspawnabletypes.xml:
<!-- In cfgspawnabletypes.xml -->
<type name="AKM">
<attachments preset="opticAR" />
<attachments preset="suppressorEast" />
<attachments preset="buttstockAK" />
</type>
Balancing Presets
Use small pools
Focused presets are easier to tune than one giant pool shared across every weapon or backpack.
Separate rarity tiers
Keep common attachments away from rare optics and suppressors unless the item should feel high-value.
Name by intent
Names like medicalLowTier or opticWesternRare make references easier to audit.
Check references
Unused presets add confusion. Renamed presets must also be updated in cfgspawnabletypes.xml.
Troubleshooting
| Problem | Check |
|---|---|
| Preset never appears | Confirm it is referenced by name in cfgspawnabletypes.xml and the preset chance is greater than zero. |
| Only one item appears too often | Review item chance weights and reduce overly dominant entries. |
| Server logs missing classnames | Remove stale items or install the mod that provides those classnames. |
| Generated XML is valid but feels wrong | Test several restart cycles and tune preset chance separately from item weights. |