navigation_goalrating_timeout_force(this);
return;
}
+ locked_goal = true; // wait for item to respawn
}
else if(this.goalentity == this.goalcurrent)
locked_goal = true; // wait for item to respawn
}
}
}
+ if (this.goalcurrent == this.goalentity && this.goalentity_lock_timeout > time)
+ locked_goal = true;
+
if(!locked_goal)
{
// optimize path finding by anticipating goalrating when bot is near a waypoint;
}
diff = destorg - this.origin;
- //dist = vlen(diff);
+
+ if (fabs(diff.x) < 10 && fabs(diff.y) < 10
+ && this.goalcurrent == this.goalentity && time < this.goalentity_lock_timeout)
+ {
+ destorg = this.origin;
+ diff.x = 0;
+ diff.y = 0;
+ }
+
dir = normalize(diff);
flatdir = diff;flatdir.z = 0;
flatdir = normalize(flatdir);
// if bot for some reason doesn't get close to the current goal find another one
if(!this.jumppadcount && !IS_PLAYER(this.goalcurrent))
- if(!(this.goalcurrent.bot_pickup_respawning && this.goalcurrent_distance_z < 50 && this.goalcurrent_distance_2d < 50))
+ if(!(locked_goal && this.goalcurrent_distance_z < 50 && this.goalcurrent_distance_2d < 50))
if(havocbot_checkgoaldistance(this, gco))
{
if(this.goalcurrent_distance_time < 0) // can't get close for the second time
this.goalcurrent_distance_2d = FLOAT_MAX;
this.goalcurrent_distance_z = FLOAT_MAX;
this.goalcurrent_distance_time = 0;
- //print("bot ", etos(this), " clear\n");
+ this.goalentity_lock_timeout = 0;
this.goalentity = NULL;
this.goalcurrent = NULL;
this.goalstack01 = NULL;
this.goalcurrent_distance_time = 0;
//print("bot ", etos(this), " pop\n");
if(this.goalcurrent == this.goalentity)
+ {
this.goalentity = NULL;
+ this.goalentity_lock_timeout = 0;
+ }
this.goalcurrent = this.goalstack01;
this.goalstack01 = this.goalstack02;
this.goalstack02 = this.goalstack03;
.float goalcurrent_distance_2d;
.float goalcurrent_distance_time;
+.float goalentity_lock_timeout;
+
.entity nearestwaypoint;
.float nearestwaypointtimeout;
if(CTF_DIFFTEAM(player, flag)) { return; }
if((flag.cnt || enemy_flag.cnt) && flag.cnt != enemy_flag.cnt) { return; } // this should catch some edge cases (capturing grouped flag at ungrouped flag disallowed etc)
+ if (toucher.goalentity == flag.bot_basewaypoint)
+ toucher.goalentity_lock_timeout = 0;
+
if(ctf_oneflag)
for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext)
if(SAME_TEAM(tmp_entity, player))
navigation_goalrating_timeout_set(this);
+ entity head = ctf_worldflaglist;
+ while (head)
+ {
+ if (this.goalentity == head.bot_basewaypoint)
+ {
+ this.goalentity_lock_timeout = time + 5;
+ break;
+ }
+ head = head.ctf_worldflagnext;
+ }
+
if (this.goalentity)
this.havocbot_cantfindflag = time + 10;
else if (time > this.havocbot_cantfindflag)