Fix all killstreaks (but thermal on ac/cg)

This commit is contained in:
rackover 2021-05-09 01:24:37 +02:00
parent 9f6b5c6214
commit 7f8995cf3e
6 changed files with 60 additions and 6 deletions

View File

@ -546,7 +546,7 @@ namespace Components
{ {
int developer = Dvar::Var("developer").get<int>(); int developer = Dvar::Var("developer").get<int>();
if (developer > 0) if (developer > 0 && Dedicated::IsEnabled())
Utils::Hook::Set<BYTE>(0x48D8C7, 0x75); Utils::Hook::Set<BYTE>(0x48D8C7, 0x75);
}); });

View File

@ -92,8 +92,6 @@ namespace Components
{ {
if (XInput::xiPlayerNum != -1) if (XInput::xiPlayerNum != -1)
{ {
Game::clientActive_t* clientActive = reinterpret_cast<Game::clientActive_t*>(0xB2C698);
XINPUT_STATE* xiState = &xiStates[xiPlayerNum]; XINPUT_STATE* xiState = &xiStates[xiPlayerNum];
// Deadzones // Deadzones
@ -122,11 +120,13 @@ namespace Components
bool pressingRightTrigger = xiState->Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD ? true : false; bool pressingRightTrigger = xiState->Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD ? true : false;
if (pressingRightTrigger != XInput::lastXiState.Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD) if (pressingRightTrigger != XInput::lastXiState.Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD)
{ {
if (pressingRightTrigger) if (pressingRightTrigger) {
Command::Execute("+attack"); Command::Execute("+attack");
else }
else {
Command::Execute("-attack"); Command::Execute("-attack");
} }
}
// Buttons (on/off) mappings // Buttons (on/off) mappings
for (size_t i = 0; i < mappings.size(); i++) for (size_t i = 0; i < mappings.size(); i++)
@ -330,6 +330,29 @@ namespace Components
} }
} }
int XInput::unk_CheckKeyHook(int localClientNum, Game::keyNum_t keyCode) {
if (XInput::xiPlayerNum != -1)
{
XINPUT_STATE* xiState = &xiStates[xiPlayerNum];
if (keyCode == Game::keyNum_t::K_MOUSE2) {
bool pressingLeftTrigger = xiState->Gamepad.bLeftTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD ? true : false;
if (pressingLeftTrigger != XInput::lastXiState.Gamepad.bLeftTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD)
{
if (pressingLeftTrigger) {
return 1;
}
else {
return 0;
}
}
}
}
Utils::Hook::Call<int(int, Game::keyNum_t)>(0x48B2D0)(localClientNum, keyCode);
}
void XInput::MouseOverride(Game::clientActive_t* clientActive, float* mx, float* my) { void XInput::MouseOverride(Game::clientActive_t* clientActive, float* mx, float* my) {
XInput::CL_GetMouseMovementCl(clientActive, mx, my); XInput::CL_GetMouseMovementCl(clientActive, mx, my);
@ -384,6 +407,23 @@ namespace Components
*(my) = viewStickX * viewSensitivityMultiplier * generalXSensitivityMultiplier * adsMultiplier; *(my) = viewStickX * viewSensitivityMultiplier * generalXSensitivityMultiplier * adsMultiplier;
*(mx) = -viewStickY * viewSensitivityMultiplier * generalYSensitivityMultiplier * adsMultiplier; *(mx) = -viewStickY * viewSensitivityMultiplier * generalYSensitivityMultiplier * adsMultiplier;
} }
// Handling killstreaks
bool pressingRightTrigger = xiState->Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD ? true : false;
if (pressingRightTrigger != XInput::lastXiState.Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD)
{
bool* isInPredator = reinterpret_cast<bool*>(0x8EE3B8);
if (pressingRightTrigger) {
Utils::Hook::Set(0xA1C4F4, Game::LOC_SEL_INPUT_CONFIRM);
if (*isInPredator) {
// Yea, that's how we boost
// Command::execute is sync by default so the predator event gets fired properly
Command::Execute("+attack");
Command::Execute("-attack");
}
}
}
} }
} }
@ -443,6 +483,8 @@ namespace Components
Utils::Hook(0x492009, XInput::MSG_ReadDeltaUsercmdKeyStub2, HOOK_JUMP).install()->quick(); Utils::Hook(0x492009, XInput::MSG_ReadDeltaUsercmdKeyStub2, HOOK_JUMP).install()->quick();
Utils::Hook(0x5A617D, CL_GetMouseMovementStub, HOOK_CALL).install()->quick(); Utils::Hook(0x5A617D, CL_GetMouseMovementStub, HOOK_CALL).install()->quick();
Utils::Hook(0x5A6816, CL_GetMouseMovementStub, HOOK_CALL).install()->quick();
Utils::Hook(0x5A6829, unk_CheckKeyHook, HOOK_CALL).install()->quick();
Game::Dvar_RegisterFloat("xpad_sensitivity", 1.0f, 0.1f, 10.0f, Game::DVAR_FLAG_SAVED, "View sensitivity for XInput-compatible gamepads"); Game::Dvar_RegisterFloat("xpad_sensitivity", 1.0f, 0.1f, 10.0f, Game::DVAR_FLAG_SAVED, "View sensitivity for XInput-compatible gamepads");
Game::Dvar_RegisterInt("xpad_early_time", 350, 0, 1000, Game::DVAR_FLAG_SAVED, "Time (in milliseconds) of reduced view sensitivity"); Game::Dvar_RegisterInt("xpad_early_time", 350, 0, 1000, Game::DVAR_FLAG_SAVED, "Time (in milliseconds) of reduced view sensitivity");

View File

@ -49,6 +49,7 @@ namespace Components
static float lastMenuNavigationDirection; static float lastMenuNavigationDirection;
static void CL_GetMouseMovementCl(Game::clientActive_t* result, float* mx, float* my); static void CL_GetMouseMovementCl(Game::clientActive_t* result, float* mx, float* my);
static int unk_CheckKeyHook(int localClientNum, Game::keyNum_t keyCode);
static void MouseOverride(Game::clientActive_t* clientActive, float* my, float* mx); static void MouseOverride(Game::clientActive_t* clientActive, float* my, float* mx);
static char MovementOverride(int a1, Game::usercmd_s* cmd); static char MovementOverride(int a1, Game::usercmd_s* cmd);

View File

@ -148,6 +148,7 @@ namespace Game
Info_ValueForKey_t Info_ValueForKey = Info_ValueForKey_t(0x47C820); Info_ValueForKey_t Info_ValueForKey = Info_ValueForKey_t(0x47C820);
Key_SetCatcher_t Key_SetCatcher = Key_SetCatcher_t(0x43BD00); Key_SetCatcher_t Key_SetCatcher = Key_SetCatcher_t(0x43BD00);
Key_IsKeyCatcherActive_t Key_IsKeyCatcherActive = Key_IsKeyCatcherActive_t(0x4DA010);
LargeLocalInit_t LargeLocalInit = LargeLocalInit_t(0x4A62A0); LargeLocalInit_t LargeLocalInit = LargeLocalInit_t(0x4A62A0);

View File

@ -342,6 +342,9 @@ namespace Game
typedef void(__cdecl * Key_SetCatcher_t)(int localClientNum, int catcher); typedef void(__cdecl * Key_SetCatcher_t)(int localClientNum, int catcher);
extern Key_SetCatcher_t Key_SetCatcher; extern Key_SetCatcher_t Key_SetCatcher;
typedef bool(__cdecl* Key_IsKeyCatcherActive_t)(int localClientNum, int catcher);
extern Key_IsKeyCatcherActive_t Key_IsKeyCatcherActive;
typedef void(__cdecl * LargeLocalInit_t)(); typedef void(__cdecl * LargeLocalInit_t)();
extern LargeLocalInit_t LargeLocalInit; extern LargeLocalInit_t LargeLocalInit;

View File

@ -1097,6 +1097,13 @@ namespace Game
int stunTime; int stunTime;
}; };
enum LocSelInputState
{
LOC_SEL_INPUT_NONE = 0x0,
LOC_SEL_INPUT_CONFIRM = 0x1,
LOC_SEL_INPUT_CANCEL = 0x2,
};
struct clSnapshot_t struct clSnapshot_t
{ {
playerState_s ps; playerState_s ps;