What it does
Each enemy stands at its post or walks a beat, turning at walls. It notices the player when they come into its view cone with a clear line of sight, or when a shot is heard through open floor and open doors, and after a moment's reaction it hunts: along the map's shortest path, opening doors as it reaches them, replanning as the player moves.
Close enough and in sight, it stops to aim, then attacks: a hitscan shot whose chance falls with distance and when the player is moving, a melee bite or swing, or a projectile for the game to fly. Only a few aim at once. Hurt, it may flinch; killed, it falls and leaves its drops. The pack reports each of these as an event, and for drawing it says which of four or eight sprite angles to show from where the player stands.
Features
- Guard and patrol — enemies hold a post or walk a beat.
- Sight and hearing — a view cone and range, and shots heard through open doors.
- Chasing — shortest paths through doors, replanned as you move.
- Three attacks — hitscan with falling accuracy, melee, and projectiles to dodge.
- Fair fights — a cap on how many aim at once, and a skill scale on damage.
- Pain and death — flinches, drops and scores.
- Sprite angles — which of 4 or 8 views to show.
- Voices — noticing, attacking, pain, death, and idle and hunting sounds at intervals, each where the enemy is.
- Infighting — an enemy hurt by another kind turns on it.
- Any map — cell corridors or sector levels with heights, flyers included, through one small interface.
Good for
- A corridor shooter —
corridor-shooterruns its guards, dogs and monsters on it. - A stealth maze — narrow view cones, short reactions and deaf or sharp-eared guards.
- A horror crawl — slow, tough enemies that hunt by sound.
Make it yours
Hit points, speeds, size, sight, view cone, reaction, attack, accuracy, wind-up, cooldown, pain, score and drops are per kind. Pistol guards with a 20-cell sight and quick dogs that bite is one cast; skeletons that swing, archers and wraiths whose shots can be sidestepped, and a slow brute is another.
A quick look
Spawn a patrol and step the enemies with where the player is.
const horde = fpsEnemies.createHorde({ defs: [guard, hound] }, map);
horde.spawn('guard', 5.5, 3.5, 0, 'patrol');
for (const e of horde.tick(dt, { x: px, z: pz, alive: true })) if (e.type === 'attack' && e.hit) hurt(e.damage);
Works with
cell-dungeonandsector-map— maps they see across and walk.fps-bosses— boss fights among them.audio— positional sound for their voices.fps-weapons— the player's side of the fight.corridor-shooter— the two together, as a game.
Good to know
- One target: they hunt a single player.
- They do not push past one another, so they can overlap in a narrow corridor.
- They walk the routes their map gives; for open 3D levels use a navmesh instead.






