// Movement loop
yaw = vectoyaw(move);
move = end - org;
- for (;;)
+ for(0;;)
{
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(; org_z < end_z + self.maxs_z; org_z += stepdist)
+ for(0; org.z < end.z + self.maxs.z; org.z += stepdist)
{
if(autocvar_bot_debug_tracewalk)
debugnode(org);
break;
}
- if not (pointcontents(org + '0 0 1') == CONTENT_EMPTY)
+ if(pointcontents(org + '0 0 1') != CONTENT_EMPTY)
{
if(autocvar_bot_debug_tracewalk)
debugnodestatus(org, DEBUG_NODE_FAIL);
{
float c;
c = pointcontents(org + '0 0 1');
- if not(c == CONTENT_WATER || c == CONTENT_LAVA || c == CONTENT_SLIME)
+ if (!(c == CONTENT_WATER || c == CONTENT_LAVA || c == CONTENT_SLIME))
swimming = FALSE;
else
continue;
}
// find the spawnfunc_waypoint near a dynamic goal such as a dropped weapon
-entity navigation_findnearestwaypoint_withdist(entity ent, float walkfromwp, float bestdist)
+entity navigation_findnearestwaypoint_withdist_except(entity ent, float walkfromwp, float bestdist, entity except)
{
entity waylist, w, best;
vector v, org, pm1, pm2;
while (w)
{
// if object is touching spawnfunc_waypoint
- if(w != ent)
+ if(w != ent && w != except)
if (boxesoverlap(pm1, pm2, w.absmin, w.absmax))
return w;
w = w.chain;
}
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;
}
entity navigation_findnearestwaypoint(entity ent, float walkfromwp)
{
- return navigation_findnearestwaypoint_withdist(ent, walkfromwp, 1050);
+ entity wp = navigation_findnearestwaypoint_withdist_except(ent, walkfromwp, 1050, world);
+ if (autocvar_g_waypointeditor_auto)
+ {
+ entity wp2 = navigation_findnearestwaypoint_withdist_except(ent, walkfromwp, 1050, wp);
+ if (wp && !wp2)
+ wp.wpflags |= WAYPOINTFLAG_PROTECTED;
+ }
+ return wp;
}
// finds the waypoints near the bot initiating a navigation query
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;
npa = pointa + down;
npb = pointb + down;
- if(npa_z<=self.absmax_z)
+ if(npa.z<=self.absmax.z)
break;
- if(npb_z<=e.absmax_z)
+ if(npb.z<=e.absmax.z)
break;
traceline(npa, npb, MOVE_NORMAL, self);
// Rough estimation of fuel consumption
// (ignores acceleration and current xyz velocity)
xydistance = vlen(pointa - pointb);
- zdistance = fabs(pointa_z - self.origin_z);
+ zdistance = fabs(pointa.z - self.origin.z);
t = zdistance / autocvar_g_jetpack_maxspeed_up;
t += xydistance / autocvar_g_jetpack_maxspeed_side;
fuel = t * autocvar_g_jetpack_fuel * 0.8;
-
+
bot_debug(strcat("jetpack ai: required fuel ", ftos(fuel), " self.ammo_fuel ", ftos(self.ammo_fuel), "\n"));
// enough fuel ?
if(e.flags & FL_ITEM)
{
- if not(e.flags & FL_WEAPON)
+ if (!(e.flags & FL_WEAPON))
if(e.nearestwaypoint)
search = FALSE;
}
if(e == world)
return FALSE;
- for (;;)
+ for(0;;)
{
// add the spawnfunc_waypoint to the path
navigation_pushroute(e);
bot_debug(strcat("best goal ", self.goalcurrent.classname , "\n"));
// If the bot got stuck then try to reach the farthest waypoint
- if not (self.navigation_hasgoals)
+ if (!self.navigation_hasgoals)
if (autocvar_bot_wander_enable)
{
- if not(self.aistatus & AI_STATUS_STUCK)
+ if (!(self.aistatus & AI_STATUS_STUCK))
{
bot_debug(strcat(self.netname, " cannot walk to any goal\n"));
self.aistatus |= AI_STATUS_STUCK;
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)
{
float search_radius = 1000;
- if not(autocvar_bot_wander_enable)
+ if (!autocvar_bot_wander_enable)
return;
- if not(bot_waypoint_queue_owner)
+ if (!bot_waypoint_queue_owner)
{
bot_debug(strcat(self.netname, " sutck, taking over the waypoints queue\n"));
bot_waypoint_queue_owner = self;
}
bot_waypoint_queue_goal = bot_waypoint_queue_goal.bot_waypoint_queue_nextgoal;
- if not(bot_waypoint_queue_goal)
+ if (!bot_waypoint_queue_goal)
{
if (bot_waypoint_queue_bestgoal)
{
void debugnode(vector node)
{
- if not(IS_PLAYER(self))
+ if (!IS_PLAYER(self))
return;
if(debuglastnode=='0 0 0')