r5378 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Jan 2 07:11:59 EST 2009


Author: div0
Date: 2009-01-02 07:11:59 -0500 (Fri, 02 Jan 2009)
New Revision: 5378

Modified:
   trunk/data/qcsrc/server/cl_weaponsystem.qc
   trunk/data/qcsrc/server/defs.qh
   trunk/data/qcsrc/server/w_campingrifle.qc
Log:
camping rifle: make reloading use an extra weapon frame (yes, the model does not support it yet)


Modified: trunk/data/qcsrc/server/cl_weaponsystem.qc
===================================================================
--- trunk/data/qcsrc/server/cl_weaponsystem.qc	2009-01-02 11:37:06 UTC (rev 5377)
+++ trunk/data/qcsrc/server/cl_weaponsystem.qc	2009-01-02 12:11:59 UTC (rev 5378)
@@ -19,6 +19,7 @@
 float WFRAME_FIRE1 = 0;
 float WFRAME_FIRE2 = 1;
 float WFRAME_IDLE = 2;
+float WFRAME_RELOAD = 3;
 
 void(float fr, float t, void() func) weapon_thinkf;
 

Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh	2009-01-02 11:37:06 UTC (rev 5377)
+++ trunk/data/qcsrc/server/defs.qh	2009-01-02 12:11:59 UTC (rev 5378)
@@ -510,4 +510,4 @@
 .string target2;
 .string target3;
 .string target4;
-.float trigger_reverse
+.float trigger_reverse;

Modified: trunk/data/qcsrc/server/w_campingrifle.qc
===================================================================
--- trunk/data/qcsrc/server/w_campingrifle.qc	2009-01-02 11:37:06 UTC (rev 5377)
+++ trunk/data/qcsrc/server/w_campingrifle.qc	2009-01-02 12:11:59 UTC (rev 5378)
@@ -4,20 +4,41 @@
 
 .float campingrifle_bulletcounter;
 
+void W_Campingrifle_ReloadedAndReady()
+{
+	self.campingrifle_bulletcounter = 0;
+	ATTACK_FINISHED(self) = time;
+	w_ready();
+}
+
 void W_Campingrifle_Reload()
 {
-	if (self.campingrifle_bulletcounter <= 0)
+	if (self.campingrifle_bulletcounter == 0)
 		return;
 	
+	if (self.weaponentity)
+	{
+		if (self.weaponentity.frame == WFRAME_RELOAD)
+			return;
+
+		// allow to switch away while reloading, but this will cause a new reload!
+		self.weaponentity.state = WS_READY;
+	}
+
 	sound (self, CHAN_WEAPON2, "weapons/campingrifle_reload.wav", VOL_BASE, ATTN_NORM);
-	ATTACK_FINISHED(self) = time + cvar("g_balance_campingrifle_reloadtime");
-	self.campingrifle_bulletcounter = 0;
+
+	ATTACK_FINISHED(self) = time + cvar("g_balance_campingrifle_reloadtime") + 1;
+
+	weapon_thinkf(WFRAME_RELOAD, cvar("g_balance_campingrifle_reloadtime"), W_Campingrifle_ReloadedAndReady);
 }
 
-void W_Campingrifle_CheckReload()
+void W_Campingrifle_CheckReloadAndReady()
 {
+	w_ready();
 	if (self.campingrifle_bulletcounter >= cvar("g_balance_campingrifle_magazinecapacity"))
 		W_Campingrifle_Reload();
+	else
+		w_ready();
 }
 
 void W_CampingRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAddedDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant)
@@ -40,7 +61,6 @@
 		SpawnCasing (w_shotorg + v_forward * 10, ((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3);
 	
 	self.campingrifle_bulletcounter = self.campingrifle_bulletcounter + 1;
-	W_Campingrifle_CheckReload();
 }
 
 void W_Campingrifle_Attack()
@@ -86,17 +106,26 @@
 	}
 	else if (req == WR_THINK)
 	{
-		if (self.BUTTON_ATCK)
-		if (weapon_prepareattack(0, cvar("g_balance_campingrifle_primary_refire")))
+		if(self.campingrifle_bulletcounter < 0)
 		{
-			W_Campingrifle_Attack();
-			weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_campingrifle_primary_animtime"), w_ready);
+			if(self.switchweapon == self.weapon)
+			if(self.weaponentity.state == WS_READY)
+				W_Campingrifle_Reload();
 		}
-		if (self.BUTTON_ATCK2)
-		if (weapon_prepareattack(1, cvar("g_balance_campingrifle_secondary_refire")))
+		else
 		{
-			W_Campingrifle_Attack2();
-			weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_campingrifle_secondary_animtime"), w_ready);
+			if (self.BUTTON_ATCK)
+			if (weapon_prepareattack(0, cvar("g_balance_campingrifle_primary_refire")))
+			{
+				W_Campingrifle_Attack();
+				weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_campingrifle_primary_animtime"), W_Campingrifle_CheckReloadAndReady);
+			}
+			if (self.BUTTON_ATCK2)
+			if (weapon_prepareattack(1, cvar("g_balance_campingrifle_secondary_refire")))
+			{
+				W_Campingrifle_Attack2();
+				weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_campingrifle_secondary_animtime"), W_Campingrifle_CheckReloadAndReady);
+			}
 		}
 	}
 	else if (req == WR_PRECACHE)
@@ -121,7 +150,8 @@
 	else if (req == WR_SETUP)
 	{
 		weapon_setup(WEP_CAMPINGRIFLE);
-		W_Campingrifle_Reload();
+		if(self.campingrifle_bulletcounter != 0)
+			self.campingrifle_bulletcounter = -1;
 	}
 	else if (req == WR_CHECKAMMO1)
 		return self.ammo_nails >= cvar("g_balance_campingrifle_primary_ammo");




More information about the nexuiz-commits mailing list