Bastion Works: Towers, Turrets and Targeting Kit
README.md
turretsKit.Turret
The one turret part. Put it on a synced entity and set def (which turret it is) and
targeting (how it picks), by name:
e.component.add("turretsKit.Turret", { def = "tesla", targeting = "strongest", tier = 2 })
or use turretsKit.api.addTurret(e, opts). Changing def, targeting, tier or
style while it runs takes effect at once: the model is rebuilt from the new
type/tier/style (turretsKit.looks) and the brain carries on with the new numbers. In
edit mode the model also follows inspector changes.
The peer in charge of the entity (its owner, or the room host while nobody owns it)
runs the brain (turretsKit.brain), picks targets, turns, fires and deals damage
(turretsKit.combat), and writes target, state and its aim. Every other peer turns
the same model onto the same target and replays the same shots from the kit's fx channel.
Public fields
| Field | Type | Default | Synced | Meaning |
|---|---|---|---|---|
def | string | "machineGun" | yes | Turret type id (the one field that says which turret it is): machineGun, cannon, mortar, laser, tesla, frost, poison, missile, sniper, flame, support, wall, or any turretType data file's id. |
targeting | string | "first" | yes | first (furthest along the path), last, nearest, strongest, weakest. |
tier | number | 1 | yes | Upgrade tier 1..3; changes the model and every number. |
style | string | "auto" | yes | scifi, medieval, toy, or auto (the world default, TK.setStyle). |
team | string | "defenders" | yes | SecondWind team; it never shoots its own team. |
targetPlayers | bool | false | yes | Shoot players too (sentry guns). |
active | bool | true | yes | Off: stands idle and does not shoot. |
label | bool | true | no | Floating label, two lines: the name, then tier · targeting mode (support shows tier · its boost, walls tier · their health). |
labelSize | number | 1 | no | How big the label is (1 = normal). Raise it for turrets seen from far away. |
labelLift | number | 0 | no | Extra metres the label floats above the model. |
labelAt | number | 0 | no | Put the label at this height above the base, whatever the model's size (0 = above the model, plus labelLift). Lines labels up in rows. |
note | string | "" | no | Extra line under the label (e.g. "press E to change"). |
showRange | bool | false | no | Draws its range as a ring on the ground (attack turrets). |
target | string | "" | yes | Entity id it is engaging now (written by the peer in charge). |
state | string | "sweep" | yes | sweep, track, fire, hold or idle (written by the peer in charge). |
aimYaw | number | 0 | yes | Aim in degrees left/right of its facing (written a few times a second). |
aimPitch | number | 0 | yes | Aim in degrees up/down (written a few times a second). |
kills | number | 0 | yes | Kills credited to it. |
Behaviour by role
- attack: sweeps its arc, tracks a target, and fires when the aim is within the
type's
fireCone. Bullets fireburstshots, missiles asalvo, shells and clouds one lobbed shot, hitscan pierces along the line, arcs chain between targets, beams and sprays tickfireRatetimes a second. - support: idle; draws an aura ring and boosts same-team turrets within
auraRange. - wall: idle; gets a box collider and SecondWind health sized to its tier, blocks enemies in front of it, sinks into the ground when broken and rises when it comes back.
Removing the component despawns its model, label, range ring and wall collider and ends
its beam. Runs at executionOrder = 20.