From ee0d92a6e621e6a8135b16914a09def52bd70a4b Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Tue, 1 Nov 2022 00:16:42 +0200 Subject: [PATCH] allow enemies to continue their shot even when we can't see them --- src/gamescr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gamescr.c b/src/gamescr.c index 5b3a6d2..64169e7 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -383,8 +383,8 @@ static int update(void) /* enemy logic */ enemy = enemies; for(i=0; ihp <= 0 || enemy->vobj.px < 0) { + /* only consider enemies which are not dead */ + if(enemy->hp <= 0) { enemy++; continue; } @@ -392,7 +392,8 @@ static int update(void) if(enemy->shot_frame >= 0) { /* in the process of charging a shot */ if(++enemy->shot_frame >= NUM_SHOT_FRAMES - 1) { - if(!did_strafe) { + /* only get hit if we can see the enemy and we didn't strafe */ + if(!did_strafe && enemy->vobj.px >= 0) { hit_frame = 1; if(--energy <= 0) { gameover = 1; @@ -400,7 +401,7 @@ static int update(void) } enemy->shot_frame = -1; } - } else { + } else if(enemy->vobj.px >= 0) { /* check rate of fire and start a shot if necessary */ if(timer_msec - enemy->last_shot >= E_RATE) { enemy->last_shot = timer_msec; -- 1.7.10.4