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
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.
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.
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.
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.
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:
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.
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:
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.
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:
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
shape | Lies | Reads | Like |
|---|---|---|---|
circle | around where it landed | radius | Blizzard, Thunder Clap |
cone | from the caster, the way it was aimed | length, angle (radians) | Breath of Fire |
line | from the caster, the way it was aimed | length, width (each side) | Shockwave |
rect | around where it landed, along the aim | length, width (each side) | a wall of fire |
ring | around where it landed | radius, width (inward) | Decimate |
arc | around the caster, centred on the aim | radius, angle, width | a crescent sweep |
cross | around where it landed, 45° off the aim | length, width (each side) | Death from Below |
- "The caster" means where the effects go off from: the caster, or its
origin(avector'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. SetAbilityDef.aimwhen the effects don't say (a channel, a radius in code). checkRulesnames a shape that doesn't exist and one missing a size it reads (a cone with noanglecovers nothing).
target values
| Value | The player | The caster |
|---|---|---|
none | clicks the button | casts where it stands |
unit | clicks a unit targets allows | walks into range, then casts |
point | clicks a spot | walks into range, then casts |
direction | clicks a spot | casts toward it, without walking |
vector | clicks a start, then a direction | walks into range of the start |
passive | can't cast it | always 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
| Field | Type | What it does |
|---|---|---|
duration | EffectValue | Seconds it lasts |
radius / shape | from EffectCommon | Its ground |
effects | EffectDef[] | On those inside, four times a second |
onEnd | EffectDef[] | On those still inside as it ends |
onEnter | EffectDef[] | On each who comes in (those inside as it forms included) |
onLeave | EffectDef[] | On each who leaves |
edge | EffectDef[] | 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 |
affects | from EffectCommon | Who 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
| Field | What it does |
|---|---|
id | Its name, used as target |
like | The 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 |
aim | Where the effects go from what was aimed: a point, a target, an origin |
indicator | Shapes 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).