//************************************************************// // Copyright (c) ©2000,2001 Sony Online Entertainment Inc. // All Rights Reserved // // Title: qadna.script // Description: Creates valid test sample DNA for testers. // @author $Author: James Michener $ // @version $Revision: #1 $ //************************************************************/ /********* Includes ******************************************/ include library.sui; include library.utils; include library.incubator; include library.qa; include library.beast_lib; /********** Constants ****************************************/ const string INCUBATOR_TEMPLATES = "datatables/beast/incubator_templates.iff"; const string SCRIPTVAR = "qadna"; const string DNA_PROMPT = "Choose the creature you want to get DNA from. \nThe chosen DNA will be created in your inventory."; const string DNA_TITLE = "QA DNA Tool"; const string[] QATOOL_MAIN_MENU = dataTableGetStringColumn( "datatables/test/qa_tool_menu.iff", "main_tool" ); const string QATOOL_TITLE = "QA Tools"; const string QATOOL_PROMPT = "Choose the tool you want to use"; /********** Triggers *****************************************/ trigger OnAttach() { if (!isGod(self)) { detachScript(self, "test.qadna"); } else if (isGod(self)) { if(getGodLevel(self) < 10) { detachScript(self, "test.qadna"); sendSystemMessage(self, "You do not have the appropriate access level to use this script.", null); } } return SCRIPT_CONTINUE; } trigger OnSpeaking(string text) { if(isGod(self)) { if (toLower(text).equals("qadna") ) { getCreatureList(self); return SCRIPT_OVERRIDE; } } return SCRIPT_CONTINUE; } /********** MessageHandlers ********************************/ messageHandler handlePetOptionsTool() { if(!isGod(self)) { return SCRIPT_CONTINUE; } 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); if(btn == sui.BP_CANCEL) { qa.refreshMenu(self, QATOOL_PROMPT, QATOOL_TITLE, QATOOL_MAIN_MENU, "toolMainMenu", true, "qatool.pid"); utils.removeScriptVarTree(player, "qadna"); return SCRIPT_CONTINUE; } if(btn == sui.BP_REVERT) { qa.refreshMenu(self, QATOOL_PROMPT, QATOOL_TITLE, QATOOL_MAIN_MENU, "toolMainMenu", true, "qatool.pid"); utils.removeScriptVarTree(player, "qadna"); return SCRIPT_CONTINUE; } else { switch(idx) { case 0: //QA DNA Creature List getCreatureList(self); break; case 1: //Not Available sendSystemMessageTestingOnly(self, "These pet options are not yet available."); qa.refreshMenu(self, QATOOL_PROMPT, QATOOL_TITLE, QATOOL_MAIN_MENU, "toolMainMenu", true, "qatool.pid"); utils.removeScriptVarTree(player, "qadna"); break; default: removePlayer(player, "Default Option on Switch"); return SCRIPT_CONTINUE; } } } return SCRIPT_CONTINUE; } messageHandler handleDnaOptions() { if(!isGod(self)) { return SCRIPT_CONTINUE; } 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.refreshMenu(self, QATOOL_PROMPT, QATOOL_TITLE, QATOOL_MAIN_MENU, "toolMainMenu", true, "qatool.pid"); utils.removeScriptVarTree(player, "qadna"); return SCRIPT_CONTINUE; } else if(btn == sui.BP_REVERT) { qa.refreshMenu(self, QATOOL_PROMPT, QATOOL_TITLE, QATOOL_MAIN_MENU, "toolMainMenu", true, "qatool.pid"); utils.removeScriptVarTree(player, "qadna"); return SCRIPT_CONTINUE; } else if(idx < 0) { removePlayer(player, "Index less than zero"); return SCRIPT_CONTINUE; } else { //retrieve chosen item string string chosenDnaItem = dataTableGetString(INCUBATOR_TEMPLATES, idx, "initial_template"); //get the creature name - this is used to accurately set the parent_creature_template objvar string creature = getDisplayName(chosenDnaItem); //sendSystemMessageTestingOnly(self, ""+params); setUpDnaWithDummyData(self, chosenDnaItem, creature); } } return SCRIPT_CONTINUE; } /*************** Functions *********************************/ //BUILDS THE MAIN TOOL MENU void toolMainMenu(obj_id self, string[] dnaCreatureArray) { qa.refreshMenu(self, DNA_PROMPT, DNA_TITLE, dnaCreatureArray, "handleDnaOptions", SCRIPTVAR+".pid", SCRIPTVAR+".mainMenu", sui.OK_CANCEL_REFRESH); } void getCreatureList(obj_id self) { //create vector Vector dnaCreatures = new Vector(); //get datatable column string[] dnaCreatureStringColumn = dataTableGetStringColumn(INCUBATOR_TEMPLATES, "initial_template"); if(dnaCreatureStringColumn.length > -1) { for(int i = 0; i < dnaCreatureStringColumn.length; i++) { string creatureDisplayName = getDisplayName(dnaCreatureStringColumn[i]); //add parsed string to vector dnaCreatures.add(creatureDisplayName); } //make sure the Vector is populated if(dnaCreatures.size() >= 1) { //convert the Vector to an Array string[] dnaCreatureArray = new string[dnaCreatures.size()]; dnaCreatures.toArray(dnaCreatureArray); toolMainMenu(self, dnaCreatureArray); } else { sendSystemMessageTestingOnly(self, "There is an error with this tool, if the issue persists, please contact the tool team."); removePlayer(self, ""); } } else { sendSystemMessageTestingOnly(self, "There is an error with this tool, if the issue persists, please contact the tool team."); removePlayer(self, ""); } } string getDisplayName(string creatureName) { //remove 'object/mobile/beast_master/' if(creatureName.indexOf("/") > -1) { string[] splitType = split(creatureName, '/'); creatureName = splitType[3]; } //remove '.iff' if(creatureName.indexOf(".") > -1) { string[] splitAtDot= split(creatureName, '.'); creatureName = splitAtDot[0]; } //remove 'bm_' creatureName = beast_lib.stripBmFromType(creatureName); return creatureName; } void setUpDnaWithDummyData (obj_id self, string creatureTemplate, string creature) { //player inventory obj_id pInv = utils.getInventoryContainer(self); //create dnaContainer obj_id dnaContainer = createObjectOverloaded("object/tangible/loot/beast/dna_container.iff", pInv); incubator.initializeDna(dnaContainer, self); setObjVar(dnaContainer, incubator.DNA_PARENT_TEMPLATE, creature); int row = dataTableSearchColumnForString(creatureTemplate, "initial_template", INCUBATOR_TEMPLATES); int hashTemplate = dataTableGetInt(INCUBATOR_TEMPLATES, row, "hash_initial_template"); setObjVar(dnaContainer, incubator.DNA_TEMPLATE_OBJVAR, hashTemplate); sendSystemMessageTestingOnly(self, "A "+creature+" DNA sample has been placed in your inventory."); removePlayer(self, ""); } //THIS FUNCTION IS A GENERIC SCRIPT REMOVAL FUNCTION void removePlayer(obj_id self, string err) { sendSystemMessageTestingOnly(self, err); qa.removeScriptVars(self, SCRIPTVAR); utils.removeScriptVarTree(self, SCRIPTVAR); }