Files
dsrc/sku.0/sys.server/compiled/game/script/working/requestloctest.script
T

305 lines
7.8 KiB
Plaintext

include library.locations;
include library.utils;
trigger OnAttach()
{
if ( !isGod(self) )
{
sendSystemMessage(self, "You are not authorized to use this script.", "");
detachScript(self, "working.requestloctest");
}
return SCRIPT_CONTINUE;
}
trigger OnSpeaking(string text)
{
if ( !isGod(self) )
{
return SCRIPT_CONTINUE;
}
int stringCheck = text.indexOf("get_location_32");
if ( stringCheck > -1 )
{
boolean checkSlope = true;
boolean checkWater = true;
stringCheck = text.indexOf("allow_slope");
if ( stringCheck > -1 )
{
checkSlope = false;
}
stringCheck = text.indexOf("allow_water");
if ( stringCheck > -1 )
{
checkWater = false;
}
location here = getLocation(self);
requestLocation(self, "get_location_32", here, 500.0f, 32.0f, checkWater, checkSlope);
sendSystemMessage(self, "requestingLocation: get_location_32 - water: " + checkWater + ", slope: " + checkSlope, "");
return SCRIPT_OVERRIDE;
}
stringCheck = text.indexOf("get_location_48");
if ( stringCheck > -1 )
{
boolean checkSlope = true;
boolean checkWater = true;
stringCheck = text.indexOf("allow_slope");
if ( stringCheck > -1 )
{
checkSlope = false;
}
stringCheck = text.indexOf("allow_water");
if ( stringCheck > -1 )
{
checkWater = false;
}
location here = getLocation(self);
requestLocation(self, "get_location_48", here, 500.0f, 48.0f, checkWater, checkSlope);
sendSystemMessage(self, "requestingLocation: get_location_48 - water: " + checkWater + ", slope: " + checkSlope, "");
return SCRIPT_OVERRIDE;
}
stringCheck = text.indexOf("get_location_64");
if ( stringCheck > -1 )
{
boolean checkSlope = true;
boolean checkWater = true;
stringCheck = text.indexOf("allow_slope");
if ( stringCheck > -1 )
{
checkSlope = false;
}
stringCheck = text.indexOf("allow_water");
if ( stringCheck > -1 )
{
checkWater = false;
}
location here = getLocation(self);
requestLocation(self, "get_location_64", here, 500.0f, 64.0f, checkWater, checkSlope);
sendSystemMessage(self, "requestingLocation: get_location_64 - water: " + checkWater + ", slope: " + checkSlope, "");
return SCRIPT_OVERRIDE;
}
stringCheck = text.indexOf("get_location_80");
if ( stringCheck > -1 )
{
boolean checkSlope = true;
boolean checkWater = true;
stringCheck = text.indexOf("allow_slope");
if ( stringCheck > -1 )
{
checkSlope = false;
}
stringCheck = text.indexOf("allow_water");
if ( stringCheck > -1 )
{
checkWater = false;
}
location here = getLocation(self);
requestLocation(self, "get_location_80", here, 500.0f, 80.0f, checkWater, checkSlope);
sendSystemMessage(self, "requestingLocation: get_location_80 - water: " + checkWater + ", slope: " + checkSlope, "");
return SCRIPT_OVERRIDE;
}
stringCheck = text.indexOf("get_location_96");
if ( stringCheck > -1 )
{
boolean checkSlope = true;
boolean checkWater = true;
stringCheck = text.indexOf("allow_slope");
if ( stringCheck > -1 )
{
checkSlope = false;
}
stringCheck = text.indexOf("allow_water");
if ( stringCheck > -1 )
{
checkWater = false;
}
location here = getLocation(self);
requestLocation(self, "get_location_96", here, 500.0f, 96.0f, checkWater, checkSlope);
sendSystemMessage(self, "requestingLocation: get_location_96 - water: " + checkWater + ", slope: " + checkSlope, "");
return SCRIPT_OVERRIDE;
}
stringCheck = text.indexOf("clear_last_location");
if ( stringCheck > -1 )
{
if ( hasObjVar(self, "locTest.objects") )
{
resizeable obj_id[] locObjects = getResizeableObjIdArrayObjVar(self, "locTest.objects");
if ( locObjects != null && locObjects.length > 0 )
{
int lastObjectIndx = locObjects.length - 1;
obj_id locObject = locObjects[lastObjectIndx];
utils.removeElementAt(locObjects, lastObjectIndx);
setObjVar(self, "locTest.objects", locObjects);
if ( isIdValid(locObject) )
{
locations.destroyLocationObject(locObject);
}
}
}
if ( hasObjVar(self, "locTest.waypoints") )
{
resizeable obj_id[] locWaypoints = getResizeableObjIdArrayObjVar(self, "locTest.waypoints");
if ( locWaypoints != null && locWaypoints.length > 0 )
{
int lastWaypointIndx = locWaypoints.length - 1;
obj_id locWaypoint = locWaypoints[lastWaypointIndx];
utils.removeElementAt(locWaypoints, lastWaypointIndx);
setObjVar(self, "locTest.waypoints", locWaypoints);
if ( isIdValid(locWaypoint) )
{
destroyWaypointInDatapad(locWaypoint, self);
}
}
}
return SCRIPT_OVERRIDE;
}
stringCheck = text.indexOf("clear_all_locations");
if ( stringCheck > -1 )
{
getRidOfLocObjects(self);
return SCRIPT_OVERRIDE;
}
stringCheck = text.indexOf("detach_script");
if ( stringCheck > -1 )
{
getRidOfLocObjects(self);
detachScript(self, "working.requestloctest");
return SCRIPT_OVERRIDE;
}
stringCheck = text.indexOf("help");
if ( stringCheck > -1 )
{
string msg1 = "Type get_location_32, get_location_48, get_location_64, get_location_80, or get_location_96 to request a location.";
string msg1b = " Include allow_slope or allow_water to not block for slope or for water.";
string msg2 = " Type clear_last_location or clear_all_locations to clear reserved location objects.";
string msg3 = " Type detach_script to clear current reserved location objects and detach this script.";
sendSystemMessage(self, msg1+msg1b+msg2+msg3, "");
return SCRIPT_OVERRIDE;
}
return SCRIPT_CONTINUE;
}
trigger OnLocationReceived (string locationId, obj_id locationObject, location locationLocation, float locationRadius)
{
if ( !isIdValid(locationObject) )
{
sendSystemMessage(self, "locationObject was invalid for search location: " + locationLocation + " locationId: " + locationId, "");
return SCRIPT_CONTINUE;
}
if ( locationLocation == null )
{
sendSystemMessage(self, "locationLocation was null (??!!?) for search location: " + locationLocation + " locationId: " + locationId, "");
return SCRIPT_CONTINUE;
}
resizeable obj_id[] locObjects = new obj_id[0];
if ( hasObjVar(self, "locTest.objects") )
{
locObjects = getResizeableObjIdArrayObjVar(self, "locTest.objects");
}
utils.addElement(locObjects, locationObject);
setObjVar(self, "locTest.objects", locObjects);
obj_id waypoint = createWaypointInDatapad(self, locationLocation);
setWaypointName(waypoint, locationId);
setWaypointActive(waypoint, true);
resizeable obj_id[] locWaypoints = new obj_id[0];
if ( hasObjVar(self, "locTest.waypoints") )
{
locWaypoints = getResizeableObjIdArrayObjVar(self, "locTest.waypoints");
}
utils.addElement(locWaypoints, waypoint);
setObjVar(self, "locTest.waypoints", locWaypoints);
sendSystemMessage(self, "OnLocationReceived parameters - Id: " + locationId + ", location: " + locationLocation + ", object: " + locationObject + ", radius:" + locationRadius, "");
return SCRIPT_CONTINUE;
}
void getRidOfLocObjects(obj_id self)
{
if ( hasObjVar(self, "locTest.objects") )
{
resizeable obj_id[] locObjects = getResizeableObjIdArrayObjVar(self, "locTest.objects");
removeObjVar(self, "locTest.objects");
if ( locObjects != null && locObjects.length > 0 )
{
for ( int i = 0; i < locObjects.length; i++ )
{
obj_id locObject = locObjects[i];
if ( isIdValid(locObject) )
{
locations.destroyLocationObject(locObject);
}
}
}
}
if ( hasObjVar(self, "locTest.waypoints") )
{
resizeable obj_id[] locWaypoints = getResizeableObjIdArrayObjVar(self, "locTest.waypoints");
removeObjVar(self, "locTest.waypoints");
if ( locWaypoints != null && locWaypoints.length > 0 )
{
for ( int i = 0; i < locWaypoints.length; i++ )
{
obj_id locWaypoint = locWaypoints[i];
if ( isIdValid(locWaypoint) )
{
destroyWaypointInDatapad(locWaypoint, self);
}
}
}
}
return;
}