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

position

Its location.

siegeEngine.rotation

rotation

The direction it faces.

siegeEngine.cycle

cycle

'idle', 'drawing', 'loading', 'ready' or 'firing'.

siegeEngine.loaded

loaded

Whether it is ready to fire.

siegeEngine.speed

speed

How fast the crew works, 0.1 to 20, default 1. You can assign to it, and a step in progress is rescaled.

siegeEngine.damage

damage

Damage at the centre of an impact, default 0, none. You can assign to it.

siegeEngine.blastRadius

blastRadius

How far damage reaches from an impact, up to 100 m, default 10. You can assign to it.

siegeEngine.usable

usable

Whether players can operate it, default false. You can assign to it.

siegeEngine.range

range

The range the guide shows, limited to minRange and maxRange. You can assign to it.

siegeEngine.minRange

minRange

The shortest distance it can hit.

siegeEngine.maxRange

maxRange

The longest distance it can hit.

siegeEngine.reloadTime

reloadTime

Seconds for a full reload at the current speed.

siegeEngine.maxHealth

maxHealth

Its maximum health. 0, the default, means it cannot be damaged. Assigning heals it fully.

siegeEngine.health

health

Its health. You can assign to it, up to maxHealth.

siegeEngine.wrecked

wrecked

Whether health has reached 0. A wrecked engine cannot load or fire until repaired.

siegeEngine.ammo

ammo

Shots left, and each load uses one. A negative number, -1 by default, never runs out. You can assign to it.

siegeEngine.crewMinimum

crewMinimum

How many crew places must be filled. You can assign to it, up to crewSeats.

siegeEngine.crewSeats

crewSeats

Its crew places: 2 winches on a trebuchet, none on a cannon.

siegeEngine.operator

operator

The player operating it, or null.

siegeEngine.crew

crew

Its 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: number

The network id.

siegeEngine.kind

kind: string

'trebuchet' or 'cannon'.

siegeEngine.dimension

dimension: number

Its dimension.