void navigation_goalrating_start(entity this);
void navigation_goalrating_timeout_set(entity this);
void navigation_goalrating_timeout_force(entity this);
+void navigation_goalrating_timeout_expire(entity this, float seconds);
bool navigation_goalrating_timeout(entity this);
bool navigation_goalrating_timeout_can_be_anticipated(entity this);
void navigation_markroutes(entity this, entity fixed_source_waypoint);
// frame, which causes choppy framerates)
if (bot_strategytoken_taken)
{
+ // give goal token to the first bot without goals; if all bots don't have
+ // any goal (or are dead/frozen) simply give it to the next one
bot_strategytoken_taken = false;
entity bot_strategytoken_save = bot_strategytoken;
while (true)
if (!bot_strategytoken)
bot_strategytoken = bot_list;
- if (!(IS_DEAD(bot_strategytoken) || STAT(FROZEN, bot_strategytoken)))
+ if (!(IS_DEAD(bot_strategytoken) || STAT(FROZEN, bot_strategytoken))
+ && !bot_strategytoken.goalcurrent)
break;
if (!bot_strategytoken_save) // break loop if all the bots are dead or frozen
if(checkpvs(this.origin, this.goalentity))
{
this.goalentity.bot_pickup_respawning = false;
- navigation_clearroute(this);
- navigation_goalrating_timeout_force(this);
- return;
+ navigation_goalrating_timeout_expire(this, random());
}
locked_goal = true; // wait for item to respawn
}
{
if(checkpvs(this.origin, this.goalentity))
{
- navigation_clearroute(this);
- navigation_goalrating_timeout_force(this);
- return;
+ navigation_goalrating_timeout_expire(this, random());
}
}
}
if(autocvar_bot_debug_goalstack)
debuggoalstack(this);
- bool bunnyhop_forbidden = false;;
+ bool bunnyhop_forbidden = false;
SET_DESTCOORDS(this.goalcurrent, this.origin, destorg);
// in case bot ends up inside the teleport waypoint without touching
this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
}
+// use this when current goal must be discarded immediately
void navigation_goalrating_timeout_force(entity this)
{
- this.bot_strategytime = 0;
+ navigation_goalrating_timeout_expire(this, 0);
+}
+
+// use this when current goal can be kept for a short while to increase the chance
+// of bot touching a waypoint, which helps to find a new goal more efficiently
+void navigation_goalrating_timeout_expire(entity this, float seconds)
+{
+ if (seconds <= 0)
+ this.bot_strategytime = 0;
+ else if (this.bot_strategytime > time + seconds)
+ this.bot_strategytime = time + seconds;
}
bool navigation_goalrating_timeout(entity this)