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

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Jun 4 22:06:59 EDT 2009


Author: mand1nga
Date: 2009-06-04 22:06:55 -0400 (Thu, 04 Jun 2009)
New Revision: 6862

Modified:
   trunk/data/qcsrc/server/bots.qc
   trunk/data/qcsrc/server/havocbot.qc
Log:
Fixed bug on the path finding to dropped ctf flags
Better detection of used jumpads/teleports
Make the bot walk (wander) to a near visible waypoint if it can't walk to any goal
Let the bot ai access the deadflag field all the time
Reverted last change in the targeting of enemies (bad results)
Minor cleaning


Modified: trunk/data/qcsrc/server/bots.qc
===================================================================
--- trunk/data/qcsrc/server/bots.qc	2009-06-04 11:55:41 UTC (rev 6861)
+++ trunk/data/qcsrc/server/bots.qc	2009-06-05 02:06:55 UTC (rev 6862)
@@ -1235,7 +1235,10 @@
 	else
 		org_z = e.origin_z;
 
-	e.nearestwaypointtimeout = time + 1000000000;
+	// TODO: Cleaner solution
+	if(e.classname!="item_flag_team")
+		e.nearestwaypointtimeout = time + 1000000000;
+
 	// don't spawn an item spawnfunc_waypoint if it already exists
 	w = findchain(classname, "waypoint");
 	while (w)
@@ -1411,14 +1414,15 @@
 };
 
 // find the spawnfunc_waypoint near a dynamic goal such as a dropped weapon
-entity navigation_findnearestwaypoint(entity player, float walkfromwp)
+entity navigation_findnearestwaypoint(entity ent, float walkfromwp)
 {
 	local entity waylist, w, best;
 	local float dist, bestdist;
 	local vector v, org, pm1, pm2;
-	pm1 = player.origin + PL_MIN;
-	pm2 = player.origin + PL_MAX;
+	pm1 = ent.origin + PL_MIN;
+	pm2 = ent.origin + PL_MAX;
 	waylist = findchain(classname, "waypoint");
+
 	// do two scans, because box test is cheaper
 	w = waylist;
 	while (w)
@@ -1429,9 +1433,9 @@
 		w = w.chain;
 	}
 
-	org = player.origin + (player.mins_z - PL_MIN_z) * '0 0 1';
-	if(player.tag_entity)
-		org = org + player.tag_entity.origin;
+	org = ent.origin + (ent.mins_z - PL_MIN_z) * '0 0 1';
+	if(ent.tag_entity)
+		org = org + ent.tag_entity.origin;
 	if (navigation_testtracewalk)
 		te_plasmaburn(org);
 	best = world;
@@ -1458,9 +1462,9 @@
 		{
 			if (walkfromwp)
 			{
-				traceline(v, org, TRUE, player);
+				traceline(v, org, TRUE, ent);
 				if (trace_fraction == 1)
-				if (tracewalk(player, v, PL_MIN, PL_MAX, org, MOVE_NORMAL))
+				if (tracewalk(ent, v, PL_MIN, PL_MAX, org, MOVE_NORMAL))
 				{
 					bestdist = dist;
 					best = w;
@@ -1468,9 +1472,9 @@
 			}
 			else
 			{
-				traceline(v, org, TRUE, player);
+				traceline(v, org, TRUE, ent);
 				if (trace_fraction == 1)
-				if (tracewalk(player, org, PL_MIN, PL_MAX, v, MOVE_NORMAL))
+				if (tracewalk(ent, org, PL_MIN, PL_MAX, v, MOVE_NORMAL))
 				{
 					bestdist = dist;
 					best = w;
@@ -1702,9 +1706,14 @@
 	if (time > e.nearestwaypointtimeout)
 	{
 		e.nearestwaypoint = navigation_findnearestwaypoint(e, TRUE);
-		e.nearestwaypointtimeout = time + random() * 3 + 5;
+
+		// TODO: Cleaner solution, probably handling this timeout from ctf.qc
+		if(e.classname=="item_flag_team")
+			e.nearestwaypointtimeout = time + 2;
+		else
+			e.nearestwaypointtimeout = time + random() * 3 + 5;
 	}
-	//dprint(e.classname, " ", ftos(f));
+
 	//dprint("-- checking ", e.classname, " (with cost ", ftos(e.nearestwaypoint.wpcost), ")\n");
 	if (e.nearestwaypoint)
 	if (e.nearestwaypoint.wpcost < 10000000)
@@ -1713,7 +1722,7 @@
 		//dprint(e.classname, " ", ftos(f), "/(1+", ftos((e.nearestwaypoint.wpcost + vlen(e.origin - e.nearestwaypoint.wpnearestpoint))), "/", ftos(rangebias), ") = ");
 		f = f * rangebias / (rangebias + (e.nearestwaypoint.wpcost + vlen(e.origin - e.nearestwaypoint.wpnearestpoint)));
 		//if (self.havocbot_role == havocbot_role_ctf_offense)
-		//	dprint("-- considering ", e.classname, " (with rating ", ftos(f), ")\n");
+		//dprint("considering ", e.classname, " (with rating ", ftos(f), ")\n");
 		//dprint(ftos(f));
 		if (navigation_bestrating < f)
 		{
@@ -1805,7 +1814,7 @@
 	if(self.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
 	{
 		if(self.lastteleporttime>0)
-		if(time-self.lastteleporttime<0.2)
+		if(time-self.lastteleporttime<0.15)
 		{
 			navigation_poproute();
 			return;
@@ -1861,6 +1870,22 @@
 void navigation_goalrating_end()
 {
 	navigation_routetogoals();
+
+	// If 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");
+		local entity head;
+		head = findradius(self.origin,500);
+		while(head)
+		{
+			if(head.classname=="waypoint")
+			if(checkpvs(self.origin,head))
+				navigation_routetogoal(head,self.origin);
+
+			head = head.chain;
+		}
+	}
 };
 
 
@@ -2412,7 +2437,6 @@
 			self.BUTTON_JUMP = 1; // press jump to respawn
 			self.bot_strategytime = 0;
 		}
-		return;
 	}
 
 	// now call the current bot AI (havocbot for example)

Modified: trunk/data/qcsrc/server/havocbot.qc
===================================================================
--- trunk/data/qcsrc/server/havocbot.qc	2009-06-04 11:55:41 UTC (rev 6861)
+++ trunk/data/qcsrc/server/havocbot.qc	2009-06-05 02:06:55 UTC (rev 6862)
@@ -713,13 +713,13 @@
 	if (time < self.havocbot_chooseenemy_finished)
 		return;
 	self.havocbot_chooseenemy_finished = time + cvar("bot_ai_enemydetectioninterval");
-	eye = self.origin + self.view_ofs + '0 0 -25'; // lowered a bit to give room for projectiles
+	eye = self.origin + self.view_ofs;
 	best = world;
 	bestrating = 100000000;
 	head = findchainfloat(bot_attack, TRUE);
 	while (head)
 	{
-		v = (head.absmin + head.absmax) * 0.65;
+		v = (head.absmin + head.absmax) * 0.5;
 		rating = vlen(v - eye);
 		if (bestrating > rating)
 		if (bot_shouldattack(head))
@@ -1011,6 +1011,7 @@
 
 		// TODO: tracewalk() should take care of this job (better path finding under water)
 		// if we don't have a goal and we're under water look for a waypoint near the "shore" and push it
+		if(self.deadflag != DEAD_NO)
 		if(self.goalcurrent==world)
 		if(self.waterlevel==WATERLEVEL_SWIMMING || self.aistatus & AI_STATUS_OUT_WATER)
 		{
@@ -1057,6 +1058,10 @@
 		// token has been used this frame
 		bot_strategytoken_taken = TRUE;
 	}
+
+	if(self.deadflag != DEAD_NO)
+		return;
+
 	havocbot_chooseenemy();
 	if (self.bot_chooseweapontime < time )
 	{



More information about the nexuiz-commits mailing list