Skip to content

Commit

Permalink
Allow observe for dying player with EF_NODRAW effect
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyShorokhov committed Jun 19, 2021
1 parent a9111f8 commit 5877492
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion regamedll/dlls/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,29 @@ CBasePlayer *CBasePlayer::__API_HOOK(Observer_IsValidTarget)(int iPlayerIndex, b
CBasePlayer *pPlayer = UTIL_PlayerByIndex(iPlayerIndex);

// Don't spec observers or players who haven't picked a class yet
if (!pPlayer || pPlayer == this || pPlayer->has_disconnected || pPlayer->GetObserverMode() != OBS_NONE || (pPlayer->pev->effects & EF_NODRAW) || pPlayer->m_iTeam == UNASSIGNED || (bSameTeam && pPlayer->m_iTeam != m_iTeam))
if (!pPlayer || pPlayer == this)
return nullptr;

if (pPlayer->has_disconnected)
return nullptr;

if (pPlayer->GetObserverMode() != OBS_NONE)
return nullptr;

if (pPlayer->m_iTeam == UNASSIGNED || (bSameTeam && pPlayer->m_iTeam != m_iTeam))
return nullptr;

if (pPlayer->pev->effects & EF_NODRAW)
{
#ifdef REGAMEDLL_FIXES
bool bStillDying = (pPlayer->pev->deadflag >= DEAD_DYING && (gpGlobals->time <= (pPlayer->m_fDeadTime + 3.0f)));
if (bStillDying && !(pPlayer->m_afPhysicsFlags & PFLAG_OBSERVER))
return pPlayer; // keep observing to victim until dying, even if it is invisible
#endif

return nullptr;
}

return pPlayer;
}

Expand Down

0 comments on commit 5877492

Please sign in to comment.