Log inGet started
World

Lantern Depths: Find the Shade Dash, Slay the Thorn Knight

Branchmain
Branchesmain
Commitda5ac13948

README.md

Boss2D

A 2D side-scrolling pixel-art boss with two phases, for twoDKit platformers: put it on an entity whose position is the boss's start (feet on the arena floor), pick a kind (thornKnight, hiveQueen or ironWarden) and give it the arena bounds. It needs no sibling components: it draws its own sprite and effects on temporary child entities, and finds players through twoDKit's player registry.

local boss = entity.spawnSynced("Boss", { position = { 18, 1, 0 } })
boss.component.add("pixelBosses.Boss2D", { kind = "hiveQueen", arenaMinX = 1, arenaMinY = 1, arenaMaxX = 23, arenaMaxY = 11 })
-- in play, from any peer:
boss.component.get("pixelBosses.Boss2D"):activate()
  • States: dormant (waits, cannot be hurt) -> activate() -> intro (a roar; sword hits already count) -> fighting -> defeated at 0 health (a death animation with a chain of explosions). reset() puts it back at full health, dormant, at its start, with every projectile cleared.
  • Brain: on the authority an aiKit.bt behaviour tree picks what happens each frame (asleep, finished, dying, phase change, waking, busy, next attack); the attacks themselves are pixelBosses.moves.
  • Health: a SecondWind.pool record on the authority, mirrored into the synced health.
  • Phases: phase 2 starts at or below half health (Defs.PHASES) with a roar, a hit-stop and a burst, and adds the kind's phase-2 attacks.
  • Damage: damage(amount, attackerId, dirX) on any peer; the authority applies it (flash, a small flinch toward dirX). With slash2D installed the boss registers itself as a slash target on every peer, at its live body box, and every peer flashes it and plays juiceKit sparks for every counted sword hit (pixelBosses.feel).
  • Hurting players: each peer tests only its own player against the body and every live hazard and calls pixelBosses.api hurtPlayer (default: a Trapline life), at most once a second.
  • Multiplayer: spawn the entity with entity.spawnSynced; its owner runs the AI and writes each move once into the synced move field, and every peer simulates the same moves on the shared clock.

Fields: kind, arenaMinX, arenaMinY, arenaMaxX, arenaMaxY, maxHealth (0 = the kind's default; resolved in play), and read-only synced health, phase, state, move, hitDir, resets; per-peer contactDamage, debugLabel, sound. Methods: activate, reset, damage, isDefeated, hitbox, hazards, displayName, maxHp. The package README lists every attack per phase.