diff --git a/regamedll/dlls/observer.cpp b/regamedll/dlls/observer.cpp index 56f8a17a6..68329e442 100644 --- a/regamedll/dlls/observer.cpp +++ b/regamedll/dlls/observer.cpp @@ -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; }