Block maybe

This commit is contained in:
Twirpytherobot
2025-11-15 17:07:28 +00:00
parent 6da70f9bfe
commit 61446a0bcd
6 changed files with 68 additions and 3 deletions
+9 -1
View File
@@ -34,8 +34,16 @@ func take_damage(amount: float, attacker_id: int = -1):
if is_dead:
return
# Apply blocking reduction if applicable (duck typing - check if method exists)
var final_damage = amount
if has_method("get_block_reduction"):
var block_reduction = call("get_block_reduction")
if block_reduction > 0.0:
final_damage = amount * (1.0 - block_reduction)
print("Blocked! Damage reduced from ", amount, " to ", final_damage, " (", block_reduction * 100, "% reduction)")
var old_health = current_health
current_health = max(0, current_health - amount)
current_health = max(0, current_health - final_damage)
# Broadcast health change to all clients
rpc("sync_health", current_health)