Compare commits

...

2 Commits

Author SHA1 Message Date
rtldg
757c210541
Merge 91ed36a82a into 58a1046e0a 2025-02-20 03:31:17 +00:00
rtldg
91ed36a82a gamedata-ify more things 2025-02-20 03:28:56 +00:00
2 changed files with 81 additions and 12 deletions

View File

@ -106,6 +106,34 @@
"linux" "12" "linux" "12"
"linux64" "24" "linux64" "24"
} }
"SoundInfo_t::fVolume"
{
"windows" "40"
"windows64" "44"
"linux" "40"
"linux64" "44"
}
"SoundInfo_t::bIsAmbient"
{
"windows" "85"
"windows64" "89"
"linux" "85"
"linux64" "89"
}
"ss_update_t::pCurrentSoundscape"
{
"windows" "4"
"windows64" "8"
"linux" "4"
"windows64" "8"
}
"CGameClient::thing"
{
"windows" "4"
"windows64" "8"
"linux" "4"
"windows64" "8"
}
} }
} }
@ -208,6 +236,26 @@
"windows" "12" "windows" "12"
"linux" "12" "linux" "12"
} }
"SoundInfo_t::fVolume"
{
"windows" "40"
"linux" "40"
}
"SoundInfo_t::bIsAmbient"
{
"windows" "89"
"linux" "89"
}
"ss_update_t::pCurrentSoundscape"
{
"windows" "4"
"linux" "4"
}
"CGameClient::thing"
{
"windows" "4"
"linux" "4"
}
} }
} }
} }

View File

@ -39,11 +39,14 @@ Address gP_SoundscapeSystem = Address_Null;
Handle gH_AcceptInput = null; Handle gH_AcceptInput = null;
Handle gH_GetPlayerSlot = null; Handle gH_GetPlayerSlot = null;
Handle gH_GetStringID = null; Handle gH_GetStringID = null;
int gI_AmbientOffset = -1;
int gI_m_soundscapesOffset = -1; int gI_m_soundscapesOffset = -1;
int gI_VolumeOffset = -1;
int gI_CurrentSoundscapeOffset = -1;
int gI_CGameClientThing = -1;
// Other // Other
int gI_SilentSoundScape = -1; int gI_SilentSoundScape = -1;
int gI_AmbientOffset = 0;
char gS_WeaponID[32]; char gS_WeaponID[32];
bool gB_ShouldHookShotgunShot = false; bool gB_ShouldHookShotgunShot = false;
@ -64,12 +67,10 @@ public void OnPluginStart()
gEV_Type = GetEngineVersion(); gEV_Type = GetEngineVersion();
if(gEV_Type == Engine_CSS) if(gEV_Type == Engine_CSS)
{ {
gI_AmbientOffset = 85;
FormatEx(gS_WeaponID, sizeof(gS_WeaponID), "m_iWeaponID"); FormatEx(gS_WeaponID, sizeof(gS_WeaponID), "m_iWeaponID");
} }
else if(gEV_Type == Engine_CSGO) else if(gEV_Type == Engine_CSGO)
{ {
gI_AmbientOffset = 89;
FormatEx(gS_WeaponID, sizeof(gS_WeaponID), "m_weapon"); FormatEx(gS_WeaponID, sizeof(gS_WeaponID), "m_weapon");
} }
else else
@ -237,6 +238,31 @@ void LoadDHooks()
HookAcceptInput(); HookAcceptInput();
HookSendSound(hGameData); HookSendSound(hGameData);
if ((gI_AmbientOffset = GameConfGetOffset(hGameData, "SoundInfo_t::bIsAmbient")) == -1)
{
SetFailState("Could not get SoundInfo_t::bIsAmbient offset");
}
if ((gI_m_soundscapesOffset = GameConfGetOffset(hGameData, "CSoundscapeSystem::m_soundscapes")) == -1)
{
SetFailState("Could not get CSoundscapeSystem::m_soundscapes offset");
}
if ((gI_VolumeOffset = GameConfGetOffset(hGameData, "SoundInfo_t::fVolume")) == -1)
{
SetFailState("Could not get SoundInfo_t::fVolume offset");
}
if ((gI_CurrentSoundscapeOffset = GameConfGetOffset(hGameData, "ss_update_t::pCurrentSoundscape")) == -1)
{
SetFailState("Could not get ss_update_t::pCurrentSoundscape");
}
if ((gI_CGameClientThing = GameConfGetOffset(hGameData, "CGameClient::thing")) == -1)
{
SetFailState("Could not get CGameClient::thing");
}
delete hGameData; delete hGameData;
} }
@ -249,11 +275,6 @@ void StartPrepSDKCall_GetStringID(Handle hGameData)
SetFailState("Could not get address of CSoundscapeSystem pointer."); SetFailState("Could not get address of CSoundscapeSystem pointer.");
} }
if ((gI_m_soundscapesOffset = GameConfGetOffset(hGameData, "CSoundscapeSystem::m_soundscapes")) == -1)
{
SetFailState("Could not get CSoundscapeSystem::m_soundscapes offset");
}
StartPrepSDKCall(SDKCall_Raw); StartPrepSDKCall(SDKCall_Raw);
PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "CStringRegistry::GetStringID"); PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "CStringRegistry::GetStringID");
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer); PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
@ -308,7 +329,7 @@ void HookSoundscapes(Handle hGameData)
struct ss_update_t struct ss_update_t
{ {
CBasePlayer *pPlayer; Offset: 0 | Size: 4 CBasePlayer *pPlayer; Offset: 0 | Size: 4
CEnvSoundscape pCurrentSoundscape; Offset: 4 | Size: 4 CEnvSoundscape *pCurrentSoundscape; Offset: 4 | Size: 4
Vector playerPosition; Offset: 8 | Size: 12 Vector playerPosition; Offset: 8 | Size: 12
float currentDistance; Offset: 20 | Size: 4 float currentDistance; Offset: 20 | Size: 4
int traceCount; Offset: 24 | Size: 4 int traceCount; Offset: 24 | Size: 4
@ -345,7 +366,7 @@ public MRESReturn DHook_UpdateForPlayer(int pThis, Handle hParams)
} }
else else
{ {
DHookSetParamObjectPtrVar(hParams, 1, 4, ObjectValueType_CBaseEntityPtr, 0); DHookSetParamObjectPtrVar(hParams, 1, gI_CurrentSoundscapeOffset, ObjectValueType_CBaseEntityPtr, 0);
} }
gI_LastSoundscape[client] = GetEntProp(client, Prop_Data, "soundscapeIndex"); gI_LastSoundscape[client] = GetEntProp(client, Prop_Data, "soundscapeIndex");
@ -484,13 +505,13 @@ void HookSendSound(Handle hGameData)
//void CGameClient::SendSound( SoundInfo_t &sound, bool isReliable ) //void CGameClient::SendSound( SoundInfo_t &sound, bool isReliable )
public MRESReturn DHook_SendSound(Address pThis, Handle hParams) public MRESReturn DHook_SendSound(Address pThis, Handle hParams)
{ {
if(DHookGetParamObjectPtrVar(hParams, 1, 40, ObjectValueType_Float) == 0.0) if(DHookGetParamObjectPtrVar(hParams, 1, gI_VolumeOffset, ObjectValueType_Float) == 0.0)
{ {
return MRES_Ignored; return MRES_Ignored;
} }
// TODO: // TODO:
Address pIClient = pThis + view_as<Address>(0x4); Address pIClient = pThis + view_as<Address>(gI_CGameClientThing);
int client = view_as<int>(SDKCall(gH_GetPlayerSlot, pIClient)) + 1; int client = view_as<int>(SDKCall(gH_GetPlayerSlot, pIClient)) + 1;
if(!IsValidClient(client)) if(!IsValidClient(client))