mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-28 22:15:54 -04:00
165 lines
5.4 KiB
Plaintext
165 lines
5.4 KiB
Plaintext
// ======================================================================
|
|
//
|
|
// qa_helper.script
|
|
// Copyright 2006, Sony Online Entertainment
|
|
// All Rights Reserved.
|
|
//
|
|
// VERSION 1.00
|
|
//
|
|
// Jeff W Haskell
|
|
//
|
|
// [internal]
|
|
// QA Tool - AI Helper Tool Version 1.00
|
|
// [public]
|
|
// not for public use
|
|
// [testplan]
|
|
// Attach the test.qatools script to the test character and use the spatial command 'qahelper'.
|
|
// [TT none]
|
|
// [reviewed-by ]
|
|
// ======================================================================
|
|
//
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
|
|
include java.util.StringTokenizer;
|
|
include library.create;
|
|
include library.combat;
|
|
include library.qa;
|
|
include library.sui;
|
|
include library.utils;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
const string PID_SCRIPTVAR = "qa_helper";
|
|
const string SCRIPTVAR = "qahelper";
|
|
const string SCRIPTVAR_MOB = "qahelper_record";
|
|
const string CREATURE_TABLE = "datatables/mob/creatures.iff";
|
|
//const int MAXHEALTH = getMaxAttrib( self, HEALTH );
|
|
|
|
/***** TRIGGER *******************************************************/
|
|
trigger OnSpeaking(string text)
|
|
{
|
|
if(isGod(self))
|
|
{
|
|
|
|
if (text.startsWith(SCRIPTVAR))
|
|
{
|
|
java.util.StringTokenizer st = new java.util.StringTokenizer(text);
|
|
string cmd = st.nextToken();
|
|
string arg = "";
|
|
|
|
if (st.hasMoreTokens())
|
|
arg = st.nextToken();
|
|
|
|
makeHelper(self, arg);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnCreatureDamaged(obj_id attacker, obj_id weapon, int[] damage)
|
|
{
|
|
if (hasScript(self, "player.yavin_e3") && utils.getBooleanScriptVar(self, SCRIPTVAR_MOB+".recordDamage") && utils.getObjIdScriptVar(attacker, "spawnedBy") == self)
|
|
{
|
|
sendSystemMessageTestingOnly(self, "Damage numbers will not be accurate due to player.yavin_e3 script attached to your character");
|
|
}
|
|
else
|
|
{
|
|
//check to make sure we are registering hits from the helper
|
|
if (utils.getObjIdScriptVar(attacker, "spawnedBy") == self)
|
|
{
|
|
//make sure we are recording
|
|
if (utils.getBooleanScriptVar(self, SCRIPTVAR_MOB+".recordDamage"))
|
|
{
|
|
string weaponString = "";
|
|
string unlocalizedWeaponName = "";
|
|
|
|
int testerHealth = utils.getIntScriptVar(self, SCRIPTVAR_MOB+".healthVar");
|
|
|
|
int currentTime = getGameTime();
|
|
int currentHealth = getAttrib(self, HEALTH);
|
|
int damageAmount = testerHealth - currentHealth;
|
|
|
|
//sendSystemMessageTestingOnly(attacker, "testerHealth: "+ testerHealth);
|
|
//sendSystemMessageTestingOnly(attacker, "testerHealth: "+ testerHealth);
|
|
//sendSystemMessageTestingOnly(attacker, "testerHealth: "+ testerHealth);
|
|
|
|
//set the health value to the current value so we can get an accurate damage number next time
|
|
utils.setScriptVar(self, SCRIPTVAR_MOB+".healthVar", currentHealth);
|
|
|
|
//Get weapon data
|
|
obj_id objWeapon = getCurrentWeapon(attacker);
|
|
string objectWeaponName = getName(objWeapon);
|
|
|
|
int staticItem = objectWeaponName.indexOf("static_item_n:");
|
|
int nonStaticItem = objectWeaponName.indexOf("weapon_name:");
|
|
|
|
//The weapon used could be in one of 2 string files on the server (see above)
|
|
//Based on the int value, the weapon data will be saved/exported in the report
|
|
if (nonStaticItem > -1)
|
|
{
|
|
unlocalizedWeaponName = objectWeaponName.substring(12);
|
|
weaponString = localize(new string_id( "weapon_name", unlocalizedWeaponName));
|
|
}
|
|
else if (staticItem > -1)
|
|
{
|
|
unlocalizedWeaponName = objectWeaponName.substring(14);
|
|
weaponString = localize(new string_id( "static_item_n", unlocalizedWeaponName));
|
|
}
|
|
//Make the weapon string the unlocalized code string if the string isn't localized. Better a code string than nothing
|
|
else if (unlocalizedWeaponName != "")
|
|
{
|
|
weaponString = unlocalizedWeaponName;
|
|
}
|
|
//If all else fails, leave an error message so that the user will contact tool team to fix
|
|
else
|
|
{
|
|
weaponString = "Error Retirieving Weapon Data";
|
|
}
|
|
|
|
//sendSystemMessageTestingOnly(attacker, "weaponString: "+ weaponString);
|
|
string damageData = attacker + "\t" + currentTime + "\t " + damageAmount + "\t" + weaponString +"\r\n";
|
|
|
|
string appendDamage = "";
|
|
//Get Previous Damage Data if any
|
|
string damageDone = utils.getStringScriptVar(self, SCRIPTVAR_MOB+".damageDone");
|
|
if (damageDone != "No Data")
|
|
{
|
|
appendDamage = damageDone + damageData;
|
|
}
|
|
else
|
|
{
|
|
appendDamage = damageData;
|
|
}
|
|
//Append the new data and place it into a script var for use later
|
|
utils.setScriptVar(self, SCRIPTVAR_MOB+".damageDone", appendDamage);
|
|
|
|
currentHealth = 0;
|
|
damageAmount = 0;
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
/***** FUNCTION *******************************************************/
|
|
|
|
void makeHelper(obj_id self, string argumentString)
|
|
{
|
|
//sendSystemMessageTestingOnly(self, "function test completed");
|
|
int creatureRowNumber = dataTableSearchColumnForString(argumentString, "creatureName", CREATURE_TABLE);
|
|
if (creatureRowNumber > -1)
|
|
{
|
|
obj_id helperMob = create.createCreature(argumentString, getLocation(self), true);
|
|
attachScript(helperMob, "test.qa_ai_helper_attach");
|
|
sendSystemMessageTestingOnly(self,"Helper Created. Use radial menu.");
|
|
dictionary creatureRow = dataTableGetRow (CREATURE_TABLE, creatureRowNumber);
|
|
utils.setScriptVar(self, SCRIPTVAR+".creatureDictionary", creatureRow);
|
|
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessageTestingOnly(self,"Creature name invalid.");
|
|
}
|
|
} |