Skip to content

Buffs and auras ​

A buff is something lasting on a unit: stat changes, a shield, damage over time, a stun. You define it once (BuffDef) and put it on with the buff effect, or keep it on everyone nearby with an aura.

Quick start ​

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

export const innerFire: BuffDef = { id: 'innerFire', name: 'Inner Fire', duration: 60, stats: { armor: 5 }, percent: { attackDamage: 0.1 } }

export const castInnerFire: AbilityDef = {
	id: 'castInnerFire',
	name: 'Inner Fire',
	target: 'unit',
	targets: { allies: true },
	range: 7,
	manaCost: 35,
	effects: [{ type: 'buff', buff: 'innerFire' }]
}

The ally gets +5 armor and +10% attack damage for a minute. Add the buff to Rules.buffs beside the ability.

Common tasks ​

Slow a unit ​

A negative percent.moveSpeed slows. harmful makes it a debuff (it goes on enemies, and tenacity shortens it).

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

const frost: BuffDef = { id: 'frost', name: 'Frost', harmful: true, duration: 3, percent: { moveSpeed: -0.4, attackSpeed: -0.25 } }

Deal damage over time ​

A negative healthRegen is damage over time. For ticks you can see, use onTick.

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

const burning: BuffDef = { id: 'burning', name: 'Burning', harmful: true, duration: 4, stats: { healthRegen: -25 } }
const poison: BuffDef = { id: 'poison', name: 'Poison', harmful: true, duration: 6, onTick: { every: 1, effects: [{ type: 'damage', amount: 15 }] } }

Give a unit a shield ​

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

const barrier: BuffDef = { id: 'barrier', name: 'Barrier', duration: 5, shield: [100, 175, 250], shieldScaling: { abilityPower: 0.5 } }
// a shield sized by the cast instead of the buff
const shieldAlly: EffectDef = { type: 'buff', buff: 'barrier', amount: 200 }

recharge: 8 brings a shield back once the unit hasn't been hurt for 8 seconds.

Keep a buff on everyone nearby ​

An aura keeps its buff on every unit within radius while they stay there. Put it in a passive.

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

const devotion: BuffDef = { id: 'devotion', name: 'Devotion Aura', stats: { armor: [1.5, 3, 4.5] } }
const devotionAura: AbilityDef = { id: 'devotionAura', name: 'Devotion Aura', target: 'passive', effects: [{ type: 'aura', buff: 'devotion', radius: 9 }] }

Stack a buff ​

stack: true adds one more, up to maxStacks. perStack makes its stats count once per stack.

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

const souls: BuffDef = { id: 'souls', name: 'Souls', maxStacks: 1000, stats: { attackDamage: 3 }, perStack: true }
const takeSoul: EffectDef = { type: 'buff', buff: 'souls', stack: true, on: 'caster' }
// at five stacks: a stun, and the stacks spent
const rupture: BuffDef = {
	id: 'rupture',
	name: 'Rupture',
	harmful: true,
	duration: 4,
	maxStacks: 5,
	onMaxStacks: [{ type: 'buff', buff: 'stunned' }, { type: 'removeBuff', buff: 'rupture' }]
}

Turn a buff on and off ​

The toggle effect puts a buff on the caster until cast again. With the resources pack, drain takes mana each second while it lasts.

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

const immolating: BuffDef = { id: 'immolating', name: 'Immolation', drain: { mana: 7 }, onTick: { every: 1, effects: [{ type: 'damage', amount: 10, radius: 2 }] } }
const immolation: AbilityDef = { id: 'immolation', name: 'Immolation', target: 'none', effects: [{ type: 'toggle', buff: 'immolating' }] }

End a buff early ​

breaksOn takes it off on damage, an attack or a cast. The removeBuff effect takes stacks or the whole buff off.

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

const sleep: BuffDef = { id: 'sleep', name: 'Sleep', harmful: true, duration: 6, stun: true, breaksOn: ['damage'] }
const wake: EffectDef = { type: 'removeBuff', buff: 'sleep', radius: 4, affects: 'all' }

Do something when it ends or its carrier dies ​

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

// a bomb that goes off when its time is up
const timeBomb: BuffDef = { id: 'timeBomb', name: 'Time Bomb', harmful: true, duration: 4, onEnd: [{ type: 'damage', amount: 200, radius: 3 }] }
// Doom: a demon of the caster's where its carrier dies
const doom: BuffDef = { id: 'doom', name: 'Doom', harmful: true, duration: 30, silence: true, onCarrierDeath: [{ type: 'spawn', unit: 'doomGuard' }] }

Make a unit untouchable ​

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

const divineShield: BuffDef = { id: 'divineShield', name: 'Divine Shield', duration: 15, invulnerable: true }
const stasis: BuffDef = { id: 'stasis', name: 'Stasis', duration: 2.5, invulnerable: true, untargetable: true, stun: true }
const undyingRage: BuffDef = { id: 'undyingRage', name: 'Undying Rage', duration: 5, minHealth: [30, 50, 70] }

invulnerable: no damage, no enemy casts or attacks on it (heals still land). untargetable: nobody else's ability, attack or area reaches it, allies' included, though it is still seen. minHealth: damage never takes it below this.

Pay for abilities with health ​

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

const bloodTithe: BuffDef = { id: 'bloodTithe', name: 'Blood Tithe', paysWithHealth: true, stats: { omnivamp: 0.1 } }

paysWithHealth: the carrier's abilities cost health, not mana, one for one (or a number: health for each point of mana). It cannot cast with no more health than that; items still cost nothing. Gravelord's innate.

Turn healing past full into a shield ​

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

const mercysEcho: BuffDef = { id: 'mercysEcho', name: 'Mercy’s Echo', overheal: { buff: 'echoShield', part: [0.4, 0.6, 0.8, 1], most: 0.25 } }
const echoShield: BuffDef = { id: 'echoShield', name: 'Echo', duration: 5 }

overheal: the healing past full health the carrier gives (of: 'given', the default) or gets (of: 'taken') becomes the shield buff named, holding part of what spilled over (all when left out), up to most of the healed one's max health (a third when left out).

Tag a buff ​

tags: ['fire', 'slow']: free words a search finds it by and code asks for (buffsTagged(world, entity, 'anti-heal') is what a unit is under), as abilities, units and items have (Tags).

Walk through units, cleave ​

phasing: true has the carrier walk through units (Crowd control); cleave: { part, radius, angle? } has its blows strike the enemies around their target (Damage and heal).

Editor ​

  1. In the Data panel, pick Buffs and click Add….
  2. Set duration, harmful and the stats under stats or percent.
  3. Tick the flags you need (stun, root, silence…).
  4. In the ability, add a buff effect and pick your buff.

Reference ​

The buff effect ​

FieldTypeDefaultWhat it does
buffstringThe buff's id
durationEffectValuethe buff'sHow long, overriding the buff's own
stackbooleanfalseAdds a stack, up to maxStacks
amountEffectValuethe buff's shieldThe shield it holds; takes the target formulas (byMaxHealth…)
scalingScalingScales that shield

Other buff-related effects: aura (buff, radius, affects), toggle (buff), removeBuff (buff, stacks: all when left out), dispel (takes buffs off, hurts summons by amount), cleanse (Crowd control).

BuffDef ​

Full type: BuffDef; every field with a League and a Warcraft III example: Buffs and debuffs: every field. Most flags take true or a function (world, carrier, instance) => boolean.

FieldWhat it does
id, name, descriptionId, shown name, hover text
tagsFree words to find it by (buffsTagged)
durationSeconds; lasts until removed when left out
harmfulA debuff: goes on enemies; tenacity shortens it
stats, percentFlat and percent stat changes
changeStats worked out in code (call invalidateStats when what it reads changes)
perStack, maxStacksStats per stack; most stacks one unit carries
stackingPut on again: strongest (default), refresh, perSource, independent, or a function
shield, shieldScaling, rechargeDamage it takes first; grows with the giver's stats; comes back after so many unhurt seconds
stun, root, silence, disarm, airborne, down, grounds, control, suppress, grounded, unstoppableSee Crowd control
invisibleUnseen by enemies unless detected
spellImmuneImmune to spells
invulnerableNo damage; no enemy casts or attacks on it
untargetableOut of everyone else's reach
minHealthLeast health damage leaves it with
avoidsAbility tags that do nothing to it
dispellableWhether dispel takes it off (yes by default)
breaksOndamage, attack, cast
onApply, onTick, onEnd, onRemoveEffects (or code) as it goes on, every few seconds, when its time is up, as it comes off (code)
onCarrierDeathEffects where its carrier dies carrying it
onMaxStacksEffects as a stack brings it to maxStacks
passiveTriggers while carried (Triggers)
drainMana or a pool taken each second; ends when it runs out (resources pack)
paysWithHealthIts abilities cost health, not mana
overhealHealing past full becomes a shield (buff, part, most, of)
phasingWalks through units
cleaveIts blows strike the enemies around their target (part, radius, angle)
revealed, camouflage, trueSightVision pack (Vision)

In code ​

applyBuff(world, target, buff, duration?, source?, level?), hasBuff(entity, buff), removeStacks(world, entity, buff, count?), breakBuffs(world, entity, by), isInvulnerable, isUntargetable, healthFloor.

Notes ​

  • onEnd runs when the time is up, not when the buff is taken off. It runs in the name of who put the buff on, and its amounts can grow with the stacks (context.stacks).
  • breaksOn: ['attack'] takes the buff off after the attack lands, so the buff's own onHit still counts (Wind Walk's backstab). cast ignores the ability that put it on.
  • onMaxStacks with a removeBuff among its effects spends the stacks.
  • An aura updates as units come and go. The aura's buff has no duration; it comes off as they leave.