From: terencehill Date: Thu, 18 Oct 2018 20:39:30 +0000 (+0200) Subject: Bot waypoints: improve generation of waypoints for warpzones pointing downwards;... X-Git-Tag: xonotic-v0.8.5~1742^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=62453c94f20ed9676b07e0cbf6398c674812e7e1;p=xonotic%2Fxonotic-data.pk3dir.git Bot waypoints: improve generation of waypoints for warpzones pointing downwards; don't generate waypoints for warpzones pointing upwards, bots can't use them anyway --- diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index b5ff8e53c..6164ca065 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -118,7 +118,7 @@ void waypoint_schedulerelink(entity wp); void waypoint_spawnforitem(entity e); void waypoint_spawnforitem_force(entity e, vector org); void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent); -void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, vector down_dir_src, vector down_dir_dest, entity tracetest_ent); +void waypoint_spawnforteleporter_wz(entity e, entity tracetest_ent); void waypoint_spawn_fromeditor(entity pl); entity waypoint_spawn(vector m1, vector m2, float f); void waypoint_unreachable(entity pl); diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index ef75d7aa2..8ce5d2d38 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -1297,22 +1297,38 @@ void waypoint_spawnforteleporter_boxes(entity e, int teleport_flag, vector org1, e.nearestwaypointtimeout = -1; } -void waypoint_spawnforteleporter_wz(entity e, vector src, vector destination, float timetaken, vector down_dir_src, vector down_dir_dest, entity tracetest_ent) +void waypoint_spawnforteleporter_wz(entity e, entity tracetest_ent) { - // warpzones with oblique warp plane rely on down_dir to snap waypoints - // to the ground without leaving the warp plane - // warpzones with horizontal warp plane (down_dir.x == -1) generate - // destination waypoint snapped to the ground (leaving warpzone), source - // waypoint in the center of the warp plane - - // snap to the ground only if source warpzone isn't horizontal - if(down_dir_src.x != -1) + float src_angle = e.warpzone_angles.x; + while (src_angle < -180) src_angle += 360; + while (src_angle > 180) src_angle -= 360; + + float dest_angle = e.enemy.warpzone_angles.x; + while (dest_angle < -180) dest_angle += 360; + while (dest_angle > 180) dest_angle -= 360; + + // no waypoints for warpzones pointing upwards, they can't be used by the bots + if (src_angle == -90 || dest_angle == -90) + return; + + makevectors(e.warpzone_angles); + vector src = (e.absmin + e.absmax) * 0.5; + src += ((e.warpzone_origin - src) * v_forward) * v_forward + 16 * v_right; + vector down_dir_src = -v_up; + + makevectors(e.enemy.warpzone_angles); + vector dest = (e.enemy.absmin + e.enemy.absmax) * 0.5; + dest += ((e.enemy.warpzone_origin - dest) * v_forward) * v_forward - 16 * v_right; + vector down_dir_dest = -v_up; + + // 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); - if(down_dir_dest.x == -1) // horizontal - down_dir_dest = '0 0 -1'; // change to vertical - destination = waypoint_fixorigin_down_dir(destination, tracetest_ent, down_dir_dest); + dest = waypoint_fixorigin_down_dir(dest, tracetest_ent, down_dir_dest); + } - waypoint_spawnforteleporter_boxes(e, WAYPOINTFLAG_TELEPORT, src, src, destination, destination, timetaken); + waypoint_spawnforteleporter_boxes(e, WAYPOINTFLAG_TELEPORT, src, src, dest, dest, 0); } void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent) diff --git a/qcsrc/server/bot/default/waypoints.qh b/qcsrc/server/bot/default/waypoints.qh index aa11778b1..d3c6cf510 100644 --- a/qcsrc/server/bot/default/waypoints.qh +++ b/qcsrc/server/bot/default/waypoints.qh @@ -59,7 +59,7 @@ void waypoint_saveall(); void waypoint_spawnforitem_force(entity e, vector org); void waypoint_spawnforitem(entity e); void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent); -void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, vector down_dir_src, vector down_dir_dest, entity tracetest_ent); +void waypoint_spawnforteleporter_wz(entity e, entity tracetest_ent); void botframe_showwaypointlinks(); float waypoint_loadall(); diff --git a/qcsrc/server/bot/null/bot_null.qc b/qcsrc/server/bot/null/bot_null.qc index 0256a9d1d..bdca146c2 100644 --- a/qcsrc/server/bot/null/bot_null.qc +++ b/qcsrc/server/bot/null/bot_null.qc @@ -38,7 +38,7 @@ void waypoint_schedulerelink(entity wp) { } void waypoint_spawnforitem(entity e) { } void waypoint_spawnforitem_force(entity e, vector org) { } void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent) { } -void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, vector down_dir_src, vector down_dir_dest, entity tracetest_ent) { } +void waypoint_spawnforteleporter_wz(entity e, entity tracetest_ent) { } void waypoint_spawn_fromeditor(entity pl) { } entity waypoint_spawn(vector m1, vector m2, float f) { return NULL; } #endif diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index a9b8c66f7..a92a4ea12 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -372,20 +372,7 @@ void WarpZone_PostInitialize_Callback() tracetest_ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; //for(entity e = warpzone_first; e; e = e.warpzone_next) for(entity e = NULL; (e = find(e, classname, "trigger_warpzone")); ) - { - vector src, dst; - src = (e.absmin + e.absmax) * 0.5; - makevectors(e.warpzone_angles); - src = src + ((e.warpzone_origin - src) * v_forward) * v_forward + 16 * v_right; - dst = (e.enemy.absmin + e.enemy.absmax) * 0.5; - vector down_dir_src = -v_up; - - makevectors(e.enemy.warpzone_angles); - dst = dst + ((e.enemy.warpzone_origin - dst) * v_forward) * v_forward - 16 * v_right; - vector down_dir_dest = -v_up; - - waypoint_spawnforteleporter_wz(e, src, dst, 0, down_dir_src, down_dir_dest, tracetest_ent); - } + waypoint_spawnforteleporter_wz(e, tracetest_ent); delete(tracetest_ent); }