From: terencehill Date: Tue, 14 Feb 2017 22:05:23 +0000 (+0100) Subject: Find a new goal as soon as the item bot is running to gets taken by someone else X-Git-Tag: xonotic-v0.8.2~202^2~7 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=826ab66ae3a567384eba14c3cebd4474c6b869f6;p=xonotic%2Fxonotic-data.pk3dir.git Find a new goal as soon as the item bot is running to gets taken by someone else --- diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 606857611..ba8757502 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -674,7 +674,33 @@ void havocbot_movetogoal(entity this) 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) diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 5d612e10f..95d787e00 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -232,6 +232,7 @@ void navigation_clearroute(entity this) { //print("bot ", etos(this), " clear\n"); this.navigation_hasgoals = false; + this.goalentity = NULL; this.goalcurrent = NULL; this.goalstack01 = NULL; this.goalstack02 = NULL; @@ -275,6 +276,8 @@ void navigation_clearroute(entity this) 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; @@ -315,6 +318,8 @@ void navigation_pushroute(entity this, entity e) 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; @@ -943,16 +948,6 @@ void navigation_poptouchedgoals(entity this) } } - 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))