]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'TimePath/features/jetpack_jump' into 'master'
authorMario <zacjardine@y7mail.com>
Wed, 24 Dec 2014 04:28:57 +0000 (04:28 +0000)
committerMario <zacjardine@y7mail.com>
Wed, 24 Dec 2014 04:28:57 +0000 (04:28 +0000)
Jetpack Jump

Changes the jetpack to be activated by jumping again in the air, this is much more natural.
Also allows the hook to be used at the same time.

See merge request !59

19 files changed:
defaultXonotic.cfg
keybinds.txt
keybinds.txt.de
keybinds.txt.es
keybinds.txt.fr
keybinds.txt.hu
keybinds.txt.it
keybinds.txt.ru
keybinds.txt.uk
qcsrc/common/weapons/w_hook.qc
qcsrc/menu/xonotic/dialog_settings_input.c
qcsrc/server/cl_client.qc
qcsrc/server/cl_physics.qc
qcsrc/server/defs.qh
qcsrc/server/g_hook.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator_multijump.qc
qcsrc/server/mutators/mutator_nades.qc
qcsrc/server/t_items.qc

index 7984a29d63082b767c7f5121c41031035201198d..cbb8014bc0a0983e99e5fb943c746e09d73e76ee 100644 (file)
@@ -34,6 +34,8 @@ seta g_configversion 0        "Configuration file version (used to upgrade settings) 0:
 // other aliases
 alias +hook +button6
 alias -hook -button6
+alias +jetpack +button10
+alias -jetpack -button10
 alias use "impulse 21"
 
 // for backwards compatibility
@@ -1026,6 +1028,8 @@ seta cl_clippedspectating 1 "movement collision for spectators so that you can't
 
 seta cl_autoscreenshot 1 "Take a screenshot upon the end of a match... 0 = Disable completely, 1 = Allow sv_autoscreenshot to take a screenshot when requested, 2 = Always take an autoscreenshot anyway."
 
+seta cl_jetpack_jump 1 "Activate jetpack by pressing jump in the air. 0 = Disable, 1 = Stop when touching ground, 2 = Enable"
+
 // must be at the bottom of this file:
 
 set g_bugrigs 0
@@ -1087,7 +1091,7 @@ seta cl_gentle_gibs 0             "client side gentle mode (only replaces gibs); when set t
 seta cl_gentle_messages 0      "client side gentle mode (only replaces frag messages/centerprints)"
 seta cl_gentle_damage 0                "client side gentle mode (only replaces damage flash); when set to 1, a white flash replaces the blood image, when set to 2, a randomily colored flash is used instead"
 
-set g_jetpack 0 "Jetpack mutator (uses the hook's button, can't coexist with the offhand hook, but only with the onhand one)"
+set g_jetpack 0 "Jetpack mutator"
 
 set g_running_guns 0 "... or wonder, till it drives you mad, what would have followed if you had."
 set g_bastet 0 "don't try"
index 0458a548f06839238c17ee38cb0484d04b48a118..189d02eb4ddf0135ab0ed9ededd38db602495949 100644 (file)
@@ -5,7 +5,8 @@
 "+moveright"                            "strafe right"
 "+jump"                                 "jump / swim"
 "+crouch"                               "crouch / sink"
-"+hook"                                 "off-hand hook / jet pack"
+"+hook"                                 "off-hand hook"
+"+jetpack"                              "jet pack"
 ""                                      ""
 ""                                      "Attacking"
 "+fire"                                 "primary fire"
index 9a6d9e98272e3214c8e8bdb86fef39f2f169c5fa..0c2aaf2b18a85cf0d3385ef1e355c667c532869c 100644 (file)
@@ -5,7 +5,8 @@
 "+moveright"                            "rechts"
 "+jump"                                 "springen / schwimmen"
 "+crouch"                               "ducken / sinken"
-"+hook"                                 "Enterhaken / Jetpack"
+"+hook"                                 "Enterhaken"
+"+jetpack"                              "Jetpack"
 ""                                      ""
 ""                                      "Angriff"
 "+fire"                                 "1. Feuermodus"
index e7c2fd7441fe7f83624dde0475565684be997ed5..51d9bfc390374ef73cf0f145e93fc37097119e3a 100644 (file)
@@ -5,7 +5,8 @@
 "+moveright"                            "derecha"
 "+jump"                                 "saltar / nadar"
 "+crouch"                               "agacharse / bajar"
-"+hook"                                 "gancho / jet pack"
+"+hook"                                 "gancho"
+"+jetpack"                              "jet pack"
 ""                                      ""
 ""                                      "Ataque"
 "+fire"                                 "ataque primario"
index 2dfd6cd4a07f0063d298179dc40759c1bd9a812d..15a21f01e6df33a4a60eb24c093c437f7c40729e 100644 (file)
@@ -5,7 +5,8 @@
 "+moveright"                            "droite"
 "+jump"                                 "sauter / nager"
 "+crouch"                               "s'accroupir / couler"
-"+hook"                                 "grappin / jet pack"
+"+hook"                                 "grappin"
+"+jetpack"                              "jet pack"
 ""                                      ""
 ""                                      "Attaque"
 "+fire"                                 "tir primaire"
index 53bd46c14341b30d194beba4c6abe1c168f5b7a8..3ae11f77f76281a331557c0e3e82f45af21e304b 100644 (file)
@@ -5,7 +5,8 @@
 "+moveright"                            "jobbra lépés"
 "+jump"                                 "ugrás / úszás"
 "+crouch"                               "guggolás / süllyedés"
-"+hook"                                 "kézi kampó / rakéta puttony"
+"+hook"                                 "kézi kampó"
+"+jetpack"                              "rakéta puttony"
 ""                                      ""
 ""                                      "Tüzelés"
 "+fire"                                 "Elsődleges"
index 8546bdbe8f1c5d74e26857acb08b78f34b65e873..a01a9731baa6f4ddbd2e52629f44c268c3174f71 100644 (file)
@@ -5,7 +5,8 @@
 "+moveright"                            "a destra"
 "+jump"                                 "salta / risalire in acqua"
 "+crouch"                               "abbassarsi / scendere in acqua"
-"+hook"                                 "off-hand hook / jet pack"
+"+hook"                                 "off-hand hook"
+"+jetpack"                              "jet pack"
 ""                                      ""
 ""                                      "Attacco"
 "+fire"                                 "fuoco primario"
index 3ca70768e26591c49b5ce8787cd9ae9783cb6608..7ab93ff8ff7823cea577dd12a1600fa82d8292c2 100644 (file)
@@ -5,7 +5,8 @@
 "+moveright"                            "вправо"
 "+jump"                                 "прыжок / плыть"
 "+crouch"                               "пригнуться / погрузиться"
-"+hook"                                 "крюк / реактивный ранец"
+"+hook"                                 "крюк"
+"+jetpack"                              "реактивный ранец"
 ""                                      ""
 ""                                      "Нападение"
 "+fire"                                 "основной огонь"
index 8fc522a82d4840c706ae2423c22dac800e6d7929..07812dee8ea5e15efb67bb1d909835666d898275 100644 (file)
@@ -5,7 +5,8 @@
 "+moveright"                            "крок праворуч"
 "+jump"                                 "стрибок / плисти нагору"
 "+crouch"                               "присідання / занурення"
-"+hook"                                 "гак / реактивний ранець"
+"+hook"                                 "гак"
+"+jetpack"                              "реактивний ранець"
 ""                                      ""
 ""                                      "Бій"
 "+fire"                                 "основний вогонь"
index 931d3e0ad17b13b7e0641f35026e097bea0265ef..3713ca9c75c417fe91dddbd2f3b44d0fc24e696e 100644 (file)
@@ -186,7 +186,7 @@ float W_Hook(float req)
                }
                case WR_THINK:
                {
-                       if(self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
+                       if(self.BUTTON_ATCK || self.BUTTON_HOOK)
                        {
                                if(!self.hook)
                                if(!(self.hook_state & HOOK_WAITING_FOR_RELEASE))
@@ -260,7 +260,7 @@ float W_Hook(float req)
                        if(self.BUTTON_CROUCH)
                        {
                                self.hook_state &= ~HOOK_PULLING;
-                               if(self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
+                               if(self.BUTTON_ATCK || self.BUTTON_HOOK)
                                        self.hook_state &= ~HOOK_RELEASING;
                                else
                                        self.hook_state |= HOOK_RELEASING;
@@ -270,7 +270,7 @@ float W_Hook(float req)
                                self.hook_state |= HOOK_PULLING;
                                self.hook_state &= ~HOOK_RELEASING;
 
-                               if(self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
+                               if(self.BUTTON_ATCK || self.BUTTON_HOOK)
                                {
                                        // already fired
                                        if(self.hook)
index 8b68c6582f808ba30c036d487cba5c44bdb42d2a..57b6cef630d6e171bb2c31441b26a88338049b02 100644 (file)
@@ -89,6 +89,13 @@ void XonoticInputSettingsTab_fill(entity me)
                me.TD(me, 1, 3, e = makeXonoticCheckBox(1, "cl_movement_track_canjump", _("Automatically repeat jumping if holding jump")));
                        e.sendCvars = TRUE;
        me.TR(me);
+               me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Jetpack on jump:")));
+               me.TD(me, 1, 2, e = makeXonoticTextSlider("cl_jetpack_jump"));
+                       e.addValue(e, _("Disabled"), "0");
+                       e.addValue(e, _("Air only"), "1");
+                       e.addValue(e, _("All"), "2");
+                       e.configureXonoticTextSliderValues(e);
+                       e.sendCvars = TRUE;
        me.TR(me);
                if(cvar_type("joy_enable") & CVAR_TYPEFLAG_ENGINE)
                {
index be379590aadb2fe23792509bdc46ef877d8bc8bc..01092c886fd1fb97fe58ec8bfa716367964315ac 100644 (file)
@@ -1140,6 +1140,10 @@ void ClientConnect (void)
        // Wazat's grappling hook
        SetGrappleHookBindings();
 
+       // Jetpack binds
+       stuffcmd(self, "alias +jetpack +button10\n");
+       stuffcmd(self, "alias -jetpack -button10\n");
+
        // get version info from player
        stuffcmd(self, "cmd clientversion $gameversion\n");
 
index 08f9dee9562f5c9d91c382236f3f0ea56e84e0bf..900f65bc8ab3dcbbe698f23ab906e7b5320f7601 100644 (file)
 PlayerJump
 
 When you press the jump key
+returns TRUE if handled
 =============
 */
-void PlayerJump (void)
+float PlayerJump (void)
 {
        if(self.frozen)
-               return; // no jumping in freezetag when frozen
+               return TRUE; // no jumping in freezetag when frozen
 
        if(self.player_blocked)
-               return; // no jumping while blocked
+               return TRUE; // no jumping while blocked
 
        float doublejump = FALSE;
        float mjumpheight = autocvar_sv_jumpvelocity;
@@ -31,7 +32,7 @@ void PlayerJump (void)
        player_multijump = doublejump;
        player_jumpheight = mjumpheight;
        if(MUTATOR_CALLHOOK(PlayerJump))
-               return;
+               return TRUE;
 
        doublejump = player_multijump;
        mjumpheight = player_jumpheight;
@@ -54,16 +55,16 @@ void PlayerJump (void)
        if (self.waterlevel >= WATERLEVEL_SWIMMING)
        {
                self.velocity_z = self.stat_sv_maxspeed * 0.7;
-               return;
+               return TRUE;
        }
 
        if (!doublejump)
                if (!(self.flags & FL_ONGROUND))
-                       return;
+                       return !(self.flags & FL_JUMPRELEASED);
 
        if(self.cvar_cl_movement_track_canjump)
                if (!(self.flags & FL_JUMPRELEASED))
-                       return;
+                       return TRUE;
 
        // sv_jumpspeedcap_min/sv_jumpspeedcap_max act as baseline
        // velocity bounds.  Final velocity is bound between (jumpheight *
@@ -122,6 +123,7 @@ void PlayerJump (void)
 
        self.restart_jump = -1; // restart jump anim next time
        // value -1 is used to not use the teleport bit (workaround for tiny hitch when re-jumping)
+       return TRUE;
 }
 void CheckWaterJump()
 {
@@ -151,11 +153,41 @@ void CheckWaterJump()
                }
        }
 }
+
+.float jetpack_stopped;
+// Hack: shouldn't need to know about this
+.float multijump_count;
 void CheckPlayerJump()
 {
-       if (self.BUTTON_JUMP)
-               PlayerJump ();
+       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)
+       {
+               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.jetpack_stopped) { }
+               else if (!has_fuel)
+               {
+                       if (was_flying) // TODO: ran out of fuel message
+                               Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL);
+                       else
+                               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
+       {
+               self.jetpack_stopped = FALSE;
+               self.items &= ~IT_USING_JETPACK;
+       }
+       if (!self.BUTTON_JUMP)
                self.flags |= FL_JUMPRELEASED;
 
        if (self.waterlevel == WATERLEVEL_SWIMMING)
@@ -752,8 +784,6 @@ void SV_PlayerPhysics()
                bot_think();
        }
 
-       self.items &= ~IT_USING_JETPACK;
-
        if(IS_PLAYER(self))
        {
                if(self.race_penalty)
@@ -1018,7 +1048,7 @@ void SV_PlayerPhysics()
                        PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0, 0);
                }
        }
-       else if ((self.items & IT_JETPACK) && self.BUTTON_HOOK && (!autocvar_g_jetpack_fuel || self.ammo_fuel >= 0.01 || self.items & IT_UNLIMITED_WEAPON_AMMO) && !self.frozen)
+       else if (self.items & IT_USING_JETPACK)
        {
                //makevectors(self.v_angle_y * '0 1 0');
                makevectors(self.v_angle);
index 647030620b52cd5d470fcb67445d50da91850bae..757ee65e2799449c1afd71e68aaf2339596faada 100644 (file)
@@ -13,6 +13,7 @@ noref float require_spawnfunc_prefix; // if this float exists, only functions wi
 #define BUTTON_USE        buttonuse
 #define BUTTON_DRAG       button8
 #define BUTTON_ZOOMSCRIPT button9
+#define BUTTON_JETPACK    button10
 
 // Globals
 
@@ -260,6 +261,7 @@ float default_weapon_alpha;
 .float cvar_cl_handicap;
 .float cvar_cl_clippedspectating;
 .float cvar_cl_autoscreenshot;
+.float cvar_cl_jetpack_jump;
 .float cvar_cl_movement_track_canjump;
 .float cvar_cl_newusekeysupported;
 
index 90b91ad3d0880158f339c8c344e9985a4688592f..eab482618bc3833d47cd74250cd706fbf827063b 100644 (file)
@@ -407,7 +407,7 @@ void GrapplingHookFrame()
                        //self.hook_state &= ~HOOK_RELEASING;
                }
        }
-       else if(!(self.items & IT_JETPACK) && !g_grappling_hook && self.switchweapon != WEP_HOOK)
+       else if(!g_grappling_hook && self.switchweapon != WEP_HOOK)
        {
                if(self.BUTTON_HOOK && !self.hook_switchweapon)
                        W_SwitchWeapon(WEP_HOOK);
index 9090f6922d83b42600d4baf10085f1a7bb05e4db..e6fda399e27eb0427e90a241964f623843a54feb 100644 (file)
@@ -489,6 +489,7 @@ void GetCvars(float f)
 
        GetCvars_handleFloat(s, f, autoswitch, "cl_autoswitch");
        GetCvars_handleFloat(s, f, cvar_cl_autoscreenshot, "cl_autoscreenshot");
+       GetCvars_handleFloat(s, f, cvar_cl_jetpack_jump, "cl_jetpack_jump");
        GetCvars_handleString(s, f, cvar_g_xonoticversion, "g_xonoticversion");
        GetCvars_handleFloat(s, f, cvar_cl_handicap, "cl_handicap");
        GetCvars_handleFloat(s, f, cvar_cl_clippedspectating, "cl_clippedspectating");
@@ -862,7 +863,6 @@ void readplayerstartcvars()
 
        if ((start_items & IT_JETPACK) || (g_grappling_hook && (start_weapons & WEPSET_HOOK)))
        {
-               g_grappling_hook = 0; // these two can't coexist, as they use the same button
                start_items |= IT_FUEL_REGEN;
                start_ammo_fuel = max(start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
                warmup_start_ammo_fuel = max(warmup_start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
index 50741dc20b4f3cadd1d2d75ff1b0ce1f5180a4c5..868ddf246e0b5f0c88c93e7b594e412238110df7 100644 (file)
@@ -4,12 +4,7 @@
 MUTATOR_HOOKFUNCTION(multijump_PlayerPhysics)
 {
        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
-       }
+               self.multijump_count = 0;
 
        return FALSE;
 }
@@ -21,7 +16,7 @@ MUTATOR_HOOKFUNCTION(multijump_PlayerJump)
        else
                self.multijump_ready = FALSE;
 
-       if(!player_multijump && self.multijump_ready && self.multijump_count < autocvar_g_multijump && self.velocity_z > autocvar_g_multijump_speed)
+       if(!player_multijump && self.multijump_ready && (autocvar_g_multijump == -1 || self.multijump_count < autocvar_g_multijump) && self.velocity_z > autocvar_g_multijump_speed)
        {
                if (autocvar_g_multijump)
                {
@@ -55,8 +50,7 @@ MUTATOR_HOOKFUNCTION(multijump_PlayerJump)
                                        self.velocity_y = wishdir_y * curspeed;
                                        // keep velocity_z unchanged!
                                }
-                               if (autocvar_g_multijump > 0)
-                                       self.multijump_count += 1;
+                               self.multijump_count += 1;
                        }
                }
                self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump
index 04794ec6b021c8d8ab695b3519c8ce89d3f893f2..91bd53e5aa070d93b78c5e43f289e56aba4c8a6d 100644 (file)
@@ -910,8 +910,8 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink)
        float key_pressed = self.BUTTON_HOOK;
        float time_score;
 
-       if(g_grappling_hook || client_hasweapon(self, WEP_HOOK, FALSE, FALSE) || (weaponsInMap & WEPSET_HOOK) || g_jetpack || self.items & IT_JETPACK)
-               key_pressed = self.button16; // if hook/jetpack is enabled, use an alternate key
+       if(g_grappling_hook || client_hasweapon(self, WEP_HOOK, FALSE, FALSE) || (weaponsInMap & WEPSET_HOOK))
+               key_pressed = self.button16; // if hook is enabled, use an alternate key
                
        if(self.nade)
        {
index 8d705b363f8c72c84c20ce3d4a3b81f70608d4bf..4455d3fb46a3128ecf541c8d4558286341eb8a4e 100644 (file)
@@ -1458,8 +1458,6 @@ void spawnfunc_item_fuel_regen(void)
 
 void spawnfunc_item_jetpack(void)
 {
-       if(g_grappling_hook)
-               return; // sorry, but these two can't coexist (same button); spawn fuel instead
        if(!self.ammo_fuel)
                self.ammo_fuel = g_pickup_fuel_jetpack;
        if(start_items & IT_JETPACK)