From: Rudolf Polzer Date: Mon, 29 Mar 2010 10:13:43 +0000 (+0200) Subject: cl_weaponimpulsemode: customize the way weapon switching is done when you do not... X-Git-Tag: xonotic-v0.1.0preview~672 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=89d9f2541917bb026c3139139e064f90fbef24dd;p=xonotic%2Fxonotic-data.pk3dir.git cl_weaponimpulsemode: customize the way weapon switching is done when you do not have a certain gun --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index b432c6c59..e524d3a74 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1479,6 +1479,7 @@ seta cl_weaponpriority6 "" "use impulse 206 for prev gun from this list, 216 for seta cl_weaponpriority7 "" "use impulse 207 for prev gun from this list, 217 for best gun, 227 for next gun" seta cl_weaponpriority8 "" "use impulse 208 for prev gun from this list, 218 for best gun, 228 for next gun" seta cl_weaponpriority9 "" "use impulse 209 for prev gun from this list, 219 for best gun, 229 for next gun" +seta cl_weaponimpulsemode 0 "0: only cycle between currently usable weapons in weapon priority order; 1: cycle between all possible weapons on a key in weapon priority order" seta sv_status_privacy 1 "hide IP addresses from \"status\" replies shown to clients" diff --git a/qcsrc/server/cl_weapons.qc b/qcsrc/server/cl_weapons.qc index 788a67e51..b5e245db6 100644 --- a/qcsrc/server/cl_weapons.qc +++ b/qcsrc/server/cl_weapons.qc @@ -12,6 +12,8 @@ void W_SwitchWeapon(float imp) { if (client_hasweapon(self, imp, TRUE, TRUE)) W_SwitchWeapon_Force(self, imp); + else + self.selectweapon = imp; // update selectweapon ANYWAY } else { @@ -20,7 +22,7 @@ void W_SwitchWeapon(float imp) }; .float weaponcomplainindex; -float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain) +float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain, float skipmissing) { // We cannot tokenize in this function, as GiveItems calls this // function. Thus we must use car/cdr. @@ -28,6 +30,12 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa string rest; switchtonext = switchtolast = 0; first_valid = prev_valid = 0; + float weaponcur; + + if(skipmissing || pl.selectweapon == 0) + weaponcur = pl.switchweapon; + else + weaponcur = pl.selectweapon; if(dir == 0) switchtonext = 1; @@ -44,13 +52,13 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa ++c; - if(client_hasweapon(pl, weaponwant, TRUE, FALSE)) + if(!skipmissing || client_hasweapon(pl, weaponwant, TRUE, FALSE)) { if(switchtonext) return weaponwant; if(!first_valid) first_valid = weaponwant; - if(weaponwant == pl.switchweapon) + if(weaponwant == weaponcur) { if(dir >= 0) switchtonext = 1; @@ -96,7 +104,7 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa void W_CycleWeapon(string weaponorder, float dir) { float w; - w = W_GetCycleWeapon(self, weaponorder, dir, -1, 1); + w = W_GetCycleWeapon(self, weaponorder, dir, -1, 1, TRUE); if(w > 0) W_SwitchWeapon(w); } @@ -104,7 +112,7 @@ void W_CycleWeapon(string weaponorder, float dir) void W_NextWeaponOnImpulse(float imp) { float w; - w = W_GetCycleWeapon(self, self.cvar_cl_weaponpriority, +1, imp, 1); + w = W_GetCycleWeapon(self, self.cvar_cl_weaponpriority, +1, imp, 1, (self.cvar_cl_weaponimpulsemode == 0)); if(w > 0) W_SwitchWeapon(w); } @@ -145,7 +153,7 @@ string W_FixWeaponOrder_ForceComplete(string order) float w_getbestweapon(entity e) { - return W_GetCycleWeapon(e, e.cvar_cl_weaponpriority, 0, -1, 0); + return W_GetCycleWeapon(e, e.cvar_cl_weaponpriority, 0, -1, FALSE, TRUE); }; // generic weapons table diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index e7bfc69d0..f1e9bf70e 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -36,6 +36,7 @@ void W_SwitchWeapon_Force(entity e, float w) { e.cnt = e.switchweapon; e.switchweapon = w; + e.selectweapon = w; } .float antilag_debug; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index e80025a67..7fa0b1771 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -637,3 +637,6 @@ string deathmessage; .float cvar_cl_accuracy_data_share; .float cvar_cl_accuracy_data_receive; + +.float cvar_cl_weaponimpulsemode; +.float selectweapon; // last selected weapon of the player diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 479a69106..7aa9166cf 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -617,6 +617,7 @@ void GetCvars(float f) GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[7], "cl_weaponpriority7", W_FixWeaponOrder_AllowIncomplete); GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[8], "cl_weaponpriority8", W_FixWeaponOrder_AllowIncomplete); GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[9], "cl_weaponpriority9", W_FixWeaponOrder_AllowIncomplete); + GetCvars_handleFloat(s, f, cvar_cl_weaponimpulsemode, "cl_weaponimpulsemode"); GetCvars_handleFloat(s, f, cvar_cl_autotaunt, "cl_autotaunt"); GetCvars_handleFloat(s, f, cvar_cl_noantilag, "cl_noantilag"); GetCvars_handleFloat(s, f, cvar_cl_voice_directional, "cl_voice_directional");