Skip to content

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 ​

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

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

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

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

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

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

FieldWhat it does
idWhat heroes' callings and items' suits name it by
nameWhat the player sees
descriptionA few words for a tooltip
iconAn image's address, or a glyph's name
colorA CSS colour; the HUD's accent when left out

The engine's eight ​

CallingPlays asLike
VanguardStarts fights and takes the hitsTank, initiator
KeeperHeals, shields and saves alliesEnchanter support
BinderStuns, roots and holds enemies downCatcher, controller
ReaverLasting damage up close, and drainsFighter, bruiser
StalkerPicks off one target and gets outAssassin
RangerSteady damage from range, stronger lateMarksman
ArcanistBursts and areas of damage with spellsMage
RoamerClears camps and moves about the mapJungler

Where callings are read ​

WhoWhat
heroesPack({ callings })The game's list; HeroSettings.callings
HeroDef.callingsA hero's, with strengths
ItemDef.suitsWhat an item is for
The shop windowFor this hero, the calling chips
The HUDThe hero panel, the altar's and tavern's buttons, the portrait tooltip
data.jsoncallings (rename, add), defaults.callings (choose)
The editorData › Callings, Data › Default sets, the item tree's filter

Tests: packages/engine/tests/callings.test.ts, packages/engine/tests/dataTagsCallings.test.ts.