Make my own item tree
An item tree is items whose from names their parts: basics build into intermediates, intermediates into legendaries. The price of a recipe is for all of it; what the buyer carries is used up and taken off. Start from the engine's fifty, or from nothing.
// in src/items.ts
import type { ItemDef, TagDef } from '@v12-engine/engine'
export const items: ItemDef[] = [
// the parts: one thing each
{ id: 'ironSword', name: 'Iron Sword', description: '+15 attack damage', tier: 'basic', cost: { gold: 350 }, bonus: { stats: { attackDamage: 15 } }, tags: ['attack'] },
{ id: 'rubyShard', name: 'Ruby Shard', description: '+150 health', tier: 'basic', cost: { gold: 400 }, bonus: { stats: { health: 150 } }, tags: ['health'] },
{ id: 'boots', name: 'Boots', description: '+0.6 move speed. One pair', tier: 'basic', cost: { gold: 300 }, bonus: { stats: { moveSpeed: 0.6 } }, group: 'boots', tags: ['movement'] },
// built from them
{
id: 'brutalAxe',
name: 'Brutal Axe',
description: '+40 attack damage',
tier: 'intermediate',
cost: { gold: 1100 },
from: ['ironSword', 'ironSword'],
bonus: { stats: { attackDamage: 40 } },
tags: ['attack']
},
{
id: 'giantsBelt',
name: 'Giant’s Belt',
description: '+350 health',
tier: 'intermediate',
cost: { gold: 1000 },
from: ['rubyShard', 'rubyShard'],
bonus: { stats: { health: 350 } },
tags: ['health']
},
// what it leads to: a unique effect that asks for a way to play
{
id: 'bloodreaver',
name: 'Bloodreaver',
description: '+60 attack damage, +400 health. Frenzy: the lower its health, the faster it attacks',
tier: 'legendary',
cost: { gold: 3000 },
from: ['brutalAxe', 'giantsBelt'],
bonus: { stats: { attackDamage: 60, health: 400 } },
passive: 'bloodreaverFrenzy',
unique: 'frenzy',
tags: ['attack', 'health', 'sustain'],
suits: ['reaver']
}
]
export const tags: TagDef[] = [
{ id: 'attack', name: 'Attack', color: '#e07a4f', filter: true },
{ id: 'health', name: 'Health', color: '#4fbf6a', filter: true },
{ id: 'movement', name: 'Movement', color: '#d8d06a', filter: true },
{ id: 'sustain', name: 'Sustain', color: '#3fae8f', filter: true }
]// in src/rules.ts
export const rules: Rules = { ..., items, tags, units: [{ id: 'armory', kind: 'building', sells: items.map((item) => item.id) /* ... */ }] }Done: the armory sells six items; a hero with an Iron Sword pays 750 for the Brutal Axe and the sword becomes part of it; Bloodreaver is 3,000 all told, 900 with both parts carried. The shop window shows each item's build tree and the chips Attack, Health, Movement, Sustain. The 'bloodreaverFrenzy' passive is an ability with target: 'passive' (Legendaries).
Start from the engine's tree instead
import { defaultItemSet, useDefaults } from '@v12-engine/engine'
export const rules = useDefaults(own, [defaultItemSet], { items: { except: ['sightWard'], with: [myBlade], change: { boots: { cost: { gold: 250 } } } } })All fifty, with their abilities, buffs, units and tags, less one, plus one of yours, one changed (The default set). Or in data.json: "defaults": { "items": { "except": ["sightWard"] } }, and in the editor, Data › Default sets.
Draw it and check it
The editor's Item tree (Data panel) draws the columns by tier with each price and its parts' sum, red where a recipe costs less than its parts, a dot where the rules' check has something to say; drag an item onto another to make it a part (Data panel). The check (checkRules, Data › Problems) names a loop, a missing part, a price under its parts, an item nothing sells or drops, and a recipe that breaks its group's limit (Items: check the tree).
Reference
| Field | What it does |
|---|---|
from | The parts; the same id twice for two of it |
cost | The price of all of it; parts carried are taken off (priceOf) |
tier | consumable, starter, basic, intermediate, legendary, relic |
group | One pair of boots: group: 'boots', the limit 1 unless groupLimit or settings.items.groups says |
unique | The legendary's passive name: two sharing it work once |
suits | The callings the shop suggests it for |
Prices the engine's tree sits in: basics 250–1,000, intermediates 900–1,600, legendaries 2,500–3,500. Every default item.