Shadowparasitemanager
Based on game build 714014 | Last updated: 2026-03-03
Overview
ShadowParasitemanager orchestrates the Shadow Thrall boss encounter in DST. It tracks active players, manages parasite wave spawning (via hosted creatures like Rocky, Bunnyman, or spiders), coordinates floating parasitefx spawns during rift events, and handles player rejoining/leaving logic. It is instantiated only on the master simulation and interacts closely with the riftspawner, combat, inventory, spawnfader, skinner, and follower components.
Usage example
local inst = CreateEntity()
inst:AddComponent("shadowparasitemanager")
-- When rifts spawn, this component is triggered automatically via "ms_riftaddedtopool".
-- It responds to player joins/leaves and spawns waves as needed.
Dependencies & tags
Components used: combat, follower, herdmember, inventory, riftspawner, skinner, spawnfader
Tags: Checks shadowthrall_parasite_mask; adds NOCLICK to floaters.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
_activeplayers | table | {} | Map of active player entities → true |
_targetplayers | table | {} | Map of players → true who should trigger waves |
_targetuserids | table | {} | Map of userids → true for players who left while targeted |
_parasites | table | {} | Map of parasite entities → true currently tracked |
_floaters | table | {} | Map of floating parasitefx entities → true |
num_waves | number | 0 | Count of pending parasite waves |
_WEIGHTED_HOSTS_TABLE | table | WEIGHTED_HOSTS_TABLE | Mod-accessible map of host prefabs to spawn weights |
_HOST_CAN_SPAWN_TEST | table | HOST_CAN_SPAWN_TEST | Mod-accessible map of host prefabs to condition functions |
Main functions
ApplyWorldSettings()
- Description: Removes disabled host creatures from
_WEIGHTED_HOSTS_TABLEbased on world settings (e.g.,TUNING.ROCKYHERD_SPAWNER_DENSITY). - Parameters: None.
- Returns: Nothing.
- Error states: None.
OnPlayerJoined(player)
- Description: Registers a new player and immediately spawns a parasite wave for them if they were previously targeted.
- Parameters:
player(entity) – the joining player entity. - Returns: Nothing.
- Error states: Returns early if player is already tracked.
OnPlayerLeft(player)
- Description: Removes a player from
_activeplayersand marks them as a target (or stores their userid) if a wave was pending. - Parameters:
player(entity) – the leaving player entity. - Returns: Nothing.
- Error states: Returns early if player is not tracked.
AddParasiteToHost(host)
- Description: Equips a
shadow_thrall_parasitehatitem on the given host entity. - Parameters:
host(entity) – the host creature to infect. - Returns:
host,mask(both entities) – mask returned for modder use. - Error states: None.
SpawnParasiteWaveForPlayer(player, joining)
- Description: Spawns 5–7 parasite-host creatures near the player, assigns them combat target.
- Parameters:
player(entity) – the target player.joining(boolean) – if true, delays target suggestion byJOIN_TARGET_DELAY.
- Returns: Nothing.
- Error states: Returns early if no shadow rift exists.
GetShadowRift()
- Description: Returns the first shadow-affinity rift from
riftspawner. - Parameters: None.
- Returns: entity or
nil– the rift entity, ornilif none exist orriftspawneris absent. - Error states: Returns
nilif rift spawner is missing or no shadow rifts exist.
BeginParasiteWave()
- Description: Decrements
num_wavesand either spawns floating parasites (if players are nearby) or triggers wave spawning for all targeted players. - Parameters: None.
- Returns: Nothing.
- Error states: Returns early if no rift exists.
OverrideBlobSpawn(player)
- Description: Probabilistically overrides a normal blob spawn with a Shadow Thrall encounter if a wave is pending. Marks the player as targeted and initiates a wave if no floaters are active.
- Parameters:
player(entity) – the player who may spawn a blob. - Returns:
trueif parasite wave is queued;falseotherwise. - Error states: Returns
falseif no rift exists, no hosts available, or luck roll fails.
SpawnHostedPlayer(inst)
- Description: Spawns a
player_hostedentity and copies skins, userid, and other metadata from the original playerinst. - Parameters:
inst(entity) – the original player instance to replicate. - Returns: hosted entity or
nil. - Error states: Returns
nilifSpawnPrefab("player_hosted")fails.
ReviveHosted(inst)
- Description: Handles reviving a hosted player entity: resets death flag, stops following/targeting, and spawns a fx entity.
- Parameters:
inst(entity) – the hosted parasite entity. - Returns: Nothing.
- Error states: None.
OnSave()
- Description: Serializes state (
num_waves, target player userids) for saving. - Parameters: None.
- Returns: table or
nil– save data if non-empty.
OnLoad(data)
- Description: Restores state from save data.
- Parameters:
data(table ornil) – saved data. - Returns: Nothing.
GetDebugString()
- Description: Returns a human-readable status string for debug display.
- Parameters: None.
- Returns: string – formatted wave/parasite/target counts.
Events & listeners
- Listens to:
ms_playerjoined– callsOnPlayerJoinedms_playerleft– callsOnPlayerLeftms_riftaddedtopool– callsOnRiftAddedToPoolonremoveon parasite/floater entities – triggers tracking cleanup
- Pushes: None (no
PushEventcalls found).