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