]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/miscfunctions.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qc
index ded47a6387f97920ce32f2fa41851a7b8ec32dea..4c5bef5979bf0841657b24cb4797afb827aae898 100644 (file)
@@ -1257,7 +1257,7 @@ string uid2name(string myuid) {
        return s;
 }
 
-float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance)
+bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance, bool frompos)
 {
     float m, i;
     vector start, org, delta, end, enddown, mstart;
@@ -1317,14 +1317,22 @@ float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundma
 
        // rule 4: we must "see" some spawnpoint or item
     entity sp = NULL;
-    IL_EACH(g_spawnpoints, checkpvs(mstart, it),
+    if(frompos)
     {
-       if((traceline(mstart, it.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
-       {
-               sp = it;
-               break;
-       }
-    });
+       if((traceline(mstart, e.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
+               sp = e;
+    }
+    if(!sp)
+    {
+           IL_EACH(g_spawnpoints, checkpvs(mstart, it),
+           {
+               if((traceline(mstart, it.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
+               {
+                       sp = it;
+                       break;
+               }
+           });
+       }
        if(!sp)
        {
                int items_checked = 0;
@@ -1382,9 +1390,9 @@ float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundma
         return false;
 }
 
-float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance)
+bool MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance)
 {
-       return MoveToRandomLocationWithinBounds(e, world.mins, world.maxs, goodcontents, badcontents, badsurfaceflags, attempts, maxaboveground, minviewdistance);
+       return MoveToRandomLocationWithinBounds(e, world.mins, world.maxs, goodcontents, badcontents, badsurfaceflags, attempts, maxaboveground, minviewdistance, false);
 }
 
 void write_recordmarker(entity pl, float tstart, float dt)