Skip to content

WorldEvents beta ​

Interface of @v12-engine/engine

ts
export interface WorldEvents

The events a world emits (world.events), by name, each with its payload; what hooks do not cover and listeners and sessions hear

Members ​

abilityCast ​

ts
abilityCast: {
        caster: Entity;
        ability: AbilityDef;
        level: number;
        target?: Entity;
        point: Vec2;
        charged?: boolean;
    };

An ability was cast: by whom, at what level, at which target or point, and whether it used a charge

abilityImpact ​

ts
abilityImpact: {
        caster: Entity;
        ability: AbilityDef;
        level: number;
        target?: Entity;
        point: Vec2;
        radius: number;
        impact?: string;
        from?: Vec2;
        effect?: EffectDef;
    };

What an ability set off arrived: a missile hit, a rush ended, the time was up. from: where it went off from, when not the caster (EffectContext.origin). effect: the effect of the ability whose arrival it is (a missile, a delay, a zone at its end), where the list that landed is one of the ability's

attackStarted ​

ts
attackStarted: {
        attacker: Entity;
        target?: Entity;
        weapon: number;
    };

weapon: which of its attacks swings, by place (UnitTypeDef.attacks)

boarded ​

ts
boarded: {
        passenger: Entity;
        transport: Entity;
    };

A unit got into a transport (UnitTypeDef.transport), or out of one

bounty ​

ts
bounty: {
        entity: Entity;
        player: PlayerId;
        amount: number;
    };

A player was paid a bounty of this amount for an entity's death

buffApplied ​

ts
buffApplied: {
        target: Entity;
        buff: string;
        level: number;
        source?: Entity;
        renewed: boolean;
        previousLevel?: number;
    };

A buff was put on, or put on again (renewed, with the level it had before: previousLevel)

buffRemoved ​

ts
buffRemoved: {
        entity: Entity;
        buff: string;
        expired: boolean;
    };

A buff came off: it ran out (expired), or was taken off. Not for the buffs of something that dies

cameraOrdered ​

ts
cameraOrdered: {
        player: PlayerId;
    } & Pick<CameraOrder, 'pan' | 'shake'>;

The rules pan or shake one player's camera (see cameraFor)

campCleared ​

ts
campCleared: {
        camp: Camp;
    };

Every creep of a camp is gone. It comes back after a while, when it says so (see Camp.respawn)

campReturned ​

ts
campReturned: {
        camp: Camp;
    };

A camp cleared came back, its creeps where they stood (see respawnCamp)

castCancelled ​

ts
castCancelled: {
        caster: Entity;
        ability?: AbilityDef;
    };

A wind-up called off before it went off: the caster stunned, killed, or ordered elsewhere. ability: the one wound up, where it is still known (an item's, gone with the item, is not)

castStarted ​

ts
castStarted: {
        caster: Entity;
        ability: AbilityDef;
        point?: Vec2;
        duration: number;
    };

duration: seconds of the wind-up

cellsChanged ​

ts
cellsChanged: {
        layer: string;
        cells: number[];
        value: number;
        over?: number;
    };

Cells of a layer (Terrain.cells) were set to a value (setCells): told to the players who see them, the others as they come into sight (cellsSeen). over: the seconds the screens ease into it over, where the rules said (grass growing back)

cellsSeen ​

ts
cellsSeen: {
        team: number;
        layer: string;
        cells: number[];
        value: number;
    };

Cells of a layer that changed out of a team's sight came into it (TeamMemory.cells): told to that team's players, the cells at value now

channelEnded ​

ts
channelEnded: {
        caster: Entity;
        ability: AbilityDef;
        interrupted: boolean;
    };

A channelled ability stopped being kept up; interrupted when it was broken off

channelStarted ​

ts
channelStarted: {
        caster: Entity;
        ability: AbilityDef;
        duration: number;
    };

A channelled ability started to be kept up, or ended: done, or interrupted

chatted ​

ts
chatted: {
        player: PlayerId;
        text: string;
        to: ChatAudience;
        by?: string;
    };

A player said a line (see chat): to their side, or to everyone

checkpoint ​

ts
checkpoint: {
        label: Message;
    };

The rules marked a moment to start again from, like the start of a wave: a session keeps a save of it

chopped ​

ts
chopped: {
        worker: Entity;
        source: Entity;
    };

A worker struck the tree it is working on

cinematicChoice ​

ts
cinematicChoice: CinematicChoice;

A player picked an answer of a cinematic's choice, as their screen said (see cinematicChose)

cinematicCue ​

ts
cinematicCue: CinematicCue;

The rules play one of the view's cinematics on the screens of some players, or everyone's (see playCinematic)

cinematicCued ​

ts
cinematicCued: CinematicCueSent;

The rules cue the cinematic playing on some screens, or everyone's (see cueCinematic)

cinematicEnded ​

ts
cinematicEnded: CinematicEnded;

A cinematic the rules played is over on a player's screen, as their screen said (see cinematic's wait)

commandHandled ​

ts
commandHandled: {
        player: PlayerId;
        seq: number;
        refusal?: Message;
    };

A command that came with a number of its sender's (seq) was carried out: refused with the first error the player was told, or not

commandRejected ​

ts
commandRejected: {
        player?: PlayerId;
        type?: string;
        kind: RejectedKind;
        reason: string;
    };

A command turned away (RejectedKind: why, for what counts them, as a server's cheat counter does), with the reason in words for the log

constructionCancelled ​

ts
constructionCancelled: Entity;

A construction was called off by its owner: it dies next, with the reason cancelled

constructionFinished ​

ts
constructionFinished: Entity;

A building was completed

constructionStarted ​

ts
constructionStarted: Entity;

A building's construction began, its site placed

damaged ​

ts
damaged: {
        target: Entity;
        source?: Entity;
        amount: number;
        type: DamageType;
        crit: boolean;
        attack: boolean;
        ability?: string;
        tags?: string[];
    };

Damage was dealt to a target: how much, of which type, by whom and by what ability or attack

enteredArea ​

ts
enteredArea: {
        area: string;
        entity: Entity;
    };

A unit walked into an area of the game (Rules.areas)

entityDied ​

ts
entityDied: {
        entity: Entity;
        killer?: Entity;
        attack: boolean;
        cause?: DeathCause;
        how?: string;
        reason: DeathReason;
    };

cause: the blow, for what died of damage. how: what the rules made of the death in the death hook, for the screen to show ('exploded', 'burned')

entityMorphed ​

ts
entityMorphed: {
        entity: Entity;
        from: string;
    };

An entity became another type: from, what it was

entityRemoved ​

ts
entityRemoved: Entity;

An entity left the world, dead or taken away

entitySpawned ​

ts
entitySpawned: Entity;

An entity was added to the world

environmentChanged ​

ts
environmentChanged: {
        environment: MapEnvironment;
        over?: number;
    };

over: the seconds the screens ease into it over, where the rules said

exchanged ​

ts
exchanged: {
        player: PlayerId;
        sold: string;
        sent: number;
        bought: string;
        received: number;
    };

A player traded one resource for another at a rate (see exchange): how much of what went, and how much of what came

fxStarted ​

ts
fxStarted: FxCue;

The rules play one of the view's effects at a place or on an entity, for everyone who sees it (see world.fx)

fxStopped ​

ts
fxStopped: {
        id: number;
        fade?: number;
    };

The rules stop an effect they played (see world.stopFx)

gameOver ​

ts
gameOver: {
        winner: number;
    };

The game ended; winner is the winning team

groundReshaped ​

ts
groundReshaped: {
        patch: TerrainPatch;
    };

A part of the ground was reshaped (reshapeGround): as it is now, told to every player

gusted ​

ts
gusted: {
        x: number;
        z: number;
        gust: WindGust;
    };

A gust of wind blew at a place (gust, WindGust): where, and the gust. Told to the players who see the place, for their screens to bend the grass and bushes there

healed ​

ts
healed: {
        target: Entity;
        source?: Entity;
        amount: number;
    };

A target was healed by an amount, by a source when it has one

heroLevelUp ​

ts
heroLevelUp: {
        hero: Entity;
        level: number;
    };

A hero reached a new level

heroRevived ​

ts
heroRevived: Entity;

A fallen hero was brought back

impact ​

ts
impact: {
        x: number;
        z: number;
        radius: number;
        owner: PlayerId;
    };

An attack that hits an area came down

inventoryChanged ​

ts
inventoryChanged: {
        entity: Entity;
    };

What a unit carries changed: an item given, taken, bought, sold, used up, or a hero carried in with theirs

itemDropped ​

ts
itemDropped: GroundItem;

An item came to lie on the ground

itemPicked ​

ts
itemPicked: {
        entity: Entity;
        item: ItemInstance;
    };

An entity picked an item up from the ground

itemUndone ​

ts
itemUndone: {
        entity: Entity;
        item: string;
        shop: number;
    };

A hero took a purchase back at a shop (undoBuy): what it cost came back, the parts it used up came back

leftArea ​

ts
leftArea: {
        area: string;
        entity: Entity;
    };

A unit walked out of one. What dies in an area is not said to leave it

lineEnded ​

ts
lineEnded: {
        id: number;
        to: PlayerId[];
    };

A line was skipped by whom it was said to: it ends early for them

lineSaid ​

ts
lineSaid: SaidLine;

Someone said a line, to some players or everyone (see world.dialog)

manaChanged ​

ts
manaChanged: {
        entity: Entity;
        amount: number;
        ability?: string;
        source?: Entity;
    };

A unit's mana changed by something it did or was given: spent on a cast (amount below 0, ability the one cast) or given by an effect (above 0). Not its regeneration, which would be every tick

messageSent ​

ts
messageSent: {
        player: PlayerId;
        message: Message;
        kind: MessageKind;
        seconds?: number;
    };

Feedback for a player, like "Not enough gold": what the client finds the words for

missed ​

ts
missed: {
        x: number;
        z: number;
        source?: Entity;
        target?: Entity;
    };

An attack went wide. Where it would have landed, and whom it was for

missileHit ​

ts
missileHit: {
        missile: Missile;
        target: Entity;
    };

A missile passed through a target

missileRemoved ​

ts
missileRemoved: Missile;

A missile ended or was taken away

missileSpawned ​

ts
missileSpawned: Missile;

A missile was sent on its way

morphCancelled ​

ts
morphCancelled: {
        entity: Entity;
        into: string;
    };

That was called off, or the building died before it was done

morphedBack ​

ts
morphedBack: {
        entity: Entity;
        form: string;
        why?: MorphBack | (string & {});
    };

A hero in a form turned back into what it was (leaveForm): form, the type it was in; why, what turned it back

morphStarted ​

ts
morphStarted: {
        entity: Entity;
        into: string;
        time: number;
    };

A building started to turn into another type (UnitTypeDef.upgradesTo), over time seconds

objectiveChanged ​

ts
objectiveChanged: {
        player: PlayerId;
        objective: ObjectiveState;
        was?: ObjectiveStatus;
    };

An objective of a player was given (was undefined), got further along, was done or failed

pauseAsked ​

ts
pauseAsked: {
        player: PlayerId;
        seconds: number;
        left: number;
    };

A player asked for a pause, and the rules let them (see askPause): whoever runs the world pauses it, for seconds at most

pinged ​

ts
pinged: {
        player: PlayerId;
        point: Vec2;
        kind: PingId;
        to: ChatAudience;
        by?: string;
    };

A player marked a spot for their allies, or for everyone (see ping)

playerDefeated ​

ts
playerDefeated: Player;

A player was defeated, out of the game

playerSurrendered ​

ts
playerSurrendered: {
        player: PlayerId;
    };

A player gave up (see surrender): playerDefeated follows

projectileRemoved ​

ts
projectileRemoved: Projectile;

A projectile landed or was taken away

projectileSpawned ​

ts
projectileSpawned: Projectile;

A projectile was fired

researchFinished ​

ts
researchFinished: {
        building: Entity;
        upgrade: string;
        level: number;
    };

A building finished researching an upgrade, to this level

resourceChanged ​

ts
resourceChanged: {
        entity: Entity;
        kind: string;
        amount: number;
        reason?: string;
    };

A pool of a game's own on a unit (rage, energy, charges) changed: emitted by the game's rules (world.events.emit(resourceChanged, …)), heard by the screens of the unit's owner and allies (resource)

resourcesDeposited ​

ts
resourcesDeposited: {
        entity: Entity;
        player: PlayerId;
        kind: ResourceId;
        amount: number;
        upkeep?: number;
    };

A worker handed in what it carried: amount as it went into the purse, upkeep what upkeep took of it at the door

resourcesSpent ​

ts
resourcesSpent: {
        player: PlayerId;
        cost: Cost;
        on: SpentOn;
        id?: string;
        refund: boolean;
    };

A player paid for something (spend), or was given back what they paid (refund, giveBack): on what (unit, upgrade, structure, item, hire, repair... or a game's own word), and its id

rustled ​

ts
rustled: {
        layer: string;
        entity: Entity;
        x: number;
        z: number;
        entered: boolean;
        teams?: number[];
    };

One hidden in a layer of cells moved in it, or stepped into it (ConcealmentOptions.rustle): told to the teams it names that do not see it (all of them, where none are named), where they see the ground, as a shake of what the layer draws there

swingCancelled ​

ts
swingCancelled: {
        attacker: Entity;
        target?: Entity;
        weapon: number;
    };

A swing called off before its blow (cancelSwing): the unit was told something else, its target went, it was stunned. What it was swinging at, where it was at something, and with which of its attacks

teamChanged ​

ts
teamChanged: {
        player: PlayerId;
        from: number;
        to: number;
    };

A player went over to another team (setTeam)

traded ​

ts
traded: {
        from: PlayerId;
        to: PlayerId;
        resource: string;
        sent: number;
        received: number;
    };

A player gave an ally resources (see give): how much went, and how much came after the tax

unitHired ​

ts
unitHired: {
        shop: Entity;
        unit: Entity;
        player: PlayerId;
    };

A unit was hired at a place that hires (UnitTypeDef.hires)

unitTrained ​

ts
unitTrained: {
        building: Entity;
        unit: Entity;
    };

A building finished training a unit

unloaded ​

ts
unloaded: {
        passenger: Entity;
        transport: Entity;
    };

A unit got out of a transport

worked ​

ts
worked: {
        worker: Entity;
        target: Entity;
    };

A worker struck what it is mending

worldFailed ​

ts
worldFailed: WorldFailure;

The game ended on an error in its rules (world.failure): it is not stepped again

xpGained ​

ts
xpGained: {
        hero: Entity;
        amount: number;
        level: number;
        from?: Entity;
    };

A hero earned experience (grantXp): how much, after beforeXp, and the level it is at after it