WorldEvents
constWorldEvents:object
Defined in: server/api.d.ts:4811
The Overland’s roaming enemy encounters under World.setEncounterPolicy(“server”), run once on the server so every player meets the same one. A spot rolls when a player comes within 100 m: each of its kinds has a 60% chance (at most 3 of a kind up at once), then a size and a roster. Everyone leaving its stream-out radius despawns it and starts its cooldown; a failed roll waits for everyone to leave. Events: worldEventStarted(spotId, kind), worldEventCleared(spotId), worldEventEnded(spotId).
Type Declaration
Section titled “Type Declaration”cooldownHours
Section titled “cooldownHours”
readonlycooldownHours:number
In-game hours on the server clock before a spot that ran an event rolls again. Default 24, the game’s own.
enabled
Section titled “enabled”
readonlyenabled:boolean
Whether world events run under the “server” policy. Default true.
get(
id): {activeFrom:number;activeTo:number;cleared:boolean;cooldownSeconds:number;id:string;kind:string|null;kinds:string[];npcs:NPC[];state:"waiting"|"failed"|"active"|"cooldown";streamOutRadius:number;x:number;y:number;z:number; } |null
One spot, or null for an unknown id.
Parameters
Section titled “Parameters”string
A spot id from getAll.
Returns
Section titled “Returns”{ activeFrom: number; activeTo: number; cleared: boolean; cooldownSeconds: number; id: string; kind: string | null; kinds: string[]; npcs: NPC[]; state: "waiting" | "failed" | "active" | "cooldown"; streamOutRadius: number; x: number; y: number; z: number; } | null
getAll()
Section titled “getAll()”getAll():
object[]
Every spot. kinds are the encounters it can run (WE_ENEMY_ENCOUNTER_kind is the running or last one. activeFrom..activeTo are the server-clock hours it may start in (0..24 all day). cooldownSeconds is the in-game time left before a cooling spot rolls again, and npcs its live NPCs.
Returns
Section titled “Returns”object[]
getRewardPolicy()
Section titled “getRewardPolicy()”getRewardPolicy():
object
What world-event enemies pay, with the server default and built-in values filled in.
Returns
Section titled “Returns”object
experience
Section titled “experience”experience:
number
gameReward
Section titled “gameReward”gameReward:
boolean
loot:
object[] |null
lootDelivery
Section titled “lootDelivery”lootDelivery:
"drop"|"inventory"
lootMode
Section titled “lootMode”lootMode:
"each"|"shared"
radius
Section titled “radius”radius:
number
recipients
Section titled “recipients”recipients:
"killer"|"damagers"|"nearby"
reset()
Section titled “reset()”reset(
id):boolean
Despawns a spot’s event and clears its cooldown; it rolls again for the next player to come near.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
False for an unknown id.
setCooldownHours()
Section titled “setCooldownHours()”setCooldownHours(
hours):boolean
Sets the cooldown for events that end from now on.
Parameters
Section titled “Parameters”number
0 to 720; 0 rolls again on the next approach.
Returns
Section titled “Returns”boolean
False for a value out of range.
setEnabled()
Section titled “setEnabled()”setEnabled(
enabled):void
Turns world events on or off. Off despawns every running event, clears cooldowns and rolls nothing; camps are unaffected.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Returns
Section titled “Returns”void
setRewardPolicy()
Section titled “setRewardPolicy()”setRewardPolicy(
policy):void
Sets what world-event enemies pay when they die (see NPC.setRewardPolicy), on their live NPCs and on every one spawned after. Throws a TypeError or RangeError for a malformed policy.
Parameters
Section titled “Parameters”policy
Section titled “policy”{ experience?: number; gameReward?: boolean; loot?: object[] | null; lootDelivery?: "drop" | "inventory"; lootMode?: "each" | "shared"; radius?: number; recipients?: "killer" | "damagers" | "nearby"; } | null
Fields left out come from NPC.setDefaultRewardPolicy; null clears it.
Returns
Section titled “Returns”void
start()
Section titled “start()”start(
id,kind?):boolean
Starts an event at a spot now, whatever its roll, cooldown, hours or the active cap. It ends like any other, once everyone has left.
Parameters
Section titled “Parameters”string
string
One of the spot’s kinds; a uniform pick among them when left out.
Returns
Section titled “Returns”boolean
False for an unknown spot or kind, a spot already running one, or outside the “server” policy.