]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/default/navigation.qc
Bot AI: fix bots not being able to get unstuck from a perfectly vertical jumppad
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / default / navigation.qc
index 1a491530a815b20d34fc342c7e9c406c5f95f067..5e509506db6d3ba5f5340efa6607fef7d0aa6ba2 100644 (file)
@@ -1611,11 +1611,12 @@ int navigation_poptouchedgoals(entity this)
                if (!this.goalcurrent.wpisbox // warpzone
                        && vlen2(this.origin - this.goalstack01.origin) < vlen2(this.origin - this.goalcurrent.origin))
                {
+                       // immediately remove origin and destination waypoints
                        navigation_poproute(this);
                        ++removed_goals;
                        navigation_poproute(this);
                        ++removed_goals;
-                       return removed_goals;
+                       this.lastteleporttime = 0;
                }
 
                // make sure jumppad is really hit, don't rely on distance based checks
@@ -1638,12 +1639,17 @@ int navigation_poptouchedgoals(entity this)
                                if (time - this.lastteleporttime < random() * max_delay)
                                        return removed_goals;
                        }
+                       else if (this.goalcurrent.wpisbox) // teleport
+                       {
+                               // immediately remove origin and destination waypoints
+                               navigation_poproute(this);
+                               ++removed_goals;
+                       }
                        navigation_poproute(this);
                        this.lastteleporttime = 0;
                        ++removed_goals;
                }
-               else
-                       return removed_goals;
+               return removed_goals;
        }
        else if (this.lastteleporttime > 0)
        {
@@ -1675,6 +1681,9 @@ int navigation_poptouchedgoals(entity this)
                        ++removed_goals;
                        return removed_goals;
                }
+               // reset of lastteleporttime can be overriden by a jumppad when it's set
+               // in more than one frame: make sure it's reset
+               this.lastteleporttime = 0;
        }
 
        // Loose goal touching check when running