This commit is contained in:
Marek Lenczewski
2026-04-01 22:53:28 +02:00
parent b236cd52cb
commit e76c66eda6
70 changed files with 1016 additions and 732 deletions

View File

@@ -49,10 +49,14 @@ func _return_to_spawn(delta: float) -> void:
_regenerate(delta)
func _regenerate(delta: float) -> void:
var health: Node = enemy.get_node("Health")
if health.current_health < health.max_health:
var rate: float = REGEN_FAST if health.current_health < health.max_health else REGEN_SLOW
if health.current_health >= health.max_health * 0.99:
var health: float = Stats.get_stat(enemy, "health")
var max_health: float = Stats.get_stat(enemy, "max_health")
if health == null or max_health == null:
return
if health < max_health:
var rate: float = REGEN_FAST
if health >= max_health * 0.99:
rate = REGEN_SLOW
health.current_health = min(health.current_health + health.max_health * rate * delta, health.max_health)
EventBus.health_changed.emit(enemy, health.current_health, health.max_health)
health = min(health + max_health * rate * delta, max_health)
Stats.set_stat(enemy, "health", health)
EventBus.health_changed.emit(enemy, health, max_health)