From: terencehill Date: Mon, 22 Oct 2018 14:40:20 +0000 (+0200) Subject: Bot AI: fix bots getting stuck in oblique warpzones (in the map hyperspace there... X-Git-Tag: xonotic-v0.8.5~1742^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=10388420368e98086971ae421c68f44f44ba74bb;p=xonotic%2Fxonotic-data.pk3dir.git Bot AI: fix bots getting stuck in oblique warpzones (in the map hyperspace there are 2) --- diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 6164ca065..11e0707e9 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -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_JUMP = BIT(14); entity kh_worldkeylist; .entity kh_worldkeynext; diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index f5ba20c8a..28176464b 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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)) + { navigation_goalrating_timeout_force(this); + } } bool goalcurrent_can_be_removed = false; @@ -961,8 +963,16 @@ void havocbot_movetogoal(entity this) { 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 diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 250b7cb09..8fe72ff63 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -1608,6 +1608,16 @@ int navigation_poptouchedgoals(entity this) 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)) diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index 8ce5d2d38..ff376c2ed 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -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; + 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); + // 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)