X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_weapons.qc;h=94eaccd2daf4a4cc8a46b3afc9982c122b006e38;hb=3d25fdf470809fd60dbd0bc43bd532c7d94f29de;hp=8c0cb96e0eb4f0627867800f7691eb979aa53af2;hpb=5eb33d999861a22adacb08d808421351b3291163;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_weapons.qc b/qcsrc/server/cl_weapons.qc index 8c0cb96e0..94eaccd2d 100644 --- a/qcsrc/server/cl_weapons.qc +++ b/qcsrc/server/cl_weapons.qc @@ -173,11 +173,17 @@ float W_AmmoItemCode(float wpn) return (get_weaponinfo(wpn)).items & IT_AMMO; } +.float savenextthink; void thrown_wep_think() { - self.solid = SOLID_TRIGGER; self.owner = world; - SUB_SetFade(self, time + 20, 1); + float timeleft = self.savenextthink - time; + if(timeleft > 1) + SUB_SetFade(self, self.savenextthink - 1, 1); + else if(timeleft > 0) + SUB_SetFade(self, time, timeleft); + else + SUB_VanishOrRemove(self); } // returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count @@ -197,6 +203,33 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto wep.flags |= FL_TOSSED; wep.colormap = own.colormap; + if(W_WeaponBit(wpn) & WEPBIT_SUPERWEAPONS) + { + if(own.items & IT_UNLIMITED_SUPERWEAPONS) + { + wep.superweapons_finished = time + autocvar_g_balance_superweapons_time; + } + else + { + float superweapons = 1; + for(i = WEP_FIRST; i <= WEP_LAST; ++i) + if(own.weapons & WEPBIT_SUPERWEAPONS & W_WeaponBit(i)) + ++superweapons; + if(superweapons <= 1) + { + wep.superweapons_finished = own.superweapons_finished; + own.superweapons_finished = 0; + } + else + { + float timeleft = own.superweapons_finished - time; + float weptimeleft = timeleft / superweapons; + wep.superweapons_finished = time + weptimeleft; + own.superweapons_finished -= weptimeleft; + } + } + } + wa = W_AmmoItemCode(wpn); if(wa == 0) { @@ -208,7 +241,9 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto return string_null; wep.glowmod = own.weaponentity_glowmod; wep.think = thrown_wep_think; - wep.nextthink = time + 0.5; + wep.savenextthink = wep.nextthink; + wep.nextthink = min(wep.nextthink, time + 0.5); + wep.pickup_anyway = TRUE; // these are ALWAYS pickable return ""; } else @@ -227,7 +262,6 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto if(wa & j) { ammofield = Item_CounterField(j); - wep.ammofield = 0; // if our weapon is loaded, give its load back to the player if(self.(weapon_load[self.weapon]) > 0) @@ -235,6 +269,8 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto own.ammofield += self.(weapon_load[self.weapon]); self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading } + + wep.ammofield = 0; } } } @@ -245,10 +281,6 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto if(wa & j) { ammofield = Item_CounterField(j); - thisammo = min(own.ammofield, wep.ammofield); - wep.ammofield = thisammo; - own.ammofield -= thisammo; - s = strcat(s, " and ", ftos(thisammo), " ", Item_CounterFieldName(j)); // if our weapon is loaded, give its load back to the player if(self.(weapon_load[self.weapon]) > 0) @@ -256,13 +288,19 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto own.ammofield += self.(weapon_load[self.weapon]); self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading } + + thisammo = min(own.ammofield, wep.ammofield); + wep.ammofield = thisammo; + own.ammofield -= thisammo; + s = strcat(s, " and ", ftos(thisammo), " ", Item_CounterFieldName(j)); } } s = substring(s, 5, -1); } wep.glowmod = own.weaponentity_glowmod; wep.think = thrown_wep_think; - wep.nextthink = time + 0.5; + wep.savenextthink = wep.nextthink; + wep.nextthink = min(wep.nextthink, time + 0.5); wep.pickup_anyway = TRUE; // these are ALWAYS pickable return s; } @@ -288,8 +326,6 @@ float W_IsWeaponThrowable(float w) wb = W_WeaponBit(w); if(!wb) return 0; - if(wb & WEPBIT_SUPERWEAPONS) // can't throw a superweapon, they don't work - return 0; wa = W_AmmoItemCode(w); if(start_weapons & wb) {