Skip to content

Areas and shapes ​

Cones, lines, rings and crosses; ground that burns for a while; blasts that land a moment later; and your own ways of aiming.

Quick start ​

ts
import type { AbilityDef } from '@v12-engine/engine'

const breath: AbilityDef = {
	id: 'breathOfFire',
	name: 'Breath of Fire',
	target: 'point',
	range: 6,
	effects: [{ type: 'damage', amount: [65, 125, 185], shape: 'cone', length: 6, angle: Math.PI / 2 }]
}

A quarter-circle cone, 6 cells long, from the caster toward the spot. The player sees the cone on the ground while aiming, and it flashes as it goes off.

Common tasks ​

Hit a circle, a line or a ring ​

Any effect with a radius alone covers a circle where it landed. Add a shape for the rest.

ts
import type { EffectDef } from '@v12-engine/engine'

const blast: EffectDef = { type: 'damage', amount: 100, radius: 3 }
const wave: EffectDef = { type: 'damage', amount: 100, shape: 'line', length: 10, width: 1 }
// Darius's Decimate: the outer ring hurts, the middle doesn't
const decimate: EffectDef = { type: 'damage', amount: 100, shape: 'ring', radius: 4, width: 1.5 }
// Pyke's Death from Below: an X at the spot
const cross: EffectDef = { type: 'damage', amount: 100, shape: 'cross', length: 8, width: 0.6 }

Burn the ground for a while ​

A zone runs its effects on those inside four times a second, for duration seconds.

ts
import type { AbilityDef } from '@v12-engine/engine'

const flameStrike: AbilityDef = {
	id: 'flameStrike',
	name: 'Flame Strike',
	target: 'point',
	range: 8,
	cooldown: 10,
	effects: [{ type: 'zone', radius: 2.5, duration: 5, effects: [{ type: 'damage', amount: 10 }] }]
}

Lay a wall of fire ​

A shaped zone keeps the way it was cast, even as the caster walks off.

ts
import type { EffectDef } from '@v12-engine/engine'

const wallOfFire: EffectDef = { type: 'zone', duration: 6, shape: 'rect', length: 6, width: 0.5, effects: [{ type: 'damage', amount: 12 }] }

Stun whoever crosses the edge ​

onEnter, onLeave and edge run on who comes and goes. edge is anyone who crosses either way after it forms.

ts
import type { AbilityDef } from '@v12-engine/engine'

const eventHorizon: AbilityDef = {
	id: 'eventHorizon',
	name: 'Event Horizon',
	target: 'point',
	range: 9,
	effects: [{ type: 'zone', duration: 3, radius: 3, edge: [{ type: 'buff', buff: 'stunned' }] }]
}

Carry a zone with the caster ​

follow: 'caster' moves it with the caster and turns it the caster's way. A cone of it stays in front. Rumble's Flamespitter:

ts
import type { EffectDef } from '@v12-engine/engine'

const flamespitter: EffectDef = {
	type: 'zone',
	duration: 3,
	follow: 'caster',
	effects: [{ type: 'damage', amount: 20, shape: 'cone', length: 5, angle: Math.PI / 2 }]
}

Land a blast a moment later ​

after runs its effects delay seconds later, where it was aimed. The screen marks the spot until it lands.

ts
import type { EffectDef } from '@v12-engine/engine'

const meteor: EffectDef = { type: 'after', delay: 1.2, effects: [{ type: 'damage', amount: 250, radius: 3 }, { type: 'buff', buff: 'stunned', radius: 3 }] }

Keep it up: a channel ​

A channel holds the caster in place, running its effects every every seconds. Another order or a stun breaks it. Blizzard:

ts
import type { AbilityDef } from '@v12-engine/engine'

const blizzard: AbilityDef = {
	id: 'blizzard',
	name: 'Blizzard',
	target: 'point',
	range: 8,
	aim: { shape: 'circle', radius: 2 },
	effects: [],
	channel: { duration: 6, every: 1, effects: [{ type: 'damage', amount: [30, 40, 50], radius: 2 }] }
}

Aimed and walking channels are in Recasts, charges and holds.

Aim along two points ​

target: 'vector': the player clicks where it starts, then the direction. Its effects go off with the first point as their origin and the second as their point. Viktor's Death Ray, Rumble's The Equalizer.

ts
import type { AbilityDef } from '@v12-engine/engine'

const deathRay: AbilityDef = {
	id: 'deathRay',
	name: 'Death Ray',
	target: 'vector',
	range: 5,
	effects: [{ type: 'missile', speed: 20, distance: 7, effects: [{ type: 'damage', amount: 90 }] }]
}

Make your own way of aiming ​

defineTargeting sets what it is like (what the player gives), what can be aimed at (check), and what the indicator draws. List it in Rules.targetings and declare its name:

ts
declare module '@v12-engine/engine' {
	interface AbilityTargetings {
		wall: true
	}
}

const wall = defineTargeting({
	id: 'wall',
	like: 'point',
	check: (world, caster, ability, { point }) => (point && isBlocked(world, point) ? { key: 'notOpenGround' } : undefined),
	indicator: ({ from, pointer }) => {
		if (!pointer) return undefined
		const across = Math.atan2(pointer.x - from.x, pointer.z - from.z) + Math.PI / 2
		return [{ shape: 'line', length: 4, width: 0.4, at: { x: pointer.x - Math.sin(across) * 2, z: pointer.z - Math.cos(across) * 2 }, heading: across }]
	}
})

Reference ​

Shapes ​

shapeLiesReadsLike
circlearound where it landedradiusBlizzard, Thunder Clap
conefrom the caster, the way it was aimedlength, angle (radians)Breath of Fire
linefrom the caster, the way it was aimedlength, width (each side)Shockwave
rectaround where it landed, along the aimlength, width (each side)a wall of fire
ringaround where it landedradius, width (inward)Decimate
arcaround the caster, centred on the aimradius, angle, widtha crescent sweep
crossaround where it landed, 45° off the aimlength, width (each side)Death from Below
  • "The caster" means where the effects go off from: the caster, or its origin (a vector's first point, a proxy).
  • The way it faces runs from there to where it landed; for an ability aimed at nothing, the way the caster faces.
  • A unit is hit when any part of it is inside.
  • The screen draws the first shaped effect's area while aiming (aimOf), so the player aims what will hit. Set AbilityDef.aim when the effects don't say (a channel, a radius in code).
  • checkRules names a shape that doesn't exist and one missing a size it reads (a cone with no angle covers nothing).

target values ​

ValueThe playerThe caster
noneclicks the buttoncasts where it stands
unitclicks a unit targets allowswalks into range, then casts
pointclicks a spotwalks into range, then casts
directionclicks a spotcasts toward it, without walking
vectorclicks a start, then a directionwalks into range of the start
passivecan't cast italways on

A computer casts a vector from the nearest enemy in reach, onward away from the caster, or where its ai says ({ point, to }).

The zone effect ​

FieldTypeWhat it does
durationEffectValueSeconds it lasts
radius / shapefrom EffectCommonIts ground
effectsEffectDef[]On those inside, four times a second
onEndEffectDef[]On those still inside as it ends
onEnterEffectDef[]On each who comes in (those inside as it forms included)
onLeaveEffectDef[]On each who leaves
edgeEffectDef[]On each who crosses its edge either way, after it forms
follow'caster' or 'target'Moves with that unit; ends (with onEnd) when it dies
affectsfrom EffectCommonWho counts as inside

after: delay, effects, impact (a name for how its landing looks and sounds). A zone or an after with a shape keeps where it was cast from and its heading (Zone.from, heading).

defineTargeting ​

FieldWhat it does
idIts name, used as target
likeThe engine's way it behaves like: what the player gives and what the order walks to
check(world, caster, ability, aim) gives a refusal, or nothing: the player is told why not
aimWhere the effects go from what was aimed: a point, a target, an origin
indicatorShapes drawn while aiming, from from (the caster), pointer and the first point

aimKind(registry, ability) says what an ability is aimed as. checkRules names a target that is no way of aiming.

In code ​

effectArea(context, effect) gives an effect's area and inArea(area, place, radius) tests a point, for your own effect. endZone(world, zone, { onEnd? }) ends a zone early (world.zones).