Skip to content
smartargs
VantageDocumentation

Threat reference

The threat table a monster keeps on its attackers, the component that fills it from damage and heals, and one row of the table. For how to use it, see Threat.

VtThreatTable

Component. Add it with Add Component → Vantage → Threat → VtThreatTable.

Per-defender threat ledger — the per-attacker (VtUnitId keyed) ledger that drives MMO-style target selection. Lives on the defender (the NPC being attacked), not on the attacker, so one entry per attacker, clean decay / pruning, and a single payload to replicate per NPC.

Inspector fields

Field Type Default Range Description
Decay Rate Per Second (decayRatePerSecond) float 0 ≥ 0 Threat decay rate, fraction per second. 0 = no decay (classic MMO; threat persists until combat ends or unit dies). 0.05 = -5%/s.
Prune After Seconds (pruneAfterSeconds) float 30 ≥ 1 Seconds since last update before a row is pruned. Stops the table growing unbounded over long fights with players entering / leaving range. Default 30s.

Scripting API

Member Description
IReadOnlyDictionary<VtUnitId, VtThreatEntry> Entries { get; } Read-only view of the live entries. Iterate for snapshot replication / UI. Order is unspecified.
VtUnitId TopAttacker { get; } The current top-threat attacker, or VtUnitId.None when empty.
float TopThreat { get; } Threat value of the current top entry, or 0 when empty.
event Action<VtUnitId> OnThreatChanged Fires when the top-threat attacker changes (top entry id swaps, or top becomes None when the table empties). Args: new top attacker id. Subscribers — typically VtCombatEngagement — re-target.
VtUnitId GetTopAttacker() Convenience alias of TopAttacker.
float GetThreat(VtUnitId attackerId) Threat value for the given attacker, 0 if no row.
bool HasThreat(VtUnitId attackerId) True when the attacker has a row in this table.
void AddThreat(VtUnitId attackerId, float amount) Add (or subtract, with negative amount) threat for an attacker. Authority-gated. Triggers OnThreatChanged only if the top swaps as a result.
void SetThreat(VtUnitId attackerId, float value) Force-set an attacker’s threat to an absolute value. Authority- gated. Used by VtTauntEffect + similar.
bool ClearThreat(VtUnitId attackerId) Drop a single attacker from the table (e.g. attacker died, left the zone, vanished). Authority-gated.
void Reset() Wipe the entire table — typically called when the owning unit drops out of combat or dies. Authority-gated. Fires OnThreatChanged with VtUnitId.None if it was non-empty.
void Tick(float deltaTime) Advance every row by deltaTime seconds: age it, apply decayRatePerSecond, then prune rows older than pruneAfterSeconds. Authority-only. The only time input this component consumes.
bool Prune() Drop rows whose VtThreatEntry.secondsSinceUpdate exceeds pruneAfterSeconds. Returns true if anything was removed. Runs on every tick; call it to prune right away.
void ApplyThreatTableFromNet(IReadOnlyList<VtThreatEntry> snapshot) Net-replication entry point: replace the table with the authoritative snapshot. Bypasses the authority gate. Fires OnThreatChanged when the top swaps.

VtThreatAutoSubscriber

Component. Add it with Add Component → Vantage → Threat → VtThreatAutoSubscriber.

Auto-wires the threat / aggro event hooks for a unit. Three behaviours, each independent — the MB activates whichever ones the unit’s siblings support.

Inspector fields

Field Type Default Description
Call For Help Ratio (callForHelpRatio) float -1 Per-instance override of VtThreatConstants.CallForHelpRatio. -1 = use the global default. 0 = suppress propagation entirely on this unit.
Heal Aggro Ratio (healAggroRatio) float -1 Per-instance override of VtThreatConstants.HealThreatRatio. -1 = use the global default. 0 = suppress heal-aggro broadcast on this unit.

Scripting API

Member Description
void Initialize() Caches sibling components and subscribes to VtUnitStats events. Idempotent — safe to call any number of times.

VtThreatEntry

Serializable struct.

One row in a VtThreatTable — the attacker, its accumulated threat and the seconds since the row last changed. Public so consumer net code can iterate the table for replication snapshots and UI (“you have aggro!” indicator).

Inspector fields

Field Type Default Description
Attacker Id (attackerId) VtUnitId — The unit this row tracks threat for.
Threat (threat) float 0 Accumulated threat. Never below 0; the highest row is the table’s top attacker.
Seconds Since Update (secondsSinceUpdate) float 0 Seconds since this row last gained or was set to threat. The row is removed once this passes the table’s Prune After Seconds.