From 5bc7426b855caca10ec0c9fdf1f60f39df636190 Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Sun, 19 Mar 2017 19:19:41 +0000 Subject: [PATCH] Cvar to control for how long a dropped weapon stays alive --- defaultXonotic.cfg | 1 + qcsrc/server/autocvars.qh | 1 + qcsrc/server/weapons/throwing.qc | 19 +++++++++++-------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index be25fe0dc..7a86aa9d2 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -428,6 +428,7 @@ set g_shootfromfixedorigin "" "if set to a string like 0 y z, the gun is moved t set g_pinata 0 "if set to 1 you will not only drop your current weapon when you are killed, but you will drop all weapons that you possessed" set g_weapon_stay 0 "1: ghost weapons can be picked up too but give no ammo, 2: ghost weapons refill ammo to one pickup size, thrown guns have no ammo" set g_weapon_throwable 1 "if set to 1, weapons can be dropped" +set g_weapon_throw_lifetime 20 "time a dropped weapon should stay alive, -1 for infinite time" set g_powerups -1 "if set to 0 the strength and shield (invincibility) will not spawn on the map, if 1 they will spawn in all game modes, -1 is game mode default" set g_use_ammunition 1 "if set to 0 all weapons have unlimited ammunition" set g_pickup_items -1 "if set to 0 all items (health, armor, ammo, weapons...) are removed from the map, if 1 they are forced to spawn" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 8f397397f..f137d3241 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -249,6 +249,7 @@ vector autocvar_g_waypointeditor_symmetrical_center; bool autocvar_g_waypoints_for_items; #define autocvar_g_weapon_stay cvar("g_weapon_stay") bool autocvar_g_weapon_throwable; +int autocvar_g_weapon_throw_lifetime; #define autocvar_g_weaponarena cvar_string("g_weaponarena") string autocvar_g_xonoticversion; float autocvar_gameversion; diff --git a/qcsrc/server/weapons/throwing.qc b/qcsrc/server/weapons/throwing.qc index 53e68d9eb..d3c7b1c7d 100644 --- a/qcsrc/server/weapons/throwing.qc +++ b/qcsrc/server/weapons/throwing.qc @@ -22,13 +22,16 @@ void thrown_wep_think(entity this) this.oldorigin = this.origin; } this.owner = NULL; - float timeleft = this.savenextthink - time; - if(timeleft > 1) - SUB_SetFade(this, this.savenextthink - 1, 1); - else if(timeleft > 0) - SUB_SetFade(this, time, timeleft); - else - SUB_VanishOrRemove(this); + if ( autocvar_g_weapon_throw_lifetime >= 0 ) + { + float timeleft = this.savenextthink - time; + if(timeleft > 1) + SUB_SetFade(this, this.savenextthink - 1, 1); + else if(timeleft > 0) + SUB_SetFade(this, time, timeleft); + else + SUB_VanishOrRemove(this); + } } // returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count @@ -83,7 +86,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto if(startitem_failed) return string_null; setthink(wep, thrown_wep_think); - wep.savenextthink = wep.nextthink; + wep.savenextthink = time + autocvar_g_weapon_throw_lifetime; wep.nextthink = min(wep.nextthink, time + 0.5); wep.pickup_anyway = true; // these are ALWAYS pickable -- 2.39.2