mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-28 22:15:54 -04:00
413 lines
12 KiB
Plaintext
413 lines
12 KiB
Plaintext
// ======================================================================
|
|
//
|
|
// qa_resources.script
|
|
// Copyright 2005, Sony Online Entertainment
|
|
// All Rights Reserved.
|
|
//
|
|
// VERSION .01
|
|
//
|
|
// Jeff W Haskell
|
|
//
|
|
// [internal]
|
|
// QA Tool - QA Resource Tool
|
|
// [public]
|
|
// not for public consumption
|
|
// [testplan]
|
|
// Attach the test.qa_resources script to the test character and use the spatial command 'qaresource'.
|
|
// A SUI will instantiate and give the tester options.
|
|
// [TT none]
|
|
// [reviewed-by ]
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// Library Includes
|
|
// ======================================================================
|
|
|
|
include library.craftinglib;
|
|
include library.utils;
|
|
include library.qa;
|
|
include library.sui;
|
|
|
|
/********* CONSTANTS *****************************************/
|
|
const string SCRIPTVAR = "resource";
|
|
|
|
const string[] MAIN_MENU =
|
|
{
|
|
"Recycled Resources",
|
|
"Space Resources"
|
|
};
|
|
|
|
const string[] RECYCLED_MAIN =
|
|
{
|
|
"Chemical",
|
|
"Creature",
|
|
"Flora",
|
|
"Metal",
|
|
"Ore"
|
|
};
|
|
|
|
const string[] RECYCLED_CHEMICAL =
|
|
{
|
|
"chemical",
|
|
"fuel_petrochem_solid",
|
|
"radioactive",
|
|
"water"
|
|
};
|
|
|
|
const string[] RECYCLED_CREATURE =
|
|
{
|
|
"bone",
|
|
"bone_horn",
|
|
"hide",
|
|
"meat",
|
|
"milk",
|
|
"seafood"
|
|
};
|
|
|
|
const string[] RECYCLED_FLORA =
|
|
{
|
|
"cereal",
|
|
"fruit",
|
|
"vegetable",
|
|
"wood"
|
|
};
|
|
|
|
const string[] RECYCLED_METAL =
|
|
{
|
|
"metal_ferrous",
|
|
"metal_nonferrous"
|
|
};
|
|
|
|
const string[] RECYCLED_ORE =
|
|
{
|
|
"ore_igneous",
|
|
"ore_sedimentary",
|
|
"gemstone"
|
|
};
|
|
|
|
const string[] SPACE_RESOURCE_CONST =
|
|
{
|
|
"space_chemical_acid",
|
|
"space_chemical_cyanomethanic",
|
|
"space_chemical_petrochem",
|
|
"space_chemical_sulfuric",
|
|
"space_gas_methane",
|
|
"space_gas_organometallic",
|
|
"space_gem_crystal",
|
|
"space_gem_diamond",
|
|
"space_metal_carbonaceous",
|
|
"space_metal_ice",
|
|
"space_metal_iron",
|
|
"space_metal_obsidian",
|
|
"space_metal_silicaceous"
|
|
};
|
|
|
|
const string RESOURCE_TOOL_DESCRIPTION = "This Tool will automatically spawn the space resources selected into the tester inventory.";
|
|
const string TITLE = "QA Resource Tool";
|
|
const int RECYCLED_AMOUNT = 100000;
|
|
|
|
/***** TRIGGERS *******************************************************/
|
|
trigger OnAttach()
|
|
{
|
|
if(isGod(self))
|
|
{
|
|
if(getGodLevel(self) < 10)
|
|
{
|
|
detachScript(self, "test.qa_resources");
|
|
sendSystemMessage(self, "You do not have the appropriate access level to use this script.", null);
|
|
}
|
|
}
|
|
else if (!isGod(self))
|
|
{
|
|
detachScript(self, "test.qa_resources");
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnSpeaking(string text)
|
|
{
|
|
if(isGod(self))
|
|
{
|
|
if ((toLower(text).equals("qaresource")) || (toLower(text).equals("qaresources")))
|
|
{
|
|
qa.refreshMenu ( self, "Select a Resource Type", TITLE, MAIN_MENU, "startingMenuOptions", true, "resource.pid", "resource.mainMenu" );
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/******** Message Handlers *************************************/
|
|
|
|
messageHandler startingMenuOptions()
|
|
{
|
|
if (isGod(self))
|
|
{
|
|
//STATIC SCRIPT VARIBLE
|
|
if (utils.hasScriptVar(self, "resource.pid"))
|
|
{
|
|
//sendSystemMessageTestingOnly(self, "startingMenuOptions");
|
|
|
|
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(player);
|
|
utils.removeScriptVarTree(player, SCRIPTVAR);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
//BUILD THE NEXT SUI
|
|
else
|
|
{
|
|
//PLACE THE PREVIOUS SCRIPTVAR ARRAY INTO A REAL ARRAY
|
|
string[] previousMainMenuArray = utils.getStringArrayScriptVar( self, "resource.mainMenu" );
|
|
//FIND THE SELECTION MADE FROM THE ARRAY ABOVE
|
|
string previousSelection = previousMainMenuArray[idx];
|
|
|
|
if (previousSelection == "Recycled Resources")
|
|
{
|
|
qa.refreshMenu ( self, "Select a Resource Type", TITLE, RECYCLED_MAIN, "recycledMenuOptions", false, "resource.pid", "resource.recycledMain" );
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
else if (previousSelection == "Space Resources")
|
|
{
|
|
qa.refreshMenu ( player, "Select a Resource Type", TITLE, SPACE_RESOURCE_CONST, "spaceResourceHandler", false, "resource.pid", "resource.spaceResource" );
|
|
|
|
}
|
|
else if(previousSelection == "Common Resources")
|
|
{
|
|
craftinglib.makeBestResource(self, "steel", 1000000);
|
|
craftinglib.makeBestResource(self, "iron", 1000000);
|
|
craftinglib.makeBestResource(self, "copper", 1000000);
|
|
craftinglib.makeBestResource(self, "fuel_petrochem_solid", 1000000);
|
|
craftinglib.makeBestResource(self, "radioactive", 1000000);
|
|
craftinglib.makeBestResource(self, "aluminum", 1000000);
|
|
craftinglib.makeBestResource(self, "ore_extrusive", 1000000);
|
|
craftinglib.makeBestResource(self, "petrochem_inert", 1000000);
|
|
craftinglib.makeBestResource(self, "fiberplast", 1000000);
|
|
craftinglib.makeBestResource(self, "gas_inert", 1000000);
|
|
craftinglib.makeBestResource(self, "gas_reactive", 1000000);
|
|
debugSpeakMsg(self, "Completed.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessageTestingOnly(player, "Tool Failed.");
|
|
qa.removePlayer(player, SCRIPTVAR, "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler recycledMenuOptions()
|
|
{
|
|
if(isGod(self))
|
|
{
|
|
|
|
|
|
//STATIC SCRIPT VARIBLE
|
|
if(utils.hasScriptVar( self, "resource.pid"))
|
|
{
|
|
//sendSystemMessageTestingOnly(self, "recycledMenuOptions");
|
|
|
|
qa.checkParams(params, "resource");
|
|
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.refreshMenu ( self, "Select a Resource Type", TITLE, MAIN_MENU, "startingMenuOptions", true, "resource.pid", "resource.mainMenu" );
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
//BUILD THE NEXT SUI
|
|
else
|
|
{
|
|
//PLACE THE PREVIOUS SCRIPTVAR ARRAY INTO A REAL ARRAY
|
|
string[] previousMainMenuArray = utils.getStringArrayScriptVar( self, "resource.recycledMain" );
|
|
//FIND THE SELECTION MADE FROM THE ARRAY ABOVE
|
|
string previousSelection = previousMainMenuArray[idx];
|
|
|
|
if (previousSelection == "Chemical")
|
|
{
|
|
qa.refreshMenu ( self, "Select a Resource Type", TITLE, RECYCLED_CHEMICAL, "allRecycledMenuOptions", false, "resource.pid", "resource.allRecycled" );
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
else if (previousSelection == "Creature")
|
|
{
|
|
qa.refreshMenu ( self, "Select a Resource Type", TITLE, RECYCLED_CREATURE, "allRecycledMenuOptions", false, "resource.pid", "resource.allRecycled" );
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
else if (previousSelection == "Flora")
|
|
{
|
|
qa.refreshMenu ( self, "Select a Resource Type", TITLE, RECYCLED_FLORA, "allRecycledMenuOptions", false, "resource.pid", "resource.allRecycled" );
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
else if (previousSelection == "Metal")
|
|
{
|
|
qa.refreshMenu ( self, "Select a Resource Type", TITLE, RECYCLED_METAL, "allRecycledMenuOptions", false, "resource.pid", "resource.allRecycled" );
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
else if (previousSelection == "Ore")
|
|
{
|
|
qa.refreshMenu ( self, "Select a Resource Type", TITLE, RECYCLED_ORE, "allRecycledMenuOptions", false, "resource.pid", "resource.allRecycled" );
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessageTestingOnly(player, "Tool Failed.");
|
|
qa.removePlayer(player, SCRIPTVAR, "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler allRecycledMenuOptions()
|
|
{
|
|
if(isGod(self))
|
|
{
|
|
//STATIC SCRIPT VARIBLE
|
|
if(utils.hasScriptVar(self, "resource.pid"))
|
|
{
|
|
//sendSystemMessageTestingOnly(self, "allRecycledMenuOptions");
|
|
|
|
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.refreshMenu ( self, "Select a Resource Type", TITLE, MAIN_MENU, "startingMenuOptions", true, "resource.pid", "resource.mainMenu" );
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
//BUILD THE NEXT SUI
|
|
else
|
|
{
|
|
//PLACE THE PREVIOUS SCRIPTVAR ARRAY INTO A REAL ARRAY
|
|
string[] previousMainMenuArray = utils.getStringArrayScriptVar(self, "resource.allRecycled");
|
|
//FIND THE SELECTION MADE FROM THE ARRAY ABOVE
|
|
string previousSelection = previousMainMenuArray[idx];
|
|
|
|
//SPAWN THE RECYCLED RESOURCE IN INVENTORY
|
|
createResourceInInventory(player, previousSelection);
|
|
CustomerServiceLog("qaTool","User: (" + self + ") " + getName(self) + " has spawned " + previousSelection + " (a recycled resource) using the QA Resource Tool.");
|
|
|
|
//INSTANTIATE THE SAME SUI JUST USED
|
|
qa.refreshMenu ( self, "Select a Resource Type", TITLE, previousMainMenuArray, "allRecycledMenuOptions", false, "resource.pid", "resource.allRecycled" );
|
|
return SCRIPT_OVERRIDE;
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler spaceResourceHandler()
|
|
{
|
|
if(isGod(self))
|
|
{
|
|
if(utils.hasScriptVar( self, "resource.pid"))
|
|
{
|
|
qa.checkParams(params, "resource");
|
|
obj_id player = sui.getPlayerId(params);
|
|
int idx = sui.getListboxSelectedRow(params);
|
|
int btn = sui.getIntButtonPressed(params);
|
|
string previousMainMenuArray[] = utils.getStringArrayScriptVar( self, "resource.spaceResource" );
|
|
if(btn == sui.BP_CANCEL)
|
|
{
|
|
qa.refreshMenu ( self, "Select a Resource Type", TITLE, MAIN_MENU, "startingMenuOptions", true, "resource.pid", "resource.mainMenu" );
|
|
}
|
|
else
|
|
{
|
|
string previousSelection = previousMainMenuArray[idx];
|
|
|
|
if(previousSelection == "")
|
|
{
|
|
sendSystemMessageTestingOnly(player, "There was a menu index error. Script failed.");
|
|
qa.removePlayer(player, SCRIPTVAR, "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
obj_id[] rtypes = getResourceTypes(previousSelection);
|
|
obj_id rtype = rtypes[0];
|
|
if(!isIdValid(rtype))
|
|
{
|
|
sendSystemMessageTestingOnly(self, "No id found");
|
|
sendSystemMessageTestingOnly(self, "Space Resource "+previousSelection+" could not be spawned. Report this to the tools team.");
|
|
return SCRIPT_CONTINUE;
|
|
|
|
}
|
|
string crateTemplate = getResourceContainerForType(rtype);
|
|
if(!crateTemplate.equals(""))
|
|
{
|
|
obj_id pInv = utils.getInventoryContainer(player);
|
|
if(!isIdNull(pInv))
|
|
{
|
|
obj_id crate = createObject(crateTemplate, pInv, "");
|
|
if( addResourceToContainer (crate, rtype, 100000, self) )
|
|
{
|
|
sendSystemMessageTestingOnly(self, "Resource of class "+previousSelection+" placed in inventory.");
|
|
CustomerServiceLog("qaTool","User: (" + self + ") " + getName(self) + " has spawned " + previousSelection + " (a space resource) using the QA Resource Tool.");
|
|
qa.refreshMenu(player, RESOURCE_TOOL_DESCRIPTION, TITLE, SPACE_RESOURCE_CONST, "spaceResourceHandler", false, "resource.pid", "resource.spaceResource");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/*------------- ALL FUNCTIONS ----------------------------------------------*/
|
|
/*--------------------------------------------------------------------------*/
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
void createResourceInInventory(obj_id player, string resourceTypeName)
|
|
{
|
|
|
|
obj_id resourceId = pickRandomNonDepeletedResource(resourceTypeName);
|
|
|
|
sendSystemMessageTestingOnly(player, "resourceId "+resourceId);
|
|
|
|
if(!isIdNull(resourceId))
|
|
{
|
|
obj_id recycle = getRecycledVersionOfResourceType(resourceId);
|
|
obj_id inv = utils.getInventoryContainer (player);
|
|
|
|
obj_id generic = createResourceCrate(recycle, RECYCLED_AMOUNT, inv);
|
|
sendSystemMessageTestingOnly(player, "Resource placed in inventory.");
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessageTestingOnly(player, "The function failed because there were no resources of this type found on the server.");
|
|
}
|
|
qa.removePlayer(player, SCRIPTVAR, "");
|
|
}
|