]> de.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 6e2bbb8d7cd3c8a52868f9d3456c6b17d789db04..14f704f5478214461a09ac78fcf3a7efe88c5a4f 100644 (file)
@@ -1274,7 +1274,7 @@ string uid2name(string myuid)
        return s;
 }
 
-bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, int 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 = e.dphitcontentsmask;
     e.dphitcontentsmask = goodcontents | badcontents;
@@ -1332,14 +1332,22 @@ bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax
 
                // 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;
@@ -1396,9 +1404,9 @@ bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax
     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)