]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_physics.qc
fix warnings
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_physics.qc
index cb94429d97b071df8ad2a5bc0ec13567dab8478c..b005dd5f3f20c575914e76107a7891ffd4198d07 100644 (file)
@@ -37,8 +37,7 @@ float sv_airspeedlimit_nonqw;
 .float multijump_ready;
 .float prevjumpbutton;
 
-.float prevtopspeed; // store the top speed during the last 0.25 seconds to make dodging at full speeds easier
-.float prevtopspeed_time;
+.float nexspeed;
 
 /*
 =============
@@ -81,32 +80,48 @@ void PlayerJump (void)
                        self.multijump_ready = FALSE;
        }
 
-       if(self.multijump_ready && self.multijump_count < cvar("g_multijump") && self.velocity_z > cvar("g_multijump_speed"))
+       if(!doublejump && self.multijump_ready && self.multijump_count < cvar("g_multijump") && self.velocity_z > cvar("g_multijump_speed"))
        {
+               // doublejump = FALSE; // checked above in the if
                if (cvar("g_multijump") > 0)
                {
                        if (cvar("g_multijump_add") == 0) // in this case we make the z velocity == jumpvelocity
-                               self.velocity_z = 0;
-
-                       if(self.movement_x != 0 || self.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys
                        {
-                               float curspeed;
-                               vector wishvel, wishdir;
-
-                               curspeed = max(vlen(self.velocity - '0 0 1' * self.velocity_z), self.prevtopspeed);
-                               makevectors(self.v_angle);
-                               wishvel = v_forward * self.movement_x + v_right * self.movement_y;
-                               wishdir = normalize(wishvel);
+                               if (self.velocity_z < mjumpheight)
+                               {
+                                       doublejump = TRUE;
+                                       self.velocity_z = 0;
+                               }
+                       }
+                       else
+                               doublejump = TRUE;
 
-                               self.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump
-                               self.velocity_y = wishdir_y * curspeed;
-                               // keep velocity_z unchanged!
+                       if(doublejump)
+                       {
+                               if(self.movement_x != 0 || self.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys
+                               {
+                                       float curspeed;
+                                       vector wishvel, wishdir;
+
+                                       curspeed = max(
+                                               vlen(vec2(self.velocity)), // current xy speed
+                                               vlen(vec2(antilag_takebackavgvelocity(self, max(self.lastteleporttime + sys_frametime, time - 0.25), time))) // average xy topspeed over the last 0.25 secs
+                                       );
+                                       makevectors(self.v_angle_y * '0 1 0');
+                                       wishvel = v_forward * self.movement_x + v_right * self.movement_y;
+                                       wishdir = normalize(wishvel);
+
+                                       self.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump
+                                       self.velocity_y = wishdir_y * curspeed;
+                                       // keep velocity_z unchanged!
+                               }
+                               self.multijump_count += 1;
                        }
-                       self.multijump_count += 1;
                }
                self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump
        }
-       else if (!doublejump)
+
+       if (!doublejump)
                if (!(self.flags & FL_ONGROUND))
                        return;
 
@@ -944,12 +959,6 @@ void SV_PlayerPhysics()
                                self.multijump_count = -2; // the cvar value for infinite jumps is -1, so this needs to be smaller
                }
 
-               if(vlen(self.velocity) >= self.prevtopspeed || time - self.prevtopspeed_time > 0.25)
-               {
-                       self.prevtopspeed_time = time;
-                       self.prevtopspeed = vlen(self.velocity - '0 0 1' * self.velocity_z);
-               }
-
                if (self.BUTTON_JUMP)
                        PlayerJump ();
                else
@@ -1316,6 +1325,17 @@ void SV_PlayerPhysics()
                        }
                }
        }
+
+       float xyspeed;
+       xyspeed = vlen('1 0 0' * self.velocity_x + '0 1 0' * self.velocity_y);
+       if(self.weapon == WEP_NEX && cvar("g_balance_nex_charge") && cvar("g_balance_nex_charge_velocity_rate") && xyspeed > cvar("g_balance_nex_charge_minspeed"))
+       {
+               // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed
+               xyspeed = min(xyspeed, cvar("g_balance_nex_charge_maxspeed"));
+               f = (xyspeed - cvar("g_balance_nex_charge_minspeed")) / (cvar("g_balance_nex_charge_maxspeed") - cvar("g_balance_nex_charge_minspeed"));
+               // add the extra charge
+               self.nex_charge = min(1, self.nex_charge + cvar("g_balance_nex_charge_velocity_rate") * f * frametime);
+       }
 :end
        if(self.flags & FL_ONGROUND)
                self.lastground = time;