WorldEvents beta
Interface of @v12-engine/engine
export interface WorldEventsThe events a world emits (world.events), by name, each with its payload; what hooks do not cover and listeners and sessions hear
Members
abilityCast
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
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
attackStarted: {
attacker: Entity;
target?: Entity;
weapon: number;
};weapon: which of its attacks swings, by place (UnitTypeDef.attacks)
boarded
boarded: {
passenger: Entity;
transport: Entity;
};A unit got into a transport (UnitTypeDef.transport), or out of one
bounty
bounty: {
entity: Entity;
player: PlayerId;
amount: number;
};A player was paid a bounty of this amount for an entity's death
buffApplied
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
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
cameraOrdered: {
player: PlayerId;
} & Pick<CameraOrder, 'pan' | 'shake'>;The rules pan or shake one player's camera (see cameraFor)
campCleared
campCleared: {
camp: Camp;
};Every creep of a camp is gone. It comes back after a while, when it says so (see Camp.respawn)
campReturned
campReturned: {
camp: Camp;
};A camp cleared came back, its creeps where they stood (see respawnCamp)
castCancelled
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
castStarted: {
caster: Entity;
ability: AbilityDef;
point?: Vec2;
duration: number;
};duration: seconds of the wind-up
cellsChanged
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
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
channelEnded: {
caster: Entity;
ability: AbilityDef;
interrupted: boolean;
};A channelled ability stopped being kept up; interrupted when it was broken off
channelStarted
channelStarted: {
caster: Entity;
ability: AbilityDef;
duration: number;
};A channelled ability started to be kept up, or ended: done, or interrupted
chatted
chatted: {
player: PlayerId;
text: string;
to: ChatAudience;
by?: string;
};A player said a line (see chat): to their side, or to everyone
checkpoint
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
chopped: {
worker: Entity;
source: Entity;
};A worker struck the tree it is working on
cinematicChoice
cinematicChoice: CinematicChoice;A player picked an answer of a cinematic's choice, as their screen said (see cinematicChose)
cinematicCue
cinematicCue: CinematicCue;The rules play one of the view's cinematics on the screens of some players, or everyone's (see playCinematic)
cinematicCued
cinematicCued: CinematicCueSent;The rules cue the cinematic playing on some screens, or everyone's (see cueCinematic)
cinematicEnded
cinematicEnded: CinematicEnded;A cinematic the rules played is over on a player's screen, as their screen said (see cinematic's wait)
commandHandled
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
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
constructionCancelled: Entity;A construction was called off by its owner: it dies next, with the reason cancelled
constructionFinished
constructionFinished: Entity;A building was completed
constructionStarted
constructionStarted: Entity;A building's construction began, its site placed
damaged
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
enteredArea: {
area: string;
entity: Entity;
};A unit walked into an area of the game (Rules.areas)
entityDied
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
entityMorphed: {
entity: Entity;
from: string;
};An entity became another type: from, what it was
entityRemoved
entityRemoved: Entity;An entity left the world, dead or taken away
entitySpawned
entitySpawned: Entity;An entity was added to the world
environmentChanged
environmentChanged: {
environment: MapEnvironment;
over?: number;
};over: the seconds the screens ease into it over, where the rules said
exchanged
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
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
fxStopped: {
id: number;
fade?: number;
};The rules stop an effect they played (see world.stopFx)
gameOver
gameOver: {
winner: number;
};The game ended; winner is the winning team
groundReshaped
groundReshaped: {
patch: TerrainPatch;
};A part of the ground was reshaped (reshapeGround): as it is now, told to every player
gusted
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
healed: {
target: Entity;
source?: Entity;
amount: number;
};A target was healed by an amount, by a source when it has one
heroLevelUp
heroLevelUp: {
hero: Entity;
level: number;
};A hero reached a new level
heroRevived
heroRevived: Entity;A fallen hero was brought back
impact
impact: {
x: number;
z: number;
radius: number;
owner: PlayerId;
};An attack that hits an area came down
inventoryChanged
inventoryChanged: {
entity: Entity;
};What a unit carries changed: an item given, taken, bought, sold, used up, or a hero carried in with theirs
itemDropped
itemDropped: GroundItem;An item came to lie on the ground
itemPicked
itemPicked: {
entity: Entity;
item: ItemInstance;
};An entity picked an item up from the ground
itemUndone
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
leftArea: {
area: string;
entity: Entity;
};A unit walked out of one. What dies in an area is not said to leave it
lineEnded
lineEnded: {
id: number;
to: PlayerId[];
};A line was skipped by whom it was said to: it ends early for them
lineSaid
lineSaid: SaidLine;Someone said a line, to some players or everyone (see world.dialog)
manaChanged
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
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
missed: {
x: number;
z: number;
source?: Entity;
target?: Entity;
};An attack went wide. Where it would have landed, and whom it was for
missileHit
missileHit: {
missile: Missile;
target: Entity;
};A missile passed through a target
missileRemoved
missileRemoved: Missile;A missile ended or was taken away
missileSpawned
missileSpawned: Missile;A missile was sent on its way
morphCancelled
morphCancelled: {
entity: Entity;
into: string;
};That was called off, or the building died before it was done
morphedBack
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
morphStarted: {
entity: Entity;
into: string;
time: number;
};A building started to turn into another type (UnitTypeDef.upgradesTo), over time seconds
objectiveChanged
objectiveChanged: {
player: PlayerId;
objective: ObjectiveState;
was?: ObjectiveStatus;
};An objective of a player was given (was undefined), got further along, was done or failed
pauseAsked
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
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
playerDefeated: Player;A player was defeated, out of the game
playerSurrendered
playerSurrendered: {
player: PlayerId;
};A player gave up (see surrender): playerDefeated follows
projectileRemoved
projectileRemoved: Projectile;A projectile landed or was taken away
projectileSpawned
projectileSpawned: Projectile;A projectile was fired
researchFinished
researchFinished: {
building: Entity;
upgrade: string;
level: number;
};A building finished researching an upgrade, to this level
resourceChanged
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
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
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
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
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
teamChanged: {
player: PlayerId;
from: number;
to: number;
};A player went over to another team (setTeam)
traded
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
unitHired: {
shop: Entity;
unit: Entity;
player: PlayerId;
};A unit was hired at a place that hires (UnitTypeDef.hires)
unitTrained
unitTrained: {
building: Entity;
unit: Entity;
};A building finished training a unit
unloaded
unloaded: {
passenger: Entity;
transport: Entity;
};A unit got out of a transport
worked
worked: {
worker: Entity;
target: Entity;
};A worker struck what it is mending
worldFailed
worldFailed: WorldFailure;The game ended on an error in its rules (world.failure): it is not stepped again
xpGained
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