From: terencehill Date: Thu, 7 Sep 2017 19:40:46 +0000 (+0200) Subject: Fix havocbot_checkgoaldistance forcing to find a new goal when bot walks over multipl... X-Git-Tag: xonotic-v0.8.5~2378^2~71 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8809a99a023e7db7d18c10b20269eb1e2af098bf;p=xonotic%2Fxonotic-data.pk3dir.git Fix havocbot_checkgoaldistance forcing to find a new goal when bot walks over multiple obstacles and current goal is below bot's position --- diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 4891b8d38..0c47f608b 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -430,7 +430,8 @@ void havocbot_bunnyhop(entity this, vector dir) bool havocbot_checkgoaldistance(entity this, vector gco) { float curr_dist = vlen(this.origin - gco); - if(curr_dist > this.goalcurrent_distance) + float curr_dist_2d = vlen(vec2(this.origin - gco)); + if(curr_dist > this.goalcurrent_distance && curr_dist_2d > this.goalcurrent_distance_2d) { if(!this.goalcurrent_distance_time) this.goalcurrent_distance_time = time; @@ -440,7 +441,8 @@ bool havocbot_checkgoaldistance(entity this, vector gco) else { // reduce it a little bit so it works even with very small approaches to the goal - this.goalcurrent_distance = max(20, curr_dist - 15); + this.goalcurrent_distance = max(20, curr_dist - 10); + this.goalcurrent_distance_2d = max(20, curr_dist_2d - 10); this.goalcurrent_distance_time = 0; } return false; diff --git a/qcsrc/server/bot/default/navigation.qh b/qcsrc/server/bot/default/navigation.qh index ea913456d..c88fd3397 100644 --- a/qcsrc/server/bot/default/navigation.qh +++ b/qcsrc/server/bot/default/navigation.qh @@ -26,6 +26,7 @@ entity navigation_bestgoal; .entity goalcurrent_prev; .float goalcurrent_distance; +.float goalcurrent_distance_2d; .float goalcurrent_distance_time; .entity nearestwaypoint;