From 25805f67f832c5774459a942d6be9d27c5d9f610 Mon Sep 17 00:00:00 2001 From: Awe Date: Fri, 11 Oct 2024 20:08:23 -0400 Subject: [PATCH 1/8] Add config flag for MaxPrestrafe override --- addons/sourcemod/configs/shavit-styles.cfg | 1 + .../scripting/include/shavit/style-settings.sp | 1 + addons/sourcemod/scripting/shavit-core.sp | 3 ++- addons/sourcemod/scripting/shavit-misc.sp | 14 +++++++++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/addons/sourcemod/configs/shavit-styles.cfg b/addons/sourcemod/configs/shavit-styles.cfg index 11d2c1886..3c83dcdb8 100644 --- a/addons/sourcemod/configs/shavit-styles.cfg +++ b/addons/sourcemod/configs/shavit-styles.cfg @@ -35,6 +35,7 @@ // Physics "airaccelerate" "1000.0" // sv_airaccelerate value for the style. "runspeed" "260.00" // Running speed. Requires DHooks, shavit-misc and shavit_misc_staticprestrafe set to 1. + "maxprestrafe" "0.0" // IDK what description to put for this.... "gravity" "1.0" // Gravity setting, 1.0 for default. Standard for low gravity styles is 0.6. "speed" "1.0" // Speed multiplier, 1.0 for default. Standard for slowmo styles is 0.5. This a multiplier for m_flLaggedMovementValue. "timescale" "1.0" // Timing will scale with this setting. This is a multiplier for m_flLaggedMovementValue but also affects the timer increase speed. diff --git a/addons/sourcemod/scripting/include/shavit/style-settings.sp b/addons/sourcemod/scripting/include/shavit/style-settings.sp index 404641e38..52c143f9d 100644 --- a/addons/sourcemod/scripting/include/shavit/style-settings.sp +++ b/addons/sourcemod/scripting/include/shavit/style-settings.sp @@ -164,6 +164,7 @@ public SMCResult OnStyleEnterSection(SMCParser smc, const char[] name, bool opt_ SetStyleSettingFloat(gI_CurrentParserIndex, "airaccelerate", 1000.0); SetStyleSettingFloat(gI_CurrentParserIndex, "runspeed", 260.00); + SetStyleSettingFloat(gI_CurrentParserIndex, "maxprestrafe", 0.0); SetStyleSettingFloat(gI_CurrentParserIndex, "gravity", 1.0); SetStyleSettingFloat(gI_CurrentParserIndex, "speed", 1.0); SetStyleSettingInt (gI_CurrentParserIndex, "halftime", 0); diff --git a/addons/sourcemod/scripting/shavit-core.sp b/addons/sourcemod/scripting/shavit-core.sp index 6ea5821d2..d7f2695b4 100644 --- a/addons/sourcemod/scripting/shavit-core.sp +++ b/addons/sourcemod/scripting/shavit-core.sp @@ -2510,7 +2510,8 @@ bool CanStartTimer(int client, int track, bool skipGroundCheck) if (curVel <= 50.0) return true; - float prestrafe = StyleMaxPrestrafe(style); + float cfgMax = GetStyleSettingFloat(style, "maxprestrafe"); + float prestrafe = cfgMax > 0.0 ? cfgMax : StyleMaxPrestrafe(style); if (curVel > prestrafe) return false; diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index 0f834044e..3527c961c 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -1356,6 +1356,13 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fSpeed); float fLimit = (Shavit_GetStyleSettingFloat(gI_Style[client], "runspeed") + gCV_PrestrafeLimit.FloatValue); + float cfgLimit = Shavit_GetStyleSettingFloat(gI_Style[client], "maxprestrafe"); + float maxPrestrafe = StyleMaxPrestrafe(gI_Style[client]); + if (cfgLimit > 0.0) { + fLimit = cfgLimit; + } else if (fLimit > maxPrestrafe) { + fLimit = maxPrestrafe; + } // if trying to jump, add a very low limit to stop prespeeding in an elegant way // otherwise, make sure nothing weird is happening (such as sliding at ridiculous speeds, at zone enter) @@ -2286,8 +2293,13 @@ public Action Shavit_OnStartPre(int client, int track, bool& skipGroundTimer) GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fSpeed); float fLimit = (Shavit_GetStyleSettingFloat(gI_Style[client], "runspeed") + gCV_PrestrafeLimit.FloatValue); + float cfgLimit = Shavit_GetStyleSettingFloat(gI_Style[client], "maxprestrafe"); float maxPrestrafe = StyleMaxPrestrafe(gI_Style[client]); - if (fLimit > maxPrestrafe) fLimit = maxPrestrafe; + if (cfgLimit > 0.0) { + fLimit = cfgLimit; + } else if (fLimit > maxPrestrafe) { + fLimit = maxPrestrafe; + } // if trying to jump, add a very low limit to stop prespeeding in an elegant way // otherwise, make sure nothing weird is happening (such as sliding at ridiculous speeds, at zone enter) From a51140d90745e64659ef5f6031496c49fbcdd603 Mon Sep 17 00:00:00 2001 From: Awe Date: Sat, 12 Oct 2024 14:22:38 -0400 Subject: [PATCH 2/8] Allow zoners to edit startzone data --- addons/sourcemod/scripting/shavit-zones.sp | 14 +++++++++++++- .../translations/shavit-zones.phrases.txt | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/addons/sourcemod/scripting/shavit-zones.sp b/addons/sourcemod/scripting/shavit-zones.sp index e6c94e17f..581e39f6b 100644 --- a/addons/sourcemod/scripting/shavit-zones.sp +++ b/addons/sourcemod/scripting/shavit-zones.sp @@ -4361,7 +4361,19 @@ void CreateEditMenu(int client, bool autostage=false) FormatEx(sMenuItem, 64, "%T", "ZoneForceRender", client, ((gA_EditCache[client].iFlags & ZF_ForceRender) > 0)? "+":"-"); menu.AddItem("forcerender", sMenuItem); - if (gA_EditCache[client].iType == Zone_Stage) + if (gA_EditCache[client].iType == Zone_Start) { + if (gA_EditCache[client].iData == 0) + { + FormatEx(sMenuItem, 64, "%T", "ZoneSetSpeedLimitDefault", client, gA_EditCache[client].iData); + } + else + { + FormatEx(sMenuItem, 64, "%T", "ZoneSetSpeedLimit", client, gA_EditCache[client].iData); + } + + menu.AddItem("datafromchat", sMenuItem); + } + else if (gA_EditCache[client].iType == Zone_Stage) { if (autostage) { diff --git a/addons/sourcemod/translations/shavit-zones.phrases.txt b/addons/sourcemod/translations/shavit-zones.phrases.txt index 8691d155a..07b9b8422 100644 --- a/addons/sourcemod/translations/shavit-zones.phrases.txt +++ b/addons/sourcemod/translations/shavit-zones.phrases.txt @@ -260,6 +260,11 @@ "#format" "{1:d}" "en" "Custom speed limit: {1} (No Limit)" } + "ZoneSetSpeedLimitDefault" + { + "#format" "{1:d}" + "en" "Custom speed limit: {1} (Default Speedcap)" + } "ZoneSetStage" { "#format" "{1:d}" From ae6497219bc0505698424e6e383abe248a167a85 Mon Sep 17 00:00:00 2001 From: Awe Date: Sat, 12 Oct 2024 16:42:36 -0400 Subject: [PATCH 3/8] Use start zone data field for prestrafe limit --- addons/sourcemod/scripting/shavit-core.sp | 21 +++++++++++++--- addons/sourcemod/scripting/shavit-misc.sp | 30 ++++++++++++++++++++--- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/addons/sourcemod/scripting/shavit-core.sp b/addons/sourcemod/scripting/shavit-core.sp index d7f2695b4..bf20f0a40 100644 --- a/addons/sourcemod/scripting/shavit-core.sp +++ b/addons/sourcemod/scripting/shavit-core.sp @@ -173,6 +173,7 @@ char gS_Verification[MAXPLAYERS+1][8]; bool gB_CookiesRetrieved[MAXPLAYERS+1]; float gF_ZoneAiraccelerate[MAXPLAYERS+1]; float gF_ZoneSpeedLimit[MAXPLAYERS+1]; +float gF_ZoneStartSpeedLimit[MAXPLAYERS+1]; int gI_LastPrintedSteamID[MAXPLAYERS+1]; // kz support @@ -2511,7 +2512,18 @@ bool CanStartTimer(int client, int track, bool skipGroundCheck) return true; float cfgMax = GetStyleSettingFloat(style, "maxprestrafe"); - float prestrafe = cfgMax > 0.0 ? cfgMax : StyleMaxPrestrafe(style); + float zoneMax = gF_ZoneStartSpeedLimit[client]; + // float prestrafe = cfgMax > 0.0 ? cfgMax : StyleMaxPrestrafe(style); + float prestrafe; + if (zoneMax > 0.0) { + prestrafe = zoneMax; + } + else if (cfgMax > 0.0) { + prestrafe = cfgMax; + } else { + prestrafe = StyleMaxPrestrafe(style); + } + if (curVel > prestrafe) return false; @@ -2899,7 +2911,10 @@ void SQL_DBConnect() public void Shavit_OnEnterZone(int client, int type, int track, int id, int entity, int data) { - if (type == Zone_Airaccelerate && track == gA_Timers[client].iTimerTrack) + if (type == Zone_Start && track == gA_Timers[client].iTimerTrack) { + gF_ZoneStartSpeedLimit[client] = float(data); + } + else if (type == Zone_Airaccelerate && track == gA_Timers[client].iTimerTrack) { gF_ZoneAiraccelerate[client] = float(data); } @@ -2921,7 +2936,7 @@ public void Shavit_OnLeaveZone(int client, int type, int track, int id, int enti // Probably so very niche that it doesn't matter. if (track != gA_Timers[client].iTimerTrack) return; - if (type != Zone_Airaccelerate && type != Zone_CustomSpeedLimit) + if (type != Zone_Airaccelerate && type != Zone_CustomSpeedLimit && type != Zone_Start) return; UpdateStyleSettings(client); diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index 3527c961c..ea0571f06 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -1357,10 +1357,21 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float float fLimit = (Shavit_GetStyleSettingFloat(gI_Style[client], "runspeed") + gCV_PrestrafeLimit.FloatValue); float cfgLimit = Shavit_GetStyleSettingFloat(gI_Style[client], "maxprestrafe"); + + int zoneid; + Shavit_InsideZoneGetID(client, Zone_Start, track, zoneid); + float zoneLimit = float(Shavit_GetZoneData(zoneid)); + float maxPrestrafe = StyleMaxPrestrafe(gI_Style[client]); - if (cfgLimit > 0.0) { + if (zoneLimit > 0.0) + { + fLimit = zoneLimit; + } + else if (cfgLimit > 0.0) + { fLimit = cfgLimit; - } else if (fLimit > maxPrestrafe) { + } + else if (fLimit > maxPrestrafe){ fLimit = maxPrestrafe; } @@ -2294,10 +2305,21 @@ public Action Shavit_OnStartPre(int client, int track, bool& skipGroundTimer) float fLimit = (Shavit_GetStyleSettingFloat(gI_Style[client], "runspeed") + gCV_PrestrafeLimit.FloatValue); float cfgLimit = Shavit_GetStyleSettingFloat(gI_Style[client], "maxprestrafe"); + + int zoneid; + Shavit_InsideZoneGetID(client, Zone_Start, track, zoneid); + float zoneLimit = float(Shavit_GetZoneData(zoneid)); + float maxPrestrafe = StyleMaxPrestrafe(gI_Style[client]); - if (cfgLimit > 0.0) { + if (zoneLimit > 0.0) + { + fLimit = zoneLimit; + } + else if (cfgLimit > 0.0) + { fLimit = cfgLimit; - } else if (fLimit > maxPrestrafe) { + } + else if (fLimit > maxPrestrafe){ fLimit = maxPrestrafe; } From 59f17f1c1ce76b95a08dbbeab2617c4b6a75d675 Mon Sep 17 00:00:00 2001 From: Awe Date: Wed, 16 Oct 2024 16:13:37 -0400 Subject: [PATCH 4/8] Add prespeed type 6 that behaves like 5 and prevents prehopping --- addons/sourcemod/scripting/shavit-misc.sp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index ea0571f06..2f6ca19ce 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -264,7 +264,7 @@ public void OnPluginStart() // cvars and stuff gCV_GodMode = new Convar("shavit_misc_godmode", "3", "Enable godmode for players?\n0 - Disabled\n1 - Only prevent fall/world damage.\n2 - Only prevent damage from other players.\n3 - Full godmode.\n4 - Prevent fall/world/entity damage (all except damage from other players).", 0, true, 0.0, true, 4.0); - gCV_PreSpeed = new Convar("shavit_misc_prespeed", "2", "Stop prespeeding in the start zone?\n0 - Disabled, fully allow prespeeding.\n1 - Limit relatively to prestrafelimit.\n2 - Block bunnyhopping in startzone.\n3 - Limit to prestrafelimit and block bunnyhopping.\n4 - Limit to prestrafelimit but allow prespeeding. Combine with shavit_core_nozaxisspeed 1 for SourceCode timer's behavior.\n5 - Limit horizontal speed to prestrafe but allow prespeeding.", 0, true, 0.0, true, 5.0); + gCV_PreSpeed = new Convar("shavit_misc_prespeed", "2", "Stop prespeeding in the start zone?\n0 - Disabled, fully allow prespeeding.\n1 - Limit relatively to prestrafelimit.\n2 - Block bunnyhopping in startzone.\n3 - Limit to prestrafelimit and block bunnyhopping.\n4 - Limit to prestrafelimit but allow prespeeding. Combine with shavit_core_nozaxisspeed 1 for SourceCode timer's behavior.\n5 - Limit horizontal speed to prestrafe but allow prespeeding. \n6 - Limit horizontal speed to prestrafe and block bunnyhopping.", 0, true, 0.0, true, 5.0); gCV_HideTeamChanges = new Convar("shavit_misc_hideteamchanges", "1", "Hide team changes in chat?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0); gCV_RespawnOnTeam = new Convar("shavit_misc_respawnonteam", "1", "Respawn whenever a player joins a team?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0); gCV_RespawnOnRestart = new Convar("shavit_misc_respawnonrestart", "1", "Respawn a dead player if they use the timer restart command?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0); @@ -1346,7 +1346,7 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float } int iPrevGroundEntity = (gI_GroundEntity[client] != -1) ? EntRefToEntIndex(gI_GroundEntity[client]) : -1; - if ((prespeed_type == 2 || prespeed_type == 3) && iPrevGroundEntity == -1 && iGroundEntity != -1 && (buttons & IN_JUMP) > 0) + if ((prespeed_type == 2 || prespeed_type == 3 || prespeed_type == 6) && iPrevGroundEntity == -1 && iGroundEntity != -1 && (buttons & IN_JUMP) > 0) { DumbSetVelocity(client, view_as({0.0, 0.0, 0.0})); } @@ -1387,7 +1387,7 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float if(fScale < 1.0) { - if (prespeed_type == 5) + if (prespeed_type == 5 || prespeed_type == 6) { float zSpeed = fSpeed[2]; fSpeed[2] = 0.0; @@ -2335,7 +2335,7 @@ public Action Shavit_OnStartPre(int client, int track, bool& skipGroundTimer) if(fScale < 1.0) { - if (prespeed_type == 5) + if (prespeed_type == 5 || prespeed_type == 6) { float zSpeed = fSpeed[2]; fSpeed[2] = 0.0; From 419d0c53f3cdc004e940e051f1ef38582db28a0e Mon Sep 17 00:00:00 2001 From: Awe Date: Wed, 16 Oct 2024 16:14:31 -0400 Subject: [PATCH 5/8] Fix formatting --- addons/sourcemod/scripting/shavit-misc.sp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index 2f6ca19ce..e32d8b3a5 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -1371,7 +1371,8 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float { fLimit = cfgLimit; } - else if (fLimit > maxPrestrafe){ + else if (fLimit > maxPrestrafe) + { fLimit = maxPrestrafe; } @@ -2319,7 +2320,8 @@ public Action Shavit_OnStartPre(int client, int track, bool& skipGroundTimer) { fLimit = cfgLimit; } - else if (fLimit > maxPrestrafe){ + else if (fLimit > maxPrestrafe) + { fLimit = maxPrestrafe; } From b68985626991e56593521f1dbe276ba2012fb24a Mon Sep 17 00:00:00 2001 From: Awe Date: Wed, 16 Oct 2024 18:02:24 -0400 Subject: [PATCH 6/8] Bodged up code for 1 second prehop cooldown on prestrafe mode 6 --- addons/sourcemod/scripting/shavit-misc.sp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index e32d8b3a5..88999c867 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -73,6 +73,7 @@ Function gH_AfterWarningMenu[MAXPLAYERS+1]; int gI_LastWeaponTick[MAXPLAYERS+1]; int gI_LastNoclipTick[MAXPLAYERS+1]; int gI_LastStopInfo[MAXPLAYERS+1]; +int gI_LastGroundLandTick[MAXPLAYERS+1]; // cookies Handle gH_HideCookie = null; @@ -1345,8 +1346,19 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float prespeed_type = gCV_PreSpeed.IntValue; } + int tickCount = GetSysTickCount(); int iPrevGroundEntity = (gI_GroundEntity[client] != -1) ? EntRefToEntIndex(gI_GroundEntity[client]) : -1; - if ((prespeed_type == 2 || prespeed_type == 3 || prespeed_type == 6) && iPrevGroundEntity == -1 && iGroundEntity != -1 && (buttons & IN_JUMP) > 0) + + if (iPrevGroundEntity == -1 && iGroundEntity != -1) { + gI_LastGroundLandTick[client] = tickCount; + } + + if ((prespeed_type == 2 || prespeed_type == 3) && iPrevGroundEntity == -1 && iGroundEntity != -1 && (buttons & IN_JUMP) > 0) + { + DumbSetVelocity(client, view_as({0.0, 0.0, 0.0})); + } + + if (prespeed_type == 6 && iPrevGroundEntity == -1 && iGroundEntity != -1 && tickCount - gI_LastGroundLandTick[client] <= 1000) { DumbSetVelocity(client, view_as({0.0, 0.0, 0.0})); } From 0ad706ce32ab5b3164e433cb350b00a16924333c Mon Sep 17 00:00:00 2001 From: Awe Date: Wed, 16 Oct 2024 19:34:27 -0400 Subject: [PATCH 7/8] Make anti prespeed a little bit better (maybe????) --- addons/sourcemod/scripting/shavit-misc.sp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index 88999c867..9d8e931b4 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -1358,7 +1358,7 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float DumbSetVelocity(client, view_as({0.0, 0.0, 0.0})); } - if (prespeed_type == 6 && iPrevGroundEntity == -1 && iGroundEntity != -1 && tickCount - gI_LastGroundLandTick[client] <= 1000) + if (prespeed_type == 6 && iGroundEntity != -1 && tickCount - gI_LastGroundLandTick[client] <= 250 && (buttons & IN_JUMP) > 0) { DumbSetVelocity(client, view_as({0.0, 0.0, 0.0})); } @@ -1466,6 +1466,7 @@ public void OnClientPutInServer(int client) gI_LastWeaponTick[client] = 0; gI_LastNoclipTick[client] = 0; + gI_LastGroundLandTick[client] = 0; if(IsFakeClient(client)) { From 124decb1ec696d694518bc3defe614cc59bdee32 Mon Sep 17 00:00:00 2001 From: Awe Date: Sun, 20 Oct 2024 01:27:15 -0400 Subject: [PATCH 8/8] Tiredly twiddle with prespeed style 6 impl --- addons/sourcemod/scripting/shavit-misc.sp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index 9d8e931b4..99674c5b5 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -1358,10 +1358,6 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float DumbSetVelocity(client, view_as({0.0, 0.0, 0.0})); } - if (prespeed_type == 6 && iGroundEntity != -1 && tickCount - gI_LastGroundLandTick[client] <= 250 && (buttons & IN_JUMP) > 0) - { - DumbSetVelocity(client, view_as({0.0, 0.0, 0.0})); - } else if (prespeed_type == 1 || prespeed_type >= 3) { float fSpeed[3]; @@ -1395,6 +1391,21 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float fLimit /= 3.0; } + int iOldButtons = GetEntProp(client, Prop_Data, "m_nOldButtons"); + // TODO: somehow incorporate the autobhop style thingy or figure out a better way to do all of this lmao + int iAutoBhop = Shavit_GetStyleSettingBool(Shavit_GetBhopStyle(client), "autobhop"); + bool isJumping = (buttons & IN_JUMP) > 0; + if (!iAutoBhop) + { + isJumping &= (iOldButtons & IN_JUMP) == 0; + } + if (prespeed_type == 6 && iGroundEntity != -1 && + tickCount - gI_LastGroundLandTick[client] <= 150 && + isJumping) + { + fLimit /= 3.0; + } + float fSpeedXY = (SquareRoot(Pow(fSpeed[0], 2.0) + Pow(fSpeed[1], 2.0))); float fScale = (fLimit / fSpeedXY);