Skip to content

UnitTypeDef ​

Interface of @v12-engine/engine

ts
export interface UnitTypeDef

The definition of a unit type: a unit, building or resource, with its stats, abilities, costs and what it does

Members ​

abilities ​

ts
abilities?: string[];

Ids of the abilities the unit has

ai ​

ts
ai?: AiHints;

What the computer player takes it for (AiHints): its roles (worker, hall, soldier...), the game's words about it, what it answers. Declared where what the kit infers from the rest of the definition is wrong or cannot be known; inferred otherwise (inferRoles in @v12-engine/engine/ai)

attackCost beta ​

ts
attackCost?: Record<string, number>;

What each of its attacks costs of its pools (pools), in a game with the resources pack: with less than that it does not attack (Jhin's four shots, then the reload)

attacks ​

ts
attacks?: AttackDef[];

How it attacks, as the classic RTS two weapons: against each target the first that reaches it (its targets), or the one the game picks (RuleSettings.combat.pickAttack). It swings one at a time: a hit's cooldown is that attack's, whichever swings next. None for what does not attack

basedOn ​

ts
basedOn?: string;

The definition this one is a copy of, made from the data (copyOf in a data.json, the editor's Copy as new): what it is drawn, heard and pictured as where the game gives it no look of its own

blocksMissiles beta ​

ts
blocksMissiles?: 'enemies' | 'all';

Stops the missiles of abilities that come at it, in a game with the ground objects pack (groundObjectsPack): those of its enemies (enemies), or of everyone (all); they are gone where they meet it, with nothing happening (Yasuo's Wind Wall, a line of them: EffectFields.line). A missile thrown (arc) flies over it

bounty ​

ts
bounty?: [min: number, max: number];

Gold for whoever kills it, rolled between the two

buildRate beta ​

ts
buildRate?: (builders: number, world: World, structure: Entity) => number;

How fast it goes up with so many builders at it, 1 being one builder's: the game's rule (RuleSettings.production.buildRate) for every type when left out

builds ​

ts
builds?: string[];

Building types this unit can construct

buildsItself ​

ts
buildsItself?: boolean;

Goes up on its own once it is put down, as the undead summon theirs: the builder is free at once, and nobody helps (RuleSettings.production.buildRate of one builder, all the way). The same as construction: 'self'

buildTime ​

ts
buildTime?: number;

Seconds to build or train

builtOn ​

ts
builtOn?: ResourceId;

Goes up on a resource of this kind, over it, of the same footprint: the undead's cursed gold mine. The resource is its owner's alone from then on (canHarvest); one that takes what is gathered there (dropOff) has its owner's workers gather at it from around it, handing in where they stand, as many at once as gatherers says. It goes down with the resource, which stands again where it is destroyed

burns beta ​

ts
burns?: boolean | BurnsDef;

Whether it burns, in a game with the burning pack (burningPack), and how (BurnsDef: for how long, what it leaves, whether its wood is kept, what kind of burning it is): true as the pack says, false never. What can be felled (fellable: trees) burns when left out; anything else does not

burst beta ​

ts
burst?: {
        ability: string;
        chain?: number;
    };

What happens where it dies, in a game with the ground objects pack (groundObjectsPack): an ability of the game's goes off there in its maker's name (ability), and those of its type and owner within chain of it die too and go off in turn: Gangplank's barrels (uses: 3 counts the hits that bring one down)

construction beta ​

ts
construction?: 'builder' | 'self' | 'instant';

How it goes up once it is put down: with builders at it (builder, the more the faster, as buildRate says), on its own with the builder free at once (self, the undead's), or whole at once (instant: a wall piece, a ward). builder when left out (self with buildsItself)

corpse ​

ts
corpse?: boolean | ((world: World, entity: Entity) => boolean | number);

Whether it leaves a corpse when it dies, for spells to use (see raiseDead). Units do, unless this says no: machines, spirits. Decided for each death in code: false for none, true or seconds for one (how long it lies)

cost ​

ts
cost?: Cost;

What it costs to build or train, in resources

destructible ​

ts
destructible?: boolean;

Rocks, a barricade, a gate to break down, in a game with the destructibles pack (destructiblesPack): it stands in the way as any building does until it is brought down, and any unit whose attack reaches it attacks it when told to, never of its own accord

dropOff ​

ts
dropOff?: boolean | ResourceId[];

Accepts harvested resources: all of them, or only the ones listed

drops ​

ts
drops?: {
        item: string;
        chance: number;
    }[] | ((world: World, entity: Entity, killer?: Entity) => string[]);

What it may leave behind when it dies, each with its chance from 0 to 1. Or code: the items it leaves, decided as it dies (one random level-3 item; more for a stronger killer)

fellable ​

ts
fellable?: boolean;

Destroyed by attacks that fell, like a tree by a catapult, whatever else it withstands

flying ​

ts
flying?: boolean;

Flies: over cliffs, trees and buildings, out of reach of whatever cannot hit the air

footprint ​

ts
footprint?: {
        w: number;
        d: number;
    };

Size in grid cells. Required for buildings and resources

gatherers ​

ts
gatherers?: number;

Workers that gather at once at it, when it stands on a resource (builtOn): 5 when left out

harvester ​

ts
harvester?: {
        capacity: number;
        gatherTime: number;
        ids?: ResourceId[];
    };

Makes it a worker that gathers: how much it carries, seconds a load takes, and which resources it gathers

hero ​

ts
hero?: HeroDef;

Makes the type a hero, with its levels and the rest of HeroDef; none for a unit that is not one

hires ​

ts
hires?: string[];

Units it hires out to whoever has one of theirs there, by type: a tavern's heroes, a dock's boats. Their cost, and a hero only once (see hire). Neutral, it hires to everyone

hotkey ​

ts
hotkey?: string;

Key used in the command card when building or training this type

id ​

ts
id: string;

The type's id, shared by every game: give it a prefix of the game's

ignored ​

ts
ignored?: boolean;

Nobody picks a fight with it on their own: it is only attacked when someone is told to

initialMana ​

ts
initialMana?: number;

Mana it comes into the world with. All of it when left out

inventory ​

ts
inventory?: number;

Slots for items. Heroes have six

invisible ​

ts
invisible?: {
        after?: number;
    };

Enemies cannot see it, after seconds after it came into the world, unless something reveals it to them

invulnerable ​

ts
invulnerable?: boolean;

Whether it cannot be hurt

kind ​

ts
kind: EntityKind;

Whether the type is a unit, a building or a resource

level ​

ts
level?: number;

How dangerous it is, for creeps. Shown to the player, and added up per camp

lifetime ​

ts
lifetime?: number;

Seconds it lasts before it is gone by itself, like a ward

name ​

ts
name: string;

What the player sees the type called

ts
naval?: boolean;

Goes on deep water and nowhere else: a boat. Sent onto land, it goes to the water nearest where it was sent. On the ground, as far as what can hit it goes

pools beta ​

ts
pools?: Record<string, PoolDef>;

Resources of its own beside mana, in a game with the resources pack (resourcesPack), by id: energy, fury, heat, flow, ammo (PoolDef: how much at most, at the start, back each second, lost each second when nothing used it, gained by walking, refilled when empty, and buffs at thresholds). What its abilities cost of them (AbilityDef.cost) and give (gain), what its attacks cost (attackCost), the gain effect

provides ​

ts
provides?: string[];

Building types this one counts as, for requirements. A keep is a town hall too

race ​

ts
race?: string;

The race it is of (Rules.races): only its players may build or train it. Everyone's when left out: creeps, what is shared. What a player may have is the game's to change (the available hook)

radius ​

ts
radius: number;

Collision radius

recovers ​

ts
recovers?: number;

Seconds after it was last hurt that it is whole again, all at once

requires ​

ts
requires?: string[];

Building types the player has to have before this can be built or trained

researches ​

ts
researches?: string[];

Upgrades that can be researched here

resource ​

ts
resource?: {
        id: ResourceId;
        amount: number;
        slots: number;
        entered?: boolean;
        gatherTime?: number;
    };

Makes it a deposit that can be gathered from: which resource, how much, how many workers fit and how they gather

revives ​

ts
revives?: boolean;

Brings fallen heroes back

sells ​

ts
sells?: string[];

Items this building sells

sight ​

ts
sight: number;

Vision radius by day

sightNight ​

ts
sightNight?: number;

Vision radius at night. A part of the one by day when left out

spellImmune ​

ts
spellImmune?: boolean | ((world: World, entity: Entity) => boolean);

Immune to spells: abilities do not touch it, of friends or enemies, unless they say they get through (piercesImmunity). Decided in code whenever it is asked: while it stands on holy ground. The player's screen only knows the plain true of it, to grey out a target; the simulation goes by the code

stats ​

ts
stats: Partial<Stats> & {
        health: number;
    };

What it starts with. What is left out is 0, a critical strike is worth 175%

supply ​

ts
supply?: number | Record<string, number>;

Supply (food) it takes up for as long as it lives, and while it is being trained: of the one pool there always is, or by pool ({ supply: 2, command: 1 }: supply that one, the rest the game's own, RuleSettings.supply.pools). Read with supplyOf and supplyPoolsOf

supplyGiven ​

ts
supplyGiven?: number | Record<string, number>;

What it provides once it stands finished: of the one pool, or by pool, as supply is said. Read with supplyGivenOf and supplyPoolsGivenOf

tags beta ​

ts
tags?: string[];

Words of the game's for what it is (undead, mechanical, ward): what an effect's tags, an ability's targets.tags and an if's condition (UnitCondition.tags) go by

targetableBy ​

ts
targetableBy?: string[];

Ids of the abilities that alone may target it (a soul that only possess takes). Nothing else may: not an ability clicked on it or used on it by the AI, nor an attack, nor the area of one, nor a heal; the ones named get through the target rules as they say (targets). It is untouched as invulnerable is, but for them

threat ​

ts
threat?: number;

Higher values are picked first when acquiring targets

trains ​

ts
trains?: string[];

Unit types this building can train

transport ​

ts
transport?: {
        capacity: number;
        takes?: (def: UnitTypeDef) => boolean;
        armed?: number | ((world: World, building: Entity, inside: Entity[]) => number);
    };

Carries others: a boat, or a building they go into (a garrison). takes says who may get in; armed, for a building with an attack, is the attack damage each one inside adds, and it attacks only while someone is inside, as an orc burrow does. What a building holds comes out when it falls; what a boat holds goes down with it

trigger beta ​

ts
trigger?: GroundTrigger;

A trap, a mine, a pickup, in a game with the ground objects pack (groundObjectsPack): an ability of the game's that goes off as one of those it is for comes within its radius (GroundTrigger)

trueSight beta ​

ts
trueSight?: number;

Finds what of its enemies is invisible or camouflaged within this far of it, for its team, for as long as it stays that near, in a game with the vision pack (visionPack): a Sentry Ward's true sight, a Control Ward

turnRate ​

ts
turnRate?: number;

How fast it turns, in radians a second: the game's for every unit (RuleSettings.movement.turnRate, 12) when left out

undying ​

ts
undying?: boolean;

Takes damage like anything else but never dies of it: it is left with a little health, like something to practise on

upgradesTo ​

ts
upgradesTo?: string | string[];

Type this building can be upgraded into, where it stands; or the types, for one that may become one of several (a keep that turns into a castle or a citadel, upgradesOf). The first is what an upgrade is into where none is named

use beta ​

ts
use?: GroundUse;

Something others click on, in a game with the ground objects pack (groundObjectsPack): a unit of those it is for told to it (right-clicked) walks up to it and uses it, an ability of the game's going off (GroundUse): Thresh's lantern, Bard's portals

uses ​

ts
uses?: number;

Goes down after this many attacks and spells, whatever they deal: its health counts hits, and its most health is this whatever its stats.health or what changes its stats say

wall beta ​

ts
wall?: {
        family: string;
        gate?: boolean;
    };

A piece of wall (wallsPack): it joins with the pieces of its family beside it, and its shape (single, end, straight, corner, tee, cross) is its look. A gate (gate) joins as a piece does, turned along its line, and its owner opens and shuts it for everyone (wallGateCommand): its look open or shut. Pieces join by their footprints, so a gate wider than a cell sits in a line of pieces of one: one of a cell lets nobody through, the ground about a wall being kept off by the radius of what walks (a gatehouse of 3 by 3 lets through what is 1 wide)

waygate ​

ts
waygate?: boolean;

A waygate, in a game with the portals pack (portalsPack): a unit told to it walks in and is at once where it leads (its waygate field, a point of the map; setWaygate in code)

xp ​

ts
xp?: number;

Experience heroes get for killing it. Follows from its cost when left out