Enemy AI Framework

Systemssystemenemiesproject check
Checked against the project files: In the project every FSM enemy currently sits at 1 health, so they are not damage sponges; the multi-hit pools described here are design headroom, not current fact.

High-Level Overview: Every enemy in the game is assembled from one shared behaviour core plus its own decision graph. The core owns everything enemies have in common (noticing, chasing, attacking, taking damage, dying, respawning), so an individual enemy is defined entirely by how it decides what to do next. Designing a new enemy means designing a decision, not designing an enemy from scratch.

The Shared Core

These behaviours are true of every enemy without being specified per enemy:

  • Sleep and wake. Enemies think only when a player is nearby, waking at 35m and sleeping again at 45m. Enemies are cheap to place in bulk.
  • Damage. Hit points are counted in hits, not chip damage. A short invulnerability window after each hit (0.2s) stops one sustained attack draining a whole bar in a single pass, and every hit plays a colour flash.
  • Death. A poof effect, an optional pickup dropped onto the ground beneath where the enemy died (so an enemy killed in mid-air still drops something reachable), and a respawn after a long delay.
  • Death feel. A killing blow applies only half the normal knockback, so a defeated enemy pops back and dies snappily instead of sailing off screen.
  • Alerts. A ! popup the moment an enemy first notices a player, and a second popup when it commits to an attack.

The Shared Tuning Vocabulary

Every enemy is tuned with the same six numbers, so these words mean the same thing across the whole roster.

TermTypicalMeaning
Aggro range10mDistance at which the enemy notices a player and gives chase.
Attack range1.5mDistance at which it commits to an attack.
Leash range10mDistance from home past which it gives up and walks back.
Windup0.6sThe telegraph. The player's window to read the attack.
Active0.5sThe hit frames.
Recovery1.9sThe punish window. The player's window to hit back.

Windup and recovery are the two numbers that decide whether an enemy is fair. Windup is what the player reads; recovery is what they are rewarded with. Everything else is pacing.

The Standard Loop

Most enemies run the melee graph:

Idle or Patrol → Chase → Windup → Attack → Recover → Chase
                    ↓ (leashed)
                Return Home → Idle or Patrol

Enemies that fight at range replace the middle of this with a decision step that picks between two or more attacks by distance and cooldown.

Patrols are optional and come in two shapes: ping-ponging between placed points, or wandering at random around the spawn. An enemy with no patrol simply idles where it stands.

How Enemies Answer the Duo's Abilities

An enemy opts into each of the duo's tools individually. This is the main lever for making an enemy feel like part of the combat system rather than an obstacle sitting beside it.

AbilityEffect on an enemy that accepts it
Koopa's bubbleTraps the enemy. A bubbled enemy is a homing target for Koopa's spin: trap, then pop.
Kiko's tornadoSweeps the enemy up. The tornado is always the kill: the enemy dies inside the funnel and the corpse is flung clear.
Melee and projectilesReceived through a single hurtbox. Kiko's peck is granted extra reach, because his beak strikes ahead of his body.