Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Global objectClient APIGenerated

Vfx

const Vfx: 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.

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.

string

Name of the effect, spelled as the game’s particle libraries spell it.

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.

As spawn, plus offset: where the emitter sits in the entity’s own space, in metres. Up to 8 m from its origin.

number

number

Vector3

boolean

number

Quaternion | Vector3

number

number

number

number

number

A handle to pass to stop, or 0 when the entity was not there or the game would not load the effect.

count(): number

How many effects this client is playing right now, across every resource. The budget is 192.

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.

string

Name to look for.

boolean

True when the name resolves here and now.

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.

number

What spawn or attach returned.

boolean

True while it is playing.

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.

string

Keep only the names starting with this, e.g. WH_Particels.fires or collisions.combat.

string[]

The matching names.

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.

string

Name of the effect, spelled as the game’s particle libraries spell it.

Vector3

Where to play it, in world-space metres.

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.

number

number

boolean

number

Quaternion | Vector3

number

number

number

number

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(handle): boolean

Stops one effect and releases what it was standing on.

number

What spawn or attach returned.

boolean

True when the handle named an effect that was still playing.

stopAll(): void

Stops every effect this client started, including ones other resources started. The session ending does this too.

void

Nothing.