update
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user