void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius);
void havocbot_goalrating_waypoints(entity this, float ratingscale, vector org, float sradius);
+bool havocbot_goalrating_item_pickable_check_players(entity this, vector org, entity item, vector item_org);
+
vector havocbot_middlepoint;
float havocbot_middlepoint_radius;
vector havocbot_symmetryaxis_equation;
void navigation_goalrating_timeout_set(entity this);
void navigation_goalrating_timeout_force(entity this);
bool navigation_goalrating_timeout(entity this);
+bool navigation_goalrating_timeout_can_be_anticipated(entity this);
void navigation_markroutes(entity this, entity fixed_source_waypoint);
void navigation_markroutes_inverted(entity fixed_source_waypoint);
void navigation_routerating(entity this, entity e, float f, float rangebias);
}
if(!locked_goal)
{
- if(navigation_poptouchedgoals(this) && time > this.bot_strategytime - (IS_MOVABLE(this.goalentity) ? 3 : 2))
- navigation_goalrating_timeout_force(this);
+ // optimize path finding by anticipating goalrating when bot is near a waypoint;
+ // in this case path finding can start directly from a waypoint instead of
+ // looking for all the reachable waypoints up to a certain distance
+ if(navigation_poptouchedgoals(this) && this.goalcurrent)
+ {
+ if(navigation_goalrating_timeout_can_be_anticipated(this))
+ navigation_goalrating_timeout_force(this);
+ }
}
// if ran out of goals try to use an alternative goal or get a new strategy asap
return this.bot_strategytime < time;
}
+bool navigation_goalrating_timeout_can_be_anticipated(entity this)
+{
+ if(time > this.bot_strategytime - (IS_MOVABLE(this.goalentity) ? 3 : 2))
+ return true;
+
+ if (this.goalentity.bot_pickup && time > this.bot_strategytime - 5)
+ {
+ vector gco = (this.goalentity.absmin + this.goalentity.absmax) * 0.5;
+ if(!havocbot_goalrating_item_pickable_check_players(this, this.origin, this.goalentity, gco))
+ {
+ this.ignoregoal = this.goalentity;
+ this.ignoregoaltime = time + autocvar_bot_ai_ignoregoal_timeout;
+ return true;
+ }
+ }
+ return false;
+}
+
void navigation_dynamicgoal_init(entity this, bool initially_static)
{
this.navigation_dynamicgoal = true;