dao::vfx

Draw in the world with the game’s visual effects: rings, reticles, any effect by row.

Declared in dao/Vfx.h.

Classes

Class  
EmitterColor One sprite emitter’s colour, as the engine is about to draw its particles for a frame.
RunningEffect One visual effect the area has running.
Tint A colour to tint an effect’s model with: red, green, blue and alpha, each from 0 to 1.

Functions

IsPickable()

bool IsPickable(ObjectId effect)

Returns false if SetPickable excluded the effect from the cursor’s pick, otherwise true.

Move()

bool Move(ObjectId effect, const Vector &at, const std::optional<Vector> &facing=std::nullopt)

Moves a placed effect, and turns it to facing if that is given.

Returns false if the effect no longer exists

OnEmitterColor()

void OnEmitterColor(std::function<void(EmitterColor &)> callback)

Adds a callback to run each time the engine draws a sprite emitter’s particles, once a frame for each emitter in view: plain sprites and ribbons, not mesh particles.

Nothing is kept: the emitter’s own colour is put back after the draw, so a callback that stops changing it leaves the emitter as vanilla has it. Callbacks run on the engine’s worker threads, several at once, so keep them short and make what they share safe across threads.

Parameter  
callback may change color; the rest is for reading

Place()

ObjectId Place(std::int32_t vfx, const Vector &at, float scale=1.0F, const std::optional<Vector> &facing=std::nullopt, const std::optional<Tint> &tint=std::nullopt)

Places a vfx_base row at a point in the current area.

A tint multiplies the colour of every part of the effect whose material takes a user colour: the aiming rings (30017 to 30019), the auras’ glyphs and most effects on VFX.mat. Parts drawn with the reticles’ plain material, the selection reticles and the move marker (30000), keep their own colour.

Parameter  
vfx the vfx_base row
at where to place it, in world coordinates
scale its size relative to the row’s own, the same on all three axes
facing the direction it faces; the row’s default if not given
tint a colour to use in place of the row’s own Tint column, if given

Returns the effect’s id, or kInvalidObject if no area is loaded

PlaceRing()

ObjectId PlaceRing(const Vector &at, float radius, bool inReach=true)

Places the game’s aiming ring on the ground.

Parameter  
radius the ring’s radius in metres
inReach false for the out-of-reach ring, which looks the same in the game

Returns the effect’s id, or kInvalidObject if no area is loaded

Remove()

void Remove(ObjectId effect)

Removes a placed effect and clears its SetPickable setting.

Does nothing if the effect is already gone.

ReplayEmitters()

int ReplayEmitters(float seconds)

Runs the particles of the scene’s fires, torches and other sprite emitters, ribbons among them, again from nothing: each one’s particles are emptied and simulated for seconds from a random seed of its own place, so a paused frame shows them the same in every launch.

Each emitter is run again in the engine’s next frame that draws it.

Call it on the game thread with the game paused. Emitters of physics or mesh particles are left as they are.

Parameter  
seconds how long to simulate, as the engine’s own warm-up does: in steps of 1/15 s

Returns how many such emitters the scene has

RunningEffects()

std::vector<RunningEffect> RunningEffects()

Returns every visual effect the area has running, off screen as well as in view: those a script, an ability or a plugin made, and the effects that are part of its rooms’ own models (a fire or a torch’s flame the level places), which have no id or row of their own: their id and owner are kInvalidObject, their vfx 0 and their position the model’s place.

Call it on the game thread.

SetPickable()

void SetPickable(ObjectId effect, bool pickable)

Excludes an effect from the cursor’s pick, which decides what is under the cursor, or includes it again.

Some rows, such as the move marker (30000), have a shape the cursor’s ray hits, so a marker moved under the cursor would be picked instead of the ground. An excluded effect is ignored by the explore-mode cursor, by clicks, and by dao::world::PickAt, but dao::world::Raycast still hits it.

Parameter  
pickable false to exclude it, true to include it again

SetScale()

bool SetScale(ObjectId effect, float scale)

Changes a placed effect’s scale without removing and placing it again.

Returns false if the effect no longer exists

SetTint()

bool SetTint(ObjectId effect, const Tint &tint)

Changes a placed effect’s tint without removing and placing it again.

The tint shows on the parts Place says.

Returns false if the effect no longer exists

Variables

kAreaRing

constexpr std::int32_t kAreaRing = 30017

The vfx_base rows that explore mode uses for aiming.

“AOE Selection”, fxg_aoe_p

kAreaRingOutOfReach

constexpr std::int32_t kAreaRingOutOfReach = 30019

“AOE No Selection”, fxg_aoe_no_p; looks like 30017

kConeArea

constexpr std::int32_t kConeArea = 30018

“Cone Selection”, fxg_cone_p

kRingRadius

constexpr float kRingRadius = 10.0F

The radius of the aiming rings at scale 1, in metres.