Files
tactical-shooter/server/scripts/combat/damage_processor.gd
T
shawn 4a5264c5b0 Fix headless class_name dependencies
- Replaced TeamData.Team type hints with int in all scripts
- Added explicit preloads for headless mode class resolution
- Created stub LagCompensation and DamageProcessor scripts
- Fixed PluginManager, SpawnManager, EconomyManager, BuyZone,
  RoundManager, BuyMenuHandler, BombObjective class_name references
- Updated server config to match ServerConfig.gd format

Gray screen root cause: server scripts failed to parse in headless
mode due to Godot 4 class_name loading order (Resource after Node),
leaving server_main.gd non-functional — accepted connections but
never spawned players.
2026-07-02 10:09:28 -04:00

38 lines
1.2 KiB
GDScript

## DamageProcessor — applies hit results, tracks health and kills.
## Minimal stub for server startup compatibility.
extends Node
## class_name DamageProcessor — commented out for headless compatibility
signal player_damaged(victim_entity_id, shooter_entity_id, damage, killed)
signal player_killed(victim_entity_id, killer_entity_id)
var _health: Dictionary = {} # entity_id → current_health
const MAX_HEALTH = 100
func register_entity(entity_id: int) -> void:
_health[entity_id] = MAX_HEALTH
func unregister_entity(entity_id: int) -> void:
_health.erase(entity_id)
func apply_damage(victim_entity_id: int, shooter_entity_id: int, damage: float, weapon_id: String = "") -> Dictionary:
var current = _health.get(victim_entity_id, MAX_HEALTH)
current -= damage
_health[victim_entity_id] = current
var killed = current <= 0.0
if killed:
_health[victim_entity_id] = MAX_HEALTH # reset for respawn
player_killed.emit(victim_entity_id, shooter_entity_id)
player_damaged.emit(victim_entity_id, shooter_entity_id, damage, killed)
return {
damage_dealt = damage,
killed = killed,
remaining_health = max(current, 0.0),
}
func get_health(entity_id: int) -> float:
return _health.get(entity_id, MAX_HEALTH)
func reset_all() -> void:
_health.clear()