Random Location Spawner. Needs Critique and Help
-
void main()
{
int iFetch_zmax = GetLocalInt(OBJECT_SELF, "zmax");
int iFetch_zcounter = GetLocalInt(OBJECT_SELF, "zcounter");
int iFetch_ztimer = GetLocalInt(OBJECT_SELF, "ztimer");int iRandomX = Random(100);
int iRandomY = Random(100);
int iRandomZ = Random(100);float fRandomXConvert = IntToFloat(iRandomX);
float fRandomYConvert = IntToFloat(iRandomY);
float fRandomZConvert = IntToFloat(iRandomZ);int iRandomO = Random(100);
float fRandomOConvert = IntToFloat(iRandomO);vector vRandomVector = Vector(fRandomXConvert, fRandomYConvert, fRandomZConvert);
object oFetchedArea = GetArea(OBJECT_SELF);
location lRandomLocation = Location(oFetchedArea, vRandomVector, fRandomOConvert);
if (iFetch_zcounter <= 5)
{
int iRandom = Random(12);if (iRandom == 0)
{
CreateObject(OBJECT_TYPE_CREATURE, "hzm", lRandomLocation, FALSE);
}
else if (iRandom == 1)
{
CreateObject(OBJECT_TYPE_CREATURE, "hzf", lRandomLocation, FALSE);
}
else if (iRandom == 2)
{
CreateObject(OBJECT_TYPE_CREATURE, "ezm", lRandomLocation, FALSE);
}
else if (iRandom == 3)
{
CreateObject(OBJECT_TYPE_CREATURE, "ezf", lRandomLocation, FALSE);
}
else if (iRandom == 4)
{
CreateObject(OBJECT_TYPE_CREATURE, "dzm", lRandomLocation, FALSE);
}
else if (iRandom == 5)
{
CreateObject(OBJECT_TYPE_CREATURE, "dzf", lRandomLocation, FALSE);
}
else if (iRandom == 6)
{
CreateObject(OBJECT_TYPE_CREATURE, "hozm", lRandomLocation, FALSE);
}
else if (iRandom == 7)
{
CreateObject(OBJECT_TYPE_CREATURE, "hozf", lRandomLocation, FALSE);
}
else if (iRandom == 8)
{
CreateObject(OBJECT_TYPE_CREATURE, "gzm", lRandomLocation, FALSE);
}
else if (iRandom == 9)
{
CreateObject(OBJECT_TYPE_CREATURE, "gzf", lRandomLocation, FALSE);
}
else if (iRandom == 10)
{
CreateObject(OBJECT_TYPE_CREATURE, "hzm2", lRandomLocation, FALSE);
}
else if (iRandom == 11)
{
CreateObject(OBJECT_TYPE_CREATURE, "hzf2", lRandomLocation, FALSE);
}SetLocalInt(OBJECT_SELF, "zcounter", iFetch_zcounter+1);
}
} -
What is this even trying to do?
-
I'm making a zombie survival rp server, and this script spawns zombies at random locations in an area. What I need help with is how the vectors work in relation to placement on the map. I basically made the random generation for the vectors for the random location 100 in hopes it would work, not knowing exactly how they interact with the grid and terrain. The script seems to work, but I was hoping on advice for how vectors and such work in the toolset. Also orientation in a location.
-
Nwn lexicon is your friend
http://www.nwnlexicon.com/index.php?tit ... 0_position
Search for random on that page and you will find GetRandomLocation ();
You can use that to plug in your locations without needing to get into the vector stuff.
-
If you really really need to then fiddle by hand with the orientation, you can use SetFacing ();