diff --git a/src/Components/Modules/XInput.cpp b/src/Components/Modules/XInput.cpp index 307208f2..4e0a21a4 100644 --- a/src/Components/Modules/XInput.cpp +++ b/src/Components/Modules/XInput.cpp @@ -7,10 +7,12 @@ namespace Components int XInput::xiPlayerNum = -1; std::chrono::milliseconds XInput::timeAtFirstHeldMaxLookX = 0ms; // "For how much time in miliseconds has the player been holding a horizontal direction on their stick, fully" (-1.0 or 1.0) bool XInput::isHoldingMaxLookX = false; + bool XInput::isADS; float XInput::lockedSensitivityMultiplier = 0.45f; float XInput::generalXSensitivityMultiplier = 3 * 1.5f; float XInput::generalYSensitivityMultiplier = 4 * 0.8f; + float XInput::adsMultiplier = 0.3f; float XInput::lastMenuNavigationDirection = .0f; std::chrono::milliseconds XInput::lastNavigationTime = 0ms; @@ -18,8 +20,6 @@ namespace Components std::chrono::milliseconds XInput::msBeforeUnlockingSensitivity = 350ms; - float sensitivityMultiplier = 1.0f; - std::vector mappings = { XInput::ActionMapping(XINPUT_GAMEPAD_A, "gostand"), XInput::ActionMapping(XINPUT_GAMEPAD_B, "stance"), @@ -97,6 +97,8 @@ namespace Components { if (XInput::xiPlayerNum != -1) { + Game::clientActive_t* clientActive = reinterpret_cast(0xB2C698); + XINPUT_STATE* xiState = &xiStates[xiPlayerNum]; // Deadzones @@ -113,12 +115,12 @@ namespace Components if (pressingLeftTrigger != XInput::lastXiState.Gamepad.bLeftTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD) { if (pressingLeftTrigger) { - Command::Execute("+toggleads_throw"); - Command::Execute("+speed"); + Command::Execute("+speed_throw"); + XInput::isADS = true; } else { - Command::Execute("-toggleads_throw"); - Command::Execute("-speed"); + Command::Execute("-speed_throw"); + XInput::isADS = false; } } @@ -368,9 +370,18 @@ namespace Components XInput::timeAtFirstHeldMaxLookX = 0ms; } + float adsMultiplier = 1.0f; + + auto ps = &clientActive->snap.ps; + + // DO NOT use clientActive->usingAds ! It only works for toggle ADS + if (Game::PM_IsAdsAllowed(ps) && XInput::isADS) { + adsMultiplier = XInput::adsMultiplier; + } + if (viewStickX != 0 || viewStickY != 0) { - *(my) = viewStickX * viewSensitivityMultiplier * generalXSensitivityMultiplier; - *(mx) = -viewStickY * viewSensitivityMultiplier * generalYSensitivityMultiplier; + *(my) = viewStickX * viewSensitivityMultiplier * generalXSensitivityMultiplier * adsMultiplier; + *(mx) = -viewStickY * viewSensitivityMultiplier * generalYSensitivityMultiplier * adsMultiplier; } } diff --git a/src/Components/Modules/XInput.hpp b/src/Components/Modules/XInput.hpp index b1969b8f..9525f9b8 100644 --- a/src/Components/Modules/XInput.hpp +++ b/src/Components/Modules/XInput.hpp @@ -46,6 +46,8 @@ namespace Components static float lockedSensitivityMultiplier; static float generalXSensitivityMultiplier; static float generalYSensitivityMultiplier; + static float adsMultiplier; + static bool isADS; static std::chrono::milliseconds lastNavigationTime; static std::chrono::milliseconds msBetweenNavigations; diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index eeffd563..228af09e 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -970,6 +970,21 @@ namespace Game } } + bool PM_IsAdsAllowed(Game::playerState_s* playerState) + { + bool result; + + __asm + { + mov esi, playerState + mov ebx, 0x5755A0 + call ebx + mov result, al // AL + } + + return result; + } + __declspec(naked) void FS_AddLocalizedGameDirectory(const char* /*path*/, const char* /*dir*/) { __asm diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 23cb11fb..958fd661 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -900,6 +900,8 @@ namespace Game void FS_AddLocalizedGameDirectory(const char *path, const char *dir); + bool PM_IsAdsAllowed(Game::playerState_s* playerState); + void ShowMessageBox(const std::string& message, const std::string& title); unsigned int R_HashString(const char* string); diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index b9f1e2e6..632729d7 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -111,6 +111,39 @@ namespace Game IMG_CATEGORY_TEMP = 0x7, } ; + enum buttons_t + { + KB_LEFT = 0x0, + KB_RIGHT = 0x1, + KB_FORWARD = 0x2, + KB_BACK = 0x3, + KB_LOOKUP = 0x4, + KB_LOOKDOWN = 0x5, + KB_MOVELEFT = 0x6, + KB_MOVERIGHT = 0x7, + KB_STRAFE = 0x8, + KB_SPEED = 0x9, + KB_UP = 0xA, + KB_DOWN = 0xB, + KB_ANYUP = 0xC, + KB_MLOOK = 0xD, + KB_ATTACK = 0xE, + KB_BREATH = 0xF, + KB_FRAG = 0x10, + KB_OFFHANDSECONDARY = 0x11, + KB_MELEE = 0x12, + KB_ACTIVATE = 0x13, + KB_RELOAD = 0x14, + KB_USE_RELOAD = 0x15, + KB_PRONE = 0x16, + KB_CROUCH = 0x17, + KB_THROW = 0x18, + KB_SPRINT = 0x19, + KB_NIGHTVISION = 0x1A, + KB_TALK = 0x1B, + NUM_BUTTONS = 0x1C + }; + enum DvarSetSource { DVAR_SOURCE_INTERNAL = 0x0,