Skip to content

CombatState beta ​

Interface of @v12-engine/engine

ts
export interface CombatState

What a unit keeps of its fighting: cooldown, swing, targets and recovery

Members ​

autoTarget ​

ts
autoTarget: EntityId;

Target picked by the unit itself rather than by an order

cooldown ​

ts
cooldown: number;

Seconds until the next attack may start

engaged ​

ts
engaged?: EntityId;

What it is fighting or closing in on, whoever picked it: 0 for nothing (see engagement.ts)

guard ​

ts
guard: Vec2 | null;

Where an idle unit returns to after chasing

helpedAt ​

ts
helpedAt?: number;

The tick the allies of whoever it hit were last called to help (RuleSettings.combat.helpRange), so that they are asked once in a while, not by every blow. Unset until it hits someone

lastAttacker ​

ts
lastAttacker: EntityId;

The entity that last hit it

passive ​

ts
passive: boolean;

Does not pick fights of its own accord until it gets an order (set by a game's rules; stop no longer sets it)

recovery ​

ts
recovery?: number;

Seconds left of the recovery after its last blow (AttackDef.recovery), while what it is told waits: none when it has none

shunned ​

ts
shunned?: [EntityId, number][];

Targets it left alone because it could not get at them, and until when, in world time

slot ​

ts
slot?: number | null;

The spot it holds around that, as an angle seen from it. Null when it has none: it flies, it hits a building

swing ​

ts
swing: number;

Seconds until the running swing lands. 0 when not swinging

swingTarget ​

ts
swingTarget: EntityId;

The entity the running swing is aimed at

weapon ​

ts
weapon?: number;

Which of its attacks the running swing, or the last, is of, by place (UnitTypeDef.attacks): the first when left out, as for every unit with one. It swings one at a time, and waits out the cooldown of the one that hit