]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: fix bots turning aim too much when current goal and next goal are close to...
authorterencehill <piuntn@gmail.com>
Thu, 24 May 2018 14:27:35 +0000 (16:27 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 24 May 2018 15:16:00 +0000 (17:16 +0200)
qcsrc/server/bot/default/havocbot/havocbot.qc

index a0b1e398d283014d94f8501af2b32b511f3b775f..26ded65e3d4e3022321d9bae0433ca87daf91ed0 100644 (file)
@@ -948,7 +948,7 @@ void havocbot_movetogoal(entity this)
                        vector flat_diff = vec2(diff);
                        offset = max(32, vlen(vec2(this.velocity)) * cos(deviation.y * DEG2RAD) * 0.2) * flatdir;
                        vector actual_destorg = this.origin + offset;
                        vector flat_diff = vec2(diff);
                        offset = max(32, vlen(vec2(this.velocity)) * cos(deviation.y * DEG2RAD) * 0.2) * flatdir;
                        vector actual_destorg = this.origin + offset;
-                       if (!this.goalstack01 || this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
+                       if (!this.goalstack01 || this.goalcurrent.wpflags & (WAYPOINTFLAG_TELEPORT | WAYPOINTFLAG_LADDER))
                        {
                                if (vlen2(flat_diff) < vlen2(offset))
                                {
                        {
                                if (vlen2(flat_diff) < vlen2(offset))
                                {
@@ -965,9 +965,15 @@ void havocbot_movetogoal(entity this)
                        {
                                vector next_goal_org = (this.goalstack01.absmin + this.goalstack01.absmax) * 0.5;
                                vector next_dir = normalize(vec2(next_goal_org - destorg));
                        {
                                vector next_goal_org = (this.goalstack01.absmin + this.goalstack01.absmax) * 0.5;
                                vector next_dir = normalize(vec2(next_goal_org - destorg));
-                               float next_dist = vlen(vec2(this.origin + offset - destorg));
-                               actual_destorg = vec2(destorg) + next_dist * next_dir;
+                               float dist = vlen(vec2(this.origin + offset - destorg));
+                               // if current and next goal are close to each other make sure
+                               // actual_destorg isn't set beyond next_goal_org
+                               if (dist ** 2 > vlen2(vec2(next_goal_org - destorg)))
+                                       actual_destorg = next_goal_org;
+                               else
+                                       actual_destorg = vec2(destorg) + dist * next_dir;
                                actual_destorg.z = this.origin.z;
                                actual_destorg.z = this.origin.z;
+
                        }
 
                        tracebox(this.origin, this.mins, this.maxs, actual_destorg, false, this);
                        }
 
                        tracebox(this.origin, this.mins, this.maxs, actual_destorg, false, this);