if (this.goalcurrent == NULL)
return;
- navigation_poptouchedgoals(this);
+
+ bool locked_goal = false;
+ if(this.goalentity.bot_pickup)
+ {
+ if(this.goalentity.bot_pickup_respawning)
+ {
+ if(this.goalentity.solid) // item respawned
+ 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;
+ }
+ else if(this.goalentity == this.goalcurrent)
+ locked_goal = true; // wait for item to respawn
+ }
+ else if(!this.goalentity.solid)
+ {
+ navigation_clearroute(this);
+ this.bot_strategytime = 0;
+ return;
+ }
+ }
+ if(!locked_goal)
+ navigation_poptouchedgoals(this);
// if ran out of goals try to use an alternative goal or get a new strategy asap
if(this.goalcurrent == NULL)
{
//print("bot ", etos(this), " clear\n");
this.navigation_hasgoals = false;
+ this.goalentity = NULL;
this.goalcurrent = NULL;
this.goalstack01 = NULL;
this.goalstack02 = NULL;
void navigation_pushroute(entity this, entity e)
{
//print("bot ", etos(this), " push ", etos(e), "\n");
+ if(this.goalstack31 == this.goalentity)
+ this.goalentity = NULL;
this.goalstack31 = this.goalstack30;
this.goalstack30 = this.goalstack29;
this.goalstack29 = this.goalstack28;
void navigation_poproute(entity this)
{
//print("bot ", etos(this), " pop\n");
+ if(this.goalcurrent == this.goalentity)
+ this.goalentity = NULL;
this.goalcurrent = this.goalstack01;
this.goalstack01 = this.goalstack02;
this.goalstack02 = this.goalstack03;
}
}
- if(this.goalcurrent.bot_pickup_respawning)
- {
- if(!this.goalcurrent.solid)
- {
- if(time > this.goalcurrent.scheduledrespawntime - 10) // item not yet taken (by someone else)
- return; // wait for item to respawn
- }
- this.goalcurrent.bot_pickup_respawning = false;
- }
-
// If for some reason the bot is closer to the next goal, pop the current one
if(this.goalstack01 && !wasfreed(this.goalstack01))
if(vlen2(this.goalcurrent.origin - this.origin) > vlen2(this.goalstack01.origin - this.origin))