Loot changes

This commit is contained in:
dingo
2026-01-20 16:23:00 -05:00
parent 5bc1c6e0f9
commit a39f4a0a98
20 changed files with 791 additions and 50 deletions
+52
View File
@@ -506,3 +506,55 @@ func play_hurt_effect():
await get_tree().create_timer(0.1).timeout
if is_instance_valid(sprite_to_flash):
sprite_to_flash.modulate = original_color
func play_death_animation():
"""Play death animation and stop on last frame"""
_current_state = "dead"
if _animated_sprite and _animated_sprite.sprite_frames:
# Try to play death animation
var frames = _animated_sprite.sprite_frames
var death_anim_name = ""
# Try different death animation names
var names_to_try = [
"dead_%s" % _facing_direction,
"dead",
"death_%s" % _facing_direction,
"death"
]
for anim_name in names_to_try:
if frames.has_animation(anim_name):
death_anim_name = anim_name
break
if death_anim_name != "":
# Play the death animation
_animated_sprite.play(death_anim_name)
# Wait for animation to finish
if _animated_sprite.sprite_frames.get_animation_loop(death_anim_name):
# If it loops, disable looping temporarily
_animated_sprite.sprite_frames.set_animation_loop(death_anim_name, false)
# Wait for animation to complete
await _animated_sprite.animation_finished
# Stop on last frame
var frame_count = _animated_sprite.sprite_frames.get_frame_count(death_anim_name)
if frame_count > 0:
_animated_sprite.frame = frame_count - 1
_animated_sprite.stop()
else:
# No death animation, just fade out the fallback
_update_fallback_state("dead")
else:
# Using fallback sprite, just update its appearance
_update_fallback_state("dead")
# Hide health bar and name label for dead mobs
if health_bar:
health_bar.visible = false
if name_label:
name_label.visible = false