cvar_t in_pitch_max = {CF_CLIENT, "in_pitch_max", "90", "how far you can aim downward (quake used 80)"};
cvar_t m_filter = {CF_CLIENT | CF_ARCHIVE, "m_filter","0", "smoothes mouse movement, less responsive but smoother aiming"};
-cvar_t m_accelerate = {CF_CLIENT | CF_ARCHIVE, "m_accelerate","1", "linear mouse acceleration factor (set to 1 to disable the linear acceleration and use only the power acceleration; set to 0 to disable all acceleration)"};
+cvar_t m_accelerate = {CF_CLIENT | CF_ARCHIVE, "m_accelerate","1", "linear mouse acceleration factor (set to 1 to disable the linear acceleration and use only the power or natural acceleration; set to 0 to disable all acceleration)"};
cvar_t m_accelerate_minspeed = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_minspeed","5000", "below this speed in px/s, no acceleration is done, with a linear slope between (applied only on linear acceleration)"};
cvar_t m_accelerate_maxspeed = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_maxspeed","10000", "above this speed in px/s, full acceleration is done, with a linear slope between (applied only on linear acceleration)"};
cvar_t m_accelerate_filter = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_filter","0", "linear mouse acceleration factor filtering lowpass constant in seconds (set to 0 for no filtering)"};
cvar_t m_accelerate_power = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_power","2", "acceleration power (must be above 1 to be useful)"};
cvar_t m_accelerate_power_senscap = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_power_senscap", "0", "maximum acceleration factor generated by power acceleration; use 0 for unbounded"};
cvar_t m_accelerate_power_strength = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_power_strength", "0", "strength of the power mouse acceleration effect"};
+cvar_t m_accelerate_natural_strength = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_natural_strength", "0", "How quickly the accelsensitivity approaches the m_accelerate_natural_accelsenscap, values are compressed between 0 and 1 but higher numbers are allowed"};
+cvar_t m_accelerate_natural_accelsenscap = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_natural_accelsenscap", "0", "Horizontal asymptote that sets the maximum value for the natural mouse acceleration curve, value 2, for example, means that the maximum sensitivity is 2 times the base sensitivity"};
+cvar_t m_accelerate_natural_offset = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_natural_offset", "0", "below this speed in px/ms, no natural acceleration is done"};
cvar_t cl_netfps = {CF_CLIENT | CF_ARCHIVE, "cl_netfps","72", "how many input packets to send to server each second"};
cvar_t cl_netrepeatinput = {CF_CLIENT | CF_ARCHIVE, "cl_netrepeatinput", "1", "how many packets in a row can be lost without movement issues when using cl_movement (technically how many input messages to repeat in each packet that have not yet been acknowledged by the server), only affects DP7 and later servers (Quake uses 0, QuakeWorld uses 2, and just for comparison Quake3 uses 1)"};
}
}
- // apply m_accelerate if it is on
+ // apply m_accelerate if it is on
if(m_accelerate.value > 0)
{
float mouse_deltadist = sqrtf(in_mouse_x * in_mouse_x + in_mouse_y * in_mouse_y);
static float averagespeed = 0;
float f, mi, ma;
if(m_accelerate_filter.value > 0)
- f = bound(0, cl.realframetime / m_accelerate_filter.value, 1);
+ f = bound(0, cl.realframetime / m_accelerate_filter.value, 1);
else
- f = 1;
+ f = 1;
averagespeed = speed * f + averagespeed * (1 - f);
// Note: this check is technically unnecessary, as everything in here cancels out if it is zero.
{
// Then do Quake Live-style power acceleration.
// Note that this behavior REPLACES the usual
- // sensitivity, so we apply it but then dividie by
+ // sensitivity, so we apply it but then divide by
// sensitivity.value so that the later multiplication
// restores it again.
float accelsens = 1.0f;
{
// TODO: How does this interact with sensitivity changes? Is this intended?
// Currently: senscap is in absolute sensitivity units, so if senscap < sensitivity, it overrides.
- accelsens = m_accelerate_power_senscap.value * inv_sensitivity;
+ accelsens = m_accelerate_power_senscap.value * inv_sensitivity;
+ }
+
+ in_mouse_x *= accelsens;
+ in_mouse_y *= accelsens;
+ }
+
+ if (m_accelerate_natural_strength.value > 0.0f && m_accelerate_natural_accelsenscap.value >= 0.0f)
+ {
+ float accelsens = 1.0f;
+ float adjusted_speed_pxms = (averagespeed * 0.001f - m_accelerate_natural_offset.value);
+
+ if (adjusted_speed_pxms > 0 && m_accelerate_natural_accelsenscap.value != 1.0f)
+ {
+ float adjusted_accelsenscap = m_accelerate_natural_accelsenscap.value - 1.0f;
+ // This equation is made to multiply the sensitivity for a factor between 1 and m_accelerate_natural_accelsenscap
+ // this means there is no need to divide it for the sensitivity.value as the whole
+ // expression needs to be multiplied by the sensitivity at the end instead of only having the sens multiplied
+ accelsens += (adjusted_accelsenscap - adjusted_accelsenscap * exp( - ((adjusted_speed_pxms * m_accelerate_natural_strength.value) / fabs(adjusted_accelsenscap) )));
}
in_mouse_x *= accelsens;
Cvar_RegisterVariable(&m_accelerate_power_offset);
Cvar_RegisterVariable(&m_accelerate_power_senscap);
Cvar_RegisterVariable(&m_accelerate_power_strength);
+ Cvar_RegisterVariable(&m_accelerate_natural_offset);
+ Cvar_RegisterVariable(&m_accelerate_natural_accelsenscap);
+ Cvar_RegisterVariable(&m_accelerate_natural_strength);
Cvar_RegisterVariable(&cl_netfps);
Cvar_RegisterVariable(&cl_netrepeatinput);