If a member of the Follower Audience is focused on a player that becomes invalid, immediately invalidate their attention and look for somebody new

This commit is contained in:
toaster 2023-05-14 15:42:42 +01:00
parent d1ec068e84
commit ac8de9a933

View file

@ -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
{