]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
BOT AI: avoid sticking to players when chasing them as it was very annoying, especial...
authorterencehill <piuntn@gmail.com>
Fri, 30 Mar 2018 13:41:39 +0000 (15:41 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 30 Mar 2018 13:41:39 +0000 (15:41 +0200)
qcsrc/server/bot/default/havocbot/havocbot.qc

index 2a0d0c8503f005c17d2156fd2871ebf216ac932d..7ce6efa45fc63af8e3bd50991b1bdac3dcf1336c 100644 (file)
@@ -885,17 +885,17 @@ void havocbot_movetogoal(entity this)
 
        diff = destorg - this.origin;
 
-       if (fabs(diff.x) < 10 && fabs(diff.y) < 10
-               && this.goalcurrent == this.goalentity && time < this.goalentity_lock_timeout)
+       // 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)))
        {
                destorg = this.origin;
-               diff.x = 0;
-               diff.y = 0;
+               diff = '0 0 0';
        }
 
        dir = normalize(diff);
-       flatdir = diff;flatdir.z = 0;
-       flatdir = normalize(flatdir);
+       flatdir = (diff.z == 0) ? dir : normalize(vec2(diff));
 
        //if (this.bot_dodgevector_time < time)
        {