From 0e79a85ce35a801d2389dff7cf7734849ae18bb7 Mon Sep 17 00:00:00 2001 From: div0 Date: Wed, 17 Dec 2008 13:34:06 +0000 Subject: [PATCH] - only complain about ONE missing weapon; - g_showweaponspawns (feature you know from the OTLD servers) git-svn-id: svn://svn.icculus.org/nexuiz/trunk@5249 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/defaultNexuiz.cfg | 2 ++ data/qcsrc/server/cl_weapons.qc | 20 ++++++++++++++++---- data/qcsrc/server/cl_weaponsystem.qc | 26 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/data/defaultNexuiz.cfg b/data/defaultNexuiz.cfg index 93613d6a3..1a490385c 100644 --- a/data/defaultNexuiz.cfg +++ b/data/defaultNexuiz.cfg @@ -1241,4 +1241,6 @@ set g_ban_sync_trusted_servers "" // request ban lists from these nexuiz servers set g_ban_sync_timeout 45 // time out in seconds for the ban sync requests set g_ban_sync_trusted_servers_verify 0 // when set to 1, additional bans sent by the servers are ignored, and only bans for the requested IP are used +set g_showweaponspawns 0 // 1: display sprites for weapon spawns found on the map when a weapon key is pressed and the weapon is not available + alias records "cmd records" diff --git a/data/qcsrc/server/cl_weapons.qc b/data/qcsrc/server/cl_weapons.qc index a9ad1f165..fddb6307a 100644 --- a/data/qcsrc/server/cl_weapons.qc +++ b/data/qcsrc/server/cl_weapons.qc @@ -6,9 +6,10 @@ void W_SwitchWeapon(float imp) W_SwitchWeapon_Force(self, imp); }; +.float weaponcomplainindex; float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain) { - float n, i, weaponwant, first_valid, prev_valid, switchtonext, switchtolast; + float n, i, weaponwant, first_valid, prev_valid, switchtonext, switchtolast, c; n = tokenize_sane(weaponorder); switchtonext = switchtolast = 0; first_valid = prev_valid = 0; @@ -16,14 +17,17 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa if(dir == 0) switchtonext = 1; + c = 0; + for(i = 0; i < n; ++i) { weaponwant = stof(argv(i)); - if(imp >= 0) if((get_weaponinfo(weaponwant)).impulse != imp) continue; + ++c; + if(client_hasweapon(pl, weaponwant, TRUE, FALSE)) { if(switchtonext) @@ -49,16 +53,24 @@ float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, floa else return first_valid; } - // complain + // complain (but only for one weapon on the button that has been pressed) if(complain) { + self.weaponcomplainindex += 1; + c = mod(self.weaponcomplainindex, c) + 1; for(i = 0; i < n; ++i) { weaponwant = stof(argv(i)); if(imp >= 0) if((get_weaponinfo(weaponwant)).impulse != imp) continue; - client_hasweapon(pl, weaponwant, TRUE, TRUE); + + --c; + if(c == 0) + { + client_hasweapon(pl, weaponwant, TRUE, TRUE); + break; + } } } return 0; diff --git a/data/qcsrc/server/cl_weaponsystem.qc b/data/qcsrc/server/cl_weaponsystem.qc index 922ab6112..9f62d2394 100644 --- a/data/qcsrc/server/cl_weaponsystem.qc +++ b/data/qcsrc/server/cl_weaponsystem.qc @@ -415,7 +415,33 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) // DRESK - 3/16/07 // Report Proper Weapon Status / Modified Weapon Ownership Message if(weaponsInMap & weaponbit) + { sprint(cl, strcat("You do not have the ^2", W_Name(wpn), "\n") ); + + entity e; + string s; + + if(cvar("g_showweaponspawns")) + { + e = get_weaponinfo(wpn); + s = strcat("wpn-", e.mdl); + for(e = world; (e = findfloat(e, weapons, weaponbit)); ) + { + if(e.classname == "droppedweapon") + continue; + if not(e.flags & FL_ITEM) + continue; + WaypointSprite_Spawn( + s, + 1, 0, + world, e.origin, + self, 0, + world, enemy, + 0 + ); + } + } + } else sprint(cl, strcat("The ^2", W_Name(wpn), "^7 is ^1NOT AVAILABLE^7 in this map\n") ); } -- 2.39.2