r5924 - in trunk/data: . qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Feb 22 10:57:49 EST 2009


Author: mand1nga
Date: 2009-02-22 10:57:49 -0500 (Sun, 22 Feb 2009)
New Revision: 5924

Modified:
   trunk/data/defaultNexuiz.cfg
   trunk/data/qcsrc/server/bots.qc
   trunk/data/qcsrc/server/havocbot.qc
Log:
Bots: Check for dangers when running


Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg	2009-02-22 13:05:49 UTC (rev 5923)
+++ trunk/data/defaultNexuiz.cfg	2009-02-22 15:57:49 UTC (rev 5924)
@@ -366,7 +366,7 @@
 set bot_ai_ignoregoal_timeout 3	"Ignore goals making bots to get stuck in front of a wall for N seconds"
 set bot_ai_bunnyhop_skilloffset 7	"Bots with skill equal or greater than this value will perform the  \"bunnyhop\" technique"
 set bot_ai_bunnyhop_startdistance 250 "Run to goals located further than this distance"
-set bot_ai_bunnyhop_stopdistance 200 "Stop jumping after reaching this distance to the goal"
+set bot_ai_bunnyhop_stopdistance 220 "Stop jumping after reaching this distance to the goal"
 set bot_ai_bunnyhop_firstjumpdelay 0.5 "Start running to the goal only if it was seen for more than N seconds"
 // Better don't touch these, there are hard to tweak!
 set bot_ai_aimskill_order_mix_1st 0.01

Modified: trunk/data/qcsrc/server/bots.qc
===================================================================
--- trunk/data/qcsrc/server/bots.qc	2009-02-22 13:05:49 UTC (rev 5923)
+++ trunk/data/qcsrc/server/bots.qc	2009-02-22 15:57:49 UTC (rev 5924)
@@ -1,7 +1,8 @@
 .float aistatus;
-float AI_STATUS_ROAMING		= 1;
-float AI_STATUS_ATTACKING	= 2;
-float AI_STATUS_RUNNING		= 4;
+float AI_STATUS_ROAMING			= 1;	// Bot is just crawling the map. No enemies at sight
+float AI_STATUS_ATTACKING		= 2;	// There are enemies at sight
+float AI_STATUS_RUNNING			= 4;	// Bot is bunny hopping
+float AI_STATUS_DANGER_AHEAD	= 8;	// There is lava/slime/abism ahead
 
 .string netname_freeme;
 

Modified: trunk/data/qcsrc/server/havocbot.qc
===================================================================
--- trunk/data/qcsrc/server/havocbot.qc	2009-02-22 13:05:49 UTC (rev 5923)
+++ trunk/data/qcsrc/server/havocbot.qc	2009-02-22 15:57:49 UTC (rev 5924)
@@ -146,6 +146,9 @@
 	if(self.goalcurrent.classname == "player")
 		return;
 
+	if(self.aistatus & AI_STATUS_DANGER_AHEAD)
+		return;
+
 	if(self.bot_lastseengoal != self.goalcurrent && !(self.aistatus & AI_STATUS_RUNNING))
 	{
 		self.bot_canruntogoal = 0;
@@ -305,7 +308,6 @@
 #ifdef DEBUG_BOT_GOALSTACK
 	debuggoalstack();
 #endif
-//	te_lightning2(world, self.goalcurrent.origin + self.goalcurrent.mins, self.goalcurrent.origin + self.goalcurrent.maxs);
 
 	m1 = self.goalcurrent.origin + self.goalcurrent.mins;
 	m2 = self.goalcurrent.origin + self.goalcurrent.maxs;
@@ -353,63 +355,61 @@
 
 			// avoiding dangers and obstacles
 			// TODO: don't make this check every frame
-			if(self.flags & FL_ONGROUND)
+			local vector dst_ahead, dst_down;
+			dst_ahead = self.origin + self.view_ofs + (self.velocity * 0.32);
+			dst_down = dst_ahead + '0 0 -1500';				
+			
+			traceline(self.origin + self.view_ofs , dst_ahead, TRUE, world);
+
+			// Check head-banging against walls
+			if(vlen(self.origin + self.view_ofs - trace_endpos) < 2)
 			{
-				local vector dst_ahead, dst_down;
-				dst_ahead = self.origin + self.view_ofs + (self.velocity * 0.3);
-				dst_down = dst_ahead + '0 0 -1500';				
-				
-				traceline(self.origin + self.view_ofs , dst_ahead, TRUE, world);
-
-				// Check head-banging against walls
-				if(vlen(self.origin + self.view_ofs - trace_endpos) < 2)
+				if(self.facingwalltime && time > self.facingwalltime)
 				{
-					if(self.facingwalltime && time > self.facingwalltime)
-					{
-						self.ignoregoal = self.goalcurrent;
-						self.ignoregoaltime = time + cvar("bot_ai_ignoregoal_timeout");
-						navigation_poproute();
-					}
-					else
-					{
-						self.facingwalltime = time + 0.05;
-					}
+					self.ignoregoal = self.goalcurrent;
+					self.ignoregoaltime = time + cvar("bot_ai_ignoregoal_timeout");
+					navigation_poproute();
 				}
 				else
 				{
-					self.facingwalltime = 0;
+					self.facingwalltime = time + 0.05;
+				}
+			}
+			else
+			{
+				self.facingwalltime = 0;
 
-					if(self.ignoregoal != world && time > self.ignoregoaltime)
+				if(self.ignoregoal != world && time > self.ignoregoaltime)
+				{
+					self.ignoregoal = world;
+					self.ignoregoaltime = 0;
+				}
+			}
+		
+			// Check for water/slime/lava and edges
+			self.aistatus &~= AI_STATUS_DANGER_AHEAD;
+			if(trace_fraction == 1){
+				traceline(dst_ahead , dst_down, TRUE, world);
+				//	te_lightning2(world, self.origin, dst_ahead);	// Draw "ahead" look 
+				s = pointcontents(trace_endpos + '0 0 1');
+				if (s != CONTENT_SOLID)
+				if (s == CONTENT_LAVA || s == CONTENT_SLIME)
+					evadelava = normalize(self.velocity) * -1;
+				else if (s == CONTENT_SKY)
+					evadeobstacle = normalize(self.velocity) * -1;
+				else if (tracebox_hits_trigger_hurt(dst_ahead, self.mins, self.maxs, trace_endpos))
+				{
+					//	te_lightning2(world, dst_ahead, dst_down);	// Draw "downwards" look
+					// if ain't a safe goal with "holes" (like the soylent jumpad)
+					if(!boxesoverlap(dst_ahead - self.view_ofs + self.mins, dst_ahead - self.view_ofs + self.maxs, 
+							self.goalcurrent.absmin, self.goalcurrent.absmax))
 					{
-						self.ignoregoal = world;
-						self.ignoregoaltime = 0;
-					}
-				}
-			
-				// Check for water/slime/lava and edges
-				if(trace_fraction == 1){
-					traceline(dst_ahead , dst_down, TRUE, world);
-					//	te_lightning2(world, self.origin, dst_ahead);	// Draw "ahead" look 
-					s = pointcontents(trace_endpos + '0 0 1');
-					if (s != CONTENT_SOLID)
-					if (s == CONTENT_LAVA || s == CONTENT_SLIME)
-						evadelava = normalize(self.velocity) * -1;
-					else if (s == CONTENT_SKY)
+						// Remove dangerous dynamic goals from stack
+						if (self.goalcurrent.classname == "player" || self.goalcurrent.classname == "droppedweapon")
+							navigation_poproute();
+						// try to stop
+						flatdir = '0 0 0';
 						evadeobstacle = normalize(self.velocity) * -1;
-					else if (tracebox_hits_trigger_hurt(dst_ahead, self.mins, self.maxs, trace_endpos))
-					{
-						//	te_lightning2(world, dst_ahead, dst_down);	// Draw "downwards" look
-						// if ain't a safe goal with "holes" (like the soylent jumpad)
-						if(!boxesoverlap(dst_ahead - self.view_ofs + self.mins, dst_ahead - self.view_ofs + self.maxs, 
-								self.goalcurrent.absmin, self.goalcurrent.absmax))
-						{
-							// Remove dangerous dynamic goals from stack
-							if (self.goalcurrent.classname == "player" || self.goalcurrent.classname == "droppedweapon")
-								navigation_poproute();
-							// try to stop
-							flatdir = '0 0 0';
-							evadeobstacle = normalize(self.velocity) * -1;
-						}
 					}
 				}
 			}
@@ -418,6 +418,9 @@
 			evadeobstacle_z = 0;
 			evadelava_z = 0;
 			makevectors(self.v_angle_y * '0 1 0');
+
+			if(evadeobstacle!='0 0 0'||evadelava!='0 0 0')
+				self.aistatus |= AI_STATUS_DANGER_AHEAD;
 		}
 
 		dodge = havocbot_dodge();




More information about the nexuiz-commits mailing list