From bf1ed7ebbff6e2ddaf74e842f099f89145253018 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Tue, 10 Oct 2023 19:33:00 -0400 Subject: [PATCH] !! --- Scenes/Levels/level_test.tscn | 1 - Scripts/Enemy.gd | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Scenes/Levels/level_test.tscn b/Scenes/Levels/level_test.tscn index fb2eae9..d0c2ed9 100644 --- a/Scenes/Levels/level_test.tscn +++ b/Scenes/Levels/level_test.tscn @@ -17,7 +17,6 @@ position = Vector2(497, 324) position = Vector2(248, 225) motion_mode = 0 - [node name="BatSpawnable2" parent="." instance=ExtResource("3_a1ucf")] position = Vector2(644, 251) motion_mode = 0 diff --git a/Scripts/Enemy.gd b/Scripts/Enemy.gd index bdaec5d..4cde2dd 100644 --- a/Scripts/Enemy.gd +++ b/Scripts/Enemy.gd @@ -97,11 +97,13 @@ func processAI(objs): var vec: Vector2 = Vector2(0,0) var weight: int = 0 for obj in objs: + if !obj || !obj.isAlive: + continue if position.distance_to(obj.position) > 10: weight = abs(obj.priority) * position.distance_to(obj.position) vec += weight * position.direction_to(obj.position) else: - weight = obj.priority * position.distance_to(obj.position) * (maxhp / hp) * 100 + weight = obj.priority * position.distance_to(obj.position) * ((maxhp + 1) / hp) vec += weight * -position.direction_to(obj.position) if vec.length() < 5 && objs.size() > 1: