Damage and heal
The damage, heal and mana effects, and how their amounts grow with levels, stats and the target.
Quick start
import type { AbilityDef } from '@v12-engine/engine'
const shockBlast: AbilityDef = {
id: 'shockBlast',
name: 'Shock Blast',
target: 'point',
range: 8,
manaCost: 80,
cooldown: 9,
effects: [{ type: 'damage', amount: [90, 140, 190], scaling: { abilityPower: 0.7 }, damageType: 'magic', radius: 2.5 }]
}Every enemy within 2.5 cells of the spot takes 90 magic damage at level 1, plus 70% of the caster's ability power.
Common tasks
Heal allies around the caster
heal reaches allies when affects is left out; damage reaches enemies.
import type { AbilityDef } from '@v12-engine/engine'
const healingWave: AbilityDef = {
id: 'healingWave',
name: 'Healing Wave',
target: 'none',
cooldown: 12,
effects: [{ type: 'heal', amount: [100, 160, 220], radius: 6 }]
}Hurt the caster's target only
With no radius (or shape), an effect reaches the unit the ability was cast on.
import type { AbilityDef } from '@v12-engine/engine'
const strike: AbilityDef = {
id: 'strike',
name: 'Strike',
target: 'unit',
targets: { enemies: true },
range: 1.5,
effects: [{ type: 'damage', amount: 150, damageType: 'physical' }]
}Heal or buff the caster
on: 'caster' points any effect at the caster.
import type { EffectDef } from '@v12-engine/engine'
const drink: EffectDef = { type: 'heal', amount: 250, on: 'caster' }Scale with the caster's stats
scaling adds a share of any caster stat. bonusAttackDamage is attack damage above what its type and level give.
import type { EffectDef } from '@v12-engine/engine'
const cleave: EffectDef = { type: 'damage', amount: 40, scaling: { bonusAttackDamage: 1.2, abilityPower: 0.3 }, radius: 2 }Scale with the target
Add these to damage, heal or a shield (a buff effect with an amount). Each is worked out per target as the effect lands.
import type { EffectDef } from '@v12-engine/engine'
// an execute that grows: 100, plus a fifth of the health the target has lost
const guillotine: EffectDef = { type: 'damage', amount: 100, byMissingHealth: 0.2, damageType: 'true' }
// 8% of its max health a second, in a zone
const decay: EffectDef = { type: 'zone', radius: 3, duration: 5, effects: [{ type: 'damage', amount: 0, byMaxHealth: 0.02 }] }
// 30 more for each stack of 'rend' on the target
const rend: EffectDef = { type: 'damage', amount: 20, byStacks: { buff: 'rend', amount: 30 } }Work out an amount in code
amount, duration and radius can be functions, asked for each target.
import type { EffectDef } from '@v12-engine/engine'
const finisher: EffectDef = {
type: 'damage',
amount: (context, target) => 150 + 0.25 * (target ? target.maxHealth - target.health : 0)
}context.caster holds the caster's stats and level; context.effect is the effect landing. The tooltip asks it with no target, so keep it working when target is undefined.
Give or burn mana
import type { EffectDef } from '@v12-engine/engine'
const replenish: EffectDef = { type: 'mana', amount: 75, radius: 5 }
// with manaBurnPack(): takes 60 mana and deals that much as magic damage
const burn: EffectDef = { type: 'manaBurn', amount: 60 }Hit only ground, air, buildings or heroes
import type { EffectDef } from '@v12-engine/engine'
const flak: EffectDef = { type: 'damage', amount: 50, radius: 2, layers: ['air'] }
const siege: EffectDef = { type: 'damage', amount: 200, radius: 1, kinds: ['building'] }
const heroic: EffectDef = { type: 'damage', amount: 300, radius: 4, only: 'heroes' }Take or deal more or less damage
Three core stats every game has, no pack needed, each a share added up from every buff and item and never below none:
import type { BuffDef } from '@v12-engine/engine'
const lastStand: BuffDef = { id: 'lastStand', name: 'Last Stand', duration: 6, stats: { incomingDamage: -0.3 } } // takes 30% less
const withered: BuffDef = { id: 'withered', name: 'Withered', harmful: true, duration: 3, stats: { outgoingDamage: -0.35 } } // deals 35% less
const sundered: BuffDef = { id: 'sundered', name: 'Sundered', harmful: true, duration: 4, maxStacks: 3, perStack: true, stats: { incomingMagicDamage: 0.1 } } // 10% more from spells a stackincomingDamage is applied after armor or magic resist and before shields, with the part of the damage's own type on top (incomingPhysicalDamage, incomingMagicDamage, incomingTrueDamage); outgoingDamage on the source, for attacks and abilities alike. The rules' combat.damageScale is the formula (damageScale), for a game that wants its own.
Heal less: anti-heal
incomingHealing: -0.4 on a debuff: whoever carries it is healed 40% less, by anything, before the beforeHeal hook. The formula is combat.healingScale (healingScale). Brand and Embercrown use it.
Cleave
A blow from up close strikes the enemies around its target too, a part of its damage each, before their armor:
attacks: [{ damagePoint: 0.5, acquisitionRange: 6, cleave: { part: 0.4, radius: 2, angle: 1.57 } }] // the attack's own
{ id: 'cleaving', name: 'Cleaving Attack', cleave: { part: [0.3, 0.45, 0.6], radius: 2.5 } } // a buff's, by levelradius is from the target's edge; angle (radians) a cone that opens from the attacker through the target, all the way round when left out. An attack's and a buff's together: the larger part counts. Who may be cleaved is who the attack could hit; the creeps of a camp are enemies to everyone. combat.cleave is the rule (cleaveOf).
Reference
The damage and healing stats
| Stat | What it does |
|---|---|
incomingDamage | Share by which damage taken is more or less, after armor, before shields; -0.3 is 30% less |
incomingPhysicalDamage, incomingMagicDamage, incomingTrueDamage | The same, of one type, on top |
outgoingDamage | Share by which all damage dealt is more or less, attacks and abilities |
incomingHealing | Share by which healing taken is more or less; -0.4 is an anti-heal |
The sum of the shares never goes below none. Shown in tooltips; the data panel edits them as any stat.
damage, heal, mana
| Field | Type | Default | What it does |
|---|---|---|---|
amount | EffectValue | How much: a number, one per level, or (context, target) => number | |
scaling | { stat: share } | Adds a share of the caster's stats | |
damageType | DamageType | magic | physical, magic or true (damage only) |
how | string or function | How what it kills dies, for the screen (damage only) | |
byMaxHealth | Scaled | Adds a share of the target's max health | |
byCurrentHealth | Scaled | Adds a share of its health now | |
byMissingHealth | Scaled | Adds a share of the health it lacks | |
byStacks | { buff, of?, amount } | Adds amount per stack of a buff on the target (or of: 'caster') | |
byDistance | { per, most? } | Times 1 + per for every cell a missile flew, up to most | |
byDamage | Scaled | Adds a share of the damage that set off a trigger | |
targetScaling | { stat: share } | Adds a share of the target's stats (armor, say) |
Fields every effect has (EffectCommon)
| Field | Type | What it does |
|---|---|---|
radius | EffectValue | Reaches everything within this of where it landed |
shape, length, width, angle | see Areas | Cone, line, ring, arc, rect, cross |
affects | enemies, allies, all | Who an area reaches (enemies for harm, allies for help) |
on | 'caster' | Reaches the caster instead |
layers | Layer[] | ground, air; both when left out |
kinds | EntityKind[] | unit, building, resource |
only | 'heroes' | Heroes alone |
tags | string[] | Only unit types with one of these tags |
ifBuff | string | Only targets carrying this buff |
chance | EffectValue | Happens that share of the time (Conditions) |
when | EffectMoment | Waits for a missile's hit, a dash's landing… (Missiles) |
origin | ProxyOrigin | Goes off from a unit of the caster's (Proxies) |
look | string | Names the effect for its own look (Ability visuals) |
Notes
- A shield's amount: a
buffeffect withamountsets the shield it holds in place of the buff's ownshield. - The tooltip asks code amounts for the caster with no target (
abilityValues). An ability whoseradiusis code should set itsaim, since the screen draws the aim before there's a caster to ask. - In your own effect,
effectAmount(context, effect, target)works out an amount the engine's way andvalueOf(context, value, target)a time or size. resetAttackmakes the caster's next attack come at once.