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

307 lines
7.3 KiB
Plaintext

// ======================================================================
//
// qadatapad.script
// Copyright 2006, Sony Online Entertainment
// All Rights Reserved.
//
// VERSION 1.0
//
// Jeff W Haskell
//
// ======================================================================
// Library Includes
// ======================================================================
include library.utils;
include library.qa;
include library.sui;
/********* CONSTANTS *****************************************/
const string SCRIPTVAR = "qadatapad";
const string DATAPAD_TOOL_TITLE = "QA DATAPAD TOOL";
const string DATAPAD_TOOL_PROMPT = "This tool allows the tester to view, warp, export and import into the datapad";
const int FILL_WAYPOINTS = 0;
const int CONTROL_DEVICES = 1;
const string[] DATAPAD_TOOL_MENU =
{
"Warp to Waypoints",
"Export Waypoints"
};
const string[] ADD_ON_DATAPAD_MENU =
{
"FILL WAYPOINTS",
"CLEAR ALL WAYPOINTS"
};
const string[][] WAYPOINT_STRING_MULTIARRAY =
{
{
"yavin4",
"space_yavin4",
"kashyyyk_main",
"mustafar",
"mustafar",
"tatooine",
"tatooine",
"yavin4",
"yavin4",
"endor",
"naboo",
"tatooine",
"yavin4",
"dathomir",
"rori",
"corellia"
}
,
{
"Beach",
"Yavin 4 Station",
"Kachirho",
"New Mining Facility",
"Old Mining Facility",
"Lt. Akal Colzet (Imperial Pilot Trainer)",
"Commander Oberhaur",
"Field Commander Alozen",
"Captain Denner",
"Admiral Kilnstrider",
"Grand Admiral Nial Declann",
"Commander Da'la Socuna",
"Major Eker",
"Arnecio Ulvaw'op",
"General Ufwol",
"Admiral Wilham Burke"
}
};
const float[][] WAYPOINT_FLOAT_MULTIARRAY =
{
{
6495f,
-5552f,
-568f,
-2530f,
-1850f,
-1132f,
-1127f,
3998f,
4000f,
3227f,
-5524f,
-3002f,
-6966f,
-115f,
3690f,
3082f
}
,
{
0.0f,
-7065f,
0.0f,
0.0f,
0.0f,
13.32f,
15f,
37f,
37f,
24f,
29f,
4f,
73f,
18f,
96f,
301f
}
,
{
4490f,
-5121f,
-100f,
1650f,
820f,
-3542f,
-3589f,
-6195f,
-6196f,
-3436f,
4618f,
2201f,
-5660,
-1579f,
-6463f,
-5203f
}
};
/***** TRIGGERS *******************************************************/
trigger OnAttach()
{
if(isGod(self))
{
if(getGodLevel(self) < 10)
{
detachScript(self, "test.qadatapad");
sendSystemMessage(self, "You do not have the appropriate access level to use this script.", null);
}
}
else if(!isGod(self))
{
detachScript(self, "test.qadatapad");
}
return SCRIPT_CONTINUE;
}
trigger OnSpeaking(string text)
{
if(isGod(self))
{
if(toLower(text).equals(SCRIPTVAR))
{
//FUNCTION TO SHOW THE MAIN MENU OF THE TOOL
toolMainMenu(self);
return SCRIPT_OVERRIDE;
}
}
return SCRIPT_CONTINUE;
}
/******** Message Handlers *************************************/
messageHandler handleWarpScriptOptions()
{
if(isGod(self))
{
//STATIC SCRIPT VARIBLE
if(utils.hasScriptVar( self, SCRIPTVAR+".pid"))
{
qa.checkParams(params, SCRIPTVAR);
obj_id player = sui.getPlayerId(params);
int idx = sui.getListboxSelectedRow(params);
int btn = sui.getIntButtonPressed(params);
//CHECK FOR CANCEL BUTTON
if(btn == sui.BP_CANCEL)
{
qa.removePlayer(player, SCRIPTVAR, "");
return SCRIPT_CONTINUE;
}
else if(btn == sui.BP_REVERT)
{
qa.qaToolMainMenu(self);
utils.removeScriptVarTree(self, SCRIPTVAR);
return SCRIPT_CONTINUE;
}
//ATTAINING THE PREVIOUS MENU AND PLACING IT INTO AN ARRAY
string previousMainMenuArray[] = utils.getStringArrayScriptVar(self, SCRIPTVAR+".warpMenu");
//FINDING THE SPECIFIC SELECTION MADE BY USER (IF NEEDED)
string previousSelection = previousMainMenuArray[idx];
if(utils.hasScriptVar(self, SCRIPTVAR+".warpPoints") && !addOnSelection(self, previousSelection))
{
location waypointWarpLocationArray[] = utils.getLocationArrayScriptVar( self, SCRIPTVAR+".warpPoints" );
location warpSelection = waypointWarpLocationArray[idx];
goWarpLocation (player, warpSelection);
CustomerServiceLog("qaTool","User: (" + self + ") " + getName(self) + " has warped to (" + warpSelection + ") using a QA Datapad Tool.");
qa.removePlayer(player, SCRIPTVAR, "");
}
else
{
//Add new Add-On menu item conditions as the need arises
//sendSystemMessageTestingOnly(self, "add on menu");
if(previousSelection == ADD_ON_DATAPAD_MENU[0])
{
testWaypointLocations(self);
toolMainMenu(self);
}
else if(previousSelection == ADD_ON_DATAPAD_MENU[1])
{
deleteAllWaypoints(self);
toolMainMenu(self);
}
}
}
}
return SCRIPT_CONTINUE;
}
/*------------- ALL FUNCTIONS ----------------------------------------------*/
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
//BUILDS THE WARP MENU
void toolMainMenu(obj_id self)
{
obj_id[] waypointArray = qa.getAllValidWaypoints(self);
string[] waypointMenu = qa.getMenuList(self, waypointArray, "waypoint menu");
if(waypointMenu.length > 0)
{
location[] waypointWarpLocations = qa.getLocationList(self, waypointArray);
utils.setScriptVar(self, SCRIPTVAR+".warpPoints", waypointWarpLocations);
string[] combinedMenu = new string[waypointMenu.length + ADD_ON_DATAPAD_MENU.length];
System.arraycopy(waypointMenu, 0, combinedMenu, 0, waypointMenu.length);
System.arraycopy(ADD_ON_DATAPAD_MENU, 0, combinedMenu, waypointMenu.length, ADD_ON_DATAPAD_MENU.length);
qa.refreshMenu(self, DATAPAD_TOOL_PROMPT, DATAPAD_TOOL_TITLE, combinedMenu, "handleWarpScriptOptions", SCRIPTVAR+".pid", SCRIPTVAR+".warpMenu", sui.OK_CANCEL_REFRESH);
}
else
{
qa.refreshMenu(self, DATAPAD_TOOL_PROMPT, DATAPAD_TOOL_TITLE, ADD_ON_DATAPAD_MENU, "handleWarpScriptOptions", SCRIPTVAR+".pid", SCRIPTVAR+".warpMenu", sui.OK_CANCEL_REFRESH);
}
}
void goWarpLocation(obj_id player, location selectedLocation)
{
sendSystemMessageTestingOnly(player, "Waypoint data received, warping now.");
warpPlayer(player, selectedLocation.area, selectedLocation.x, selectedLocation.y, selectedLocation.z, null, 0.0f, 0.0f, 0.0f);
}
boolean createWaypoint(obj_id self, string planetArea, float locationX, float locationY, float locationZ, string waypointName)
{
location locationVar = new location();
locationVar.area = planetArea;
locationVar.x = locationX;
locationVar.y = locationY;
locationVar.z = locationZ;
string waypName = waypointName;
qa.createAQaWaypointInDataPad(self, locationVar, waypName);
return true;
}
void testWaypointLocations(obj_id self)
{
for(int i=0; i < WAYPOINT_STRING_MULTIARRAY[0].length; i++)
{
string planetArea = WAYPOINT_STRING_MULTIARRAY[0][i];
string waypointName = WAYPOINT_STRING_MULTIARRAY[1][i];
float locationX = WAYPOINT_FLOAT_MULTIARRAY[0][i];
float locationY = WAYPOINT_FLOAT_MULTIARRAY[1][i];
float locationZ = WAYPOINT_FLOAT_MULTIARRAY[2][i];
boolean response = createWaypoint(self, planetArea, locationX, locationY, locationZ, waypointName);
}
}
boolean deleteAllWaypoints(obj_id self)
{
obj_id[] waypoints = getWaypointsInDatapad(self);
for(int i=0; i < waypoints.length; i++)
{
destroyWaypointInDatapad(waypoints[i], self);
}
return true;
}
boolean addOnSelection(obj_id self, string previousSelection)
{
for(int i=0; i < ADD_ON_DATAPAD_MENU.length; i++)
{
if(previousSelection == ADD_ON_DATAPAD_MENU[i])
return true;
}
return false;
}