]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add an option to apply gravity on slick surfaces (so one slides down slopes)
authorMario <mario@smbclan.net>
Wed, 12 Oct 2016 17:05:52 +0000 (03:05 +1000)
committerMario <mario@smbclan.net>
Wed, 12 Oct 2016 17:05:52 +0000 (03:05 +1000)
defaultXonotic.cfg
qcsrc/common/physics/movetypes/movetypes.qh
qcsrc/common/physics/player.qc
qcsrc/common/physics/player.qh
qcsrc/common/stats.qh
qcsrc/ecs/systems/physics.qc

index fe07038e79ec9efb1d2db61e680e5a2933b5a0e5..8eaf852e7f7318864ddebdc7cfcdccb76ec358fe 100644 (file)
@@ -289,6 +289,8 @@ set sv_gibhealth 100 "Minus health a dead body must have in order to get gibbed"
 set sv_friction_on_land 0
 set sv_friction_slick 0.5
 
+set sv_slick_applygravity 0
+
 set sv_aircontrol_backwards 0 "apply forward aircontrol options to backward movement"
 
 set sv_player_viewoffset "0 0 35" "view offset of the player model"
index db5d29cefda9ec18af34da81e6e57708630c53a4..46e80fbc3e47aba9df7b2c659fa0ffa1b12eb6a5 100644 (file)
@@ -3,6 +3,9 @@
 #define IS_ONGROUND(s)                      boolean((s).flags & FL_ONGROUND)
 #define SET_ONGROUND(s)                     ((s).flags |= FL_ONGROUND)
 #define UNSET_ONGROUND(s)                   ((s).flags &= ~FL_ONGROUND)
+#define IS_ONSLICK(s)                                          boolean((s).flags & FL_ONSLICK)
+#define SET_ONSLICK(s)                                         ((s).flags |= FL_ONSLICK)
+#define UNSET_ONSLICK(s)                                       ((s).flags &= ~FL_ONSLICK)
 
 #ifdef CSQC
 .float bouncestop;
@@ -79,6 +82,8 @@ const int MOVETYPE_ANGLENOCLIP      = 1;
 const int MOVETYPE_ANGLECLIP        = 2;
 #endif
 
+const int FL_ONSLICK = BIT(20);
+
 const int MOVETYPE_FAKEPUSH         = 13;
 
 const int MOVEFLAG_VALID = BIT(23);
index 09882c02da2b74fbb63cf77bccf366ede1cc213d..cbfbaaaca2beb365f8ebff248b2542922f577594 100644 (file)
@@ -307,7 +307,7 @@ bool PlayerJump(entity this)
        }
 
        if (!doublejump)
-               if (!IS_ONGROUND(this))
+               if (!IS_ONGROUND(this) && !IS_ONSLICK(this))
                        return IS_JUMP_HELD(this);
 
        bool track_jump = PHYS_CL_TRACK_CANJUMP(this);
@@ -344,7 +344,7 @@ bool PlayerJump(entity this)
                }
        }
 
-       if (!WAS_ONGROUND(this))
+       if (!WAS_ONGROUND(this) && !WAS_ONSLICK(this))
        {
 #ifdef SVQC
                if(autocvar_speedmeter)
@@ -366,6 +366,7 @@ bool PlayerJump(entity this)
        this.velocity_z += mjumpheight;
 
        UNSET_ONGROUND(this);
+       UNSET_ONSLICK(this);
        SET_JUMP_HELD(this);
 
 #ifdef SVQC
@@ -641,6 +642,24 @@ void PM_Footsteps(entity this)
 #endif
 }
 
+void PM_check_slick(entity this)
+{
+       if(!IS_ONGROUND(this))
+               return;
+
+       if(!PHYS_SLICK_APPLYGRAVITY(this))
+               return;
+
+       tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
+       if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK)
+       {
+               UNSET_ONGROUND(this);
+               SET_ONSLICK(this);
+       }
+       else
+               UNSET_ONSLICK(this);
+}
+
 void PM_check_blocked(entity this)
 {
 #ifdef SVQC
index 1899b1f60f8d79b3c700f201a660e11fcd219989..5c0b104178b0a385ee2509f9aa814f0d2b1c705c 100644 (file)
@@ -97,6 +97,8 @@ bool IsFlying(entity a);
 
 #define UPWARD_VELOCITY_CLEARS_ONGROUND(s)  STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, s)
 
+#define PHYS_SLICK_APPLYGRAVITY(s)             STAT(SLICK_APPLYGRAVITY, s)
+
 #define PHYS_INPUT_BUTTON_ATCK(s)           PHYS_INPUT_BUTTON_BUTTON1(s)
 #define PHYS_INPUT_BUTTON_JUMP(s)           PHYS_INPUT_BUTTON_BUTTON2(s)
 #define PHYS_INPUT_BUTTON_ATCK2(s)          PHYS_INPUT_BUTTON_BUTTON3(s)
@@ -156,6 +158,7 @@ STATIC_INIT(PHYS_INPUT_BUTTON_JETPACK)
 #define UNSET_JUMP_HELD(s)                  ((s).flags |= FL_JUMPRELEASED)
 
 #define WAS_ONGROUND(s)                     boolean((s).lastflags & FL_ONGROUND)
+#define WAS_ONSLICK(s)                      boolean((s).lastflags & FL_ONSLICK)
 
 #define ITEMS_STAT(s)                       ((s).items)
 
index e6cc5530cf806f819cb061faa3937966ac9b177b..09921c6f86cbfe1cbaaceb4c83b4b0cbc5798f9e 100644 (file)
@@ -263,6 +263,11 @@ REGISTER_STAT(CAMERA_SPECTATOR, int)
 
 REGISTER_STAT(SPECTATORSPEED, float)
 
+#ifdef SVQC
+bool autocvar_sv_slick_applygravity;
+#endif
+REGISTER_STAT(SLICK_APPLYGRAVITY, bool, autocvar_sv_slick_applygravity)
+
 #ifdef SVQC
 #include "physics/movetypes/movetypes.qh"
 #endif
index c0a47e39b2a4aff558c3c53af50d49694d6c01f7..a08422dcfad666dd56780211cad37a9497dc17e3 100644 (file)
@@ -62,6 +62,8 @@ void sys_phys_update(entity this, float dt)
                goto end;
        }
 
+       PM_check_slick(this);
+
        if (IS_SVQC && !PHYS_FIXANGLE(this)) { this.angles = '0 1 0' * this.v_angle.y; }
        if (IS_PLAYER(this)) {
                if (IS_ONGROUND(this)) {