Log inGet started
Package

Turret.component

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

FieldTypeDefaultSyncedMeaning
defstring"machineGun"yesTurret 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.
targetingstring"first"yesfirst (furthest along the path), last, nearest, strongest, weakest.
tiernumber1yesUpgrade tier 1..3; changes the model and every number.
stylestring"auto"yesscifi, medieval, toy, or auto (the world default, TK.setStyle).
teamstring"defenders"yesSecondWind team; it never shoots its own team.
targetPlayersboolfalseyesShoot players too (sentry guns).
activebooltrueyesOff: stands idle and does not shoot.
labelbooltruenoFloating label, two lines: the name, then tier · targeting mode (support shows tier · its boost, walls tier · their health).
labelSizenumber1noHow big the label is (1 = normal). Raise it for turrets seen from far away.
labelLiftnumber0noExtra metres the label floats above the model.
labelAtnumber0noPut the label at this height above the base, whatever the model's size (0 = above the model, plus labelLift). Lines labels up in rows.
notestring""noExtra line under the label (e.g. "press E to change").
showRangeboolfalsenoDraws its range as a ring on the ground (attack turrets).
targetstring""yesEntity id it is engaging now (written by the peer in charge).
statestring"sweep"yessweep, track, fire, hold or idle (written by the peer in charge).
aimYawnumber0yesAim in degrees left/right of its facing (written a few times a second).
aimPitchnumber0yesAim in degrees up/down (written a few times a second).
killsnumber0yesKills 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 fire burst shots, missiles a salvo, shells and clouds one lobbed shot, hitscan pierces along the line, arcs chain between targets, beams and sprays tick fireRate times 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.