+#include "navigation.qh"
+
+#include "bot.qh"
+#include "waypoints.qh"
+
+#include "../t_items.qh"
+
+#include "../../common/items/all.qh"
+
+#include "../../common/constants.qh"
+#include "../../common/triggers/trigger/jumppads.qh"
+
+.float speed;
+
void bot_debug(string input)
{
switch(autocvar_bot_debug)
{
- case 1: dprint(input); break;
- case 2: print(input); break;
+ case 1: LOG_TRACE(input); break;
+ case 2: LOG_INFO(input); break;
}
}
// can be traveled, used for waypoint linking and havocbot
float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float movemode)
-{
+{SELFPARAM();
vector org;
vector move;
vector dir;
}
move = end - start;
- move_z = 0;
+ move.z = 0;
org = start;
dist = totaldist = vlen(move);
dir = normalize(move);
// Movement loop
yaw = vectoyaw(move);
move = end - org;
- for(0;;)
+ for (;;)
{
if (boxesoverlap(end, end, org + m1 + '-1 -1 -1', org + m2 + '1 1 1'))
{
{
swimming = true;
org = trace_endpos - normalize(org - trace_endpos) * stepdist;
- for(0; org.z < end.z + self.maxs.z; org.z += stepdist)
+ for (; org.z < end.z + self.maxs.z; org.z += stepdist)
{
if(autocvar_bot_debug_tracewalk)
debugnode(org);
// completely empty the goal stack, used when deciding where to go
void navigation_clearroute()
-{
+{SELFPARAM();
//print("bot ", etos(self), " clear\n");
self.navigation_hasgoals = false;
self.goalcurrent = 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)
-{
+{SELFPARAM();
//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()
-{
+{SELFPARAM();
//print("bot ", etos(self), " pop\n");
self.goalcurrent = self.goalstack01;
self.goalstack01 = self.goalstack02;
}
org = ent.origin + 0.5 * (ent.mins + ent.maxs);
- org_z = ent.origin.z + ent.mins.z - PL_MIN_z; // player height
+ org.z = ent.origin.z + ent.mins.z - PL_MIN.z; // player height
// TODO possibly make other code have the same support for bboxes
if(ent.tag_entity)
org = org + ent.tag_entity.origin;
vector wm1, wm2;
wm1 = w.origin + w.mins;
wm2 = w.origin + w.maxs;
- 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);
}
else
v = w.origin;
// finds the waypoints near the bot initiating a navigation query
float navigation_markroutes_nearestwaypoints(entity waylist, float maxdist)
-{
+{SELFPARAM();
entity head;
vector v, m1, m2, diff;
float c;
m1 = head.origin + head.mins;
m2 = head.origin + head.maxs;
v = self.origin;
- 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);
}
else
v = head.origin;
diff = v - self.origin;
- diff_z = max(0, diff.z);
+ diff.z = max(0, diff.z);
if (vlen(diff) < maxdist)
{
head.wpconsidered = true;
{
m1 = wp.absmin;
m2 = wp.absmax;
- 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);
}
else
v = wp.origin;
// queries the entire spawnfunc_waypoint network for pathes leading away from the bot
void navigation_markroutes(entity fixed_source_waypoint)
-{
+{SELFPARAM();
entity w, wp, waylist;
float searching, cost, cost2;
vector p;
// 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)
-{
+{SELFPARAM();
entity nwp;
vector o;
if (!e)
float zdistance, xydistance, cost, t, fuel;
vector down, npa, npb;
- down = '0 0 -1' * (PL_MAX_z - PL_MIN_z) * 10;
+ down = '0 0 -1' * (PL_MAX.z - PL_MIN.z) * 10;
do{
npa = pointa + down;
// adds an item to the the goal stack with the path to a given item
float navigation_routetogoal(entity e, vector startposition)
-{
+{SELFPARAM();
self.goalentity = e;
// if there is no goal, just exit
if(e == world)
return false;
- for(0;;)
+ for (;;)
{
// add the spawnfunc_waypoint to the path
navigation_pushroute(e);
// removes any currently touching waypoints from the goal stack
// (this is how bots detect if they reached a goal)
void navigation_poptouchedgoals()
-{
+{SELFPARAM();
vector org, m1, m2;
org = self.origin;
m1 = org + self.mins;
// begin a goal selection session (queries spawnfunc_waypoint network)
void navigation_goalrating_start()
-{
+{SELFPARAM();
if(self.aistatus & AI_STATUS_STUCK)
return;
// ends a goal selection session (updates goal stack to the best goal)
void navigation_goalrating_end()
-{
+{SELFPARAM();
if(self.aistatus & AI_STATUS_STUCK)
return;
while (head)
{
v = head.origin;
- 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);
o = (head.absmin + head.absmax) * 0.5;
d = head.bot_dodgerating - vlen(o - v);
if (d > 0)
}
void navigation_unstuck()
-{
+{SELFPARAM();
float search_radius = 1000;
if (!autocvar_bot_wander_enable)
}
void debugnode(vector node)
-{
+{SELFPARAM();
if (!IS_PLAYER(self))
return;
// Debug the goal stack visually
void debuggoalstack()
-{
+{SELFPARAM();
entity goal;
vector org, go;