Skip to content

Commit

Permalink
add method to hide entities from specific players
Browse files Browse the repository at this point in the history
  • Loading branch information
wootguy committed Nov 8, 2024
1 parent 0992003 commit 0e1b013
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions dlls/cbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,15 @@ class EXPORT CBaseEntity
// true if the entity is networked to the given player
inline bool isVisibleTo(edict_t* player) { return m_netPlayers & PLRBIT(player); }

// true if the entity was flagged to be hidden from the given player
inline bool isHiddenFrom(edict_t* player) { return m_hidePlayers & PLRBIT(player); }

// flag this entity to be visible/invisible to the given player
inline void SetVisible(edict_t* player, bool visible) {
if (visible) m_hidePlayers &= ~PLRBIT(player);
else m_hidePlayers |= PLRBIT(player);
}

//We use this variables to store each ammo count.
int ammo_9mm;
int ammo_357;
Expand All @@ -420,6 +429,7 @@ class EXPORT CBaseEntity
uint32_t m_pasPlayers; // players in the audible set of this entity (invalid for invisible ents)
uint32_t m_pvsPlayers; // players in the visible set of this entity (invalid for invisible ents)
uint32_t m_netPlayers; // players this entity has been networked to (AddToFullPack returned 1)
uint32_t m_hidePlayers; // players this entity will be hidden from (AddToFullPack)
};


Expand Down
2 changes: 1 addition & 1 deletion dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h
return 0;
}

if (invisible || forceVisChecks) {
if (invisible || forceVisChecks || (baseent->m_hidePlayers & plrbit)) {
return 0;
}

Expand Down

0 comments on commit 0e1b013

Please sign in to comment.