From f67cdf08cb3dba9c176eb81e137e2da4648d9ace Mon Sep 17 00:00:00 2001 From: zlago Date: Tue, 28 Jan 2025 17:13:17 +0100 Subject: make flying enemies patrol path handling less weird --- src/flier.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') 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; -- cgit 1.4.1-2-gfad0