SiegeGame
A component script.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2SiegeGame — Trebuchet Castle Siege, whole. One component owns the siege: the menus, the progression, the trebuchet, the castle it is pointed at, the garrison defending it, the shot in the air and everything that falls down afterwards. It reads its numbers from `siege_config`, its geometry from `siege_castle`, its arc from `siege_ballistics`, its screens from `siege_ui`, and its sound bank from the `.soundClip` assets `siege_sfx` baked. Everything it spawns hangs off one temporary root and is torn down when the siege ends, so the scene on disk stays exactly what the author placed there: a battlefield, a light, and this component.
clamp(v: number, lo: number, hi: number) → number
| arg | type | description |
|---|---|---|
| v | number | |
| lo | number | |
| hi | number |
dist2(ax: number, az: number, bx: number, bz: number) → number
| arg | type | description |
|---|---|---|
| ax | number | |
| az | number | |
| bx | number | |
| bz | number |
yawQuat(ry: number) → void
| arg | type | description |
|---|---|---|
| ry | number |
toast(text: string, kind: string) → void
| arg | type | description |
|---|---|---|
| text | string | |
| kind | string |
say(text: string, seconds: number?) → void
| arg | type | description |
|---|---|---|
| text | string | |
| seconds | number? |
defaultProgress( ) → void
num(v: any, fallback: number) → number
| arg | type | description |
|---|---|---|
| v | any | |
| fallback | number |
loadProgress( ) → void
saveProgress( ) → void
clip(name: string) → any
| arg | type | description |
|---|---|---|
| name | string |
sfxGain(v: number?) → number
| arg | type | description |
|---|---|---|
| v | number? |
playAt(name: string, x: number, y: number, z: number, volume: number?, pitch: number?) → void
| arg | type | description |
|---|---|---|
| name | string | |
| x | number | |
| y | number | |
| z | number | |
| volume | number? | |
| pitch | number? |
playUi(name: string, volume: number?, pitch: number?) → void
| arg | type | description |
|---|---|---|
| name | string | |
| volume | number? | |
| pitch | number? |
applyMixer( ) → void
despawnTree(id: string?) → void
| arg | type | description |
|---|---|---|
| id | string? |
clearSiege( ) → void
siegeStanding( ) → boolean
True only while a siege's root is standing. Every runtime spawn checks it: teardown is deferred a frame or two, so a defender or an effect started on the last tick of the old siege would otherwise be parented to a root that is already on its way out, and end up an orphan nothing owns.
spawnPart(name: string, parent: string, model: string, mat: string, pos: { number }, scale: { number }) → void
| arg | type | description |
|---|---|---|
| name | string | |
| parent | string | |
| model | string | |
| mat | string | |
| pos | { number } | |
| scale | { number } |
buildTrebuchet( ) → void
The engine itself: a yaw platform carrying an A-frame, an axle, the arm with its counterweight, and the sling. Every moving piece is a child of the pivot it turns on, so laying and firing are two transform writes.
applyLayingTransforms( ) → void
slingTipWorld( ) → void
startCastleBuild(layout: string) → void
Spawn the castle across several frames: a fortress is several hundred stones and dropping them all in one tick is a visible hitch.
| arg | type | description |
|---|---|---|
| layout | string |
buildStep(budget: number) → boolean
| arg | type | description |
|---|---|---|
| budget | number |
spawnDefender(kind: string, post: any) → void
| arg | type | description |
|---|---|---|
| kind | string | |
| post | any |
garrisonFor( ) → void
spawnGarrison( ) → void
freeBlock(idx: number, ix: number, iy: number, iz: number, power: number) → void
| arg | type | description |
|---|---|---|
| idx | number | |
| ix | number | |
| iy | number | |
| iz | number | |
| power | number |
nearbyIndices(x: number, z: number, radius: number) → void
| arg | type | description |
|---|---|---|
| x | number | |
| z | number | |
| radius | number |
cascade(seedList: { number }) → void
Freeing one stone frees whatever it was carrying: the course sitting on top of it loses its bed and comes down, and so on up the wall. Nothing is released sideways — a span goes over because falling masonry lands on its neighbours, which the physics does far better than a radius would.
| arg | type | description |
|---|---|---|
| seedList | { number } |
igniteAt(x: number, y: number, z: number, radius: number) → void
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| z | number | |
| radius | number |
killDefendersNear(x: number, y: number, z: number, radius: number, reason: string) → void
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| z | number | |
| radius | number | |
| reason | string |
stunMasons(x: number, z: number, radius: number, seconds: number) → void
| arg | type | description |
|---|---|---|
| x | number | |
| z | number | |
| radius | number | |
| seconds | number |
recomputeIntegrity( ) → void
Integrity is the fraction of the castle still MORTARED. A stone shaken out of its bed has stopped being wall even if it has not yet toppled — and it is the measure the player can read directly off each impact, since the stones a shot breaks loose are exactly the ones the bar loses.
keepBreached( ) → boolean
impact(x: number, y: number, z: number, ammoKey: string) → void
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| z | number | |
| ammoKey | string |
launchShot(ammoKey: string, speed: number) → void
| arg | type | description |
|---|---|---|
| ammoKey | string | |
| speed | number |
endShot(x: number, y: number, z: number) → void
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| z | number |
stepShot(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
fireAtTrebuchet(from: any, kind: string) → void
| arg | type | description |
|---|---|---|
| from | any | |
| kind | string |
stepIncoming(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
supportGone(d: any) → boolean
| arg | type | description |
|---|---|---|
| d | any |
moveToward(d: any, tx: number, ty: number, tz: number, speed: number, dt: number) → boolean
| arg | type | description |
|---|---|---|
| d | any | |
| tx | number | |
| ty | number | |
| tz | number | |
| speed | number | |
| dt | number |
findRestackTarget(d: any) → number
| arg | type | description |
|---|---|---|
| d | any |
stepDefenders(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
stepFires(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
manageRubble(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
rollWind( ) → void
stockAmmo( ) → void
targetRange( ) → number
startSiege(idx: number, customRun: boolean) → void
| arg | type | description |
|---|---|---|
| idx | number | |
| customRun | boolean |
finishSiege(won: boolean, reason: string) → void
| arg | type | description |
|---|---|---|
| won | boolean | |
| reason | string |
checkObjective( ) → void
currentSpeed( ) → number
fullSpeed( ) → number
releasePointFor(angle: number) → void
Where the sling will be when it lets go, for the laying currently dialled in. The release point sits several metres behind and above the frame, so predicting from the base would be short by the length of the arm.
| arg | type | description |
|---|---|---|
| angle | number |
predictFrom(angle: number, samples: number) → Bal
| arg | type | description |
|---|---|---|
| angle | number | |
| samples | number |
predictedRange( ) → number
clearAssist( ) → void
Aim assist: a dotted arc and a ring where the shot is predicted to fall. It is the same integrator the shot itself flies, so what it draws is what happens — it removes the arithmetic, not the judgement.
updateAssist(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
selectAmmo(key: string) → void
| arg | type | description |
|---|---|---|
| key | string |
fireEngine( ) → void
stepLaying(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
stepFiring(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
stepReturn(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
rangeHint(pred: number, want: number) → void
| arg | type | description |
|---|---|---|
| pred | number | |
| want | number |
buildView( ) → any
refreshScreens(dt: number, force: boolean?) → void
| arg | type | description |
|---|---|---|
| dt | number | |
| force | boolean? |
resolveCamera( ) → void
tickToasts(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
frame(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
state( ) →
A snapshot of the siege for tooling: phase, objective, laying and garrison counts.
examples
entity.find("SiegeGame").component.get("SiegeGame"):state()standing( ) →
The masonry still standing, as world positions grouped by castle part.
examples
#entity.find("SiegeGame").component.get("SiegeGame"):standing()beginSiege(n: number) → void
Start a siege straight away, skipping the menus. Level 1-5.
| arg | type | description |
|---|---|---|
| n | number | Which siege to raise. |
examples
entity.find("SiegeGame").component.get("SiegeGame"):beginSiege(3)lay(yaw: number, counterweight: number, releaseAngle: number) → void
Set the laying solution directly, the way the keys would.
| arg | type | description |
|---|---|---|
| yaw | number | Frame yaw in degrees. |
| counterweight | number | Counterweight mass in kg. |
| releaseAngle | number | Release elevation in degrees. |
examples
comp:lay(0, 1400, 42)
loose( ) → void
Wind the engine fully and loose the selected shot, as a completed winch would.
examples
comp:loose()
pick(key: string) → void
Choose the ammunition on the belt.
| arg | type | description |
|---|---|---|
| key | string | One of ranging / boulder / firepot / grapeshot / plaguecow. |
examples
comp:pick("firepot")awake( ) → void
start( ) → void
update(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
editorUpdate(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
onDestroy( ) → void
onCallback(id: string, data: any) → void
| arg | type | description |
|---|---|---|
| id | string | |
| data | any |
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
Inside
4 problems across 1 itemagent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.