]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_physics.qc
Merge remote-tracking branch 'origin/terencehill/menu_focus_bugfix'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_physics.qc
index a929e368c184f3f1a0ea6431318ac5a96c772de8..a7051ff14c4b18da5e95a228fae1ccd4c64c44ff 100644 (file)
 .float wasFlying;
 .float spectatorspeed;
 
-.float multijump_count;
-.float multijump_ready;
-.float prevjumpbutton;
-
 /*
 =============
 PlayerJump
@@ -23,13 +19,16 @@ When you press the jump key
 */
 void PlayerJump (void)
 {
-       if(self.freezetag_frozen)
-               return; // no jumping in freezetag when frozen
+       float doublejump = FALSE;
 
-       float mjumpheight;
-       float doublejump;
+       player_multijump = doublejump;
+       if(MUTATOR_CALLHOOK(PlayerJump))
+               return;
+               
+       doublejump = player_multijump;
 
-       doublejump = FALSE;
+       float mjumpheight;
+       
        if (autocvar_sv_doublejump)
        {
                tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
@@ -48,66 +47,10 @@ void PlayerJump (void)
        mjumpheight = autocvar_sv_jumpvelocity;
        if (self.waterlevel >= WATERLEVEL_SWIMMING)
        {
-               if (self.watertype == CONTENT_WATER)
-                       self.velocity_z = 200;
-               else if (self.watertype == CONTENT_SLIME)
-                       self.velocity_z = 80;
-               else
-                       self.velocity_z = 50;
-
+               self.velocity_z = self.stat_sv_maxspeed * 0.7;
                return;
        }
 
-       if (autocvar_g_multijump)
-       {
-               if (self.prevjumpbutton == FALSE && !(self.flags & FL_ONGROUND)) // jump button pressed this frame and we are in midair
-                       self.multijump_ready = TRUE;  // this is necessary to check that we released the jump button and pressed it again
-               else
-                       self.multijump_ready = FALSE;
-       }
-
-       if(!doublejump && self.multijump_ready && self.multijump_count < autocvar_g_multijump && self.velocity_z > autocvar_g_multijump_speed)
-       {
-               // doublejump = FALSE; // checked above in the if
-               if (autocvar_g_multijump)
-               {
-                       if (autocvar_g_multijump_add == 0) // in this case we make the z velocity == jumpvelocity
-                       {
-                               if (self.velocity_z < mjumpheight)
-                               {
-                                       doublejump = TRUE;
-                                       self.velocity_z = 0;
-                               }
-                       }
-                       else
-                               doublejump = TRUE;
-
-                       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!
-                               }
-                               if (autocvar_g_multijump > 0)
-                                       self.multijump_count += 1;
-                       }
-               }
-               self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump
-       }
-
        if (!doublejump)
                if (!(self.flags & FL_ONGROUND))
                        return;
@@ -116,9 +59,6 @@ void PlayerJump (void)
                if (!(self.flags & FL_JUMPRELEASED))
                        return;
 
-       if(self.health <= g_bloodloss)
-               return;
-
        // sv_jumpspeedcap_min/sv_jumpspeedcap_max act as baseline
        // velocity bounds.  Final velocity is bound between (jumpheight *
        // min + jumpheight) and (jumpheight * max + jumpheight);
@@ -170,8 +110,8 @@ void PlayerJump (void)
        self.flags &~= FL_JUMPRELEASED;
 
        animdecide_setaction(self, ANIMACTION_JUMP, TRUE);
-
-       if(g_jump_grunt)
+       
+       if(autocvar_g_jump_grunt)
                PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
 
        self.restart_jump = -1; // restart jump anim next time
@@ -207,14 +147,6 @@ void CheckWaterJump()
 }
 void CheckPlayerJump()
 {
-       if(self.flags & FL_ONGROUND)
-       {
-               if (autocvar_g_multijump > 0)
-                       self.multijump_count = 0;
-               else
-                       self.multijump_count = -2; // the cvar value for infinite jumps is -1, so this needs to be smaller
-       }
-
        if (self.BUTTON_JUMP)
                PlayerJump ();
        else
@@ -222,7 +154,6 @@ void CheckPlayerJump()
 
        if (self.waterlevel == WATERLEVEL_SWIMMING)
                CheckWaterJump ();
-       self.prevjumpbutton = self.BUTTON_JUMP;
 }
 
 float racecar_angle(float forward, float down)
@@ -704,8 +635,6 @@ void SV_PlayerPhysics()
        WarpZone_PlayerPhysics_FixVAngle();
        
        maxspd_mod = 1;
-       if(g_minstagib && (self.items & IT_INVINCIBLE))
-               maxspd_mod *= autocvar_g_minstagib_speed_highspeed;
        if(self.ballcarried)
                if(g_nexball)
                        maxspd_mod *= autocvar_g_nexball_basketball_carrier_highspeed;
@@ -768,7 +697,7 @@ void SV_PlayerPhysics()
        else if(self.specialcommand_pos && (c != substring(specialcommand, self.specialcommand_pos - 1, 1)))
                self.specialcommand_pos = 0;
 
-       if(!sv_maxidle_spectatorsareidle || self.movetype == MOVETYPE_WALK)
+       if(sv_maxidle > 0)
        {
                if(buttons != self.buttons_old || self.movement != self.movement_old || self.v_angle != self.v_angle_old)
                        self.parm_idlesince = time;
@@ -812,7 +741,7 @@ void SV_PlayerPhysics()
                        self.punchvector = '0 0 0';
        }
 
-       if (clienttype(self) == CLIENTTYPE_BOT)
+       if (IS_BOT_CLIENT(self))
        {
                if(playerdemo_read())
                        return;
@@ -821,7 +750,7 @@ void SV_PlayerPhysics()
        
        self.items &~= IT_USING_JETPACK;
 
-       if(self.classname == "player")
+       if(IS_PLAYER(self))
        {
                if(self.race_penalty)
                        if(time > self.race_penalty)
@@ -875,7 +804,7 @@ void SV_PlayerPhysics()
        if(self.conveyor.state)
                self.velocity -= self.conveyor.movedir;
 
-       if(self.classname != "player")
+       if not(IS_PLAYER(self))
        {
                maxspd_mod = autocvar_sv_spectator_speed_multiplier;
                if(!self.spectatorspeed)
@@ -924,7 +853,7 @@ void SV_PlayerPhysics()
        }
 
        if(self.flags & FL_ONGROUND)
-       if(self.classname == "player") // no fall sounds for observers thank you very much
+       if(IS_PLAYER(self)) // no fall sounds for observers thank you very much
        if(self.wasFlying)
        {
                self.wasFlying = 0;
@@ -949,7 +878,7 @@ void SV_PlayerPhysics()
        if(IsFlying(self))
                self.wasFlying = 1;
 
-       if(self.classname == "player")
+       if(IS_PLAYER(self))
                CheckPlayerJump();
 
        if (self.flags & FL_WATERJUMP )
@@ -962,7 +891,7 @@ void SV_PlayerPhysics()
                        self.teleport_time = 0;
                }
        }
-       else if (g_bugrigs && self.classname == "player")
+       else if (g_bugrigs && IS_PLAYER(self))
        {
                RaceCarPhysics();
        }
@@ -1314,7 +1243,7 @@ void SV_PlayerPhysics()
                }
        }
 
-       if((g_cts || g_race) && self.classname != "observer") {
+       if((g_cts || g_race) && !IS_OBSERVER(self)) {
                if(vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed) {
                        speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1');
                        speedaward_holder = self.netname;