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

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Jun 6 15:19:11 EDT 2009


Author: mand1nga
Date: 2009-06-06 15:19:11 -0400 (Sat, 06 Jun 2009)
New Revision: 6892

Modified:
   trunk/data/qcsrc/server/bots.qc
Log:
Better placement of auto-generated waypoints
Set hasgoals to false if no real goal was found


Modified: trunk/data/qcsrc/server/bots.qc
===================================================================
--- trunk/data/qcsrc/server/bots.qc	2009-06-06 19:16:30 UTC (rev 6891)
+++ trunk/data/qcsrc/server/bots.qc	2009-06-06 19:19:11 UTC (rev 6892)
@@ -1226,14 +1226,15 @@
 		return;
 
 	// Center of entity
-	org = e.origin + (e.mins + e.maxs) * 0.5;
+	org = (e.absmax + e.absmin) * 0.5;
 
-	// Calculate the altitude where the waypoint will be placed
-	traceline(e.origin, e.origin + '0 0 -65535', TRUE, e);
-	if(e.origin_z + e.mins_z - trace_endpos_z < PL_MAX_z - PL_MIN_z + 10)
+	// Fix the waypoint altitude if necessary
+	traceline(org, org + '0 0 -65535', TRUE, e);
+	if(
+		org_z - trace_endpos_z > PL_MAX_z - PL_MIN_z + 10 // If middle of entiy is above player heigth
+		|| org_z - trace_endpos_z < (PL_MAX_z - PL_MIN_z) * 0.5 // or below half player height
+	)
 		org_z = trace_endpos_z + PL_MAX_z - PL_MIN_z;
-	else
-		org_z = e.origin_z;
 
 	// TODO: Cleaner solution
 	if(e.classname!="item_flag_team")
@@ -1871,10 +1872,10 @@
 {
 	navigation_routetogoals();
 
-	// If can't walk to any goal just move blindly to the first visible waypoint
+	// Hack: if it can't walk to any goal just move blindly to the first visible waypoint
 	if not (self.navigation_hasgoals)
 	{
-		dprint(self.netname, " can't walk to any goal, moving to the closest waypoint\n");
+		dprint(self.netname, " can't walk to any goal, going to a near waypoint\n");
 		local entity head;
 		head = findradius(self.origin,500);
 		while(head)
@@ -1885,6 +1886,7 @@
 
 			head = head.chain;
 		}
+		self.navigation_hasgoals = FALSE; // Reset this value
 	}
 };
 



More information about the nexuiz-commits mailing list