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

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Jun 10 14:39:28 EDT 2009


Author: mand1nga
Date: 2009-06-10 14:39:27 -0400 (Wed, 10 Jun 2009)
New Revision: 6963

Modified:
   trunk/data/qcsrc/server/bots.qc
   trunk/data/qcsrc/server/havocbot.qc
Log:
Fixed bot command moveto

Modified: trunk/data/qcsrc/server/bots.qc
===================================================================
--- trunk/data/qcsrc/server/bots.qc	2009-06-10 17:17:45 UTC (rev 6962)
+++ trunk/data/qcsrc/server/bots.qc	2009-06-10 18:39:27 UTC (rev 6963)
@@ -5,8 +5,9 @@
 float AI_STATUS_DANGER_AHEAD			= 8;	// There is lava/slime/trigger_hurt ahead
 float AI_STATUS_OUT_JUMPPAD			= 16;	// Trying to get out of a "vertical" jump pad
 float AI_STATUS_OUT_WATER			= 32;	// Trying to get out of water
-float AI_STATUS_WAYPOINT_PERSONAL_GOING		= 64;	// Going to a personal waypoint
-float AI_STATUS_WAYPOINT_PERSONAL_REACHED	= 128;	// Personal waypoint reached
+float AI_STATUS_WAYPOINT_PERSONAL_LINKING	= 64;	// Waiting for the personal waypoint to be linked
+float AI_STATUS_WAYPOINT_PERSONAL_GOING		= 128;	// Going to a personal waypoint
+float AI_STATUS_WAYPOINT_PERSONAL_REACHED	= 256;	// Personal waypoint reached
 
 // utilities for path debugging
 #ifdef DEBUG_TRACEWALK
@@ -448,6 +449,7 @@
 .float wpisbox;
 .float wpflags;
 .vector wpnearestpoint;
+.float wplinked;
 
 // stack of current goals (the last one of which may be an item or other
 // desirable object, the rest are typically waypoints to reach it)
@@ -640,6 +642,7 @@
 		}
 	}
 	navigation_testtracewalk = 0;
+	self.wplinked = TRUE;
 };
 
 void waypoint_clearlinks(entity wp)
@@ -651,6 +654,7 @@
 	wp.wp08 = wp.wp09 = wp.wp10 = wp.wp11 = wp.wp12 = wp.wp13 = wp.wp14 = wp.wp15 = world;wp.wp08mincost = wp.wp09mincost = wp.wp10mincost = wp.wp11mincost = wp.wp12mincost = wp.wp13mincost = wp.wp14mincost = wp.wp15mincost = f;
 	wp.wp16 = wp.wp17 = wp.wp18 = wp.wp19 = wp.wp20 = wp.wp21 = wp.wp22 = wp.wp23 = world;wp.wp16mincost = wp.wp17mincost = wp.wp18mincost = wp.wp19mincost = wp.wp20mincost = wp.wp21mincost = wp.wp22mincost = wp.wp23mincost = f;
 	wp.wp24 = wp.wp25 = wp.wp26 = wp.wp27 = wp.wp28 = wp.wp29 = wp.wp30 = wp.wp31 = world;wp.wp24mincost = wp.wp25mincost = wp.wp26mincost = wp.wp27mincost = wp.wp28mincost = wp.wp29mincost = wp.wp30mincost = wp.wp31mincost = f;
+	wp.wplinked = FALSE;
 };
 
 // tell a spawnfunc_waypoint to relink
@@ -677,7 +681,8 @@
 		wp.model = "";
 	wp.wpisbox = vlen(wp.size) > 0;
 	wp.enemy = world;
-	wp.owner = world;
+	if (!(wp.wpflags & WAYPOINTFLAG_PERSONAL))
+		wp.owner = world;
 	if (!(wp.wpflags & WAYPOINTFLAG_NORELINK))
 		waypoint_clearlinks(wp);
 	// schedule an actual relink on next frame
@@ -1313,14 +1318,13 @@
 {
 	entity w;
 
-	tracebox(position, PL_MIN, PL_MAX, position + '0 0 -1024', MOVE_NORMAL, world);
-	if(trace_fraction < 1)
-		position = trace_endpos;
 	w = waypoint_spawn(position, position, WAYPOINTFLAG_GENERATED | WAYPOINTFLAG_PERSONAL);
 	w.nearestwaypoint = world;
 	w.nearestwaypointtimeout = 0;
 	w.owner = self;
 
+	waypoint_schedulerelink(w);
+
 	return w;
 };
 
@@ -2428,7 +2432,7 @@
 {
 	if (self.bot_nextthink > time)
 		return;
-	
+
 	self.flags &~= FL_GODMODE;
 	if(cvar("bot_god"))
 		self.flags |= FL_GODMODE;

Modified: trunk/data/qcsrc/server/havocbot.qc
===================================================================
--- trunk/data/qcsrc/server/havocbot.qc	2009-06-10 17:17:45 UTC (rev 6962)
+++ trunk/data/qcsrc/server/havocbot.qc	2009-06-10 18:39:27 UTC (rev 6963)
@@ -1123,22 +1123,37 @@
 	havocbot_movetogoal();
 };
 
+.entity havocbot_personal_waypoint;
 float havocbot_moveto(vector pos)
 {
+	local entity wp;
+
 	if(self.aistatus & AI_STATUS_WAYPOINT_PERSONAL_GOING)
 	{
-		if(self.goalcurrent==world)
+		// Step 4: Move to waypoint
+		if(self.havocbot_personal_waypoint==world)
+		{
+			dprint("Error: ", self.netname, " trying to walk to a non existent personal waypoint\n");
 			return CMD_STATUS_ERROR;
+		}
 
 		if (!bot_strategytoken_taken)
 		if(self.bot_strategytime<time)
 		{
 			// Refresh path to goal if necessary
-			local entity g;
-			g = self.goalentity;
-			//print("bot ", etos(self), " goal = ", etos(g), "\n");
-			navigation_clearroute();
-			navigation_routetogoal(g,self.origin);
+			wp = self.havocbot_personal_waypoint;
+			navigation_goalrating_start();
+			navigation_routerating(wp, 10000, 10000);
+			navigation_goalrating_end();
+
+			if(self.navigation_hasgoals)
+				dprint(self.netname, " walking to its personal waypoint\n");
+			else
+			{
+				dprint("Warning: can't walk to the personal waypoint located at ", vtos(wp.origin),"\n");
+				return CMD_STATUS_ERROR;
+			}
+
 			bot_strategytoken_taken = TRUE;
 			self.bot_strategytime = time + 10;
 		}
@@ -1154,31 +1169,63 @@
 
 		// Go!
 		havocbot_movetogoal();
+
+		if(self.aistatus & AI_STATUS_WAYPOINT_PERSONAL_REACHED)
+		{
+			// Step 5: Waypoint reached
+			dprint(self.netname, "'s personal waypoint reached\n");
+			self.aistatus &~= AI_STATUS_WAYPOINT_PERSONAL_REACHED;
+			return CMD_STATUS_FINISHED;
+		}
+
 		return CMD_STATUS_EXECUTING;
 	}
 
-	if(self.aistatus & AI_STATUS_WAYPOINT_PERSONAL_REACHED)
+	// Step 2: Linking waypoint
+	if(self.aistatus & AI_STATUS_WAYPOINT_PERSONAL_LINKING)
 	{
-		self.aistatus &~= AI_STATUS_WAYPOINT_PERSONAL_REACHED;
-		return CMD_STATUS_FINISHED;
+		// Wait until it is linked
+		if(!self.havocbot_personal_waypoint.wplinked)
+		{
+			dprint(self.netname, " waiting for personal waypoint to be linked\n");
+			return CMD_STATUS_EXECUTING;
+		}
+
+		// Step 3: Route to waypoint
+		wp = self.havocbot_personal_waypoint;
+		navigation_goalrating_start();
+		navigation_routerating(wp, 10000, 10000);
+		navigation_goalrating_end();
+
+		if(!self.navigation_hasgoals)
+		{
+			dprint("Warning: can't walk to the personal waypoint located at ", vtos(wp.origin),"\n");
+			remove(wp);
+			return CMD_STATUS_ERROR;
+		}
+
+		bot_strategytoken_taken = TRUE;
+		self.bot_strategytime = time + 10;
+
+		self.aistatus &~= AI_STATUS_WAYPOINT_PERSONAL_LINKING;
+		self.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_GOING;
+
+		dprint(self.netname, " walking to its personal waypoint\n");
+
+		return CMD_STATUS_EXECUTING;
 	}
 
-	// Spawn personal waypoint
-	entity wp;
+	// Step 1: Spawning waypoint
 	wp = waypoint_spawnpersonal(pos);
 	if(wp==world)
+	{
+		dprint("Error: Can't spawn personal waypoint at ",vtos(pos),"\n");
 		return CMD_STATUS_ERROR;
+	}
 
-	// Put it as next goal
-	navigation_clearroute();
-	wp.nearestwaypoint = navigation_findnearestwaypoint(wp, TRUE);
-	navigation_routetogoal(wp,self.origin);
-	//print("bot ", etos(self), " goal = ", etos(self.goalentity), "\n");
-	bot_strategytoken_taken = TRUE;
-	self.bot_strategytime = time + 10;
+	self.havocbot_personal_waypoint = wp;
+	self.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_LINKING;
 
-	self.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_GOING;
-
 	return CMD_STATUS_EXECUTING;
 }
 



More information about the nexuiz-commits mailing list