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

685 lines
18 KiB
Plaintext

//**********************************************************
// Copyright (c) ©2008 Sony Online Entertainment Inc.
// All Rights Reserved
//
// Title: qasetup.script
// Version: Version 1.00
// Description: QA Character Setup Tool
// - Revamp of the QASetup tool
//
//
// @author $Author: Mikkel Jensen
// @version $All Revisions:
//***********************************************************
include java.util.HashSet;
include java.util.StringTokenizer;
include java.util.Vector;
include java.util.Arrays;
include library.utils;
include library.qa;
include library.sui;
include library.skill;
include library.respec;
include library.skill_template;
include library.gm;
include library.buff;
include library.performance;
/*
add to line 2205 in systems/buff/buff_handler
if(attemptingToSpendPoints > actualPointsToSpend && !isGod(self))
*/
// Constants
const string TEMPLATE_TABLE = "datatables/test/qa_setup_expertise.iff";
const string EXOTIC_MOD_STRINGS = "datatables/crafting/reverse_engineering_mods.iff";
const string[] QASETUP_MAIN_MENU = {"Quick Buff", "Set Template", "Generate Equipment", "Write Template to Disk"};
const string QASETUP_TITLE = "QA Setup";
const string QASETUP_PROMPT = "Choose the tool you want to use";
const string[] TOOL_OPTIONS = {
"Quick Setup",
"Quick Buff",
"Set Class and Template",
"Generate Equipment"
};
const string[] MOD_TYPES = {
"basic1",
"basic2",
"basic3",
"exotic1",
"exotic2",
"exotic3"
};
const string[] EQUIPMENT_OPTIONS = {
"Prefered Mods",
"All",
"Weapon",
"Armor",
"Powerups",
"Consumables"
};
const string[] CLASS_LIST = {
"bounty_hunter_1a",
"commando_1a",
"officer_1a",
"force_sensitive_1a",
"medic_1a",
"spy_1a",
"smuggler_1a",
"trader_1a",
"trader_1d",
"trader_1b",
"trader_1c"
};
const string[] BASIC_MOD_STRINGS = {
"precision_modified",
"strength_modified",
"agility_modified",
"stamina_modified",
"constitution_modified",
"luck_modified",
"camouflage",
"combat_block_value"
};
//****************QATool Main Menu*************************************************
//
//
//*********************************************************************************
trigger OnSpeaking(string text)
{
//obj_id player = sui.getPlayerId(params);
//obj_id pInv = utils.getInventoryContainer(player);
debugConsoleMsg(self, text);
java.util.StringTokenizer st = new java.util.StringTokenizer (text);
//pInv = players inventory
obj_id pInv = utils.getInventoryContainer(self);
if (text == "qaCharacter")
{
sendSystemMessageTestingOnly(self, "start menu wooo hoo.");
qaToolMainMenu(self);
}
if (text == "writeTemp")
{
writeTemplateFile();
}
return SCRIPT_CONTINUE;
}
//Generates the main menu for the QASetup scrip
void qaToolMainMenu(obj_id self)
{
qa.refreshMenu(self, QASETUP_PROMPT, QASETUP_TITLE, QASETUP_MAIN_MENU, "handleMainMenu", true, "qasetup.pid", "qasetup.qasetup");
}
messageHandler handleMainMenu()
{
if(utils.hasScriptVar(self, "qasetup.pid"))
{
qa.checkParams(params, "qasetup");
int idx = sui.getListboxSelectedRow(params);
int btn = sui.getIntButtonPressed(params);
string previousMainMenuArray[] = utils.getStringArrayScriptVar( self, "qasetup.qasetup" );
if(btn == sui.BP_CANCEL)
{
return SCRIPT_CONTINUE;
}
else
{
string previousSelection = previousMainMenuArray[idx];
if (previousSelection == "Quick Buff")
{
quickBuff(self);
// sendSystemMessageTestingOnly(self, "bla bla bla The quick buff function is not yet implemented.");
}
if (previousSelection == "Set Template")
{
//setProfession(self);
String[] templateList = dataTableGetColumnNames(TEMPLATE_TABLE);
qa.refreshMenu(self, "Select the profession you wish to use.", "Set Profession", templateList, "handleSetProfession", true, "profession.pid", "qasetup.qasetup");
}
if (previousSelection == "Generate Equipment")
{
qa.refreshMenu(self, "Select the equipment type you want to generate.", "Generate Equipment", EQUIPMENT_OPTIONS, "handleEquipmentMenu", true, "equipment.pid", "equipment.qasetup");
//sendSystemMessageTestingOnly(self, "The generate equipment function is not yet implemented.");
return SCRIPT_CONTINUE;
}
if (previousSelection == "Write Template to Disk")
{
writeTemplateFile();
}
}
}
return SCRIPT_CONTINUE;
}
/********************************* QUICK BUFF ***********************************
This section allows the user to instantly recieve a large selection of buffs based
on what a well prepared high level player would use.
*********************************************************************************/
void quickBuff(obj_id self)
{
string prof = getSkillTemplate(self);
//if(prof != "entertainer_1a")
//{
/* for (int i = 0; i < BUFF_SKILLS.length; i++)
{
skill.grantSkillToPlayer(self, BUFF_SKILLS[i]);
sendSystemMessageTestingOnly(self, "Granting Skill: " + BUFF_SKILLS[i]);
skill.recalcPlayerPools(self, true);
};
//utils.removeScriptVarTree(self,"performance");
const string[] buffComponentKeys =
{
"action_cost_reduction",
"dodge",
"energy",
"kinetic"
};
const int[] buffComponentValues =
{
1, 1, 5, 5
};
*/
obj_id recipientId = self;
obj_id bufferId = recipientId;
//float currentBuffTime = performance.inspireGetMaxDuration(recipientId);
buff.applyBuff(recipientId, "buildabuff_inspiration", 3600);
/* utils.setScriptVar(recipientId, "performance.buildabuff.buffComponentKeys", buffComponentKeys);
utils.setScriptVar(recipientId, "performance.buildabuff.buffComponentValues", buffComponentValues);
utils.setScriptVar(recipientId, "performance.buildabuff.bufferId", bufferId);
*/
addSkillModModifier(self, "buildabuff_expertise_action_all", "expertise_action_all", 9, 3600, false, true);
addSkillModModifier(self, "buildabuff_expertise_glancing_blow_all", "expertise_glancing_blow_all", 7, 3600, false, true);
addSkillModModifier(self, "buildabuff_expertise_innate_protection_energy", "expertise_innate_protection_energy", 3750, 3600, false, true);
addSkillModModifier(self, "buildabuff_expertise_innate_protection_kinetic", "expertise_innate_protection_kinetic", 3750, 3600, false, true);
messageTo(self, "recalcPools", null, .25f, false);
//skill.recalcPlayerPools(self, true);
messageTo(self, "recalcArmor", null, .25f, false);
// }
/* for (int i = 0; i < BUFF_SKILLS.length; i++)
{
skill.revokeSkillSilent(self, BUFF_SKILLS[i]);
sendSystemMessageTestingOnly(self, "Removing Skill: " + BUFF_SKILLS[i]);
};*/
buff.applyBuff((recipientId), "me_buff_health_2", 3600);
buff.applyBuff((recipientId), "me_buff_action_3", 3600);
buff.applyBuff((recipientId), "me_buff_strength_3", 3600);
buff.applyBuff((recipientId), "me_buff_agility_3", 3600);
buff.applyBuff((recipientId), "me_buff_precision_3", 3600);
buff.applyBuff((recipientId), "drink_flameout", 3600);
qaToolMainMenu(self);
}
//base_class.java(7939): public static boolean addSkillModModifier(obj_id target, String name, String skill, int value, float duration,
/**
* Adds a skillmod modifier to a creature.
* @param target the creature
* @param name the mod name
* @param skill the skill to effect
* @param value modifier value
* @param duration how long it lasts
* @param triggerOnDone flag to trigger OnSkillModDone(string modName) when the mod is removed from the creature*/
/********************************** RESPEC TO LEVEL 90 *************************
This section will allow the user to select a template from a preset list based on
the datatable in "datatables/test/qa_setup_expertise.iff". The script will remove
all existing class and expertise skills. Set the player to level 90 (based on the
template) and grant the preset expertise skills.
The writeTemplateFile allows a user to save his expertise setup to a .tab file to
make it easier to add it to the list of available templates.
********************************************************************************/
//Takes the selected template from the qasetup.tab and passes it to 'setTemplate'
messageHandler handleSetProfession()
{
if(utils.hasScriptVar(self, "profession.pid"))
{
qa.checkParams(params, "profession");
int idx = sui.getListboxSelectedRow(params);
int btn = sui.getIntButtonPressed(params);
string previousMainMenuArray[] = utils.getStringArrayScriptVar( self, "qasetup.qasetup" );
if(btn == sui.BP_CANCEL)
{
return SCRIPT_CONTINUE;
}
else
{
string previousSelection = previousMainMenuArray[idx];
String[] selectedTemplate = dataTableGetStringColumn(TEMPLATE_TABLE, previousSelection);
string selectedProf = selectedTemplate[0];
for(int i = 1; i < selectedTemplate.length; i++)
{
int n = 0;
if(selectedTemplate[i] != "null")
{
//expertiseSkills[n] = selectedTemplate[i];
sendSystemMessageTestingOnly(self, "selectedTemp: " + selectedTemplate[i]);
}
}
sendSystemMessageTestingOnly(self, "Class template: " + selectedProf);
if(!previousSelection == "null")
{
//handleProfessionLevelToNinety(self, selectedProf);
setTemplate(self, selectedTemplate, selectedProf);
}
}
}
return SCRIPT_CONTINUE;
}
void handleProfessionLevelToNinety(obj_id player, string roadmap)
{
revokeAllSkills(player);
int currentCombatXp = getExperiencePoints(player, "combat_general");
grantExperiencePoints(player, "combat_general", -currentCombatXp);
skill.recalcPlayerPools(player, true);
setSkillTemplate(player, roadmap);
respec.autoLevelPlayer(player, 90, false);
//reset the expertise
utils.fullExpertiseReset(player, false);
skill.setPlayerStatsForLevel(player, 90);
}
void revokeAllSkills(obj_id player)
{
string[] skillList = getSkillListingForPlayer(player);
int attempts = skillList.length;
if ((skillList != null) && (skillList.length != 0))
{
while(skillList.length > 0 && attempts > 0)
{
for (int i = 0; i < skillList.length; i++)
{
string skillName = skillList[i];
if (!skillName.startsWith ("species_")&& //don't revoke species skills
!skillName.startsWith("social_language_")&&
!skillName.startsWith("utility_")&&
!skillName.startsWith("common_")&&
!skillName.startsWith("demo_")&&
!skillName.startsWith("force_title_")&&
!skillName.startsWith("force_sensitive_")&&
!skillName.startsWith("combat_melee_basic")&&
!skillName.startsWith("pilot_")&&
!skillName.startsWith("internal_expertise_") &&
!skillName.startsWith("combat_ranged_weapon_basic"))
{
skill.revokeSkillSilent(player, skillName);
}
}
// The new skill list is the remaining skills.
skillList = getSkillListingForPlayer(player);
// Prevent data from creating an infinite loop.
--attempts;
}
}
skill.recalcPlayerPools(player, true);
}
/**************************** Expertise **********************************
*************************************************************************/
// Grants expertise skills to the player based on the template skillList
void setTemplate(obj_id self, string[] skillList, string baseClass)
{
handleProfessionLevelToNinety(self, baseClass);
//reset the expertise
utils.fullExpertiseReset(self, false);
for (int j = 1; j < skillList.length; j++)
{
int exotic = 1;
int basic = 1;
string expertiseSkill = skillList[j];
if(expertiseSkill.startsWith("expertise_"))
{
skill.grantSkillToPlayer(self, expertiseSkill);
}
if(expertiseSkill.startsWith("mod_exotic") && exotic <= 3)
{
string[] modString = split(expertiseSkill, ':');
//string mod = modString[1];
string scriptVarName = "qacharacter.exotic" + exotic;
utils.setScriptVar(self, scriptVarName, modString[1]);
exotic++;
}
if(expertiseSkill.startsWith("mod_basic") && basic <= 3)
{
string[] modString = split(expertiseSkill, ':');
//string mod = modString[1];
string scriptVarName = "qacharacter.basic" + basic;
utils.setScriptVar(self, scriptVarName, modString[1]);
basic++;
}
}
qaToolMainMenu(self);
}
//Generates a .tab file with the characters expertise skills
void writeTemplateFile()
{
obj_id self = getSelf();
sendSystemMessageTestingOnly(self, "In write file method");
string[] pSkill = getSkillListingForPlayer(self);
string prof = getSkillTemplate(self);
string template = "Template Name\n"+"s\n"+prof;
string temp;
int attempts = pSkill.length;
if ((pSkill != null) && (pSkill.length != 0))
{
while(pSkill.length > 0 && attempts > 0)
{
for (int i = 0; i < pSkill.length; i++)
{
string skillName = pSkill[i];
if (skillName.startsWith ("expertise_"))
{
temp = pSkill[i];
sendSystemMessageTestingOnly(self, "Adding line: " + pSkill[i]);
template += "\n" +temp;
}
--attempts;
}
}
}
saveTextOnClient(self, "qaSetup_" + getServerFrame() + ".tab", template);
qaToolMainMenu(self);
}
/************************************* SELECT MODS ******************************************
********************************************************************************************/
void startModSelection()
{
obj_id self = getSelf();
if(!utils.hasScriptVar(self, "modSelectionInProgress"))
{
boolean rm = removeMods();
utils.setScriptVar(self, "modSelectionInProgress", 1);
utils.setScriptVar(self, "modBasic", 1);
utils.setScriptVar(self, "modExotic", 1);
}
string[] exoticModList = getExoticMods();
int basicCounter = utils.getIntScriptVar(self, "modBasic");
int exoticCounter = utils.getIntScriptVar(self, "modExotic");
if(basicCounter <= 3)
{
qa.refreshMenu(self, "Select basic mod number " + basicCounter + " of 3", "Select Mods", BASIC_MOD_STRINGS, "handleMod", true, "profession.pid", "qasetup.qasetup");
}
if(basicCounter > 3 && exoticCounter <= 3)
{
qa.refreshMenu(self, "Select exotic mod number " + exoticCounter + " of 3", "Select Mods", exoticModList, "handleMod", true, "profession.pid", "qasetup.qasetup");
}
utils.removeScriptVar(self, "modSelectionInProgress");
}
boolean removeMods()
{
obj_id self = getSelf();
for (int j = 1; j < MOD_TYPES.length; j++)
{
if(utils.hasScriptVar(self, MOD_TYPES[j]))
{
utils.removeScriptVar(self, MOD_TYPES[j]);
}
}
if(utils.hasScriptVar(self,"modBasic"))
{
utils.removeScriptVar(self, "modBasic");
}
if(utils.hasScriptVar(self,"modExotic"))
{
utils.removeScriptVar(self, "modExotic");
}
return true;
}
messageHandler handleMod()
{
if(utils.hasScriptVar(self, "selectMod.pid"))
{
qa.checkParams(params, "selectMod");
int idx = sui.getListboxSelectedRow(params);
int btn = sui.getIntButtonPressed(params);
string previousMainMenuArray[] = utils.getStringArrayScriptVar( self, "selectMod.qasetup" );
string modChoice = previousMainMenuArray[idx];
int basicCounter = utils.getIntScriptVar(self, "modBasic");
int exoticCounter = utils.getIntScriptVar(self, "modExotic");
string type = "basic";
string modType = "modBasic";
if(basicCounter > 3)
{
type = "exotic";
modType = "modExotic";
}
int modNumber = utils.getIntScriptVar(self, modType);
utils.setScriptVar(self, type + modNumber, 1);
modNumber++;
utils.setScriptVar(self, modType, modNumber);
startModSelection();
}
return SCRIPT_CONTINUE;
}
string[] getExoticMods()
{
string[] skillMods = dataTableGetStringColumn(EXOTIC_MOD_STRINGS, "name");
for (int i = 0; i < skillMods.length; i++)
{
skillMods[i] = utils.packStringId(new string_id("stat_n", skillMods[i]));
}
return skillMods;
}
/************************************* GENERATE EQUIPMENT ***********************************
********************************************************************************************/
/*
messageHandler handleEquipmentMenu()
{
if(utils.hasScriptVar(self, "equipment.pid"))
{
qa.checkParams(params, "equipment");
int idx = sui.getListboxSelectedRow(params);
int btn = sui.getIntButtonPressed(params);
string previousMainMenuArray[] = utils.getStringArrayScriptVar( self, "equipment.qasetup" );
if(btn == sui.BP_CANCEL)
{
return SCRIPT_CONTINUE;
}
else
{
string previousSelection = previousMainMenuArray[idx];
if(previousSelection == "Prefered Mods")
{
selectMods();
}
if(previousSelection == "All")
{
}
if(previousSelection == "Weapon")
{
}
if(previousSelection == "Armor")
{
}
if(previousSelection == "Powerups")
{
//generatePowerup();
}
if(previousSelection == "Consumables")
{
}
else
{
sendSystemMessageTestingOnly(self, "Could not start the selected option");
return SCRIPT_CONTINUE;
}
}
}
return SCRIPT_CONTINUE;
}
void selectMods()
{
int m =0;
obj_id self = getSelf();
if(!utils.hasScriptVar(self, "ModSelection"))
{
m = 0;
boolean modSelection = removeMods();
utils.setScriptVar(self, "ModSelection", 1);
}
if(!utils.hasScriptVar(self, MOD_TYPES[m]))
{
qa.refreshMenu(self, "Select the three basic mods you want to use.", "Select Mods", BASIC_MOD_STRINGS, "handleMod", true, "profession.pid", "qasetup.qasetup");
}
}
boolean removeMods()
{
obj_id self = getSelf();
for (int j = 1; j < MOD_TYPES.length; j++)
{
if(utils.hasScriptVar(self, MOD_TYPES[j]))
{
utils.removeScriptVar(self, MOD_TYPES[j]);
}
}
/*
if(utils.hasScriptVar(self, "basic1"))
{
utils.removeScriptVar(self, "basic1");
}
if(utils.hasScriptVar(self, "basic2"))
{
utils.removeScriptVar(self, "basic2");
}
if(utils.hasScriptVar(self, "basic3"))
{
utils.removeScriptVar(self, "basic3");
}
if(utils.hasScriptVar(self, "exotic1"))
{
utils.removeScriptVar(self, "exotic1");
}
if(utils.hasScriptVar(self, "exotic2"))
{
utils.removeScriptVar(self, "exotic2");
}
if(utils.hasScriptVar(self, "exotic3"))
{
utils.removeScriptVar(self, "exotic3");
}
return true;
}
*/