Shadow Harvester Trail
Based on game build 722832 | Last updated: 2026-04-28
Overview
shadow_harvester_trail.lua defines a visual effect prefab used to render a shadowy trail around an entity (typically associated with the Shadow Harvester or WX-78 nightmare fuel effects). The prefab attaches animation and sound components but relies on client-side logic for the trail generation. It uses an object pooling system (trailfx_pool) to recycle effect entities rather than spawning new ones continuously. The trail logic is skipped on dedicated servers (TheNet:IsDedicated()).
Usage example
-- Spawn the trail effect at a specific position:
local inst = SpawnPrefab("shadow_harvester_trail")
inst.Transform:SetPosition(10, 0, 10)
-- The trail logic initializes automatically on non-dedicated clients:
-- No manual function calls required; effects persist until entity removal.
Dependencies & tags
Entity built-ins:
Transform-- position and parentingAnimState-- animation playback and layeringSoundEmitter-- audio playback (attached but unused in source)Network-- entity replication metadata
Tags:
CLASSIFIED-- added to child fx entities to hide them from debug selection
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
assets | table | {...} | Array of Asset entries loaded with the prefab. |
trailfx | table | {} | Array of active trail effect entities currently visible. Assigned in fn() on non-dedicated sims. |
trailfx_pool | table | {} | Pool of inactive effect entities available for recycling. Assigned in fn() on non-dedicated sims. |
Main functions
fn()
- Description: Prefab constructor. Creates the base entity, attaches components, and configures animations. On non-dedicated simulations, initializes the trail effect system (
trailfx,trailfx_pool) and starts the generation task. Returnsinstfor both client and master simulations. - Parameters: None
- Returns: entity instance
- Error states: None.
CreateOneshotFx() (local)
- Description: Creates a child entity used for supplementary visual effects (shadow breath). Configures animation bank, build, and randomizes initial animation frame. Sets
persists = falseso it does not save. - Parameters: None
- Returns: entity instance (child fx)
- Error states: None.
InitializeFx(inst, fx) (local)
- Description: Configures a trail effect entity for playback. Adds
fxtoinst.trailfx, queues the animation sequence (blob_decal_pre->blob_decal_loop->blob_decal_pst), and randomizes the scale of the child oneshot fx. - Parameters:
inst-- parent entity owning the trail systemfx-- trail effect entity to initialize
- Returns: None
- Error states: Errors if
inst.trailfxis nil (should be initialized infn()).
CreateTrailFx(inst) (local)
- Description: Recursive task. Retrieves an effect entity from
trailfx_poolor creates a new one if the pool is empty. Positions the effect randomly within a small radius (0.1to0.2units) aroundinst. Initializes the fx and schedules the next call viaDoTaskInTime(3-5 frames delay). - Parameters:
inst-- parent entity - Returns: None
- Error states: Errors if
inst.Transformis missing (required forGetWorldPosition).
ExpireTrailFx(inst) (local)
- Description: Cleanup function called on entity removal. Marks all active effects in
trailfxfor finalization (finalize = true) and removes all pooled effects intrailfx_pool. - Parameters:
inst-- parent entity - Returns: None
- Error states: Errors if
inst.trailfxorinst.trailfx_poolis nil.
Events & listeners
- Listens to:
onremove(oninst) -- triggersExpireTrailFxto clean up all trail particles when the parent entity is removed. - Listens to:
animqueueover(onfxchildren) -- triggers recycling logic; iffx.finalizeis true, the entity is removed, otherwise it is returned totrailfx_pool.