Log inGet started
Package

turretsKit.package

README.md

turretsKit.targets

What a turret can shoot at, gathered at most every REFRESH (0.1 s) for every turret on this peer. The turretsKit.Turret component reads it in its scan and for splash, spray, hitscan and chain hits; turretsKit.combat uses it for walls, clouds and slows. turretsKit.api re-exports add, remove and setProgress as addTarget, removeTarget and setProgress.

Where candidates come from

  1. Anything with SecondWind health (SecondWind.Vitals) that is alive: enemies, dummies, breakable props. Players count only for turrets with targetPlayers on.
  2. spawnerKit enemies (spawnerKit.Enemy) are read for their path progress; enemies waiting in spawnerKit's pool (not active) are skipped.
  3. Targets a game registers with add, with its own team, progress and health.

"How far along the path" (used by first/last) is, in order: the setProgress function; a target's own progress function; a spawnerKit path enemy's place on its route (0 at the start, 1 at the end); otherwise how long this peer has seen it.

Candidate record

{ id, pos, health, maxHealth, team, player, enemy, progress, vel? }: vel is estimated from the last position (dropped above 30 m/s, a teleport). Custom targets without health carry custom = true.

Functions

  • add(target: any, opts: any?): registers an entity (or id) as a target, or gives a health target its own data: opts = { team, progress = fn(id) -> 0..1, health = fn(id) -> number }.
  • remove(target: any): stops treating it as a custom target.
  • setProgress(fn: any): fn(id, pos) -> number (bigger = further along) or nil to fall back, for games with their own movers.
  • enemyOf(e: any): any: the entity's spawnerKit.Enemy component, or nil.
  • all(force: boolean?): { any }: every target this tick (force refreshes now).
  • forTeam(team: string, targetPlayers: boolean): { any }: fresh copies of the targets not on team (players only when targetPlayers).
  • get(id: string): any: one target's record this tick, or nil.
  • clearLine(from, to, targetId: string?, ignore: { string }?): boolean: whether no collider stands between the two points (a physics raycast; models without colliders never block).
  • reset(): forgets every cached target (tests use it between cases).