I use this in Wario Ware.
function getRandomFloat( %min, %max )
{
return %min + getRandom() * ( %max - %min );
}
//getRandomVect(%vectA, %vectB);
//Returns a random vector between Vector3F %vectA and Vector3F %vectB.
//%len is an unsigned integer 0-5 for the allowed float length, defaults to two.
function getRandomVect(%vectA, %vectB)
{
%xA = getWord(%vectA, 0);
%yA = getWord(%vectA, 1);
%zA = getWord(%vectA, 2);
%xB = getWord(%vectB, 0);
%yB = getWord(%vectB, 1);
%zB = getWord(%vectB, 2);
if(%xA != %xB)
%x = getRandomFloat(%xA, %xB);
else
%x = %xA;
if(%yA != %yB)
%y = getRandomFloat(%yA, %yB);
else
%y = %xA;
if(%zA != %zB)
%z = getRandomFloat(%zA, %zB);
else
%z = %zA;
return %x SPC %y SPC %z;
}
function GameConnection::spawnInArea(%this, %cornerA, %cornerB)
{
%this.instantRespawn();
%vect = getRandomVect(%cornerA, %cornerB);
%this.player.position = %vect;
}
Needs two corners. May be a better way to do it. Depends on your usage. The last function may be unnecessary for you.