If your trigger is roughly rectangular, and rinning mostly in line N/S or E/W, you could store the triggers starting X and Y positions on it as floats, as well as the size in each direction. Those could then be used to create the X and Y portions needed for the random location to be created.
Going that way, you'd use something like this:
// Returns a random float in 10ths, from 0 to fNumber.
float GetRandomFloat (float fNumber)
{
int nNumber = FloatToInt (fNumber + 0.1) * 10;
int nRandom = Random (nNumber);
float fNumber = IntToFloat (nRandom) / 10.0;
return fNumber;
}
// returns a random location inside a trigger or other specified area,
// based on stored floats on the object.
// "X_BASE", "Y_BASE" --=> Starting points
// "X_MOD", "Y_MOD" --=> Maximum X and Y variances.
location GetRandomLocationInsideTrigger (object oTrigger = OBJECT_SELF)
{
location lBase = GetLocation (oTrigger);
vector vBase = GetPositionFromLocation (lBase);
float fX = GetLocalFloat (oTrigger, "X_BASE");
float fY = GetLocalFloat (oTrigger, "Y_BASE");
float fXMod = GetLocalFloat (oTrigger, "X_MOD");
float fYMod = GetLocalFloat (oTrigger, "Y_MOD");
vector vNew = Vector (fX += GetRandomFloat (fXMod), fY += GetRandomFloat (fYMod), vBase.z);
location lNew = Location (GetAreaFromLocation (lBase), vNew, GetRandomFloat (360.0) );
return lNew;
}
Admittedly, I just slapped that together, and test compiled it moreso than actually tested it, but it should work. Simply moving the mouse around over the trigger should give you the X and Y information you need for it.
Modifié par Failed.Bard, 22 septembre 2011 - 01:36 .