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
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:
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:
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:
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
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:
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.
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
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.
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
| Trigger | Goes off when | Its effects reach | Fields |
|---|---|---|---|
onHit | an attack of the carrier lands on a living target | the target | whileBuff, every, consumes, cooldown, slot, priority |
onKill | the carrier kills an enemy | the one killed, where it fell | attack, whileBuff, cooldown, only |
onCast | the carrier casts an ability it learns (not one that went off charged) | the carrier | cooldown |
onDamaged | the carrier is hurt | who hurt it | attack, melee, cooldown |
onAbilityHit | an ability of the carrier hurts an enemy (a zone's every round) | the one hurt | cooldown |
onLowHealth | health falls below below of max (once, until back above) | the carrier | below, cooldown |
onFatal | a blow would kill it | the carrier | health (all when left out), cooldown |
| Field | What it does |
|---|---|
effects | What runs, in the carrier's name, at the level of what it comes from |
cooldown | Seconds before it goes off again; shown on an ability's button |
chance | Whether it goes off; its cooldown starts only when it does |
whileBuff | Only while the carrier has this buff |
consumes | The attack spends a stack of whileBuff (a kill spends it too, after onKill saw it) |
every | Only every so many attacks that land (attacksCounted(entity, ability)) |
attack | Only an attack of its own (onKill, onDamaged) |
melee | Only a hit with no missile (onDamaged) |
slot | The slot among the carrier's attack modifiers (onHit): one of a slot goes off, the highest priority |
priority | Which of a slot goes off, the highest first; 0 when left out |
Where triggers go
- An ability with
target: 'passive', ineffects. - A cast ability's
passivelist. - 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.damageholds the damage that set offonDamaged,onAbilityHitoronHit.- What a trigger's effects do sets off no
onDamagedoronAbilityHit. onKillcan't read the dead unit's buffs (they're gone by then). Use anentityDiedlistener for that.checkRuleswarns of a buffpassivethat isn't a trigger.