]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: fix bots not being able to get unstuck from a perfectly vertical jumppad
authorterencehill <piuntn@gmail.com>
Thu, 6 Dec 2018 00:14:12 +0000 (01:14 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 6 Dec 2018 00:14:12 +0000 (01:14 +0100)
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/navigation.qh

index a8e10194ef96debb1107ce0e37aba05ae84fc00c..d6658a08456c434cfd24b8872c6c5a7646b133f1 100644 (file)
@@ -577,7 +577,7 @@ void havocbot_movetogoal(entity this)
                                        this.aistatus &= ~AI_STATUS_OUT_JUMPPAD;
                                }
                        }
-                       else
+                       else //if (this.goalcurrent)
                        {
                                if (this.goalcurrent.bot_pickup)
                                {
@@ -601,9 +601,9 @@ void havocbot_movetogoal(entity this)
                                        return;
                        }
                }
-               else
+               else //if (!(this.aistatus & AI_STATUS_OUT_JUMPPAD))
                {
-                       if(time - this.lastteleporttime > 0.2 && this.velocity.z > 0)
+                       if(this.origin.z - this.lastteleport_origin.z > (this.maxs.z - this.mins.z) * 0.5)
                        {
                                vector velxy = this.velocity; velxy_z = 0;
                                if(vdist(velxy, <, autocvar_sv_maxspeed * 0.2))
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
index b8b067c3b993cae47c20e7b5219a2d36aa913b9f..d002ae29db21e138d8632af79056d9c285409cf1 100644 (file)
@@ -52,8 +52,7 @@ entity navigation_bestgoal;
        waypoint_addlink_customcost(to_item, from_wp, waypoint_getlinkcost(from_wp, to_item))
 
 #define TELEPORT_USED(pl, tele_wp) \
-       (time - pl.lastteleporttime < ((tele_wp.wpflags & WAYPOINTFLAG_PERSONAL) ? 2 : 0.15) \
-       && boxesoverlap(tele_wp.absmin, tele_wp.absmax, pl.lastteleport_origin + STAT(PL_MIN, pl), pl.lastteleport_origin + STAT(PL_MAX, pl)))
+       boxesoverlap(tele_wp.absmin, tele_wp.absmax, pl.lastteleport_origin + STAT(PL_MIN, pl), pl.lastteleport_origin + STAT(PL_MAX, pl))
 
 vector tracewalk_dest;
 float tracewalk_dest_height;