]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/physics/player.qc
Move setting of the slowmo cvar out of the physics function (physics are called multi...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics / player.qc
index 1fc9ccdf3cdbbc16cc0b92f074de9ead94600bc5..302104351dd19560b004a7e5e14dfb39f6f558c5 100644 (file)
@@ -4,7 +4,7 @@
 
 #ifdef SVQC
 
-#include "../../server/miscfunctions.qh"
+#include <server/miscfunctions.qh>
 #include "../triggers/trigger/viewloc.qh"
 
 // client side physics
@@ -107,7 +107,7 @@ void PM_ClientMovement_Unstick(entity this)
        #define X(unstick_offset) \
        { \
                vector neworigin = unstick_offset + this.origin; \
-               tracebox(neworigin, PL_CROUCH_MIN, PL_CROUCH_MAX, neworigin, MOVE_NORMAL, this); \
+               tracebox(neworigin, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL), neworigin, MOVE_NORMAL, this); \
                if (!trace_startsolid) \
                { \
                        setorigin(this, neworigin); \
@@ -128,7 +128,17 @@ void PM_ClientMovement_UpdateStatus(entity this, bool ground)
                PM_ClientMovement_Unstick(this);
 
        // set crouched
-       if (PHYS_INPUT_BUTTON_CROUCH(this))
+       bool do_crouch = PHYS_INPUT_BUTTON_CROUCH(this);
+       if(this.hook && !wasfreed(this.hook))
+               do_crouch = false;
+       if(hud != HUD_NORMAL)
+               do_crouch = false;
+       if(STAT(FROZEN, this))
+               do_crouch = false;
+       if((activeweapon == WEP_SHOCKWAVE || activeweapon == WEP_SHOTGUN) && viewmodel.animstate_startframe == viewmodel.anim_fire2_x && time < viewmodel.weapon_nextthink)
+               do_crouch = false;
+
+       if (do_crouch)
        {
                // wants to crouch, this always works
                if (!IS_DUCKED(this)) SET_DUCKED(this);
@@ -138,7 +148,7 @@ void PM_ClientMovement_UpdateStatus(entity this, bool ground)
                // wants to stand, if currently crouching we need to check for a low ceiling first
                if (IS_DUCKED(this))
                {
-                       tracebox(this.origin, PL_MIN, PL_MAX, this.origin, MOVE_NORMAL, this);
+                       tracebox(this.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), this.origin, MOVE_NORMAL, this);
                        if (!trace_startsolid) UNSET_DUCKED(this);
                }
        }
@@ -560,7 +570,7 @@ void CheckWaterJump(entity this)
                #ifdef SVQC
                        PHYS_TELEPORT_TIME(this) = time + 2;    // safety net
                #elif defined(CSQC)
-                       pmove_waterjumptime = time + 2;
+                       pmove_waterjumptime = 2;
                #endif
                }
        }
@@ -586,7 +596,7 @@ void CheckPlayerJump(entity this)
        {
                float air_jump = !PlayerJump(this) || player_multijump; // PlayerJump() has important side effects
                float activate = JETPACK_JUMP(this) && air_jump && PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_JETPACK(this);
-               float has_fuel = !PHYS_JETPACK_FUEL(this) || PHYS_AMMO_FUEL(this) || ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO;
+               float has_fuel = !PHYS_JETPACK_FUEL(this) || PHYS_AMMO_FUEL(this) || (ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO);
 
                if (!(ITEMS_STAT(this) & ITEM_Jetpack.m_itemid)) { }
                else if (this.jetpack_stopped) { }
@@ -690,7 +700,7 @@ void PM_check_nickspam(entity this)
        {
                // slight annoyance for nick change scripts
                this.movement = -1 * this.movement;
-               this.BUTTON_ATCK = this.BUTTON_JUMP = this.BUTTON_ATCK2 = this.BUTTON_ZOOM = this.BUTTON_CROUCH = this.BUTTON_HOOK = this.BUTTON_USE = 0;
+               PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_JUMP(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_ZOOM(this) = PHYS_INPUT_BUTTON_CROUCH(this) = PHYS_INPUT_BUTTON_HOOK(this) = PHYS_INPUT_BUTTON_USE(this) = false;
 
                if (this.nickspamcount >= autocvar_g_nick_flood_penalty_red) // if you are persistent and the slight annoyance above does not stop you, I'll show you!
                {
@@ -992,7 +1002,7 @@ void PM_jetpack(entity this, float maxspd_mod)
        // add the unused velocity as up component
        wishvel_z = 0;
 
-       // if (this.BUTTON_JUMP)
+       // if (PHYS_INPUT_BUTTON_JUMP(this))
                wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
 
        // it is now normalized, so...
@@ -1247,8 +1257,10 @@ void PM_air(entity this, float buttons_prev, float maxspd_mod)
 
                if (PHYS_WARSOWBUNNY_TURNACCEL(this) && accelerating && this.movement.y == 0 && this.movement.x != 0)
                        PM_AirAccelerate(this, wishdir, wishspeed2);
-               else
-                       PM_Accelerate(this, wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, PHYS_AIRACCEL_QW_STRETCHFACTOR(this), PHYS_AIRACCEL_SIDEWAYS_FRICTION(this) / maxairspd, PHYS_AIRSPEEDLIMIT_NONQW(this));
+               else {
+                   float sidefric = maxairspd ? (PHYS_AIRACCEL_SIDEWAYS_FRICTION(this) / maxairspd) : 0;
+                       PM_Accelerate(this, wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, PHYS_AIRACCEL_QW_STRETCHFACTOR(this), sidefric, PHYS_AIRSPEEDLIMIT_NONQW(this));
+        }
 
                if (PHYS_AIRCONTROL(this))
                        CPM_PM_Aircontrol(this, wishdir, wishspeed2);
@@ -1277,12 +1289,16 @@ bool IsFlying(entity this)
                return false;
        if(this.waterlevel >= WATERLEVEL_SWIMMING)
                return false;
-       //traceline(this.origin, this.origin - '0 0 48', MOVE_NORMAL, this);
-       //if(trace_fraction < 1)
-               //return false;
+       traceline(this.origin, this.origin - '0 0 48', MOVE_NORMAL, this);
+       if(trace_fraction < 1)
+               return false;
        return true;
 }
 
+#ifdef CSQC
+float autocvar_slowmo;
+#endif
+
 void PM_Main(entity this)
 {
        int buttons = PHYS_INPUT_BUTTON_MASK(this);
@@ -1293,11 +1309,6 @@ void PM_Main(entity this)
 
        this.spectatorspeed = STAT(SPECTATORSPEED);
 
-       vector oldv_angle = this.v_angle;
-       vector oldangles = this.angles; // we need to save these, as they're abused by other code
-       this.v_angle = PHYS_INPUT_ANGLES(this);
-       this.angles = PHYS_WORLD_ANGLES(this);
-
        this.team = myteam + 1; // is this correct?
        if (!(PHYS_INPUT_BUTTON_JUMP(this))) // !jump
                UNSET_JUMP_HELD(this); // canjump = true
@@ -1310,7 +1321,7 @@ void PM_Main(entity this)
 
 
 #ifdef SVQC
-       WarpZone_PlayerPhysics_FixVAngle();
+       WarpZone_PlayerPhysics_FixVAngle(this);
 #endif
        float maxspeed_mod = 1;
        maxspeed_mod *= PHYS_HIGHSPEED(this);
@@ -1319,7 +1330,7 @@ void PM_Main(entity this)
        Physics_UpdateStats(this, maxspeed_mod);
 
        if (this.PlayerPhysplug)
-               if (this.PlayerPhysplug())
+               if (this.PlayerPhysplug(this))
                        return;
 #endif
 
@@ -1349,7 +1360,7 @@ void PM_Main(entity this)
        {
                if (playerdemo_read(this))
                        return;
-               WITH(entity, self, this, bot_think());
+               bot_think(this);
        }
 #endif
 
@@ -1405,7 +1416,7 @@ void PM_Main(entity this)
                        this.spectatorspeed = maxspeed_mod;
                if (this.impulse && this.impulse <= 19 || (this.impulse >= 200 && this.impulse <= 209) || (this.impulse >= 220 && this.impulse <= 229))
                {
-                       if (this.lastclassname != "player")
+                       if (this.lastclassname != STR_PLAYER)
                        {
                                if (this.impulse == 10 || this.impulse == 15 || this.impulse == 18 || (this.impulse >= 200 && this.impulse <= 209))
                                        this.spectatorspeed = bound(1, this.spectatorspeed + 0.5, 5);
@@ -1446,7 +1457,7 @@ void PM_Main(entity this)
        }
 #endif
 
-       if(PHYS_DEAD(this))
+       if(IS_DEAD(this))
        {
                // handle water here
                vector midpoint = ((this.absmin + this.absmax) * 0.5);
@@ -1472,8 +1483,10 @@ void PM_Main(entity this)
                PM_Footsteps(this);
        }
 
+#ifdef SVQC
        if(IsFlying(this))
                this.wasFlying = 1;
+#endif
 
        if (IS_PLAYER(this))
                CheckPlayerJump(this);
@@ -1482,10 +1495,17 @@ void PM_Main(entity this)
        {
                this.velocity_x = this.movedir.x;
                this.velocity_y = this.movedir.y;
-               if (time > PHYS_TELEPORT_TIME(this) || this.waterlevel == WATERLEVEL_NONE)
+               if (time > PHYS_TELEPORT_TIME(this) || this.waterlevel == WATERLEVEL_NONE
+               #ifdef CSQC
+                       || pmove_waterjumptime <= 0
+               #endif
+                       )
                {
                        this.flags &= ~FL_WATERJUMP;
                        PHYS_TELEPORT_TIME(this) = 0;
+               #ifdef CSQC
+                       pmove_waterjumptime = 0;
+               #endif
                }
        }
 
@@ -1514,7 +1534,7 @@ void PM_Main(entity this)
        else
                PM_air(this, buttons_prev, maxspeed_mod);
 
-:end
+LABEL(end)
        if (IS_ONGROUND(this))
                this.lastground = time;
 
@@ -1525,11 +1545,6 @@ void PM_Main(entity this)
        this.lastflags = this.flags;
 
        this.lastclassname = this.classname;
-
-#ifdef CSQC
-       this.v_angle = oldv_angle;
-       this.angles = oldangles;
-#endif
 }
 
 #if defined(SVQC)