feat: implement walking and killable enemy dummy entities and player movement controller base
This commit is contained in:
@@ -11,6 +11,7 @@ var max_shield: float = 100.0
|
||||
var shield: float = 100.0
|
||||
|
||||
var is_dead: bool = false
|
||||
var time_since_last_damage: float = 0.0
|
||||
var recent_attackers: Dictionary = {} # attacker_id: timestamp
|
||||
var ragdoll_instance: Node3D = null
|
||||
var pending_impulse: Vector3 = Vector3.ZERO
|
||||
@@ -51,6 +52,14 @@ func _physics_process(delta: float) -> void:
|
||||
if is_dead:
|
||||
return
|
||||
|
||||
# Shield recharge logic
|
||||
time_since_last_damage += delta
|
||||
if time_since_last_damage >= 5.0 and shield < max_shield:
|
||||
shield += 20.0 * delta
|
||||
if shield > max_shield:
|
||||
shield = max_shield
|
||||
_update_label()
|
||||
|
||||
# Basic gravity
|
||||
if not is_on_floor():
|
||||
velocity.y -= 9.8 * delta
|
||||
@@ -98,6 +107,8 @@ func take_damage(amount: float, hit_position: Vector3, source: Node = null, impu
|
||||
if attacker_id != 0:
|
||||
recent_attackers[attacker_id] = Time.get_ticks_msec() / 1000.0
|
||||
|
||||
time_since_last_damage = 0.0
|
||||
|
||||
var dmg_taken = amount
|
||||
if shield > 0:
|
||||
if shield >= amount:
|
||||
@@ -109,6 +120,8 @@ func take_damage(amount: float, hit_position: Vector3, source: Node = null, impu
|
||||
|
||||
if amount > 0:
|
||||
health -= amount
|
||||
if health <= 0:
|
||||
health = 0
|
||||
|
||||
_update_label()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user