From 1ff8b5f411e61a05fe003fb7abedba9df3179633 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 29 Sep 2015 18:28:09 +1000 Subject: [PATCH] Accept bounds for random location --- qcsrc/server/miscfunctions.qc | 11 ++++++++--- qcsrc/server/miscfunctions.qh | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index bcba19e30a..0a4108a8e9 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1432,7 +1432,7 @@ string uid2name(string myuid) { return s; } -float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance) +float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance) { float m, i; vector start, org, delta, end, enddown, mstart; @@ -1441,8 +1441,8 @@ float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, f m = e.dphitcontentsmask; e.dphitcontentsmask = goodcontents | badcontents; - org = world.mins; - delta = world.maxs - world.mins; + org = boundmin; + delta = boundmax - boundmin; start = end = org; @@ -1543,6 +1543,11 @@ float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, f return false; } +float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance) +{ + return MoveToRandomLocationWithinBounds(e, world.mins, world.maxs, goodcontents, badcontents, badsurfaceflags, attempts, maxaboveground, minviewdistance); +} + void write_recordmarker(entity pl, float tstart, float dt) { GameLogEcho(strcat(":recordset:", ftos(pl.playerid), ":", ftos(dt))); diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index 37e9073f3d..fc3583bb16 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -106,6 +106,8 @@ float LostMovetypeFollow(entity ent); string uid2name(string myuid); +float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance); + float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance); string NearestLocation(vector p); -- 2.39.2