SiegeEngine
A trebuchet or cannon. The server owns its cycle, idle, drawing, loading, ready or firing, its operator, ammunition, health and the result of each shot, and players' games draw it. At speed 1, a trebuchet reaches 25 to 250 m and reloads in 110 s, and a cannon reaches 10 to 200 m and reloads in 12 s. Loading, aiming and firing return { accepted, reason, seconds }. Events are siegeEngineSpawn, siegeEngineUse, which can refuse, siegeEngineReady, siegeFire, siegeImpact, siegeEngineDamage, siegeEngineWreck and siegeEngineDestroy.
siegeEngine.spawn()
SiegeEngine.spawn(kind, position, orientation, dimension)Places an engine.
siegeEngine.all()
SiegeEngine.all(dimension)All engines, or those in one dimension.
siegeEngine.getById()
SiegeEngine.getById(id)The engine with this network id, or null.
siegeEngine.destroyAll()
SiegeEngine.destroyAll(dimension)Removes all engines, or those in one dimension.
siegeEngine.position
positionIts location.
siegeEngine.rotation
rotationThe direction it faces.
siegeEngine.cycle
cycle'idle', 'drawing', 'loading', 'ready' or 'firing'.
siegeEngine.loaded
loadedWhether it is ready to fire.
siegeEngine.speed
speedHow fast the crew works, 0.1 to 20, default 1. You can assign to it, and a step in progress is rescaled.
siegeEngine.damage
damageDamage at the centre of an impact, default 0, none. You can assign to it.
siegeEngine.blastRadius
blastRadiusHow far damage reaches from an impact, up to 100 m, default 10. You can assign to it.
siegeEngine.usable
usableWhether players can operate it, default false. You can assign to it.
siegeEngine.range
rangeThe range the guide shows, limited to minRange and maxRange. You can assign to it.
siegeEngine.minRange
minRangeThe shortest distance it can hit.
siegeEngine.maxRange
maxRangeThe longest distance it can hit.
siegeEngine.reloadTime
reloadTimeSeconds for a full reload at the current speed.
siegeEngine.maxHealth
maxHealthIts maximum health. 0, the default, means it cannot be damaged. Assigning heals it fully.
siegeEngine.health
healthIts health. You can assign to it, up to maxHealth.
siegeEngine.wrecked
wreckedWhether health has reached 0. A wrecked engine cannot load or fire until repaired.
siegeEngine.ammo
ammoShots left, and each load uses one. A negative number, -1 by default, never runs out. You can assign to it.
siegeEngine.crewMinimum
crewMinimumHow many crew places must be filled. You can assign to it, up to crewSeats.
siegeEngine.crewSeats
crewSeatsIts crew places: 2 winches on a trebuchet, none on a cannon.
siegeEngine.operator
operatorThe player operating it, or null.
siegeEngine.crew
crewIts crew places, each a player or null.
siegeEngine.load()
load()Starts a reload, using one ammo. It is refused while wrecked, busy, already loaded or out of ammo.
siegeEngine.fire()
fire(target, attacker)Turns to the target and fires a loaded engine. Everything within blastRadius of the impact takes a share of the damage.
siegeEngine.aim()
aim(target)Turns the engine to a target in range.
siegeEngine.inReach()
inReach(target)Why it cannot hit a point, or '' if it can.
siegeEngine.showAimLine()
showAimLine(enabled)Shows or hides the aim guide to players.
siegeEngine.aimLine()
aimLine()Whether the aim guide shows.
siegeEngine.repair()
repair()Restores full health and ends the wrecked state.
siegeEngine.assignGunner()
assignGunner(player)Puts a player in the operator's place, removing them from any other engine, or empties it with null.
siegeEngine.destroy()
destroy()Removes the engine, firing siegeEngineDestroy.
siegeEngine.id
id: numberThe network id.
siegeEngine.kind
kind: string'trebuchet' or 'cannon'.
siegeEngine.dimension
dimension: numberIts dimension.