Skip to content
Merged
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
2 changes: 1 addition & 1 deletion PackageScript
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ for task in MMSPlugin.binaries:
builder.AddCopy(os.path.join('configs', 'zr', 'playerclass.jsonc.example'), zr_folder)
builder.AddCopy(os.path.join('configs', 'zr', 'weapons.cfg.example'), zr_folder)
builder.AddCopy(os.path.join('configs', 'zr', 'hitgroups.cfg.example'), zr_folder)
builder.AddCopy(os.path.join('configs', 'entwatch', 'maps', 'example_config.jsonc'), ew_maps_folder)
builder.AddCopy(os.path.join('configs', 'entwatch', 'maps', 'template.jsonc'), ew_maps_folder)
builder.AddCopy(os.path.join('gamedata', 'cs2fixes.games.txt'), gamedata_folder)

particles_cs2f_folder = builder.AddFolder(os.path.join(packages[sdk_name].sdk_name, 'particles', MMSPlugin.metadata['name']))
Expand Down
30 changes: 0 additions & 30 deletions configs/entwatch/maps/example_config.jsonc

This file was deleted.

52 changes: 52 additions & 0 deletions configs/entwatch/maps/template.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[
{
"name": "Item Name", // Name of item that appears in chat
"shortname": "Short Name", // Name of item that appears on the HUD
"hammerid": "", // Hammerid of the weapon entity
"message": true, // Whether to show pickup/drop messages in chat
"ui": true, // Whether to show this item on the HUD
"transfer": true, // Whether to allow this item to be transferred (this auto detects false for knife items)
"color": "", // Color of the item for chat messages (see list of colors)
"triggers": [""], // Array of hammerids of any triggers that this item is associated with
"templated": true, // Whether the entity of this handler is templated with the item weapon, (auto detected if not specified)
"handlers": [
{
"name": "Handler", // extra name to show in chat when used e.g. XXX has used Item Name (Handler)
"type": "button", // "button",
// "counterdown" - counter stops OnHitMin
// "counterup" - counter stops OnHitMax
// (anything else is ignored)
"hammerid": "", // hammerid of the entity
"event": "OnPressed", // Name of the output, counterup/down types always force "OutValue"
"mode": 2, // Mode of the handler
// 0/1 = None
// 2 = Cooldown, 3 = MaxUses (cooldown between each)
// 4 = CooldownAfterUses, 5 = CounterValue
"offset": [5,-9], // ADDS the specified offset to counter values,
// First number is counter value, Second is counter max
"cooldown": 60, // Cooldown duration if mode = 2,3,4
"maxuses": 0, // Maxuses if mode = 3,4
"message": true, // Whether to show when this is used in chat
"ui": true, // Whether to track this handler on the HUD
"templated": true // Whether the entity of this handler is templated with the item weapon,
} // (this will attempt to auto detect if not specified)
]
}
]

// LIST OF COLOR NAMES (grouped if they are the same)
// white, default
// darkred
// team
// green
// lightgreen
// olive
// red
// gray, grey
// yellow
// silver
// blue
// darkblue
// purple, pink
// red2
// orange, gold
2 changes: 1 addition & 1 deletion sdk
126 changes: 68 additions & 58 deletions src/cs2fixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,69 +757,76 @@ void CS2Fixes::Hook_PostEvent(CSplitScreenSlot nSlot, bool bLocalOnly, int nClie
if (g_cvarEnableNoShake.Get())
*(uint64*)clients &= ~g_playerManager->GetNoShakeMask();
}
else if (g_cvarEnableStopSound.Get() && info->m_MessageId == GE_SosStartSoundEvent)
else if (info->m_MessageId == GE_SosStartSoundEvent)
{
static std::set<uint32> soundEventHashes;
auto msg = const_cast<CNetMessage*>(pData)->ToPB<CMsgSosStartSoundEvent>();

ExecuteOnce(
soundEventHashes.insert(GetSoundEventHash("Weapon_Knife.HitWall"));
soundEventHashes.insert(GetSoundEventHash("Weapon_Knife.Slash"));
soundEventHashes.insert(GetSoundEventHash("Weapon_Knife.Hit"));
soundEventHashes.insert(GetSoundEventHash("Weapon_Knife.Stab"));
soundEventHashes.insert(GetSoundEventHash("Weapon_sg556.ZoomIn"));
soundEventHashes.insert(GetSoundEventHash("Weapon_sg556.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_AUG.ZoomIn"));
soundEventHashes.insert(GetSoundEventHash("Weapon_AUG.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_SSG08.Zoom"));
soundEventHashes.insert(GetSoundEventHash("Weapon_SSG08.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_SCAR20.Zoom"));
soundEventHashes.insert(GetSoundEventHash("Weapon_SCAR20.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_G3SG1.Zoom"));
soundEventHashes.insert(GetSoundEventHash("Weapon_G3SG1.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_AWP.Zoom"));
soundEventHashes.insert(GetSoundEventHash("Weapon_AWP.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_Revolver.Prepare"));
soundEventHashes.insert(GetSoundEventHash("Weapon.AutoSemiAutoSwitch")););

if (!soundEventHashes.contains(msg->soundevent_hash()))
return;

uint64 stopSoundMask = g_playerManager->GetStopSoundMask();
uint64 silenceSoundMask = g_playerManager->GetSilenceSoundMask();

if (!msg->has_source_entity_index())
return;

CBaseEntity* pSourceEntity = (CBaseEntity*)g_pEntitySystem->GetEntityInstance(CEntityIndex(msg->source_entity_index()));
int playerSlot = -1;

if (!pSourceEntity)
return;

if (!V_strcasecmp(pSourceEntity->GetClassname(), "player"))
{
playerSlot = ((CCSPlayerPawn*)pSourceEntity)->GetController()->GetPlayerSlot();
}
else if (!V_strncasecmp(pSourceEntity->GetClassname(), "weapon_", 7))
if (g_cvarEnableZR.Get())
ZR_PostEventAbstract_SosStartSoundEvent(clients, msg);

if (g_cvarEnableStopSound.Get())
{
CCSPlayerPawn* pPawn = (CCSPlayerPawn*)pSourceEntity->m_hOwnerEntity().Get();
static std::set<uint32> soundEventHashes;

ExecuteOnce(
soundEventHashes.insert(GetSoundEventHash("Weapon_Knife.HitWall"));
soundEventHashes.insert(GetSoundEventHash("Weapon_Knife.Slash"));
soundEventHashes.insert(GetSoundEventHash("Weapon_Knife.Hit"));
soundEventHashes.insert(GetSoundEventHash("Weapon_Knife.Stab"));
soundEventHashes.insert(GetSoundEventHash("Weapon_sg556.ZoomIn"));
soundEventHashes.insert(GetSoundEventHash("Weapon_sg556.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_AUG.ZoomIn"));
soundEventHashes.insert(GetSoundEventHash("Weapon_AUG.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_SSG08.Zoom"));
soundEventHashes.insert(GetSoundEventHash("Weapon_SSG08.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_SCAR20.Zoom"));
soundEventHashes.insert(GetSoundEventHash("Weapon_SCAR20.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_G3SG1.Zoom"));
soundEventHashes.insert(GetSoundEventHash("Weapon_G3SG1.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_AWP.Zoom"));
soundEventHashes.insert(GetSoundEventHash("Weapon_AWP.ZoomOut"));
soundEventHashes.insert(GetSoundEventHash("Weapon_Revolver.Prepare"));
soundEventHashes.insert(GetSoundEventHash("Weapon.AutoSemiAutoSwitch")););

if (!soundEventHashes.contains(msg->soundevent_hash()))
return;

uint64 stopSoundMask = g_playerManager->GetStopSoundMask();
uint64 silenceSoundMask = g_playerManager->GetSilenceSoundMask();

if (!msg->has_source_entity_index())
return;

CBaseEntity* pSourceEntity = (CBaseEntity*)g_pEntitySystem->GetEntityInstance(CEntityIndex(msg->source_entity_index()));
int playerSlot = -1;

if (!pSourceEntity)
return;

if (!V_strcasecmp(pSourceEntity->GetClassname(), "player"))
{
playerSlot = ((CCSPlayerPawn*)pSourceEntity)->GetController()->GetPlayerSlot();
}
else if (!V_strncasecmp(pSourceEntity->GetClassname(), "weapon_", 7))
{
CCSPlayerPawn* pPawn = (CCSPlayerPawn*)pSourceEntity->m_hOwnerEntity().Get();

if (pPawn && pPawn->IsPawn())
playerSlot = pPawn->GetController()->GetPlayerSlot();
}
if (pPawn && pPawn->IsPawn())
playerSlot = pPawn->GetController()->GetPlayerSlot();
}

// Remove player who triggered this sound from masks
// Because some of these sounds never get played locally (Zoom's, Knife Hit/Stab)
if (playerSlot != -1 && g_playerManager->IsPlayerUsingStopSound(playerSlot))
stopSoundMask &= ~((uint64)1 << playerSlot);
// Remove player who triggered this sound from masks
// Because some of these sounds never get played locally (Zoom's, Knife Hit/Stab)
if (playerSlot != -1 && g_playerManager->IsPlayerUsingStopSound(playerSlot))
stopSoundMask &= ~((uint64)1 << playerSlot);

if (playerSlot != -1 && g_playerManager->IsPlayerUsingSilenceSound(playerSlot))
silenceSoundMask &= ~((uint64)1 << playerSlot);
if (playerSlot != -1 && g_playerManager->IsPlayerUsingSilenceSound(playerSlot))
silenceSoundMask &= ~((uint64)1 << playerSlot);

// Filter out people using stop/silence sound from hearing this sound from other players
*(uint64*)clients &= ~stopSoundMask;
*(uint64*)clients &= ~silenceSoundMask;
// Filter out people using stop/silence sound from hearing this sound from other players
*(uint64*)clients &= ~stopSoundMask;
*(uint64*)clients &= ~silenceSoundMask;
}
}
}

Expand Down Expand Up @@ -953,9 +960,8 @@ void CS2Fixes::Hook_ClientDisconnect(CPlayerSlot slot, ENetworkDisconnectionReas

if (g_cvarEnableZR.Get())
{
if (player)
ZR_CheckTeamWinConditions(player->m_iTeamNum == CS_TEAM_T ? CS_TEAM_CT : CS_TEAM_T);
else if (!ZR_CheckTeamWinConditions(CS_TEAM_T)) // If we cant get team num, just check both
// Controller team num is not valid post-disconnect, so just check both teams
if (!ZR_CheckTeamWinConditions(CS_TEAM_T))
ZR_CheckTeamWinConditions(CS_TEAM_CT);
}

Expand Down Expand Up @@ -1113,7 +1119,11 @@ bool CS2Fixes::Hook_OnTakeDamage_Alive(CTakeDamageResult* pDamageResult)
CCSPlayerPawn* pPawn = META_IFACEPTR(CCSPlayerPawn);

if (g_cvarEnableZR.Get() && ZR_Hook_OnTakeDamage_Alive(pDamageResult->m_pOriginatingInfo, pPawn))
{
pDamageResult->m_bWasDamageSuppressed = true;
pDamageResult->m_nDamageDealt = 0;
RETURN_META_VALUE(MRES_SUPERCEDE, false);
}

// This is a shit place to be doing this, but player_death event is too late and there is no pre-hook alternative
// Check if this is going to kill the player
Expand Down
1 change: 1 addition & 0 deletions src/cs2fixes.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern CCSGameRules* g_pGameRules;
extern CSpawnGroupMgrGameSystem* g_pSpawnGroupMgr;
extern double g_flUniversalTime;
extern CGlobalVars* GetGlobals();
extern uint32 GetSoundEventHash(const char* pszSoundEventName);
extern CUtlVector<CServerSideClient*>* GetClientList();
extern CServerSideClient* GetClientBySlot(CPlayerSlot slot);
extern void FullUpdateAllClients();
Expand Down
22 changes: 15 additions & 7 deletions src/detours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ int64 FASTCALL Detour_CBaseEntity_TakeDamageOld(CBaseEntity* pThis, CTakeDamageI

CBaseEntity_TakeDamageOld(pThis, pInfo, pResult);

if (pResult->m_nDamageDealt > 0 && g_cvarEnableZR.Get() && pThis->IsPawn())
if (pResult->m_nDamageDealt > 0 && !pResult->m_bWasDamageSuppressed && g_cvarEnableZR.Get() && pThis->IsPawn())
ZR_OnPlayerTakeDamage(reinterpret_cast<CCSPlayerPawn*>(pThis), pInfo, pResult->m_nDamageDealt);

return 1;
Expand Down Expand Up @@ -288,13 +288,21 @@ void SayChatMessageWithTimer(IRecipientFilter& filter, const char* pText, CCSPla
uiNextWordLength = strlen(pNextWord);
}

// Case: ... X sec(onds) ... or ... X min(utes) ...
if (pNextWord != NULL && uiNextWordLength > 2 && uiCurrentValue > 0)
// Case: ... X sec(onds) ... or ... X s ... or ... X min(utes) ...
if (pNextWord != NULL && uiCurrentValue > 0)
{
if (pNextWord[0] == 's' && pNextWord[1] == 'e' && pNextWord[2] == 'c')
uiTriggerTimerLength = uiCurrentValue;
if (pNextWord[0] == 'm' && pNextWord[1] == 'i' && pNextWord[2] == 'n')
uiTriggerTimerLength = uiCurrentValue * 60;
if (uiNextWordLength == 1)
{
if (pNextWord[0] == 's')
uiTriggerTimerLength = uiCurrentValue;
}
else if (uiNextWordLength > 2)
{
if (pNextWord[0] == 's' && pNextWord[1] == 'e' && pNextWord[2] == 'c')
uiTriggerTimerLength = uiCurrentValue;
if (pNextWord[0] == 'm' && pNextWord[1] == 'i' && pNextWord[2] == 'n')
uiTriggerTimerLength = uiCurrentValue * 60;
}
}

// Case: ... Xs - only support up to 3 digit numbers (in seconds) for this timer parse method
Expand Down
17 changes: 17 additions & 0 deletions src/playermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,22 @@ void CPlayerManager::SetPlayerSilenceSound(int slot, bool set)
g_pUserPreferencesSystem->SetPreferenceInt(slot, SOUND_STATUS_PREF_KEY_NAME, iStopPreferenceStatus + iSilencePreferenceStatus);
}

void CPlayerManager::SetPlayerZSounds(int slot, bool set)
{
if (set)
m_nUsingZSounds |= ((uint64)1 << slot);
else
m_nUsingZSounds &= ~((uint64)1 << slot);

// Set the user prefs if the player is ingame
ZEPlayer* pPlayer = m_vecPlayers[slot];
if (!pPlayer) return;

uint64 iSlotMask = (uint64)1 << slot;
int iZSoundsPreferenceStatus = (m_nUsingZSounds & iSlotMask) ? 1 : 0;
g_pUserPreferencesSystem->SetPreferenceInt(slot, ZSOUNDS_PREF_KEY_NAME, iZSoundsPreferenceStatus);
}

void CPlayerManager::SetPlayerStopDecals(int slot, bool set)
{
if (set)
Expand Down Expand Up @@ -1808,6 +1824,7 @@ void CPlayerManager::ResetPlayerFlags(int slot)
{
SetPlayerStopSound(slot, true);
SetPlayerSilenceSound(slot, false);
SetPlayerZSounds(slot, true);
SetPlayerStopDecals(slot, true);
SetPlayerNoShake(slot, false);
}
Expand Down
6 changes: 6 additions & 0 deletions src/playermanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern CConVar<CUtlString> g_cvarFlashLightAttachment;
#define SOUND_STATUS_PREF_KEY_NAME "sound_status"
#define NO_SHAKE_PREF_KEY_NAME "no_shake"
#define BUTTON_WATCH_PREF_KEY_NAME "button_watch"
#define ZSOUNDS_PREF_KEY_NAME "zsounds"
#define INVALID_ZEPLAYERHANDLE_INDEX 0u

static uint32 iZEPlayerHandleSerial = 0u; // this should actually be 3 bytes large, but no way enough players join in servers lifespan for this to be an issue
Expand Down Expand Up @@ -398,6 +399,7 @@ class CPlayerManager
V_memset(m_vecPlayers, 0, sizeof(m_vecPlayers));
m_nUsingStopSound = -1; // On by default
m_nUsingSilenceSound = 0;
m_nUsingZSounds = -1; // On by default
m_nUsingStopDecals = -1; // On by default
m_nUsingNoShake = 0;
}
Expand Down Expand Up @@ -425,18 +427,21 @@ class CPlayerManager

uint64 GetStopSoundMask() { return m_nUsingStopSound; }
uint64 GetSilenceSoundMask() { return m_nUsingSilenceSound; }
uint64 GetZSoundsMask() { return m_nUsingZSounds; }
uint64 GetStopDecalsMask() { return m_nUsingStopDecals; }
uint64 GetNoShakeMask() { return m_nUsingNoShake; }

void SetPlayerStopSound(int slot, bool set);
void SetPlayerSilenceSound(int slot, bool set);
void SetPlayerZSounds(int slot, bool set);
void SetPlayerStopDecals(int slot, bool set);
void SetPlayerNoShake(int slot, bool set);

void ResetPlayerFlags(int slot);

bool IsPlayerUsingStopSound(int slot) { return m_nUsingStopSound & ((uint64)1 << slot); }
bool IsPlayerUsingSilenceSound(int slot) { return m_nUsingSilenceSound & ((uint64)1 << slot); }
bool IsPlayerUsingZSounds(int slot) { return m_nUsingZSounds & ((uint64)1 << slot); }
bool IsPlayerUsingStopDecals(int slot) { return m_nUsingStopDecals & ((uint64)1 << slot); }
bool IsPlayerUsingNoShake(int slot) { return m_nUsingNoShake & ((uint64)1 << slot); }

Expand All @@ -450,6 +455,7 @@ class CPlayerManager

uint64 m_nUsingStopSound;
uint64 m_nUsingSilenceSound;
uint64 m_nUsingZSounds;
uint64 m_nUsingStopDecals;
uint64 m_nUsingNoShake;
};
Expand Down
2 changes: 2 additions & 0 deletions src/user_preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void CUserPreferencesSystem::OnPutPreferences(int iSlot)
bool bHideDecals = (bool)GetPreferenceInt(iSlot, DECAL_PREF_KEY_NAME, 1);
bool bNoShake = (bool)GetPreferenceInt(iSlot, NO_SHAKE_PREF_KEY_NAME, 0);
int iButtonWatchMode = GetPreferenceInt(iSlot, BUTTON_WATCH_PREF_KEY_NAME, 0);
bool bZSounds = (bool)GetPreferenceInt(iSlot, ZSOUNDS_PREF_KEY_NAME, 1);

// EntWatch
int iEntwatchMode = GetPreferenceInt(iSlot, EW_PREF_HUD_MODE, 0);
Expand All @@ -125,6 +126,7 @@ void CUserPreferencesSystem::OnPutPreferences(int iSlot)
// Set the values that we just loaded --- the player is guaranteed available
g_playerManager->SetPlayerStopSound(iSlot, bStopSound);
g_playerManager->SetPlayerSilenceSound(iSlot, bSilenceSound);
g_playerManager->SetPlayerZSounds(iSlot, bZSounds);
g_playerManager->SetPlayerStopDecals(iSlot, bHideDecals);
g_playerManager->SetPlayerNoShake(iSlot, bNoShake);

Expand Down
Loading