From ac8de9a9337c524cd4e6227acccb984cd111e696 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 14 May 2023 15:42:42 +0100 Subject: [PATCH] If a member of the Follower Audience is focused on a player that becomes invalid, immediately invalidate their attention and look for somebody new --- src/objects/audience.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/objects/audience.c b/src/objects/audience.c index 631429d05..ca9098b2b 100644 --- a/src/objects/audience.c +++ b/src/objects/audience.c @@ -189,6 +189,17 @@ Obj_AudienceThink if (focusonplayer == true) { + if (audience_focusplayer(mobj) < MAXPLAYERS && audience_focusplayer(mobj) >= 0) + { + if (playeringame[audience_focusplayer(mobj)] == false + || players[audience_focusplayer(mobj)].spectator == true + || P_MobjWasRemoved(players[audience_focusplayer(mobj)].mo)) + { + // Reset the timer, search for a player again + audience_focusdelay(mobj) = 0; + } + } + if (audience_focusdelay(mobj) == 0) { fixed_t bestdist = INT32_MAX, dist; @@ -228,7 +239,7 @@ Obj_AudienceThink } // Try to add some spacing out so the object isn't constantly looking for players - audience_focusdelay(mobj) = TICRATE + min((bestdist/FRACUNIT), (2*TICRATE)) + (bestdist % TICRATE); + audience_focusdelay(mobj) = TICRATE + min((bestdist/FRACUNIT), TICRATE) + (bestdist % TICRATE); } else {