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

288 lines
6.7 KiB
Plaintext

//**********************************************************
// Copyright (c) ©2007 Sony Online Entertainment Inc.
// All Rights Reserved
//
// Title: qasetup.script
// Version: Version 1.00
// Description: QA Space Tools
// - Set of tools created for QA to test space content (especially chapter 8)
//
//
// @author $Author: Tim Jones
// @version $All Revisions:
//***********************************************************
/*
Todo list
New QA bag funtionality
Looping ala old lootlogger
Output to tab file
*/
/***** INCLUDES ********************************************************/
include java.util.Arrays;
include java.util.HashSet;
include java.util.StringTokenizer;
include java.util.Vector
include library.ai_lib;
include library.anims;
include library.beast_lib;
include library.buff;
include library.cloninglib;
include library.combat;
include library.corpse;
include library.create;
include library.datatable;
include library.dump;
include library.factions;
include library.features;
include library.gcw;
include library.gm;
include library.groundquests;
include library.hue;
include library.jedi;
include library.loot;
include library.minigame;
include library.objvar_mangle;
include library.pclib;
include library.player_structure;
include library.qa;
include library.respec;
include library.ship_ai;
include library.skill;
include library.skill_template;
include library.space_battlefield;
include library.space_combat;
include library.space_content;
include library.space_crafting;
include library.space_create;
include library.space_pilot_command;
include library.space_quest;
include library.space_transition;
include library.space_utils;
include library.spawning;
include library.static_item;
include library.sui;
include library.utils;
include library.xp;
include test.qatool;
/********* TABLES/DATA SOURCES *****************************************/
const string CREATURE_TABLE = "datatables/mob/creatures.iff";
const string SPACE_MOBILE_TABLE = "datatables/space_mobile/space_mobile.iff";
const string MASTER_ITEM_TABLE = "datatables/item/master_item/master_item.iff";
/********* MESSAGE HANDLERS *****************************************/
messageHandler runSpaceLootIteration()
{
int victimCount = params.getInt("victimCount");
string victimName = params.getString("victimName");
spaceLootIteration(self, victimName, victimCount);
return SCRIPT_CONTINUE;
}
/********* TRIGGERS *****************************************/
trigger OnAttach()
{
sendSystemMessageTestingOnly(self, "QaSpace script attached.");
return SCRIPT_CONTINUE;
}
trigger OnDetach()
{
sendSystemMessageTestingOnly(self, "QaSpace script detached.");
return SCRIPT_CONTINUE;
}
// Listens for spoken keywords. When the player speaks the appropriate keyword, the script is activated
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);
string command = st.nextToken();
string victimShip = "";
int victimCount = 1;
//pInv = players inventory
obj_id pInv = utils.getInventoryContainer(self);
if (command != "qaspaceloot")
{
return SCRIPT_CONTINUE;
}
if (st.hasMoreTokens())
{
victimShip = st.nextToken();
}
else
{
sendSystemMessageTestingOnly(self, "Space Loot Error: Missing name of victim ship");
}
if (st.hasMoreTokens())
{
victimCount = Integer.parseInt(st.nextToken());
}
spaceLoot(self, victimShip, victimCount);
return SCRIPT_CONTINUE;
}
/********* LOCAL METHODS *****************************************/
void spaceLoot(obj_id self, string victimName, int victimCount)
{
//DEBUG sendSystemMessageTestingOnly(self, "Enter SpaceLoot");
obj_id objMyShip = getPilotedShip(self);
if(objMyShip==null)
{
sendSystemMessageTestingOnly(self, "Space Loot Error: You must be in a ship in space.");
return;
}
int shipRowNumber = dataTableSearchColumnForString(victimName, "strIndex", SPACE_MOBILE_TABLE);
if(shipRowNumber == -1)
{
sendSystemMessageTestingOnly(self, "Space Loot Error: You passed in a bad shipType. Type is "+victimName);
return;
}
if(victimCount > 100)
{
sendSystemMessageTestingOnly(self, "Space Loot Error: Iterations limited 1 to 100.");
victimCount = 100;
}
if(victimCount < 1)
{
sendSystemMessageTestingOnly(self, "Space Loot Error: Iterations limited 1 to 100.");
victimCount = 1;
}
//figure out how many times you want to loop through the amount
//by dividing by 10
int loopAmountInt = victimCount / 10;
//find remainder if any
int remainderInt = victimCount % 10;
dictionary incrementDict = new dictionary();
//This is the Mobile's name that has already been checked/found in the creatures table
incrementDict.put("victimName", victimName);
if (loopAmountInt >= 1)
{
for(int i = 0; i < loopAmountInt; i++)
{
try
{
incrementDict.put("victimCount", 10);
//DEBUG sendSystemMessageTestingOnly(self, "send message: runSpaceLootIteration 10");
messageTo(self, "runSpaceLootIteration", incrementDict, 5, true);
}
catch (Exception e)
{
sendSystemMessageTestingOnly(self, "Interrupted! " + e);
}
}
}
if (remainderInt >= 1)
{
incrementDict.put("victimCount", remainderInt);
//DEBUG sendSystemMessageTestingOnly(self, "send message: runSpaceLootIteration " +remainderInt);
messageTo(self, "runSpaceLootIteration", incrementDict, 5, true);
}
}
void spaceLootIteration(obj_id self, string victimName, int victimCount)
{
if (victimCount < 1)
{
return;
}
for(int i = 0; i < victimCount; i++)
{
obj_id objMyShip = getPilotedShip(self);
obj_id objVictimShip = null;
if(isIdValid(objMyShip))
{
objVictimShip = space_create.createShip(victimName, getTransform_o2p(getPilotedShip(self)));
}
else
{
objVictimShip = space_create.createShip(victimName, getTransform_o2p(self));
}
if(objVictimShip==null)
{
sendSystemMessageTestingOnly(self, "Space Loot Error: You passed in a bad shipType. Type is "+victimName);
}
else
{
sendSystemMessageTestingOnly(self, "Space Loot: Made ship of type "+victimName+" object id is: "+objVictimShip);
notifyShipDamage(objVictimShip, objMyShip, 10.0f);
space_combat.doChassisDamage(objMyShip, objVictimShip, 0 ,1.0f);
setShipCurrentChassisHitPoints(objVictimShip, 0.0f);
utils.setLocalVar(objVictimShip, "space.give_rewards", 1);
space_combat.targetDestroyed(objVictimShip);
space_combat.setDeathFlags(objVictimShip);
float fltIntensity = rand(0, 1.0f);
handleShipDestruction(objVictimShip, fltIntensity);
space_combat.doDeathCleanup(objVictimShip);
sendSystemMessageTestingOnly(self, "Space Loot: Killed ship of type "+victimName+" object id is: "+objVictimShip);
}
}
}