Skip to content

BeforeCast beta ​

Interface of @v12-engine/engine

ts
export interface BeforeCast

An ability about to go off, before it is paid for. Change what it costs, or call it off with a reason. Whether the caster has the mana was already checked against the ability's own cost before it wound up: a lower cost here does not let it cast with less than that

Members ​

ability ​

ts
readonly ability: AbilityDef;

The ability being cast

cancel ​

ts
cancel(reason?: MessageRef): void;

Stops it. The reason is what the player is told, where this hook tells them (reason)

cancelled ​

ts
cancelled: boolean;

Whether a handler has called the cast off; set by cancel()

caster ​

ts
readonly caster: Entity;

The unit that casts

cooldown ​

ts
cooldown: number;

Seconds until it can be used again

item ​

ts
readonly item?: ItemInstance;

What it is cast from, for an item's ability

level ​

ts
readonly level: number;

The level of the ability it is cast at

manaCost ​

ts
manaCost: number;

The mana it costs; a handler may change it

point ​

ts
readonly point: Vec2;

The point it is cast at (the target's place for a unit target)

reason ​

ts
reason?: MessageRef;

What the player is told of why it was called off

target ​

ts
readonly target?: Entity;

The unit it is cast on, left out for a point or no target