Skip to content

Commit 5877492

Browse files
committed
Allow observe for dying player with EF_NODRAW effect
1 parent a9111f8 commit 5877492

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

regamedll/dlls/observer.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,29 @@ CBasePlayer *CBasePlayer::__API_HOOK(Observer_IsValidTarget)(int iPlayerIndex, b
2929
CBasePlayer *pPlayer = UTIL_PlayerByIndex(iPlayerIndex);
3030

3131
// Don't spec observers or players who haven't picked a class yet
32-
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))
32+
if (!pPlayer || pPlayer == this)
3333
return nullptr;
3434

35+
if (pPlayer->has_disconnected)
36+
return nullptr;
37+
38+
if (pPlayer->GetObserverMode() != OBS_NONE)
39+
return nullptr;
40+
41+
if (pPlayer->m_iTeam == UNASSIGNED || (bSameTeam && pPlayer->m_iTeam != m_iTeam))
42+
return nullptr;
43+
44+
if (pPlayer->pev->effects & EF_NODRAW)
45+
{
46+
#ifdef REGAMEDLL_FIXES
47+
bool bStillDying = (pPlayer->pev->deadflag >= DEAD_DYING && (gpGlobals->time <= (pPlayer->m_fDeadTime + 3.0f)));
48+
if (bStillDying && !(pPlayer->m_afPhysicsFlags & PFLAG_OBSERVER))
49+
return pPlayer; // keep observing to victim until dying, even if it is invisible
50+
#endif
51+
52+
return nullptr;
53+
}
54+
3555
return pPlayer;
3656
}
3757

0 commit comments

Comments
 (0)