From: TimePath Date: Wed, 17 Dec 2014 09:03:49 +0000 (+1100) Subject: Change jetpack to activate when pressing jump in the air X-Git-Tag: xonotic-v0.8.0~52^2~9 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=839904ff3a80b181dfce46615c8e1d0cddb8772d;p=xonotic%2Fxonotic-data.pk3dir.git Change jetpack to activate when pressing jump in the air --- diff --git a/qcsrc/common/weapons/w_hook.qc b/qcsrc/common/weapons/w_hook.qc index 931d3e0ad..3713ca9c7 100644 --- a/qcsrc/common/weapons/w_hook.qc +++ b/qcsrc/common/weapons/w_hook.qc @@ -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) diff --git a/qcsrc/server/cl_physics.qc b/qcsrc/server/cl_physics.qc index 1d4753660..9d67174d2 100644 --- a/qcsrc/server/cl_physics.qc +++ b/qcsrc/server/cl_physics.qc @@ -15,15 +15,16 @@ 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,13 +153,23 @@ void CheckWaterJump() } } } + +// Hack: shouldn't need to know about this +.float multijump_count; void CheckPlayerJump() { if (self.BUTTON_JUMP) - PlayerJump (); + { + if (!PlayerJump() || self.multijump_count > 0) + { + self.items |= IT_USING_JETPACK; + } + } else + { self.flags |= FL_JUMPRELEASED; - + self.items &= ~IT_USING_JETPACK; + } if (self.waterlevel == WATERLEVEL_SWIMMING) CheckWaterJump (); } @@ -1018,7 +1030,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) && (!autocvar_g_jetpack_fuel || self.ammo_fuel >= 0.01 || self.items & IT_UNLIMITED_WEAPON_AMMO) && !self.frozen) { //makevectors(self.v_angle_y * '0 1 0'); makevectors(self.v_angle); @@ -1119,7 +1131,7 @@ 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) + if((self.items & IT_USING_JETPACK) && !(buttons_prev & 2) && self.ammo_fuel < 0.01) sprint(self, "You don't have any fuel for the ^2Jetpack\n"); // walking @@ -1188,7 +1200,7 @@ void SV_PlayerPhysics() { 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) + if((self.items & IT_USING_JETPACK) && !(buttons_prev & 2) && self.ammo_fuel < 0.01) sprint(self, "You don't have any fuel for the ^2Jetpack\n"); if(maxspd_mod < 1) diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc index 90b91ad3d..eab482618 100644 --- a/qcsrc/server/g_hook.qc +++ b/qcsrc/server/g_hook.qc @@ -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); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 71294f194..7eec95d03 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -862,7 +862,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")); diff --git a/qcsrc/server/mutators/mutator_multijump.qc b/qcsrc/server/mutators/mutator_multijump.qc index 50741dc20..868ddf246 100644 --- a/qcsrc/server/mutators/mutator_multijump.qc +++ b/qcsrc/server/mutators/mutator_multijump.qc @@ -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 diff --git a/qcsrc/server/mutators/mutator_nades.qc b/qcsrc/server/mutators/mutator_nades.qc index 70c4578bd..ef66e7136 100644 --- a/qcsrc/server/mutators/mutator_nades.qc +++ b/qcsrc/server/mutators/mutator_nades.qc @@ -873,8 +873,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) {