38 lines
5.1 KiB
Plaintext
38 lines
5.1 KiB
Plaintext
You are implementing PHASE 2 ONLY of "Body Snatcher" in index.html (already exists in this directory from Phase 1). @AGENTS.md is the full spec — read it. @verify.js is the gate; run `node verify.js 2` until it prints "PHASE 2 PASSED" (exit 0). PRESERVE everything from Phase 1; EDIT index.html, do not rewrite from scratch.
|
|
|
|
SCOPE for Phase 2 — possession + the first 3 enemies + pathfinding + pacing rules. Do NOT add the other 9 enemies, procgen, shop, or save/load (later phases).
|
|
|
|
1. ENEMY DATA MODEL. Each enemy is an object: { type, hp, maxHp, damage, speed, x, y, facing:{x,y}, aggroed:false, overheatLeft:0, lockout:0, ... }. Add enemies to window.GAME.enemies. speed = number of turns BETWEEN moves (2 = moves every 2 turns; 0 = immobile). Implement spawn(type,x,y) to create and return the enemy at tile coords and push it into enemies[].
|
|
- Brute: maxHp 8, damage 3, speed 2. Slow A* chase; heavy melee 2 dmg to the PLAYER when adjacent.
|
|
- Skitterer: maxHp 2, damage 1, speed 2. Loose swarm/flank; weak melee 1 dmg to the PLAYER.
|
|
- Sentinel: maxHp 4, damage 1, speed 2 (repositions slowly). NO melee. RANGED: keeps ~4 tile distance, fires a BURST of 3 projectiles (one per turn) toward the player, then sets overheatLeft = 3 and CANNOT fire while overheatLeft > 0 (it only repositions slowly during overheat). Projectiles hit the PLAYER ONLY.
|
|
Make (maxHp, damage, speed) distinct across whatever enemies exist (Brute/Skitterer/Sentinel here).
|
|
|
|
2. POSSESSION. While the player is a GHOST and presses SPACE (' ' or 'Space') with an enemy on an adjacent tile, begin possession; it completes within 1 turn. On completion: state -> 'possessed'; player.host = that enemy object; player.ghost = false; the player uses the host's hp/damage/speed/abilities. SPACE while possessed = the host's attack/special (for these 3: Brute melee swing in facing dir, Skitterer rapid weak hit, Sentinel fires a projectile in facing dir with the SAME 3-shot-burst-then-overheat rhythm so it can't stunlock). The ghost timer PAUSES while possessed.
|
|
|
|
3. VOLUNTARY ABANDON (X). While possessed, input('x') ejects the player as a ghost: state -> 'playing'; player.host = null; player.ghost = true; the timer RESUMES from where it paused (do NOT reset it to 15 — only a host death resets the timer). The abandoned host SURVIVES at its current HP, stays in enemies[], is pacified/stunned for 2 turns, and gets a re-possess lockout: set enemy.lockout = 2 (or similar) so it CANNOT be re-possessed for 2 turns (prevent i-frame spam). The harness checks timer did not increase after abandon.
|
|
|
|
4. PATHFINDING (A* or BFS). Enemies navigate AROUND walls toward the player — never through them. Aggro: every enemy starts DOCILE (idle/wander, does NOT path to the player). It only begins to chase/attack when the player is within its aggro radius (~6 tiles) AND has line of sight (not through walls). Track this on enemy.aggroed (bool). Outside aggro / without LOS, an enemy stays put or wanders; it must NOT beeline across the map.
|
|
|
|
5. NO FRIENDLY FIRE (THE MOST IMPORTANT RULE). Enemy melee, AoE, and projectiles ONLY ever damage the PLAYER (the ghost or your current host). Enemies NEVER reduce each other's HP. (Your possessed host's attacks still damage enemies normally.) Without this rule the game is broken.
|
|
|
|
6. ESSENCE. When an enemy dies, drop essence by type (Brute=3, Skitterer=1, Sentinel=3) into window.GAME.essence. Add a helper addEssence(n) if convenient. Essence persists for the run.
|
|
|
|
7. HUD. While possessed, the HUD shows the host's HP and a contextual SPACE hint naming the current body's action ("SPACE: Heavy swing", "SPACE: Fire burst", etc.) and an "X: Abandon host" hint. While ghost, "SPACE: Possess".
|
|
|
|
8. Place a few Brutes/Skitterers/Sentinels on the Phase-1 test dungeon at newRun() so the player has something to possess. Keep the player's spawn area clear of enemies (>=5 tiles).
|
|
|
|
HARNESS CONTRACT (read @verify.js phase2; match exactly):
|
|
- spawn('brute',x,y).maxHp===8 (or hp===8), damage===3, speed>=2.
|
|
- spawn('skitterer',...).maxHp/hp===2, damage===1, speed===2.
|
|
- spawn('sentinel',...).maxHp/hp===4.
|
|
- input(' ') on an adjacent enemy -> state 'possessed' within a few ticks; player.host.type is that enemy.
|
|
- input('x') while possessed -> state 'playing', host null, timer>0, timer not increased, former host still in enemies[], lockout field>0 on it.
|
|
- An enemy within ~2-5 tiles with clear LOS closes distance over ticks (aggro+pathfind).
|
|
- An enemy far away (>=7 tiles) with LOS blocked stays docile (does not close distance); its .aggroed===false if exposed.
|
|
- Two enemies adjacent to each other, far from the player: neither loses HP over 12 ticks (no friendly fire).
|
|
- A Sentinel within 3-5 tiles with clear LOS: fires projectiles (G.projectiles grows), then enters a multi-turn no-fire window (sentinel.overheatLeft>0 observable, OR a >=3-turn stretch with no new projectiles).
|
|
- Killing an enemy via the possessed host's attack increases G.essence.
|
|
|
|
When done, run `node verify.js 2` yourself and fix every failure until "PHASE 2 PASSED". Also re-run `node verify.js 1` to ensure no regression. Write less code; everything ships working.
|