From e92674bff49f97a68cd84bff7c9268753e22f91d Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 24 Jun 2018 15:33:26 +0200 Subject: [PATCH] Bot AI: fix bots jumping over frozen players when trying to revive them --- qcsrc/server/bot/default/havocbot/havocbot.qc | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 33aabfc54..50a706d7f 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -871,16 +871,31 @@ void havocbot_movetogoal(entity this) diff = destorg - this.origin; - // 1. stop if too close to target player (even if frozen) - // 2. stop if the locked goal has been reached - if ((IS_PLAYER(this.goalcurrent) && vdist(diff, <, 80)) - || (this.goalcurrent == this.goalentity && time < this.goalentity_lock_timeout && vdist(diff, <, 10))) + if (this.goalcurrent == this.goalentity && time < this.goalentity_lock_timeout && vdist(diff, <, 10)) { + // stop if the locked goal has been reached destorg = this.origin; - diff = '0 0 0'; + diff = dir = '0 0 0'; } - - dir = normalize(diff); + else if (IS_PLAYER(this.goalcurrent) || IS_MONSTER(this.goalcurrent)) + { + if (vdist(diff, <, 80)) + { + // stop if too close to target player (even if frozen) + destorg = this.origin; + diff = dir = '0 0 0'; + } + else + { + // move destorg out of target players, otherwise bot will consider them + // an obstacle that needs to be jumped (especially if frozen) + dir = normalize(diff); + destorg -= dir * PL_MAX_CONST.x * M_SQRT2; + diff = destorg - this.origin; + } + } + else + dir = normalize(diff); flatdir = (diff.z == 0) ? dir : normalize(vec2(diff)); //if (this.bot_dodgevector_time < time) -- 2.39.2