Files
dsrc/sku.0/sys.server/compiled/game/script/test/getgoodlocation_test.script
T
2013-09-10 23:17:15 -07:00

93 lines
1.7 KiB
Plaintext

void end(obj_id self)
{
debugSpeakMsg(self, "Testing of GetGoodLocation has begun");
}
void start(obj_id self)
{
debugSpeakMsg(self, "Testing of GetGoodLocation has begun");
}
trigger OnAttach()
{
start(self);
return SCRIPT_CONTINUE;
}
trigger OnDetach()
{
end(self);
return SCRIPT_CONTINUE;
}
trigger OnHearSpeech(obj_id speaker, string text)
{
string[] words = split( text, ' ' );
if ( words[0].equals("getgoodloc" ))
{
getGoodLoc(self);
}
if ( words[0].equals("getheight" ))
{
getHeight(self);
}
if (words[0].equals("dropobjectstest" ))
{
dropTestObjects(self, 100);
}
return SCRIPT_CONTINUE;
}
void getGoodLoc(obj_id self)
{
location sll = new location (getLocation (self));
sll.x -= 8;
sll.z -= 8;
location sur = new location (getLocation (self));
sur.x += 8;
sur.z += 8;
location goodLocation = getGoodLocation(8, 8, sll, sur, false, true);
if(goodLocation != null)
{
debugSpeakMsg(self, goodLocation.x + ", " + goodLocation.y + ", " + goodLocation.z + " is a good location.");
}
else
{
debugSpeakMsg(self, "Failed");
}
}
void dropTestObjects(obj_id self, int numObjects)
{
int areaSizeX = 8;
int areaSizeY = 8;
location sll = new location (getLocation (self));
sll.x -= 100;
sll.z -= 100;
location sur = new location (getLocation (self));
sur.x += 100;
sur.z += 100;
for(int i = 0; i < numObjects; ++i)
{
location goodLocation = getGoodLocation(areaSizeX, areaSizeY, sll, sur, false, true);
if(goodLocation != null)
{
createObject("object/tangible/furniture/frn_all_table_s01.iff", goodLocation);
}
else
{
debugSpeakMsg(self, "Failed to find good location.");
}
}
}
void getHeight(obj_id self)
{
float result = getHeightAtLocation(0, 0);
debugSpeakMsg(self, "" + result);
}