Skip to content

Consumables ​

A consumable is an item with charges: each use casts its ability and spends one; at none it is gone, unless its charges come back. Several of one kind can share a slot.

Quick start ​

ts
{
	id: 'healingDraught',
	name: 'Healing Draught',
	description: 'Regains 240 health over 12 seconds. Five go in a slot',
	tier: 'consumable',
	cost: { gold: 50 },
	charges: 1,
	stack: 5,
	ability: 'drinkHealingDraught',
	stock: { max: 5, restock: 30 },
	tags: ['consumable', 'health', 'sustain', 'early']
}

One draught is one use. Buy a second and it goes into the same slot, two charges; up to five. The shop has five and gets one back every 30 seconds.

Common tasks ​

Give an item several uses ​

charges: 2: two uses, then gone. The slot shows the charges left. Without charges an item stays however often it is used.

Stack several in one slot ​

stack: 3: three of it share a slot, their charges added (three one-charge wards are one slot with three charges). Buying, picking up or being handed another of it goes into the stack while there is room, then into a free slot. stack is of items with charges: what stacks is the charges.

Let the charges come back ​

ts
{ id: 'returnScroll', charges: 1, refill: { shop: true } } // every charge back while the carrier stands at a shop it may trade with
{ id: 'seersDust', charges: 2, refill: { every: 90 } } // one charge back every 90 seconds, wherever it is carried

An item that refills is kept at no charges, waiting; using it then is refused (noCharges). The engine counts the refills every tick, for every carrier.

Make a power-up ​

powerUp: true: used as it is picked up, by walking over it or by the order, and never carried. Its ability is cast by whoever picked it (a rune of healing, a tome of strength). The runes pack (runesPack) says it in code: see Add the classic RTS rules.

Sell the leftovers ​

Selling gives back the game's economy.sellPrice share of the price (0.7 when left out), or the item's own sellRate; a stack sells one at a time. A purchase is taken back whole within the shop's undo seconds: Undo a purchase.

Spend a charge from code ​

spendCharge(world, entity, instance) takes one off and the item away at none, unless it refills. useItem casts the ability and spends the charge as a click does.

Reference ​

FieldWhat it does
chargesUses before it is gone
stackHow many of it go in one slot; one when left out
refill{ shop?: boolean, every?: number }: all back at a shop, one every so many seconds
powerUpUsed as it is picked up, never carried
stockHow many a shop has (max) and the seconds to get one back (restock)

The rules' check flags a stack or a refill on an item without charges. The default set's consumables are the Healing and Mana Draughts, the Elixir of Might, the Sight Ward, Seer's Dust and the Return Scroll: Every default item.

Tests: packages/engine/tests/itemRules.test.ts (stacks, refills, an empty one kept).