Callings
A calling is what a hero is good at: Vanguard, Keeper, Binder, Reaver, Stalker, Ranger, Arcanist, Roamer. A hero is not boxed into one: it has several, each with a strength from 1 to 3 (Duskblade is Stalker 3 and Roamer 2). Callings lock nothing. They guide: the shop's suggestions and filters (suits on an item), the tooltips, the hero panel, and the computer players. They are data (CallingDef), so a game renames them, adds to them or replaces them, as with items.
Quick start
import { heroesPack, type Rules } from '@v12-engine/engine'
export const rules: Rules = {
id: 'my-game',
name: 'My game',
units: [
{
id: 'oathbreaker',
name: 'Oathbreaker',
kind: 'unit',
radius: 0.5,
sight: 12,
stats: { health: 660, attackDamage: 54, attackSpeed: 0.625, attackRange: 0.6, moveSpeed: 4.25 },
hero: { growth: { stats: { health: 99 } }, learns: [], callings: { vanguard: 3, keeper: 1 } }
}
],
packs: [heroesPack()]
}The heroes pack brings the engine's eight callings when told none. Oathbreaker shows a Vanguard 3 and a Keeper 1 on its panel, and the shop puts items that suit Vanguards first for him.
Common tasks
Give a hero callings
hero.callings: { stalker: 3, roamer: 2 }. Strengths are 1 (a little of it), 2, 3 (what it is above all). The rules' check names a calling the game does not have.
Use the engine's eight
Nothing to do: heroesPack() has them (Every calling). defaultCallings() gives the list anew, to read or change.
Rename one
heroesPack({ callings: defaultCallings().map((calling) => (calling.id === 'vanguard' ? { ...calling, name: 'Bulwark', description: 'Holds the line' } : calling)) })Or in data.json: "callings": { "vanguard": { "name": "Bulwark" } } (the editor's Data › Callings writes it). The id stays, so items' suits and heroes' callings still match.
Add one, or leave one out
heroesPack({ callings: [...defaultCallings().filter((each) => each.id !== 'roamer'), { id: 'siegemaster', name: 'Siegemaster', description: 'Brings buildings down', icon: 'siege', color: '#c08040' }] })icon is an image's address or the name of a glyph the HUD draws (registerGlyph); the engine draws its own eight by their ids; a calling with neither shows the first letter of its name.
Replace them all
heroesPack({ callings: [{ id: 'tank', name: 'Tank' }, { id: 'healer', name: 'Healer' }, { id: 'carry', name: 'Carry' }] })Or choose with the set chooser, so that data.json and the editor can choose again: useDefaults(rules, [defaultCallingSet()], { callings: { only: ['vanguard', 'keeper'], with: [tank] } }) (The default set).
Change them while the rules are made
withCallings(rules, callings) gives the rules with these callings in the place of theirs: the heroes pack remade with them, its own options kept. What a data.json's callings comes to.
Read them in code
import { callingsOf, heroCallings, callingStrength } from '@v12-engine/engine'
callingsOf(world.registry) // the game's callings, CallingDef each
heroCallings(world.registry, hero.def) // [{ calling, strength }], strongest first
callingStrength(hero.def, 'stalker') // 3, or 0 for one it does not haveOn the screen, the hero panel's info carries them as CallingTags (HeroPanelInfo.callings), the train and hire buttons and the portraits too.
Say what suits a calling
An item's suits: ['vanguard', 'keeper'] is what the shop suggests it for (Legendaries: say what suits whom). A hero's recommended row is drawn from what suits its callings, the strongest first.
Reference
CallingDef
| Field | What it does |
|---|---|
id | What heroes' callings and items' suits name it by |
name | What the player sees |
description | A few words for a tooltip |
icon | An image's address, or a glyph's name |
color | A CSS colour; the HUD's accent when left out |
The engine's eight
| Calling | Plays as | Like |
|---|---|---|
| Vanguard | Starts fights and takes the hits | Tank, initiator |
| Keeper | Heals, shields and saves allies | Enchanter support |
| Binder | Stuns, roots and holds enemies down | Catcher, controller |
| Reaver | Lasting damage up close, and drains | Fighter, bruiser |
| Stalker | Picks off one target and gets out | Assassin |
| Ranger | Steady damage from range, stronger late | Marksman |
| Arcanist | Bursts and areas of damage with spells | Mage |
| Roamer | Clears camps and moves about the map | Jungler |
Where callings are read
| Who | What |
|---|---|
heroesPack({ callings }) | The game's list; HeroSettings.callings |
HeroDef.callings | A hero's, with strengths |
ItemDef.suits | What an item is for |
| The shop window | For this hero, the calling chips |
| The HUD | The hero panel, the altar's and tavern's buttons, the portrait tooltip |
data.json | callings (rename, add), defaults.callings (choose) |
| The editor | Data › Callings, Data › Default sets, the item tree's filter |
Tests: packages/engine/tests/callings.test.ts, packages/engine/tests/dataTagsCallings.test.ts.