Skip to content
smartargs
VantageDocumentation

Loot reference

The loot dropper component, the loot table asset and its rows, the rolled drops, and the roller and random source you can call or replace. For how to use it, see Loot.

VtLootDropper

Component. Add it with Add Component → Vantage → Loot → VtLootDropper.

Rolls the unit’s VtLootTableDefinition when it dies and spawns the drops as VtWorldItem pickups around the corpse; currency drops go straight to the killer’s wallet. VtUnit adds it when the unit definition has a loot table, or add it yourself.

Inspector fields

Field Type Default Range Description
Table (table) VtLootTableDefinition None Loot table rolled when this unit dies. When the unit definition has a Loot Table, that table replaces this one as the unit spawns. Empty = no drops.
World Item Prefab (worldItemPrefab) GameObject None Optional override of VtLootTableDefinition.defaultWorldItemPrefab. Use when this specific unit should drop a different visual (boss loot bag prefab, themed corpse marker). If null, the dropper falls back to the table’s default.
Scatter Radius (scatterRadius) float 0.5 ≥ 0 XZ-plane scatter radius around the corpse position. Each drop spawns at corpse + random-disc-offset(radius). 0 = stack every drop on the corpse origin (bad for multi-drop kills — they pile into one cluster). Default 0.5 looks natural for typical mob sizes.

Scripting API

Member Description
event Action<IList<VtLootDrop>> OnRolled Fires after the table is rolled, before any VtWorldItem is instantiated. Subscribers can inspect or mutate the list (party-loot rules, instance loot, ironman runs that suppress drops, custom replication snapshotting). The list passed in is the actual buffer used for spawning — clearing it suppresses every drop; adding to it spawns extra drops.
void Initialize() Caches the sibling VtUnitStats reference and subscribes to VtUnitStats.OnDied. Idempotent — safe to call any number of times.
void SetTable(VtLootTableDefinition newTable) Swap the active loot table at runtime, such as for escalating elite mobs or world-state-driven drops. Null clears.
void SetRandom(IVtRandom newRng) Override the random source used for rolls and scatter, such as a fixed-seed stream for replays. Passing null reverts to VtUnityRandom.Instance.

VtLootTableDefinition

Asset. Create it with Create → Vantage → Loot → Loot Table.

Authored loot table — the weighted pool of VtLootDropEntry rows that VtLootDropper rolls on a unit’s death. SO-driven so designers can tune drops in the inspector without touching code.

Inspector fields

General

Field Type Default Range Description
Id (id) string Empty Stable id used in logs and as a stable serialization key. Convention: ‘loot.’ (e.g. ‘loot.basicmob’, ‘loot.boss.necromancer’). Required.
Display Name (displayName) string Empty Designer-facing name. Shown in inspector dropdowns.
Description (description) string Empty Designer-facing description. Doesn’t affect runtime behavior.

Drops

Field Type Default Range Description
Guaranteed Drops (guaranteedDrops) VtLootDropEntry[] Empty Drops that ALWAYS emit on every roll, with no weighted competition. Boss tokens, quest items, scripted always-drop currency stacks. The count range still rolls per drop (so a ‘guaranteed 1-3 potions’ entry uses minCount=1, maxCount=3). Leave empty for trash mobs that only roll the weighted pool.
Entries (entries) VtLootDropEntry[] Empty Weighted pool the table picks from on each roll. Null-item entries are ‘no drop’ weight buckets — when the pick lands on one, the roll is consumed without emitting anything. Use this to tune overall drop chance without inflating per-item weights.
Currency Drops (currencyDrops) VtCurrencyDropEntry[] Empty Currency drops — credited directly to the killer’s VtUnitWallet on death (NOT spawned as world items); a killer in a party splits it with the members in share range. Always emit on every kill (no weighting); amount rolls in [minAmount, maxAmount]. Killers without a wallet (most NPCs killing each other) silently lose the drop. Environment kills (no killer) lose currency drops entirely — items still roll normally.
Rolls (rolls) int 1 ≥ 1 How many independent picks against the weighted pool happen per death. Each roll is independent — the same entry can win multiple times. Default 1; raise for boss / chest tables that should drop multiple items.

Spawn

Field Type Default Range Description
Default World Item Prefab (defaultWorldItemPrefab) GameObject None Default prefab the dropper instantiates per drop. Must contain a VtWorldItem component (the dropper sets its item + count after spawning). Per-mob overrides live on VtLootDropper.worldItemPrefab — useful for boss-specific loot bag visuals. If both this AND the override are null, drops silently no-op with a one-time warning.

VtLootDropEntry

Serializable struct.

One row in a VtLootTableDefinition. Pairs an item with a weight (used for the random pick) and a count range (rolled once per successful pick).

Inspector fields

Field Type Default Range Description
Item (item) VtItemDefinition None Item to drop when this entry wins the weighted pick. Null = “no drop” weight bucket — the roll is consumed but no item is emitted. Use this to tune drop chances without inflating individual item weights (e.g. 10% drop chance = [item w=1, null w=9]).
Weight (weight) int 0 ≥ 0 Relative weight in the weighted random pick. Higher = more likely. 0 = entry is skipped entirely (treat as ‘disabled’). Weights don’t need to sum to any particular total.
Min Count (minCount) int 0 ≥ 1 Minimum count emitted when this entry wins. Inclusive. Stackable items merge into one inventory entry on pickup.
Max Count (maxCount) int 0 ≥ 1 Maximum count emitted when this entry wins. Inclusive. Equal to minCount = always emits exactly that many.

VtLootDrop

Serializable struct.

One resolved drop coming out of VtLootRoller.RollDrops — the (item, count, position) triple VtLootDropper hands to Instantiate when spawning a VtWorldItem.

Inspector fields

Field Type Default Description
Item (Item) VtItemDefinition None Item that won the weighted pick or came from a guaranteed drop. Never empty.
Count (Count) int 0 How many of the item drop together.
Position (Position) Vector3 (0, 0, 0) World position the drop spawns at, scatter offset included.

IVtRandom

Interface. Implemented by VtUnityRandom.

The random source loot rolls use. Implement it for a fixed-seed or network-replicated stream and pass it to VtLootDropper.SetRandom or VtLootRoller.RollDrops; the default wraps UnityEngine.Random.

Scripting API

Member Description
float Value { get; } Uniform float in [0, 1). Mirrors UnityEngine.Random.value.
int Range(int minInclusive, int maxExclusive) Integer from minInclusive up to, but not including, maxExclusive. Mirrors UnityEngine.Random.Range(int, int).

VtUnityRandom

Class.

The default IVtRandom: forwards every call to UnityEngine.Random. VtLootDropper uses it unless you set another source.

Scripting API

Member Description
float Value { get; } Uniform float from 0 up to 1, from UnityEngine.Random.value.
static readonly VtUnityRandom Instance Singleton instance — stateless wrapper, no need to allocate per roll.
int Range(int minInclusive, int maxExclusive) Integer from minInclusive up to, but not including, maxExclusive, from UnityEngine.Random.Range.

VtLootRoller

Static class.

Rolls a VtLootTableDefinition into the list of VtLootDrops it produces at an origin, without spawning anything. Call it to roll a chest, preview a table, or build a dropper of your own; randomness comes from the IVtRandom you pass.

Scripting API

Member Description
static List<VtLootDrop> RollDrops(VtLootTableDefinition table, Vector3 origin, float scatterRadius, IVtRandom rng) Roll the table at origin using rng for picks and scatter offsets.