Skip to content

Fix player damage system: migrate to 3-layer defense and fix projectile owner ID#26

Open
Copilot wants to merge 83 commits intocopilot/refonte-systme-armement-bonusfrom
copilot/refactor-defensesystem-damage
Open

Fix player damage system: migrate to 3-layer defense and fix projectile owner ID#26
Copilot wants to merge 83 commits intocopilot/refonte-systme-armement-bonusfrom
copilot/refactor-defensesystem-damage

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

Player was not taking damage from enemy projectiles due to owner ID mismatch. Enemy projectiles created with owner: "enemy" (string) caused CollisionSystem entity lookup to fail, filtering out all enemy projectiles.

Critical Fixes

Enemy projectile owner ID (js/systems/CombatSystem.js)

  • Changed owner: "enemy"owner: enemy.id (numeric entity ID)
  • CollisionSystem can now resolve owner entity for damage routing

Player defense system migration (js/Game.js, js/systems/CollisionSystem.js)

  • Replaced legacy health component with defense component (shield/armor/structure layers)
  • Fixed invulnerability tracking: now on defense.invulnerable instead of health.invulnerable
  • Updated damage flow: projectile collision → DefenseSystem.applyDamage() → shield → armor → structure

XP bar field mismatch (js/Game.js, js/systems/UISystem.js)

  • Changed xpToNext: 100xpRequired: 100 to match all system expectations
  • Fixed calculation: (xp / undefined) * 100(xp / xpRequired) * 100

UI Cleanup

  • Removed duplicate legacy stats panels and health bars from index.html, js/systems/UISystem.js, js/ui/EnhancedUIComponents.js
  • Single defense UI system remains: 3-layer bars (shield/armor/structure)

Architecture

DefenseSystem integration:

// CombatSystem creates projectiles with valid owner
projectile.owner = enemy.id;  // numeric entity ID

// CollisionSystem routes damage
const ownerEntity = this.world.getEntity(projComp.owner);  // now resolves
if (ownerEntity?.type === 'enemy') {
    const damagePacket = DamagePacket.simple(damage, damageType);
    this.world.defenseSystem.applyDamage(player, damagePacket);
}

DamagePacket enforcement:

  • All damage calls now use DamagePacket structure
  • Added validation for legacy numeric calls with warnings

Debug Support

Added comprehensive debug logging gated by window.DEBUG_DEFENSE:

  • Damage application with layer details
  • Regeneration ticks
  • Collision detection flow
  • Owner entity resolution

Documentation

Moved all markdown reports to /rapports folder with detailed diagnostics.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 14, 2026 00:50
…on and crit

Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
…onstants

Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor DefenseSystem as the sole authority for damage application Centralize damage authority in DefenseSystem with DamagePacket abstraction Feb 14, 2026
Copilot AI requested a review from Linkatplug February 14, 2026 00:59
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Copilot AI changed the title Centralize damage authority in DefenseSystem with DamagePacket abstraction Refactor CombatSystem to delegate all damage to DefenseSystem Feb 14, 2026
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Copilot AI changed the title Refactor CombatSystem to delegate all damage to DefenseSystem Add unified ShipStats data model Feb 14, 2026
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Copilot AI changed the title Add unified ShipStats data model Add FinalStatsCalculator for deterministic stat aggregation Feb 14, 2026
Copilot AI and others added 30 commits February 14, 2026 13:49
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
…ion and fix debug label

Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
…E_MIN constant

Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
…m-pipeline

Add public resistance modifier API to DefenseSystem
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
…ystem

Add dirty flag system and defense sandbox for stat recalculation infrastructure
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
…shes

Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
… combat sandbox

Co-authored-by: Linkatplug <36280686+Linkatplug@users.noreply.github.com>
…ance-proof

Add combat development sandboxes and fix rendering defensive code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants