From: terencehill Date: Fri, 28 Apr 2017 16:36:47 +0000 (+0200) Subject: Snap waypoint to item's origin if close enough (can be disabled on the fly by pressin... X-Git-Tag: xonotic-v0.8.5~2378^2~175 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d24fe78729eadc5e0788320a2b1487bd09ec1627;p=xonotic%2Fxonotic-data.pk3dir.git Snap waypoint to item's origin if close enough (can be disabled on the fly by pressing the CROUCH key); don't allow spawning a waypoint too close to another one --- diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index 46db36198..2c628f8cb 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -174,7 +175,14 @@ entity waypoint_spawn(vector m1, vector m2, float f) { if(!(f & WAYPOINTFLAG_PERSONAL)) { - IL_EACH(g_waypoints, boxesoverlap(m1, m2, it.absmin, it.absmax), + vector em1 = m1; + vector em2 = m2; + if (m1 == m2) + { + em1 = m1 - '8 8 8'; + em2 = m2 + '8 8 8'; + } + IL_EACH(g_waypoints, boxesoverlap(em1, em2, it.absmin, it.absmax), { return it; }); @@ -235,6 +243,21 @@ void waypoint_spawn_fromeditor(entity pl) ctf_flags = order; } + if(!PHYS_INPUT_BUTTON_CROUCH(pl)) + { + // snap waypoint to item's origin if close enough + IL_EACH(g_items, true, + { + vector item_org = (it.absmin + it.absmax) * 0.5; + item_org.z = it.absmin.z - PL_MIN_CONST.z; + if(vlen(item_org - org) < 30) + { + org = item_org; + break; + } + }); + } + LABEL(add_wp); e = waypoint_spawn(org, org, 0); waypoint_schedulerelink(e);