Sorry for the delay in responce, I just noticed the edits you made to the post you made.
ffbj wrote...
Well I would not say it was useless. Say if you don't want npc wandering outside of a certain range. I suppose there could be other uses for it.
True not totaly useless. Just keep in mind that the GetRandomObject ByTag may return an invlaid object even if there are valid tags within range. If you want the function to always return a valid object if there is one in range, Write your own function that handles the situation the way you want it to.
Not so enamored of the get random location either, though I can think of some interesting uses for that too. Maybe for creating spawn waypoints or random traps or some such. Not to be contrary, but apparently someone thought there was a use for it.
I read through all those other posts before. Mainly I don't use vectors I do the random location for spawning monsters, like this:
location lWP = GetRandomLocation(oArea,oTarget,fDistance);
Where the PC is the target and fDistance is some variable distance from the PC. It works pretty well and perhaps that was one of the thoughts behind the creation of the function. Not sure. but that's one thing I use it for.
I agree that function has many uses. It is just not written the best way. I would still suggest either using the one Faild bard wrote or the one I wrote. You would just need to add the function to one of your includes or a new include.
with Faild Bards function
Link your line would look like
location lWP = FB_GetRandomLocation(GetLocation(oTarget),fDistance);
with My function
Linkyour line would look like:
location lWP = GetRndLocRoundObject(oTarget,fDistance);
Both of our functions would end up doing the same thing the boiware function does, Jut more effeciently. My function if you look at it also gives you more controll over where the random location is at around the target if you wanted to define it futher.
//Gets a random location around an object.
// - oObject : The object to get the random location around
// - fMaxDist: The maximum distance from oObject.
// - fMinDist: The mininum distance from oObject, Defaults to 0.
// - nAngle : The angle offset from the orintation of oObject. defaults to 0.
// 0 would be the direction that oObject is facing.
// - nAngleSpread: defines the size of the arc that the location fall into.
// The spread is on both sides of nAngle.Defaults to 180 that would
// be the full 360 deg around oObject
// - examples: If nAngle is 0 and nAngleSpread is 15. the location returned will
// be in the 30deg arc in front of the object. 15deg to the right
// and left.
// If nAngle is 90 and nAngleSpread is 90 the location returned will
// be Anywhere to the left of oObject. Angel 0 - 180 from objects orintation.
location GetRndLocRoundObject( object oObject, float fMaxDist, float fMinDist=0.0, int nAngle=0,int nAngleSpread=180);
So if you wanted to spawn in a creature 15 to 20 meters away anywhere in the 180 degrees behind a PC. You could use.
location lSpawnPoint = GetRndLocRoundObject( oPC, 20.0, 15.0, 180 ,90);
The 15.0 and 20.0 being thenin and max distance, the 180 being the angle direcly behind the pc and the 90 being the spread on both sides of the 180 degree angle.
That would give you a random location at the distance with an angle anywhere from 90-270 degrees from the PC's orientation.
Modifié par Lightfoot8, 05 septembre 2011 - 11:50 .