Commit 3e0fddda authored by Mario's avatar Mario

Merge branch 'TimePath/features/jetpack_jump' into 'master'

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
parents 73266281 0986191f
......@@ -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"
......
......@@ -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"
......
......@@ -5,7 +5,8 @@
"+moveright" "rechts"
"+jump" "springen / schwimmen"
"+crouch" "ducken / sinken"
"+hook" "Enterhaken / Jetpack"
"+hook" "Enterhaken"
"+jetpack" "Jetpack"
"" ""
"" "Angriff"
"+fire" "1. Feuermodus"
......
......@@ -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"
......
......@@ -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"
......
......@@ -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"
......
......@@ -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"
......
......@@ -5,7 +5,8 @@
"+moveright" "вправо"
"+jump" "прыжок / плыть"
"+crouch" "пригнуться / погрузиться"
"+hook" "крюк / реактивный ранец"
"+hook" "крюк"
"+jetpack" "реактивный ранец"
"" ""
"" "Нападение"
"+fire" "основной огонь"
......
......@@ -5,7 +5,8 @@
"+moveright" "крок праворуч"
"+jump" "стрибок / плисти нагору"
"+crouch" "присідання / занурення"
"+hook" "гак / реактивний ранець"
"+hook" "гак"
"+jetpack" "реактивний ранець"
"" ""
"" "Бій"
"+fire" "основний вогонь"
......
......@@ -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)
......
......@@ -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)
{
......
......@@ -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");
......
......@@ -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,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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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"));
......
......@@ -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
......
......@@ -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)
{
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment