Add turnrates for controllers
This commit is contained in:
parent
ac1ade1976
commit
e49e17d6e6
@ -140,6 +140,9 @@ namespace Game
|
|||||||
AimAssistGlobals* aaGlobArray = reinterpret_cast<AimAssistGlobals*>(0x7A2110);
|
AimAssistGlobals* aaGlobArray = reinterpret_cast<AimAssistGlobals*>(0x7A2110);
|
||||||
keyname_t* vanillaKeyNames = reinterpret_cast<keyname_t*>(0x798580);
|
keyname_t* vanillaKeyNames = reinterpret_cast<keyname_t*>(0x798580);
|
||||||
keyname_t* vanillaLocalizedKeyNames = reinterpret_cast<keyname_t*>(0x798880);
|
keyname_t* vanillaLocalizedKeyNames = reinterpret_cast<keyname_t*>(0x798880);
|
||||||
|
|
||||||
|
constexpr auto VANILLA_AIM_ASSIST_GRAPH_COUNT = 4u;
|
||||||
|
GraphFloat* aaInputGraph = reinterpret_cast<GraphFloat*>(0x7A2FC0);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
@ -168,6 +171,15 @@ namespace Components
|
|||||||
Dvar::Var Gamepad::gpad_button_rstick_deflect_max;
|
Dvar::Var Gamepad::gpad_button_rstick_deflect_max;
|
||||||
Dvar::Var Gamepad::gpad_button_lstick_deflect_max;
|
Dvar::Var Gamepad::gpad_button_lstick_deflect_max;
|
||||||
Dvar::Var Gamepad::input_viewSensitivity;
|
Dvar::Var Gamepad::input_viewSensitivity;
|
||||||
|
Dvar::Var Gamepad::aim_turnrate_pitch;
|
||||||
|
Dvar::Var Gamepad::aim_turnrate_pitch_ads;
|
||||||
|
Dvar::Var Gamepad::aim_turnrate_yaw;
|
||||||
|
Dvar::Var Gamepad::aim_turnrate_yaw_ads;
|
||||||
|
Dvar::Var Gamepad::aim_accel_turnrate_enabled;
|
||||||
|
Dvar::Var Gamepad::aim_accel_turnrate_lerp;
|
||||||
|
Dvar::Var Gamepad::aim_input_graph_enabled;
|
||||||
|
Dvar::Var Gamepad::aim_input_graph_index;
|
||||||
|
Dvar::Var Gamepad::aim_scale_view_axis;
|
||||||
|
|
||||||
Dvar::Var Gamepad::xpadSensitivity;
|
Dvar::Var Gamepad::xpadSensitivity;
|
||||||
Dvar::Var Gamepad::xpadEarlyTime;
|
Dvar::Var Gamepad::xpadEarlyTime;
|
||||||
@ -322,11 +334,167 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Gamepad::Key_IsValidGamePadChar(const int key)
|
float Gamepad::LinearTrack(const float target, const float current, const float rate, const float deltaTime)
|
||||||
{
|
{
|
||||||
return key >= Game::K_FIRSTGAMEPADBUTTON_RANGE_1 && key <= Game::K_LASTGAMEPADBUTTON_RANGE_1
|
const auto err = target - current;
|
||||||
|| key >= Game::K_FIRSTGAMEPADBUTTON_RANGE_2 && key <= Game::K_LASTGAMEPADBUTTON_RANGE_2
|
float step;
|
||||||
|| key >= Game::K_FIRSTGAMEPADBUTTON_RANGE_3 && key <= Game::K_LASTGAMEPADBUTTON_RANGE_3;
|
if(err <= 0.0f)
|
||||||
|
step = -rate * deltaTime;
|
||||||
|
else
|
||||||
|
step = rate * deltaTime;
|
||||||
|
|
||||||
|
if(std::fabs(err) <= 0.001f)
|
||||||
|
return target;
|
||||||
|
|
||||||
|
if (std::fabs(step) <= std::fabs(err))
|
||||||
|
return current + step;
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gamepad::AimAssist_CalcAdjustedAxis(const Game::AimInput* input, float* pitchAxis, float* yawAxis)
|
||||||
|
{
|
||||||
|
assert(input);
|
||||||
|
assert(pitchAxis);
|
||||||
|
assert(yawAxis);
|
||||||
|
|
||||||
|
const auto graphIndex = aim_input_graph_index.get<int>();
|
||||||
|
if(aim_input_graph_enabled.get<bool>() && graphIndex >= 0 && graphIndex < Game::VANILLA_AIM_ASSIST_GRAPH_COUNT)
|
||||||
|
{
|
||||||
|
const auto deflection = std::sqrt(input->pitchAxis * input->pitchAxis + input->yawAxis * input->yawAxis);
|
||||||
|
|
||||||
|
float fraction;
|
||||||
|
if (deflection - 1.0f < 0.0f)
|
||||||
|
fraction = deflection;
|
||||||
|
else
|
||||||
|
fraction = 1.0f;
|
||||||
|
|
||||||
|
if (0.0f - deflection >= 0.0f)
|
||||||
|
fraction = 0.0f;
|
||||||
|
|
||||||
|
const auto graphScale = Game::GraphFloat_GetValue(&Game::aaInputGraph[graphIndex], fraction);
|
||||||
|
*pitchAxis = input->pitchAxis * graphScale;
|
||||||
|
*yawAxis = input->yawAxis * graphScale;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*pitchAxis = input->pitchAxis;
|
||||||
|
*yawAxis = input->yawAxis;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(aim_scale_view_axis.get<bool>())
|
||||||
|
{
|
||||||
|
const auto absPitchAxis = std::fabs(*pitchAxis);
|
||||||
|
const auto absYawAxis = std::fabs(*yawAxis);
|
||||||
|
|
||||||
|
if (absPitchAxis <= absYawAxis)
|
||||||
|
*pitchAxis = (1.0f - (absYawAxis - absPitchAxis)) * *pitchAxis;
|
||||||
|
else
|
||||||
|
*yawAxis = (1.0f - (absPitchAxis - absYawAxis)) * *yawAxis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gamepad::AimAssist_CalcSlowdown(const Game::AimInput* /*input*/, float* pitchScale, float* yawScale)
|
||||||
|
{
|
||||||
|
/*assert(input); */
|
||||||
|
assert(pitchScale);
|
||||||
|
assert(yawScale);
|
||||||
|
|
||||||
|
*pitchScale = 1.0f;
|
||||||
|
*yawScale = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Gamepad::AimAssist_Lerp(const float from, const float to, const float fraction)
|
||||||
|
{
|
||||||
|
return (to - from) * fraction + from;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gamepad::AimAssist_ApplyTurnRates(const Game::AimInput* input, Game::AimOutput* output)
|
||||||
|
{
|
||||||
|
assert(input->localClientNum < Game::MAX_GAMEPADS);
|
||||||
|
auto& aaGlob = Game::aaGlobArray[input->localClientNum];
|
||||||
|
|
||||||
|
auto slowdownPitchScale = 0.0f;
|
||||||
|
auto slowdownYawScale = 0.0f;
|
||||||
|
float adjustedPitchAxis;
|
||||||
|
float adjustedYawAxis;
|
||||||
|
|
||||||
|
if(aaGlob.autoMeleeState == Game::AIM_MELEE_STATE_UPDATING)
|
||||||
|
{
|
||||||
|
adjustedPitchAxis = 0.0f;
|
||||||
|
adjustedYawAxis = 0.0f;
|
||||||
|
slowdownPitchScale = 1.0f;
|
||||||
|
slowdownYawScale = 1.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AimAssist_CalcAdjustedAxis(input, &adjustedPitchAxis, &adjustedYawAxis);
|
||||||
|
AimAssist_CalcSlowdown(input, &slowdownPitchScale, &slowdownYawScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto sensitivity = input_viewSensitivity.get<float>();
|
||||||
|
auto pitchTurnRate = AimAssist_Lerp(aim_turnrate_pitch.get<float>(), aim_turnrate_pitch_ads.get<float>(), aaGlob.adsLerp);
|
||||||
|
pitchTurnRate = slowdownPitchScale * aaGlob.fovTurnRateScale * sensitivity * pitchTurnRate;
|
||||||
|
auto yawTurnRate = AimAssist_Lerp(aim_turnrate_yaw.get<float>(), aim_turnrate_yaw_ads.get<float>(), aaGlob.adsLerp);
|
||||||
|
yawTurnRate = slowdownYawScale * aaGlob.fovTurnRateScale * sensitivity * yawTurnRate;
|
||||||
|
|
||||||
|
if (input->pitchMax > 0 && input->pitchMax < pitchTurnRate)
|
||||||
|
pitchTurnRate = input->pitchMax;
|
||||||
|
if (input->yawMax > 0 && input->yawMax < yawTurnRate)
|
||||||
|
yawTurnRate = input->yawMax;
|
||||||
|
|
||||||
|
const auto pitchSign = adjustedPitchAxis >= 0.0f ? 1.0f : -1.0f;
|
||||||
|
const auto yawSign = adjustedYawAxis >= 0.0f ? 1.0f : -1.0f;
|
||||||
|
|
||||||
|
const auto pitchDelta = std::fabs(adjustedPitchAxis) * pitchTurnRate;
|
||||||
|
const auto yawDelta = std::fabs(adjustedYawAxis) * yawTurnRate;
|
||||||
|
|
||||||
|
if(!aim_accel_turnrate_enabled.get<bool>())
|
||||||
|
{
|
||||||
|
aaGlob.pitchDelta = pitchDelta;
|
||||||
|
aaGlob.yawDelta = yawDelta;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto accel = aim_accel_turnrate_lerp.get<float>() * sensitivity;
|
||||||
|
if (pitchDelta <= aaGlob.pitchDelta)
|
||||||
|
aaGlob.pitchDelta = pitchDelta;
|
||||||
|
else
|
||||||
|
aaGlob.pitchDelta = LinearTrack(pitchDelta, aaGlob.pitchDelta, accel, input->deltaTime);
|
||||||
|
|
||||||
|
if (yawDelta <= aaGlob.yawDelta)
|
||||||
|
aaGlob.yawDelta = yawDelta;
|
||||||
|
else
|
||||||
|
aaGlob.yawDelta = LinearTrack(yawDelta, aaGlob.yawDelta, accel, input->deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
output->pitch = aaGlob.pitchDelta * input->deltaTime * pitchSign + output->pitch;
|
||||||
|
output->yaw = aaGlob.yawDelta * input->deltaTime * yawSign + output->yaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gamepad::AimAssist_UpdateGamePadInput(const Game::AimInput* input, Game::AimOutput* output)
|
||||||
|
{
|
||||||
|
assert(input->localClientNum < Game::MAX_GAMEPADS);
|
||||||
|
auto& aaGlob = Game::aaGlobArray[input->localClientNum];
|
||||||
|
|
||||||
|
output->pitch = input->pitch;
|
||||||
|
output->yaw = input->yaw;
|
||||||
|
|
||||||
|
if(aaGlob.initialized)
|
||||||
|
{
|
||||||
|
Game::AimAssist_UpdateTweakables(input->localClientNum);
|
||||||
|
Game::AimAssist_UpdateAdsLerp(input);
|
||||||
|
AimAssist_ApplyTurnRates(input, output);
|
||||||
|
|
||||||
|
Game::AimAssist_ApplyAutoAim(input, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
aaGlob.prevButtons = input->buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Gamepad::CG_ShouldUpdateViewAngles(const int localClientNum)
|
||||||
|
{
|
||||||
|
return !Game::Key_IsKeyCatcherActive(localClientNum, Game::KEYCATCH_MASK_ANY) || Game::UI_GetActiveMenu(localClientNum) == Game::UIMENU_SCOREBOARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Gamepad::CL_GamepadAxisValue(const int gamePadIndex, const Game::GamepadVirtualAxis virtualAxis)
|
float Gamepad::CL_GamepadAxisValue(const int gamePadIndex, const Game::GamepadVirtualAxis virtualAxis)
|
||||||
@ -367,7 +535,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
assert(gamePadIndex < Game::MAX_GAMEPADS);
|
assert(gamePadIndex < Game::MAX_GAMEPADS);
|
||||||
auto& gamePad = gamePads[gamePadIndex];
|
auto& gamePad = gamePads[gamePadIndex];
|
||||||
auto& gamePadGlobal = gamePadGlobals[gamePadIndex];
|
auto& clientActive = Game::clients[gamePadIndex];
|
||||||
|
|
||||||
if (!gpad_enabled.get<bool>() || !gamePad.enabled)
|
if (!gpad_enabled.get<bool>() || !gamePad.enabled)
|
||||||
return;
|
return;
|
||||||
@ -379,7 +547,7 @@ namespace Components
|
|||||||
auto yaw = -CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_YAW);
|
auto yaw = -CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_YAW);
|
||||||
auto forward = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_FORWARD);
|
auto forward = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_FORWARD);
|
||||||
auto side = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_SIDE);
|
auto side = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_SIDE);
|
||||||
auto attack = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_ATTACK);
|
//auto attack = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_ATTACK);
|
||||||
auto moveScale = static_cast<float>(std::numeric_limits<char>::max());
|
auto moveScale = static_cast<float>(std::numeric_limits<char>::max());
|
||||||
|
|
||||||
if (std::fabs(side) > 0.0f || std::fabs(forward) > 0.0f)
|
if (std::fabs(side) > 0.0f || std::fabs(forward) > 0.0f)
|
||||||
@ -393,21 +561,32 @@ namespace Components
|
|||||||
const auto forwardMove = static_cast<int>(std::floor(forward * moveScale));
|
const auto forwardMove = static_cast<int>(std::floor(forward * moveScale));
|
||||||
const auto rightMove = static_cast<int>(std::floor(side * moveScale));
|
const auto rightMove = static_cast<int>(std::floor(side * moveScale));
|
||||||
|
|
||||||
const auto sensitivity = input_viewSensitivity.get<float>();
|
|
||||||
pitch *= sensitivity;
|
|
||||||
yaw *= sensitivity;
|
|
||||||
|
|
||||||
if (Game::clients[0].cgameMaxPitchSpeed > 0 && Game::clients[0].cgameMaxPitchSpeed < std::fabs(pitch))
|
|
||||||
pitch = std::signbit(pitch) ? -Game::clients[0].cgameMaxPitchSpeed : Game::clients[0].cgameMaxPitchSpeed;
|
|
||||||
if (Game::clients[0].cgameMaxYawSpeed > 0 && Game::clients[0].cgameMaxYawSpeed < std::fabs(yaw))
|
|
||||||
yaw = std::signbit(yaw) ? -Game::clients[0].cgameMaxYawSpeed : Game::clients[0].cgameMaxYawSpeed;
|
|
||||||
|
|
||||||
|
|
||||||
Game::clients[0].clViewangles[0] += pitch;
|
|
||||||
Game::clients[0].clViewangles[1] += yaw;
|
|
||||||
|
|
||||||
cmd->rightmove = ClampChar(cmd->rightmove + rightMove);
|
cmd->rightmove = ClampChar(cmd->rightmove + rightMove);
|
||||||
cmd->forwardmove = ClampChar(cmd->forwardmove + forwardMove);
|
cmd->forwardmove = ClampChar(cmd->forwardmove + forwardMove);
|
||||||
|
|
||||||
|
// Check for frozen controls. Flag name should start with PMF_
|
||||||
|
if(CG_ShouldUpdateViewAngles(gamePadIndex) && (clientActive.snap.ps.pm_flags & 0x800) == 0)
|
||||||
|
{
|
||||||
|
Game::AimInput aimInput{};
|
||||||
|
Game::AimOutput aimOutput{};
|
||||||
|
aimInput.deltaTime = frame_time_base;
|
||||||
|
aimInput.buttons = cmd->buttons;
|
||||||
|
aimInput.localClientNum = gamePadIndex;
|
||||||
|
aimInput.deltaTimeScaled = static_cast<float>(Game::cls->frametime) * 0.001f;
|
||||||
|
aimInput.pitch = clientActive.clViewangles[0];
|
||||||
|
aimInput.pitchAxis = pitch;
|
||||||
|
aimInput.pitchMax = clientActive.cgameMaxPitchSpeed;
|
||||||
|
aimInput.yaw = clientActive.clViewangles[1];
|
||||||
|
aimInput.yawAxis = yaw;
|
||||||
|
aimInput.yawMax = clientActive.cgameMaxYawSpeed;
|
||||||
|
aimInput.forwardAxis = forward;
|
||||||
|
aimInput.rightAxis = side;
|
||||||
|
AimAssist_UpdateGamePadInput(&aimInput, &aimOutput);
|
||||||
|
clientActive.clViewangles[0] = aimOutput.pitch;
|
||||||
|
clientActive.clViewangles[1] = aimOutput.yaw;
|
||||||
|
cmd->meleeChargeDist = aimOutput.meleeChargeDist;
|
||||||
|
cmd->meleeChargeYaw = aimOutput.meleeChargeYaw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto CL_MouseMove = 0x5A6240;
|
constexpr auto CL_MouseMove = 0x5A6240;
|
||||||
@ -433,6 +612,12 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Gamepad::Key_IsValidGamePadChar(const int key)
|
||||||
|
{
|
||||||
|
return key >= Game::K_FIRSTGAMEPADBUTTON_RANGE_1 && key <= Game::K_LASTGAMEPADBUTTON_RANGE_1
|
||||||
|
|| key >= Game::K_FIRSTGAMEPADBUTTON_RANGE_2 && key <= Game::K_LASTGAMEPADBUTTON_RANGE_2
|
||||||
|
|| key >= Game::K_FIRSTGAMEPADBUTTON_RANGE_3 && key <= Game::K_LASTGAMEPADBUTTON_RANGE_3;
|
||||||
|
}
|
||||||
|
|
||||||
void Gamepad::CL_GamepadResetMenuScrollTime(const int gamePadIndex, const int key, const bool down, const unsigned time)
|
void Gamepad::CL_GamepadResetMenuScrollTime(const int gamePadIndex, const int key, const bool down, const unsigned time)
|
||||||
{
|
{
|
||||||
@ -1135,13 +1320,13 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gamepad::Bind_GP_SticksConfigs_f(Command::Params* params)
|
void Gamepad::Bind_GP_SticksConfigs_f(Command::Params*)
|
||||||
{
|
{
|
||||||
const auto* stickConfigName = gpad_sticksConfig.get<const char*>();
|
const auto* stickConfigName = gpad_sticksConfig.get<const char*>();
|
||||||
Game::Cbuf_AddText(0, Utils::String::VA("exec %s\n", stickConfigName));
|
Game::Cbuf_AddText(0, Utils::String::VA("exec %s\n", stickConfigName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gamepad::Bind_GP_ButtonsConfigs_f(Command::Params* params)
|
void Gamepad::Bind_GP_ButtonsConfigs_f(Command::Params*)
|
||||||
{
|
{
|
||||||
const auto* buttonConfigName = gpad_buttonConfig.get<const char*>();
|
const auto* buttonConfigName = gpad_buttonConfig.get<const char*>();
|
||||||
Game::Cbuf_AddText(0, Utils::String::VA("exec %s\n", buttonConfigName));
|
Game::Cbuf_AddText(0, Utils::String::VA("exec %s\n", buttonConfigName));
|
||||||
@ -1169,6 +1354,15 @@ namespace Components
|
|||||||
gpad_button_rstick_deflect_max = Dvar::Register<float>("gpad_button_rstick_deflect_max", 1.0f, 0.0f, 1.0f, 0, "Game pad maximum pad stick pressed value");
|
gpad_button_rstick_deflect_max = Dvar::Register<float>("gpad_button_rstick_deflect_max", 1.0f, 0.0f, 1.0f, 0, "Game pad maximum pad stick pressed value");
|
||||||
|
|
||||||
input_viewSensitivity = Dvar::Register<float>("input_viewSensitivity", 1.0f, 0.0001f, 5.0f, Game::DVAR_FLAG_SAVED, "View Sensitivity");
|
input_viewSensitivity = Dvar::Register<float>("input_viewSensitivity", 1.0f, 0.0001f, 5.0f, Game::DVAR_FLAG_SAVED, "View Sensitivity");
|
||||||
|
aim_turnrate_pitch = Dvar::Var("aim_turnrate_pitch");
|
||||||
|
aim_turnrate_pitch_ads = Dvar::Var("aim_turnrate_pitch_ads");
|
||||||
|
aim_turnrate_yaw = Dvar::Var("aim_turnrate_yaw");
|
||||||
|
aim_turnrate_yaw_ads = Dvar::Var("aim_turnrate_yaw_ads");
|
||||||
|
aim_accel_turnrate_enabled = Dvar::Var("aim_accel_turnrate_enabled");
|
||||||
|
aim_accel_turnrate_lerp = Dvar::Var("aim_accel_turnrate_lerp");
|
||||||
|
aim_input_graph_enabled = Dvar::Var("aim_input_graph_enabled");
|
||||||
|
aim_input_graph_index = Dvar::Var("aim_input_graph_index");
|
||||||
|
aim_scale_view_axis = Dvar::Var("aim_scale_view_axis");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gamepad::IN_Init_Hk()
|
void Gamepad::IN_Init_Hk()
|
||||||
|
@ -160,11 +160,14 @@ namespace Game
|
|||||||
AIM_MELEE_STATE_TARGETED = 0x1,
|
AIM_MELEE_STATE_TARGETED = 0x1,
|
||||||
AIM_MELEE_STATE_UPDATING = 0x2,
|
AIM_MELEE_STATE_UPDATING = 0x2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable: 4324)
|
||||||
struct __declspec(align(16)) AimAssistGlobals
|
struct __declspec(align(16)) AimAssistGlobals
|
||||||
{
|
{
|
||||||
AimAssistPlayerState ps;
|
AimAssistPlayerState ps;
|
||||||
__declspec(align(8)) float screenMtx[4][4];
|
char _pad1[4];
|
||||||
|
float screenMtx[4][4];
|
||||||
float invScreenMtx[4][4];
|
float invScreenMtx[4][4];
|
||||||
bool initialized;
|
bool initialized;
|
||||||
int prevButtons;
|
int prevButtons;
|
||||||
@ -197,6 +200,7 @@ namespace Game
|
|||||||
float autoMeleeYawTarget;
|
float autoMeleeYawTarget;
|
||||||
int lockOnTargetEnt;
|
int lockOnTargetEnt;
|
||||||
};
|
};
|
||||||
|
#pragma warning(pop)
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
@ -271,6 +275,11 @@ namespace Components
|
|||||||
static Dvar::Var aim_turnrate_pitch_ads;
|
static Dvar::Var aim_turnrate_pitch_ads;
|
||||||
static Dvar::Var aim_turnrate_yaw;
|
static Dvar::Var aim_turnrate_yaw;
|
||||||
static Dvar::Var aim_turnrate_yaw_ads;
|
static Dvar::Var aim_turnrate_yaw_ads;
|
||||||
|
static Dvar::Var aim_accel_turnrate_enabled;
|
||||||
|
static Dvar::Var aim_accel_turnrate_lerp;
|
||||||
|
static Dvar::Var aim_input_graph_enabled;
|
||||||
|
static Dvar::Var aim_input_graph_index;
|
||||||
|
static Dvar::Var aim_scale_view_axis;
|
||||||
|
|
||||||
static Dvar::Var xpadSensitivity;
|
static Dvar::Var xpadSensitivity;
|
||||||
static Dvar::Var xpadEarlyTime;
|
static Dvar::Var xpadEarlyTime;
|
||||||
@ -286,13 +295,20 @@ namespace Components
|
|||||||
static void MSG_ReadDeltaUsercmdKeyStub();
|
static void MSG_ReadDeltaUsercmdKeyStub();
|
||||||
static void MSG_ReadDeltaUsercmdKeyStub2();
|
static void MSG_ReadDeltaUsercmdKeyStub2();
|
||||||
|
|
||||||
static bool Key_IsValidGamePadChar(int key);
|
static float LinearTrack(float target, float current, float rate, float deltaTime);
|
||||||
|
static void AimAssist_CalcAdjustedAxis(const Game::AimInput* input, float* pitchAxis, float* yawAxis);
|
||||||
|
static void AimAssist_CalcSlowdown(const Game::AimInput* input, float* pitchScale, float* yawScale);
|
||||||
|
static float AimAssist_Lerp(float from, float to, float fraction);
|
||||||
|
static void AimAssist_ApplyTurnRates(const Game::AimInput* input, Game::AimOutput* output);
|
||||||
|
static void AimAssist_UpdateGamePadInput(const Game::AimInput* input, Game::AimOutput* output);
|
||||||
|
|
||||||
|
static bool CG_ShouldUpdateViewAngles(int localClientNum);
|
||||||
static float CL_GamepadAxisValue(int gamePadIndex, Game::GamepadVirtualAxis virtualAxis);
|
static float CL_GamepadAxisValue(int gamePadIndex, Game::GamepadVirtualAxis virtualAxis);
|
||||||
static char ClampChar(int value);
|
static char ClampChar(int value);
|
||||||
static void CL_GamepadMove(int gamePadIndex, Game::usercmd_s* cmd, float frame_time_base);
|
static void CL_GamepadMove(int gamePadIndex, Game::usercmd_s* cmd, float frame_time_base);
|
||||||
static void CL_MouseMove_Stub();
|
static void CL_MouseMove_Stub();
|
||||||
|
|
||||||
|
static bool Key_IsValidGamePadChar(int key);
|
||||||
static void CL_GamepadResetMenuScrollTime(int gamePadIndex, int key, bool down, unsigned int time);
|
static void CL_GamepadResetMenuScrollTime(int gamePadIndex, int key, bool down, unsigned int time);
|
||||||
static bool CL_CheckForIgnoreDueToRepeat(int gamePadIndex, int key, int repeatCount, unsigned int time);
|
static bool CL_CheckForIgnoreDueToRepeat(int gamePadIndex, int key, int repeatCount, unsigned int time);
|
||||||
static void UI_GamepadKeyEvent(int gamePadIndex, int key, bool down);
|
static void UI_GamepadKeyEvent(int gamePadIndex, int key, bool down);
|
||||||
|
@ -325,6 +325,7 @@ namespace Game
|
|||||||
TeleportPlayer_t TeleportPlayer = TeleportPlayer_t(0x496850);
|
TeleportPlayer_t TeleportPlayer = TeleportPlayer_t(0x496850);
|
||||||
|
|
||||||
UI_AddMenuList_t UI_AddMenuList = UI_AddMenuList_t(0x4533C0);
|
UI_AddMenuList_t UI_AddMenuList = UI_AddMenuList_t(0x4533C0);
|
||||||
|
UI_GetActiveMenu_t UI_GetActiveMenu = UI_GetActiveMenu_t(0x4BE790);
|
||||||
UI_CheckStringTranslation_t UI_CheckStringTranslation = UI_CheckStringTranslation_t(0x4FB010);
|
UI_CheckStringTranslation_t UI_CheckStringTranslation = UI_CheckStringTranslation_t(0x4FB010);
|
||||||
UI_LoadMenus_t UI_LoadMenus = UI_LoadMenus_t(0x641460);
|
UI_LoadMenus_t UI_LoadMenus = UI_LoadMenus_t(0x641460);
|
||||||
UI_UpdateArenas_t UI_UpdateArenas = UI_UpdateArenas_t(0x4A95B0);
|
UI_UpdateArenas_t UI_UpdateArenas = UI_UpdateArenas_t(0x4A95B0);
|
||||||
@ -341,6 +342,8 @@ namespace Game
|
|||||||
|
|
||||||
unzClose_t unzClose = unzClose_t(0x41BF20);
|
unzClose_t unzClose = unzClose_t(0x41BF20);
|
||||||
|
|
||||||
|
AimAssist_ApplyAutoAim_t AimAssist_ApplyAutoAim = AimAssist_ApplyAutoAim_t(0x56A360);
|
||||||
|
|
||||||
XAssetHeader* DB_XAssetPool = reinterpret_cast<XAssetHeader*>(0x7998A8);
|
XAssetHeader* DB_XAssetPool = reinterpret_cast<XAssetHeader*>(0x7998A8);
|
||||||
unsigned int* g_poolSize = reinterpret_cast<unsigned int*>(0x7995E8);
|
unsigned int* g_poolSize = reinterpret_cast<unsigned int*>(0x7995E8);
|
||||||
|
|
||||||
@ -434,6 +437,10 @@ namespace Game
|
|||||||
|
|
||||||
GfxScene* scene = reinterpret_cast<GfxScene*>(0x6944914);
|
GfxScene* scene = reinterpret_cast<GfxScene*>(0x6944914);
|
||||||
|
|
||||||
|
clientActive_t* clients = reinterpret_cast<clientActive_t*>(0xB2C698);
|
||||||
|
|
||||||
|
clientStatic_t* cls = reinterpret_cast<clientStatic_t*>(0xA7FE90);
|
||||||
|
|
||||||
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize)
|
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize)
|
||||||
{
|
{
|
||||||
int elSize = DB_GetXAssetSizeHandlers[type]();
|
int elSize = DB_GetXAssetSizeHandlers[type]();
|
||||||
@ -920,7 +927,25 @@ namespace Game
|
|||||||
Game::R_AddDebugLine(color, v[3], v[7]);
|
Game::R_AddDebugLine(color, v[3], v[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GraphGetValueFromFraction(const int knotCount, const float(*knots)[2], const float fraction)
|
||||||
|
{
|
||||||
|
for (auto knotIndex = 1; knotIndex < knotCount; ++knotIndex)
|
||||||
|
{
|
||||||
|
if (knots[knotIndex][0] >= fraction)
|
||||||
|
{
|
||||||
|
const auto adjustedFraction = (fraction - knots[knotIndex - 1][0]) / (knots[knotIndex][0] - knots[knotIndex - 1][0]);
|
||||||
|
|
||||||
|
return (knots[knotIndex][1] - knots[knotIndex - 1][1]) * adjustedFraction + knots[knotIndex - 1][1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GraphFloat_GetValue(const GraphFloat* graph, const float fraction)
|
||||||
|
{
|
||||||
|
return GraphGetValueFromFraction(graph->knotCount, graph->knots, fraction) * graph->scale;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma optimize("", off)
|
#pragma optimize("", off)
|
||||||
__declspec(naked) float UI_GetScoreboardLeft(void* /*a1*/)
|
__declspec(naked) float UI_GetScoreboardLeft(void* /*a1*/)
|
||||||
@ -1278,7 +1303,29 @@ namespace Game
|
|||||||
retn
|
retn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma optimize("", on)
|
|
||||||
|
|
||||||
clientActive_t* clients = reinterpret_cast<clientActive_t*>(0xB2C698);
|
__declspec(naked) void AimAssist_UpdateTweakables(int /*localClientNum*/)
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax,[esp+0x4]
|
||||||
|
mov ebx,0x569950
|
||||||
|
call ebx
|
||||||
|
retn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(naked) void AimAssist_UpdateAdsLerp(const AimInput* /*aimInput*/)
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, [esp + 0x4]
|
||||||
|
mov ebx, 0x569AA0
|
||||||
|
call ebx
|
||||||
|
retn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma optimize("", on)
|
||||||
}
|
}
|
||||||
|
@ -767,6 +767,9 @@ namespace Game
|
|||||||
|
|
||||||
typedef void(__cdecl * UI_AddMenuList_t)(UiContext *dc, MenuList *menuList, int close);
|
typedef void(__cdecl * UI_AddMenuList_t)(UiContext *dc, MenuList *menuList, int close);
|
||||||
extern UI_AddMenuList_t UI_AddMenuList;
|
extern UI_AddMenuList_t UI_AddMenuList;
|
||||||
|
|
||||||
|
typedef uiMenuCommand_t(__cdecl* UI_GetActiveMenu_t)(int localClientNum);
|
||||||
|
extern UI_GetActiveMenu_t UI_GetActiveMenu;
|
||||||
|
|
||||||
typedef char* (__cdecl * UI_CheckStringTranslation_t)(char*, char*);
|
typedef char* (__cdecl * UI_CheckStringTranslation_t)(char*, char*);
|
||||||
extern UI_CheckStringTranslation_t UI_CheckStringTranslation;
|
extern UI_CheckStringTranslation_t UI_CheckStringTranslation;
|
||||||
@ -801,6 +804,9 @@ namespace Game
|
|||||||
typedef void(__cdecl * unzClose_t)(void* handle);
|
typedef void(__cdecl * unzClose_t)(void* handle);
|
||||||
extern unzClose_t unzClose;
|
extern unzClose_t unzClose;
|
||||||
|
|
||||||
|
typedef void(__cdecl* AimAssist_ApplyAutoAim_t)(const AimInput* input, AimOutput* output);
|
||||||
|
extern AimAssist_ApplyAutoAim_t AimAssist_ApplyAutoAim;
|
||||||
|
|
||||||
extern XAssetHeader* DB_XAssetPool;
|
extern XAssetHeader* DB_XAssetPool;
|
||||||
extern unsigned int* g_poolSize;
|
extern unsigned int* g_poolSize;
|
||||||
|
|
||||||
@ -893,6 +899,10 @@ namespace Game
|
|||||||
|
|
||||||
extern GfxScene* scene;
|
extern GfxScene* scene;
|
||||||
|
|
||||||
|
extern clientActive_t* clients;
|
||||||
|
|
||||||
|
extern clientStatic_t* cls;
|
||||||
|
|
||||||
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize);
|
XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize);
|
||||||
void Menu_FreeItemMemory(Game::itemDef_s* item);
|
void Menu_FreeItemMemory(Game::itemDef_s* item);
|
||||||
void Menu_SetNextCursorItem(Game::UiContext* ctx, Game::menuDef_t* currentMenu, int unk = 1);
|
void Menu_SetNextCursorItem(Game::UiContext* ctx, Game::menuDef_t* currentMenu, int unk = 1);
|
||||||
@ -955,7 +965,11 @@ namespace Game
|
|||||||
void R_AddDebugBounds(float* color, Bounds* b);
|
void R_AddDebugBounds(float* color, Bounds* b);
|
||||||
void R_AddDebugBounds(float* color, Bounds* b, const float(*quat)[4]);
|
void R_AddDebugBounds(float* color, Bounds* b, const float(*quat)[4]);
|
||||||
|
|
||||||
|
float GraphGetValueFromFraction(int knotCount, const float(*knots)[2], float fraction);
|
||||||
|
float GraphFloat_GetValue(const GraphFloat* graph, const float fraction);
|
||||||
|
|
||||||
Glyph* R_GetCharacterGlyph(Font_s* font, unsigned int letter);
|
Glyph* R_GetCharacterGlyph(Font_s* font, unsigned int letter);
|
||||||
|
|
||||||
extern clientActive_t* clients;
|
void AimAssist_UpdateTweakables(int localClientNum);
|
||||||
|
void AimAssist_UpdateAdsLerp(const AimInput* input);
|
||||||
}
|
}
|
||||||
|
@ -208,6 +208,7 @@ namespace Game
|
|||||||
|
|
||||||
enum KeyCatch_t
|
enum KeyCatch_t
|
||||||
{
|
{
|
||||||
|
KEYCATCH_MASK_ANY = -1,
|
||||||
KEYCATCH_CONSOLE = 0x1,
|
KEYCATCH_CONSOLE = 0x1,
|
||||||
KEYCATCH_UNKNOWN2 = 0x2,
|
KEYCATCH_UNKNOWN2 = 0x2,
|
||||||
KEYCATCH_UNKNOWN4 = 0x4,
|
KEYCATCH_UNKNOWN4 = 0x4,
|
||||||
@ -357,6 +358,22 @@ namespace Game
|
|||||||
K_LAST_KEY = 0xDF,
|
K_LAST_KEY = 0xDF,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum uiMenuCommand_t
|
||||||
|
{
|
||||||
|
UIMENU_NONE = 0x0,
|
||||||
|
UIMENU_MAIN = 0x1,
|
||||||
|
UIMENU_INGAME = 0x2,
|
||||||
|
UIMENU_PREGAME = 0x3,
|
||||||
|
UIMENU_POSTGAME = 0x4,
|
||||||
|
UIMENU_SCRIPT_POPUP = 0x5,
|
||||||
|
UIMENU_SCOREBOARD = 0x6,
|
||||||
|
UIMENU_PARTY = 0x7,
|
||||||
|
UIMENU_GAMELOBBY = 0x8,
|
||||||
|
UIMENU_PRIVATELOBBY = 0x9,
|
||||||
|
UIMENU_ENDOFGAME = 0xA,
|
||||||
|
UIMENU_MIGRATION = 0xB,
|
||||||
|
};
|
||||||
|
|
||||||
struct __declspec(align(4)) PhysPreset
|
struct __declspec(align(4)) PhysPreset
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -1020,6 +1037,20 @@ namespace Game
|
|||||||
hudelem_s archival[31];
|
hudelem_s archival[31];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum pmtype_t
|
||||||
|
{
|
||||||
|
PM_NORMAL = 0x0,
|
||||||
|
PM_NORMAL_LINKED = 0x1,
|
||||||
|
PM_NOCLIP = 0x2,
|
||||||
|
PM_UFO = 0x3,
|
||||||
|
PM_MPVIEWER = 0x4,
|
||||||
|
PM_SPECTATOR = 0x5,
|
||||||
|
PM_INTERMISSION = 0x6,
|
||||||
|
PM_LASTSTAND = 0x7,
|
||||||
|
PM_DEAD = 0x8,
|
||||||
|
PM_DEAD_LINKED = 0x9,
|
||||||
|
};
|
||||||
|
|
||||||
struct playerState_s
|
struct playerState_s
|
||||||
{
|
{
|
||||||
int commandTime;
|
int commandTime;
|
||||||
@ -5962,6 +5993,154 @@ namespace Game
|
|||||||
int allowAddDObj;
|
int allowAddDObj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct AimInput
|
||||||
|
{
|
||||||
|
float deltaTime;
|
||||||
|
float deltaTimeScaled;
|
||||||
|
float pitch;
|
||||||
|
float pitchAxis;
|
||||||
|
float pitchMax;
|
||||||
|
float yaw;
|
||||||
|
float yawAxis;
|
||||||
|
float yawMax;
|
||||||
|
float forwardAxis;
|
||||||
|
float rightAxis;
|
||||||
|
int buttons;
|
||||||
|
int localClientNum;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AimOutput
|
||||||
|
{
|
||||||
|
float pitch;
|
||||||
|
float yaw;
|
||||||
|
float meleeChargeYaw;
|
||||||
|
char meleeChargeDist;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct clientLogo_t
|
||||||
|
{
|
||||||
|
int startTime;
|
||||||
|
int duration;
|
||||||
|
int fadein;
|
||||||
|
int fadeout;
|
||||||
|
Material* material[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct vidConfig_t
|
||||||
|
{
|
||||||
|
unsigned int sceneWidth;
|
||||||
|
unsigned int sceneHeight;
|
||||||
|
unsigned int displayWidth;
|
||||||
|
unsigned int displayHeight;
|
||||||
|
unsigned int displayFrequency;
|
||||||
|
int isFullscreen;
|
||||||
|
float aspectRatioWindow;
|
||||||
|
float aspectRatioScenePixel;
|
||||||
|
float aspectRatioDisplayPixel;
|
||||||
|
unsigned int maxTextureSize;
|
||||||
|
unsigned int maxTextureMaps;
|
||||||
|
bool deviceSupportsGamma;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct trDebugLine_t
|
||||||
|
{
|
||||||
|
float start[3];
|
||||||
|
float end[3];
|
||||||
|
float color[4];
|
||||||
|
int depthTest;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct trDebugString_t
|
||||||
|
{
|
||||||
|
float xyz[3];
|
||||||
|
float color[4];
|
||||||
|
float scale;
|
||||||
|
char text[96];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct clientDebugStringInfo_t
|
||||||
|
{
|
||||||
|
int max;
|
||||||
|
int num;
|
||||||
|
trDebugString_t* strings;
|
||||||
|
int* durations;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct clientDebugLineInfo_t
|
||||||
|
{
|
||||||
|
int max;
|
||||||
|
int num;
|
||||||
|
trDebugLine_t* lines;
|
||||||
|
int* durations;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct clientDebug_t
|
||||||
|
{
|
||||||
|
int prevFromServer;
|
||||||
|
int fromServer;
|
||||||
|
clientDebugStringInfo_t clStrings;
|
||||||
|
clientDebugStringInfo_t svStringsBuffer;
|
||||||
|
clientDebugStringInfo_t svStrings;
|
||||||
|
clientDebugLineInfo_t clLines;
|
||||||
|
clientDebugLineInfo_t svLinesBuffer;
|
||||||
|
clientDebugLineInfo_t svLines;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ClientMatchData
|
||||||
|
{
|
||||||
|
char def[64];
|
||||||
|
char data[1024];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct clientStatic_t
|
||||||
|
{
|
||||||
|
int quit;
|
||||||
|
int hunkUsersStarted;
|
||||||
|
char servername[256];
|
||||||
|
int rendererStarted;
|
||||||
|
int soundStarted;
|
||||||
|
int uiStarted;
|
||||||
|
int frametime;
|
||||||
|
float frametime_base;
|
||||||
|
int realtime;
|
||||||
|
bool gpuSyncedPrevFrame;
|
||||||
|
bool inputUpdatedPrevFrame;
|
||||||
|
clientLogo_t logo;
|
||||||
|
float mapCenter[3];
|
||||||
|
int lastServerPinged;
|
||||||
|
int pingedServerCount;
|
||||||
|
int totalServersParsed;
|
||||||
|
int pingUpdateSource;
|
||||||
|
Material* whiteMaterial;
|
||||||
|
Material* consoleMaterial;
|
||||||
|
Font_s* consoleFont;
|
||||||
|
vidConfig_t vidConfig;
|
||||||
|
clientDebug_t debug;
|
||||||
|
int doVidRestart;
|
||||||
|
ClientMatchData matchData;
|
||||||
|
XNADDR xnaddrs[18];
|
||||||
|
float debugRenderPos[3];
|
||||||
|
int skelValid;
|
||||||
|
int skelTimeStamp;
|
||||||
|
volatile int skelMemPos;
|
||||||
|
char skelMemory[262144];
|
||||||
|
char* skelMemoryStart;
|
||||||
|
bool allowedAllocSkel;
|
||||||
|
int serverId;
|
||||||
|
gameState_t gameState;
|
||||||
|
clSnapshot_t noDeltaSnapshot;
|
||||||
|
int nextNoDeltaEntity;
|
||||||
|
entityState_s noDeltaEntities[1024];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GraphFloat
|
||||||
|
{
|
||||||
|
char name[64];
|
||||||
|
float knots[32][2];
|
||||||
|
unsigned __int16 knotCount;
|
||||||
|
float scale;
|
||||||
|
};
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#ifndef IDA
|
#ifndef IDA
|
||||||
|
Loading…
Reference in New Issue
Block a user