feat: fully implemented death in NpcUnit

This commit is contained in:
Sara Gerretsen 2025-10-25 13:18:04 +02:00
parent 5f61fafe7b
commit 28183fceb8
4 changed files with 43 additions and 8 deletions

View file

@ -7,23 +7,43 @@ script/source = "extends EnemyWretched
@export var difficulty_weight : float = 10
func _on_health_status_death() -> void:
var is_dead := false
func on_death() -> void:
%StateMachine.process_mode = Node.PROCESS_MODE_DISABLED
%NavigationAgent3D.process_mode = Node.PROCESS_MODE_DISABLED
$wretched/AnimationPlayer.play(\"death\")
$CollisionShape3D.disabled = true
set_movement_direction(Vector2())
func _on_health_status_death() -> void:
$wretched/AnimationPlayer.play(\"death\")
get_unit().region.raise_difficulty(1.0 / difficulty_weight)
on_death.call_deferred()
is_dead = true
func _enter_tree() -> void:
if is_dead and $wretched/AnimationPlayer.current_animation != \"death\":
$wretched/AnimationPlayer.play.call_deferred(\"death\")
$wretched/AnimationPlayer.advance.call_deferred(INF)
elif is_dead:
$wretched/AnimationPlayer.play.call_deferred(\"death\")
"
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_ng1ul"]
radius = 0.26953125
radius = 0.58691406
[node name="EnemyWretched" type="EnemyWretched"]
wall_min_slide_angle = 0.0
script = SubResource("GDScript_qot2n")
[node name="wretched" parent="." instance=ExtResource("1_qot2n")]
[node name="Body" parent="wretched/Character/Skeleton3D" index="0"]
gi_mode = 0
[node name="club" parent="wretched/Character/Skeleton3D" index="1"]
gi_mode = 0
[node name="Hitbox" parent="wretched/Character/Skeleton3D" index="2" node_paths=PackedStringArray("health")]
health = NodePath("../../../../HealthStatus")