Vfx
constVfx:object
Defined in: client/api.d.ts:1466
The game’s own particle effects, played on this machine. An effect is a name out of the game’s particle libraries – WH_Particels.fires.candle, collisions.combat.sword_sword, cinematics.dust.dust_army_a – and list is the whole vocabulary. Nothing here is replicated: an effect everyone should see is one the server tells every client to play with Vfx.burst, or one the server places with Vfx.spawn, which the interest grid then streams to whoever is near it. Almost every effect the game ships is continuous, which means it never ends on its own – so everything started here is given a duration, and one that is not stopped first is stopped when the session ends.
Type Declaration
Section titled “Type Declaration”attach()
Section titled “attach()”attach(
effect,entityId,options?):number
Plays an effect in a free render slot of an entity, where it follows that entity: smoke off a cart, a glow around a body, dust under a horse. The slot is freed when the duration runs out, when stop is called, or when the entity goes. The offset is measured from the entity’s own origin, not from a bone, so an effect cannot be pinned to a hand or a weapon this way.
Parameters
Section titled “Parameters”effect
Section titled “effect”string
Name of the effect, spelled as the game’s particle libraries spell it.
entityId
Section titled “entityId”number
Engine entity to hang it on – what Player.entityId reports. Entity ids are reused, so one is only meaningful while the entity is alive.
options?
Section titled “options?”As spawn, plus offset: where the emitter sits in the entity’s own space, in metres. Up to 8 m from its origin.
countScale?
Section titled “countScale?”number
durationMs?
Section titled “durationMs?”number
offset?
Section titled “offset?”prime?
Section titled “prime?”boolean
pulsePeriod?
Section titled “pulsePeriod?”number
rotation?
Section titled “rotation?”scale?
Section titled “scale?”number
speedScale?
Section titled “speedScale?”number
strength?
Section titled “strength?”number
timeScale?
Section titled “timeScale?”number
Returns
Section titled “Returns”number
A handle to pass to stop, or 0 when the entity was not there or the game would not load the effect.
count()
Section titled “count()”count():
number
How many effects this client is playing right now, across every resource. The budget is 192.
Returns
Section titled “Returns”number
The number of live effects.
has(
effect):boolean
Asks the game whether it can resolve an effect by this name, without playing it. False while no world is loaded, and for a name the catalog knows but this install’s particle libraries no longer declare, so a resource that ships names can fail early rather than silently.
Parameters
Section titled “Parameters”effect
Section titled “effect”string
Name to look for.
Returns
Section titled “Returns”boolean
True when the name resolves here and now.
isPlaying()
Section titled “isPlaying()”isPlaying(
handle):boolean
Whether the effect behind a handle is still running. False once its duration has run out, its entity has gone, or the level has changed under it.
Parameters
Section titled “Parameters”handle
Section titled “handle”number
What spawn or attach returned.
Returns
Section titled “Returns”boolean
True while it is playing.
list()
Section titled “list()”list(
prefix?):string[]
Every effect name the shipped game declares, in order. Mined from the particle libraries at build time, so it is the same list on the server.
Parameters
Section titled “Parameters”prefix?
Section titled “prefix?”string
Keep only the names starting with this, e.g. WH_Particels.fires or collisions.combat.
Returns
Section titled “Returns”string[]
The matching names.
spawn()
Section titled “spawn()”spawn(
effect,position,options?):number
Plays an effect standing at a point in the world, on an entity this client owns and removes again. Every spawn parameter is read once, when the emitter is created, so none of them can be changed afterwards – stop it and start another.
Parameters
Section titled “Parameters”effect
Section titled “effect”string
Name of the effect, spelled as the game’s particle libraries spell it.
position
Section titled “position”Where to play it, in world-space metres.
options?
Section titled “options?”rotation aims the emitter; scale, countScale, speedScale and timeScale multiply what the effect authored; strength feeds its strength curves; pulsePeriod restarts it on that many seconds; prime starts it already running, which is what a fire wants. durationMs is how long it lives – two seconds by default, and an hour at most.
countScale?
Section titled “countScale?”number
durationMs?
Section titled “durationMs?”number
prime?
Section titled “prime?”boolean
pulsePeriod?
Section titled “pulsePeriod?”number
rotation?
Section titled “rotation?”scale?
Section titled “scale?”number
speedScale?
Section titled “speedScale?”number
strength?
Section titled “strength?”number
timeScale?
Section titled “timeScale?”number
Returns
Section titled “Returns”number
A handle to pass to stop, or 0 when the world was not up, the budget was full or the game would not load the effect.
stop()
Section titled “stop()”stop(
handle):boolean
Stops one effect and releases what it was standing on.
Parameters
Section titled “Parameters”handle
Section titled “handle”number
What spawn or attach returned.
Returns
Section titled “Returns”boolean
True when the handle named an effect that was still playing.
stopAll()
Section titled “stopAll()”stopAll():
void
Stops every effect this client started, including ones other resources started. The session ending does this too.
Returns
Section titled “Returns”void
Nothing.