SiegeEngine
Defined in: server/api.d.ts:5805
Replicated handle for a trebuchet or a cannon.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SiegeEngine(
id):SiegeEngine
Defined in: server/api.d.ts:5810
Creates a script wrapper for an existing siege engine with this ID; use SiegeEngine.spawn() to build one.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”SiegeEngine
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”aim(
target):SiegeResult
Defined in: server/api.d.ts:5932
Turns the engine to face a point without shooting. fire turns it anyway; this is for showing where it will shoot.
Parameters
Section titled “Parameters”target
Section titled “target”The point to turn towards.
Returns
Section titled “Returns”What happened, and the phrase to explain it with when nothing did.
canHit()
Section titled “canHit()”canHit(
target):string
Defined in: server/api.d.ts:5939
Whether the engine can reach a point from where it stands.
Parameters
Section titled “Parameters”target
Section titled “target”The point to test.
Returns
Section titled “Returns”string
Empty when it can; otherwise why not, as a phrase.
destroy()
Section titled “destroy()”destroy():
void
Defined in: server/api.d.ts:5968
Removes the engine on every client after emitting siegeEngineDestroy. A projectile already in the air still lands.
Returns
Section titled “Returns”void
fire()
Section titled “fire()”fire(
target,attacker?):SiegeResult
Defined in: server/api.d.ts:5925
Turns a loaded engine to face the target and shoots at it. A trebuchet’s arm lets the stone go at one angle, so its speed is solved for the distance; a cannon fires at one speed, so its elevation is. The stone is let go partway through the shot (seconds), then every client nearby draws it along the same arc. It comes down where the world stops it, which the attacker is asked to report when near enough, else the player nearest the target, or on the target when nobody can.
Parameters
Section titled “Parameters”target
Section titled “target”Where the projectile should come down.
attacker?
Section titled “attacker?”number | Player | null
The player credited with whatever it hits, in playerDamage, npcDamage and siegeImpact.
Returns
Section titled “Returns”What happened, and the phrase to explain it with when nothing did.
getAimGuide()
Section titled “getAimGuide()”getAimGuide():
boolean
Defined in: server/api.d.ts:5951
Whether the operator sees the aim guide; see setAimGuide.
Returns
Section titled “Returns”boolean
True when the beam is shown.
load()
Section titled “load()”load():
SiegeResult
Defined in: server/api.d.ts:5917
Starts the reload cycle of an idle engine. siegeEngineReady fires when it can shoot.
Returns
Section titled “Returns”What happened, and the phrase to explain it with when nothing did.
repair()
Section titled “repair()”repair():
void
Defined in: server/api.d.ts:5956
Makes the engine whole again: health back to maxHealth, and a wreck idle and unloaded.
Returns
Section titled “Returns”void
setAimGuide()
Section titled “setAimGuide()”setAimGuide(
enabled):void
Defined in: server/api.d.ts:5945
Shows or hides the operator’s aim guide: a translucent red beam along the shot’s path – out of a trebuchet’s sling and along its arc, or straight from a cannon’s muzzle – to where it would come down, with a ball there. Off by default, which leaves laying the engine to the eye; the Fire hint says how far the shot goes either way.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Whether the operator sees the beam.
Returns
Section titled “Returns”void
setOperator()
Section titled “setOperator()”setOperator(
player):boolean
Defined in: server/api.d.ts:5963
Puts a player in the engine’s place without asking them, or takes whoever is there out of it. A player holds one place at a time, so they leave any other engine or winch first. Raises no siegeEngineUse.
Parameters
Section titled “Parameters”player
Section titled “player”Player | null
Who takes the engine’s place, or null to empty it.
Returns
Section titled “Returns”boolean
False for a player who is no longer connected.
setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world):void
Defined in: server/api.d.ts:8797
Moves this entity into another virtual world.
Parameters
Section titled “Parameters”number
Virtual-world identifier used to partition replication and visibility.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setVisibleTo()
Section titled “setVisibleTo()”setVisibleTo(
player):void
Defined in: server/api.d.ts:8803
Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.
Parameters
Section titled “Parameters”player
Section titled “player”Entity | null
Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:5911
Formats this engine handle for logging and debugging.
Returns
Section titled “Returns”string
The engine ID, its kind and where it is in its cycle.
Inherited from
Section titled “Inherited from”
staticall(virtualWorld?):SiegeEngine[]
Defined in: server/api.d.ts:5985
Lists the siege engines the server has.
Parameters
Section titled “Parameters”virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world to list; omitted lists every one.
Returns
Section titled “Returns”SiegeEngine[]
One handle per engine, in no particular order.
destroyAll()
Section titled “destroyAll()”
staticdestroyAll(virtualWorld?):number
Defined in: server/api.d.ts:5999
Removes siege engines, emitting siegeEngineDestroy for each one.
Parameters
Section titled “Parameters”virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world to clear; omitted clears every one.
Returns
Section titled “Returns”number
How many were removed.
getById()
Section titled “getById()”
staticgetById(id):SiegeEngine|null
Defined in: server/api.d.ts:5992
Looks an engine up by its network entity ID.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”SiegeEngine | null
The engine’s handle, or null when no live engine has that ID.
spawn()
Section titled “spawn()”
staticspawn(kind,position,rotation?,virtualWorld?):SiegeEngine
Defined in: server/api.d.ts:5978
Builds and replicates a siege engine, unloaded. The trebuchet is the game’s own model and plays its own winch, load and fire animations; the cannon is the game’s static gun.
Parameters
Section titled “Parameters”string
trebuchet or cannon.
position
Section titled “position”World-space position of the engine’s base.
rotation?
Section titled “rotation?”Optional initial orientation: a Quaternion, or a Vector3 of Euler angles in degrees. fire and aim turn it to face their target.
virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world the engine belongs to; omitted puts it in the global one.
Returns
Section titled “Returns”SiegeEngine
The new engine’s handle.
Properties
Section titled “Properties”ammo:
number
Defined in: server/api.d.ts:5885
Shots left to load; each load takes one, and an engine with none refuses to load. -1, the default, never runs out; any negative value means the same.
readonlycrew: (Player|null)[]
Defined in: server/api.d.ts:5905
Who mans each winch, in place order, with null for an empty one.
crewPlaces
Section titled “crewPlaces”
readonlycrewPlaces:number
Defined in: server/api.d.ts:5895
How many winches the engine has: 2 on a trebuchet, 0 on a cannon.
crewRequired
Section titled “crewRequired”crewRequired:
number
Defined in: server/api.d.ts:5890
How many of the engine’s winches must be manned for its arm to be winched down; 0, the default, winds it by itself. With fewer hands than this the winding holds where it is, and goes on when they come back. Players near a usable engine that needs them are offered its winches, and each one there plays the game’s own pull. Kept to crewPlaces.
readonlycycle:string
Defined in: server/api.d.ts:5820
Where the engine is in its cycle: idle (unloaded), drawing (a trebuchet’s arm being winched down), loading (the crew laying the projectile), ready or firing. Named cycle because every entity already has a state, which is its state bag.
damage
Section titled “damage”damage:
number
Defined in: server/api.d.ts:5835
Health taken from anything at the point of impact; a player has 100. A quarter of it reaches the edge of damageRadius. 0 leaves hits to siegeImpact.
damageRadius
Section titled “damageRadius”damageRadius:
number
Defined in: server/api.d.ts:5840
How far from the point of impact anything is hurt, in metres, up to 100.
health
Section titled “health”health:
number
Defined in: server/api.d.ts:5875
What is left of maxHealth. Setting it to 0 wrecks the engine and raising it from 0 repairs one; ignored while maxHealth is 0.
readonlyid:number
Defined in: server/api.d.ts:8765
Immutable network entity identifier.
Inherited from
Section titled “Inherited from”
readonlykind:string
Defined in: server/api.d.ts:5815
What the engine is: trebuchet or cannon. The game ships no catapult and no ballista.
loadDuration
Section titled “loadDuration”
readonlyloadDuration:number
Defined in: server/api.d.ts:5865
How long load takes at the engine’s speed, in seconds.
loaded
Section titled “loaded”
readonlyloaded:boolean
Defined in: server/api.d.ts:5825
Whether the engine is ready to fire.
maxHealth
Section titled “maxHealth”maxHealth:
number
Defined in: server/api.d.ts:5870
What the engine can take before it is wrecked; 0, the default, means nothing harms it. Setting it heals the engine to the new maximum and repairs a wreck. A blast within damageRadius of an engine – any engine’s, its own included – takes its share of that shot’s damage off it, raising siegeEngineDamage.
maxRange
Section titled “maxRange”
readonlymaxRange:number
Defined in: server/api.d.ts:5860
The furthest the engine can be aimed, in metres along the ground.
minRange
Section titled “minRange”
readonlyminRange:number
Defined in: server/api.d.ts:5855
The closest the engine can be aimed, in metres along the ground.
operator
Section titled “operator”
readonlyoperator:Player|null
Defined in: server/api.d.ts:5900
The player in the engine’s place, or null. They lay it where they look while they hold the block key, load it with the torch key, fire it with the attack key and step away with the use key; walking off lets go of it too. setOperator puts somebody there.
position
Section titled “position”position:
Vector3
Defined in: server/api.d.ts:8775
Authoritative world-space position; assignment forces replicated state.
Inherited from
Section titled “Inherited from”range:
number
Defined in: server/api.d.ts:5850
How far a shot goes along the operator’s facing when they fire before laying the engine anywhere, in metres; kept between minRange and maxRange. 150 for a trebuchet and 120 for a cannon to start with.
rotation
Section titled “rotation”rotation:
Vector3|Quaternion
Defined in: server/api.d.ts:8780
Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.
Inherited from
Section titled “Inherited from”speed:
number
Defined in: server/api.d.ts:5830
How fast the cycle runs, from 0.1 to 20; 1 is the game’s own pace, which takes a trebuchet’s crew nearly two minutes to load and lets the stone go 3.5 seconds into the shot. Changing it mid-step carries on from where the engine has got to.
readonlystate:StateBag
Defined in: server/api.d.ts:8785
Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.
Inherited from
Section titled “Inherited from”usable
Section titled “usable”usable:
boolean
Defined in: server/api.d.ts:5845
Whether players may work the engine. A player within 2 m of an empty one gets the game’s own action hint on the use key to take its place, and becomes its operator; near a trebuchet with a crewRequired, a free winch is offered too. Each ask raises siegeEngineUse first, which may refuse it. Off by default.
virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: server/api.d.ts:8770
Current virtual-world identifier.
Inherited from
Section titled “Inherited from”wrecked
Section titled “wrecked”
readonlywrecked:boolean
Defined in: server/api.d.ts:5880
Whether the engine’s health ran out. A wrecked cannon shows the game’s broken gun and a wrecked trebuchet leans and settles; nothing loads, aims or fires it, and its operator and crew are let go, until repair or a new maxHealth.