mirror of
https://github.com/GAMMACASE/NoclipSpeed.git
synced 2025-12-06 18:08:39 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb9f4efe60 | ||
|
|
8fabe86bb9 | ||
|
|
dbd7683201 | ||
|
|
2532f958c9 | ||
|
|
b704e1feac | ||
|
|
cdebbc96a2 |
@ -1,9 +1,6 @@
|
||||
# NoclipSpeed
|
||||
SourceMod plugin that allows players to change noclip speed.
|
||||
|
||||
## Note
|
||||
Only CSGO is currently supported.
|
||||
|
||||
## Requirements
|
||||
* [Dhooks with detour support](https://forums.alliedmods.net/showpost.php?p=2588686&postcount=589);
|
||||
* SourceMod 1.10 or higher.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
"Games"
|
||||
{
|
||||
"csgo"
|
||||
"#default"
|
||||
{
|
||||
"Keys"
|
||||
{
|
||||
@ -12,16 +12,6 @@
|
||||
"CBaseEntity::m_RefEHandle" "12"
|
||||
}
|
||||
|
||||
"Signatures"
|
||||
{
|
||||
"CGameMovement::FullNoClipMove"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x53\x8B\xDC\x83\xEC\x08\x83\xE4\xF0\x83\xC4\x04\x55\x8B\x6B\x04\x89\x6C\x24\x04\x8B\xEC\x83\xEC\x5C\x56\x8B\xF1"
|
||||
"linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x9C\x00\x00\x00\xA1\x2A\x2A\x2A\x2A\x8B\x5D\x08\x3D\x2A\x2A\x2A\x2A"
|
||||
}
|
||||
}
|
||||
|
||||
"Offsets"
|
||||
{
|
||||
"OSType"
|
||||
@ -37,4 +27,30 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"csgo"
|
||||
{
|
||||
"Signatures"
|
||||
{
|
||||
"CGameMovement::FullNoClipMove"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x53\x8B\xDC\x83\xEC\x08\x83\xE4\xF0\x83\xC4\x04\x55\x8B\x6B\x04\x89\x6C\x24\x04\x8B\xEC\x83\xEC\x5C\x56\x8B\xF1"
|
||||
"linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x4C\xA1\x2A\x2A\x2A\x2A\x8B\x5D\x08\x3D\x2A\x2A\x2A\x2A\x0F\x84\x2A\x2A\x2A\x2A\x8B\x10\x8B\x52\x3C\x81\xFA\x2A\x2A\x2A\x2A\x0F\x85\x2A\x2A\x2A\x2A\x8B\x70\x1C\x39\xC6\x0F\x84\x2A\x2A\x2A\x2A\x8B\x06\x8B\x40\x3C\x3D\x2A\x2A\x2A\x2A\x0F\x85\x2A\x2A\x2A\x2A\x8B\x7E\x1C\x39\xFE\x0F\x84\x2A\x2A\x2A\x2A\x8B\x07\x8B\x40\x3C\x3D\x2A\x2A\x2A\x2A\x0F\x85\x2A\x2A\x2A\x2A\x8B\x47\x1C"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"cstrike"
|
||||
{
|
||||
"Signatures"
|
||||
{
|
||||
"CGameMovement::FullNoClipMove"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x53\x8B\xDC\x83\xEC\x08\x83\xE4\xF0\x83\xC4\x04\x55\x8B\x6B\x04\x89\x6C\x24\x04\x8B\xEC\x83\xEC\x6C\xA1\x2A\x2A\x2A\x2A"
|
||||
"linux" "@_ZN13CGameMovement14FullNoClipMoveEff"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
54
addons/sourcemod/scripting/include/glib/addressutils.inc
Normal file
54
addons/sourcemod/scripting/include/glib/addressutils.inc
Normal file
@ -0,0 +1,54 @@
|
||||
#if defined _addressutils_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _addressutils_included
|
||||
|
||||
methodmap AddressBase
|
||||
{
|
||||
property Address Address
|
||||
{
|
||||
public get() { return view_as<Address>(this); }
|
||||
}
|
||||
}
|
||||
|
||||
//-==Operator overloadings
|
||||
stock Address operator+(Address l, int r)
|
||||
{
|
||||
return l + view_as<Address>(r);
|
||||
}
|
||||
|
||||
stock Address operator+(int l, Address r)
|
||||
{
|
||||
return view_as<Address>(l) + r;
|
||||
}
|
||||
|
||||
stock Address operator-(Address l, int r)
|
||||
{
|
||||
return l - view_as<Address>(r);
|
||||
}
|
||||
|
||||
stock Address operator-(int l, Address r)
|
||||
{
|
||||
return view_as<Address>(l) - r;
|
||||
}
|
||||
|
||||
stock Address operator*(Address l, int r)
|
||||
{
|
||||
return l * view_as<Address>(r);
|
||||
}
|
||||
|
||||
stock Address operator*(int l, Address r)
|
||||
{
|
||||
return view_as<Address>(l) * r;
|
||||
}
|
||||
|
||||
stock Address operator/(Address l, int r)
|
||||
{
|
||||
return l / view_as<Address>(r);
|
||||
}
|
||||
|
||||
stock Address operator/(int l, Address r)
|
||||
{
|
||||
return view_as<Address>(l) / r;
|
||||
}
|
||||
//Operator overloadings==-
|
||||
58
addons/sourcemod/scripting/include/glib/assertutils.inc
Normal file
58
addons/sourcemod/scripting/include/glib/assertutils.inc
Normal file
@ -0,0 +1,58 @@
|
||||
#if defined _assertutils_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _assertutils_included
|
||||
|
||||
/* Compile time settings for this include. Should be defined before including this file.
|
||||
* #define ASSERTUTILS_DISABLE //Disables all assertions
|
||||
* #define ASSERTUTILS_FAILSTATE_FUNC //Define the name of the function that should be called when assertion is hit
|
||||
*/
|
||||
|
||||
#if !defined SNAME
|
||||
#define __SNAME ""
|
||||
#else
|
||||
#define __SNAME SNAME
|
||||
#endif
|
||||
|
||||
#define ASSERT_FMT_STRING_LEN 512
|
||||
|
||||
#if defined ASSERTUTILS_DISABLE
|
||||
|
||||
#define ASSERT(%1)%2;
|
||||
#define ASSERT_MSG(%1,%2)%3;
|
||||
#define ASSERT_FINAL(%1)%2;
|
||||
#define ASSERT_FINAL_MSG(%1,%2)%3;
|
||||
|
||||
#elseif defined ASSERTUTILS_FAILSTATE_FUNC
|
||||
|
||||
#define ASSERT(%1) if(!(%1)) ASSERTUTILS_FAILSTATE_FUNC(__SNAME..."Assertion failed: \""...#%1..."\"")
|
||||
#define ASSERT_MSG(%1,%2) if(!(%1)) ASSERTUTILS_FAILSTATE_FUNC(__SNAME...%2)
|
||||
#define ASSERT_FINAL(%1) if(!(%1)) SetFailState(__SNAME..."Assertion failed: \""...#%1..."\"")
|
||||
#define ASSERT_FINAL_MSG(%1,%2) if(!(%1)) SetFailState(__SNAME...%2)
|
||||
|
||||
#else
|
||||
|
||||
#define ASSERT(%1) if(!(%1)) SetFailState(__SNAME..."Assertion failed: \""...#%1..."\"")
|
||||
#define ASSERT_MSG(%1,%2) if(!(%1)) SetFailState(__SNAME...%2)
|
||||
#define ASSERT_FINAL(%1) ASSERT(%1)
|
||||
#define ASSERT_FINAL_MSG(%1,%2) ASSERT_MSG(%1,%2)
|
||||
|
||||
#endif
|
||||
|
||||
// Might be redundant as default ASSERT_MSG accept format arguments just fine.
|
||||
#if 0
|
||||
stock void ASSERT_FMT(bool result, char[] fmt, any ...)
|
||||
{
|
||||
#if !defined ASSERTUTILS_DISABLE
|
||||
if(!result)
|
||||
{
|
||||
char buff[ASSERT_FMT_STRING_LEN];
|
||||
VFormat(buff, sizeof(buff), fmt, 3);
|
||||
|
||||
SetFailState(__SNAME..."%s", buff);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef ASSERT_FMT_STRING_LEN
|
||||
@ -1,7 +1,9 @@
|
||||
#include "sourcemod"
|
||||
#include "sdktools"
|
||||
#include "dhooks"
|
||||
#include "glib/memutils"
|
||||
|
||||
#include "glib/addressutils"
|
||||
#include "glib/assertutils"
|
||||
|
||||
#define SNAME "[NoclipSpeed] "
|
||||
|
||||
@ -10,7 +12,7 @@ public Plugin myinfo =
|
||||
name = "NoclipSpeed",
|
||||
author = "GAMMA CASE",
|
||||
description = "Let's you change noclip speed.",
|
||||
version = "1.0.0",
|
||||
version = "1.1.1",
|
||||
url = "http://steamcommunity.com/id/_GAMMACASE_/"
|
||||
};
|
||||
|
||||
@ -20,13 +22,13 @@ public Plugin myinfo =
|
||||
#define MAX_EDICT_BITS 11
|
||||
#define MAX_EDICTS (1 << MAX_EDICT_BITS)
|
||||
|
||||
#define NUM_ENT_ENTRY_BITS (MAX_EDICT_BITS + 2)
|
||||
#define NUM_ENT_ENTRY_BITS (MAX_EDICT_BITS + 1)
|
||||
#define NUM_ENT_ENTRIES (1 << NUM_ENT_ENTRY_BITS)
|
||||
#define INVALID_EHANDLE_INDEX 0xFFFFFFFF
|
||||
|
||||
#define NUM_SERIAL_NUM_BITS 16 // (32 - NUM_ENT_ENTRY_BITS)
|
||||
#define NUM_SERIAL_NUM_SHIFT_BITS (32 - NUM_SERIAL_NUM_BITS)
|
||||
#define ENT_ENTRY_MASK (( 1 << NUM_SERIAL_NUM_BITS) - 1)
|
||||
#define ENT_ENTRY_MASK_CSGO (( 1 << NUM_SERIAL_NUM_BITS) - 1)
|
||||
#define ENT_ENTRY_MASK_CSS (NUM_ENT_ENTRIES - 1)
|
||||
|
||||
enum OSType
|
||||
{
|
||||
@ -48,10 +50,14 @@ ConVar sv_maxspeed;
|
||||
ConVar sv_friction;
|
||||
ConVar sv_noclipspeed;
|
||||
|
||||
EngineVersion gEVType;
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
RegConsoleCmd("sm_ns", SM_NoclipSpeed, "Sets noclip speed.");
|
||||
RegConsoleCmd("sm_noclipspeed", SM_NoclipSpeed, "Sets noclip speed.");
|
||||
gEVType = GetEngineVersion();
|
||||
|
||||
RegConsoleCmd("sm_ns", SM_NoclipSpeed, "Sets noclip speed. Can also be used to set or change speed via argument (Examples: sm_ns 1500 or sm_ns +100)");
|
||||
RegConsoleCmd("sm_noclipspeed", SM_NoclipSpeed, "Sets noclip speed. Can also be used to set or change speed via argument (Examples: sm_ns 1500 or sm_ns +100)");
|
||||
|
||||
gMaxAllowedNoclipFactor = CreateConVar("noclipspeed_max_factor", "35", "Max allowed factor for noclip (factor * 300 = speed)", .hasMin = true);
|
||||
|
||||
@ -101,8 +107,16 @@ void SetupDhooks(GameData gd)
|
||||
ASSERT_MSG(DHookSetFromConf(dhook, gd, SDKConf_Signature, "CGameMovement::FullNoClipMove"), "Failed to find \"CGameMovement::FullNoClipMove\" signature.");
|
||||
|
||||
DHookAddParam(dhook, HookParamType_Int, .custom_register = DHookRegister_ECX);
|
||||
DHookAddParam(dhook, HookParamType_Float, .custom_register = DHookRegister_XMM1);
|
||||
DHookAddParam(dhook, HookParamType_Float, .custom_register = DHookRegister_XMM2);
|
||||
if(gEVType == Engine_CSGO)
|
||||
{
|
||||
DHookAddParam(dhook, HookParamType_Float, .custom_register = DHookRegister_XMM1);
|
||||
DHookAddParam(dhook, HookParamType_Float, .custom_register = DHookRegister_XMM2);
|
||||
}
|
||||
else
|
||||
{
|
||||
DHookAddParam(dhook, HookParamType_Float);
|
||||
DHookAddParam(dhook, HookParamType_Float);
|
||||
}
|
||||
|
||||
ASSERT_MSG(DHookEnableDetour(dhook, false, FullNoClipMove_Dhook), "Failed to enable \"CGameMovement::FullNoClipMove\" detour.");
|
||||
}
|
||||
@ -169,7 +183,7 @@ int EntityToBCompatRef(Address player)
|
||||
return INVALID_EHANDLE_INDEX;
|
||||
|
||||
// https://github.com/perilouswithadollarsign/cstrike15_src/blob/29e4c1fda9698d5cebcdaf1a0de4b829fa149bf8/public/basehandle.h#L137
|
||||
int entry_idx = m_RefEHandle & ENT_ENTRY_MASK;
|
||||
int entry_idx = gEVType == Engine_CSGO ? m_RefEHandle & ENT_ENTRY_MASK_CSGO : m_RefEHandle & ENT_ENTRY_MASK_CSS;
|
||||
|
||||
if(entry_idx >= MAX_EDICTS)
|
||||
return m_RefEHandle | (1 << 31);
|
||||
@ -203,11 +217,18 @@ public Action SM_NoclipSpeed(int client, int args)
|
||||
|
||||
float spd = StringToFloat(buff);
|
||||
|
||||
gPlayerNoclipSpeed[client] = Clamp(NoclipUPSToFactor(spd), 0.0, gMaxAllowedNoclipFactor.FloatValue);
|
||||
// NaN check in case of an invalid argument
|
||||
if(spd == 0.0 || spd != spd)
|
||||
{
|
||||
PrintToChat(client, SNAME..."Invalid speed value specified, check your arguments!");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
gPlayerNoclipSpeed[client] = Clamp(buff[0] == '+' || buff[0] == '-' ? gPlayerNoclipSpeed[client] + NoclipUPSToFactor(spd) : NoclipUPSToFactor(spd), 0.0, gMaxAllowedNoclipFactor.FloatValue);
|
||||
Format(buff, sizeof(buff), "%f", gPlayerNoclipSpeed[client]);
|
||||
sv_noclipspeed.ReplicateToClient(client, buff);
|
||||
|
||||
PrintToChat(client, SNAME..."Changed noclip speed to: %.2f u/s", NoclipFactorToUPS(gPlayerNoclipSpeed[client]));
|
||||
PrintToChat(client, SNAME..."Changed noclip speed to: %i u/s", RoundToNearest(NoclipFactorToUPS(gPlayerNoclipSpeed[client])));
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
@ -219,7 +240,7 @@ public int NoclipSpeed_Menu(Menu menu, MenuAction action, int param1, int param2
|
||||
{
|
||||
case MenuAction_Display:
|
||||
{
|
||||
menu.SetTitle("Noclip speed\n \nCurrent speed: %.2f\n ", NoclipFactorToUPS(gPlayerNoclipSpeed[param1]));
|
||||
menu.SetTitle("Noclip speed\n \nCurrent speed: %i\n ", RoundToNearest(NoclipFactorToUPS(gPlayerNoclipSpeed[param1])));
|
||||
}
|
||||
|
||||
case MenuAction_DrawItem:
|
||||
@ -285,4 +306,4 @@ float Clamp(float val, float min, float max)
|
||||
bool CloseEnough(float a, float b, float eps = FLT_EPSILON)
|
||||
{
|
||||
return FloatAbs(a - b) <= eps;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user