CreateSiegeEngine
Stands a siege engine in the world - a trebuchet, a cannon, a siege ladder or a pile of stones.
It faces yaw - where it throws (a trebuchet stands with its crew’s end behind it: give it room, its frame is some 10 m wide
and 12 m long). z below 0 or nil = on the ground there, which needs the level’s heightmap or navmesh on the server
(the terrain guide) - the shots leave from the engine’s height; without them give z
(GetPlayerPos has it). It stands at rest, unloaded, with no shot limit and a whole structure; DestroyEntity removes it.
A "ladder" stands up against its wall: (x, y, z) is its foot and yaw the way it leans - toward the wall, its foot
about 2 m out from it. With the level’s collision data on the server (the collision guide) the
ladder is made as long as the wall is high - its top just over the wall walk, for walks from about 5 to 14 m up; without it,
it is the game’s 10 m ladder, its top 2 m on that way and 9.5 m up (the walls of Suchdol fit it exactly).
A "stones" pile lies at (x, y, z) - give the wall walk’s own height, a step from the parapet: its thrower stands
beside it and throws from where they stand. It starts full (9 stones).
Syntax
Section titled “Syntax”CreateSiegeEngine(kind, x, y [, z, yaw, world])| Parameter | Type | |
|---|---|---|
kind |
string | "trebuchet", "cannon", "ladder" or "stones" (GetSiegeKinds) |
x |
number | metres |
y |
number | metres |
z |
number | metres; nil or below 0 = on the ground (optional) |
yaw |
number | degrees, the way it throws (0 = +Y) - a ladder’s, the way it leans (optional) |
world |
number | the virtual world; nil = 0 (optional) |
Returns
Section titled “Returns”number - the engine’s entity id; nil for an unknown kind, a full world or a ground the server cannot find
Example
Section titled “Example”-- /trebuchet: one behind the player, throwing the way they looklocal x, y, z = GetPlayerPos(pid)local r = math.rad(GetPlayerYaw(pid))local id = CreateSiegeEngine("trebuchet", x + math.sin(r) * 12, y - math.cos(r) * 12, z, GetPlayerYaw(pid))SetSiegeEngineShots(id, 20)See also
Section titled “See also”GetSiegeEngines · DestroyEntity · SetSiegeEngineRules · GetSiegeKinds · the Siege engines group of the index
