]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: fix bots getting stuck in oblique warpzones (in the map hyperspace there...
authorterencehill <piuntn@gmail.com>
Mon, 22 Oct 2018 14:40:20 +0000 (16:40 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 22 Oct 2018 14:40:20 +0000 (16:40 +0200)
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/waypoints.qc

index 6164ca065cafff014fcb6599ed4f11bd4d8dee2c..11e0707e989e3ab5e344825b1cdc742103678e81 100644 (file)
@@ -13,6 +13,7 @@ const int WAYPOINTFLAG_PROTECTED = BIT(18);  // Useless WP detection never kills
 const int WAYPOINTFLAG_USEFUL = BIT(17);  // Useless WP detection temporary flag.
 const int WAYPOINTFLAG_DEAD_END = BIT(16);  // Useless WP detection temporary flag.
 const int WAYPOINTFLAG_LADDER = BIT(15);
 const int WAYPOINTFLAG_USEFUL = BIT(17);  // Useless WP detection temporary flag.
 const int WAYPOINTFLAG_DEAD_END = BIT(16);  // Useless WP detection temporary flag.
 const int WAYPOINTFLAG_LADDER = BIT(15);
+const int WAYPOINTFLAG_JUMP = BIT(14);
 
 entity kh_worldkeylist;
 .entity kh_worldkeynext;
 
 entity kh_worldkeylist;
 .entity kh_worldkeynext;
index f5ba20c8a41b1acbe04a1368748eb8cbede98d30..28176464bb67f45f395112ff9b176c11b73ac236 100644 (file)
@@ -779,7 +779,9 @@ void havocbot_movetogoal(entity this)
        {
                if (vdist(this.origin - this.goalcurrent_prev.origin, <, 50)
                        && navigation_goalrating_timeout_can_be_anticipated(this))
        {
                if (vdist(this.origin - this.goalcurrent_prev.origin, <, 50)
                        && navigation_goalrating_timeout_can_be_anticipated(this))
+               {
                        navigation_goalrating_timeout_force(this);
                        navigation_goalrating_timeout_force(this);
+               }
        }
 
        bool goalcurrent_can_be_removed = false;
        }
 
        bool goalcurrent_can_be_removed = false;
@@ -961,8 +963,16 @@ void havocbot_movetogoal(entity this)
                        {
                                if (vlen2(flat_diff) < vlen2(offset))
                                {
                        {
                                if (vlen2(flat_diff) < vlen2(offset))
                                {
-                                       actual_destorg.x = destorg.x;
-                                       actual_destorg.y = destorg.y;
+                                       if (this.goalcurrent.wpflags & WAYPOINTFLAG_JUMP && this.goalstack01)
+                                       {
+                                               // oblique warpzones need a jump otherwise bots gets stuck
+                                               PHYS_INPUT_BUTTON_JUMP(this) = true;
+                                       }
+                                       else
+                                       {
+                                               actual_destorg.x = destorg.x;
+                                               actual_destorg.y = destorg.y;
+                                       }
                                }
                        }
                        else if (vdist(flat_diff, <, 32) && diff.z < -16) // destination is under the bot
                                }
                        }
                        else if (vdist(flat_diff, <, 32) && diff.z < -16) // destination is under the bot
index 250b7cb09c639e45680e699514958d769b97a686..8fe72ff6377d6690480eb61c7f6121e44a5cd32d 100644 (file)
@@ -1608,6 +1608,16 @@ int navigation_poptouchedgoals(entity this)
 
        if(this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
        {
 
        if(this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
        {
+               if (!this.goalcurrent.wpisbox // warpzone
+                       && vlen2(this.origin - this.goalstack01.origin) < vlen2(this.origin - this.goalcurrent.origin))
+               {
+                       navigation_poproute(this);
+                       ++removed_goals;
+                       navigation_poproute(this);
+                       ++removed_goals;
+                       return removed_goals;
+               }
+
                // make sure jumppad is really hit, don't rely on distance based checks
                // as they may report a touch even if it didn't really happen
                if(this.lastteleporttime > 0 && TELEPORT_USED(this, this.goalcurrent))
                // make sure jumppad is really hit, don't rely on distance based checks
                // as they may report a touch even if it didn't really happen
                if(this.lastteleporttime > 0 && TELEPORT_USED(this, this.goalcurrent))
index 8ce5d2d38b38228eebc3b4ad549687f07e420d4a..ff376c2ed56ffda2a5c1ad373168c35ee0fceef1 100644 (file)
@@ -1321,14 +1321,18 @@ void waypoint_spawnforteleporter_wz(entity e, entity tracetest_ent)
        dest += ((e.enemy.warpzone_origin - dest) * v_forward) * v_forward - 16 * v_right;
        vector down_dir_dest = -v_up;
 
        dest += ((e.enemy.warpzone_origin - dest) * v_forward) * v_forward - 16 * v_right;
        vector down_dir_dest = -v_up;
 
+       int extra_flag = 0;
        // don't snap to the ground waypoints for source warpzones pointing downwards
        if (src_angle != 90)
        {
                src = waypoint_fixorigin_down_dir(src, tracetest_ent, down_dir_src);
                dest = waypoint_fixorigin_down_dir(dest, tracetest_ent, down_dir_dest);
        // don't snap to the ground waypoints for source warpzones pointing downwards
        if (src_angle != 90)
        {
                src = waypoint_fixorigin_down_dir(src, tracetest_ent, down_dir_src);
                dest = waypoint_fixorigin_down_dir(dest, tracetest_ent, down_dir_dest);
+               // oblique warpzones need a jump otherwise bots gets stuck
+               if (src_angle != 0)
+                       extra_flag = WAYPOINTFLAG_JUMP;
        }
 
        }
 
-       waypoint_spawnforteleporter_boxes(e, WAYPOINTFLAG_TELEPORT, src, src, dest, dest, 0);
+       waypoint_spawnforteleporter_boxes(e, WAYPOINTFLAG_TELEPORT | extra_flag, src, src, dest, dest, 0);
 }
 
 void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent)
 }
 
 void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent)