r5786 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Feb 6 09:57:48 EST 2009


Author: div0
Date: 2009-02-06 09:57:48 -0500 (Fri, 06 Feb 2009)
New Revision: 5786

Modified:
   trunk/data/qcsrc/server/cl_player.qc
   trunk/data/qcsrc/server/cl_weapons.qc
   trunk/data/qcsrc/server/w_laser.qc
Log:
weapon_laser spawn func;
pinata: don't throw laser if nobody could pick it up anyway


Modified: trunk/data/qcsrc/server/cl_player.qc
===================================================================
--- trunk/data/qcsrc/server/cl_player.qc	2009-02-06 14:31:33 UTC (rev 5785)
+++ trunk/data/qcsrc/server/cl_player.qc	2009-02-06 14:57:48 UTC (rev 5786)
@@ -257,8 +257,9 @@
 		float j;
 		for(j = WEP_FIRST; j <= WEP_LAST; ++j)
 		{
-			if(self.weapons == self.weapons | W_WeaponBit(j))
-				W_ThrowNewWeapon(self, j, FALSE, self.origin, randomvec() * 175 + '0 0 325');
+			if(self.weapons & W_WeaponBit(j))
+				if(W_IsWeaponThrowable(j))
+					W_ThrowNewWeapon(self, j, FALSE, self.origin, randomvec() * 175 + '0 0 325');
 		}
 	}
 	else

Modified: trunk/data/qcsrc/server/cl_weapons.qc
===================================================================
--- trunk/data/qcsrc/server/cl_weapons.qc	2009-02-06 14:31:33 UTC (rev 5785)
+++ trunk/data/qcsrc/server/cl_weapons.qc	2009-02-06 14:57:48 UTC (rev 5786)
@@ -224,10 +224,31 @@
 	}
 }
 
+float W_IsWeaponThrowable(float w)
+{
+	float wb, wa;
+	wb = W_WeaponBit(w);
+	if(!wb)
+		return 0;
+	wa = W_AmmoItemCode(w);
+	if(start_weapons & wb)
+	{
+		if(wa == IT_SUPERWEAPON && start_items & IT_UNLIMITED_SUPERWEAPONS)
+			return 0;
+		if(wa != IT_SUPERWEAPON && start_items & IT_UNLIMITED_WEAPON_AMMO)
+			return 0;
+		// start weapons that take no ammo can't be dropped (this prevents dropping the laser, as long as it continues to use no ammo)
+		if(wa == 0)
+			return 0;
+	}
+
+	return 1;
+}
+
 // toss current weapon
 void W_ThrowWeapon(vector velo, vector delta, float doreduce)
 {
-	local float w, a, wb, wa;
+	local float w, a, wb;
 
 	w = self.weapon;
 	if (w == 0)
@@ -240,25 +261,14 @@
 		return;
 	if (!cvar("g_pickup_items"))
 		return;
+	if(!W_IsWeaponThrowable(w))
+		return;
 
 	wb = W_WeaponBit(w);
-	wa = W_AmmoItemCode(w);
-	if(!wb)
-		return;
 	if(self.weapons & wb != wb)
 		return;
-	if(start_weapons & wb)
-	{
-		if(wa == IT_SUPERWEAPON && start_items & IT_UNLIMITED_SUPERWEAPONS)
-			return;
-		if(wa != IT_SUPERWEAPON && start_items & IT_UNLIMITED_WEAPON_AMMO)
-			return;
-		// start weapons that take no ammo can't be dropped (this prevents dropping the laser, as long as it continues to use no ammo)
-		if(wa == 0)
-			return;
-	}
 
-	self.weapons = self.weapons - wb;
+	self.weapons &~= wb;
 	W_SwitchWeapon_Force(self, w_getbestweapon(self));
 	a = W_ThrowNewWeapon(self, w, doreduce, self.origin + delta, velo);
 	if(a < 0)

Modified: trunk/data/qcsrc/server/w_laser.qc
===================================================================
--- trunk/data/qcsrc/server/w_laser.qc	2009-02-06 14:31:33 UTC (rev 5785)
+++ trunk/data/qcsrc/server/w_laser.qc	2009-02-06 14:57:48 UTC (rev 5786)
@@ -58,6 +58,11 @@
 	CSQCProjectile(missile, TRUE, PROJECTILE_LASER, TRUE);
 }
 
+void spawnfunc_weapon_laser (void)
+{
+	weapon_defaultspawnfunc(WEP_LASER);
+}
+
 float w_laser(float req)
 {
 	local float r1;




More information about the nexuiz-commits mailing list