Skip to content

Zombie Muting #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cfg/cs2fixes/cs2fixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ zr_human_win_overlay_material "" //Material override for human's win overlay pa
zr_human_win_overlay_size 100 //Size of human's win overlay particle
zr_zombie_win_overlay_particle "" //Screenspace particle to display when zombie win
zr_zombie_win_overlay_material "" //Material override for zombie's win overlay particle
zr_zombie_win_overlay_size 100 //Size of zombie's win overlay particle
zr_zombie_win_overlay_size 100 //Size of zombie's win overlay particle
zr_zombie_mute 0 // Prevent humans from hearing zombies. Zombies can still talk, but will only he heard by other zombies.
zr_zombie_mute_bypass "abj" // A list of admin flags that can talk to humans as a zombie
13 changes: 13 additions & 0 deletions src/adminsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,19 @@ bool CAdminSystem::FindAndRemoveInfraction(ZEPlayer *player, CInfractionBase::EI
return false;
}

bool CAdminSystem::HasInfraction(ZEPlayer *player, CInfractionBase::EInfractionType type)
{
FOR_EACH_VEC(m_vecInfractions, i)
{
if (m_vecInfractions[i]->GetSteamId64() == player->GetSteamId64() && m_vecInfractions[i]->GetType() == type)
{
return true;
}
}

return false;
}

CAdmin *CAdminSystem::FindAdmin(uint64 iSteamID)
{
FOR_EACH_VEC(m_vecAdmins, i)
Expand Down
6 changes: 6 additions & 0 deletions src/adminsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ class CAdminSystem
void SaveInfractions();
bool ApplyInfractions(ZEPlayer *player);
bool FindAndRemoveInfraction(ZEPlayer *player, CInfractionBase::EInfractionType type);

/// @brief Determines if the player has an active infraction of the specified type
/// @param player
/// @param type
/// @return true if an active infraction is found
bool HasInfraction(ZEPlayer *player, CInfractionBase::EInfractionType type);
CAdmin *FindAdmin(uint64 iSteamID);
uint64 ParseFlags(const char* pszFlags);

Expand Down
18 changes: 13 additions & 5 deletions src/detours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void FASTCALL Detour_CBaseEntity_TakeDamageOld(Z_CBaseEntity *pThis, CTakeDamage
inputInfo->m_flDamage,
inputInfo->m_bitsDamageType);
#endif

// Block all player damage if desired
if (g_bBlockAllDamage && pThis->IsPawn())
return;
Expand Down Expand Up @@ -155,7 +155,7 @@ void FASTCALL Detour_TriggerPush_Touch(CTriggerPush* pPush, Z_CBaseEntity* pOthe
Vector vecAbsDir;

matrix3x4_t mat = pPush->m_CBodyComponent()->m_pSceneNode()->EntityToWorldTransform();

Vector pushDir = pPush->m_vecPushDirEntitySpace();

// i had issues with vectorrotate on linux so i did it here
Expand Down Expand Up @@ -187,12 +187,20 @@ void FASTCALL Detour_TriggerPush_Touch(CTriggerPush* pPush, Z_CBaseEntity* pOthe
pOther->m_fFlags(flags);
}

bool FASTCALL Detour_IsHearingClient(void* serverClient, int index)
bool FASTCALL Detour_IsHearingClient(CServerSideClient* serverClient, int index)
{
ZEPlayer* player = g_playerManager->GetPlayer(index);
if (player && player->IsMuted())
return false;

if (serverClient)
{
CCSPlayerController* client = CCSPlayerController::FromSlot(serverClient->GetPlayerSlot());

if (player->IsMutedToTeam(client->m_iTeamNum()))
return false;
}

return IsHearingClient(serverClient, index);
}

Expand Down Expand Up @@ -256,7 +264,7 @@ void SayChatMessageWithTimer(IRecipientFilter &filter, const char *pText, CCSPla
{
if (pCurrentWord[j] >= '0' && pCurrentWord[j] <= '9')
continue;

if (pCurrentWord[j] == 's')
{
pCurrentWord[j] = '\0';
Expand Down Expand Up @@ -490,7 +498,7 @@ bool InitDetours(CGameConfig *gameConfig)
if (!CCSPlayer_WeaponServices_CanUse.CreateDetour(gameConfig))
success = false;
CCSPlayer_WeaponServices_CanUse.EnableDetour();

if (!CEntityIdentity_AcceptInput.CreateDetour(gameConfig))
success = false;
CEntityIdentity_AcceptInput.EnableDetour();
Expand Down
2 changes: 1 addition & 1 deletion src/detours.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void FlushAllDetours();

void FASTCALL Detour_UTIL_SayTextFilter(IRecipientFilter &, const char *, CCSPlayerController *, uint64);
void FASTCALL Detour_UTIL_SayText2Filter(IRecipientFilter &, CCSPlayerController *, uint64, const char *, const char *, const char *, const char *, const char *);
bool FASTCALL Detour_IsHearingClient(void*, int);
bool FASTCALL Detour_IsHearingClient(CServerSideClient*, int);
void FASTCALL Detour_TriggerPush_Touch(CTriggerPush* pPush, Z_CBaseEntity* pOther);
void FASTCALL Detour_CGameRules_Constructor(CGameRules *pThis);
void FASTCALL Detour_CBaseEntity_TakeDamageOld(Z_CBaseEntity *pThis, CTakeDamageInfo *inputInfo);
Expand Down
16 changes: 10 additions & 6 deletions src/playermanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ZEPlayerHandle
void operator=(const ZEPlayerHandle &other) { m_Index = other.m_Index; }
void operator=(ZEPlayer *pZEPlayer) { Set(pZEPlayer); }
void Set(ZEPlayer *pZEPlayer);

ZEPlayer *Get() const;

private:
Expand All @@ -89,12 +89,13 @@ class ZEPlayer
{
public:
ZEPlayer(CPlayerSlot slot, bool m_bFakeClient = false): m_slot(slot), m_bFakeClient(m_bFakeClient), m_Handle(slot)
{
{
m_bAuthenticated = false;
m_iAdminFlags = 0;
m_SteamID = nullptr;
m_bGagged = false;
m_bMuted = false;
m_iBlockVoiceToTeam = CS_TEAM_NONE;
m_iHideDistance = 0;
m_bConnected = false;
m_iTotalDamage = 0;
Expand Down Expand Up @@ -130,7 +131,7 @@ class ZEPlayer
const CSteamID* GetSteamId() { return m_SteamID; }
bool IsAdminFlagSet(uint64 iFlag);
bool IsFlooding();

void SetAuthenticated() { m_bAuthenticated = true; }
void SetConnected() { m_bConnected = true; }
void SetUnauthenticatedSteamId(const CSteamID* steamID) { m_UnauthenticatedSteamID = steamID; }
Expand Down Expand Up @@ -158,8 +159,10 @@ class ZEPlayer
void SetFlashLight(CBarnLight *pLight) { m_hFlashLight.Set(pLight); }
void SetBeaconParticle(CParticleSystem *pParticle) { m_hBeaconParticle.Set(pParticle); }
void SetPlayerState(uint32 iPlayerState) { m_iPlayerState = iPlayerState; }
void SetMutedToTeam(int team) { m_iBlockVoiceToTeam = team; }

bool IsMuted() { return m_bMuted; }
bool IsMutedToTeam(int team) { return m_iBlockVoiceToTeam == team; }
bool IsGagged() { return m_bGagged; }
bool ShouldBlockTransmit(int index) { return m_shouldTransmit.Get(index); }
int GetHideDistance();
Expand All @@ -180,7 +183,7 @@ class ZEPlayer
CParticleSystem *GetBeaconParticle() { return m_hBeaconParticle.Get(); }
ZEPlayerHandle GetHandle() { return m_Handle; }
uint32 GetPlayerState() { return m_iPlayerState; }

void OnAuthenticated();
void CheckAdmin();
void CheckInfractions();
Expand All @@ -195,6 +198,7 @@ class ZEPlayer
CPlayerSlot m_slot;
bool m_bFakeClient;
bool m_bMuted;
int m_iBlockVoiceToTeam;
bool m_bGagged;
uint64 m_iAdminFlags;
int m_iHideDistance;
Expand Down Expand Up @@ -253,7 +257,7 @@ class CPlayerManager
uint64 GetStopSoundMask() { return m_nUsingStopSound; }
uint64 GetSilenceSoundMask() { return m_nUsingSilenceSound; }
uint64 GetStopDecalsMask() { return m_nUsingStopDecals; }

void SetPlayerStopSound(int slot, bool set);
void SetPlayerSilenceSound(int slot, bool set);
void SetPlayerStopDecals(int slot, bool set);
Expand All @@ -274,4 +278,4 @@ class CPlayerManager
uint64 m_nUsingStopDecals;
};

extern CPlayerManager *g_playerManager;
extern CPlayerManager *g_playerManager;
Loading