float findtrajectorywithleading(vector org, vector m1, vector m2, entity targ, float shotspeed, float shotspeedupward, float maxtime, float shotdelay, entity ignore)
{
local float c, savesolid, shottime;
- local vector dir, end, v;
+ local vector dir, end, v, o;
if (shotspeed < 1)
return FALSE; // could cause division by zero if calculated
if (targ.solid < SOLID_BBOX) // SOLID_NOT and SOLID_TRIGGER
setsize(tracetossent, m1, m2);
savesolid = targ.solid;
targ.solid = SOLID_NOT;
- shottime = ((vlen(targ.origin - org) / shotspeed) + shotdelay);
- v = targ.velocity * shottime + targ.origin;
- tracebox(targ.origin, targ.mins, targ.maxs, v, FALSE, targ);
+ o = (targ.absmin + targ.absmax) * 0.5;
+ shottime = ((vlen(o - org) / shotspeed) + shotdelay);
+ v = targ.velocity * shottime + o;
+ tracebox(o, targ.mins, targ.maxs, v, FALSE, targ);
v = trace_endpos;
end = v + (targ.mins + targ.maxs) * 0.5;
if ((vlen(end - org) / shotspeed + 0.2) > maxtime)
local vector now,v,next;//,heading;
local float aimdistance,skillblend,distanceblend,blend;
- next = now = self.goalcurrent.origin - (self.origin + self.view_ofs);
+ next = now = ( (self.goalcurrent.absmin + self.goalcurrent.absmax) * 0.5) - (self.origin + self.view_ofs);
aimdistance = vlen(now);
//heading = self.velocity;
//dprint(self.goalstack01.classname,etos(self.goalstack01),"\n");
self.goalstack01 != self && self.goalstack01 != world && self.aistatus & AI_STATUS_RUNNING == 0 &&
!(self.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
)
- next = self.goalstack01.origin - (self.origin + self.view_ofs);
+ next = ((self.goalstack01.absmin + self.goalstack01.absmax) * 0.5) - (self.origin + self.view_ofs);
skillblend=bound(0,(skill+self.bot_moveskill-2.5)*0.5,1); //lower skill player can't preturn
distanceblend=bound(0,aimdistance/autocvar_bot_ai_keyboard_distance,1);
local float bunnyhopdistance;
local vector deviation;
local float maxspeed;
+ vector gco, gno;
if(autocvar_g_midair)
return;
self.bot_timelastseengoal = 0;
}
- bunnyhopdistance = vlen(self.origin - self.goalcurrent.origin);
+ gco = (self.goalcurrent.absmin + self.goalcurrent.absmax) * 0.5;
+ bunnyhopdistance = vlen(self.origin - gco);
// Run only to visible goals
if(self.flags & FL_ONGROUND)
if(self.aistatus & AI_STATUS_ROAMING)
if(self.goalcurrent.classname=="waypoint")
if not(self.goalcurrent.wpflags & WAYPOINTFLAG_PERSONAL)
- if(fabs(self.goalcurrent.origin_z - self.origin_z) < self.maxs_z - self.mins_z)
+ if(fabs(gco_z - self.origin_z) < self.maxs_z - self.mins_z)
if(self.goalstack01!=world)
{
- deviation = vectoangles(self.goalstack01.origin - self.origin) - vectoangles(self.goalcurrent.origin - self.origin);
+ gno = (self.goalstack01.absmin + self.goalstack01.absmax) * 0.5;
+ deviation = vectoangles(gno - self.origin) - vectoangles(gco - self.origin);
while (deviation_y < -180) deviation_y = deviation_y + 360;
while (deviation_y > 180) deviation_y = deviation_y - 360;
if(fabs(deviation_y) < 20)
- if(bunnyhopdistance < vlen(self.origin - self.goalstack01.origin))
- if(fabs(self.goalstack01.origin_z - self.goalcurrent.origin_z) < self.maxs_z - self.mins_z)
+ if(bunnyhopdistance < vlen(self.origin - gno))
+ if(fabs(gno_z - gco_z) < self.maxs_z - self.mins_z)
{
- if(vlen(self.goalcurrent.origin - self.goalstack01.origin) > autocvar_bot_ai_bunnyhop_startdistance)
+ if(vlen(gco - gno) > autocvar_bot_ai_bunnyhop_startdistance)
if(checkpvs(self.origin + self.view_ofs, self.goalstack01))
{
checkdistance = FALSE;
local vector evadelava;
local float s;
local float maxspeed;
+ local vector gco;
//local float dist;
local vector dodge;
//if (self.goalentity)
float db, v, d;
vector dxy;
- dxy = self.origin - self.goalcurrent.origin; dxy_z = 0;
+ dxy = self.origin - ( ( self.goalcurrent.absmin + self.goalcurrent.absmax ) * 0.5 ); dxy_z = 0;
d = vlen(dxy);
v = vlen(self.velocity - self.velocity_z * '0 0 1');
db = (pow(v,2) / (autocvar_g_jetpack_acceleration_side * 2)) + 100;
if(distance>1000)
continue;
- traceline(self.origin + self.view_ofs , head.origin, TRUE, world);
+ traceline(self.origin + self.view_ofs , ( ( head.absmin + head.absmax ) * 0.5 ), TRUE, world);
if(trace_fraction<1)
continue;
if(self.goalcurrent==world)
dir = v_forward;
else
- dir = normalize(self.goalcurrent.origin - self.origin);
+ dir = normalize(( ( self.goalcurrent.absmin + self.goalcurrent.absmax ) * 0.5 ) - self.origin);
local vector xyvelocity = self.velocity; xyvelocity_z = 0;
local float xyspeed = xyvelocity * dir;
return;
}
+
if(autocvar_bot_debug_goalstack)
debuggoalstack();
dir = normalize(diff);
flatdir = diff;flatdir_z = 0;
flatdir = normalize(flatdir);
+ gco = (self.goalcurrent.absmin + self.goalcurrent.absmax) * 0.5;
//if (self.bot_dodgevector_time < time)
{
}
else
{
- if(self.velocity_z >= 0 && !(self.watertype == CONTENT_WATER && self.goalcurrent.origin_z < self.origin_z) &&
+ if(self.velocity_z >= 0 && !(self.watertype == CONTENT_WATER && gco_z < self.origin_z) &&
( !(self.waterlevel == WATERLEVEL_WETFEET && self.watertype == CONTENT_WATER) || self.aistatus & AI_STATUS_OUT_WATER))
self.BUTTON_JUMP = TRUE;
else
{
// Remove dangerous dynamic goals from stack
if (self.goalcurrent.classname == "player" || self.goalcurrent.classname == "droppedweapon")
+ {
navigation_poproute();
+ if(self.goalcurrent)
+ gco = (self.goalcurrent.absmin + self.goalcurrent.absmax) * 0.5;
+ }
// try to stop
flatdir = '0 0 0';
evadeobstacle = normalize(self.velocity) * -1;
dodge = havocbot_dodge();
dodge = dodge * bound(0,0.5+(skill+self.bot_dodgeskill)*0.1,1);
evadelava = evadelava * bound(1,3-(skill+self.bot_dodgeskill),3); //Noobs fear lava a lot and take more distance from it
- traceline(self.origin, self.enemy.origin, TRUE, world);
+ traceline(self.origin, ( ( self.enemy.absmin + self.enemy.absmax ) * 0.5 ), TRUE, world);
if(trace_ent.classname == "player")
dir = dir * bound(0,(skill+self.bot_dodgeskill)/7,1);
// and not really really far away
// and we're not severely injured
// then keep tracking for a half second into the future
- traceline(self.origin+self.view_ofs, self.enemy.origin+self.enemy.view_ofs*0.5,FALSE,world);
+ traceline(self.origin+self.view_ofs, ( self.enemy.absmin + self.enemy.absmax ) * 0.5,FALSE,world);
if (trace_ent == self.enemy || trace_fraction == 1)
- if (vlen(self.enemy.origin - self.origin) < 1000)
+ if (vlen((( self.enemy.absmin + self.enemy.absmax ) * 0.5) - self.origin) < 1000)
if (self.health > 30)
{
// remain tracking him for a shot while (case he went after a small corner or pilar
lag_additem(time + self.ping, 0, 0, self.enemy, self.origin, selfvel, self.enemy.origin, enemyvel);
}
else
- lag_additem(time + self.ping, 0, 0, world, self.origin, selfvel, self.goalcurrent.origin, '0 0 0');
+ lag_additem(time + self.ping, 0, 0, world, self.origin, selfvel, ( ( self.goalcurrent.absmin + self.goalcurrent.absmax ) * 0.5 ), '0 0 0');
};
float havocbot_moveto_refresh_route()
debuggoalstack();
// Heading
- local vector dir = self.goalcurrent.origin - (self.origin + self.view_ofs);
+ local vector dir = ( ( self.goalcurrent.absmin + self.goalcurrent.absmax ) * 0.5 ) - (self.origin + self.view_ofs);
dir_z = 0;
bot_aimdir(dir, -1);
void navigation_routerating(entity e, float f, float rangebias)
{
entity nwp;
+ vector o;
if (!e)
return;
+ o = (e.absmin + e.absmax) * 0.5;
//print("routerating ", etos(e), " = ", ftos(f), " - ", ftos(rangebias), "\n");
// Evaluate path using jetpack
if(g_jetpack)
if(self.items & IT_JETPACK)
if(autocvar_bot_ai_navigation_jetpack)
- if(vlen(self.origin - e.origin) > autocvar_bot_ai_navigation_jetpack_mindistance)
+ if(vlen(self.origin - o) > autocvar_bot_ai_navigation_jetpack_mindistance)
{
vector pointa, pointb;
pointa = trace_endpos - '0 0 1';
// Point B
- traceline(e.origin, e.origin + '0 0 65535', MOVE_NORMAL, e);
+ traceline(o, o + '0 0 65535', MOVE_NORMAL, e);
pointb = trace_endpos - '0 0 1';
// Can I see these two points from the sky?
{
//te_wizspike(nwp.wpnearestpoint);
// dprint(e.classname, " ", ftos(f), "/(1+", ftos((nwp.wpcost + vlen(e.origin - nwp.wpnearestpoint))), "/", ftos(rangebias), ") = ");
- f = f * rangebias / (rangebias + (nwp.wpcost + vlen(e.origin - nwp.wpnearestpoint)));
+ f = f * rangebias / (rangebias + (nwp.wpcost + vlen(o - nwp.wpnearestpoint)));
//dprint("considering ", e.classname, " (with rating ", ftos(f), ")\n");
//dprint(ftos(f));
if (navigation_bestrating < f)
return TRUE;
// if it can reach the goal there is nothing more to do
- if (tracewalk(self, startposition, PL_MIN, PL_MAX, e.origin, bot_navigation_movemode))
+ if (tracewalk(self, startposition, PL_MIN, PL_MAX, (e.absmin + e.absmax) * 0.5, bot_navigation_movemode))
return TRUE;
// see if there are waypoints describing a path to the item
void botframe_updatedangerousobjects(float maxupdate)
{
local entity head, bot_dodgelist;
- local vector m1, m2, v;
+ local vector m1, m2, v, o;
local float c, d, danger;
c = 0;
bot_dodgelist = findchainfloat(bot_dodge, TRUE);
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);
- d = head.bot_dodgerating - vlen(head.origin - v);
+ o = (head.absmin + head.absmax) * 0.5;
+ d = head.bot_dodgerating - vlen(o - v);
if (d > 0)
{
- traceline(head.origin, v, TRUE, world);
+ traceline(o, v, TRUE, world);
if (trace_fraction == 1)
danger = danger + d;
}
void debuggoalstack()
{
local entity goal;
- local vector org;
+ local vector org, go;
if(self.goalcounter==0)goal=self.goalcurrent;
else if(self.goalcounter==1)goal=self.goalstack01;
org = self.lastposition;
- te_lightning2(world, org, goal.origin);
- self.lastposition = goal.origin;
+ go = ( goal.absmin + goal.absmax ) * 0.5;
+ te_lightning2(world, org, go);
+ self.lastposition = go;
self.goalcounter++;
}