]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/physics/player.qc
Don't run client-side player physics while inside a vehicle
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics / player.qc
index 545d71a21fff7d711e93da7f2df3c8115f15aed6..d70717ac5e983eeff9690ee6200a51662e638ca0 100644 (file)
@@ -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);
@@ -442,11 +452,11 @@ bool PlayerJump(entity this)
        bool doublejump = false;
        float mjumpheight = PHYS_JUMPVELOCITY(this);
 
-       if (MUTATOR_CALLHOOK(PlayerJump, this, doublejump, mjumpheight))
+       if (MUTATOR_CALLHOOK(PlayerJump, this, mjumpheight, doublejump))
                return true;
 
-       doublejump = player_multijump;
-       mjumpheight = player_jumpheight;
+       mjumpheight = M_ARGV(1, float);
+       doublejump = M_ARGV(2, bool);
 
        if (this.waterlevel >= WATERLEVEL_SWIMMING)
        {
@@ -577,16 +587,18 @@ void CheckWaterJump(entity this)
 void CheckPlayerJump(entity this)
 {
 #ifdef SVQC
-       float was_flying = ITEMS_STAT(this) & IT_USING_JETPACK;
+       bool was_flying = boolean(ITEMS_STAT(this) & IT_USING_JETPACK);
 #endif
        if (JETPACK_JUMP(this) < 2)
                ITEMS_STAT(this) &= ~IT_USING_JETPACK;
 
        if(PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_JETPACK(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;
+               bool playerjump = PlayerJump(this); // required
+
+               bool air_jump = !playerjump || M_ARGV(2, bool);
+               bool activate = JETPACK_JUMP(this) && air_jump && PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_JETPACK(this);
+               bool 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) { }
@@ -636,15 +648,15 @@ float racecar_angle(float forward, float down)
 
 string specialcommand = "xwxwxsxsxaxdxaxdx1x ";
 .float specialcommand_pos;
-void SpecialCommand()
+void SpecialCommand(entity this)
 {
 #ifdef SVQC
-       if (!CheatImpulse(CHIMPULSE_GIVE_ALL.impulse))
+       if (!CheatImpulse(this, CHIMPULSE_GIVE_ALL.impulse))
                LOG_INFO("A hollow voice says \"Plugh\".\n");
 #endif
 }
 
-float PM_check_specialcommand(entity this, float buttons)
+bool PM_check_specialcommand(entity this, int buttons)
 {
 #ifdef SVQC
        string c;
@@ -671,7 +683,7 @@ float PM_check_specialcommand(entity this, float buttons)
                if (this.specialcommand_pos >= strlen(specialcommand))
                {
                        this.specialcommand_pos = 0;
-                       SpecialCommand();
+                       SpecialCommand(this);
                        return true;
                }
        }
@@ -1285,10 +1297,6 @@ bool IsFlying(entity this)
        return true;
 }
 
-#ifdef CSQC
-float autocvar_slowmo;
-#endif
-
 void PM_Main(entity this)
 {
        int buttons = PHYS_INPUT_BUTTON_MASK(this);
@@ -1299,11 +1307,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
@@ -1316,7 +1319,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);
@@ -1325,11 +1328,11 @@ void PM_Main(entity this)
        Physics_UpdateStats(this, maxspeed_mod);
 
        if (this.PlayerPhysplug)
-               if (this.PlayerPhysplug())
+               if (this.PlayerPhysplug(this))
                        return;
 #elif defined(CSQC)
-       if(autocvar_slowmo != STAT(MOVEVARS_TIMESCALE))
-               cvar_set("slowmo", ftos(STAT(MOVEVARS_TIMESCALE)));
+       if(hud != HUD_NORMAL)
+               return; // no vehicle prediction (yet)
 #endif
 
 #ifdef SVQC
@@ -1358,7 +1361,7 @@ void PM_Main(entity this)
        {
                if (playerdemo_read(this))
                        return;
-               WITH(entity, self, this, bot_think());
+               bot_think(this);
        }
 #endif
 
@@ -1543,11 +1546,6 @@ LABEL(end)
        this.lastflags = this.flags;
 
        this.lastclassname = this.classname;
-
-#ifdef CSQC
-       this.v_angle = oldv_angle;
-       this.angles = oldangles;
-#endif
 }
 
 #if defined(SVQC)
@@ -1557,7 +1555,7 @@ void CSQC_ClientMovement_PlayerMove_Frame(entity this)
 #endif
 {
 #ifdef SVQC
-       SELFPARAM();
+       ENGINE_EVENT();
 #endif
        PM_Main(this);
 }