Skip to content

OnSiegeImpact

A siege engine’s shot came down - after its damage went out.

x, y, z is where it struck, and what says what it struck:

  • "player" - a player’s body in its way (target = the player)
  • "actor" - a server actor’s body in its way (target = the actor’s entity id)
  • "engine" - another siege engine, a siege ladder or a pile of stones (target = its entity id)
  • "gate" - within 6 m of a gate the server knows (GetGates; target = the gate’s key)
  • "wall" - the level’s solid geometry over the ground: a wall, a house, a rock (target = nil)
  • "ground" - the terrain (target = nil); a server without the level’s heightmap reports every other impact as "ground"

The engine may be gone by now (it was removed while the shot flew). The rest is the mode’s - open a gate struck often enough (SetGateState), switch a level layer (SetLevelLayer), count the hits on a wall.

function OnSiegeImpact(id, x, y, z, shooter, shot, what, target)
-- ...
end
Parameter Type
id number the engine that fired it
x number metres
y number metres
z number metres
shooter number the player who fired it; -1 = the mode
shot number the engine’s shot number
what string "player", "actor", "engine", "gate", "wall" or "ground"
target number|string|nil the player, the actor’s or engine’s entity id, the gate’s key - nil for a wall and the ground

nothing

-- ten stones on a gate break it open
local gateHits = {}
function OnSiegeImpact(id, x, y, z, shooter, shot, what, target)
if what ~= "gate" then return end
gateHits[target] = (gateHits[target] or 0) + 1
if gateHits[target] == 10 then
SetGateState(target, true)
SendClientMessageToAll(COLOR_RED, "The gate has fallen!")
end
end

OnSiegeShot · OnPlayerSiegeHit · OnSiegeEngineHit · OnSiegeEngineDestroyed · SetGateState · the Siege engines group of the index