]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/physics/movetypes/toss.qc
Make the QC physics match the engine a bit more accurately, fixes some issues with...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics / movetypes / toss.qc
index fc3de0859bba0a22e91c87afec51e63384d8fd59..772eb1b070c59a2be0df4aa72df5bc904e115838 100644 (file)
@@ -2,19 +2,26 @@
 
 void _Movetype_Physics_Toss(entity this, float dt)  // SV_Physics_Toss
 {
-       if (IS_ONGROUND(this))
+       if(IS_ONGROUND(this))
        {
-               if (this.velocity.z >= 1 / 32 && UPWARD_VELOCITY_CLEARS_ONGROUND(this))
+               if(this.velocity.z >= (1 / 32) && UPWARD_VELOCITY_CLEARS_ONGROUND(this))
                {
+                       // don't stick to ground if onground and moving upward
                        UNSET_ONGROUND(this);
                }
-               else if (!this.groundentity)
+               else if(!this.groundentity || !GAMEPLAYFIX_NOAIRBORNCORPSE(this))
                {
                        return;
                }
-               else if (this.move_suspendedinair && wasfreed(this.groundentity))
+               else if(this.move_suspendedinair && wasfreed(this.groundentity))
                {
                        this.groundentity = NULL;
+                       if(NOAIRBORNCORPSE_ALLOWSUSPENDED(this))
+                               return;
+               }
+               else if(boxesoverlap(this.absmin, this.absmax, this.groundentity.absmin, this.groundentity.absmax))
+               {
+                       // don't slide if still touching the groundentity
                        return;
                }
        }
@@ -23,35 +30,37 @@ void _Movetype_Physics_Toss(entity this, float dt)  // SV_Physics_Toss
 
        _Movetype_CheckVelocity(this);
 
-       /*if (this.move_movetype == MOVETYPE_BOUNCE || this.move_movetype == MOVETYPE_TOSS)
+       if(this.move_movetype == MOVETYPE_BOUNCE || this.move_movetype == MOVETYPE_TOSS)
        {
-               this.move_didgravity = 1;
+               this.move_didgravity = true;
                this.velocity_z -= (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1)
                    * dt
-                   * (this.gravity ? this.gravity : 1)
+                   * ((this.gravity) ? this.gravity : 1)
                    * PHYS_GRAVITY(this);
-       }*/
+       }
 
-       if (this.move_movetype == MOVETYPE_BOUNCE || this.move_movetype == MOVETYPE_TOSS)
+       /*if (this.move_movetype == MOVETYPE_BOUNCE || this.move_movetype == MOVETYPE_TOSS)
        {
                this.move_didgravity = true;
                this.velocity_z -= (((this.gravity) ? this.gravity : 1) * PHYS_GRAVITY(this) * dt);
-       }
+       }*/
 
        this.angles = this.angles + this.avelocity * dt;
 
        float movetime = dt;
-       for (int bump = 0; bump < MAX_CLIP_PLANES && movetime > 0; ++bump)
+       for (int bump = 0; bump < MAX_CLIP_PLANES && movetime > 0; bump++)
        {
                vector move = this.velocity * movetime;
-               _Movetype_PushEntity(this, move, true, false);
+               if(!_Movetype_PushEntity(this, move, true, true))
+                       return;
                if (wasfreed(this))
                        return;
 
                if (trace_startsolid)
                {
                        _Movetype_UnstickEntity(this);
-                       _Movetype_PushEntity(this, move, false, false);
+                       if(!_Movetype_PushEntity(this, move, true, true))
+                               return;
                        if (wasfreed(this))
                                return;
                }
@@ -63,28 +72,36 @@ void _Movetype_Physics_Toss(entity this, float dt)  // SV_Physics_Toss
 
                if (this.move_movetype == MOVETYPE_BOUNCEMISSILE)
                {
-                       this.velocity = _Movetype_ClipVelocity(this.velocity, trace_plane_normal, 2.0);
+                       float bouncefac = (!this.bouncefactor) ? 1.0 : this.bouncefactor;
+                       this.velocity = _Movetype_ClipVelocity(this.velocity, trace_plane_normal, 1 + bouncefac);
                        UNSET_ONGROUND(this);
+                       if(!GAMEPLAYFIX_SLIDEMOVEPROJECTILES(this))
+                               movetime = 0;
                }
                else if (this.move_movetype == MOVETYPE_BOUNCE)
                {
-                       float bouncefac = this.bouncefactor;     if (!bouncefac)  bouncefac = 0.5;
-                       float bstop = this.bouncestop; if (!bstop) bstop = 60 / 800;
-                       bstop *= (this.gravity ? this.gravity : 1) * PHYS_GRAVITY(this);
+                       float bouncefac = (!this.bouncefactor) ? 0.5 : this.bouncefactor;
+                       float bstop = (!this.bouncestop) ? (60 / 800) : this.bouncestop;
+                       float grav = ((this.gravity) ? this.gravity : 1);
 
                        this.velocity = _Movetype_ClipVelocity(this.velocity, trace_plane_normal, 1 + bouncefac);
 
                        float d = trace_plane_normal * this.velocity;
-                       if (trace_plane_normal.z > 0.7 && d < bstop && d > -bstop)
+                       if(!GAMEPLAYFIX_GRENADEBOUNCESLOPES(this))
+                               d = this.velocity.z;
+                       if (trace_plane_normal.z > 0.7 && d < PHYS_GRAVITY(this) * bstop * grav)
                        {
                                SET_ONGROUND(this);
                                this.groundentity = trace_ent;
                                this.velocity = '0 0 0';
                                this.avelocity = '0 0 0';
+                               movetime = 0;
                        }
                        else
                        {
                                UNSET_ONGROUND(this);
+                               if(!GAMEPLAYFIX_SLIDEMOVEPROJECTILES(this))
+                                       movetime = 0;
                        }
                }
                else
@@ -98,24 +115,27 @@ void _Movetype_Physics_Toss(entity this, float dt)  // SV_Physics_Toss
                                        this.move_suspendedinair = true;
                                this.velocity = '0 0 0';
                                this.avelocity = '0 0 0';
+                               movetime = 0;
                        }
                        else
                        {
                                UNSET_ONGROUND(this);
+                               if(!GAMEPLAYFIX_SLIDEMOVEPROJECTILES(this))
+                                       movetime = 0;
                        }
                }
 
                // DP revision 8905 (just, WHY...)
-               if (this.move_movetype == MOVETYPE_BOUNCEMISSILE)
-                       break;
+               //if (this.move_movetype == MOVETYPE_BOUNCEMISSILE)
+                       //break;
 
                // DP revision 8918 (WHY...)
-               if (IS_ONGROUND(this))
-                       break;
+               //if (IS_ONGROUND(this))
+                       //break;
        }
 
-       //if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE && this.move_didgravity > 0 && !IS_ONGROUND(this))
-       //      this.velocity_z -= 0.5 * dt * (this.gravity ? this.gravity : 1) * PHYS_GRAVITY(this);
+       if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE && this.move_didgravity > 0 && !IS_ONGROUND(this))
+               this.velocity_z -= 0.5 * dt * ((this.gravity) ? this.gravity : 1) * PHYS_GRAVITY(this);
 
        _Movetype_CheckWaterTransition(this);
 }