Skip to content

Commit

Permalink
Merge pull request #468 from KZGlobalTeam/dev
Browse files Browse the repository at this point in the history
3.6.0
  • Loading branch information
zealain authored May 3, 2023
2 parents 8f1eea6 + 7e5ee57 commit 8ba2aa8
Show file tree
Hide file tree
Showing 51 changed files with 2,491 additions and 817 deletions.
17 changes: 17 additions & 0 deletions addons/sourcemod/gamedata/gokz-core.games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
{
"#default"
{
"Functions"
{
"CCSGameMovement::CanUnduck"
{
"signature" "CCSGameMovement::CanUnduck"
"callconv" "thiscall"
"this" "address"
"return" "bool"
}
}

"Keys"
{
"IGameMovement" "GameMovement001"
Expand All @@ -17,6 +28,12 @@
"windows" "@CreateInterface"
"linux" "@CreateInterface"
}
"CCSGameMovement::CanUnduck"
{
"library" "server"
"windows" "\x55\x8B\xEC\x81\xEC\x8C\x00\x00\x00\x57\x8B\xF9\x8B\x87\x54\x0E\x00\x00"
"linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\xFC\x00\x00\x00\x8B\x5D\x08\x8B\x83\x54\x0E\x00\x00"
}
}

"Offsets"
Expand Down
24 changes: 24 additions & 0 deletions addons/sourcemod/gamedata/gokz-quiet.games.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"Games"
{
"csgo"
{
"Signatures"
{
"CGameClient::SendSound"
{
"library" "engine"
"windows" "\x55\x8B\xEC\x51\x56\x8B\xF1\x8B\x46\x04"
"linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x2C\x8B\x5D\x08\x8B\x75\x10\x8B\x03"
}
}

"Offsets"
{
"CBaseClient::GetPlayerSlot"
{
"windows" "16"
"linux" "17"
}
}
}
}
20 changes: 20 additions & 0 deletions addons/sourcemod/gamedata/gokz-replays.games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
{
"csgo"
{
"Addresses"
{
"BotDuck"
{
"signature" "BotDuckSig"
}
}
"Functions"
{
"CCSGameRules::TeamFull"
Expand All @@ -26,6 +33,19 @@
"windows" "\x55\x8B\xEC\x56\x8B\xF1\xE8\x2A\x2A\x2A\x2A\x8B\x45\x08\x83\xE8\x01"
"linux" "\x55\x89\xE5\x56\x53\x8B\x5D\x08\x8B\x75\x0C\x80\xBB\xAD\x0E\x00\x00\x00"
}
"BotDuckSig"
{
"windows" "\x8B\x86\x54\x0E\x00\x00\x8B\xCE"
"linux" "\x8B\x83\x54\x0E\x00\x00\x83\xEC\x0C"
}
}
"Offsets"
{
"BotDuckPatchLength"
{
"windows" "23"
"linux" "38"
}
}
}
}
55 changes: 55 additions & 0 deletions addons/sourcemod/gamedata/gokz-tpanglefix.games.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"Games"
{
"csgo"
{
"Functions"
{
"CGameClient::WriteViewAngleUpdate"
{
"signature" "CGameClient::WriteViewAngleUpdate"
"callconv" "thiscall"
"this" "address"
"return" "void"
}
}
"Addresses"
{
"WriteViewAngleUpdate"
{
"windows"
{
"signature" "CGameClient::WriteViewAngleUpdate"
}
"linux"
{
"signature" "CGameClient::WriteViewAngleUpdate"
}
}
}

"Offsets"
{
"WriteViewAngleUpdateReliableOffset"
{
"windows" "363"
"linux" "290"
}
"ClientIndexOffset"
{
"linux" "116"
"windows" "112"
}
}

"Signatures"
{
//A few functions after "%c00000000000000" string
"CGameClient::WriteViewAngleUpdate"
{
"library" "engine"
"windows" "\x55\x8B\xEC\x83\xEC\x40\x56\x57"
"linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x4C\x8B\x5D\x08\x8B\x03"
}
}
}
}
7 changes: 7 additions & 0 deletions addons/sourcemod/scripting/gokz-core.sp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
{
gI_CmdNum[client] = cmdnum;
gI_TickCount[client] = tickcount;
OnPlayerRunCmd_Triggerfix(client);
OnPlayerRunCmd_MapTriggers(client, buttons);
OnPlayerRunCmd_Turnbinds(client, buttons, tickcount, angles);
return Plugin_Continue;
Expand Down Expand Up @@ -271,6 +272,11 @@ public void OnCSPlayerSpawnPost(int client)
}
}

public void OnClientPreThinkPost(int client)
{
OnClientPreThinkPost_UseButtons(client);
}

public void Movement_OnChangeMovetype(int client, MoveType oldMovetype, MoveType newMovetype)
{
OnChangeMovetype_Timer(client, newMovetype);
Expand Down Expand Up @@ -510,6 +516,7 @@ static void HookClientEvents(int client)
DHookEntity(gH_DHooks_OnTeleport, true, client);
DHookEntity(gH_DHooks_SetModel, true, client);
SDKHook(client, SDKHook_SpawnPost, OnCSPlayerSpawnPost);
SDKHook(client, SDKHook_PreThinkPost, OnClientPreThinkPost);
}

static void UpdateTrackingVariables(int client, int cmdnum, int buttons)
Expand Down
172 changes: 171 additions & 1 deletion addons/sourcemod/scripting/gokz-core/misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,176 @@ void OnMapStart_FixMissingSpawns()
}
}

// =====[ BUTTONS ]=====

void OnClientPreThinkPost_UseButtons(int client)
{
if (GOKZ_GetCoreOption(client, Option_ButtonThroughPlayers) == ButtonThroughPlayers_Enabled && GetEntProp(client, Prop_Data, "m_afButtonPressed") & IN_USE)
{
int entity = FindUseEntity(client);
if (entity != -1)
{
AcceptEntityInput(entity, "Use", client, client, 1);
}
}
}

static int FindUseEntity(int client)
{
float fwd[3];
float angles[3];
GetClientEyeAngles(client, angles);
GetAngleVectors(angles, fwd, NULL_VECTOR, NULL_VECTOR);

Handle trace;

float eyeOrigin[3];
GetClientEyePosition(client, eyeOrigin);
int useableContents = (MASK_NPCSOLID_BRUSHONLY | MASK_OPAQUE_AND_NPCS) & ~CONTENTS_OPAQUE;

float endpos[3];

// Check if +use trace collide with a player first, so we don't activate any button twice
trace = TR_TraceRayFilterEx(eyeOrigin, angles, useableContents, RayType_Infinite, TRFOtherPlayersOnly, client);
if (TR_DidHit(trace))
{
int ent = TR_GetEntityIndex(trace);
if (ent < 1 || ent > MaxClients)
{
return -1;
}
// Search for a button behind it.
trace = TR_TraceRayFilterEx(eyeOrigin, angles, useableContents, RayType_Infinite, TraceEntityFilterPlayers);
if (TR_DidHit(trace))
{
char buffer[20];
ent = TR_GetEntityIndex(trace);
// Make sure that it is a button, and this button activates when pressed.
// If it is not a button, check its parent to see if it is a button.
bool isButton;
while (ent != -1)
{
GetEntityClassname(ent, buffer, sizeof(buffer));
if (StrEqual("func_button", buffer, false) && GetEntProp(ent, Prop_Data, "m_spawnflags") & SF_BUTTON_USE_ACTIVATES)
{
isButton = true;
break;
}
else
{
ent = GetEntPropEnt(ent, Prop_Data, "m_hMoveParent");
}
}
if (isButton)
{
TR_GetEndPosition(endpos, trace);
float delta[3];
for (int i = 0; i < 2; i++)
{
delta[i] = endpos[i] - eyeOrigin[i];
}
// Z distance is treated differently.
float m_vecMins[3];
float m_vecMaxs[3];
float m_vecOrigin[3];
GetEntPropVector(ent, Prop_Send, "m_vecOrigin", m_vecOrigin);
GetEntPropVector(ent, Prop_Send, "m_vecMins", m_vecMins);
GetEntPropVector(ent, Prop_Send, "m_vecMaxs", m_vecMaxs);

delta[2] = IntervalDistance(endpos[2], m_vecOrigin[2] + m_vecMins[2], m_vecOrigin[2] + m_vecMaxs[2]);
if (GetVectorLength(delta) < 80.0)
{
return ent;
}
}
}
}

int nearestEntity;
float nearestPoint[3];
float nearestDist = FLOAT_MAX;
ArrayList entities = new ArrayList();
TR_EnumerateEntitiesSphere(eyeOrigin, 80.0, 1<<5, AddEntities, entities);
for (int i = 0; i < entities.Length; i++)
{
char buffer[64];
int ent = entities.Get(i);
GetEntityClassname(ent, buffer, sizeof(buffer));
// Check if the entity is a button and it is pressable.
if (StrEqual("func_button", buffer, false) && GetEntProp(ent, Prop_Data, "m_spawnflags") & SF_BUTTON_USE_ACTIVATES)
{
float point[3];
CalcNearestPoint(ent, eyeOrigin, point);

float dir[3];
for (int j = 0; j < 3; j++)
{
dir[j] = point[j] - eyeOrigin[2];
}
// Check the maximum angle the player can be away from the button.
float minimumDot = GetEntPropFloat(ent, Prop_Send, "m_flUseLookAtAngle");
NormalizeVector(dir, dir);
float dot = GetVectorDotProduct(dir, fwd);
if (dot < minimumDot)
{
continue;
}

float dist = CalcDistanceToLine(point, eyeOrigin, fwd);
if (dist < nearestDist)
{
trace = TR_TraceRayFilterEx(eyeOrigin, point, useableContents, RayType_EndPoint, TraceEntityFilterPlayers);
if (TR_GetFraction(trace) == 1.0 || TR_GetEntityIndex(trace) == ent)
{
CopyVector(point, nearestPoint);
nearestDist = dist;
nearestEntity = ent;
}
}
}
}
// We found the closest button, but we still need to check if there is a player in front of it or not.
// In the case that there isn't a player inbetween, we don't return the entity index, because that button will be pressed by the game function anyway.
// If there is, we will press two buttons at once, the "right" button found by this function and the "wrong" button that we only happen to press because
// there is a player in the way.

trace = TR_TraceRayFilterEx(eyeOrigin, nearestPoint, useableContents, RayType_EndPoint, TRFOtherPlayersOnly);
if (TR_DidHit(trace))
{
return nearestEntity;
}
return -1;
}

public bool AddEntities(int entity, ArrayList entities)
{
entities.Push(entity);
return true;
}

static float IntervalDistance(float x, float x0, float x1)
{
if (x0 > x1)
{
float tmp = x0;
x0 = x1;
x1 = tmp;
}
if (x < x0)
{
return x0 - x;
}
else if (x > x1)
{
return x - x1;
}
return 0.0;
}
// TraceRay filter for other players exclusively.
public bool TRFOtherPlayersOnly(int entity, int contentmask, int client)
{
return (0 < entity <= MaxClients) && (entity != client);
}

// =====[ SAFE MODE ]=====

Expand All @@ -630,4 +800,4 @@ void ToggleProSafeGuard(int client)
{
GOKZ_SetCoreOption(client, Option_Safeguard, Safeguard_EnabledPRO);
}
}
}
6 changes: 5 additions & 1 deletion addons/sourcemod/scripting/gokz-core/teleports.sp
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,11 @@ static void CheckpointTeleportDo(int client)
checkpoints[client].GetArray(checkpointIndex[client], cp);

TeleportDo(client, cp.origin, cp.angles);

if (cp.groundEnt != INVALID_ENT_REFERENCE)
{
SetEntPropEnt(client, Prop_Data, "m_hGroundEntity", cp.groundEnt);
SetEntityFlags(client, GetEntityFlags(client) | FL_ONGROUND);
}
// Handle ladder stuff
if (cp.onLadder)
{
Expand Down
Loading

0 comments on commit 8ba2aa8

Please sign in to comment.