Missiles
The missile effect sends something flying: an arrow, a bolt that chases its target, a grenade, a boomerang, a hook. What it does to what it hits is its own effects list.
Quick start
import type { AbilityDef } from '@v12-engine/engine'
const shockwave: AbilityDef = {
id: 'shockwave',
name: 'Shockwave',
target: 'direction',
range: 10,
manaCost: 100,
cooldown: 8,
effects: [{ type: 'missile', speed: 14, distance: 10, radius: 1, pierce: true, effects: [{ type: 'damage', amount: [75, 130, 200] }] }]
}A wave flies 10 cells from the caster toward where the player clicked, hurting every enemy it passes through.
Common tasks
Chase a unit
homing follows the unit it was cast on. Storm Bolt, Death Coil.
import type { EffectDef } from '@v12-engine/engine'
const stormBolt: EffectDef = {
type: 'missile',
homing: true,
speed: 10,
effects: [
{ type: 'damage', amount: 100 },
{ type: 'buff', buff: 'stunned' }
]
}Stop at the first enemy
pierce: false stops at the first. pierce: 2 goes through two and stops at the third. blocked: true stops at buildings and trees.
import type { EffectDef } from '@v12-engine/engine'
const lightBinding: EffectDef = { type: 'missile', speed: 12, distance: 11, radius: 0.6, pierce: 1, effects: [{ type: 'buff', buff: 'rooted' }] }Fly to the spot and blow up there
toPoint stops at the spot clicked. onEnd runs where it ends.
import type { EffectDef } from '@v12-engine/engine'
const rocket: EffectDef = { type: 'missile', speed: 20, distance: 12, toPoint: true, pierce: true, onEnd: [{ type: 'damage', amount: 150, radius: 2.5 }] }Throw it in an arc
arc flies over everything and hits what is within radius where it lands.
import type { EffectDef } from '@v12-engine/engine'
const grenade: EffectDef = { type: 'missile', toPoint: true, distance: 12, radius: 2, arc: { height: 3, time: 1 }, effects: [{ type: 'damage', amount: 120 }] }Bounce to the next target
bounce springs on to the nearest it hasn't hit, count times, each falloff weaker. Chain Lightning.
import type { EffectDef } from '@v12-engine/engine'
const glaive: EffectDef = { type: 'missile', homing: true, speed: 18, bounce: { count: 2, range: 6, falloff: 0.33 }, effects: [{ type: 'damage', amount: 80 }] }Fire several in a fan
count and spread (radians, total). None of them hits what another already hit.
import type { EffectDef } from '@v12-engine/engine'
const volley: EffectDef = { type: 'missile', count: 5, spread: Math.PI / 3, speed: 15, distance: 8, pierce: false, effects: [{ type: 'damage', amount: 40 }] }Come back to the caster
returns flies back to the caster from where it ends. With hitsOnReturn it hits on the way back too (Ahri's orb).
import type { EffectDef } from '@v12-engine/engine'
const orb: EffectDef = { type: 'missile', speed: 15, distance: 9, returns: true, hitsOnReturn: true, effects: [{ type: 'damage', amount: 40 }] }Hook an enemy and pull it in
import type { EffectDef } from '@v12-engine/engine'
const hook: EffectDef = {
type: 'missile',
speed: 28,
distance: 9,
pierce: false,
returns: true,
effects: [
{ type: 'pull', seconds: 0.6, effects: [{ type: 'damage', amount: [70, 120, 170] }] },
{ type: 'buff', buff: 'grabbed' }
]
}The first enemy it meets is dragged in over 0.6 seconds, hurt as it arrives, and held by the grabbed buff. See Moves.
Find its own targets
seek flies after the nearest enemy within that radius. Fox-Fire, Spirit Rush's bolts.
import type { EffectDef } from '@v12-engine/engine'
const wisps: EffectDef = { type: 'missile', count: 3, spread: 2 * Math.PI, speed: 16, distance: 7, seek: 6, effects: [{ type: 'damage', amount: 60 }] }Split where it ends
split runs effects from where it ended, facing the way it flew. Vel'Koz's Plasma Fission.
import type { EffectDef } from '@v12-engine/engine'
const fission: EffectDef = {
type: 'missile',
speed: 13,
distance: 11,
effects: [{ type: 'damage', amount: 80 }],
split: [{ type: 'missile', count: 2, spread: Math.PI, speed: 13, distance: 11, effects: [{ type: 'damage', amount: 80 }] }]
}Stun on a wall, steer in flight
import type { EffectDef } from '@v12-engine/engine'
// stops at a cliff, building or tree, and stuns the last unit it hit there
const binding: EffectDef = { type: 'missile', speed: 14, distance: 10, pierce: 1, onWall: [{ type: 'buff', buff: 'stunned' }] }
// the owner turns it toward the pointer, up to 2 radians a second
const steered: EffectDef = { type: 'missile', speed: 10, distance: 20, steer: { rate: 2 }, effects: [{ type: 'damage', amount: 90 }] }Chain effects with when
Instead of nesting, put an effect after the missile with when. It waits for the nearest effect before it that reaches that moment. This is the hook above, flat:
import type { EffectDef } from '@v12-engine/engine'
const hook: EffectDef[] = [
{ type: 'missile', speed: 28, distance: 9, pierce: false, returns: true },
{ type: 'pull', seconds: 0.6, when: 'hit' },
{ type: 'damage', amount: [70, 120, 170], when: 'arrived' },
{ type: 'buff', buff: 'grabbed', when: 'hit' }
]
// a leap, then a hook thrown from where it lands
const pounce: EffectDef[] = [
{ type: 'dash', distance: 5, leap: 2 },
{ type: 'damage', amount: 60, radius: 2, when: 'landed' },
{ type: 'missile', speed: 28, distance: 9, pierce: false, when: 'landed' },
{ type: 'pull', seconds: 0.4, when: 'hit' }
]Reference
The missile effect
| Field | Type | Default | What it does |
|---|---|---|---|
speed | number | Cells a second | |
distance | EffectValue | How far it flies | |
radius | EffectValue | How wide it hits | |
effects | EffectDef[] | What happens to each it hits | |
onEnd | EffectDef[] | What happens where it ends for good | |
homing | boolean | false | Follows the target unit |
toPoint | boolean | false | Ends at the spot clicked |
pierce | boolean or number | true | true through all, false stops at the first, n through n |
falloff | number | With pierce: each one passed takes this share off the next (context.share) | |
count, spread | number, radians | 1 | Several in a fan |
delay | number | 0 | Takes shape where cast this long before it sets off; the caster is free |
arc | { height, time? } | Thrown: flies over everything, hits around where it lands | |
bounce | { count, range, falloff? } | Springs on to the nearest it hasn't hit | |
returns | boolean | false | Comes back to the caster; its onEnd runs at the caster |
hitsOnReturn | boolean | false | With returns: hits again on the way back |
seek | number | Flies after the nearest it may hit within this radius | |
split | EffectDef[] | Run from where it ended, the way it flew | |
steer | { rate } | The owner steers it, rate radians a second at most | |
onWall | EffectDef[] | Stops at a wall; these run there, to the last it hit | |
blocked | boolean | false | Buildings and trees stop it |
sight | number | The caster's team sees around it as it flies | |
kinds, layers | from EffectCommon | What it may hit |
when
when | Waits for | The same as nesting in |
|---|---|---|
hit | a missile | its effects |
arrived | a pull | its effects |
landed | a dash | its effects |
end | a missile or a zone | its onEnd |
An effect with nothing before it to wait for never happens, and checkRules calls it an error. Every effects list takes when: an ability's, a passive's, a channel's, a buff's, and those inside effects. lowerChain(effects) turns a chain into the nested form.
In code
launchMissile(context, effect) sends one off and hands back the missiles. removeMissile(world, missile, { end? }) takes one out early (a wind wall), running its onEnd with end. splitMissile(world, missile) splits it early (a recast). steerMissile turns one. The client draws a returning missile facing the way it went out (MissileState.returning), a thrown one at its height (MissileState.arc).
Notes
- A missile's damage, heal and mana are reduced by
bounce.falloffandfalloff; your own effect readscontext.share. bouncesprings from wherever the missile would be done: it hit its target, was used up, landed, or reached its end.checkRuleswarns of missile fields on an effect that isn't a missile,hitsOnReturnwithoutreturns, and aseeknot above 0.- A ground object with
blocksMissileseats missiles that meet it; anarcflies over it.