From 2af108d5618e12bb4100ba2816969e127f8e0206 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 5 Jan 2015 22:30:34 +1100 Subject: [PATCH] Add slick surface support --- qcsrc/common/physics.qc | 20 +++++++++++++++++++- qcsrc/common/physics.qh | 2 ++ qcsrc/common/stats.qh | 2 +- qcsrc/server/autocvars.qh | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index 233e3c33d..1b96fe03a 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -26,6 +26,9 @@ float AdjustAirAccelQW(float accelqw, float factor); .float stat_sv_maxspeed; .float stat_movement_highspeed; +.float stat_sv_friction_on_land; +.float stat_sv_friction_slick; + .float stat_doublejump; .float stat_jumpspeedcap_min; @@ -66,6 +69,10 @@ void Physics_AddStats() 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 + addstat(STAT_MOVEVARS_FRICTION_ONLAND, AS_FLOAT, stat_sv_friction_on_land); + addstat(STAT_MOVEVARS_FRICTION_SLICK, AS_FLOAT, stat_sv_friction_slick); } void Physics_UpdateStats(float maxspd_mod) @@ -91,6 +98,9 @@ void Physics_UpdateStats(float maxspd_mod) 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; + self.stat_sv_friction_slick = PHYS_FRICTION_SLICK; } #endif @@ -1596,9 +1606,17 @@ void PM_walk(float buttons_prev, float maxspd_mod) float f = vlen(vec2(self.velocity)); if (f > 0) { + float realfriction; + trace_dphitq3surfaceflags = 0; + tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self); // TODO: apply edge friction // apply ground friction - f = 1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION * ((f < PHYS_STOPSPEED) ? (PHYS_STOPSPEED / f) : 1); + if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK) + realfriction = PHYS_FRICTION_SLICK; + else + realfriction = PHYS_FRICTION; + + f = 1 - PHYS_INPUT_TIMELENGTH * realfriction * ((f < PHYS_STOPSPEED) ? (PHYS_STOPSPEED / f) : 1); f = max(0, f); self.velocity *= f; /* diff --git a/qcsrc/common/physics.qh b/qcsrc/common/physics.qh index 3ddb24486..a169ad4ff 100644 --- a/qcsrc/common/physics.qh +++ b/qcsrc/common/physics.qh @@ -77,6 +77,7 @@ #define PHYS_AIRSTRAFEACCELERATE getstatf(STAT_MOVEVARS_AIRSTRAFEACCELERATE) #define PHYS_ENTGRAVITY(s) getstatf(STAT_MOVEVARS_ENTGRAVITY) #define PHYS_FRICTION getstatf(STAT_MOVEVARS_FRICTION) + #define PHYS_FRICTION_SLICK getstatf(STAT_MOVEVARS_FRICTION_SLICK) #define PHYS_FRICTION_ONLAND getstatf(STAT_MOVEVARS_FRICTION_ONLAND) #define PHYS_GRAVITY getstatf(STAT_MOVEVARS_GRAVITY) #define PHYS_HIGHSPEED getstatf(STAT_MOVEVARS_HIGHSPEED) @@ -172,6 +173,7 @@ #define PHYS_AIRSTRAFEACCELERATE autocvar_sv_airstrafeaccelerate #define PHYS_ENTGRAVITY(s) s.gravity #define PHYS_FRICTION autocvar_sv_friction + #define PHYS_FRICTION_SLICK autocvar_sv_friction_slick #define PHYS_FRICTION_ONLAND autocvar_sv_friction_on_land #define PHYS_GRAVITY autocvar_sv_gravity #define PHYS_HIGHSPEED autocvar_g_movement_highspeed diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index ef4472d9f..8898ad2b2 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -223,7 +223,7 @@ const float STAT_REVIVE_PROGRESS = 106; // 188 empty? // 189 empty? // 190 empty? -// 191 empty? +const float STAT_MOVEVARS_FRICTION_SLICK = 191; const float STAT_MOVEVARS_FRICTION_ONLAND = 192; const float STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS = 193; const float STAT_MOVEVARS_JUMPSPEEDCAP_MAX = 194; diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 6b46a9512..a1ecb2fd1 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -631,6 +631,7 @@ string autocvar_sv_eventlog_files_namesuffix; float autocvar_sv_eventlog_files_timestamps; float autocvar_sv_friction; float autocvar_sv_friction_on_land; +var float autocvar_sv_friction_slick = 1; float autocvar_sv_gameplayfix_q2airaccelerate; float autocvar_sv_gentle; #define autocvar_sv_gravity cvar("sv_gravity") -- 2.39.2