Bosses
Usage guide of enemy.boss: bosses as data, health-gated phases, telegraphed patterns (slam, sweep, lunge, nova, summon), a scripted end instead of a death, the boss bar in the interface with its title card, boss bar variables, events and hooks.
Boss fights (enemy.boss) #
What it is for #
Boss fights as data: health-gated phases that cycle telegraphed patterns (slam, sweep, lunge, expanding rings and summons), with an intro, a boss health bar in the interface and a defeat event. A boss is an enemy of enemy.ai whose document names a boss document. Shared concepts of the family are in the Enemies in your game guide.
Turn it on #
gripforge_gamekit_install { project_id: "gkp_…", id: "enemy.boss" }
gripforge_gamekit_configure { project_id: "gkp_…", id: "enemy.boss",
config: { "introSeconds": 1.5, "telegraphScale": 1,
"screenBar": "auto", "introCard": 3 } }
Needs enemy.ai, combat.melee, combat.core, game.engine; installing the kit brings them along.
First example #
<!-- test: kits/game_engine/host/tests/boss_recovery.rs::nova_recovery_reaches_only_the_last_real_strike_and_holds_the_brain --> An enemy names a boss document; the boss has one phase and one pattern. This is the shape the test builds (an optional recovery of 0 to 60 seconds follows a pattern; a nova applies it only after its last ring).
{ "enemies": [{ "id": "keeper", "name": "Keeper", "health": 100, "boss": "keeper", "attacks": [] }],
"bosses": [{ "id": "keeper", "name": "Keeper",
"patterns": { "slam": { "type": "slam", "damage": 20, "radius": 4, "windup": 0.8, "at": "target" } },
"phases": [{ "id": "only", "untilHealth": 0, "patterns": ["slam"], "pause": 1.5 }] }] }
Settings and defaults #
| Setting | Default | Meaning |
|---|---|---|
introSeconds | 1.5 | Seconds the boss waits after spawning (0 to 10). |
telegraphScale | 1 | Multiplies every pattern windup (0.25 to 3). |
screenBar | auto | Who draws the boss bar in the interface: auto, on or off (see below). |
introCard | 3 | Seconds the name of the boss stays big in the middle of the screen when its fight starts (0 to 10; 0: no title card). |
A document of bosses holds patterns (id to pattern) and phases (id, untilHealth, patterns, pause, enrage). A pattern has a type: slam (damage, radius, windup, at), sweep (range, arc), lunge (distance, width), nova (rings, radiusStep, interval) or summon (enemy, count); each has an optional recovery. The boss model is bound to the asset slot boss_model.
Scripted end #
<!-- test: kits/game_engine/host/tests/boss_end.rs::the_defeat_of_the_player_ends_the_fight_without_a_death_or_a_respawn --> A fight the story decides (a battle that must be lost, a boss that flees, a scene that takes over before the last blow) is an optional end on the boss document, instead of a death:
{ "id": "breaker", "name": "The Breaker",
"patterns": { "sweep": { "type": "sweep", "damage": 25, "range": 4, "arc": 160, "windup": 0.9 } },
"phases": [{ "id": "only", "untilHealth": 0, "patterns": ["sweep"], "pause": 1.2 }],
"end": { "at": 0.1, "playerDefeat": "end", "hold": 2 } }
| Field | Default | Meaning |
|---|---|---|
at | none | Health ratio (0 to 1) at or below which the fight ends; a lethal blow ends it too and leaves the boss that fraction of its health. |
playerDefeat | die | end: a lethal blow on the last player still up while this boss is the active one ends the fight too; that player keeps 1 health and no player.died is emitted, so checkpoints and end screens do not react. In co-op the others are defeated as usual until then. |
hold | 2 | Seconds the players take no damage after the end (0 to 30). |
Once the end is accepted the boss stands still for good, plays no more patterns and takes no more damage, and boss.ended is emitted once per fight. Start what follows from that event, for instance a trigger that plays a cinematic. Without end nothing changes: the boss dies and boss.defeated is emitted.
Boss display ownership #
enemy.boss declares the active boss, translated name and title, health, and remaining intro-card time through view(). hud.action draws the single screen bar and title card. Install and enable that HUD to display them. screenBar: auto and on request the display; off disables it. The HUD also respects hud.active, hud.show.boss and cinematic.active. A remounted card uses only its remaining time.
hud.health.entity is the generic entity ID whose health is displayed by the screen HUD, or an empty string. combat.core hides only that world health bar. Without an active HUD, the world bar remains. Other HUDs can use the same declaration for any entity kind.
Several players #
<!-- test: kits/game_engine/host/tests/boss_coop.rs::an_alternating_boss_switches_target_every_n_patterns_and_says_so --> In co-op, targeting says whom the boss goes for (1.7):
{ "id": "warden", "name": "Warden",
"targeting": { "mode": "alternate", "every": 2 } }
mode | The boss goes for |
|---|---|
first (default) | the player in scope, as in solo |
nearest | the nearest player still up |
alternate | one player for every patterns (default 2), then the next player still up; boss.target is emitted for the warning your game shows (a look, a sound, a marker under the next victim) |
A downed or dead player is never a target of nearest and alternate. Combined with end.playerDefeat: "end", the fight ends on the defeat of the last player still up, and the hold protects every player.
Services, events, variables #
- Events:
boss.started(entity,boss,name),boss.phase(entity,boss,phase),boss.pattern(entity,boss,pattern,type),boss.defeated(entity,boss),boss.ended(entity,boss,reason:thresholdorplayer_down),boss.target(entity,boss,target,previous: an alternating boss turned to another player). It listens toenemy.spawned,combat.killed,entity.despawned,engine.config.changed, andcombat.damagedwhen a boss document hasend. - Variables:
boss.name,boss.health,boss.max,boss.phase(they feed the boss bar),boss.entity(the entity of the active boss, empty when there is none) andboss.screen(true while a boss is active andscreenBaris notoff: its bar is in the interface). They are cleared at the defeat; after a scripted end the boss stays the active one. - Service
enemy.boss:bosses(),active(), andview(lang)(what the interface draws:nameandtitletranslated,health,max,phase,screen,intro,startwhich changes at eachboss.started,card: the seconds the title card still shows on the game clock, 0 once it is over,bar,entity). - Component
boss { "doc": "warden" }: on an enemy instance, makes it fight as that boss even when its enemies document names none.
Hooks and modding #
| Hook | Meaning |
|---|---|
boss.start | An enemy is about to become the active boss; cancelled, it fights with its patterns but is not announced and takes no boss bar. |
boss.phase.change | The health ratio puts the boss in another phase; phase is mutable (the id of another phase of the document); cancelled, it stays in the current one. |
boss.pattern.play | The boss is about to play the next pattern of its phase; pattern and telegraphScale are mutable; cancelled, the pattern is skipped and the boss pauses. |
boss.end | The fight of a boss with end is about to end (reason, ratio); cancelled, the fight goes on as without end for that reason and it is not asked again. |
boss.target | An alternating boss is about to turn from previous to target; target is mutable (another player still up); cancelled, it stays on previous for the next every patterns. |
Moddable: the four settings (screenBar and introCard live) and the collection bosses.
Limits #
Runs as the same Rust logic on the web, in the native player, Godot, Unity and Unreal. The hooks, the optional recovery and the scripted end are served by the web and native Rust logic; the Godot, Unity and Unreal deliveries keep the earlier fixed recoveries and do not implement end. The targeting modes are Rust logic too. The interface piece is a web fragment: engines that draw their interface natively instead of through ui.webui do not show it, and keep the bar over the boss. Unbound, the boss is drawn as a large capsule: bind a rigged model to boss_model.
Versions #
Kit 1.8.0 (hooks in 1.4.0, optional recovery in 1.5.0, scripted end in 1.6.0, several players in 1.7.0, the boss bar in the interface in 1.8.0); service enemy.boss 1.1.0. It relies on enemy.behaviors ^1 (from enemy.ai), combat.melee ^1, combat.health ^1 and game.engine ^1.
<!-- kit-services:begin -->
Services this kit uses (and that you can provide) #
| Capability | Required | Methods |
|---|---|---|
combat.health | required | alive, health |
combat.melee | required | cancel, strike |
combat.status | optional | moveMultiplier |
enemy.behaviors | required | defOf, spawn |
engine.content | optional | registerComponent |
engine.hooks | optional | run, tap, untap |
i18n.text | optional | has, language, t, text |
input.actions | optional | axis, justPressed, pressed |
npc.behavior | optional | brain, npcs, register, setBehavior |
npc.locomotion | optional | moveTo, stop |
world.ground | optional | bounds |
Any brick can serve them: a kit, or your engine (Godot provide_service, Unity Provide, Unreal ProvideService, Bevy provide_kit_service, C gfk_provide) — see the guide. <!-- kit-services:end -->