[nexuiz-commits] r6597 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Apr 26 16:03:40 EDT 2009


Author: mand1nga
Date: 2009-04-26 16:03:39 -0400 (Sun, 26 Apr 2009)
New Revision: 6597

Modified:
   trunk/data/qcsrc/server/bots.qc
   trunk/data/qcsrc/server/havocbot_roles.qc
   trunk/data/qcsrc/server/t_jumppads.qc
   trunk/data/qcsrc/server/t_teleporters.qc
Log:
Fix ancient bug in the detection of "touched" jump pads/teleporters
Fix flawed logic in navigation_routetogoals


Modified: trunk/data/qcsrc/server/bots.qc
===================================================================
--- trunk/data/qcsrc/server/bots.qc	2009-04-26 13:00:28 UTC (rev 6596)
+++ trunk/data/qcsrc/server/bots.qc	2009-04-26 20:03:39 UTC (rev 6597)
@@ -1542,13 +1542,13 @@
 	if(bestgoalswindex==MAX_BESTGOALS)
 	{
 		bestgoalswindex=0;
-		bestgoalsrindex=1;
+		if(bestgoalsrindex==0)
+			bestgoalsrindex=1;
 	}
 
 	navigation_bestgoals[bestgoalswindex] = goal;
 
 	++bestgoalswindex;
-
 }
 
 entity navigation_get_bestgoal()
@@ -1639,47 +1639,65 @@
 
 void navigation_routetogoals()
 {
-	entity e;
-	vector position, v;
+	entity g1, g2;
 
 	navigation_clearroute();
 
-	position = self.origin;
+	g1 = navigation_get_bestgoal();
 	for(;;)
 	{
-		e = navigation_get_bestgoal();
+		if(g2==world)
+			g2 = navigation_get_bestgoal();
 
-		if(e==world)
+		if(g2==world)
+		{
+			navigation_routetogoal(g1, self.origin);
 			return;
+		}
 
-		if(navigation_routetogoal(e, position))
+		if(navigation_routetogoal(g1, g2.origin))
 		{
-			position = v;
-			self.navigation_hasgoals = TRUE;
+			g1 = g2;
+			g2 = world;
+			continue;
 		}
+
+		navigation_clearroute();
+		g1 = g2;
+		g2 = world;
 	}
 }
 
 // removes any currently touching waypoints from the goal stack
 // (this is how bots detect if they have reached a goal)
+.float lastteleporttime;
+
 void navigation_poptouchedgoals()
 {
 	local vector org, m1, m2;
-	org = self.origin;// + self.velocity * 0.1;
+	org = self.origin;
 	m1 = org + self.mins;
 	m2 = org + self.maxs;
 
-	// Loose goal touching check for running state
+	if(self.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
+	{
+		if(self.lastteleporttime>0)
+		if(time-self.lastteleporttime<0.2)
+		{
+			navigation_poproute();
+			return;
+		}
+	}
+
+	// Loose goal touching check when running
 	if(self.aistatus & AI_STATUS_RUNNING)
 	if(self.goalcurrent.classname=="waypoint")
 	{
 		if(vlen(self.origin - self.goalcurrent.origin)<150)
 		{
-				traceline(self.origin + self.view_ofs , self.goalcurrent.origin, TRUE, world);
-				if(trace_fraction==1)
-				{
-					navigation_poproute();
-				}
+			traceline(self.origin + self.view_ofs , self.goalcurrent.origin, TRUE, world);
+			if(trace_fraction==1)
+				navigation_poproute();
 		}
 	}
 

Modified: trunk/data/qcsrc/server/havocbot_roles.qc
===================================================================
--- trunk/data/qcsrc/server/havocbot_roles.qc	2009-04-26 13:00:28 UTC (rev 6596)
+++ trunk/data/qcsrc/server/havocbot_roles.qc	2009-04-26 20:03:39 UTC (rev 6597)
@@ -982,10 +982,6 @@
 	}
 };
 
-
-
-
-
 void havocbot_chooserole_kh()
 {
 	local float r;

Modified: trunk/data/qcsrc/server/t_jumppads.qc
===================================================================
--- trunk/data/qcsrc/server/t_jumppads.qc	2009-04-26 13:00:28 UTC (rev 6596)
+++ trunk/data/qcsrc/server/t_jumppads.qc	2009-04-26 20:03:39 UTC (rev 6597)
@@ -69,12 +69,12 @@
 
 	// push him so high...
 	vz = sqrt(2 * grav * jumpheight); // NOTE: sqrt(positive)!
-	
+
 	// we start with downwards velocity only if it's a downjump and the jump apex should be outside the jump!
 	if(ht < 0)
 		if(zdist < 0)
 			vz = -vz;
-	
+
 	vector solution;
 	solution = solve_quadratic(0.5 * grav, -vz, zdist); // equation "z(ti) = zdist"
 	// ALWAYS solvable because jumpheight >= zdist
@@ -82,7 +82,7 @@
 		solution_y = solution_x; // just in case it is not solvable due to roundoff errors, assume two equal solutions at their center (this is mainly for the usual case with ht == 0)
 	if(zdist == 0)
 		solution_x = solution_y; // solution_x is 0 in this case, so don't use it, but rather use solution_y (which will be sqrt(0.5 * jumpheight / grav), actually)
-	
+
 	if(zdist < 0)
 	{
 		// down-jump
@@ -164,7 +164,9 @@
 			sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NORM);
 			self.pushltime = time + 0.2;
 		}
-		if(clienttype(other) == CLIENTTYPE_REAL)
+		local float ct;
+		ct = clienttype(other);
+		if( ct == CLIENTTYPE_REAL)
 		{
 			local float i;
 			local float found;
@@ -181,6 +183,8 @@
 			if(self.message)
 				centerprint(other, self.message);
 		}
+		else if(ct == CLIENTTYPE_BOT)
+			other.lastteleporttime = time;
 		else
 			other.jumppadcount = TRUE;
 	}

Modified: trunk/data/qcsrc/server/t_teleporters.qc
===================================================================
--- trunk/data/qcsrc/server/t_teleporters.qc	2009-04-26 13:00:28 UTC (rev 6596)
+++ trunk/data/qcsrc/server/t_teleporters.qc	2009-04-26 20:03:39 UTC (rev 6597)
@@ -96,6 +96,9 @@
 			player.pushltime = 0;
 		}
 
+		if(player.isbot)
+			player.lastteleporttime = time;
+
 		// stop player name display
 		{
 			oldself = self;



More information about the nexuiz-commits mailing list