X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Fselection.qc;h=ce2a671c4584f9290ea9a67d93b985c102f11179;hb=2e4b6fcb1aec544934a31bd49bba5eeecaffbf86;hp=5ea0a5d9d842c8690cdf979cd7a9c717e5439477;hpb=cd109cf922bc405155c680582745d645bd057ded;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 5ea0a5d9d..ce2a671c4 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -1,17 +1,11 @@ -#if defined(CSQC) -#elif defined(MENUQC) -#elif defined(SVQC) - #include "../../dpdefs/progsdefs.qh" - #include "../../dpdefs/dpextensions.qh" - #include "../../common/constants.qh" - #include "../../common/util.qh" - #include "../../common/weapons/weapons.qh" - #include "selection.qh" - #include "weaponsystem.qh" - #include "../t_items.qh" - #include "../autocvars.qh" - #include "../defs.qh" -#endif +#include "selection.qh" +#include "../_all.qh" + +#include "weaponsystem.qh" +#include "../t_items.qh" +#include "../../common/constants.qh" +#include "../../common/util.qh" +#include "../../common/weapons/all.qh" // switch between weapons void Send_WeaponComplain(entity e, float wpn, float type) @@ -24,15 +18,16 @@ void Send_WeaponComplain(entity e, float wpn, float type) } float client_hasweapon(entity cl, float wpn, float andammo, float complain) -{ +{SELFPARAM(); float f; - entity oldself; if(time < self.hasweapon_complain_spam) complain = 0; - if(wpn == WEP_HOOK && !g_grappling_hook && autocvar_g_nades && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn))) - complain = 0; + // ignore hook button when using other offhand equipment + if (cl.offhand != OFFHAND_HOOK) + if (wpn == WEP_HOOK.m_id && !((cl.weapons | weaponsInMap) & WepSet_FromWeapon(wpn))) + complain = 0; if(complain) self.hasweapon_complain_spam = time + 0.2; @@ -53,25 +48,24 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) } else { - oldself = self; - self = cl; - f = WEP_ACTION(wpn, WR_CHECKAMMO1); - f = f + WEP_ACTION(wpn, WR_CHECKAMMO2); + setself(cl); + Weapon w = get_weaponinfo(wpn); + f = w.wr_checkammo1(w) + w.wr_checkammo2(w); // always allow selecting the Mine Layer if we placed mines, so that we can detonate them entity mine; - if(wpn == WEP_MINE_LAYER) + if(wpn == WEP_MINE_LAYER.m_id) for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self) f = 1; - self = oldself; + setself(this); } if (!f) { if (complain) if(IS_REAL_CLIENT(cl)) { - play2(cl, "weapons/unavailable.wav"); + play2(cl, SND(UNAVAILABLE)); Send_WeaponComplain (cl, wpn, 0); } return false; @@ -97,15 +91,16 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) continue; if(!(e.flags & FL_ITEM)) continue; - WaypointSprite_Spawn( - (get_weaponinfo(wpn)).wpmodel, + entity wp = WaypointSprite_Spawn( + WP_Weapon, 1, 0, world, e.origin + ('0 0 1' * e.maxs.z) * 1.2, self, 0, world, enemy, 0, - RADARICON_NONE, '0 0 0' + RADARICON_NONE ); + wp.wp_extra = wpn; } } } @@ -114,13 +109,13 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) Send_WeaponComplain (cl, wpn, 2); } - play2(cl, "weapons/unavailable.wav"); + play2(cl, SND(UNAVAILABLE)); } return false; } float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain, float skipmissing) -{ +{SELFPARAM(); // We cannot tokenize in this function, as GiveItems calls this // function. Thus we must use car/cdr. float weaponwant, first_valid, prev_valid, switchtonext, switchtolast; @@ -259,7 +254,7 @@ void W_SwitchToOtherWeapon(entity pl) } void W_SwitchWeapon(float imp) -{ +{SELFPARAM(); if (self.switchweapon != imp) { if (client_hasweapon(self, imp, true, true)) @@ -267,11 +262,14 @@ void W_SwitchWeapon(float imp) else self.selectweapon = imp; // update selectweapon ANYWAY } - else if(!forbidWeaponUse()) { WEP_ACTION(self.weapon, WR_RELOAD); } + else if(!forbidWeaponUse(self)) { + Weapon w = get_weaponinfo(self.weapon); + w.wr_reload(w); + } } void W_CycleWeapon(string weaponorder, float dir) -{ +{SELFPARAM(); float w; w = W_GetCycleWeapon(self, weaponorder, dir, -1, 1, true); if(w > 0) @@ -279,7 +277,7 @@ void W_CycleWeapon(string weaponorder, float dir) } void W_NextWeaponOnImpulse(float imp) -{ +{SELFPARAM(); float w; w = W_GetCycleWeapon(self, self.cvar_cl_weaponpriority, +1, imp, 1, (self.cvar_cl_weaponimpulsemode == 0)); if(w > 0) @@ -288,7 +286,7 @@ void W_NextWeaponOnImpulse(float imp) // next weapon void W_NextWeapon(float list) -{ +{SELFPARAM(); if(list == 0) W_CycleWeapon(weaponorder_byid, -1); else if(list == 1) @@ -299,7 +297,7 @@ void W_NextWeapon(float list) // prev weapon void W_PreviousWeapon(float list) -{ +{SELFPARAM(); if(list == 0) W_CycleWeapon(weaponorder_byid, +1); else if(list == 1) @@ -310,7 +308,7 @@ void W_PreviousWeapon(float list) // previously used if exists and has ammo, (second) best otherwise void W_LastWeapon(void) -{ +{SELFPARAM(); if(client_hasweapon(self, self.cnt, true, false)) W_SwitchWeapon(self.cnt); else