Fix NPC interaction and event handling issues - Added a visual problem-solution summary for debugging NPC event handling. - Resolved cooldown bug in NPCManager by implementing explicit null/undefined checks. - Modified PersonChatMinigame to prioritize event parameters over state restoration. - Updated security guard dialogue in Ink scenarios to improve interaction flow. - Adjusted vault key parameters in npc-patrol-lockpick.json for consistency. - Changed inventory stylesheet references to hud.css in test HTML files for better organization. feat(combat): Integrate chair kicking with punch mechanic Update chair interaction to use the punch system instead of direct kicking: **Changes to interactions.js:** - Modified swivel chair interaction to trigger player punch instead of directly applying kick velocity - Simplified chair interaction handler to just call playerCombat.punch() **Changes to player-combat.js:** - Extended checkForHits() to detect chairs in punch range and direction - Added kickChair() method that applies the same velocity calculation: - Calculates direction from player to chair - Applies 1200 px/s kick force in that direction - Triggers spin direction calculation for visual rotation - Adds visual feedback (flash chair, light screen shake) - Chairs now respond to punch AOE damage like hostile NPCs Now clicking a chair or pressing 'E' near it triggers a punch, and if the chair is in punch range and facing direction, it gets kicked with the original velocity physics. Multiple chairs can be kicked with one punch. feat(combat): Implement hostile NPC behavior and final integration (Phase 6-7) Complete hostile NPC combat system with chase behavior and integration: **Phase 6: Hostile NPC Behavior** - Modified npc-behavior.js determineState() to check hostile state from npcHostileSystem - Implemented updateHostileBehavior() with chase and attack logic: - NPCs chase player when hostile and in aggro range - NPCs stop and attack when in attack range - NPCs use directional movement with proper animations - Integration with npcCombat system for attack attempts - Added KO state check to prevent KO'd NPCs from acting **Phase 7: Final Integration** - Modified player.js to disable movement when player is KO - Added visual KO effect (50% alpha) to NPC sprites in npc-hostile.js - Connected all combat systems end-to-end: - Ink dialogue → hostile tag → hostile state → chase behavior → combat - Player interaction → punch → NPC damage → KO → visual feedback - NPC chase → attack → player damage → HP UI → game over Full combat loop now functional: hostile NPCs chase and attack player, player can punch hostile NPCs, complete visual/audio feedback, game over on KO. feat(combat): Add feedback, UI, and combat mechanics (Phase 2-5) Implement comprehensive combat feedback, UI, and mechanics: **Phase 2: Enhanced Feedback Systems** - damage-numbers.js: Floating damage numbers with object pooling - screen-effects.js: Screen flash and shake for combat feedback - sprite-effects.js: Sprite tinting, flashing, and visual effects - attack-telegraph.js: Visual indicators for incoming NPC attacks **Phase 3: UI Components** - health-ui.js: Player health display as hearts (5 hearts, shows when damaged) - npc-health-bars.js: Health bars above hostile NPCs with color coding - game-over-screen.js: KO screen with restart/main menu options **Phase 4-5: Combat Mechanics** - player-combat.js: Player punch system with AOE directional damage - npc-combat.js: NPC attack system with telegraph and cooldowns - Modified interactions.js to trigger punch on hostile NPC interaction - Integrated all systems into game.js create() and update() loops Combat now functional with complete visual/audio feedback pipeline. Player can punch hostile NPCs, NPCs can attack player, health tracking works. feat(combat): Add hostile NPC system foundation (Phase 0-1) Implement core hostile NPC combat system infrastructure: - Add #hostile tag handler to chat-helpers.js for Ink integration - Fix security-guard.ink to use proper hub pattern with -> hub instead of -> END - Add #hostile:security_guard tags to hostile conversation paths - Create combat configuration system (combat-config.js) - Create combat event constants (combat-events.js) - Implement player health tracking system with HP and KO state - Implement NPC hostile state management with HP tracking - Add combat debug utilities for testing - Add error handling utilities for validation - Integrate combat systems into game.js create() method - Create test-hostile.ink for testing hostile tag system This establishes the foundation for hostile NPC behavior, allowing NPCs to become hostile through Ink dialogue and tracking health for both player and NPCs. docs(npc): Apply codebase-verified corrections to hostile NPC plans Apply critical corrections based on actual codebase verification: CORRECTIONS.md (Updated): - ✅ Confirms #exit_conversation tag ALREADY IMPLEMENTED * Location: person-chat-minigame.js line 537 * No handler needed in chat-helpers.js - ❌ Hostile tag still needs implementation in chat-helpers.js - Provides exact code for hostile tag handler - Clarifies tag format: #hostile:npcId or #hostile (uses current NPC) - Updated action items to reflect what's already working INTEGRATION_UPDATES.md (New): - Comprehensive correction document - Issue 1 Corrected: Exit conversation already works - Issue 6 Corrected: Punch mechanics are interaction-based with AOE - Details interaction-based punch targeting: * Player clicks hostile NPC OR presses 'E' nearby * Punch animation plays in facing direction * Damage applies to ALL NPCs in range + direction (AOE) * Can hit multiple enemies if grouped (strategic gameplay) - Provides complete implementation examples - Removes complexity of target selection systems - Uses existing interaction patterns quick_start.md (Updated): - Removed exit_conversation handler (already exists) - Updated hostile tag handler code - Added punch mechanics design section - Clarified interaction-based targeting - Added troubleshooting for exit_conversation Key Findings: ✅ Exit conversation tag works out of the box ✅ Punch targeting uses existing interaction system (simpler!) ✅ AOE punch adds strategic depth without complexity ❌ Only ONE critical task remains: Add hostile tag to chat-helpers.js Impact: - Less work required (don't need exit_conversation handler) - Simpler implementation (use existing interaction patterns) - Better gameplay (AOE punches, directional attacks) - Clear path forward with exact code examples docs(npc): Add critical corrections and codebase integration review Add comprehensive review of hostile NPC plans against actual codebase: CORRECTIONS.md: - Identifies critical Ink pattern error (-> END vs -> hub) - Documents correct hub-based conversation pattern - Provides corrected examples for all Ink files - Explains why -> hub is required after #exit_conversation FORMAT_REVIEW.md: - Validates JSON scenario format against existing scenarios - Reviews NPC object structure and required fields - Documents correct Ink hub pattern from helper-npc.ink - Proposes hostile configuration object for NPC customization - Provides complete format reference and checklists review2/integration_review.md: - Comprehensive codebase analysis by Explore agent - Identifies 2 critical blockers requiring immediate attention: * Missing tag handlers for #hostile and #exit_conversation * Incorrect Ink pattern (-> END) in planning documents - Documents 4 important integration differences: * Initialization in game.js not main.js * Event dispatcher already exists (window.eventDispatcher) * Room transition behavior needs design decision * Multi-hostile NPC targeting needs design decision - Confirms 8 systems are fully compatible with plan - Provides existing code patterns to follow - Corrects integration sequence review2/quick_start.md: - Step-by-step guide for Phase 0-1 implementation - Includes complete code examples for critical systems - Browser console test procedures - Common issues and solutions - Success criteria checklist Key Findings: ✅ 90% compatible with existing codebase ❌ Must add tag handlers to chat-helpers.js before implementation ❌ Must fix all Ink examples to use -> hub not -> END ⚠️ Should follow game.js initialization pattern not main.js ⚠️ Should use existing window.eventDispatcher ⚠️ Need design decisions on room transitions and multi-targeting All critical issues documented with solutions ready. Implementation can proceed with high confidence after corrections applied. docs(npc): Add comprehensive planning documents for hostile NPC system Add detailed implementation plans for hostile NPC feature including: - Complete implementation plan with phase-by-phase breakdown - Architecture overview with system diagrams and data flows - Detailed TODO list with 200+ actionable tasks - Phase 0 foundation with design decisions and base components - Enhanced combat feedback implementation guide - Implementation roadmap with 6-day schedule Add comprehensive review documents: - Implementation review with risk assessment and recommendations - Technical review analyzing code patterns and best practices - UX review covering player experience and game feel Key features planned: - NPC hostile state triggered via Ink tags - Player health system with heart-based UI - NPC health bars and combat mechanics - Punch combat for both player and NPCs - Strong visual/audio feedback for combat - Game over system and KO states - Attack telegraphing for fairness - Enhanced NPC chase behavior with LOS - Debug utilities and error handling - Comprehensive testing strategy
22 KiB
Implementation Roadmap - NPC Hostile State
Document Purpose
This roadmap provides the recommended implementation order, incorporating all design decisions, enhanced feedback systems, and integration best practices.
Implementation Phases
Phase 0: Foundation (3-4 hours)
Purpose: Establish design decisions and foundational components
Tasks:
- Make design decisions (see
phase0_foundation.md) - Create
/js/events/combat-events.js- Event constants - Create
/js/utils/error-handling.js- Error utilities - Create
/js/utils/combat-debug.js- Debug commands - Create
/scenarios/ink/test-hostile.ink- Test Ink file - Update
/js/config/combat-config.js- Add validation - Test event system and debug commands
Deliverables:
- All design decisions documented
- Event constants defined
- Error handling utilities ready
- Debug commands functional
- Test Ink file created
- Configuration validated
Success Criteria:
- All 10 design decisions made
- Event constants imported without errors
- Debug commands work in console
- Configuration validation passes
- Test Ink loads and compiles
Phase 1: Core Systems (4-5 hours)
Purpose: Build health and state management systems
Tasks:
1.1 Player Health System
File: /js/systems/player-health.js
- Create module with state initialization pattern
- Implement
initPlayerHealth()with resetable state - Implement
getPlayerHP(),setPlayerHP() - Implement
damagePlayer(amount)with validation - Implement
healPlayer(amount)with validation - Implement
isPlayerKO()check - Emit events using
CombatEventsconstants - Add error handling throughout
- Add to
window.playerHealth - Test with debug commands
1.2 NPC Hostile System
File: /js/systems/npc-hostile.js
- Create module with Map-based state storage
- Define hostile state object structure
- Implement
initNPCHostileSystem() - Implement
setNPCHostile(npcId, isHostile) - Implement
getNPCHostileState(npcId)with safe defaults - Implement
damageNPC(npcId, amount)with validation - Implement
isNPCKO(npcId),canNPCAttack(npcId) - Add state cleanup when NPC destroyed
- Emit events using
CombatEventsconstants - Add error handling and null checks
- Add to
window.npcHostileSystem - Test with debug commands
1.3 Test Core Systems
- Use
CombatDebug.setPlayerHP(50)- verify HP changes - Use
CombatDebug.damagePlayer(20)- verify events fire - Use
CombatDebug.makeHostile('test_npc')- verify state changes - Verify error handling with invalid inputs
- Check console for validation errors
Deliverables:
- Player health system functional
- NPC hostile system functional
- Both testable via debug commands
- Events emitting correctly
Phase 2: Enhanced Feedback Systems (4-5 hours)
Purpose: Build visual and audio feedback for combat
Tasks:
2.1 Damage Numbers
File: /js/systems/damage-numbers.js
- Create
DamageNumberPoolclass - Implement object pooling (20 objects)
- Implement
show(x, y, damage, isCritical, isMiss) - Add float-up animation with tweens
- Support critical hits (larger, red text)
- Support miss display
- Add to
window.damageNumbers - Test: spawn multiple numbers rapidly
2.2 Screen Effects
File: /js/systems/screen-effects.js
- Create red flash overlay
- Implement
flashDamage()with config duration - Implement
flashHeal()(green flash) - Implement
flashWarning()(orange flash) - Implement
shake()with intensity parameter - Add helper methods:
shakeLight(),shakeMedium(),shakeHeavy() - Respect accessibility settings
- Add to
window.screenEffects - Test: trigger each effect type
2.3 Sprite Effects
File: /js/systems/sprite-effects.js
- Implement
flashSprite(sprite, color, duration) - Implement
flashSpriteRepeat(sprite, color, times, duration) - Implement
shakeSprite(sprite, intensity, duration) - Test with player and NPC sprites
2.4 Attack Telegraph
File: /js/systems/attack-telegraph.js
- Create
AttackTelegraphclass - Add exclamation mark icon
- Add attack range circle indicator
- Implement
show()with pulse animation - Implement
hide()and cleanup - Implement
updatePosition()for movement - Test: show/hide telegraph on NPC
2.5 Combat Sounds (Optional for MVP)
File: /js/systems/combat-sounds.js
- Create
CombatSoundsclass - Add placeholder sound loading (or skip)
- Implement play methods for each sound type
- Respect audio settings
- Gracefully handle missing sounds
- Add to
window.combatSounds
Deliverables:
- Damage numbers floating correctly
- Screen flash and shake functional
- Attack telegraph displays
- Sound system ready (even if no audio files yet)
Test Scenario:
// In console
CombatDebug.damagePlayer(20)
// Should show: screen flash, shake, damage number, sound
Phase 3: UI Components (3-4 hours)
Purpose: Build health display UI
Tasks:
3.1 Player Health UI
File: /js/systems/player-health-ui.js
- Create HTML structure for hearts container
- Add CSS styling (above inventory)
- Implement
initPlayerHealthUI() - Implement
updatePlayerHealthUI()- calculate hearts - Implement
showPlayerHealthUI()/hidePlayerHealthUI() - Handle full/half/empty hearts display
- Listen to
CombatEvents.PLAYER_HP_CHANGED - Context-aware visibility (show near hostiles)
- Test: verify hearts update on damage
- Test: verify hearts hidden at full HP
3.2 NPC Health Bar UI
File: /js/systems/npc-health-ui.js
- Create
HealthBarclass (Phaser Graphics) - Implement color-based fill (green/yellow/red)
- Implement
createHealthBar(scene, npcId, npc) - Implement
updateHealthBar(npcId, currentHP, maxHP) - Implement
updatePositions()- follow NPCs - Implement
destroyHealthBar(npcId) - Add to scene depth correctly
- Test: health bar follows NPC movement
- Test: health bar updates on damage
3.3 Game Over UI
File: /js/systems/game-over-ui.js
- Create HTML overlay structure
- Add CSS styling (fullscreen, centered)
- Implement
initGameOverUI() - Implement
showGameOver()with stats - Show: defeated by, damage dealt, time survived
- Add buttons: Restart, Load Save, Main Menu
- Implement
handleRestart()- reload or reset state - Listen to
CombatEvents.PLAYER_KO - Disable player controls when shown
- Test: KO triggers game over screen
- Test: restart button works
Deliverables:
- Hearts display and update correctly
- NPC health bars appear above hostile NPCs
- Game over screen functional
Phase 4: Animation Systems (2-3 hours)
Purpose: Create combat animations (placeholders)
Tasks:
4.1 Combat Animations
File: /js/systems/combat-animations.js
- Implement
playPlayerPunchAnimation(scene, player, direction)- Use animation completion callback (not timer)
- Apply red tint during animation
- Play walk animation
- Return promise that resolves on completion
- Clear tint and return to idle
- Add safety timeout (1000ms)
- Implement
playNPCPunchAnimation(scene, npc, direction)- Same pattern as player
- Use NPC-specific animation keys
- Test animations with both player and NPC
4.2 KO Sprites
File: /js/systems/npc-ko-sprites.js
- Implement
replaceWithKOSprite(scene, npc) - Store original position
- Destroy active sprite
- Create grayed sprite (tint 0x666666)
- Rotate 90 degrees (fallen)
- Set alpha 0.5
- Disable physics body
- Update npc.sprite reference
- Set npc.isKO flag
- Test: NPC sprite replaced correctly
Deliverables:
- Punch animations play with proper timing
- KO sprites appear when NPC defeated
Phase 5: Combat Mechanics (4-5 hours)
Purpose: Implement punch mechanics for player and NPCs
Tasks:
5.1 Player Combat System
File: /js/systems/player-combat.js
- Initialize combat state (cooldown, isPunching)
- Implement
initPlayerCombat() - Implement
canPlayerPunch()- check cooldown, state, KO - Implement
playerPunch(targetNPC):- Play punch sound
- Play punch animation (await)
- Check target still in range
- If hit: apply damage, show feedback
- If miss: show miss indicator
- Start cooldown timer
- Implement
updatePlayerCombat(delta)- update cooldowns - Implement
getHostileNPCsInRange()helper - Add to
window.playerCombat - Integrate all feedback systems
- Test: punch hostile NPC, verify damage
- Test: punch out of range, verify miss
5.2 NPC Combat System
File: /js/systems/npc-combat.js
- Implement
initNPCCombat() - Implement
canNPCAttack(npcId, npc, playerPos):- Check hostile state
- Check cooldown
- Check if KO
- Check player in range
- Implement
npcAttack(npcId, npc):- Show attack telegraph
- Play warning sound/effect
- Wait wind-up duration (500ms)
- Hide telegraph
- Play attack animation (await)
- Check player still in range
- If hit: damage player, strong feedback
- If miss: play miss sound
- Update cooldown
- Implement
updateNPCCombat(delta)- update cooldowns - Add to
window.npcCombat - Integrate all feedback systems
- Test: NPC attacks player, verify damage
- Test: telegraph shows before attack
Deliverables:
- Player can punch hostile NPCs
- NPCs can attack player
- Hit/miss detection works
- All feedback integrated
- Cooldowns prevent spam
Phase 6: Behavior System Extensions (3-4 hours)
Purpose: Add hostile behavior to NPC system
Tasks:
6.1 Extend NPC Behavior
File: /js/systems/npc-behavior.js (MODIFY)
- Import hostile system and config
- Add hostile check in
updateNPCBehaviors()loop - Implement
updateHostileBehavior(npc, playerPosition, delta):- Enable LOS (360 degrees)
- Check if player in LOS
- If in LOS: chase player using pathfinding
- Calculate distance to player
- If in attack range: stop and attack
- If not in LOS: enter search state or patrol
- Implement
moveNPCTowardsTarget(npc, targetPosition):- Use existing pathfinding system
- Set chase speed from config
- Throttle pathfinding (recalc every 500ms)
- Implement
stopNPCMovement(npc) - Handle room transitions (NPC stops at door)
- Test: NPC chases player when hostile
- Test: NPC attacks when in range
- Test: NPC returns to patrol when calm
6.2 Extend LOS System
File: /js/systems/npc-los.js (MODIFY)
- Implement
enableNPCLOS(npc, range, angle):- Create los object if doesn't exist
- Set enabled, range, angle
- Implement
setNPCLOSTracking(npc, isTracking):- Set angle to 360 if tracking
- Set angle to 120 if not
- Export new functions
- Test: LOS enabled when NPC becomes hostile
- Test: 360-degree vision works
Deliverables:
- Hostile NPCs chase player
- NPCs attack when in range
- NPCs use pathfinding correctly
- LOS system extends dynamically
Phase 7: Integration Points (3-4 hours)
Purpose: Connect systems together
Tasks:
7.1 Ink Tag Handler
File: /js/minigames/helpers/chat-helpers.js (MODIFY)
- Import
CombatEvents - Add hostile tag filter in
processGameActionTags() - Implement
processHostileTag(tag, ui):- Parse NPC ID from tag
- Call
setNPCHostile(npcId, true) - Emit
CombatEvents.NPC_BECAME_HOSTILE - Exit conversation immediately
- Log hostile trigger
- Test with test-hostile.ink file
- Verify hostile state triggered
- Verify conversation exits
7.2 Update Security Guard Ink
File: /scenarios/ink/security-guard.ink (MODIFY)
- Review all paths ending with
-> END - Replace with
# exit_conversationwhere appropriate - Or return to hub with
-> hub - Add
# hostile:security_guardto hostile paths:- hostile_response knot
- escalate_conflict knot
- Ensure all hostile paths have
# exit_conversation - Verify hub pattern works (all choices loop or exit)
- Test all dialogue paths
- Verify hostile trigger works
7.3 Player Movement Controls
File: /js/core/player.js (MODIFY)
- Add KO check in
updatePlayerMovement():- Check
window.playerHealth?.isPlayerKO() - If KO: stop velocity, play idle, return early
- Check
- Add KO check in
movePlayerToPoint():- If KO: log and return early
- Test: player cannot move when KO
- Test: player stops when reaching 0 HP
7.4 Punch Interaction
File: /js/systems/interactions.js (MODIFY)
- Import
COMBAT_CONFIG - Implement
checkHostileNPCInteractions():- Get player position
- Get NPCs in current room
- Find hostile NPCs in punch range
- Select closest as target (or in facing direction)
- Store in
window.currentPunchTarget - Show visual indicator on target
- Add punch key handler (SPACE):
- Check if currentPunchTarget exists
- Check if canPlayerPunch()
- Call playerCombat.playerPunch()
- Call checkHostileNPCInteractions() in update loop
- Test: punch indicator shows near hostile NPC
- Test: SPACE key punches NPC
- Test: multiple hostile NPCs, correct target selected
Deliverables:
- Hostile tag works in Ink
- Security guard triggers hostile correctly
- Player can punch near hostile NPCs
- Player movement disabled when KO
Phase 8: Main Integration (2-3 hours)
Purpose: Initialize all systems in main game
Tasks:
8.1 Initialize Systems
File: /js/main.js (MODIFY)
- Import all new modules
- In create() method, initialize systems in order:
- Validate
COMBAT_CONFIG - Init player health:
window.playerHealth = initPlayerHealth() - Init player health UI:
initPlayerHealthUI() - Init NPC hostile system:
window.npcHostileSystem = initNPCHostileSystem() - Init NPC health UI:
initNPCHealthUI(this) - Init combat systems:
window.playerCombat = initPlayerCombat() - Init NPC combat:
window.npcCombat = initNPCCombat() - Init feedback systems:
initDamageNumbers(this)initScreenEffects(this)initCombatSounds(this)(optional)
- Init game over UI:
initGameOverUI() - Init debug commands:
window.CombatDebug
- Validate
8.2 Set Up Event Listeners
- Listen to
PLAYER_HP_CHANGED→ update health UI - Listen to
PLAYER_KO→ show game over, disable movement - Listen to
NPC_BECAME_HOSTILE→ enable LOS, create health bar, create attack telegraph - Listen to
NPC_KO→ replace sprite, destroy health bar - Test: all events trigger correct handlers
8.3 Update Game Loop
- In update(time, delta) method:
- Call
window.playerCombat?.update(delta) - Call
window.npcCombat?.update(delta) - Call
window.npcHealthUI?.updatePositions() - Call
checkHostileNPCInteractions()
- Call
- Test: systems update each frame
- Test: health bars follow NPCs
Deliverables:
- All systems initialized without errors
- Events connected correctly
- Update loop includes combat systems
- Full integration working
Phase 9: Testing and Polish (4-5 hours)
Purpose: Comprehensive testing and bug fixes
Tasks:
9.1 System Integration Tests
- Start game, verify no console errors
- Load security guard conversation
- Trigger hostile response (escalate_conflict)
- Verify: guard becomes hostile, conversation exits
- Verify: health bar appears above guard
- Verify: guard chases player
- Verify: attack telegraph shows before guard attacks
- Verify: player takes damage, screen flash/shake
- Verify: hearts appear and update
- Verify: player can punch guard (SPACE key)
- Verify: damage number appears on hit
- Verify: miss indicator on miss
- Verify: guard health bar updates
- Verify: guard KO'd at 0 HP, sprite replaced
- Verify: player KO'd at 0 HP
- Verify: game over screen appears
- Verify: restart button works
9.2 Edge Case Tests
- Punch when NPC moves out of range during animation
- Rapid SPACE presses (cooldown should prevent)
- Multiple hostile NPCs in same room
- Hostile NPC loses sight of player
- Player leaves room with hostile NPC
- Player re-enters room with hostile NPC
- Damage at exactly 0 HP (shouldn't go negative)
- Very rapid damage (multiple NPCs attacking)
- Conversation while hostile NPC nearby
- Save/load with hostile NPC (if save system exists)
9.3 Visual Polish
- Hearts clearly visible and positioned correctly
- Health bars don't overlap with other UI
- Damage numbers readable on all backgrounds
- Red tint visible during punches
- KO sprite clearly different from active
- Game over screen centered and readable
- Attack telegraph clearly visible
- Screen flash not too intense
- Test on different screen sizes
9.4 Performance Testing
- Run with 5 hostile NPCs in one room
- Monitor frame rate (should stay 60fps)
- Check update times in profiler
- Verify pathfinding throttling works
- Check memory usage (object pooling)
- Test for 60 seconds of continuous combat
9.5 Configuration Tuning
- Playtest and adjust values:
- Player HP (too easy/hard?)
- Player damage (too strong/weak?)
- NPC HP (too easy/hard to defeat?)
- NPC damage (too punishing?)
- Chase speed (too fast/slow?)
- Attack ranges (feel right?)
- Cooldowns (too spammy/sluggish?)
- Wind-up duration (fair/unfair?)
- Document final values in config
Deliverables:
- All tests passing
- Edge cases handled gracefully
- Visual polish applied
- Performance acceptable
- Configuration tuned for fun gameplay
Phase 10: Documentation (1-2 hours)
Purpose: Document the implementation
Tasks:
10.1 Code Documentation
- Add JSDoc comments to all public functions
- Document event payloads
- Document configuration options
- Add file header comments
10.2 Usage Documentation
- Document hostile tag usage in Ink
- Add example hostile conversation
- Document combat configuration
- Add troubleshooting guide
- Update game mechanics documentation
Deliverables:
- Code well documented
- Usage examples provided
- Troubleshooting guide available
Total Estimated Time
| Phase | Hours |
|---|---|
| Phase 0: Foundation | 3-4 |
| Phase 1: Core Systems | 4-5 |
| Phase 2: Enhanced Feedback | 4-5 |
| Phase 3: UI Components | 3-4 |
| Phase 4: Animation Systems | 2-3 |
| Phase 5: Combat Mechanics | 4-5 |
| Phase 6: Behavior Extensions | 3-4 |
| Phase 7: Integration Points | 3-4 |
| Phase 8: Main Integration | 2-3 |
| Phase 9: Testing & Polish | 4-5 |
| Phase 10: Documentation | 1-2 |
| TOTAL | 33-44 hours |
Recommended Schedule: 5-6 full working days
Critical Success Factors
- Complete Phase 0 First - Design decisions prevent rework
- Test After Each Phase - Don't accumulate bugs
- Use Debug Commands - Test systems in isolation
- Integrate Incrementally - Don't wait for Phase 8
- Strong Feedback Early - Makes testing more enjoyable
- Handle Errors Gracefully - Systems should not crash
- Performance Monitor - Check frame rate regularly
- Playtest Often - Feel is as important as function
Risk Mitigation
If Behind Schedule:
- Skip sound effects (Phase 2.5)
- Simplify game over screen (Phase 3.3)
- Use simpler damage numbers (Phase 2.1)
- Defer polish items (Phase 9.3)
If Technical Issues:
- Have fallbacks for each feature
- Graceful degradation (missing sounds, etc.)
- Use debug commands to isolate problems
- Test in isolation before integration
If Gameplay Doesn't Feel Good:
- Adjust config values first (easiest)
- Add more feedback (screen shake, sounds)
- Increase wind-up time (fairness)
- Reduce NPC damage (less punishing)
Final Checklist
Before considering complete:
- All systems functional
- No console errors during normal play
- Player health system works correctly
- NPC hostile system works correctly
- Combat feels responsive with feedback
- UI elements display correctly
- Ink integration works
- Security guard triggers hostile correctly
- Performance is acceptable (60fps)
- Edge cases handled gracefully
- Configuration tuned for fun
- Code documented
- Debug commands available
- Tested with multiple scenarios
Quick Start Implementation
Day 1:
- Complete Phase 0 (foundation)
- Complete Phase 1 (core systems)
- Test with debug commands
Day 2:
- Complete Phase 2 (feedback systems)
- Complete Phase 3 (UI components)
- Visual systems working
Day 3:
- Complete Phase 4 (animations)
- Complete Phase 5 (combat mechanics)
- Combat functional
Day 4:
- Complete Phase 6 (behavior)
- Complete Phase 7 (integration)
- Hostile NPCs working
Day 5:
- Complete Phase 8 (main integration)
- Start Phase 9 (testing)
- Full integration complete
Day 6:
- Complete Phase 9 (testing & polish)
- Complete Phase 10 (documentation)
- Feature complete
This roadmap provides a structured path to implementing the hostile NPC feature with high success probability.