]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: make bots release movement keys after a small random delay on jumppad touch...
authorterencehill <piuntn@gmail.com>
Tue, 29 May 2018 12:50:33 +0000 (14:50 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 29 May 2018 12:50:33 +0000 (14:50 +0200)
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/navigation.qc

index 1aa305ab3540689f0e6834ef278187ee37f29d72..429254a5ef60d39631b7cebae03a91b4b301c7ee 100644 (file)
@@ -540,8 +540,8 @@ void havocbot_movetogoal(entity this)
                if(this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
                {
                        this.aistatus |= AI_STATUS_OUT_JUMPPAD;
-                       navigation_poptouchedgoals(this);
-                       return;
+                       if(navigation_poptouchedgoals(this))
+                               return;
                }
                else if(this.aistatus & AI_STATUS_OUT_JUMPPAD)
                {
@@ -849,11 +849,14 @@ void havocbot_movetogoal(entity this)
 
        bool bunnyhop_forbidden = false;
        vector destorg = get_closer_dest(this.goalcurrent, this.origin);
-
-       // in case bot ends up inside the teleport waypoint without touching
-       // the teleport itself, head to the teleport origin
-       if(this.goalcurrent.wpisbox && boxesoverlap(this.goalcurrent.absmin, this.goalcurrent.absmax, this.origin + eZ * this.mins.z, this.origin + eZ * this.maxs.z))
+       if (this.jumppadcount && this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
+       {
+               // if bot used the jumppad, push towards jumppad origin until jumppad waypoint gets removed
+               destorg = this.goalcurrent.origin;
+       }
+       else if (this.goalcurrent.wpisbox && boxesoverlap(this.goalcurrent.absmin, this.goalcurrent.absmax, this.origin + eZ * this.mins.z, this.origin + eZ * this.maxs.z))
        {
+               // if bot is inside the teleport waypoint, head to teleport origin until teleport gets used
                bunnyhop_forbidden = true;
                destorg = this.goalcurrent.origin;
                if(destorg.z > this.origin.z)
index 8c7e776b73615f052eac4ad524ff80a960f56dd2..22e6b0d1982f21f19d03f5746210b1ce0509666c 100644 (file)
@@ -1599,6 +1599,16 @@ int navigation_poptouchedgoals(entity this)
                                this.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_GOING;
                                this.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_REACHED;
                        }
+                       if(this.jumppadcount)
+                       {
+                               // remove jumppad waypoint after a random delay to prevent bots getting
+                               // stuck on certain jumppads that require an extra initial horizontal speed
+                               float max_delay = 0.1;
+                               if (vdist(vec2(this.velocity), >, 2 * autocvar_sv_maxspeed))
+                                       max_delay = 0.05;
+                               if (time - this.lastteleporttime < random() * max_delay)
+                                       return removed_goals;
+                       }
                        navigation_poproute(this);
                        this.lastteleporttime = 0;
                        ++removed_goals;