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
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).
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.
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
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.
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.
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.
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.
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
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
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
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
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
- In the Data panel, pick Buffs and click Add….
- Set duration, harmful and the stats under stats or percent.
- Tick the flags you need (stun, root, silence…).
- In the ability, add a buff effect and pick your buff.
Reference
The buff effect
| Field | Type | Default | What it does |
|---|---|---|---|
buff | string | The buff's id | |
duration | EffectValue | the buff's | How long, overriding the buff's own |
stack | boolean | false | Adds a stack, up to maxStacks |
amount | EffectValue | the buff's shield | The shield it holds; takes the target formulas (byMaxHealth…) |
scaling | Scaling | Scales 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.
| Field | What it does |
|---|---|
id, name, description | Id, shown name, hover text |
tags | Free words to find it by (buffsTagged) |
duration | Seconds; lasts until removed when left out |
harmful | A debuff: goes on enemies; tenacity shortens it |
stats, percent | Flat and percent stat changes |
change | Stats worked out in code (call invalidateStats when what it reads changes) |
perStack, maxStacks | Stats per stack; most stacks one unit carries |
stacking | Put on again: strongest (default), refresh, perSource, independent, or a function |
shield, shieldScaling, recharge | Damage 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, unstoppable | See Crowd control |
invisible | Unseen by enemies unless detected |
spellImmune | Immune to spells |
invulnerable | No damage; no enemy casts or attacks on it |
untargetable | Out of everyone else's reach |
minHealth | Least health damage leaves it with |
avoids | Ability tags that do nothing to it |
dispellable | Whether dispel takes it off (yes by default) |
breaksOn | damage, attack, cast |
onApply, onTick, onEnd, onRemove | Effects (or code) as it goes on, every few seconds, when its time is up, as it comes off (code) |
onCarrierDeath | Effects where its carrier dies carrying it |
onMaxStacks | Effects as a stack brings it to maxStacks |
passive | Triggers while carried (Triggers) |
drain | Mana or a pool taken each second; ends when it runs out (resources pack) |
paysWithHealth | Its abilities cost health, not mana |
overheal | Healing past full becomes a shield (buff, part, most, of) |
phasing | Walks through units |
cleave | Its blows strike the enemies around their target (part, radius, angle) |
revealed, camouflage, trueSight | Vision 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
onEndruns 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 ownonHitstill counts (Wind Walk's backstab).castignores the ability that put it on.onMaxStackswith aremoveBuffamong its effects spends the stacks.- An
auraupdates as units come and go. The aura's buff has no duration; it comes off as they leave.