]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_physics.qc
Merge branch 'master' of ssh://gitlab.com/xonotic/xonotic-data.pk3dir into kickban...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_physics.qc
index 91c91476d245279d72271104370bafcd3666d3ca..fb283bb2a3a488b0bc8bc6d2ed627d7f6917c26a 100644 (file)
@@ -159,24 +159,29 @@ void CheckWaterJump()
 .float multijump_count;
 void CheckPlayerJump()
 {
+       float was_flying = self.items & IT_USING_JETPACK;
+
+       if (self.cvar_cl_jetpack_jump < 2)
+               self.items &= ~IT_USING_JETPACK;
+
        if (self.BUTTON_JUMP || self.BUTTON_JETPACK)
        {
-               if (self.BUTTON_JUMP && (!PlayerJump() || self.multijump_count > 0) || self.BUTTON_JETPACK)
+               float air_jump = !PlayerJump() || self.multijump_count > 0; // PlayerJump() has important side effects
+               float activate = self.cvar_cl_jetpack_jump && air_jump && self.BUTTON_JUMP || self.BUTTON_JETPACK;
+               float has_fuel = !autocvar_g_jetpack_fuel || self.ammo_fuel || self.items & IT_UNLIMITED_WEAPON_AMMO;
+               if (!(self.items & IT_JETPACK)) { }
+               else if (self.jetpack_stopped) { }
+               else if (!has_fuel)
                {
-                       if (self.cvar_cl_jetpack_jump || self.BUTTON_JETPACK)
-                       if (!self.jetpack_stopped && (!autocvar_g_jetpack_fuel || self.ammo_fuel > 0 || self.items & IT_UNLIMITED_WEAPON_AMMO) && !self.frozen)
-                       {
-                               self.items |= IT_USING_JETPACK;
-                       }
-                       else
-                       {
-                               // we get here if we ran out of ammo
-                               if (!self.jetpack_stopped)
-                                       sprint(self, "You don't have any fuel for the ^2Jetpack\n");
-                               self.jetpack_stopped = TRUE;
-                               self.items &= ~IT_USING_JETPACK;
-                       }
+                       if (was_flying) // TODO: ran out of fuel message
+                               Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL);
+                       else if (activate)
+                               Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL);
+                       self.jetpack_stopped = TRUE;
+                       self.items &= ~IT_USING_JETPACK;
                }
+               else if (activate && !self.frozen)
+                       self.items |= IT_USING_JETPACK;
        }
        else
        {
@@ -780,8 +785,6 @@ void SV_PlayerPhysics()
                bot_think();
        }
 
-       self.items &= ~IT_USING_JETPACK;
-
        if(IS_PLAYER(self))
        {
                if(self.race_penalty)
@@ -791,7 +794,6 @@ void SV_PlayerPhysics()
                not_allowed_to_move = 0;
                if(self.race_penalty)
                        not_allowed_to_move = 1;
-               if(!autocvar_sv_ready_restart_after_countdown)
                if(time < game_starttime)
                        not_allowed_to_move = 1;
 
@@ -1146,6 +1148,10 @@ void SV_PlayerPhysics()
        }
        else if (self.flags & FL_ONGROUND)
        {
+               // we get here if we ran out of ammo
+               if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && self.ammo_fuel < 0.01)
+                       Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL);
+
                // walking
                makevectors(self.v_angle_y * '0 1 0');
                wishvel = v_forward * self.movement_x + v_right * self.movement_y;
@@ -1211,6 +1217,9 @@ void SV_PlayerPhysics()
        else
        {
                float wishspeed0;
+               // we get here if we ran out of ammo
+               if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && self.ammo_fuel < 0.01)
+                       Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL);
 
                if(maxspd_mod < 1)
                {