Log inGet started
Package

turretsKit.package

README.md

turretsKit.turretType

The data contract every turret .data file is checked against. One data file is one turret type; a turretsKit.Turret component is set to it by its id. The catalog (turretsKit.catalog) reads every instance of this contract anywhere in the world.

Adding a turret

Add a .data folder with contract: turretsKit.turretType and a values: block: no code needed. The twelve shipped turrets are in turretsKit.package/turrets/*.data (machineGun, cannon, mortar, laser, tesla, frost, poison, missile, sniper, flame, support, wall); copy the closest one. From code, turretsKit.api.define(id, def, base) does the same at runtime.

contract: turretsKit.turretType
values:
  id: machineGun
  label: Machine Gun
  delivery: bullet
  special: burst
  tiers:
    - { name: "Mk I",  cost: 100, fireRate: 5, range: 11,   damage: 5, burst: 1, barrels: 1 }
    - { name: "Mk II", cost: 120, fireRate: 6, range: 12,   damage: 6, burst: 2, barrels: 2 }
    - { name: "Mk III",cost: 180, fireRate: 7, range: 13.5, damage: 7, burst: 3, barrels: 4 }

Top-level fields

FieldTypeDefaultMeaning
idstringrequiredName the Turret component's def field uses.
labelstringrequiredDisplay name (floating label, UI).
descriptionstring""One-paragraph description.
tagslist of strings[]Tags for filtering and picking: listed with the type by TK.types() and TK.info, and TK.types(tag) filters by one.
roleattack | support | wallattackAttack turrets target and fire; support and wall are passive.
deliverybullet shell missile beam arc spray cloud hitscan aura nonebulletHow it delivers damage (see below).
damageTypephysical fire ice electric poison explosionphysicalSecondWind damage type of its hits.
shotbullet shell mortar missile beam arc frost poison sniper flame nonebulletWhich projectile look slot of the style it draws with.
shapestring"" (= id)Which head model turretsKit.looks builds.
colorcolor#ffcc44The turret's own colour (glow, range ring, styles that tint by turret).
specialstring""Name of the tier stat shown as its headline number (info().specialValue).
specialLabelstring""Human label for that stat.
indirectbooleanfalseLobbed fire: ignores the pitch limits when checking a target, sweeps at mid pitch.
needsSightbooleantrueNeeds a clear line to the target (ignored when indirect).
leadbooleantrueAims ahead of moving targets (bullets, shells, clouds).
aimHeightnumber0.9Metres above a target's position it aims at.
hitslist of ground / air[]Target layers it shoots; empty = both.
detectsbooleanfalseCan see and shoot hidden (stealthed) targets.
detectRangenumber0How far it sees hidden targets, in metres; 0 = its whole range.
fireConenumber 0..1808Degrees of aim error within which it fires.
coneAnglenumber 0..18030Spray cone width in degrees (flame).
sellRatenumber 0..10.7Fraction of money spent refunded on sale.
defaultTargetingfirst last nearest strongest weakestfirstTargeting mode when none is given.

turn (struct): yawSpeed (180 °/s), pitchSpeed (90 °/s), yawMin / yawMax (-180 / 180, degrees from its facing), pitchMin / pitchMax (-10 / 60).

projectile (struct): speed (40 m/s), arc (0, peak height of shells), gravity (18), turnRate (180 °/s, missiles), radius (0.7, contact distance), size (1, look scale).

Tiers

tiers (required) is a list of tier structs, normally three (tier 1..3; the catalog's MAX_TIER is 3, and a turret's tier is clamped to the list's length). Every tier field is optional; an absent one takes the default in catalog.STAT_DEFAULTS.

Common to all: name ("" → "Tier n"), cost (100; tier 1 = build cost, later tiers = upgrade cost), fireRate (1 shot/s, or ticks/s for beam and spray), range (10 m), minRange (0), damage (10), turnBoost (0, extra turn speed fraction), barrels (1, model barrel count), scale (1, model size).

Which fields each delivery reads:

Turret (delivery)Tier fields
Machine gun (bullet)burst: bullets per trigger pull (≥1)
Cannon, mortar (shell), frost (bullet), missilesplash: blast radius in metres (falls off to half at the edge)
Tesla (arc)chains: extra jumps; chainRange (4): jump distance; chainFalloff (0.8): damage multiplier per jump
Frostslow: fraction of speed taken (0..1); slowTime: seconds
Poison (cloud)cloudRadius, cloudTime, cloudDps: the cloud left where the shell lands
Missilesalvo: missiles per volley (≥1)
Sniper (hitscan)pierce (1): targets hit along the line, each 25% weaker
Flame (spray)burnDps, burnTime: burn applied to everything in the cone
Laser (beam)rampMax (1): damage multiplier reached after rampTime (2) s on one target
Support (aura)auraRange; boostFireRate, boostDamage, boostRange: fractions given to same-team turrets in reach (strongest beacon counts, no stacking)
Wall (none)health: SecondWind max health; thorns: dps dealt to enemies touching it; blockRadius (1.4): how far in front it holds enemies

burnDps/burnTime and slow/slowTime also apply to any shot that hits, if set.