From: terencehill Date: Fri, 1 Sep 2017 16:31:03 +0000 (+0200) Subject: Fix waypoints for warpzones with oblique or horizontal warp plane X-Git-Tag: xonotic-v0.8.5~2378^2~74 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=64e7b6ddf13d965e8a91746540dc06de3e4c16fe;p=xonotic%2Fxonotic-data.pk3dir.git Fix waypoints for warpzones with oblique or horizontal warp plane --- diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 5c41731dd..27651bf81 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -98,7 +98,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, entity tracetest_ent); +void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, vector down_dir, 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 4b7da649c..c3b67a378 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -1069,9 +1069,16 @@ float waypoint_loadall() return cwp + cwb; } -vector waypoint_fixorigin(vector position, entity tracetest_ent) +#define waypoint_fixorigin(position, tracetest_ent) \ + waypoint_fixorigin_down_dir(position, tracetest_ent, '0 0 -1') + +vector waypoint_fixorigin_down_dir(vector position, entity tracetest_ent, vector down_dir) { - tracebox(position + '0 0 1' * (1 - PL_MIN_CONST.z), PL_MIN_CONST, PL_MAX_CONST, position + '0 0 -512', MOVE_NOMONSTERS, tracetest_ent); + tracebox(position + '0 0 1', PL_MIN_CONST, PL_MAX_CONST, position + down_dir * 3000, MOVE_NOMONSTERS, tracetest_ent); + if(trace_startsolid) + tracebox(position + '0 0 1' * (1 - PL_MIN_CONST.z / 2), PL_MIN_CONST, PL_MAX_CONST, position + down_dir * 3000, MOVE_NOMONSTERS, tracetest_ent); + if(trace_startsolid) + tracebox(position + '0 0 1' * (1 - PL_MIN_CONST.z), PL_MIN_CONST, PL_MAX_CONST, position + down_dir * 3000, MOVE_NOMONSTERS, tracetest_ent); if(trace_fraction < 1) position = trace_endpos; return position; @@ -1129,10 +1136,18 @@ void waypoint_spawnforteleporter_boxes(entity e, int teleport_flag, vector org1, e.nearestwaypointtimeout = -1; } -void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, entity tracetest_ent) +void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, vector down_dir, entity tracetest_ent) { - org = waypoint_fixorigin(org, tracetest_ent); - destination = waypoint_fixorigin(destination, 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 + if(down_dir.x != -1) + org = waypoint_fixorigin_down_dir(org, tracetest_ent, down_dir); + if(down_dir.x == -1) + down_dir = '0 0 -1'; + destination = waypoint_fixorigin_down_dir(destination, tracetest_ent, down_dir); waypoint_spawnforteleporter_boxes(e, WAYPOINTFLAG_TELEPORT, org, org, destination, destination, timetaken); } diff --git a/qcsrc/server/bot/default/waypoints.qh b/qcsrc/server/bot/default/waypoints.qh index d3cb3a4e3..bea11e929 100644 --- a/qcsrc/server/bot/default/waypoints.qh +++ b/qcsrc/server/bot/default/waypoints.qh @@ -57,7 +57,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, entity tracetest_ent); +void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, vector down_dir, entity tracetest_ent); void botframe_showwaypointlinks(); float waypoint_loadall(); @@ -72,6 +72,6 @@ entity waypoint_spawnpersonal(entity this, vector position); void waypoint_unreachable(entity pl); -vector waypoint_fixorigin(vector position, entity tracetest_ent); +vector waypoint_fixorigin_down_dir(vector position, entity tracetest_ent, vector down_dir); void botframe_autowaypoints(); diff --git a/qcsrc/server/bot/null/bot_null.qc b/qcsrc/server/bot/null/bot_null.qc index ddf7abd9d..f8738f80f 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, entity tracetest_ent) { } +void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, vector down_dir, 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 51890765d..fcae79ea6 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -425,7 +425,7 @@ void WarpZone_PostInitialize_Callback() dst = (e.enemy.absmin + e.enemy.absmax) * 0.5; makevectors(e.enemy.warpzone_angles); dst = dst + ((e.enemy.warpzone_origin - dst) * v_forward) * v_forward - 16 * v_right; - waypoint_spawnforteleporter_wz(e, src, dst, 0, tracetest_ent); + waypoint_spawnforteleporter_wz(e, src, dst, 0, -v_up, tracetest_ent); } delete(tracetest_ent); }