Skip to content

Damage and heal ​

The damage, heal and mana effects, and how their amounts grow with levels, stats and the target.

Quick start ​

ts
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.

ts
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.

ts
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.

ts
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.

ts
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.

ts
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.

ts
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 ​

ts
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 ​

ts
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:

ts
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 stack

incomingDamage 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:

ts
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 level

radius 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 ​

StatWhat it does
incomingDamageShare by which damage taken is more or less, after armor, before shields; -0.3 is 30% less
incomingPhysicalDamage, incomingMagicDamage, incomingTrueDamageThe same, of one type, on top
outgoingDamageShare by which all damage dealt is more or less, attacks and abilities
incomingHealingShare 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 ​

FieldTypeDefaultWhat it does
amountEffectValueHow much: a number, one per level, or (context, target) => number
scaling{ stat: share }Adds a share of the caster's stats
damageTypeDamageTypemagicphysical, magic or true (damage only)
howstring or functionHow what it kills dies, for the screen (damage only)
byMaxHealthScaledAdds a share of the target's max health
byCurrentHealthScaledAdds a share of its health now
byMissingHealthScaledAdds 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
byDamageScaledAdds 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) ​

FieldTypeWhat it does
radiusEffectValueReaches everything within this of where it landed
shape, length, width, anglesee AreasCone, line, ring, arc, rect, cross
affectsenemies, allies, allWho an area reaches (enemies for harm, allies for help)
on'caster'Reaches the caster instead
layersLayer[]ground, air; both when left out
kindsEntityKind[]unit, building, resource
only'heroes'Heroes alone
tagsstring[]Only unit types with one of these tags
ifBuffstringOnly targets carrying this buff
chanceEffectValueHappens that share of the time (Conditions)
whenEffectMomentWaits for a missile's hit, a dash's landing… (Missiles)
originProxyOriginGoes off from a unit of the caster's (Proxies)
lookstringNames the effect for its own look (Ability visuals)

Notes ​

  • A shield's amount: a buff effect with amount sets the shield it holds in place of the buff's own shield.
  • The tooltip asks code amounts for the caster with no target (abilityValues). An ability whose radius is code should set its aim, 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 and valueOf(context, value, target) a time or size.
  • resetAttack makes the caster's next attack come at once.