From cd06eb102cd3ce2d6e5394de18196b6aa0e7fea9 Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 16 Feb 2017 00:19:11 +0100 Subject: [PATCH] Fix head-banging detection against not so high walls. If detected simply find a goal from the current position --- qcsrc/server/bot/default/havocbot/havocbot.qc | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 3d4e298d13..17f3a80b3f 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -784,44 +784,36 @@ void havocbot_movetogoal(entity this) } // avoiding dangers and obstacles - offset = (vdist(this.velocity, >, 32) ? this.velocity * 0.5 : v_forward * 32); - vector dst_ahead = this.origin + this.view_ofs + offset; + offset = (vdist(this.velocity - eZ * this.velocity.z, >, 32) ? this.velocity * 0.5 : v_forward * 32); + vector dst_ahead = this.origin + offset; vector dst_down = dst_ahead - '0 0 3000'; - // Look ahead - traceline(this.origin + this.view_ofs, dst_ahead, true, NULL); - // Check head-banging against walls - if(vdist(this.origin + this.view_ofs - trace_endpos, <, 25) && !(this.aistatus & AI_STATUS_OUT_WATER)) + traceline(this.origin, dst_ahead, true, NULL); + if(vdist(this.origin - trace_endpos, <, 25) && !(this.aistatus & AI_STATUS_OUT_WATER)) { PHYS_INPUT_BUTTON_JUMP(this) = true; - if(this.facingwalltime && time > this.facingwalltime) + if(!this.facingwalltime) + this.facingwalltime = time + 0.2; + else if(time > this.facingwalltime) { - this.ignoregoal = this.goalcurrent; - this.ignoregoaltime = time + autocvar_bot_ai_ignoregoal_timeout; + navigation_clearroute(this); this.bot_strategytime = 0; return; } - else - { - this.facingwalltime = time + 0.05; - } } else - { this.facingwalltime = 0; - if(this.ignoregoal != NULL && time > this.ignoregoaltime) - { - this.ignoregoal = NULL; - this.ignoregoaltime = 0; - } - } - // Check for water/slime/lava and dangerous edges // (only when the bot is on the ground or jumping intentionally) this.aistatus &= ~AI_STATUS_DANGER_AHEAD; + dst_ahead = this.origin + this.view_ofs + offset; + dst_down = dst_ahead - '0 0 3000'; + + traceline(this.origin + this.view_ofs, dst_ahead, true, NULL); + bool unreachable = false; s = CONTENT_SOLID; if(trace_fraction == 1 && this.jumppadcount == 0 && !this.goalcurrent.wphardwired ) -- 2.39.2