Skip to content

Recasts, charges and holds ​

Abilities you can use several times in a row, cast again for a second part, hold down to charge, or keep up while you aim or walk.

Quick start ​

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

const spiritRush: AbilityDef = {
	id: 'spiritRush',
	name: 'Spirit Rush',
	target: 'point',
	range: 6,
	cooldown: [130, 105, 80],
	recast: { window: 10, count: 2 },
	effects: [{ type: 'dash', distance: 5, speed: 30 }]
}

Cast it, then cast it twice more within 10 seconds. The cooldown starts after the last dash, or when the window runs out.

Common tasks ​

Hold several uses (charges) ​

charges holds count uses; one comes back every refill seconds. cooldown is then the time between two uses.

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

const roll: AbilityDef = { id: 'roll', name: 'Roll', target: 'point', range: 3, cooldown: 1, charges: { count: 3, refill: 12 }, effects: [{ type: 'dash', distance: 3, speed: 25 }] }

The button shows uses left in its corner.

A second cast that does something else ​

A recast's own effects, target, range and manaCost replace the ability's. mark sends the recast to whoever carries the mark the first cast left. Lee Sin's Sonic Wave (needs movesPack()):

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

const sonicWave: AbilityDef = {
	id: 'sonicWave',
	name: 'Sonic Wave',
	target: 'direction',
	range: 12,
	cooldown: 8,
	recast: { window: 3, mark: 'sonicWave', effects: [{ type: 'dash', to: 'target', speed: 30, effects: [{ type: 'damage', amount: 100 }] }] },
	effects: [
		{
			type: 'missile',
			speed: 40,
			distance: 12,
			pierce: false,
			effects: [
				{ type: 'damage', amount: 50 },
				{ type: 'buff', buff: 'sonicWave' }
			]
		}
	]
}

With nobody marked, the recast is refused ("Nothing is marked").

Start the cooldown at the first cast ​

cooldown: 'first' on the recast runs the cooldown from the first cast, with the recasts going on meanwhile. The default, 'after', waits for the last recast or the window's end.

Reset a cooldown ​

refresh makes an ability ready again (the one it belongs to, or ability). Death from Below on a kill:

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

const reset: EffectDef = { type: 'if', target: { healthBelow: 0.1 }, effects: [{ type: 'damage', amount: 9999, damageType: 'true' }, { type: 'refresh', on: 'caster' }] }

In code: setCooldown(entity, ability, seconds), reduceCooldown, restoreCharges(world, entity, ability, count?).

Charge up by stacks ​

charge names a stacking buff on the caster. At max stacks the ability is charged: its button glows (showing the picture <id>Charged where there is one), its charged effects take their charged branch, and casting it spends the buff.

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

const focus: BuffDef = { id: 'focus', name: 'Focus', maxStacks: 4 }
const pointBlank: AbilityDef = {
	id: 'pointBlank',
	name: 'Point Blank',
	target: 'direction',
	range: 6,
	charge: 'focus',
	effects: [{ type: 'charged', effects: [{ type: 'damage', amount: 300, shape: 'cone', length: 6, angle: 1 }], otherwise: [{ type: 'damage', amount: 120, shape: 'cone', length: 6, angle: 1 }] }],
	passive: [{ type: 'onCast', effects: [{ type: 'buff', buff: 'focus', stack: true, on: 'caster' }] }]
}

meter on a hero shows the stacks beside its health and mana.

Hold to charge, release to fire ​

The rest needs holdsPack() in Rules.packs. The cast starts the hold and the caster keeps walking; letting the key go (or a click) fires it. Varus's Piercing Arrow flies farther and hits harder the longer it's held:

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

const piercingArrow: AbilityDef = {
	id: 'piercingArrow',
	name: 'Piercing Arrow',
	target: 'direction',
	manaCost: 50,
	cooldown: 10,
	hold: { max: 1.25, upTo: 4, range: { from: 6, to: 11 }, scale: 1.5, buff: 'drawing' },
	effects: [{ type: 'missile', speed: 40, distance: 20, toPoint: true, pierce: true, effects: [{ type: 'damage', amount: 100 }] }]
}
const rules = { /* … */ packs: [holdsPack()] }

tap: { under: 0.3, effects } fires other effects when let go quickly (Pyke's stab instead of his hook).

Aim a channel, or walk while it lasts ​

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

// the beam follows the pointer
const disintegrate: AbilityDef = {
	id: 'disintegrate',
	name: 'Disintegrate',
	target: 'direction',
	range: 10,
	effects: [],
	channel: { duration: 3, every: 0.25, aimed: true, effects: [{ type: 'damage', amount: 20, shape: 'line', length: 10, width: 0.5 }] }
}
// a song sung on the march
const warSong: AbilityDef = { id: 'warSong', name: 'War Song', target: 'none', effects: [], channel: { duration: 8, every: 1, walks: true, effects: [{ type: 'heal', amount: 15, radius: 5 }] } }

Break a channel when the target walks away ​

leash breaks a channel on a unit as it gets that far from the caster's edge, dies or hides (Siphon Mana, Life Drain). No pack needed.

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

const lifeDrain: AbilityDef = {
	id: 'lifeDrain',
	name: 'Life Drain',
	target: 'unit',
	targets: { enemies: true },
	range: 6,
	effects: [],
	channel: { duration: 4, every: 0.5, leash: 8, effects: [{ type: 'damage', amount: 25 }] }
}

Reference ​

AbilityRecast ​

FieldTypeDefaultWhat it does
windownumberSeconds after the cast it may be cast again
countnumber1Recasts allowed
effectsEffectDef[]the ability'sWhat a recast does
targetAbilityTargetthe ability'sHow a recast is aimed
rangeScaledthe ability'sA recast's range
manaCostScaled0A recast's cost
markstringA buff the cast leaves; the recast goes to its nearest carrier
cooldown'after' or 'first''after'When the cooldown starts

A recast has no wind-up, no channel and spends no charge.

charges ​

{ count, refill }, both Scaled. Kept in a save. refresh and a hero's revival fill them. chargesLeft(ability, state) says how many; AbilityState.charges and refill hold them only while not full. An item's charges show as CarriedItem.uses.

HoldDef ​

FieldTypeWhat it does
maxnumberSeconds to full
upTonumberFires by itself after this long (at full when left out)
range{ from, to }Reach let go at once and at full; a toPoint missile goes that far
scalenumberAmounts at full, times those let go at once (context.held is 0 to 1)
tap{ under, effects }Let go before under seconds: these effects instead
buffstringOn the caster while holding (a slow)

A stun, silence or death lets go of a hold for nothing. A hold is paid for as it fires.

channel ​

FieldWhat it does
durationSeconds, or a function
everySeconds between runs of effects (or run, in code)
effects, runWhat it does each time
finishedRuns only if kept up to the end (a recall's teleport)
interruptedCode run when broken off
breaksOnDamageAny damage breaks it
leashBreaks as the target gets this far away
aimedFollows the player's aim (holds pack)
walksKept up while walking; a stun, silence or death breaks it (holds pack)

In code ​

endRecast(state) closes a window early, markedBy finds marked units, abilityAsCast gives the ability as its next cast will be. releaseHold(world, entity, point?), aimAt(world, entity, point), heldShare(world, entity). The recast window is AbilityState.recast (saved) and shows on the button via AbilityInfo.recast. A unit holding or aiming carries the aiming component.

Notes ​

  • A tooltip's {window} is the recast window in seconds.
  • checkRules warns of a hold on a unit-target, passive or vector ability, a hold with a channel, and a leash on an ability not cast on a unit.
  • The debug switch for no cooldowns spends no charges.