X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_weapons.qc;h=477b641ba7e61d21ba7d28989827ccbe20a5ef8a;hb=4598f224d52aa8485c3ae0ecd40a12bc2cfbf8c8;hp=4a1281424e39eb8b51c993e3d6460318cf5b9f33;hpb=0e7ed909bffb4ff21f0c68d163edfc17487e380a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_weapons.qc b/qcsrc/server/cl_weapons.qc index 4a1281424..477b641ba 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); } @@ -113,9 +121,9 @@ void W_NextWeaponOnImpulse(float imp) void W_NextWeapon(float list) { if(list == 0) - W_CycleWeapon(weaponpriority_hudselector_0, -1); + W_CycleWeapon(weaponorder_byid, -1); else if(list == 1) - W_CycleWeapon(weaponpriority_hudselector_1, -1); + W_CycleWeapon(self.weaponorder_byimpulse, -1); else if(list == 2) W_CycleWeapon(self.cvar_cl_weaponpriority, -1); } @@ -124,28 +132,16 @@ void W_NextWeapon(float list) void W_PreviousWeapon(float list) { if(list == 0) - W_CycleWeapon(weaponpriority_hudselector_0, +1); + W_CycleWeapon(weaponorder_byid, +1); else if(list == 1) - W_CycleWeapon(weaponpriority_hudselector_1, +1); + W_CycleWeapon(self.weaponorder_byimpulse, +1); else if(list == 2) W_CycleWeapon(self.cvar_cl_weaponpriority, +1); } -string W_FixWeaponOrder_AllowIncomplete(string order) -{ - return W_FixWeaponOrder(order, 0); -} - -string W_FixWeaponOrder_ForceComplete(string order) -{ - if(order == "") - order = W_NumberWeaponOrder(cvar_string("cl_weaponpriority")); - return W_FixWeaponOrder(order, 1); -} - 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 @@ -267,12 +263,12 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce) w = self.weapon; if (w == 0) return; // just in case + if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon)) + return; if (g_weaponarena) return; if (g_lms) return; - if (g_nixnex) - return; if (g_nexball && w == WEP_GRENADE_LAUNCHER) return; if (!cvar("g_pickup_items")) @@ -285,6 +281,8 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce) return; if(!W_IsWeaponThrowable(w)) return; + if(self.deadflag == DEAD_NO && self.weaponentity.state != WS_READY) + return; wb = W_WeaponBit(w); if(self.weapons & wb != wb) @@ -375,7 +373,7 @@ void W_WeaponFrame() // server framerate is very low and the weapon fire rate very high local float c; c = 0; - while (c < 5) + while (c < W_TICSPERFRAME) { c = c + 1; if(wb && ((self.weapons & wb) == 0)) @@ -425,131 +423,3 @@ void W_WeaponFrame() self.currentammo = 1; #endif }; - -float nixnex_weapon; -float nixnex_weapon_ammo; -float nixnex_nextchange; -float nixnex_nextweapon; -float nixnex_nextweapon_ammo; -.float nixnex_lastchange_id; -.float nixnex_lastinfotime; -.float nixnex_nextincr; - -float NixNex_CanChooseWeapon(float wpn) -{ - entity e; - e = get_weaponinfo(wpn); - if(!e.weapons) // skip dummies - return FALSE; - if(g_weaponarena) - { - if not(g_weaponarena & e.weapons) - return FALSE; - } - else - { - if(wpn == WEP_LASER && g_nixnex_with_laser) - return FALSE; - if not(e.spawnflags & WEP_FLAG_NORMAL) - return FALSE; - } - return TRUE; -} -void Nixnex_ChooseNextWeapon() -{ - float j; - RandomSelection_Init(); - for(j = WEP_FIRST; j <= WEP_LAST; ++j) - if(NixNex_CanChooseWeapon(j)) - RandomSelection_Add(world, j, string_null, 1, (j != nixnex_weapon)); - nixnex_nextweapon = RandomSelection_chosen_float; - nixnex_nextweapon_ammo = W_AmmoItemCode(nixnex_nextweapon); -} - -void Nixnex_GiveCurrentWeapon() -{ - float dt; - if(g_nixnex) - { - if(!nixnex_nextweapon) - Nixnex_ChooseNextWeapon(); - - dt = ceil(nixnex_nextchange - time); - - if(dt <= 0) - { - nixnex_weapon = nixnex_nextweapon; - nixnex_weapon_ammo = nixnex_nextweapon_ammo; - nixnex_nextweapon = 0; - nixnex_nextchange = time + cvar("g_balance_nixnex_roundtime"); - //weapon_action(nixnex_weapon, WR_PRECACHE); // forget it, too slow - } - - if(nixnex_nextchange != self.nixnex_lastchange_id) // this shall only be called once per round! - { - self.nixnex_lastchange_id = nixnex_nextchange; - if (self.items & IT_UNLIMITED_WEAPON_AMMO) - { - self.ammo_shells = (nixnex_weapon_ammo & IT_SHELLS) ? - cvar("g_pickup_shells_max") : 0; - self.ammo_nails = (nixnex_weapon_ammo & IT_NAILS) ? - cvar("g_pickup_nails_max") : 0; - self.ammo_rockets = (nixnex_weapon_ammo & IT_ROCKETS) ? - cvar("g_pickup_rockets_max") : 0; - self.ammo_cells = (nixnex_weapon_ammo & IT_CELLS) ? - cvar("g_pickup_cells_max") : 0; - self.ammo_fuel = (nixnex_weapon_ammo & IT_FUEL) ? - cvar("g_pickup_fuel_max") : 0; - } - else - { - self.ammo_shells = (nixnex_weapon_ammo & IT_SHELLS) ? - cvar("g_balance_nixnex_ammo_shells") : 0; - self.ammo_nails = (nixnex_weapon_ammo & IT_NAILS) ? - cvar("g_balance_nixnex_ammo_nails") : 0; - self.ammo_rockets = (nixnex_weapon_ammo & IT_ROCKETS) ? - cvar("g_balance_nixnex_ammo_rockets") : 0; - self.ammo_cells = (nixnex_weapon_ammo & IT_CELLS) ? - cvar("g_balance_nixnex_ammo_cells") : 0; - self.ammo_fuel = (nixnex_weapon_ammo & IT_FUEL) ? - cvar("g_balance_nixnex_ammo_fuel") : 0; - } - self.nixnex_nextincr = time + cvar("g_balance_nixnex_incrtime"); - if(dt >= 1 && dt <= 5) - self.nixnex_lastinfotime = -42; - else - centerprint(self, strcat("\n\n^2Active weapon: ^3", W_Name(nixnex_weapon))); - } - if(self.nixnex_lastinfotime != dt) - { - self.nixnex_lastinfotime = dt; // initial value 0 should count as "not seen" - if(dt >= 1 && dt <= 5) - centerprint(self, strcat("^3", ftos(dt), "^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nixnex_nextweapon), "\n")); - } - - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nixnex_nextincr) - { - if (nixnex_weapon_ammo & IT_SHELLS) - self.ammo_shells = self.ammo_shells + cvar("g_balance_nixnex_ammoincr_shells"); - else if (nixnex_weapon_ammo & IT_NAILS) - self.ammo_nails = self.ammo_nails + cvar("g_balance_nixnex_ammoincr_nails"); - else if (nixnex_weapon_ammo & IT_ROCKETS) - self.ammo_rockets = self.ammo_rockets + cvar("g_balance_nixnex_ammoincr_rockets"); - else if (nixnex_weapon_ammo & IT_CELLS) - self.ammo_cells = self.ammo_cells + cvar("g_balance_nixnex_ammoincr_cells"); - if (nixnex_weapon_ammo & IT_FUEL) // hook uses cells and fuel - self.ammo_fuel = self.ammo_fuel + cvar("g_balance_nixnex_ammoincr_fuel"); - self.nixnex_nextincr = time + cvar("g_balance_nixnex_incrtime"); - } - - self.weapons = 0; - if(g_nixnex_with_laser) - self.weapons = self.weapons | WEPBIT_LASER; - self.weapons = self.weapons | W_WeaponBit(nixnex_weapon); - - if(self.switchweapon != nixnex_weapon) - if(!client_hasweapon(self, self.switchweapon, TRUE, FALSE)) - if(client_hasweapon(self, nixnex_weapon, TRUE, FALSE)) - W_SwitchWeapon(nixnex_weapon); - } -}