Ability visuals
How abilities and buffs look: a colour and a style per ability, a look per effect (its missile, its zone, its rush), the ground telegraphs, trails and links every ability gets, and styles of your own.
Quick start
import { presetFx, type GameView } from '@v12-engine/client'
export const view: GameView = {
units: { looks: {} },
fx: {
defs: presetFx(['burning-ground', 'fireball']),
abilities: {
looks: {
stormBolt: { color: [0.6, 0.8, 1], style: 'missile' },
thunderClap: { color: [1, 0.9, 0.5], style: 'slam' },
blizzard: { color: [0.7, 0.9, 1], style: 'mark' },
devotion: { color: [1, 0.85, 0.4], aura: 'glow' }
}
}
}
}Each ability is drawn in its style and colour, keyed by the ability's id (or the buff's, for aura). The client's eleven styles are always there; a look that names a style of neither the client's nor the game's is drawn as a ring, and the log says so once.
Common tasks
Pick a style
| Style | Draws |
|---|---|
ring | a ring on the ground (the default) |
tornado | a whirlwind that forms where cast and travels with what is sent |
smash | the ground breaking open |
tether | a rope from caster to target (until: the buff it lasts as long as) |
sonar | rings going out one after another, for searching |
missile | an arrow, a rock or a bird of light on its way (options.shape) |
burst | sparks where it's cast |
slam | the ground thrown up around the caster, after a rush too |
mark | a place on the ground: where a star will fall, a field, a sky beam |
barrage | missiles called down one after another, each blast shaking the view |
glow | for buffs (aura): sparks rising, falling or drifting, a ring, a bubble |
Give each effect of an ability its own look
effects on a look overrides it per effect: by the effect's look name, else its place ('0', '1'… first to last, each before those it holds), else its type (missile, zone, dash…).
import type { AbilityLooks } from '@v12-engine/client'
const looks: AbilityLooks = {
// Ahri's orb, one look out and back
orb: { color: [0.9, 0.45, 1], style: 'missile', options: { shape: 'ball' } },
// Vel'Koz's halves another (`look: 'halves'` on the split's missile)
fission: { color: [0.6, 0.35, 1], style: 'missile', effects: { halves: { color: [1, 0.6, 0.15] } } },
// Flame Strike: the fall in `mark` style, then burning ground for the zone's life
flameStrike: { color: [1, 0.5, 0.1], style: 'mark', effects: { zone: { color: [1, 0.2, 0.05], fx: 'burning-ground' } } }
}Show stacks, a polymorph, a control mark
import type { AbilityLooks } from '@v12-engine/client'
const looks: AbilityLooks = {
bleed: { color: [0.95, 0.1, 0.1], counter: { max: 5 } }, // a pip per stack over the carrier
hex: { color: [0.3, 1, 0.3], drawnAs: 'sheep' }, // drawn as another unit type
terrify: { color: [0.6, 0.2, 0.8], marker: true } // the mark over a feared unit, in this colour
}Telegraph the ground
Every ability with a shape shows it on the ground for everyone while it winds up (its castTime), flashes it as it goes off, marks a delayed blast until it lands and a zone for its life. ground: false on the look turns that off.
Trail a dash, link a bounce
A unit rushed by a dash, pull or throw leaves a trail in the ability's colour (trail: false for none, fx to play an effect on it). A bouncing missile draws links between those it strikes (link: chain by default, ray, tether, or your own; false for none).
import type { AbilityLooks } from '@v12-engine/client'
const looks: AbilityLooks = {
chainLightning: { color: [0.6, 0.8, 1], style: 'missile', link: 'chain' },
charge: { color: [1, 0.6, 0.2], trail: true, fx: 'dust-trail' }
}For link, take the link effects into the view: defs: { ...presetFx(), ...linkFx() }.
Decide a look in code
abilities.for picks a look each cast from the caster and level (a hero's own colours, a fireball that grows with its level). looks is used when it gives nothing.
Write your own style
A style is an object of optional methods, told what happens, made with the renderer's kit (SpellContext). Add it beside the client's (one of the same name takes its place):
import type { GameView, SpellStyleFactory } from '@v12-engine/client'
export const flash: SpellStyleFactory = (context) => ({
cast(event, visual) {
context.ring(event.x, event.z, visual.color, 0.2, 6)
}
})
export const view: GameView = {
units: { looks: {} },
fx: { abilities: { styles: { flash }, looks: { nova: { color: [1, 1, 1], style: 'flash' } } } }
}The client's styles in packages/client/src/lite/spells/styles are written the same way; start from one.
Reference
AbilityLook
| Field | Type | What it does |
|---|---|---|
color | [r, g, b] (0 to 1) | Its colour |
style | string | The style that draws it (ring when left out) |
aura | string | For buffs: the style drawn on the carrier (glow); a small light when left out |
until | string | For tethers: the buff on the target the rope lasts as long as |
options | record | Anything else a style reads |
effects | Record<string, Partial<AbilityLook>> | A look per effect, by look name, place or type |
ground | boolean | Its shape drawn on the ground (yes) |
fx | string | An effect of the view on a zone for its life, on a rushing unit, at a strike |
trail | boolean | A trail behind a rushed unit (yes) |
link | string or false | Links between bounce targets (chain) |
drawnAs | string | Of a buff: its carrier drawn as this unit type |
counter | boolean or { max } | Of a stacking buff: a pip per stack |
marker | boolean | Of a control buff: the mark over its carrier (yes) |
GameView.fx.abilities (ViewAbilityLooks): looks, for, styles.
SpellStyle methods
| Method | Called |
|---|---|
warm(visual) | Once, up front, for every look that names the style |
windup(event, visual) | A caster started to cast |
cast(event, visual) | The ability went off |
strike(event, visual) | Something it sent arrived: a missile hit, a star fell |
missiles(list) | Every frame, with this style's visible missiles |
auras(list) | Every frame, with units in view carrying a buff whose aura is this |
update(dt) | Every frame |
dispose() | At the end |
SpellContext holds the scene, the terrain, where entities are drawn, fog-covered materials, a clock, fx (play any effect), lights, and instance / clone for meshes made once and drawn together.
What every ability gets
Without a style of its own, the client draws (loaded when the first ability is seen):
| What | Told by | Turn off or change |
|---|---|---|
| Its shape on the ground while it winds up | the windup (its aim, aimOf) | ground: false |
| A cast with a shape, flashed as it goes off | the cast | ground |
| A delayed blast until it lands, a zone for its life | Snapshot.areas (AreaState) | ground; fx |
| A trail behind a rushed unit | core.dashing (DashSight) | trail: false; fx |
| Links between bounce targets | the missileHits | link |
| Stacks over the carrier | EntityState.stacks | counter |
| The mark of a fear, charm, taunt | core.controlled | marker: false |
| A unit drawn as another type | its buffs | drawnAs |
| An effect where something struck | the strike | fx |
Shots of attacks
A unit's attack shot (ShotDef) can carry an effect as it flies (fx: 'fireball', in place of the ball when it names no model) and land with another (impact, or what its effect's impact knob names; false for none). shotFor decides both per shot; draw draws it your own way.