diff --git a/src/core/features/autohop.cpp b/src/core/features/autohop.cpp index 60190e24..a83fc876 100644 --- a/src/core/features/autohop.cpp +++ b/src/core/features/autohop.cpp @@ -1,9 +1,11 @@ #include "features.hpp" void Features::AutoHop::createMove(CUserCmd* cmd) { - if (Globals::localPlayer) { + if (Globals::localPlayer) { // Using bhop and jumpbug causes jumpbug to not work if (CONFIGBOOL("Misc>Misc>Movement>Auto Hop")) { if (Globals::localPlayer->moveType() == 9) return; + if (CONFIGBOOL("Misc>Misc>Movement>Jump Bug") && + Menu::CustomWidgets::isKeyDown(CONFIGINT("Misc>Misc>Movement>Jump Bug Key"))) return; if (CONFIGBOOL("Misc>Misc>Movement>Humanised Bhop")) { // https://www.unknowncheats.me/forum/counterstrike-global-offensive/333797-humanised-bhop.html static int hopsRestricted = 0; @@ -25,8 +27,8 @@ void Features::AutoHop::createMove(CUserCmd* cmd) { } } else { - if (!(Globals::localPlayer->flags() & (1<<0))) { // need to make macro for FL_* - cmd->buttons &= ~(1<<1); // need to make macro for IN_* + if (!(Globals::localPlayer->flags() & FL_ONGROUND)) { + cmd->buttons &= ~IN_JUMP; } } } diff --git a/src/core/features/edgejump.cpp b/src/core/features/edgejump.cpp index 5ee3be4d..27fc678a 100644 --- a/src/core/features/edgejump.cpp +++ b/src/core/features/edgejump.cpp @@ -1,20 +1,18 @@ #include "../../includes.hpp" #include "features.hpp" -int flagsBackup = 0; - void Features::EdgeJump::prePredCreateMove(CUserCmd* cmd) { if (Globals::localPlayer) flagsBackup = Globals::localPlayer->flags(); } void Features::EdgeJump::postPredCreateMove(CUserCmd* cmd) { - if (CONFIGBOOL("Misc>Misc>Movement>Edge Jump") && - Menu::CustomWidgets::isKeyDown(CONFIGINT("Misc>Misc>Movement>Edge Jump Key")) && - Globals::localPlayer && - Globals::localPlayer->moveType() != MOVETYPE_LADDER && - Globals::localPlayer->moveType() != MOVETYPE_NOCLIP && - flagsBackup & FL_ONGROUND && + if (CONFIGBOOL("Misc>Misc>Movement>Edge Jump") && + Menu::CustomWidgets::isKeyDown(CONFIGINT("Misc>Misc>Movement>Edge Jump Key")) && + Globals::localPlayer && + Globals::localPlayer->moveType() != MOVETYPE_LADDER && + Globals::localPlayer->moveType() != MOVETYPE_NOCLIP && + flagsBackup & FL_ONGROUND && !(Globals::localPlayer->flags() & FL_ONGROUND)) cmd->buttons |= IN_JUMP; } diff --git a/src/core/features/features.hpp b/src/core/features/features.hpp index fe69a06e..278b8d1f 100644 --- a/src/core/features/features.hpp +++ b/src/core/features/features.hpp @@ -134,5 +134,9 @@ namespace Features { namespace EdgeJump { void prePredCreateMove(CUserCmd* cmd); void postPredCreateMove(CUserCmd* cmd); + inline int flagsBackup; + } + namespace JumpBug { + void createMove(CUserCmd* cmd); } } diff --git a/src/core/features/jumpbug.cpp b/src/core/features/jumpbug.cpp new file mode 100644 index 00000000..af731662 --- /dev/null +++ b/src/core/features/jumpbug.cpp @@ -0,0 +1,15 @@ +#include "../../includes.hpp" +#include "features.hpp" + +void Features::JumpBug::createMove(CUserCmd* cmd) { + if (CONFIGBOOL("Misc>Misc>Movement>Jump Bug") && + Interfaces::inputSystem->IsButtonDown(KEY_SPACE) && + Menu::CustomWidgets::isKeyDown(CONFIGINT("Misc>Misc>Movement>Jump Bug Key")) && + Globals::localPlayer->moveType() != MOVETYPE_LADDER && + Globals::localPlayer->moveType() != MOVETYPE_NOCLIP && + (Globals::localPlayer->flags() & FL_ONGROUND || Globals::localPlayer->flags() & FL_PARTIALGROUND) && + !(Features::EdgeJump::flagsBackup & FL_ONGROUND || Features::EdgeJump::flagsBackup & FL_PARTIALGROUND)) { + cmd->buttons |= IN_DUCK; + cmd->buttons &= ~IN_JUMP; + } +} diff --git a/src/core/hooks/createmove.cpp b/src/core/hooks/createmove.cpp index bc86b26d..ab7c9d88 100644 --- a/src/core/hooks/createmove.cpp +++ b/src/core/hooks/createmove.cpp @@ -38,6 +38,7 @@ bool Hooks::CreateMove::hook(void* thisptr, float flInputSampleTime, CUserCmd* c Features::Backtrack::createMove(cmd); Features::Forwardtrack::createMove(cmd); } + Features::JumpBug::createMove(cmd); Features::Prediction::end(); Features::EdgeJump::postPredCreateMove(cmd); diff --git a/src/core/menu/config.hpp b/src/core/menu/config.hpp index c3d3ac8f..8ed2c6f5 100644 --- a/src/core/menu/config.hpp +++ b/src/core/menu/config.hpp @@ -322,6 +322,8 @@ namespace Config { CONFIGITEM("Misc>Misc>Movement>Bhop Max Hops Hit", 0), CONFIGITEM("Misc>Misc>Movement>Edge Jump", false), CONFIGITEM("Misc>Misc>Movement>Edge Jump Key", 0), + CONFIGITEM("Misc>Misc>Movement>Jump Bug", false), + CONFIGITEM("Misc>Misc>Movement>Jump Bug Key", 0), CONFIGITEM("Misc>Misc>Movement>Fast Duck", false), CONFIGITEM("Misc>Misc>Hitmarkers>Hitlogs", false), diff --git a/src/core/menu/tabs/misc.cpp b/src/core/menu/tabs/misc.cpp index 2fa58f8f..35d0b569 100644 --- a/src/core/menu/tabs/misc.cpp +++ b/src/core/menu/tabs/misc.cpp @@ -113,6 +113,12 @@ void Menu::drawMiscTab() { ImGui::SameLine(); } ImGui::Checkbox("Edge Jump", &CONFIGBOOL("Misc>Misc>Movement>Edge Jump")); + if (CONFIGBOOL("Misc>Misc>Movement>Jump Bug")) { + static bool toggled = false; + Menu::CustomWidgets::drawKeyBinder("Key", &CONFIGINT("Misc>Misc>Movement>Jump Bug Key"), &toggled); + ImGui::SameLine(); + } + ImGui::Checkbox("Jump Bug", &CONFIGBOOL("Misc>Misc>Movement>Jump Bug")); ImGui::Checkbox("Fast Duck", &CONFIGBOOL("Misc>Misc>Movement>Fast Duck")); ImGui::SameLine(); ImGui::TextDisabled("?"); diff --git a/src/sdk/definitions.hpp b/src/sdk/definitions.hpp index bc3389a1..d037615a 100644 --- a/src/sdk/definitions.hpp +++ b/src/sdk/definitions.hpp @@ -511,34 +511,7 @@ enum MoveType_t #define FL_FAKECLIENT (1<<8) // Fake client, simulated server side; don't send network messages to them // NON-PLAYER SPECIFIC (i.e., not used by GameMovement or the client .dll ) -- Can still be applied to players, though #define FL_INWATER (1<<9) // In water - -#define IN_ATTACK (1 << 0) -#define IN_JUMP (1 << 1) -#define IN_DUCK (1 << 2) -#define IN_FORWARD (1 << 3) -#define IN_BACK (1 << 4) -#define IN_USE (1 << 5) -#define IN_CANCEL (1 << 6) -#define IN_LEFT (1 << 7) -#define IN_RIGHT (1 << 8) -#define IN_MOVELEFT (1 << 9) -#define IN_MOVERIGHT (1 << 10) -#define IN_ATTACK2 (1 << 11) -#define IN_RUN (1 << 12) -#define IN_RELOAD (1 << 13) -#define IN_ALT1 (1 << 14) -#define IN_ALT2 (1 << 15) -#define IN_SCORE (1 << 16) -#define IN_SPEED (1 << 17) -#define IN_WALK (1 << 18) -#define IN_ZOOM (1 << 19) -#define IN_WEAPON1 (1 << 20) -#define IN_WEAPON2 (1 << 21) -#define IN_BULLRUSH (1 << 22) -#define IN_GRENADE1 (1 << 23) -#define IN_GRENADE2 (1 << 24) -#define IN_ATTACK3 (1 << 25) - +#define FL_PARTIALGROUND (1<<17) // Not all parts of the player are on ground // Fuzion class AnimState { diff --git a/src/sdk/interfaces/iappsystem.hpp b/src/sdk/interfaces/iappsystem.hpp new file mode 100644 index 00000000..17e9fb17 --- /dev/null +++ b/src/sdk/interfaces/iappsystem.hpp @@ -0,0 +1,57 @@ +#pragma once + +struct AppSystemInfo_t +{ + const char* m_pModuleName; + const char* m_pInterfaceName; +}; + +enum InitReturnVal_t +{ + INIT_FAILED = 0, + INIT_OK, + + INIT_LAST_VAL, +}; + +enum AppSystemTier_t +{ + APP_SYSTEM_TIER0 = 0, + APP_SYSTEM_TIER1, + APP_SYSTEM_TIER2, + APP_SYSTEM_TIER3, + + APP_SYSTEM_TIER_OTHER, +}; + +typedef void* (*CreateInterfaceFn) (const char*, int*); + +class IAppSystem +{ +public: + // Here's where the app systems get to learn about each other + virtual bool Connect(CreateInterfaceFn factory) = 0; + + virtual void Disconnect() = 0; + + // Here's where systems can access other interfaces implemented by this object + // Returns nullptr if it doesn't implement the requested interface + virtual void* QueryInterface(const char* pInterfaceName) = 0; + + // Init, shutdown + virtual InitReturnVal_t Init() = 0; + + virtual void Shutdown() = 0; + + // Returns all dependent libraries + virtual const AppSystemInfo_t* GetDependencies() = 0; + + // Returns the tier + virtual AppSystemTier_t GetTier() = 0; + + // Reconnect to a particular interface + virtual void Reconnect(CreateInterfaceFn factory, const char* pInterfaceName) = 0; + + // Returns whether or not the app system is a singleton + virtual bool IsSingleton() = 0; +}; diff --git a/src/sdk/interfaces/iinputsystem.hpp b/src/sdk/interfaces/iinputsystem.hpp new file mode 100644 index 00000000..ba513438 --- /dev/null +++ b/src/sdk/interfaces/iinputsystem.hpp @@ -0,0 +1,299 @@ +#pragma once + +#include "iappsystem.hpp" +#include "../../utils/utils.hpp" + +#define MAX_SPLITSCREEN_CLIENT_BITS 2 +// this should == MAX_JOYSTICKS in InputEnums.h +#define MAX_SPLITSCREEN_CLIENTS ( 1 << MAX_SPLITSCREEN_CLIENT_BITS ) // 4 + +#define JOYSTICK_BUTTON_INTERNAL( _joystick, _button ) ( JOYSTICK_FIRST_BUTTON + ((_joystick) * JOYSTICK_MAX_BUTTON_COUNT) + (_button) ) +#define JOYSTICK_POV_BUTTON_INTERNAL( _joystick, _button ) ( JOYSTICK_FIRST_POV_BUTTON + ((_joystick) * JOYSTICK_POV_BUTTON_COUNT) + (_button) ) +#define JOYSTICK_AXIS_BUTTON_INTERNAL( _joystick, _button ) ( JOYSTICK_FIRST_AXIS_BUTTON + ((_joystick) * JOYSTICK_AXIS_BUTTON_COUNT) + (_button) ) + +#define JOYSTICK_BUTTON( _joystick, _button ) ( (ButtonCode_t)JOYSTICK_BUTTON_INTERNAL( _joystick, _button ) ) +#define JOYSTICK_POV_BUTTON( _joystick, _button ) ( (ButtonCode_t)JOYSTICK_POV_BUTTON_INTERNAL( _joystick, _button ) ) +#define JOYSTICK_AXIS_BUTTON( _joystick, _button ) ( (ButtonCode_t)JOYSTICK_AXIS_BUTTON_INTERNAL( _joystick, _button ) ) + +#define IN_ATTACK (1 << 0) +#define IN_JUMP (1 << 1) +#define IN_DUCK (1 << 2) +#define IN_FORWARD (1 << 3) +#define IN_BACK (1 << 4) +#define IN_USE (1 << 5) +#define IN_CANCEL (1 << 6) +#define IN_LEFT (1 << 7) +#define IN_RIGHT (1 << 8) +#define IN_MOVELEFT (1 << 9) +#define IN_MOVERIGHT (1 << 10) +#define IN_ATTACK2 (1 << 11) +#define IN_RUN (1 << 12) +#define IN_RELOAD (1 << 13) +#define IN_ALT1 (1 << 14) +#define IN_ALT2 (1 << 15) +#define IN_SCORE (1 << 16) +#define IN_SPEED (1 << 17) +#define IN_WALK (1 << 18) +#define IN_ZOOM (1 << 19) +#define IN_WEAPON1 (1 << 20) +#define IN_WEAPON2 (1 << 21) +#define IN_BULLRUSH (1 << 22) +#define IN_GRENADE1 (1 << 23) +#define IN_GRENADE2 (1 << 24) +#define IN_ATTACK3 (1 << 25) + +enum +{ + MAX_JOYSTICKS = MAX_SPLITSCREEN_CLIENTS, + MOUSE_BUTTON_COUNT = 5, +}; + +enum JoystickAxis_t +{ + JOY_AXIS_X = 0, + JOY_AXIS_Y, + JOY_AXIS_Z, + JOY_AXIS_R, + JOY_AXIS_U, + JOY_AXIS_V, + MAX_JOYSTICK_AXES, +}; + +enum +{ + JOYSTICK_MAX_BUTTON_COUNT = 32, + JOYSTICK_POV_BUTTON_COUNT = 4, + JOYSTICK_AXIS_BUTTON_COUNT = MAX_JOYSTICK_AXES * 2, +}; + +enum ButtonCode_t +{ + BUTTON_CODE_INVALID = -1, + BUTTON_CODE_NONE = 0, + + KEY_FIRST = 0, + + KEY_NONE = KEY_FIRST, + KEY_0, + KEY_1, + KEY_2, + KEY_3, + KEY_4, + KEY_5, + KEY_6, + KEY_7, + KEY_8, + KEY_9, + KEY_A, + KEY_B, + KEY_C, + KEY_D, + KEY_E, + KEY_F, + KEY_G, + KEY_H, + KEY_I, + KEY_J, + KEY_K, + KEY_L, + KEY_M, + KEY_N, + KEY_O, + KEY_P, + KEY_Q, + KEY_R, + KEY_S, + KEY_T, + KEY_U, + KEY_V, + KEY_W, + KEY_X, + KEY_Y, + KEY_Z, + KEY_PAD_0, + KEY_PAD_1, + KEY_PAD_2, + KEY_PAD_3, + KEY_PAD_4, + KEY_PAD_5, + KEY_PAD_6, + KEY_PAD_7, + KEY_PAD_8, + KEY_PAD_9, + KEY_PAD_DIVIDE, + KEY_PAD_MULTIPLY, + KEY_PAD_MINUS, + KEY_PAD_PLUS, + KEY_PAD_ENTER, + KEY_PAD_DECIMAL, + KEY_LBRACKET, + KEY_RBRACKET, + KEY_SEMICOLON, + KEY_APOSTROPHE, + KEY_BACKQUOTE, + KEY_COMMA, + KEY_PERIOD, + KEY_SLASH, + KEY_BACKSLASH, + KEY_MINUS, + KEY_EQUAL, + KEY_ENTER, + KEY_SPACE, + KEY_BACKSPACE, + KEY_TAB, + KEY_CAPSLOCK, + KEY_NUMLOCK, + KEY_ESCAPE, + KEY_SCROLLLOCK, + KEY_INSERT, + KEY_DELETE, + KEY_HOME, + KEY_END, + KEY_PAGEUP, + KEY_PAGEDOWN, + KEY_BREAK, + KEY_LSHIFT, + KEY_RSHIFT, + KEY_LALT, + KEY_RALT, + KEY_LCONTROL, + KEY_RCONTROL, + KEY_LWIN, + KEY_RWIN, + KEY_APP, + KEY_UP, + KEY_LEFT, + KEY_DOWN, + KEY_RIGHT, + KEY_F1, + KEY_F2, + KEY_F3, + KEY_F4, + KEY_F5, + KEY_F6, + KEY_F7, + KEY_F8, + KEY_F9, + KEY_F10, + KEY_F11, + KEY_F12, + KEY_CAPSLOCKTOGGLE, + KEY_NUMLOCKTOGGLE, + KEY_SCROLLLOCKTOGGLE, + + KEY_LAST = KEY_SCROLLLOCKTOGGLE, + KEY_COUNT = KEY_LAST - KEY_FIRST + 1, + + // Mouse + MOUSE_FIRST = KEY_LAST + 1, + + MOUSE_LEFT = MOUSE_FIRST, + MOUSE_RIGHT, + MOUSE_MIDDLE, + MOUSE_4, + MOUSE_5, + MOUSE_WHEEL_UP, // A fake button which is 'pressed' and 'released' when the wheel is moved up + MOUSE_WHEEL_DOWN, // A fake button which is 'pressed' and 'released' when the wheel is moved down + + MOUSE_LAST = MOUSE_WHEEL_DOWN, + MOUSE_COUNT = MOUSE_LAST - MOUSE_FIRST + 1, + + // Joystick + JOYSTICK_FIRST = MOUSE_LAST + 1, + + JOYSTICK_FIRST_BUTTON = JOYSTICK_FIRST, + JOYSTICK_LAST_BUTTON = JOYSTICK_BUTTON_INTERNAL( MAX_JOYSTICKS - 1, JOYSTICK_MAX_BUTTON_COUNT - 1 ), + JOYSTICK_FIRST_POV_BUTTON, + JOYSTICK_LAST_POV_BUTTON = JOYSTICK_POV_BUTTON_INTERNAL( MAX_JOYSTICKS - 1, JOYSTICK_POV_BUTTON_COUNT - 1 ), + JOYSTICK_FIRST_AXIS_BUTTON, + JOYSTICK_LAST_AXIS_BUTTON = JOYSTICK_AXIS_BUTTON_INTERNAL( MAX_JOYSTICKS - 1, JOYSTICK_AXIS_BUTTON_COUNT - 1 ), + + JOYSTICK_LAST = JOYSTICK_LAST_AXIS_BUTTON, + + BUTTON_CODE_LAST, + BUTTON_CODE_COUNT = BUTTON_CODE_LAST - KEY_FIRST + 1, + + // Helpers for XBox 360 + KEY_XBUTTON_UP = JOYSTICK_FIRST_POV_BUTTON, // POV buttons + KEY_XBUTTON_RIGHT, + KEY_XBUTTON_DOWN, + KEY_XBUTTON_LEFT, + + KEY_XBUTTON_A = JOYSTICK_FIRST_BUTTON, // Buttons + KEY_XBUTTON_B, + KEY_XBUTTON_X, + KEY_XBUTTON_Y, + KEY_XBUTTON_LEFT_SHOULDER, + KEY_XBUTTON_RIGHT_SHOULDER, + KEY_XBUTTON_BACK, + KEY_XBUTTON_START, + KEY_XBUTTON_STICK1, + KEY_XBUTTON_STICK2, + KEY_XBUTTON_INACTIVE_START, + + KEY_XSTICK1_RIGHT = JOYSTICK_FIRST_AXIS_BUTTON, // XAXIS POSITIVE + KEY_XSTICK1_LEFT, // XAXIS NEGATIVE + KEY_XSTICK1_DOWN, // YAXIS POSITIVE + KEY_XSTICK1_UP, // YAXIS NEGATIVE + KEY_XBUTTON_LTRIGGER, // ZAXIS POSITIVE + KEY_XBUTTON_RTRIGGER, // ZAXIS NEGATIVE + KEY_XSTICK2_RIGHT, // UAXIS POSITIVE + KEY_XSTICK2_LEFT, // UAXIS NEGATIVE + KEY_XSTICK2_DOWN, // VAXIS POSITIVE + KEY_XSTICK2_UP, // VAXIS NEGATIVE +}; + +enum MouseCodeState_t +{ + BUTTON_RELEASED = 0, + BUTTON_PRESSED, + BUTTON_DOUBLECLICKED, +}; + +class IInputSystem : public IAppSystem +{ +public: + void EnableInput(bool bEnable) + { + typedef void (*Fn)(void*, bool); + return getVirtualFunc(this, 11)(this, bEnable); + } + + bool IsButtonDown(ButtonCode_t code) + { + typedef bool (*Fn)(void*, ButtonCode_t); + return getVirtualFunc(this, 15)(this, code); + } + + void ResetInputState() + { + typedef void (*Fn)(void*); + return getVirtualFunc(this, 39)(this); + } + + const char* ButtonCodeToString(ButtonCode_t code) + { + typedef const char* (*Fn)(void*, ButtonCode_t); + return getVirtualFunc(this, 40)(this, code); + } + + ButtonCode_t VirtualKeyToButtonCode(int nVirtualKey) + { + typedef ButtonCode_t (*Fn)(void*, int); + return getVirtualFunc(this, 44)(this, nVirtualKey); + } + + int ButtonCodeToVirtualKey(ButtonCode_t code) + { + typedef int (*Fn)(void*, ButtonCode_t); + return getVirtualFunc(this, 45)(this, code); + } + + void GetCursorPosition(int* m_pX, int* m_pY) + { + typedef void (*Fn)(void*, int*, int*); + return getVirtualFunc(this, 56)(this, m_pX, m_pY); + } +}; + +class IInputInternal; diff --git a/src/sdk/interfaces/interfaces.cpp b/src/sdk/interfaces/interfaces.cpp index 8531d267..da999bf1 100644 --- a/src/sdk/interfaces/interfaces.cpp +++ b/src/sdk/interfaces/interfaces.cpp @@ -30,6 +30,7 @@ bool Interfaces::init() { movement = getInterface("./csgo/bin/linux64/client_client.so", "GameMovement"); prediction = getInterface("./csgo/bin/linux64/client_client.so", "VClientPrediction001", true); eventManager = getInterface("./bin/linux64/engine_client.so", "GAMEEVENTSMANAGER002", true); + inputSystem = getInterface("./bin/linux64/inputsystem_client.so", "InputSystemVersion"); /* Get IClientMode */ uintptr_t HudProcessInput = reinterpret_cast(getVTable(client)[10]); @@ -64,4 +65,4 @@ bool Interfaces::unload() { Log::log(LOG, "Unloaded interfaces!"); return true; -} \ No newline at end of file +} diff --git a/src/sdk/interfaces/interfaces.hpp b/src/sdk/interfaces/interfaces.hpp index d03d4dbe..c44d4f36 100644 --- a/src/sdk/interfaces/interfaces.hpp +++ b/src/sdk/interfaces/interfaces.hpp @@ -19,6 +19,7 @@ #include "igameevent.hpp" #include "playerResource.hpp" #include "icvar.hpp" +#include "iinputsystem.hpp" #include "iclientmode.hpp" #include "globalvars.hpp" @@ -45,6 +46,7 @@ namespace Interfaces { inline IPrediction* prediction; inline IGameEventManager2* eventManager; inline ICvar* convar; + inline IInputSystem* inputSystem; inline IClientMode* clientMode; inline CGlobalVars* globals; @@ -71,7 +73,7 @@ namespace Interfaces { // loop through each interface in interfaceReg linked list for (InterfaceReg* cur = interfaceReg; cur; cur = cur->m_pNext) { // If current interface equals input name without the 3 version numbers so if an interface version changes we dont have to care - if ((strstr(cur->m_pName, name) && strlen(cur->m_pName)-3 == strlen(name)) || + if ((strstr(cur->m_pName, name) && strlen(cur->m_pName)-3 == strlen(name)) || (includeVersion && (strstr(cur->m_pName, name) && strlen(cur->m_pName) == strlen(name)))) { T* iface = reinterpret_cast(cur->m_CreateFn()); Log::log(LOG, " %s (%s) %lx", name, cur->m_pName, (uintptr_t)iface); @@ -83,4 +85,4 @@ namespace Interfaces { dlclose(lib); return nullptr; } -} \ No newline at end of file +}