Skip to content

Commit

Permalink
Merge pull request #378 from KZGlobalTeam/dev
Browse files Browse the repository at this point in the history
3.4.0
  • Loading branch information
zealain authored Oct 7, 2022
2 parents 9eef0cf + d6d9b6e commit 928b433
Show file tree
Hide file tree
Showing 78 changed files with 1,165 additions and 330 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI

env:
SM_VERSION: "1.10"
SM_VERSION: "1.11"

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/gokz-anticheat/bhop_tracking.sp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ static bool JustLanded(int client, int cmdnum)
}

// Records current button inputs
static int RecordButtons(int client, int buttons)
static void RecordButtons(int client, int buttons)
{
gI_ButtonsIndex[client] = NextIndex(gI_ButtonsIndex[client], AC_MAX_BUTTON_SAMPLES);
gI_Buttons[client][gI_ButtonsIndex[client]] = buttons;
Expand Down
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/gokz-chat.sp
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,5 @@ public int Native_SetChatTag(Handle plugin, int numParams)
}

GetNativeString(3, gC_PlayerTagColors[client], sizeof(gC_PlayerTagColors[]));
return 0;
}
19 changes: 15 additions & 4 deletions addons/sourcemod/scripting/gokz-core.sp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Handle gH_DHooks_OnTeleport;
Handle gH_DHooks_SetModel;

int gI_CmdNum[MAXPLAYERS + 1];
int gI_TickCount[MAXPLAYERS + 1];
bool gB_OldOnGround[MAXPLAYERS + 1];
int gI_OldButtons[MAXPLAYERS + 1];
int gI_TeleportCmdNum[MAXPLAYERS + 1];
Expand All @@ -52,8 +53,6 @@ ConVar gCV_gokz_chat_prefix;
ConVar gCV_sv_full_alltalk;

#include "gokz-core/commands.sp"
#include "gokz-core/forwards.sp"
#include "gokz-core/natives.sp"
#include "gokz-core/modes.sp"
#include "gokz-core/misc.sp"
#include "gokz-core/options.sp"
Expand All @@ -77,6 +76,9 @@ ConVar gCV_sv_full_alltalk;
#include "gokz-core/timer/timer.sp"
#include "gokz-core/timer/virtual_buttons.sp"

#include "gokz-core/forwards.sp"
#include "gokz-core/natives.sp"



// =====[ PLUGIN EVENTS ]=====
Expand Down Expand Up @@ -178,7 +180,9 @@ public void OnClientDisconnect(int client)
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
{
gI_CmdNum[client] = cmdnum;
gI_TickCount[client] = tickcount;
OnPlayerRunCmd_MapTriggers(client, buttons);
OnPlayerRunCmd_Turnbinds(client, buttons, tickcount, angles);
return Plugin_Continue;
}

Expand Down Expand Up @@ -248,6 +252,12 @@ public Action OnPlayerDeath(Event event, const char[] name, bool dontBroadcast)
return Plugin_Continue;
}

public void OnPlayerJump(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
OnPlayerJump_Triggers(client);
}

public MRESReturn DHooks_OnTeleport(int client, Handle params)
{
gB_OriginTeleported[client] = !DHookIsNullParam(params, 1); // Origin affected
Expand Down Expand Up @@ -363,7 +373,7 @@ public void OnConfigsExecuted()
OnConfigsExecuted_OptionsMenu();
}

public Action OnNormalSound(int[] clients, int &numClients, char[] sample, int &entity, int &channel, float &volume, int &level, int &pitch, int &flags, char[] soundEntry, int &seed)
public Action OnNormalSound(int clients[MAXPLAYERS], int &numClients, char sample[PLATFORM_MAX_PATH], int &entity, int &channel, float &volume, int &level, int &pitch, int &flags, char soundEntry[PLATFORM_MAX_PATH], int &seed)
{
if (OnNormalSound_StopSounds(entity) == Plugin_Handled)
{
Expand Down Expand Up @@ -475,8 +485,9 @@ static void HookEvents()
HookEvent("player_spawn", OnPlayerSpawn, EventHookMode_Post);
HookEvent("player_team", OnPlayerJoinTeam, EventHookMode_Pre);
HookEvent("player_death", OnPlayerDeath, EventHookMode_Pre);
HookEvent("player_jump", OnPlayerJump);
HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy);
AddNormalSoundHook(view_as<NormalSHook>(OnNormalSound));
AddNormalSoundHook(OnNormalSound);

GameData gameData = new GameData("sdktools.games");
int offset;
Expand Down
46 changes: 33 additions & 13 deletions addons/sourcemod/scripting/gokz-core/commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ void RegisterCommands()
RegConsoleCmd("sm_ncnt", CommandToggleNoclipNotrigger, "[KZ] Toggle noclip-notrigger.");
RegConsoleCmd("+noclipnt", CommandEnableNoclipNotrigger, "[KZ] Noclip-notrigger on.");
RegConsoleCmd("-noclipnt", CommandDisableNoclipNotrigger, "[KZ] Noclip-notrigger off.");
RegConsoleCmd("sm_sg", CommandSafeGuard, "[KZ] Toggle safeguard.");
RegConsoleCmd("sm_safe", CommandSafeGuard, "[KZ] Toggle safeguard.");
RegConsoleCmd("sm_safeguard", CommandSafeGuard, "[KZ] Toggle safeguard.");
RegConsoleCmd("sm_pro", CommandProSafeGuard, "[KZ] Toggle PRO safeguard.");
}

void AddCommandsListeners()
Expand All @@ -59,6 +63,13 @@ bool SwitchToModeIfAvailable(int client, int mode)
}
else
{
// Safeguard Check
if (GOKZ_GetCoreOption(client, Option_Safeguard) > Safeguard_Disabled && GOKZ_GetTimerRunning(client) && GOKZ_GetValidTimer(client))
{
GOKZ_PrintToChat(client, true, "%t", "Safeguard - Blocked");
GOKZ_PlayErrorSound(client);
return false;
}
GOKZ_SetCoreOption(client, Option_Mode, mode);
return true;
}
Expand All @@ -80,10 +91,17 @@ public Action CommandJoinTeam(int client, const char[] command, int argc)
{
if (!GOKZ_GetPaused(client) && !GOKZ_GetCanPause(client))
{
SendFakeTeamEvent(client);
return Plugin_Handled;
}
}

else if (IsPlayerAlive(client) && GOKZ_GetCoreOption(client, Option_Safeguard) > Safeguard_Disabled && GOKZ_GetTimerRunning(client) && GOKZ_GetValidTimer(client))
{
GOKZ_PrintToChat(client, true, "%t", "Safeguard - Blocked");
GOKZ_PlayErrorSound(client);
SendFakeTeamEvent(client);
return Plugin_Handled;
}
GOKZ_JoinTeam(client, team);
return Plugin_Handled;
}
Expand Down Expand Up @@ -204,21 +222,15 @@ public Action CommandClearStartPos(int client, int args)

public Action CommandMain(int client, int args)
{
if (!TeleportToCourseStart(client, 0))
{
GOKZ_PrintToChat(client, true, "%t", "No Start Found");
}
TeleportToCourseStart(client, 0);
return Plugin_Handled;
}

public Action CommandBonus(int client, int args)
{
if (args == 0)
{ // Go to Bonus 1
if (!TeleportToCourseStart(client, 1))
{
GOKZ_PrintToChat(client, true, "%t", "No Start Found (Bonus)", 1);
}
TeleportToCourseStart(client, 1);
}
else
{ // Go to specified Bonus #
Expand All @@ -227,10 +239,7 @@ public Action CommandBonus(int client, int args)
int bonus = StringToInt(argBonus);
if (GOKZ_IsValidCourse(bonus, true))
{
if (!TeleportToCourseStart(client, bonus))
{
GOKZ_PrintToChat(client, true, "%t", "No Start Found (Bonus)", bonus);
}
TeleportToCourseStart(client, bonus);
}
else
{
Expand Down Expand Up @@ -348,3 +357,14 @@ public Action CommandDisableNoclipNotrigger(int client, int args)
return Plugin_Handled;
}

public Action CommandSafeGuard(int client, int args)
{
ToggleSafeGuard(client);
return Plugin_Handled;
}

public Action CommandProSafeGuard(int client, int args)
{
ToggleProSafeGuard(client);
return Plugin_Handled;
}
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/gokz-core/demofix.sp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void OnRoundStart_Demofix()
public Action Command_Demorestart(int client, const char[] command, int argc)
{
FixRecord(client);
return Plugin_Continue;
}

static void FixRecord(int client)
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/gokz-core/map/mapfile.sp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static int EntlumpGetString(char[] result, int maxLength, int copyCount, char[]
return finalLength;
}

static EntlumpToken[] EntlumpGetToken(char[] entityLump, int &entlumpIndex)
static EntlumpToken EntlumpGetToken(char[] entityLump, int &entlumpIndex)
{
EntlumpToken result;

Expand Down
40 changes: 28 additions & 12 deletions addons/sourcemod/scripting/gokz-core/map/triggers.sp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ static int antiPauseTriggerTouchCount[MAXPLAYERS + 1];
static int antiJumpstatTriggerTouchCount[MAXPLAYERS + 1];
static int mapMappingApiVersion = GOKZ_MAPPING_API_VERSION_NONE;
static int bhopTouchCount[MAXPLAYERS + 1];
static bool jumpedThisTick[MAXPLAYERS + 1];
static float jumpOrigin[MAXPLAYERS + 1][3];
static float jumpVelocity[MAXPLAYERS + 1][3];
static ArrayList triggerTouchList[MAXPLAYERS + 1]; // arraylist of TouchedTrigger that the player is currently touching. this array won't ever get long (unless the mapper does something weird).
static StringMap triggerTouchCounts[MAXPLAYERS + 1]; // stringmap of int touch counts with key being a string of the entity reference.
static StringMap antiBhopTriggers; // stringmap of AntiBhopTrigger with key being a string of the m_iHammerID entprop.
Expand Down Expand Up @@ -197,7 +200,7 @@ void OnPlayerRunCmd_MapTriggers(int client, int &buttons)

if (touched.triggerType == TriggerType_Antibhop)
{
TouchAntibhopTrigger(touched, buttons, flags);
TouchAntibhopTrigger(client, touched, buttons, flags);
}
else if (touched.triggerType == TriggerType_Teleport)
{
Expand All @@ -211,6 +214,7 @@ void OnPlayerRunCmd_MapTriggers(int client, int &buttons)
}
}
}
jumpedThisTick[client] = false;
}

void OnPlayerSpawn_MapTriggers(int client)
Expand All @@ -236,6 +240,13 @@ void OnPlayerSpawn_MapTriggers(int client)
}
}

public void OnPlayerJump_Triggers(int client)
{
jumpedThisTick[client] = true;
GetClientAbsOrigin(client, jumpOrigin[client]);
Movement_GetVelocity(client, jumpVelocity[client]);
}

void OnEntitySpawned_MapTriggers(int entity)
{
char classname[32];
Expand Down Expand Up @@ -324,6 +335,11 @@ public void OnAntiBhopTrigTouchStart_MapTriggers(const char[] output, int entity
return;
}

if (jumpedThisTick[other])
{
TeleportEntity(other, jumpOrigin[other], NULL_VECTOR, jumpVelocity[other]);
}

AddTriggerToTouchList(other, entity, TriggerType_Antibhop);
}

Expand Down Expand Up @@ -507,7 +523,7 @@ void OnStartTouchGround_MapTriggers(int client)
TouchedTrigger touched;
triggerTouchList[client].GetArray(i, touched);
// set the touched tick to the tick that the player touches the ground.
touched.groundTouchTick = GetGameTickCount();
touched.groundTouchTick = gI_TickCount[client];
triggerTouchList[client].SetArray(i, touched);
}
}
Expand Down Expand Up @@ -563,11 +579,11 @@ static void AddTriggerToTouchList(int client, int trigger, TriggerType triggerTy
TouchedTrigger touched;
touched.triggerType = triggerType;
touched.entRef = triggerEntRef;
touched.startTouchTick = GetGameTickCount();
touched.startTouchTick = gI_TickCount[client];
touched.groundTouchTick = -1;
if (GetEntityFlags(client) & FL_ONGROUND)
{
touched.groundTouchTick = GetGameTickCount();
touched.groundTouchTick = gI_TickCount[client];
}

triggerTouchList[client].PushArray(touched);
Expand Down Expand Up @@ -616,7 +632,7 @@ static void DecrementTriggerTouchCount(int client, int trigger)
triggerTouchCounts[client].SetValue(szEntref, value);
}

static void TouchAntibhopTrigger(TouchedTrigger touched, int &newButtons, int flags)
static void TouchAntibhopTrigger(int client, TouchedTrigger touched, int &newButtons, int flags)
{
if (!(flags & FL_ONGROUND))
{
Expand All @@ -637,7 +653,7 @@ static void TouchAntibhopTrigger(TouchedTrigger touched, int &newButtons, int fl
AntiBhopTrigger trigger;
if (antiBhopTriggers.GetArray(key, trigger, sizeof(trigger)))
{
float touchTime = CalculateGroundTouchTime(touched);
float touchTime = CalculateGroundTouchTime(client, touched);
if (trigger.time == 0.0 || touchTime <= trigger.time)
{
// disable jump
Expand Down Expand Up @@ -687,7 +703,7 @@ static bool TouchTeleportTrigger(int client, TouchedTrigger touched, int flags)
// NOTE: Find out if we should actually teleport.
if (isBhopTrigger && (flags & FL_ONGROUND))
{
float touchTime = CalculateGroundTouchTime(touched);
float touchTime = CalculateGroundTouchTime(client, touched);
if (touchTime > trigger.delay)
{
shouldTeleport = true;
Expand All @@ -712,7 +728,7 @@ static bool TouchTeleportTrigger(int client, TouchedTrigger touched, int flags)
}
else if (trigger.type == TeleportType_Normal)
{
float touchTime = CalculateStartTouchTime(touched);
float touchTime = CalculateStartTouchTime(client, touched);
shouldTeleport = touchTime > trigger.delay || (trigger.delay == 0.0);
}

Expand Down Expand Up @@ -777,15 +793,15 @@ static bool TouchTeleportTrigger(int client, TouchedTrigger touched, int flags)
return shouldTeleport;
}

static float CalculateGroundTouchTime(TouchedTrigger touched)
static float CalculateGroundTouchTime(int client, TouchedTrigger touched)
{
float result = float(GetGameTickCount() - touched.groundTouchTick) * GetTickInterval();
float result = float(gI_TickCount[client] - touched.groundTouchTick) * GetTickInterval();
return result;
}

static float CalculateStartTouchTime(TouchedTrigger touched)
static float CalculateStartTouchTime(int client, TouchedTrigger touched)
{
float result = float(GetGameTickCount() - touched.startTouchTick) * GetTickInterval();
float result = float(gI_TickCount[client] - touched.startTouchTick) * GetTickInterval();
return result;
}

Expand Down
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/gokz-core/menus/mode_menu.sp
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ public int MenuHandler_Mode(Menu menu, MenuAction action, int param1, int param2
{
delete menu;
}
return 0;
}
6 changes: 6 additions & 0 deletions addons/sourcemod/scripting/gokz-core/menus/options_menu.sp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ public void TopMenuHandler_General(TopMenu topmenu, TopMenuAction action, TopMen
gC_CoreOptionPhrases[option], param,
gC_TimerButtonZoneTypePhrases[GOKZ_GetCoreOption(param, option)], param);
}
case Option_Safeguard:
{
FormatEx(buffer, maxlength, "%T - %T",
gC_CoreOptionPhrases[option], param,
gC_SafeGuardPhrases[GOKZ_GetCoreOption(param, option)], param);
}
default:FormatToggleableOptionDisplay(param, option, buffer, maxlength);
}
}
Expand Down
Loading

0 comments on commit 928b433

Please sign in to comment.