Shadow Leech
Based on game build 714014 | Last updated: 2026-03-07
Overview
shadow_leech is a hostile prefab representing a summoned shadow entity used in DST's nightmare/daywalker event systems. It is dynamically spawned in relation to a Daywalker entity, tracks it via the entitytracker component, and applies a negative sanity aura that affects observers only when they are insane (IsCrazy). The prefab integrates closely with the health, combat, locomotor, lootdropper, and sanityaura components. It also supports client-side visual transparency updates via transparentonsanity and uses a custom brain (shadow_leechbrain) for AI behavior.
Usage example
-- Example: Spawn a shadow leech in response to a Daywalker event
local leech = TheWorld:SpawnPrefab("shadow_leech")
if leech ~= nil and leech.components ~= nil then
-- Begin tracking and follow the daywalker
leech:OnSpawnFor(daywalker_inst, 2.0) -- with 2-second spawn delay
-- Alternatively: fling leech away from daywalker on destruction
-- leech:OnFlungFrom(daywalker_inst, 1.5, true)
end
Dependencies & tags
Components used:
transform, animstate, soundemitter, follower, network, physics, entitytracker, sanityaura, health, combat, lootdropper, locomotor, transparentonsanity
Tags added: shadowcreature, monster, hostile, shadow, notraptrigger, shadow_aligned, NOBLOCK
Properties
No public properties are defined or initialized in the constructor. All configuration is done via method calls (e.g., SetMaxHealth, SetLoot) and function references (e.g., ToggleBrain, OnSpawnFor).
Main functions
Not applicable — this is a prefab definition file. Core functionality resides in the fn() return function and attached function references (inst.ToggleBrain, inst.OnSpawnFor, inst.OnFlungFrom, inst.OnLoadPostPass), which are documented below as instance-level methods exposed on the prefab instance.
inst.ToggleBrain(enable)
- Description: Assigns or removes the
shadow_leechbrainbased on theenableflag. - Parameters:
enable(boolean) — iftrue, sets the brain toshadow_leechbrain; otherwise, clears the brain (nil). - Returns: Nothing.
- Error states: No built-in validation; expected use is during lifecycle events (e.g., death or reset).
inst.OnSpawnFor(daywalker, delay)
- Description: Initializes the leech’s spawn behavior: tracks the provided
daywalker, faces the daywalker, and enters the"spawn_delay"state for the specified duration. - Parameters:
daywalker(Entity) — the Daywalker entity to track.
delay(number) — seconds to wait before fully entering gameplay state. - Returns: Nothing.
- Error states: Assumes
daywalkerhas a validentitytrackerandTransform; silently fails if not (but no explicit checks are performed).
inst.OnFlungFrom(daywalker, speedmult, randomdir)
- Description: Reverses and propels the leech away from the
daywalkerupon detachment or death, using physics teleportation. - Parameters:
daywalker(Entity) — source of the fling.
speedmult(number, optional) — multiplier for fling distance (default1).
randomdir(boolean) — iftrue, uses random rotation; otherwise, minor angular offset arounddaywalker’s direction. - Returns: Nothing.
- Error states: Assumes
daywalkerhasTransform:GetWorldPosition()andTransform:GetRotation(); assumes leech is not blocked by physics collisions.
inst.OnLoadPostPass(ents, data)
- Description: Restores tracking of the Daywalker after world load, by retrieving it from
entitytrackerand re-invokingStartTrackingLeech. - Parameters:
ents,data— legacy parameters, unused in current implementation. - Returns: Nothing.
- Error states: No-op if
daywalkeris not found or lacksStartTrackingLeech.
Events & listeners
None identified — no inst:ListenForEvent calls or inst:PushEvent usages are present in this file.