Skip to content
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

Fix bot sounds being inaccurate, fix TP bots stuttering after teleporting, fix bot wrongfully spawning, fix gokz-quiet not working on bots sometimes #358

Closed
wants to merge 12 commits into from
Closed
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
50 changes: 50 additions & 0 deletions addons/sourcemod/gamedata/gokz-replays.games.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"Games"
{
"csgo"
{
"Functions"
{
"CCSGameRules::TeamFull"
{
"signature" "CCSGameRules::TeamFull"
"callconv" "thiscall"
"this" "address"
"return" "bool"
"arguments"
{
"teamid"
{
"type" "int"
}
}
}
}
"Signatures"
{
"CCSGameRules::TeamFull"
{
"windows" "\x55\x8B\xEC\x56\x8B\xF1\xE8\x2A\x2A\x2A\x2A\x8B\x45\x08\x83\xE8\x01"
"linux" "\x55\x89\xE5\x83\xEC\x18\x89\x5D\xF8\x8B\x5D\x08\x89\x75\xFC\x8B\x75\x0C\x89\x1C\x24\xE8\x2A\x2A\x2A\x2A\x83\xFE\x02"
}
"CBaseEntity::EmitSound"
{
"windows" "\x55\x8B\xEC\x83\xE4\xF8\x83\xEC\x6C\x53\x56\x8B\xF1\x8B\x0D\x2A\x2A\x2A\x2A\x57\x8B\xB9\x0C\x10\x00\x00"
"linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x9C\x00\x00\x00\x8B\x3D\x2A\x2A\x2A\x2A\x85\xFF\x0F\x95\xC0\x84\xC0\x88\x45\xE7\x74\x2A\x8B\x1D\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x39\xC3\x0F\x84\x2A\x2A\x2A\x2A\x8D\x5D\xC4\x0F\xB6\x35\x2A\x2A\x2A\x2A\xC6\x05\x2A\x2A\x2A\x2A\x01\x89\x1C\x24\xE8\x2A\x2A\x2A\x2A\xC7\x45\xC4\x2A\x2A\x2A\x2A\x89\x1C\x24\xE8\x2A\x2A\x2A\x2A\x8B\x45\x0C\xC7\x45\x84\x00\x00\x80\x3F\xC7\x85\x7C\xFF\xFF\xFF\x00\x00\x00\x00\xC7\x45\x88\x00\x00\x00\x00\xC7\x45\x8C\x00\x00\x00\x00\x89\x45\x80\x8B\x45\x10"
}
}
"Offsets"
{
"CCSPlayer::PlayStepSound"
{
"windows" "410"
"linux" "411"
}
// Subtracted off m_ubEFNoInterpParity
"CBasePlayer::m_pSurfaceData"
{
"windows" "12"
"linux" "12"
}
}
}
}
6 changes: 5 additions & 1 deletion addons/sourcemod/scripting/gokz-core/misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void OnTimerStart_JoinTeam(int client)
hasSavedPosition[client] = false;
}

void JoinTeam(int client, int newTeam, bool restorePos)
void JoinTeam(int client, int newTeam, bool restorePos, bool forceBroadcast = false)
{
KZPlayer player = KZPlayer(client);
int currentTeam = GetClientTeam(client);
Expand Down Expand Up @@ -356,6 +356,10 @@ void JoinTeam(int client, int newTeam, bool restorePos)
hasSavedPosition[client] = false;
Call_GOKZ_OnJoinTeam(client, newTeam);
}
else if (forceBroadcast)
{
Call_GOKZ_OnJoinTeam(client, newTeam);
}
}

void SendFakeTeamEvent(int client)
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/gokz-core/natives.sp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ public int Native_GetValidJump(Handle plugin, int numParams)

public int Native_JoinTeam(Handle plugin, int numParams)
{
JoinTeam(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3));
JoinTeam(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3), GetNativeCell(4));
return 0;
}

Expand Down
57 changes: 53 additions & 4 deletions addons/sourcemod/scripting/gokz-replays.sp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cstrike>
#include <sdkhooks>
#include <sdktools>
#include <dhooks>

#include <movementapi>

Expand Down Expand Up @@ -41,6 +42,10 @@ int gI_CurrentMapFileSize;
bool gB_HideNameChange;
bool gB_NubRecordMissed[MAXPLAYERS + 1];
ArrayList g_ReplayInfoCache;
Handle gH_EmitSound_SDKCall;
DynamicDetour gH_DHooks_TeamFull;
int gI_SurfaceDataOffset;
Handle gH_PlayStepSound_SDKCall;

#include "gokz-replays/commands.sp"
#include "gokz-replays/nav.sp"
Expand Down Expand Up @@ -175,7 +180,11 @@ public Action Hook_SayText2(UserMsg msg_id, any msg, const int[] players, int pl
return Plugin_Continue;
}


public MRESReturn DHooks_OnTeamFull_Pre(Address pThis, DHookReturn hReturn, DHookParam hParams)
{
DHookSetReturn(hReturn, false);
return MRES_Supercede;
}

// =====[ CLIENT EVENTS ]=====

Expand Down Expand Up @@ -269,14 +278,55 @@ public void GOKZ_DB_OnJumpstatPB(int client, int jumptype, int mode, float dista
GOKZ_DB_OnJumpstatPB_Recording(client, jumptype, distance, block, strafes, sync, pre, max, airtime);
}


public void GOKZ_OnOptionsLoaded(int client)
{
if (IsFakeClient(client))
{
GOKZ_OnOptionsLoaded_Playback(client);
}
}

// =====[ PRIVATE ]=====


static void HookEvents()
{
HookUserMessage(GetUserMessageId("SayText2"), Hook_SayText2, true);
GameData gameData = LoadGameConfigFile("gokz-replays.games");

StartPrepSDKCall(SDKCall_Entity);
PrepSDKCall_SetFromConf(gameData, SDKConf_Signature, "CBaseEntity::EmitSound");
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
PrepSDKCall_AddParameter(SDKType_Float, SDKPass_ByValue);
PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Pointer);
gH_EmitSound_SDKCall = EndPrepSDKCall();

StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(gameData, SDKConf_Virtual, "CCSPlayer::PlayStepSound");
PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
gH_PlayStepSound_SDKCall = EndPrepSDKCall();

int offset = gameData.GetOffset("CBasePlayer::m_pSurfaceData");
if (offset == -1)
{
SetFailState("Failed to find CBasePlayer::m_pSurfaceData offset");
}
gI_SurfaceDataOffset = FindSendPropInfo("CBasePlayer", "m_ubEFNoInterpParity") - offset;

gH_DHooks_TeamFull = DynamicDetour.FromConf(gameData, "CCSGameRules::TeamFull");
if (gH_DHooks_TeamFull == INVALID_HANDLE)
{
SetFailState("Failed to find CCSGameRules::TeamFull function signature");
}

if (!gH_DHooks_TeamFull.Enable(Hook_Pre, DHooks_OnTeamFull_Pre))
{
SetFailState("Failed to enable detour on CCSGameRules::TeamFull");
}
delete gameData;
}

static void UpdateCurrentMap()
Expand All @@ -286,7 +336,6 @@ static void UpdateCurrentMap()
}



// =====[ PUBLIC ]=====

// NOTE: These serialisation functions were made because the internal data layout of enum structs can change.
Expand Down
Loading