Commit 4bfdd7c6 authored by Mario's avatar Mario

Fix an issue with jump speed caps and slopes

parent b6b2f6f6
......@@ -119,6 +119,9 @@ void CSQC_Init(void)
registercvar("cl_nade_type", "3");
registercvar("cl_pokenade_type", "zombie");
registercvar("cl_jumpspeedcap_min", "");
registercvar("cl_jumpspeedcap_max", "");
gametype = 0;
// hud_fields uses strunzone on the titles!
......
......@@ -84,8 +84,6 @@ void Physics_AddStats()
addstat(STAT_DOUBLEJUMP, AS_INT, stat_doublejump);
// jump speed caps
addstat(STAT_MOVEVARS_JUMPSPEEDCAP_MIN, AS_FLOAT, stat_jumpspeedcap_min);
addstat(STAT_MOVEVARS_JUMPSPEEDCAP_MIN, AS_FLOAT, stat_jumpspeedcap_min);
addstat(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, AS_INT, stat_jumpspeedcap_disable_onramps);
// hacks
......@@ -147,8 +145,6 @@ void Physics_UpdateStats(float maxspd_mod)
self.stat_jetpack_maxspeed_up = PHYS_JETPACK_MAXSPEED_UP;
self.stat_jetpack_fuel = PHYS_JETPACK_FUEL;
self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN;
self.stat_jumpspeedcap_max = PHYS_JUMPSPEEDCAP_MAX;
self.stat_jumpspeedcap_disable_onramps = PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS;
self.stat_sv_friction_on_land = PHYS_FRICTION_ONLAND;
......@@ -602,22 +598,22 @@ bool PlayerJump (void)
// velocity bounds. Final velocity is bound between (jumpheight *
// min + jumpheight) and (jumpheight * max + jumpheight);
if(PHYS_JUMPSPEEDCAP_MIN)
if(PHYS_JUMPSPEEDCAP_MIN != "")
{
float minjumpspeed = mjumpheight * PHYS_JUMPSPEEDCAP_MIN;
float minjumpspeed = mjumpheight * stof(PHYS_JUMPSPEEDCAP_MIN);
if (self.velocity_z < minjumpspeed)
mjumpheight += minjumpspeed - self.velocity_z;
}
if(PHYS_JUMPSPEEDCAP_MAX)
if(PHYS_JUMPSPEEDCAP_MAX != "")
{
// don't do jump speedcaps on ramps to preserve old xonotic ramjump style
tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
if (!(trace_fraction < 1 && trace_plane_normal_z < 0.98 && PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS))
{
float maxjumpspeed = mjumpheight * PHYS_JUMPSPEEDCAP_MAX;
float maxjumpspeed = mjumpheight * stof(PHYS_JUMPSPEEDCAP_MAX);
if (self.velocity_z > maxjumpspeed)
mjumpheight -= self.velocity_z - maxjumpspeed;
......@@ -1832,6 +1828,17 @@ void PM_Main()
stuffcmd(self, strcat("cl_sidespeed ", temps, "\n"));
stuffcmd(self, strcat("cl_upspeed ", temps, "\n"));
}
if(self.stat_jumpspeedcap_min != PHYS_JUMPSPEEDCAP_MIN)
{
self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN;
stuffcmd(self, strcat("cl_jumpspeedcap_min ", PHYS_JUMPSPEEDCAP_MIN, "\n"));
}
if(self.stat_jumpspeedcap_max != PHYS_JUMPSPEEDCAP_MAX)
{
self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MAX;
stuffcmd(self, strcat("cl_jumpspeedcap_max ", PHYS_JUMPSPEEDCAP_MAX, "\n"));
}
#endif
if(PHYS_DEAD(self))
......
......@@ -119,8 +119,8 @@ bool IsFlying(entity a);
#define PHYS_BUGRIGS_REVERSE_SPINNING getstatf(STAT_BUGRIGS_REVERSE_SPINNING)
#define PHYS_BUGRIGS_REVERSE_STOPPING getstatf(STAT_BUGRIGS_REVERSE_STOPPING)
#define PHYS_JUMPSPEEDCAP_MIN getstatf(STAT_MOVEVARS_JUMPSPEEDCAP_MIN)
#define PHYS_JUMPSPEEDCAP_MAX getstatf(STAT_MOVEVARS_JUMPSPEEDCAP_MAX)
#define PHYS_JUMPSPEEDCAP_MIN cvar_string("cl_jumpspeedcap_min")
#define PHYS_JUMPSPEEDCAP_MAX cvar_string("cl_jumpspeedcap_max")
#define PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS getstati(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS)
#define PHYS_TRACK_CANJUMP(s) getstati(STAT_MOVEVARS_TRACK_CANJUMP)
......@@ -191,8 +191,8 @@ bool IsFlying(entity a);
.float stat_doublejump;
.float stat_jumpspeedcap_min;
.float stat_jumpspeedcap_max;
.string stat_jumpspeedcap_min;
.string stat_jumpspeedcap_max;
.float stat_jumpspeedcap_disable_onramps;
.float stat_jetpack_accel_side;
......
......@@ -246,8 +246,8 @@ const int STAT_GAMEPLAYFIX_EASIERWATERJUMP = 190;
const int STAT_MOVEVARS_FRICTION_SLICK = 191;
const int STAT_MOVEVARS_FRICTION_ONLAND = 192;
const int STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS = 193;
const int STAT_MOVEVARS_JUMPSPEEDCAP_MAX = 194;
const int STAT_MOVEVARS_JUMPSPEEDCAP_MIN = 195;
// 194 empty?
// 195 empty?
const int STAT_DOUBLEJUMP = 196;
const int STAT_MOVEVARS_TRACK_CANJUMP = 197;
const int STAT_MULTIJUMP_ADD = 198;
......
......@@ -625,9 +625,9 @@ float autocvar_sv_gameplayfix_q2airaccelerate;
int autocvar_sv_gentle;
#define autocvar_sv_gravity cvar("sv_gravity")
string autocvar_sv_intermission_cdtrack;
float autocvar_sv_jumpspeedcap_max;
string autocvar_sv_jumpspeedcap_max;
float autocvar_sv_jumpspeedcap_max_disable_on_ramps;
float autocvar_sv_jumpspeedcap_min;
string autocvar_sv_jumpspeedcap_min;
float autocvar_sv_jumpvelocity;
bool autocvar_sv_logscores_bots;
bool autocvar_sv_logscores_console;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment