X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_weaponsystem.qc;h=d2c2546d2f3e091660282b3626e6b5521996011c;hb=a2029211d07cca1158f99bd8aa0d3b3eaa81e987;hp=7ce62e5b8e60e26b8d25c40d5642d15712b755fc;hpb=a68d411f9a130f89964189bae97d43017420d437;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 7ce62e5b8..d2c2546d2 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -607,10 +607,6 @@ void CL_ExteriorWeaponentity_Think() } else setattachment(self, self.owner, "bip01 r hand"); - - // if that didn't find a tag, hide the exterior weapon model - if (!self.tag_index) - self.model = ""; } self.effects = self.owner.effects; if(sv_pitch_min == sv_pitch_max) @@ -679,6 +675,8 @@ void CL_ExteriorWeaponentity_Think() self.glowmod = self.owner.weaponentity_glowmod; self.colormap = self.owner.colormap; + + CSQCMODEL_AUTOUPDATE(); } // spawning weaponentity for client @@ -706,6 +704,13 @@ void CL_SpawnWeaponentity() self.exteriorweaponentity.angles = '0 0 0'; self.exteriorweaponentity.think = CL_ExteriorWeaponentity_Think; self.exteriorweaponentity.nextthink = time; + + { + entity oldself = self; + self = self.exteriorweaponentity; + CSQCMODEL_AUTOINIT(); + self = oldself; + } } void Send_WeaponComplain (entity e, float wpn, string wpnname, float type) @@ -722,7 +727,7 @@ void Send_WeaponComplain (entity e, float wpn, string wpnname, float type) float client_hasweapon(entity cl, float wpn, float andammo, float complain) { - float weaponbit, f; + float f; entity oldself; if(time < self.hasweapon_complain_spam) @@ -736,8 +741,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) sprint(self, "Invalid weapon\n"); return FALSE; } - weaponbit = W_WeaponBit(wpn); - if (cl.weapons & weaponbit) + if (WEPSET_CONTAINS_EW(cl, wpn)) { if (andammo) { @@ -778,7 +782,7 @@ 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) + if (WEPSET_CONTAINS_AW(weaponsInMap, wpn)) { sprint(cl, strcat("You do not have the ^2", W_Name(wpn), "\n") ); Send_WeaponComplain (cl, wpn, W_Name(wpn), 1); @@ -791,7 +795,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) e = get_weaponinfo(wpn); s = e.model2; - for(e = world; (e = findfloat(e, weapons, weaponbit)); ) + for(e = world; (e = findfloat(e, weapon, wpn)); ) { if(e.classname == "droppedweapon") continue; @@ -848,7 +852,7 @@ void weapon_setup(float windex) entity e; e = get_weaponinfo(windex); self.items &~= IT_AMMO; - self.items = self.items | e.items; + self.items = self.items | (e.items & IT_AMMO); // the two weapon entities will notice this has changed and update their models self.weapon = windex; @@ -862,14 +866,29 @@ void W_SwitchToOtherWeapon(entity pl) { // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway) float w, ww; - w = W_WeaponBit(pl.weapon); - pl.weapons &~= w; - ww = w_getbestweapon(pl); - pl.weapons |= w; + w = pl.weapon; + if(WEPSET_CONTAINS_EW(pl, w)) + { + WEPSET_ANDNOT_EW(pl, w); + ww = w_getbestweapon(pl); + WEPSET_OR_EW(pl, w); + } + else + ww = w_getbestweapon(pl); if(ww) W_SwitchWeapon_Force(pl, ww); } + +string PrimaryOrSecondary(float secondary) +{ + if(secondary) + return "secondary"; + else + return "primary"; +} + .float prevdryfire; +.float prevwarntime; float weapon_prepareattack_checkammo(float secondary) { if not(self.items & IT_UNLIMITED_WEAPON_AMMO) @@ -887,7 +906,19 @@ float weapon_prepareattack_checkammo(float secondary) self.prevdryfire = time; } - W_SwitchToOtherWeapon(self); + if(weapon_action(self.weapon, WR_CHECKAMMO2 - secondary)) // check if the other firing mode has enough ammo + { + if(time - self.prevwarntime > 1) + { + sprint(self, strcat("^2", W_Name(self.weapon), " ", PrimaryOrSecondary(secondary), "^7 is unable to fire, but its ^2", PrimaryOrSecondary(1 - secondary), "^7 can.\n")); + } + self.prevwarntime = time; + } + else // this weapon is totally unable to fire, switch to another one + { + W_SwitchToOtherWeapon(self); + } + return FALSE; } return TRUE; @@ -904,7 +935,7 @@ float weapon_prepareattack_check(float secondary, float attacktime) return FALSE; } - if (timeoutStatus == 2) //don't allow the player to shoot while game is paused + if (timeout_status == TIMEOUT_ACTIVE) //don't allow the player to shoot while game is paused return FALSE; // do not even think about shooting if switching @@ -1485,7 +1516,7 @@ void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, stri // now begin the reloading process - sound (self, CH_WEAPON_B, self.reload_sound, VOL_BASE, ATTN_NORM); + sound (self, CH_WEAPON_SINGLE, self.reload_sound, VOL_BASE, ATTN_NORM); // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon, // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,