1. The hero type
Goal: a knight who levels up from kills and spends skill points on abilities. A hero is a unit type with a hero block.
ts
// src/campaign/units.ts
export const knight: UnitTypeDef = {
id: UNIT.knight,
name: 'Knight',
kind: 'unit',
radius: 0.5,
stats: {
health: 650,
healthRegen: 1,
mana: 200,
manaRegen: 1.5,
attackDamage: 42,
attackSpeed: 0.8,
attackRange: 0.6,
armor: 30,
moveSpeed: 4.4
},
sight: 12,
attacks: [{ damagePoint: 0.4, acquisitionRange: 8 }],
hero: {
growth: { stats: { health: 80, mana: 30, attackDamage: 3, armor: 3 } },
learns: ['holyLight', 'warCry', 'judgement'],
maxLevel: 10
},
inventory: 6,
level: 1,
hotkey: 'K'
}| Field | What it does |
|---|---|
growth | Added each level (stats, flat) or multiplied (percent). At level 5: 970 health, 54 damage. |
learns | Abilities a skill point can go to, in HUD order. |
maxLevel | The top level. Experience past it is kept but does nothing. |
inventory | Item slots (chapter 3). |
Earn experience
Each enemy type says what it's worth: xp: 24 on a raider, xp: 600 on Varga, plus bounty: [6, 10] gold. The killing hero gets the experience; each level brings a skill point. In code, grantXp(world, hero, amount) gives experience and learn(world, hero, 'holyLight') spends a point.
Carry him over
When a mission is won, the campaign keeps the hero's type, name, level, experience, unspent points, ability levels and items, and places him in the next mission where the map's hero stands. See The campaign menu.
Next: 2. Two abilities.