Log inGet started
World

Bastion Works: Towers, Turrets and Targeting Kit

README.md

turretsKit.combat

What a hit does, on the peer in charge of the turret. Damage always goes through SecondWind (HK.damage), so its damage types, teams, hit effects, kill feed and multiplayer rules all apply; every other peer sees the result through SecondWind's synced health. On top of that the kit keeps the effects SecondWind has no tier dial for:

  • slow (frost): a fraction of speed taken for a few seconds. spawnerKit enemies are slowed by scaling their synced speed; a game with its own movers reads speedMultiplier(id) or listens with onSpeed(fn).
  • burn (flame): extra fire damage every half second for a few seconds.
  • cloud (poison): an area hurting everything of another team inside it every half second.
  • block (wall): enemies touching a standing wall stop (speed 0), hurt the wall with their own damage, and take its thorns.

Hits are pooled per target, damage type and kind and handed to SecondWind together every FLUSH seconds, so a crowd under many turrets costs a few SecondWind hits per enemy per second. All of it ticks in tick(dt), which turretsKit.api runs once a frame. Called by the turretsKit.Turret component; api re-exports speedMultiplier and onSpeed.

Fields

  • FLUSH: 0.12 s between pooled damage flushes.
  • KNOCKBACK: 0, the knockback passed to SecondWind (keeps path walkers on their path).

Functions

  • damage(src, targetId: string, amount: number, dtype: string, opts: any?): boolean - hurts one target on behalf of a turret src = { id, team, label, origin }. opts: dot, chained, status, crit. Pooled and applied within FLUSH. Returns false when the target is gone or dead.
  • flush(): number: applies every pooled hit now; returns how many SecondWind hits it made.
  • splash(src, pos, radius: number, amount: number, dtype: string, opts: any?): { string } : hurts every target of another team within radius, falling off to half at the edge; returns the ids hurt.
  • slow(targetId: string, amount: number, seconds: number): amount is the fraction of speed taken; the strongest slow wins and a new one refreshes the time.
  • speedMultiplier(targetId: string): number: 1 normal, 0.6 slowed by 40%, 0 held by a wall.
  • onSpeed(fn: (string, number) -> ()): () -> (): called when a target's multiplier changes; returns a function that stops it.
  • burn(src, targetId: string, dps: number, seconds: number): keeps a target burning; a hotter burn replaces a weaker one.
  • cloud(src, pos, radius: number, seconds: number, dps: number, look: string?): leaves a poison cloud and tells every peer so it can draw it.
  • setWall(id: string, info: any) / removeWall(id: string): a wall turret reports { pos, yaw, half = { halfWidth, halfDepth }, blockRadius, thorns, team, owner } every tick while it is a wall.
  • blockedBy(targetId: string): string?: which wall is holding a target.
  • tick(dt: number): flushes damage, ticks slows and walls (10 Hz), burns and clouds (every half second).
  • stats(): any: { damage, hits, secondWindCalls, pooledNow, slows, burns, clouds, blocked, walls }.
  • reset(): drops every slow, burn, cloud, block and pending hit, restoring enemy speeds this peer set.