]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Snap waypoint to item's origin if close enough (can be disabled on the fly by pressin...
authorterencehill <piuntn@gmail.com>
Fri, 28 Apr 2017 16:36:47 +0000 (18:36 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 28 Apr 2017 16:36:47 +0000 (18:36 +0200)
qcsrc/server/bot/default/waypoints.qc

index 46db36198554d226dc59ebaa6a81da65ef32af9e..2c628f8cb5c43f3ae371c34b80013c8896037e7b 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <common/constants.qh>
 #include <common/net_linked.qh>
+#include <common/physics/player.qh>
 
 #include <lib/warpzone/common.qh>
 #include <lib/warpzone/util_server.qh>
@@ -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);