// can be traveled, used for waypoint linking and havocbot
float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float movemode)
// can be traveled, used for waypoint linking and havocbot
float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float movemode)
// Analyze starting point
traceline(start, start, MOVE_NORMAL, e);
if (trace_dpstartcontents & (DPCONTENTS_SLIME | DPCONTENTS_LAVA))
// Analyze starting point
traceline(start, start, MOVE_NORMAL, e);
if (trace_dpstartcontents & (DPCONTENTS_SLIME | DPCONTENTS_LAVA))
else
{
traceline( start, start + '0 0 -65536', MOVE_NORMAL, e);
if (trace_dpstartcontents & (DPCONTENTS_SLIME | DPCONTENTS_LAVA))
{
else
{
traceline( start, start + '0 0 -65536', MOVE_NORMAL, e);
if (trace_dpstartcontents & (DPCONTENTS_SLIME | DPCONTENTS_LAVA))
{
}
}
tracebox(start, m1, m2, start, MOVE_NOMONSTERS, e);
}
}
tracebox(start, m1, m2, start, MOVE_NOMONSTERS, e);
debugnodestatus(start, DEBUG_NODE_FAIL);
//print("tracewalk: ", vtos(start), " is a bad start\n");
debugnodestatus(start, DEBUG_NODE_FAIL);
//print("tracewalk: ", vtos(start), " is a bad start\n");
debugnodestatus(org, DEBUG_NODE_SUCCESS);
//print("tracewalk: ", vtos(start), " can reach ", vtos(end), "\n");
debugnodestatus(org, DEBUG_NODE_SUCCESS);
//print("tracewalk: ", vtos(start), " can reach ", vtos(end), "\n");
debugnodestatus(org, DEBUG_NODE_FAIL);
//print("tracewalk: ", vtos(start), " hits a hazard when trying to reach ", vtos(end), "\n");
debugnodestatus(org, DEBUG_NODE_FAIL);
//print("tracewalk: ", vtos(start), " hits a hazard when trying to reach ", vtos(end), "\n");
if(autocvar_bot_debug_tracewalk)
debugnodestatus(org, DEBUG_NODE_FAIL);
if(autocvar_bot_debug_tracewalk)
debugnodestatus(org, DEBUG_NODE_FAIL);
//print("tracewalk: ", vtos(start), " hit something when trying to reach ", vtos(end), "\n");
//te_explosion(trace_endpos);
//print(ftos(e.dphitcontentsmask), "\n");
//print("tracewalk: ", vtos(start), " hit something when trying to reach ", vtos(end), "\n");
//te_explosion(trace_endpos);
//print(ftos(e.dphitcontentsmask), "\n");
float c;
c = pointcontents(org + '0 0 1');
if (!(c == CONTENT_WATER || c == CONTENT_LAVA || c == CONTENT_SLIME))
float c;
c = pointcontents(org + '0 0 1');
if (!(c == CONTENT_WATER || c == CONTENT_LAVA || c == CONTENT_SLIME))
if(autocvar_bot_debug_tracewalk)
debugnodestatus(org, DEBUG_NODE_FAIL);
if(autocvar_bot_debug_tracewalk)
debugnodestatus(org, DEBUG_NODE_FAIL);
// completely empty the goal stack, used when deciding where to go
void navigation_clearroute()
// completely empty the goal stack, used when deciding where to go
void navigation_clearroute()
self.goalcurrent = world;
self.goalstack01 = world;
self.goalstack02 = world;
self.goalcurrent = world;
self.goalstack01 = world;
self.goalstack02 = world;
// That means, if the stack overflows, the bot will know how to do the FIRST 32
// steps to the goal, and then recalculate the path.
void navigation_pushroute(entity e)
// That means, if the stack overflows, the bot will know how to do the FIRST 32
// steps to the goal, and then recalculate the path.
void navigation_pushroute(entity e)
//print("bot ", etos(self), " push ", etos(e), "\n");
self.goalstack31 = self.goalstack30;
self.goalstack30 = self.goalstack29;
//print("bot ", etos(self), " push ", etos(e), "\n");
self.goalstack31 = self.goalstack30;
self.goalstack30 = self.goalstack29;
// (in other words: remove a prerequisite for reaching the later goals)
// (used when a spawnfunc_waypoint is reached)
void navigation_poproute()
// (in other words: remove a prerequisite for reaching the later goals)
// (used when a spawnfunc_waypoint is reached)
void navigation_poproute()
//print("bot ", etos(self), " pop\n");
self.goalcurrent = self.goalstack01;
self.goalstack01 = self.goalstack02;
//print("bot ", etos(self), " pop\n");
self.goalcurrent = self.goalstack01;
self.goalstack01 = self.goalstack02;
- traceline(v, org, TRUE, ent);
+ traceline(v, org, true, ent);
if (trace_fraction == 1)
{
if (walkfromwp)
{
if (tracewalk(ent, v, PL_MIN, PL_MAX, org, bot_navigation_movemode))
if (trace_fraction == 1)
{
if (walkfromwp)
{
if (tracewalk(ent, v, PL_MIN, PL_MAX, org, bot_navigation_movemode))
}
else
{
if (tracewalk(ent, org, PL_MIN, PL_MAX, v, bot_navigation_movemode))
}
else
{
if (tracewalk(ent, org, PL_MIN, PL_MAX, v, bot_navigation_movemode))
- v_x = bound(wm1_x, org_x, wm2_x);
- v_y = bound(wm1_y, org_y, wm2_y);
- v_z = bound(wm1_z, org_z, wm2_z);
+ v.x = bound(wm1_x, org.x, wm2_x);
+ v.y = bound(wm1_y, org.y, wm2_y);
+ v.z = bound(wm1_z, org.z, wm2_z);
// finds the waypoints near the bot initiating a navigation query
float navigation_markroutes_nearestwaypoints(entity waylist, float maxdist)
// finds the waypoints near the bot initiating a navigation query
float navigation_markroutes_nearestwaypoints(entity waylist, float maxdist)
- v_x = bound(m1_x, v_x, m2_x);
- v_y = bound(m1_y, v_y, m2_y);
- v_z = bound(m1_z, v_z, m2_z);
+ v.x = bound(m1_x, v.x, m2_x);
+ v.y = bound(m1_y, v.y, m2_y);
+ v.z = bound(m1_z, v.z, m2_z);
if (tracewalk(self, self.origin, self.mins, self.maxs, v, bot_navigation_movemode))
{
head.wpnearestpoint = v;
if (tracewalk(self, self.origin, self.mins, self.maxs, v, bot_navigation_movemode))
{
head.wpnearestpoint = v;
- v_x = bound(m1_x, p_x, m2_x);
- v_y = bound(m1_y, p_y, m2_y);
- v_z = bound(m1_z, p_z, m2_z);
+ v.x = bound(m1_x, p.x, m2_x);
+ v.y = bound(m1_y, p.y, m2_y);
+ v.z = bound(m1_z, p.z, m2_z);
// queries the entire spawnfunc_waypoint network for pathes leading away from the bot
void navigation_markroutes(entity fixed_source_waypoint)
// queries the entire spawnfunc_waypoint network for pathes leading away from the bot
void navigation_markroutes(entity fixed_source_waypoint)
entity w, wp, waylist;
float searching, cost, cost2;
vector p;
w = waylist = findchain(classname, "waypoint");
while (w)
{
entity w, wp, waylist;
float searching, cost, cost2;
vector p;
w = waylist = findchain(classname, "waypoint");
while (w)
{
fixed_source_waypoint.wpnearestpoint = fixed_source_waypoint.origin + 0.5 * (fixed_source_waypoint.mins + fixed_source_waypoint.maxs);
fixed_source_waypoint.wpcost = fixed_source_waypoint.dmg;
fixed_source_waypoint.wpfire = 1;
fixed_source_waypoint.wpnearestpoint = fixed_source_waypoint.origin + 0.5 * (fixed_source_waypoint.mins + fixed_source_waypoint.maxs);
fixed_source_waypoint.wpcost = fixed_source_waypoint.dmg;
fixed_source_waypoint.wpfire = 1;
fixed_source_waypoint.wpnearestpoint = fixed_source_waypoint.origin + 0.5 * (fixed_source_waypoint.mins + fixed_source_waypoint.maxs);
fixed_source_waypoint.wpcost = fixed_source_waypoint.dmg; // the cost to get from X to fixed_source_waypoint
fixed_source_waypoint.wpfire = 1;
fixed_source_waypoint.wpnearestpoint = fixed_source_waypoint.origin + 0.5 * (fixed_source_waypoint.mins + fixed_source_waypoint.maxs);
fixed_source_waypoint.wpcost = fixed_source_waypoint.dmg; // the cost to get from X to fixed_source_waypoint
fixed_source_waypoint.wpfire = 1;
// updates the best goal according to a weighted calculation of travel cost and item value of a new proposed item
void navigation_routerating(entity e, float f, float rangebias)
// updates the best goal according to a weighted calculation of travel cost and item value of a new proposed item
void navigation_routerating(entity e, float f, float rangebias)
float zdistance, xydistance, cost, t, fuel;
vector down, npa, npb;
float zdistance, xydistance, cost, t, fuel;
vector down, npa, npb;
break;
traceline(npa, npb, MOVE_NORMAL, self);
break;
traceline(npa, npb, MOVE_NORMAL, self);
// Rough estimation of fuel consumption
// (ignores acceleration and current xyz velocity)
xydistance = vlen(pointa - pointb);
// Rough estimation of fuel consumption
// (ignores acceleration and current xyz velocity)
xydistance = vlen(pointa - pointb);
bot_debug(strcat("FAILED to find a nearest waypoint to '", e.classname, "' #", etos(e), "\n"));
if(e.flags & FL_ITEM)
bot_debug(strcat("FAILED to find a nearest waypoint to '", e.classname, "' #", etos(e), "\n"));
if(e.flags & FL_ITEM)
// adds an item to the the goal stack with the path to a given item
float navigation_routetogoal(entity e, vector startposition)
// adds an item to the the goal stack with the path to a given item
float navigation_routetogoal(entity e, vector startposition)
// put the entity on the goal stack
//print("routetogoal ", etos(e), "\n");
// put the entity on the goal stack
//print("routetogoal ", etos(e), "\n");
// if it can reach the goal there is nothing more to do
if (tracewalk(self, startposition, PL_MIN, PL_MAX, (e.absmin + e.absmax) * 0.5, bot_navigation_movemode))
// if it can reach the goal there is nothing more to do
if (tracewalk(self, startposition, PL_MIN, PL_MAX, (e.absmin + e.absmax) * 0.5, bot_navigation_movemode))
// see if there are waypoints describing a path to the item
if(e.classname != "waypoint" || (e.wpflags & WAYPOINTFLAG_PERSONAL))
// see if there are waypoints describing a path to the item
if(e.classname != "waypoint" || (e.wpflags & WAYPOINTFLAG_PERSONAL))
}
// removes any currently touching waypoints from the goal stack
// (this is how bots detect if they reached a goal)
void navigation_poptouchedgoals()
}
// removes any currently touching waypoints from the goal stack
// (this is how bots detect if they reached a goal)
void navigation_poptouchedgoals()
- traceline(self.origin + self.view_ofs , self.goalcurrent.origin, TRUE, world);
+ traceline(self.origin + self.view_ofs , self.goalcurrent.origin, true, world);
// begin a goal selection session (queries spawnfunc_waypoint network)
void navigation_goalrating_start()
// begin a goal selection session (queries spawnfunc_waypoint network)
void navigation_goalrating_start()
if(self.aistatus & AI_STATUS_STUCK)
return;
self.navigation_jetpack_goal = world;
navigation_bestrating = -1;
if(self.aistatus & AI_STATUS_STUCK)
return;
self.navigation_jetpack_goal = world;
navigation_bestrating = -1;
// ends a goal selection session (updates goal stack to the best goal)
void navigation_goalrating_end()
// ends a goal selection session (updates goal stack to the best goal)
void navigation_goalrating_end()
botframe_dangerwaypoint = find(botframe_dangerwaypoint, classname, "waypoint");
while (botframe_dangerwaypoint != world)
{
botframe_dangerwaypoint = find(botframe_dangerwaypoint, classname, "waypoint");
while (botframe_dangerwaypoint != world)
{
- v_x = bound(m1_x, v_x, m2_x);
- v_y = bound(m1_y, v_y, m2_y);
- v_z = bound(m1_z, v_z, m2_z);
+ v.x = bound(m1_x, v.x, m2_x);
+ v.y = bound(m1_y, v.y, m2_y);
+ v.z = bound(m1_z, v.z, m2_z);
- traceline(o, v, TRUE, world);
+ traceline(o, v, true, world);