Module dpmod: Change committed

havoc at icculus.org havoc at icculus.org
Thu Feb 20 03:48:17 EST 2003


Commiter   : havoc
CVSROOT    : /cvs/cvsroot/twilight
Module     : dpmod
Commit time: 2003-02-20 08:48:17 UTC

Log message:

some optimizations to CheckAttack code

Modified files:
     qc/m_soldier.qc

------=MIME.3f0fe9f3bd925be7acb9b856c4718212
Content-Type: text/plain; name="dpmod.20030220.084817.havoc.diff"
Content-Disposition: attachment; filename="dpmod.20030220.084817.havoc.diff"
Content-Transfer-Encoding: 8bit

Index: dpmod/qc/m_soldier.qc
diff -u dpmod/qc/m_soldier.qc:1.2 dpmod/qc/m_soldier.qc:1.3
--- dpmod/qc/m_soldier.qc:1.2	Thu Feb 13 21:47:16 2003
+++ dpmod/qc/m_soldier.qc	Thu Feb 20 03:48:07 2003
@@ -100,9 +100,9 @@
 */
 float() SoldierCheckAttack =
 {
-	local vector	spot1, spot2;	
-	local entity	targ;
-	local float		chance;
+	local vector spot1, spot2;
+	local entity targ;
+	local float chance;
 
 	if (self.health < 1)
 		return FALSE;
@@ -117,7 +117,8 @@
 	if (trace_ent != targ)
 		return FALSE; // don't have a clear shot
 
-	if (trace_inopen && trace_inwater)
+	if (trace_inwater)
+	if (trace_inopen)
 		return FALSE; // sight line crossed contents
 
 	// missile attack
@@ -136,16 +137,15 @@
 	else
 		chance = 0;
 
-	if (random () < chance)
+	if (chance > 0)
+	if (chance > random())
+		return FALSE;
+
+	if (self.th_missile())
 	{
-		if (self.th_missile())
-		{
-			SUB_AttackFinished (1 + random());
-			return TRUE;
-		}
+		SUB_AttackFinished (1 + random());
+		return TRUE;
 	}
-
-	return FALSE;
 };
 
 void(vector hit) army_pistol =


More information about the twilight-commits mailing list