bool havocbot_checkgoaldistance(entity this, vector gco)
{
float curr_dist = vlen(this.origin - gco);
- if(curr_dist > this.goalcurrent_distance)
+ float curr_dist_2d = vlen(vec2(this.origin - gco));
+ if(curr_dist > this.goalcurrent_distance && curr_dist_2d > this.goalcurrent_distance_2d)
{
if(!this.goalcurrent_distance_time)
this.goalcurrent_distance_time = time;
else
{
// reduce it a little bit so it works even with very small approaches to the goal
- this.goalcurrent_distance = max(20, curr_dist - 15);
+ this.goalcurrent_distance = max(20, curr_dist - 10);
+ this.goalcurrent_distance_2d = max(20, curr_dist_2d - 10);
this.goalcurrent_distance_time = 0;
}
return false;
this.goalentity.bot_pickup_respawning = false;
else if(time < this.goalentity.scheduledrespawntime - 10) // item already taken (by someone else)
{
- this.goalentity.bot_pickup_respawning = false;
- navigation_clearroute(this);
- this.bot_strategytime = 0;
- return;
+ if(checkpvs(this.origin, this.goalentity))
+ {
+ this.goalentity.bot_pickup_respawning = false;
+ navigation_clearroute(this);
+ this.bot_strategytime = 0;
+ return;
+ }
}
else if(this.goalentity == this.goalcurrent)
locked_goal = true; // wait for item to respawn
}
- else if(!this.goalentity.solid)
+ else if(!this.goalentity.solid && !boxesoverlap(this.goalentity.absmin, this.goalentity.absmax, this.absmin, this.absmax))
{
- navigation_clearroute(this);
- this.bot_strategytime = 0;
- return;
+ if(checkpvs(this.origin, this.goalentity))
+ {
+ navigation_clearroute(this);
+ this.bot_strategytime = 0;
+ return;
+ }
}
}
if(!locked_goal)
- navigation_poptouchedgoals(this);
+ {
+ if(navigation_poptouchedgoals(this) && this.bot_strategytime < time + 1)
+ this.bot_strategytime = 0;
+ }
// if ran out of goals try to use an alternative goal or get a new strategy asap
if(this.goalcurrent == NULL)