fixed so there isn't too many spam messages

This commit is contained in:
2026-01-20 02:48:14 +01:00
parent e44eeb6dea
commit 22cb66877c
12 changed files with 983 additions and 159 deletions

View File

@@ -3415,9 +3415,14 @@ func take_damage(amount: float, attacker_position: Vector2):
actual_damage = amount
print(name, " took ", amount, " damage! Health: ", current_health)
# Play damage sound effect
# Play damage sound effect (rate limited to prevent spam when tab becomes active)
var game_world = get_tree().get_first_node_in_group("game_world")
if sfx_take_damage:
sfx_take_damage.play()
if game_world and game_world.has_method("can_play_sound"):
if game_world.can_play_sound("player_damage_" + str(get_instance_id())):
sfx_take_damage.play()
else:
sfx_take_damage.play()
# Play damage animation
_set_animation("DAMAGE")
@@ -3991,9 +3996,14 @@ func _sync_damage(_amount: float, attacker_position: Vector2, is_crit: bool = fa
_show_damage_number(0.0, attacker_position, false, false, true)
return
# Play damage sound and effects
# Play damage sound and effects (rate limited to prevent spam when tab becomes active)
var game_world = get_tree().get_first_node_in_group("game_world")
if sfx_take_damage:
sfx_take_damage.play()
if game_world and game_world.has_method("can_play_sound"):
if game_world.can_play_sound("player_damage_sync_" + str(get_instance_id())):
sfx_take_damage.play()
else:
sfx_take_damage.play()
# Play damage animation
_set_animation("DAMAGE")