this.havocbot_role(this); // little too far down the rabbit hole
}
- // 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(!(IS_DEAD(this) || STAT(FROZEN, this)))
if(!this.goalcurrent)
vector now,v,next;//,heading;
float aimdistance,skillblend,distanceblend,blend;
- next = now = ( (this.goalcurrent.absmin + this.goalcurrent.absmax) * 0.5) - (this.origin + this.view_ofs);
+
+ SET_DESTCOORDS(this.goalcurrent, this.origin, now);
+ next = now = now - (this.origin + this.view_ofs);
aimdistance = vlen(now);
//heading = this.velocity;
//dprint(this.goalstack01.classname,etos(this.goalstack01),"\n");
this.bot_timelastseengoal = 0;
}
- gco = (this.goalcurrent.absmin + this.goalcurrent.absmax) * 0.5;
+ SET_DESTCOORDS(this.goalcurrent, this.origin, gco);
bunnyhopdistance = vlen(this.origin - gco);
// Run only to visible goals
vector diff;
vector dir;
vector flatdir;
- vector m1;
- vector m2;
vector evadeobstacle;
vector evadelava;
float maxspeed;
if(autocvar_bot_debug_goalstack)
debuggoalstack(this);
- m1 = this.goalcurrent.origin + this.goalcurrent.mins;
- m2 = this.goalcurrent.origin + this.goalcurrent.maxs;
- destorg = this.origin;
- destorg.x = bound(m1_x, destorg.x, m2_x);
- destorg.y = bound(m1_y, destorg.y, m2_y);
- destorg.z = bound(m1_z, destorg.z, m2_z);
+ SET_DESTCOORDS(this.goalcurrent, this.origin, destorg);
// in case bot ends up inside the teleport waypoint without touching
// the teleport itself, head to the teleport origin
debuggoalstack(this);
// Heading
- vector dir = ( ( this.goalcurrent.absmin + this.goalcurrent.absmax ) * 0.5 ) - (this.origin + this.view_ofs);
+ vector dir;
+ SET_DESTCOORDS(this.goalcurrent, this.origin, dir);
+ dir = dir - (this.origin + this.view_ofs);
dir.z = 0;
bot_aimdir(this, dir, -1);
#define navigation_item_addlink(from_wp, to_item) \
waypoint_addlink_customcost(to_item, from_wp, waypoint_getlinkcost(from_wp, to_item))
+// if ent is a box waypoint or an item v is set to coords of ent that are closer to org
+// (but v.z is set to the middle coord of ent)
+#define SET_DESTCOORDS(ent, org, v) MACRO_BEGIN { \
+ if ((ent.classname != "waypoint") || ent.wpisbox) { \
+ vector wm1 = ent.origin + ent.mins; \
+ vector wm2 = ent.origin + ent.maxs; \
+ v.x = bound(wm1.x, org.x, wm2.x); \
+ v.y = bound(wm1.y, org.y, wm2.y); \
+ v.z = (wm2.z - wm1.z) / 2; \
+ } else { \
+ v = ent.origin; \
+ } \
+} MACRO_END
+
// if ent is a box waypoint or an item v is set to coords of ent that are closer to org
// (but v.z is set to the lowest coord of ent), v_height is set to ent's height
#define SET_TRACEWALK_DESTCOORDS(ent, org, v, v_height) MACRO_BEGIN { \