Skip to content

Triggers and passives ​

A passive is always on. What it does when something happens (an attack lands, the carrier is hurt, it kills) is a trigger effect with its own effects.

Quick start ​

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

const critStrike: AbilityDef = {
	id: 'critStrike',
	name: 'Critical Strike',
	target: 'passive',
	effects: [{ type: 'onHit', chance: 0.15, effects: [{ type: 'damage', amount: 60 }] }]
}

Every attack that lands has a 15% chance to deal 60 more damage.

Common tasks ​

Hit harder every fourth attack ​

every counts attacks that land. Jhin's Whisper:

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

const whisper: AbilityDef = { id: 'whisper', name: 'Whisper', target: 'passive', effects: [{ type: 'onHit', every: 4, effects: [{ type: 'damage', amount: 75 }] }] }

Empower the next attack ​

Cast puts a buff on the caster; whileBuff with consumes spends it on the next hit. Nasus's Siphoning Strike, which also grows on kills:

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

const siphoningStrike: AbilityDef = {
	id: 'siphoningStrike',
	name: 'Siphoning Strike',
	target: 'none',
	effects: [{ type: 'buff', buff: 'siphoning', on: 'caster' }],
	passive: [
		{ type: 'onHit', whileBuff: 'siphoning', consumes: true, effects: [{ type: 'damage', amount: 40 }] },
		{ type: 'onKill', whileBuff: 'siphoning', effects: [{ type: 'buff', buff: 'souls', stack: true, on: 'caster' }] }
	]
}

passive beside effects gives a cast ability an always-on part too.

Hurt whoever hurts the carrier ​

onDamaged effects reach the attacker. melee: true counts only melee hits. Thorns:

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

const thorns: AbilityDef = {
	id: 'thorns',
	name: 'Thorns',
	target: 'passive',
	effects: [{ type: 'onDamaged', melee: true, effects: [{ type: 'damage', amount: 0, byDamage: 0.3 }] }]
}

byDamage adds a share of the damage that set off the trigger. Triggered damage never sets off another onDamaged, so two thorny units don't echo forever.

Shield the carrier at low health ​

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

const manaBarrier: AbilityDef = {
	id: 'manaBarrier',
	name: 'Mana Barrier',
	target: 'passive',
	effects: [{ type: 'onLowHealth', below: 0.3, cooldown: 90, effects: [{ type: 'buff', buff: 'barrier' }] }]
}

Cheat death ​

onFatal stops a killing blow: the carrier keeps health of its max and its effects run. Reincarnation:

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

const reincarnation: AbilityDef = {
	id: 'reincarnation',
	name: 'Reincarnation',
	target: 'passive',
	cooldown: 240,
	effects: [{ type: 'onFatal', health: 1, cooldown: 240, effects: [{ type: 'buff', buff: 'stasis' }] }]
}

Anivia's Rebirth is an onFatal with a morph into an egg (cookbook). Being removed, sold or timed out isn't a death it cheats.

React while a buff is on ​

A buff's passive holds triggers that work while it's carried: Frost Armor slows who strikes the carrier, Wind Walk's first attack hits harder.

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

const windWalk: BuffDef = {
	id: 'windWalk',
	name: 'Wind Walk',
	duration: 20,
	invisible: true,
	breaksOn: ['attack', 'cast'],
	passive: [{ type: 'onHit', effects: [{ type: 'damage', amount: 100 }] }]
}

Items have passives too (ItemDef.passive).

Do something when the carrier casts ​

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

// each spell cast gives a stack of 'flurry'
const flurry: AbilityDef = { id: 'flurry', name: 'Flurry', target: 'passive', effects: [{ type: 'onCast', effects: [{ type: 'buff', buff: 'flurry', stack: true, on: 'caster' }] }] }

Make on-hit effects an orb: slots ​

Several onHit passives on one unit (an item's poison, a buff's frost, an ability's fire) all go off on every hit, unless they share a slot: of those that share one, only the one of the highest priority goes off, as Warcraft III's orbs. Those of other slots, and those of none, add up.

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

const frostOrb: AbilityDef = { id: 'frostOrb', name: 'Orb of Frost', target: 'passive', effects: [{ type: 'onHit', slot: 'orb', effects: [{ type: 'buff', buff: 'chilled' }] }] }
const fireOrb: AbilityDef = { id: 'fireOrb', name: 'Orb of Fire', target: 'passive', effects: [{ type: 'onHit', slot: 'orb', priority: 1, effects: [{ type: 'damage', amount: 20 }] }] }

Carrying both, only the Orb of Fire goes off. Among equal priorities the first of the carrier's abilities wins, then items, then buffs. The rule is combat.attackModifiers on the rules' settings (bySlot, the default: given every AttackModifier of the hit, it returns those that go off), for a game that wants another: all of them, or the newest.

Reference ​

Triggers ​

TriggerGoes off whenIts effects reachFields
onHitan attack of the carrier lands on a living targetthe targetwhileBuff, every, consumes, cooldown, slot, priority
onKillthe carrier kills an enemythe one killed, where it fellattack, whileBuff, cooldown, only
onCastthe carrier casts an ability it learns (not one that went off charged)the carriercooldown
onDamagedthe carrier is hurtwho hurt itattack, melee, cooldown
onAbilityHitan ability of the carrier hurts an enemy (a zone's every round)the one hurtcooldown
onLowHealthhealth falls below below of max (once, until back above)the carrierbelow, cooldown
onFatala blow would kill itthe carrierhealth (all when left out), cooldown
FieldWhat it does
effectsWhat runs, in the carrier's name, at the level of what it comes from
cooldownSeconds before it goes off again; shown on an ability's button
chanceWhether it goes off; its cooldown starts only when it does
whileBuffOnly while the carrier has this buff
consumesThe attack spends a stack of whileBuff (a kill spends it too, after onKill saw it)
everyOnly every so many attacks that land (attacksCounted(entity, ability))
attackOnly an attack of its own (onKill, onDamaged)
meleeOnly a hit with no missile (onDamaged)
slotThe slot among the carrier's attack modifiers (onHit): one of a slot goes off, the highest priority
priorityWhich of a slot goes off, the highest first; 0 when left out

Where triggers go ​

  • An ability with target: 'passive', in effects.
  • A cast ability's passive list.
  • An item's ItemDef.passive.
  • A buff's BuffDef.passive: a cast or an aura that puts it on makes the carrier react.

Notes ​

  • context.damage holds the damage that set off onDamaged, onAbilityHit or onHit.
  • What a trigger's effects do sets off no onDamaged or onAbilityHit.
  • onKill can't read the dead unit's buffs (they're gone by then). Use an entityDied listener for that.
  • checkRules warns of a buff passive that isn't a trigger.