summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorzlago2025-01-28 17:13:17 +0100
committerzlago2025-01-28 17:13:17 +0100
commitf67cdf08cb3dba9c176eb81e137e2da4648d9ace (patch)
treeeb64659d81b56f4d890c34240d87ce8c5b4891fa /src
parentc5d0f2310ebd9e344d0736d0ea673dfd1616dd1e (diff)
make flying enemies patrol path handling less weird
Diffstat (limited to 'src')
-rw-r--r--src/flier.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/flier.c b/src/flier.c
index 81596d0..c507bd2 100644
--- a/src/flier.c
+++ b/src/flier.c
@@ -270,12 +270,16 @@ static int flier_update(struct entity *self) {
 		case FLIER_PATROL:
 			move2(self);
 			if (ext->reached_x && ext->reached_y) {
-				ext->current_node++;
+				size_t const last_node = ext->current_node++;
 				if (ext->current_node == ext->path_length) {
 					ext->current_node = 0;
 				}
-				ext->reached_x = false;
-				ext->reached_y = false;
+				if (ext->path[last_node].x != ext->path[ext->current_node].x) {
+					ext->reached_x = false;
+				}
+				if (ext->path[last_node].y != ext->path[ext->current_node].y) {
+					ext->reached_y = false;
+				}
 				anim(self, FLIER_A_IDLE);
 				self->state = FLIER_IDLE;
 				self->timer = ext->idle_time;