Files
HeroesStone_PRC8/_module/nss/randomwalk.nss
Jaysyn904 1eefc84201 Initial Commit
Initial Commit.
2025-09-14 15:40:46 -04:00

50 lines
1.1 KiB
Plaintext

void main()
{
int nValue = Random(10);
if (nValue < 3)
{
vector vCurrent = GetPosition(OBJECT_SELF);
float fOldX = vCurrent.x;
float fOldY = vCurrent.y;
float fOldZ = vCurrent.z;
int nX = Random(7);
int nY = Random(7);
int nSignX = Random(2);
int nSignY = Random(2);
float fNewX;
float fNewY;
float fNewZ = fOldZ;
switch(nSignX)
{
case 0:
fNewX = fOldX + IntToFloat(nX);
break;
case 1:
fNewX = fOldX - IntToFloat(nX);
break;
}
switch(nSignY)
{
case 0:
fNewY = fOldY + IntToFloat(nY);
break;
case 1:
fNewY = fOldY - IntToFloat(nY);
break;
}
object oArea = GetArea(OBJECT_SELF);
vector vNew = Vector(fNewX, fNewY, fNewZ);
float fFacing = GetFacing(OBJECT_SELF);
location lNewSpot = Location(oArea, vNew, fFacing);
AssignCommand(OBJECT_SELF, ActionMoveToLocation(lNewSpot, FALSE));
}
}