who isn't sick of converting the freaking scripts? this negates the need

This commit is contained in:
DarthArgus
2015-11-24 09:27:45 -06:00
parent 2e64106bc8
commit bbee2d328c
11077 changed files with 2604347 additions and 3425075 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,200 @@
package script.content_tools;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.space_create;
import script.library.npe;
import script.library.sequencer;
import script.library.create;
import script.library.locations;
import script.library.space_transition;
import script.library.ship_ai;
import script.library.space_battlefield;
import script.library.space_crafting;
import script.library.player_structure;
import script.library.space_content;
import script.library.objvar_mangle;
import script.library.space_quest;
import script.library.sui;
import script.library.datatable;
import script.library.utils;
import script.library.hue;
import script.library.space_utils;
public class dump_ship_object_to_datatable extends script.base_script
{
public dump_ship_object_to_datatable()
{
}
public int OnSpeaking(obj_id self, String strText) throws InterruptedException
{
if (!isGod(self))
{
return SCRIPT_CONTINUE;
}
String[] strCommands = split(strText, ' ');
if (strCommands[0].equals("dumpShipContents"))
{
location locTest = getLocation(self);
obj_id objCell = locTest.cell;
if (!isIdValid(objCell))
{
sendSystemMessageTestingOnly(self, "DONT USE THIS IF YOU'RE NOT IN A BUILDING!");
return SCRIPT_CONTINUE;
}
obj_id objBuilding = getContainedBy(objCell);
if (!isIdValid(objBuilding))
{
sendSystemMessageTestingOnly(self, "You are not in a building. Don't use this when not in a building");
return SCRIPT_CONTINUE;
}
String strArea = locTest.area;
String strDataTable = "";
strDataTable = "datatables/ship_interiors/shipObjectsTemp" + getGameTime() + ".tab";
LOG("space", "table name is " + strDataTable);
String[] strHeaderTypes =
{
"s",
"f",
"f",
"f",
"f",
"f",
"f",
"f",
"f",
"f",
"p",
"s",
"s",
"i",
"s"
};
String[] strHeaders =
{
"strTemplate",
"fltJX",
"fltJY",
"fltJZ",
"fltKX",
"fltKY",
"fltKZ",
"fltPX",
"fltPY",
"fltPZ",
"strObjVars",
"strScripts",
"strCellName",
"intNoCreate",
"strLocationList"
};
boolean boolTest = datatable.createDataTable(strDataTable, strHeaders, strHeaderTypes);
if (!boolTest)
{
sendSystemMessageTestingOnly(self, "No datatable made");
return SCRIPT_CONTINUE;
}
obj_id[] objObjects = getBuildingContents(objBuilding);
sendSystemMessageTestingOnly(self, "dumping contents of " + objBuilding);
for (int intI = 0; intI < objObjects.length; intI++)
{
if (isDumpable(objObjects[intI]))
{
dictionary dctRow = new dictionary();
int intNoCreate = 0;
locTest = getLocation(objObjects[intI]);
String strTemplate = getTemplateName(objObjects[intI]);
float fltX = locTest.x;
float fltY = locTest.y;
float fltZ = locTest.z;
String strCellName = space_utils.getCellName(objBuilding, locTest.cell);
if (hasObjVar(objObjects[intI], "intNoCreate"))
{
intNoCreate = 1;
}
String strLocationList = "";
if (hasObjVar(objObjects[intI], "strLocationList"))
{
strLocationList = getStringObjVar(objObjects[intI], "strLocationList");
}
dctRow.put("strLocationList", strLocationList);
dctRow.put("intNoCreate", intNoCreate);
transform vctTest = getTransform_o2p(objObjects[intI]);
vector vctJ = vctTest.getLocalFrameJ_p();
vector vctK = vctTest.getLocalFrameK_p();
vector vctP = vctTest.getPosition_p();
dctRow.put("fltJX", vctJ.x);
dctRow.put("fltJY", vctJ.y);
dctRow.put("fltJZ", vctJ.z);
dctRow.put("fltKX", vctK.x);
dctRow.put("fltKY", vctK.y);
dctRow.put("fltKZ", vctK.z);
dctRow.put("fltPX", vctP.x);
dctRow.put("fltPY", vctP.y);
dctRow.put("fltPZ", vctP.z);
dctRow.put("strCellName", strCellName);
dctRow.put("strTemplate", strTemplate);
String strObjVars = getPackedObjvars(objObjects[intI]);
dctRow.put("strObjVars", strObjVars);
String strScripts = utils.getPackedScripts(objObjects[intI]);
dctRow.put("strScripts", strScripts);
datatable.serverDataTableAddRow(strDataTable, dctRow);
}
}
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
public boolean isDumpable(obj_id objObject) throws InterruptedException
{
if (isPlayer(objObject))
{
return false;
}
String strName = getTemplateName(objObject);
int intIndex = strName.indexOf("object/cell");
if (intIndex > -1)
{
return false;
}
if (hasObjVar(objObject, "intNoDump"))
{
return false;
}
if (hasScript(objObject, "systems.spawning.spawned_tracker"))
{
return false;
}
return true;
}
public obj_id[] getBuildingContents(obj_id objObject) throws InterruptedException
{
Vector objContents = new Vector();
objContents.setSize(0);
obj_id[] objCells = getContents(objObject);
for (int intI = 0; intI < objCells.length; intI++)
{
obj_id[] objTestContents = getContents(objCells[intI]);
if ((objTestContents != null) && (objTestContents.length > 0))
{
for (int intJ = 0; intJ < objTestContents.length; intJ++)
{
objContents = utils.addElement(objContents, objTestContents[intJ]);
}
}
}
obj_id[] _objContents = new obj_id[0];
if (objContents != null)
{
_objContents = new obj_id[objContents.size()];
objContents.toArray(_objContents);
}
return _objContents;
}
}
@@ -1,212 +0,0 @@
// Ripping off the functionality of a space content tool for use in dumping content of a ship interior to a datatable.
include library.space_create;
include library.npe;
include library.sequencer;
include library.create;
include library.locations;
include library.space_transition;
include library.ship_ai;
include library.space_battlefield;
include library.space_crafting;
include library.player_structure;
include library.space_content;
include library.objvar_mangle;
include library.space_quest;
include library.sui;
include library.datatable;
include library.utils;
include library.hue;
include library.space_utils;
trigger OnSpeaking(string strText)
{
if(!isGod(self))
return SCRIPT_CONTINUE;
string[] strCommands = split(strText, ' ' );
if(strCommands[0] =="dumpShipContents")
{
location locTest = getLocation(self);
obj_id objCell = locTest.cell;
if(!isIdValid(objCell))
{
sendSystemMessageTestingOnly(self, "DONT USE THIS IF YOU'RE NOT IN A BUILDING!");
return SCRIPT_CONTINUE;
}
obj_id objBuilding = getContainedBy(objCell);
if(!isIdValid(objBuilding))
{
sendSystemMessageTestingOnly(self, "You are not in a building. Don't use this when not in a building");
return SCRIPT_CONTINUE;
}
// string strBuildoutName = "";
// if(strCommands.length>1)
// {
// strBuildoutName= strCommands[1];
// }
// else
// {
// if(hasObjVar(objBuilding, "strBuildout"))
// {
// strBuildoutName = getStringObjVar(objBuilding, "strBuildout");
// }
// else
// {
// sendSystemMessageTestingOnly(self, "Syntax is dumpBuildout <type> or set the strBuildout objvar");
// return SCRIPT_CONTINUE;
// }
// }
// sendSystemMessageTestingOnly(self, "for objbuilding "+objBuilding+" objvatr is "+strBuildoutName);
string strArea = locTest.area;
string strDataTable = "";
strDataTable = "datatables/ship_interiors/shipObjectsTemp"+getGameTime()+".tab";
LOG("space", "table name is "+strDataTable);
string[] strHeaderTypes = { "s","f","f","f","f","f","f","f","f","f", "p", "s", "s", "i", "s"};
string[] strHeaders = {"strTemplate","fltJX","fltJY","fltJZ","fltKX","fltKY","fltKZ","fltPX","fltPY","fltPZ", "strObjVars", "strScripts", "strCellName", "intNoCreate", "strLocationList"};
boolean boolTest = datatable.createDataTable(strDataTable, strHeaders,strHeaderTypes);
if(!boolTest)
{
sendSystemMessageTestingOnly(self, "No datatable made");
return SCRIPT_CONTINUE;
}
obj_id[] objObjects = getBuildingContents(objBuilding);
sendSystemMessageTestingOnly(self, "dumping contents of "+objBuilding);
for(int intI = 0; intI<objObjects.length; intI++)
{
if(isDumpable(objObjects[intI]))
{
dictionary dctRow = new dictionary();
int intNoCreate = 0;
locTest = getLocation(objObjects[intI]);
string strTemplate = getTemplateName(objObjects[intI]);
float fltX = locTest.x;
float fltY = locTest.y;
float fltZ = locTest.z;
string strCellName = space_utils.getCellName(objBuilding, locTest.cell);
if(hasObjVar(objObjects[intI], "intNoCreate"))
{
intNoCreate = 1;
}
string strLocationList = "";
if(hasObjVar(objObjects[intI], "strLocationList"))
{
strLocationList = getStringObjVar(objObjects[intI], "strLocationList");
}
dctRow.put("strLocationList", strLocationList);
dctRow.put("intNoCreate", intNoCreate);
transform vctTest = getTransform_o2p(objObjects[intI]);
vector vctJ = vctTest.getLocalFrameJ_p();
vector vctK = vctTest.getLocalFrameK_p();
vector vctP = vctTest.getPosition_p();
dctRow.put("fltJX", vctJ.x);
dctRow.put("fltJY", vctJ.y);
dctRow.put("fltJZ", vctJ.z);
dctRow.put("fltKX", vctK.x);
dctRow.put("fltKY", vctK.y);
dctRow.put("fltKZ", vctK.z);
dctRow.put("fltPX", vctP.x);
dctRow.put("fltPY", vctP.y);
dctRow.put("fltPZ", vctP.z);
dctRow.put("strCellName", strCellName);
dctRow.put("strTemplate", strTemplate);
string strObjVars = getPackedObjvars(objObjects[intI]);
dctRow.put("strObjVars", strObjVars);
string strScripts = utils.getPackedScripts(objObjects[intI]);
dctRow.put("strScripts", strScripts);
//dataTableAddRow(strDataTable, dctRow);
datatable.serverDataTableAddRow(strDataTable,dctRow);
}
}
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
boolean isDumpable(obj_id objObject)
{
if(isPlayer(objObject))
{
return false;
}
// if (player_structure.isBuilding( objObject ) || player_structure.isInstallation( objObject ) )
// return true;
// if(space_utils.isPlayerControlledShip(objObject))
// {
// return false;
// }
string strName = getTemplateName(objObject);
int intIndex = strName.indexOf("object/cell");
if(intIndex>-1)
{
return false;
}
if(hasObjVar(objObject,"intNoDump"))
{
return false;
}
// is it in a building
// location locTest = getLocation(objObject);
// if(!boolDumpCells)
// {
// if(isIdValid(locTest.cell))
// {
// return false;
// }
// }
if(hasScript(objObject, "systems.spawning.spawned_tracker"))
{
return false;
}
return true;
}
obj_id[] getBuildingContents(obj_id objObject)
{
resizeable obj_id[] objContents = new obj_id[0];
obj_id[] objCells = getContents(objObject);
for(int intI = 0; intI< objCells.length; intI++)
{
obj_id[] objTestContents = getContents(objCells[intI]);
if((objTestContents!=null)&&(objTestContents.length>0))
{
for(int intJ = 0; intJ < objTestContents.length; intJ++)
{
objContents = utils.addElement(objContents, objTestContents[intJ]);
}
}
}
return objContents;
}
@@ -0,0 +1,144 @@
package script.content_tools;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.utils;
import script.library.space_transition;
import script.library.prose;
import script.library.space_crafting;
import script.library.space_utils;
import script.library.space_combat;
public class interior_buildout extends script.base_script
{
public interior_buildout()
{
}
public int OnInitialize(obj_id self) throws InterruptedException
{
dictionary dctParams = new dictionary();
requestPreloadCompleteTrigger(self);
return SCRIPT_CONTINUE;
}
public int OnPreloadComplete(obj_id self) throws InterruptedException
{
String strDataTable = "";
if (hasObjVar(self, "strBuildout"))
{
strDataTable = "datatables/interior_buildouts/" + getStringObjVar(self, "strBuildout") + ".iff";
}
else
{
setName(self, "FAILED TO BUILDOUT");
return SCRIPT_CONTINUE;
}
if (dataTableOpen(strDataTable))
{
String[] strTemplates = dataTableGetStringColumn(strDataTable, "strTemplate");
float[] fltJX = dataTableGetFloatColumn(strDataTable, "fltJX");
float[] fltJY = dataTableGetFloatColumn(strDataTable, "fltJY");
float[] fltJZ = dataTableGetFloatColumn(strDataTable, "fltJZ");
float[] fltKX = dataTableGetFloatColumn(strDataTable, "fltKX");
float[] fltKY = dataTableGetFloatColumn(strDataTable, "fltKY");
float[] fltKZ = dataTableGetFloatColumn(strDataTable, "fltKZ");
float[] fltPX = dataTableGetFloatColumn(strDataTable, "fltPX");
float[] fltPY = dataTableGetFloatColumn(strDataTable, "fltPY");
float[] fltPZ = dataTableGetFloatColumn(strDataTable, "fltPZ");
String[] strCellName = dataTableGetStringColumn(strDataTable, "strCellName");
String[] strObjVars = dataTableGetStringColumn(strDataTable, "strObjVars");
String[] strScripts = dataTableGetStringColumn(strDataTable, "strScripts");
String[] strLocationList = dataTableGetStringColumn(strDataTable, "strLocationList");
int[] intNoCreate = dataTableGetIntColumn(strDataTable, "intNoCreate");
for (int intI = 0; intI < strTemplates.length; intI++)
{
vector vctJ = new vector(fltJX[intI], fltJY[intI], fltJZ[intI]);
vector vctK = new vector(fltKX[intI], fltKY[intI], fltKZ[intI]);
vector vctP = new vector(fltPX[intI], fltPY[intI], fltPZ[intI]);
transform tr = new transform(vctJ.cross(vctK), vctJ, vctK, vctP);
obj_id objCell = getCellId(self, strCellName[intI]);
if (intNoCreate[intI] > 0)
{
if (!strLocationList[intI].equals(""))
{
Vector tranList = utils.getResizeableTransformArrayScriptVar(self, strLocationList[intI]);
Vector objCells = utils.getResizeableObjIdArrayScriptVar(self, strLocationList[intI] + "Cells");
if ((tranList == null) || (tranList.size() == 0))
{
Vector tranTestList = new Vector();
tranTestList.setSize(0);
Vector objTestCells = new Vector();
objTestCells.setSize(0);
tranTestList = utils.addElement(tranTestList, tr);
objTestCells = utils.addElement(objTestCells, objCell);
utils.setScriptVar(self, strLocationList[intI], tranTestList);
utils.setScriptVar(self, strLocationList[intI] + "Cells", objTestCells);
}
else
{
objCells = utils.addElement(objCells, objCell);
tranList = utils.addElement(tranList, tr);
utils.setScriptVar(self, strLocationList[intI], tranList);
utils.setScriptVar(self, strLocationList[intI] + "Cells", objCells);
}
}
if (!utils.checkConfigFlag("ScriptFlags", "liveSpaceServer"))
{
obj_id objTest = createObject(strTemplates[intI], tr, objCell);
if (!strObjVars[intI].equals(""))
{
setPackedObjvars(objTest, strObjVars[intI]);
}
if (!strScripts[intI].equals(""))
{
String[] strScriptArray = split(strScripts[intI], ',');
for (int intJ = 0; intJ < strScriptArray.length; intJ++)
{
String script = strScriptArray[intJ];
if (script.indexOf("script.") > -1)
{
script = script.substring(7);
}
if (!hasScript(objTest, script))
{
attachScript(objTest, script);
}
}
}
attachScript(objTest, "space.ship.ship_interior_autocleanup");
}
}
else
{
obj_id objTest = createObject(strTemplates[intI], tr, objCell);
if (!strObjVars[intI].equals(""))
{
setPackedObjvars(objTest, strObjVars[intI]);
}
if (!strScripts[intI].equals(""))
{
String[] strScriptArray = split(strScripts[intI], ',');
for (int intJ = 0; intJ < strScriptArray.length; intJ++)
{
String script = strScriptArray[intJ];
if (script.indexOf("script.") > -1)
{
script = script.substring(7);
}
if (!hasScript(objTest, script))
{
attachScript(objTest, script);
}
}
}
}
}
}
return SCRIPT_CONTINUE;
}
}
@@ -1,147 +0,0 @@
include library.utils;
include library.space_transition;
include library.prose;
include library.space_crafting;
include library.space_utils;
include library.space_combat;
trigger OnInitialize()
{
dictionary dctParams = new dictionary();
requestPreloadCompleteTrigger(self);
return SCRIPT_CONTINUE;
}
trigger OnPreloadComplete()
{
string strDataTable = "";
if(hasObjVar(self, "strBuildout"))
{
strDataTable = "datatables/interior_buildouts/"+getStringObjVar(self, "strBuildout")+".iff";
}
else
{
setName(self, "FAILED TO BUILDOUT");
return SCRIPT_CONTINUE;
}
if(dataTableOpen(strDataTable))
{
//LOG("space", "Openeed table of "+strDataTable);
string[] strTemplates = dataTableGetStringColumn(strDataTable, "strTemplate");
float[] fltJX = dataTableGetFloatColumn(strDataTable, "fltJX");
float[] fltJY = dataTableGetFloatColumn(strDataTable, "fltJY");
float[] fltJZ = dataTableGetFloatColumn(strDataTable, "fltJZ");
float[] fltKX = dataTableGetFloatColumn(strDataTable, "fltKX");
float[] fltKY = dataTableGetFloatColumn(strDataTable, "fltKY");
float[] fltKZ = dataTableGetFloatColumn(strDataTable, "fltKZ");
float[] fltPX = dataTableGetFloatColumn(strDataTable, "fltPX");
float[] fltPY = dataTableGetFloatColumn(strDataTable, "fltPY");
float[] fltPZ = dataTableGetFloatColumn(strDataTable, "fltPZ");
string[] strCellName =dataTableGetStringColumn(strDataTable, "strCellName");
string[] strObjVars = dataTableGetStringColumn(strDataTable, "strObjVars");
string[] strScripts = dataTableGetStringColumn(strDataTable, "strScripts");
string[] strLocationList = dataTableGetStringColumn(strDataTable, "strLocationList");
int[] intNoCreate = dataTableGetIntColumn(strDataTable, "intNoCreate");
for(int intI = 0; intI< strTemplates.length; intI++)
{
vector vctJ = new vector(fltJX[intI], fltJY[intI], fltJZ[intI]);
vector vctK = new vector(fltKX[intI], fltKY[intI], fltKZ[intI]);
vector vctP = new vector(fltPX[intI], fltPY[intI], fltPZ[intI]);
transform tr= new transform(vctJ.cross(vctK), vctJ, vctK, vctP);
obj_id objCell = getCellId(self, strCellName[intI]);
if(intNoCreate[intI]>0)
{
if(strLocationList[intI]!="")
{
resizeable transform[] tranList= utils.getResizeableTransformArrayScriptVar(self, strLocationList[intI]);
resizeable obj_id[] objCells = utils.getResizeableObjIdArrayScriptVar(self, strLocationList[intI]+"Cells");
if((tranList==null)||(tranList.length==0))
{
resizeable transform[] tranTestList= new transform[0];
resizeable obj_id[] objTestCells = new obj_id[0];
tranTestList= utils.addElement(tranTestList, tr);
objTestCells = utils.addElement(objTestCells, objCell);
utils.setScriptVar(self, strLocationList[intI], tranTestList);
utils.setScriptVar(self, strLocationList[intI]+"Cells", objTestCells);
}
else
{
objCells = utils.addElement(objCells, objCell);
tranList = utils.addElement(tranList, tr);
utils.setScriptVar(self, strLocationList[intI], tranList);
utils.setScriptVar(self, strLocationList[intI]+"Cells", objCells);
}
}
if(!utils.checkConfigFlag("ScriptFlags","liveSpaceServer"))
{
obj_id objTest = createObject(strTemplates[intI], tr, objCell);
if(strObjVars[intI]!="")
{
setPackedObjvars(objTest, strObjVars[intI]);
}
if(strScripts[intI]!="")
{
string[] strScriptArray = split(strScripts[intI], ',');
for(int intJ = 0; intJ<strScriptArray.length; intJ++)
{
string script = strScriptArray[intJ];
if ( script.indexOf( "script." ) > -1 )
{
script = script.substring( 7 );
}
if ( !hasScript( objTest, script ) )
attachScript( objTest, script );
}
}
attachScript(objTest, "space.ship.ship_interior_autocleanup"); // for cleanup later
}
}
else
{
obj_id objTest = createObject(strTemplates[intI], tr, objCell);
if(strObjVars[intI]!="")
{
setPackedObjvars(objTest, strObjVars[intI]);
}
if(strScripts[intI]!="")
{
string[] strScriptArray = split(strScripts[intI], ',');
for(int intJ = 0; intJ<strScriptArray.length; intJ++)
{
string script = strScriptArray[intJ];
if ( script.indexOf( "script." ) > -1 )
{
script = script.substring( 7 );
}
if ( !hasScript( objTest, script ) )
attachScript( objTest, script );
}
}
}
}
}
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,462 @@
package script.content_tools;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.sequencer;
import script.library.chat;
import script.library.utils;
import script.library.space_utils;
import script.library.npe;
public class sequencer_master_object extends script.base_script
{
public sequencer_master_object()
{
}
public int OnAttach(obj_id self) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int OnPreloadComplete(obj_id self) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int OnDestroy(obj_id self) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int doEvents(obj_id self, dictionary params) throws InterruptedException
{
String strIndexScriptVar = "";
String strFileName = "";
if (utils.hasScriptVar(self, "intSequenceStopped"))
{
if (utils.hasScriptVar(self, "intSequenceContinue"))
{
utils.removeScriptVar(self, "intSequenceStopped");
utils.removeScriptVar(self, "intSequenceContinue");
}
else
{
debugSpeakMsg(self, "I have STOPPED!");
utils.removeScriptVar(self, "intSequenceStopped");
return SCRIPT_CONTINUE;
}
}
if (params != null)
{
int intMessageStamp = params.getInt("intSecondaryTableStamp");
int intMyStamp = utils.getIntScriptVar(self, "intSecondaryTableStamp");
if (intMessageStamp != intMyStamp)
{
return SCRIPT_CONTINUE;
}
}
else if (utils.hasScriptVar(self, "intSecondaryTableStamp"))
{
return SCRIPT_CONTINUE;
}
float fltDelay = runSequenceEvents(self);
if (fltDelay > -1)
{
if (fltDelay == 0)
{
return SCRIPT_CONTINUE;
}
dictionary dctParams = null;
if (utils.hasScriptVar(self, "strSecondaryTable"))
{
dctParams = new dictionary();
int intTime = getGameTime();
utils.setScriptVar(self, "intSecondaryTableStamp", intTime);
dctParams.put("intSecondaryTableStamp", intTime);
}
messageTo(self, "doEvents", dctParams, fltDelay, false);
}
return SCRIPT_CONTINUE;
}
public int interruptSequence(obj_id self, dictionary params) throws InterruptedException
{
utils.setScriptVar(self, "intSequenceStopped", 1);
stopSequence(self);
return SCRIPT_CONTINUE;
}
public void stopSequence(obj_id self) throws InterruptedException
{
String strTable = "";
String strIndexScriptVar = "";
if (utils.hasScriptVar(self, "strSecondaryTable"))
{
strIndexScriptVar = "intSecondIndex";
strTable = utils.getStringScriptVar(self, "strSecondaryTable");
}
else
{
strIndexScriptVar = "intMainIndex";
strTable = getStringObjVar(self, "strSequenceTable");
}
String strFileName = "datatables/sequencer/event_sequence/" + strTable + ".iff";
float[] fltTimes = dataTableGetFloatColumn(strFileName, "fltTime");
int intIndex = utils.getIntScriptVar(self, strIndexScriptVar);
if (intIndex > 0)
{
intIndex = intIndex - 1;
}
dictionary dctEventToRun = dataTableGetRow(strFileName, intIndex);
String strAction = toLower(dctEventToRun.getString("strAction"));
if (strAction.equals("moveto"))
{
utils.setScriptVar(self, strIndexScriptVar, intIndex);
}
}
public float runSequenceEvents(obj_id self) throws InterruptedException
{
String strIndexScriptVar = "";
String strTable = "";
if (utils.hasScriptVar(self, "strSecondaryTable"))
{
strIndexScriptVar = "intSecondIndex";
strTable = utils.getStringScriptVar(self, "strSecondaryTable");
}
else
{
strIndexScriptVar = "intMainIndex";
strTable = getStringObjVar(self, "strSequenceTable");
}
String strFileName = "datatables/sequencer/event_sequence/" + strTable + ".iff";
LOG("npe", "strFileName is " + strFileName);
boolean noMoreEvents = false;
float[] fltTimes = dataTableGetFloatColumn(strFileName, "fltTime");
int intIndex = utils.getIntScriptVar(self, strIndexScriptVar);
float fltCurrentEventTime = fltTimes[intIndex];
while (!noMoreEvents)
{
dictionary dctEventToRun = dataTableGetRow(strFileName, intIndex);
intIndex = processEvents(dctEventToRun, intIndex);
if (intIndex == sequencer.CHANGE_TABLE)
{
if (utils.hasScriptVar(self, "strSecondaryTable"))
{
strFileName = "datatables/sequencer/event_sequence/" + utils.getStringScriptVar(self, "strSecondaryTable") + ".iff";
fltTimes = dataTableGetFloatColumn(strFileName, "fltTime");
intIndex = 0;
strIndexScriptVar = "intSecondIndex";
}
}
else
{
if (intIndex == sequencer.STOP_SEQUENCE)
{
return -1f;
}
}
float fltNextEvent = -1;
if (intIndex + 1 < fltTimes.length - 1)
{
fltNextEvent = fltTimes[intIndex + 1];
}
if (fltCurrentEventTime != fltNextEvent)
{
noMoreEvents = true;
if (intIndex > fltTimes.length - 1)
{
return -1f;
}
}
}
LOG("npe", "updating " + strIndexScriptVar + " to " + intIndex);
utils.setScriptVar(getSelf(), strIndexScriptVar, intIndex);
float fltDelay = 0;
if (intIndex == 0)
{
fltDelay = fltTimes[intIndex];
}
else
{
LOG("npe", "fltTimes[intIndex] is " + fltTimes[intIndex]);
LOG("npe", "fltTimes[intIndex-1] is " + fltTimes[intIndex - 1]);
fltDelay = fltTimes[intIndex] - fltTimes[intIndex - 1];
}
if (intIndex < fltTimes.length)
{
LOG("npe", "Returning " + fltDelay);
return fltDelay;
}
LOG("npe", "Returning " + fltDelay);
return -1f;
}
public int processEvents(dictionary dctEventToRun, int intIndex) throws InterruptedException
{
obj_id self = getSelf();
String strActor = dctEventToRun.getString("strActor");
String strAction = toLower(dctEventToRun.getString("strAction"));
String strTarget = dctEventToRun.getString("strTarget");
String strData1 = toLower(dctEventToRun.getString("strData1"));
String strData2 = toLower(dctEventToRun.getString("strData2"));
int intTime = dctEventToRun.getInt("intTime");
obj_id objTarget = null;
obj_id objActor = null;
if (!strActor.equals(""))
{
objActor = sequencer.getSequenceObject(strActor);
}
if (!strTarget.equals(""))
{
objTarget = sequencer.getSequenceObject(strTarget);
}
LOG("han_solo_event", "Doing event line --- Actor is " + strActor + ", ID is " + objActor + " doing action " + strAction + " at target " + strTarget + ", ID " + objTarget);
if (strAction.equals("combatanimation"))
{
if (!isIdValid(objActor) || isDead(objActor) || isDead(objTarget))
{
}
else
{
if (isIdValid(objTarget) && isIdValid(objTarget))
{
if (exists(objTarget) && exists(objActor))
{
startCombat(objActor, objTarget);
setTarget(objActor, objTarget);
}
}
sequencer.doCombatAnimation(objActor, objTarget, strData1);
}
}
if (strAction.equals("combatanimationmultiple"))
{
String[] strTargets = split(strTarget, ',');
obj_id[] objTargets = new obj_id[strTargets.length];
for (int i = 0; i < strTargets.length; i++)
{
objTargets[i] = sequencer.getSequenceObject(strTargets[i]);
}
for (int i = 0; i < objTargets.length; i++)
{
if (!isIdValid(objActor) || isDead(objActor) || isDead(objTargets[i]))
{
}
else
{
if (isIdValid(objTargets[i]) && isIdValid(objTargets[i]))
{
if (exists(objTargets[i]) && exists(objActor))
{
startCombat(objActor, objTargets[i]);
setTarget(objActor, objTargets[i]);
sequencer.doCombatAnimation(objActor, objTargets[i], strData1);
break;
}
}
}
}
}
else if (strAction.equals("moveto"))
{
if (strData1.equals("run"))
{
sequencer.runToSequenceObject(objActor, objTarget);
}
else if (strData1.equals("walk"))
{
sequencer.walkToSequenceObject(objActor, objTarget);
}
}
else if (strAction.equals("faceto"))
{
faceTo(objActor, objTarget);
}
else if (strAction.equals("posture"))
{
if (strData1.equals("stand"))
{
setPosture(objActor, POSTURE_UPRIGHT);
sequencer.doCombatAnimation(objActor, objTarget, "posture_scramble");
}
else if (strData1.equals("kneel"))
{
setPosture(objActor, POSTURE_CROUCHED);
sequencer.doCombatAnimation(objActor, objTarget, "posture_scramble");
}
else if (strData1.equals("prone"))
{
setPosture(objActor, POSTURE_PRONE);
sequencer.doCombatAnimation(objActor, objTarget, "posture_scramble");
}
}
else if (strAction.equals("effect"))
{
playClientEffectLoc(objActor, strData1, getLocation(objTarget), 0);
}
else if (strAction.equals("playmusic"))
{
play2dNonLoopingMusic(objActor, strData1);
}
else if (strAction.equals("spacechat"))
{
String stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
if (strData2.equals("") || strData2 == null)
{
strData2 = "sound/sys_comm_generic.snd";
}
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "");
}
else if (strAction.equals("tutorialcomm"))
{
String stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
if (strData2.equals("") || strData2 == null)
{
strData2 = "sound/sys_comm_generic.snd";
}
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "object/mobile/c_3po.iff");
}
else if (strAction.equals("jabbacomm"))
{
String stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
if (strData2.equals("") || strData2 == null)
{
strData2 = "sound/sys_comm_generic.snd";
}
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "object/mobile/jabba_the_hutt.iff");
}
else if (strAction.equals("hancomm"))
{
String stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
if (strData2.equals("") || strData2 == null)
{
strData2 = "sound/sys_comm_generic.snd";
}
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "object/mobile/npe/npe_han_solo.iff");
}
else if (strAction.equals("vadercomm"))
{
String stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
if (strData2.equals("") || strData2 == null)
{
strData2 = "sound/sys_comm_generic.snd";
}
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "object/mobile/darth_vader.iff");
}
else if (strAction.equals("wookieecomm"))
{
String stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
if (getSpecies(objTarget) == SPECIES_WOOKIEE)
{
strChat = new string_id(stf, strData1 + "_w");
}
if (strData2.equals("") || strData2 == null)
{
strData2 = "sound/sys_comm_generic.snd";
}
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "object/mobile/npe/npe_chewbacca.iff");
}
else if (strAction.equals("spacechatship"))
{
String stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
space_utils.tauntPilot(objTarget, objActor, strChat);
}
else if (strAction.equals("setanimationmood"))
{
setAnimationMood(objActor, strData1);
}
else if (strAction.equals("animation"))
{
doAnimationAction(objActor, strData1);
}
else if (strAction.equals("destroy"))
{
destroyObject(objTarget);
}
else if (strAction.equals("popup"))
{
String stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
addNotification(objActor, utils.packStringId(strChat), false, 0, 0, 0, strData2);
}
else if (strAction.equals("messageto"))
{
if (strTarget.equals("self"))
{
objTarget = self;
}
messageTo(objTarget, strData1, null, 0, true);
}
else if (strAction.equals("uihighlight"))
{
}
else if (strAction.equals("setobjvar"))
{
setObjVar(objActor, strData1, strData2);
}
else if (strAction.equals("setscriptvar"))
{
utils.setScriptVar(objActor, strData1, strData2);
}
else if (strAction.equals("checkforitem"))
{
obj_id foundItem = utils.getItemPlayerHasByTemplate(objActor, strData1);
if (isIdValid(foundItem))
{
messageTo(self, strData2, null, 0, true);
}
}
else if (strAction.equals("say"))
{
String stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
chat.chat(objActor, strChat);
}
else if (strAction.equals("saysound"))
{
String stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
chat.chat(objActor, strChat);
play2dNonLoopingSound(objTarget, strData2);
}
else if (strAction.equals("stop"))
{
intIndex = intIndex + 1;
utils.setScriptVar(self, "intMainIndex", intIndex);
return sequencer.STOP_SEQUENCE;
}
else if (strAction.equals("secondtable"))
{
utils.setScriptVar(self, "intSecondIndex", 0);
utils.setScriptVar(self, "strSecondaryTable", strData1);
intIndex = intIndex + 1;
LOG("npe", "Setting main index to " + intIndex);
utils.setScriptVar(self, "intMainIndex", intIndex);
return sequencer.CHANGE_TABLE;
}
else if (strAction.equals("goto"))
{
intIndex = utils.stringToInt(strData1);
LOG("npe", "Going to " + intIndex);
return intIndex;
}
intIndex = intIndex + 1;
return intIndex;
}
public int continueMainTable(obj_id self, dictionary params) throws InterruptedException
{
LOG("npe", "CLEANUP OF SECONDARY TABLE!");
utils.removeScriptVar(self, "strSecondaryTable");
utils.removeScriptVar(self, "intSecondIndex");
utils.removeScriptVar(self, "intSecondaryTableStamp");
messageTo(self, "doEvents", null, 0, false);
return SCRIPT_CONTINUE;
}
}
@@ -1,616 +0,0 @@
include library.sequencer;
include library.chat;
include library.utils;
include library.space_utils;
include library.npe;
trigger OnAttach()
{
return SCRIPT_CONTINUE;
}
trigger OnPreloadComplete()
{
return SCRIPT_CONTINUE;
}
trigger OnDestroy()
{
return SCRIPT_CONTINUE;
}
messageHandler doEvents()
{
// check to see if we're in primary or loop mode. Primary uses the objvar, secondary uses the scriptvar
string strIndexScriptVar = "";
string strFileName = "";
// 2 modes for operation
// primary
// secondary
// delay setting
if(utils.hasScriptVar(self, "intSequenceStopped"))
{ // something external stopped us.
// we need to find the correct index to restart the system.
if(utils.hasScriptVar(self, "intSequenceContinue"))
{
utils.removeScriptVar(self, "intSequenceStopped");
utils.removeScriptVar(self, "intSequenceContinue"); // we stopped, but got a continue before the messageto arrived
}
else
{
debugSpeakMsg(self, "I have STOPPED!");
utils.removeScriptVar(self, "intSequenceStopped");
// next doEvents, we're good to go
return SCRIPT_CONTINUE;
}
}
// if a messageto comes in with a timestamp, and we don't have a timestamp, or the timestamp
// does not match, we toss it
if(params!=null)
{
int intMessageStamp = params.getInt("intSecondaryTableStamp");
int intMyStamp = utils.getIntScriptVar(self, "intSecondaryTableStamp");
if(intMessageStamp!=intMyStamp)
{
// IGNORE because it's legacy from the old secondayr looop
return SCRIPT_CONTINUE;
}
}
else if(utils.hasScriptVar(self, "intSecondaryTableStamp"))
{
// no stamp in messageto, but we have one, so KICK OUT
return SCRIPT_CONTINUE;
}
float fltDelay = runSequenceEvents(self);
if(fltDelay>-1)
{
if(fltDelay==0)
{
return SCRIPT_CONTINUE;
}
dictionary dctParams = null;
if(utils.hasScriptVar(self, "strSecondaryTable"))
{
dctParams = new dictionary();
int intTime = getGameTime();
utils.setScriptVar(self, "intSecondaryTableStamp", intTime);
dctParams.put("intSecondaryTableStamp", intTime);
}
messageTo(self, "doEvents", dctParams, fltDelay, false);
}
return SCRIPT_CONTINUE;
}
messageHandler interruptSequence()
{
utils.setScriptVar(self, "intSequenceStopped", 1);
stopSequence(self);
return SCRIPT_CONTINUE;
}
void stopSequence(obj_id self)
{
string strTable = "";
string strIndexScriptVar = "";
if(utils.hasScriptVar(self, "strSecondaryTable"))
{
// use alternate index and filename
strIndexScriptVar= "intSecondIndex";
strTable = utils.getStringScriptVar(self, "strSecondaryTable");
}
else
{
strIndexScriptVar= "intMainIndex";
strTable = getStringObjVar(self, "strSequenceTable");
}
string strFileName = "datatables/sequencer/event_sequence/"+strTable+".iff";
float[] fltTimes = dataTableGetFloatColumn(strFileName, "fltTime");
int intIndex = utils.getIntScriptVar(self, strIndexScriptVar);
// what's our "current" action.
if(intIndex>0)
{
intIndex = intIndex -1;
}
dictionary dctEventToRun = dataTableGetRow(strFileName, intIndex);
// is our index move?
string strAction =toLower( dctEventToRun.getString("strAction")); // what
if(strAction.equals("moveto"))
{
// we need to reset the index to this move so we can continue correctly.
utils.setScriptVar(self, strIndexScriptVar, intIndex);
}
}
float runSequenceEvents(obj_id self)
{
string strIndexScriptVar = "";
string strTable = "";
if(utils.hasScriptVar(self, "strSecondaryTable"))
{
// use alternate index and filename
strIndexScriptVar= "intSecondIndex";
strTable = utils.getStringScriptVar(self, "strSecondaryTable");
}
else
{
strIndexScriptVar= "intMainIndex";
strTable = getStringObjVar(self, "strSequenceTable");
}
string strFileName = "datatables/sequencer/event_sequence/"+strTable+".iff";
LOG("npe" ,"strFileName is "+strFileName);
// attempt to pass intIndex by reference, unsure if this will work. Powered by hope!
boolean noMoreEvents = false;
float[] fltTimes = dataTableGetFloatColumn(strFileName, "fltTime");
int intIndex = utils.getIntScriptVar(self, strIndexScriptVar);
float fltCurrentEventTime = fltTimes[intIndex];
while (!noMoreEvents)
{
dictionary dctEventToRun = dataTableGetRow(strFileName, intIndex);
// process event
intIndex = processEvents(dctEventToRun, intIndex);
// check for more events
if(intIndex == sequencer.CHANGE_TABLE)
{
if(utils.hasScriptVar(self, "strSecondaryTable"))
{
// reget times!
strFileName = "datatables/sequencer/event_sequence/"+utils.getStringScriptVar(self, "strSecondaryTable")+".iff";
fltTimes = dataTableGetFloatColumn(strFileName, "fltTime");
intIndex = 0;
strIndexScriptVar = "intSecondIndex";
}
// we reget fltTimes, and stuff.
}
else
{
if(intIndex ==sequencer.STOP_SEQUENCE)
{
return -1f;
}
}
float fltNextEvent = -1;
if(intIndex+1<fltTimes.length-1)
{
fltNextEvent = fltTimes[intIndex+1]; // so we don't go over
}
if(fltCurrentEventTime!=fltNextEvent)
{
noMoreEvents=true;
if(intIndex>fltTimes.length-1)
{
return -1f;
}
}
}
// intIndex is updated
LOG("npe", "updating "+strIndexScriptVar+" to "+intIndex);
utils.setScriptVar(getSelf(),strIndexScriptVar, intIndex);
float fltDelay = 0;
if(intIndex==0)
{
fltDelay = fltTimes[intIndex];
}
else
{
LOG("npe", "fltTimes[intIndex] is "+fltTimes[intIndex]);
LOG("npe", "fltTimes[intIndex-1] is "+fltTimes[intIndex-1]);
fltDelay = fltTimes[intIndex] - fltTimes[intIndex-1];
}
if(intIndex<fltTimes.length)
{
LOG("npe", "Returning "+fltDelay);
return fltDelay;
}
LOG("npe", "Returning "+fltDelay);
return -1f; // stop
}
// return value is whether to continue or wait for continue event. STOP_SEQUENCE or index
int processEvents(dictionary dctEventToRun, int intIndex)
{
// return value
// valid actins:
// attack
// moveto, arguments are run, walk
//runto
//posture (arguments are prone, stand, kneel
// say, arguments are tbd
// emote, arguments tbd
obj_id self = getSelf();
string strActor = dctEventToRun.getString("strActor"); // who
string strAction =toLower( dctEventToRun.getString("strAction")); // what
string strTarget = dctEventToRun.getString("strTarget"); // to who
string strData1 =toLower(dctEventToRun.getString("strData1")); // extra
string strData2 = toLower(dctEventToRun.getString("strData2"));// extra
int intTime = dctEventToRun.getInt("intTime");
// step 1. get objects.
obj_id objTarget = null;
obj_id objActor = null;
if(strActor!="")
{
objActor= sequencer.getSequenceObject(strActor);
}
if(strTarget!="")
{
objTarget = sequencer.getSequenceObject(strTarget);
}
LOG("han_solo_event", "Doing event line --- Actor is " + strActor + ", ID is " + objActor + " doing action " + strAction + " at target " + strTarget + ", ID " + objTarget);
if(strAction.equals("combatanimation"))
{
// data1 is the animation to use
// data2 is things like grenade templates
if(!isIdValid(objActor) || isDead(objActor) || isDead(objTarget))
{
//do nothing
}
else
{
if(isIdValid(objTarget) && isIdValid(objTarget))
{
if(exists(objTarget) && exists(objActor))
{
startCombat(objActor, objTarget);
setTarget(objActor, objTarget);
}
}
sequencer.doCombatAnimation(objActor, objTarget, strData1);
}
//debugSpeakMsg(objActor, "attacking "+objTarget);
}
if(strAction.equals("combatanimationmultiple"))
{
// data1 is the animation to use
// data2 is things like grenade templates
// objActor is multiple people, comma delimited. we'll cycle through this list til
// all of them are dead and hideously mutilated. HURRAH!
string[] strTargets = split(strTarget, ',');
obj_id[] objTargets = new obj_id[strTargets.length];
for (int i = 0; i < strTargets.length; i++)
{
objTargets[i] = sequencer.getSequenceObject(strTargets[i]);
}
for (int i = 0; i < objTargets.length; i++)
{
if (!isIdValid(objActor) || isDead(objActor) || isDead(objTargets[i]))
{
// do nothing!
}
else
{
if(isIdValid(objTargets[i]) && isIdValid(objTargets[i]))
{
if(exists(objTargets[i]) && exists(objActor))
{
startCombat(objActor, objTargets[i]);
setTarget(objActor, objTargets[i]);
sequencer.doCombatAnimation(objActor, objTargets[i], strData1);
break;
}
}
}
}
}
else if(strAction.equals("moveto"))
{
// fast or slow?!@?!@?
//debugSpeakMsg(objActor, "Moving to "+strTarget);//objTarget);
if(strData1=="run")
{
sequencer.runToSequenceObject(objActor, objTarget);
}
else if(strData1=="walk")
{
sequencer.walkToSequenceObject(objActor, objTarget);
}
}
else if(strAction.equals("faceto"))
{
faceTo(objActor, objTarget);
}
else if(strAction.equals("posture"))
{
// data 1 is the posture to go to
// valid postures are // stand, kneel and prone
//debugSpeakMsg(objActor, "setting posture to "+strData1);
if(strData1.equals("stand"))
{
setPosture(objActor, POSTURE_UPRIGHT);
sequencer.doCombatAnimation(objActor, objTarget, "posture_scramble");
}
else if(strData1.equals("kneel"))
{
setPosture(objActor, POSTURE_CROUCHED);
sequencer.doCombatAnimation(objActor, objTarget, "posture_scramble");
}
else if(strData1.equals("prone"))
{
setPosture(objActor, POSTURE_PRONE);
sequencer.doCombatAnimation(objActor, objTarget, "posture_scramble");
}
}
else if(strAction.equals("effect"))
{
//data 1 is the effect to play
//plays the clienteffect so that the actor can see it (player)
playClientEffectLoc(objActor, strData1, getLocation(objTarget), 0);
}
else if(strAction.equals("playmusic"))
{
//debugSpeakMsg(objActor, "Actor" + objActor + "is playing sound " + strData1);
play2dNonLoopingMusic(objActor, strData1);
}
else if(strAction.equals("spacechat"))
{
string stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
if (strData2.equals("") || strData2==null)
strData2="sound/sys_comm_generic.snd";
//space_utils.tauntPlayerWithSound(objTarget, objActor, strChat, strData2);
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "");
}
else if(strAction.equals("tutorialcomm"))
{
string stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
if (strData2.equals("") || strData2==null)
strData2="sound/sys_comm_generic.snd";
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "object/mobile/c_3po.iff");
}
else if(strAction.equals("jabbacomm"))
{
string stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
if (strData2.equals("") || strData2==null)
strData2="sound/sys_comm_generic.snd";
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "object/mobile/jabba_the_hutt.iff");
}
else if(strAction.equals("hancomm"))
{
string stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
if (strData2.equals("") || strData2==null)
strData2="sound/sys_comm_generic.snd";
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "object/mobile/npe/npe_han_solo.iff");
}
else if(strAction.equals("vadercomm"))
{
string stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
if (strData2.equals("") || strData2==null)
strData2="sound/sys_comm_generic.snd";
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "object/mobile/darth_vader.iff");
}
else if(strAction.equals("wookieecomm"))
{
string stf = getStringObjVar(self, "strSequenceTable");
// This function exists so that we can switch string_ids for the stupid wookiee players
// I hate those walking carpets with a fiery passion
// Just to let you know...
// in case you wanted to...
string_id strChat = new string_id (stf, strData1);
if (getSpecies(objTarget) == SPECIES_WOOKIEE)
{
strChat = new string_id(stf, strData1+"_w");
}
if (strData2.equals("") || strData2==null)
strData2="sound/sys_comm_generic.snd";
npe.commTutorialPlayer(objActor, objTarget, intTime, strChat, strData2, "object/mobile/npe/npe_chewbacca.iff");
}
else if(strAction.equals("spacechatship"))
{
string stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
space_utils.tauntPilot(objTarget, objActor, strChat);
}
else if(strAction.equals("setanimationmood"))
{
setAnimationMood(objActor, strData1);
}
else if(strAction.equals("animation"))
{
doAnimationAction(objActor, strData1);
}
else if(strAction.equals("destroy"))
{
//destroys the target object
destroyObject(objTarget);
}
else if(strAction.equals("popup"))
{
//actor is who the popup goes off on
//stf is the name of the STF file, which should be the name of the sequence table too...
//data 1 is stf entry
//data 2 is the sound that plays
string stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
addNotification(objActor, utils.packStringId(strChat), false, 0, 0, 0, strData2);
}
else if(strAction.equals("messageto"))
{
//sends an arbitrary messageTo to objTarget
//message handler name is strData1
if (strTarget.equals("self"))
objTarget = self;
//debugSpeakMsg(objActor, "Messaging " + objTarget + " with handler " + strData1);
messageTo(objTarget, strData1, null, 0, true);
}
else if(strAction.equals("uihighlight"))
{
//newbieTutorialHighlightUIElement (objActor, strData1, 10.0f);
}
else if(strAction.equals("setobjvar"))
{
//str data 1 is the objvar name
//str data 2 is a string objvar
setObjVar(objActor, strData1, strData2);
}
else if(strAction.equals("setscriptvar"))
{
utils.setScriptVar(objActor, strData1, strData2);
}
else if(strAction.equals("checkforitem"))
{
//objActor should only ever be player
//this checks for an item in players inv
//strData1 is the object template name
//strData2 is a messageHandler that is sent to self if the object is found
obj_id foundItem = utils.getItemPlayerHasByTemplate(objActor, strData1);
if (isIdValid(foundItem))
{
messageTo(self, strData2, null, 0, true);
}
}
else if(strAction.equals("say"))
{
// data 1 is the string to say
//debugSpeakMsg(objActor, "Saying "+strData1);
//stf is the string file name, which should be the same name as the sequence table
string stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
chat.chat(objActor, strChat);
}
else if (strAction.equals("saysound"))
{
string stf = getStringObjVar(self, "strSequenceTable");
string_id strChat = new string_id(stf, strData1);
chat.chat(objActor, strChat);
play2dNonLoopingSound(objTarget, strData2);
}
// tstring_id strChat = new string_id(stf, strData1);hese 2 are SPECIAL
//waitForMessage
//lochat.chat(objActor, strChat);opEvents
// reset
else if(strAction.equals("stop"))
{
// pause
intIndex = intIndex+1;
utils.setScriptVar(self, "intMainIndex", intIndex); // to make sure when we switch back we don't immediately go to secondary
return sequencer.STOP_SEQUENCE;
}
else if(strAction.equals("secondtable"))
{
// we switch to secondary table, reset secondary index, and stuff
utils.setScriptVar(self, "intSecondIndex", 0);
utils.setScriptVar(self, "strSecondaryTable", strData1);
intIndex = intIndex+1;
LOG("npe", "Setting main index to "+intIndex);
utils.setScriptVar(self, "intMainIndex", intIndex); // to make sure when we switch back we don't immediately go to secondary
return sequencer.CHANGE_TABLE;
}
else if(strAction.equals("goto"))
{
// reset index to the above value.
intIndex = utils.stringToInt(strData1);
LOG("npe", "Going to "+intIndex);
return intIndex;
}
intIndex = intIndex+1;
return intIndex;
}
messageHandler continueMainTable()
{
LOG("npe", "CLEANUP OF SECONDARY TABLE!");
utils.removeScriptVar(self, "strSecondaryTable");
utils.removeScriptVar(self, "intSecondIndex");
utils.removeScriptVar(self, "intSecondaryTableStamp");
messageTo(self, "doEvents", null, 0, false);
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,61 @@
package script.content_tools;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.sequencer;
public class sequencer_object extends script.base_script
{
public sequencer_object()
{
}
public int OnAttach(obj_id self) throws InterruptedException
{
if (hasObjVar(self, "strSequenceIdentifier"))
{
setName(self, "Sequencer Name: " + getStringObjVar(self, "strSequenceIdentifier"));
LOG("npe", "test2");
}
else
{
setName(self, "No Sequence Identifier set");
}
messageTo(self, "doPreloadRequest", null, 1, false);
return SCRIPT_CONTINUE;
}
public int OnInitialize(obj_id self) throws InterruptedException
{
if (hasObjVar(self, "strSequenceIdentifier"))
{
setName(self, "Sequencer Name: " + getStringObjVar(self, "strSequenceIdentifier"));
LOG("npe", "test2");
}
else
{
setName(self, "No Sequence Identifier set");
}
messageTo(self, "doPreloadRequest", null, 1, false);
return SCRIPT_CONTINUE;
}
public int doPreloadRequest(obj_id self, dictionary params) throws InterruptedException
{
requestPreloadCompleteTrigger(self);
return SCRIPT_CONTINUE;
}
public int OnPreloadComplete(obj_id self) throws InterruptedException
{
sequencer.registerSequenceObject(self);
return SCRIPT_CONTINUE;
}
public int OnDestroy(obj_id self) throws InterruptedException
{
sequencer.cleanUpSequenceObject(self);
return SCRIPT_CONTINUE;
}
}
@@ -1,54 +0,0 @@
include library.sequencer;
trigger OnAttach()
{
if(hasObjVar(self, "strSequenceIdentifier"))
{
setName(self, "Sequencer Name: "+getStringObjVar(self, "strSequenceIdentifier"));
LOG("npe", "test2");
}
else
{
setName(self, "No Sequence Identifier set");
}
messageTo(self, "doPreloadRequest",null, 1, false);
return SCRIPT_CONTINUE;
}
trigger OnInitialize()
{
if(hasObjVar(self, "strSequenceIdentifier"))
{
setName(self, "Sequencer Name: "+getStringObjVar(self, "strSequenceIdentifier"));
LOG("npe", "test2");
}
else
{
setName(self, "No Sequence Identifier set");
}
messageTo(self, "doPreloadRequest",null, 1, false);
return SCRIPT_CONTINUE;
}
messageHandler doPreloadRequest()
{
requestPreloadCompleteTrigger(self);
return SCRIPT_CONTINUE;
}
trigger OnPreloadComplete()
{
sequencer.registerSequenceObject(self);
return SCRIPT_CONTINUE;
}
trigger OnDestroy()
{
sequencer.cleanUpSequenceObject(self);
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,410 @@
package script.content_tools;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.utils;
import script.library.sui;
import script.library.trial;
import script.library.datatable;
public class spawn_generation_tool extends script.base_script
{
public spawn_generation_tool()
{
}
public static final String MASTER_SPAWN_OBJECT = "spawn.master_object";
public static final String ASSOCIATED_SPAWN_TABLE = "spawn.associated_table";
public static final String NOT_ASSIGNED = "Not Assigned";
public static final String TOOL_TITLE = "Spawn Creation Tool";
public static final String MASTER_SPAWN_SCRIPT = "systems.spawning.content_spawning_master";
public static final String LIST_MSO_SELECT = "list.mso_selection_array";
public static final boolean LOGGING = true;
public int showSpawnManagerSui(obj_id self, dictionary params) throws InterruptedException
{
createSpawnGenerationSui(self);
return SCRIPT_CONTINUE;
}
public int handleMasterListSelection(obj_id self, dictionary params) throws InterruptedException
{
if (sui.getIntButtonPressed(params) == sui.BP_CANCEL)
{
return SCRIPT_CONTINUE;
}
obj_id player = sui.getPlayerId(params);
int idx = sui.getListboxSelectedRow(params);
obj_id mso = getObjIdObjVar(player, MASTER_SPAWN_OBJECT);
String ast = getStringObjVar(player, ASSOCIATED_SPAWN_TABLE);
if (!isIdValid(mso) || ast.equals(NOT_ASSIGNED))
{
if (idx < 0 || idx > 1)
{
doLogging("handleMasterListSelection", "Unsigned mso/ast invalid selection occured");
return SCRIPT_CONTINUE;
}
switch (idx)
{
case 0:
setMasterSpawnObject(player);
break;
case 1:
loadExistingSpawnData(player);
break;
}
}
else
{
if (idx < 0 || idx > 2)
{
doLogging("handleMasterListSelection", "Signed mso/ast invalid selection occured");
return SCRIPT_CONTINUE;
}
switch (idx)
{
case 0:
showStandardSpawnCreationSUI(player);
break;
case 1:
showCleanSlateSpawnCreationSUI(player);
break;
case 2:
loadExistingSpawnData(player);
}
}
return SCRIPT_CONTINUE;
}
public int handleSpawnGenerationSuiUpdate(obj_id self, dictionary params) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int handleSetMso(obj_id self, dictionary params) throws InterruptedException
{
if ((params == null) || (params.isEmpty()))
{
doLogging("handleSetMso", "Params were null");
return SCRIPT_CONTINUE;
}
obj_id player = sui.getPlayerId(params);
obj_id[] objectList = utils.getObjIdArrayScriptVar(self, LIST_MSO_SELECT);
int bp = sui.getIntButtonPressed(params);
int idx = sui.getListboxSelectedRow(params);
switch (bp)
{
case sui.BP_OK:
if (idx > -1 && idx < objectList.length)
{
obj_id masterObject = objectList[idx];
if (isIdValid(masterObject))
{
attachScript(masterObject, MASTER_SPAWN_SCRIPT);
setObjVar(player, MASTER_SPAWN_OBJECT, masterObject);
for (int i = 0; i < objectList.length; i++)
{
if (objectList[i] != objectList[idx])
{
trial.cleanupNpc(objectList[i]);
}
}
}
}
else
{
doLogging("handleSetMso", "Idx was out of bounds");
return SCRIPT_CONTINUE;
}
break;
case sui.BP_CANCEL:
return SCRIPT_CONTINUE;
}
setAssociatedSpawnTable(player);
return SCRIPT_CONTINUE;
}
public int handleAstChoice(obj_id self, dictionary params) throws InterruptedException
{
if ((params == null) || (params.isEmpty()))
{
doLogging("handleAstChoice", "Params were null");
return SCRIPT_CONTINUE;
}
obj_id player = sui.getPlayerId(params);
int bp = sui.getIntButtonPressed(params);
int idx = sui.getListboxSelectedRow(params);
if (idx < 0)
{
doLogging("handleAstChoice", "Index was invalid");
}
switch (bp)
{
case sui.BP_OK:
if (idx == 0)
{
presentNewAstSUI(player);
}
else if (idx == 1)
{
presentExistingTableSui(player);
}
break;
case sui.BP_CANCEL:
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
public int handleNameNewTable(obj_id self, dictionary params) throws InterruptedException
{
if (params == null || params.isEmpty())
{
doLogging("handleNameNewTable", "Params were null");
return SCRIPT_CONTINUE;
}
obj_id player = sui.getPlayerId(params);
int bp = sui.getIntButtonPressed(params);
if (bp == sui.BP_CANCEL)
{
return SCRIPT_CONTINUE;
}
String tableName = sui.getInputBoxText(params);
if (tableName == null || tableName.equals(""))
{
sendSystemMessageTestingOnly(player, "You have entered a null or invalid name");
setAssociatedSpawnTable(player);
return SCRIPT_CONTINUE;
}
if (createNewAssociatedSpawnTable(player, tableName))
{
setObjVar(player, ASSOCIATED_SPAWN_TABLE, tableName);
}
else
{
sendSystemMessageTestingOnly(player, "Failed to create table with specified name");
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
public void createSpawnGenerationSui(obj_id player) throws InterruptedException
{
obj_id mso = null;
String ast = NOT_ASSIGNED;
if (hasObjVar(player, MASTER_SPAWN_OBJECT))
{
mso = getObjIdObjVar(player, MASTER_SPAWN_OBJECT);
}
if (hasObjVar(player, ASSOCIATED_SPAWN_TABLE))
{
ast = getStringObjVar(player, ASSOCIATED_SPAWN_TABLE);
}
else
{
setObjVar(player, ASSOCIATED_SPAWN_TABLE, NOT_ASSIGNED);
}
String prompt = getMsoAndAstDisplayData(player);
int pid = createSUIPage(sui.SUI_LISTBOX, player, player, "handleMasterListSelection");
setSUIProperty(pid, "", "Size", "900,700");
setSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT, TOOL_TITLE);
setSUIProperty(pid, sui.LISTBOX_PROMPT, sui.PROP_TEXT, prompt);
sui.listboxButtonSetup(pid, sui.OK_CANCEL);
setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, "@ok");
setSUIProperty(pid, sui.LISTBOX_BTN_CANCEL, sui.PROP_TEXT, "@cancel");
clearSUIDataSource(pid, sui.LISTBOX_DATASOURCE);
if (!isIdValid(mso) || ast.equals(NOT_ASSIGNED))
{
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 0);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 0, sui.PROP_TEXT, "Create New Spawn Data");
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 1);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 1, sui.PROP_TEXT, "Load Existing Spawn Data");
subscribeToSUIProperty(pid, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
subscribeToSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT);
showSUIPage(pid);
flushSUIPage(pid);
return;
}
else
{
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 0);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 0, sui.PROP_TEXT, "Use Existing Data");
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 1);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 1, sui.PROP_TEXT, "Create New Spawn Data");
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 2);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 2, sui.PROP_TEXT, "Load Existing Spawn Data");
subscribeToSUIProperty(pid, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
subscribeToSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT);
showSUIPage(pid);
flushSUIPage(pid);
return;
}
}
public void setMasterSpawnObject(obj_id player) throws InterruptedException
{
String prompt = getMsoAndAstDisplayData(player);
prompt += "Identify Master Spawning Object\nObjects with * have the master spawn script already present";
prompt += "\nSelect an object from the menu below, if the script is not attached it will be attached for you.";
prompt += "\nALL OTHER OBJECTS WILL BE DESTROYED TO PREVENT INADVERTANT CAPTURE IN THE SPAWNING TABLE";
int pid = createSUIPage(sui.SUI_LISTBOX, player, player, "handleSetMso");
setSUIProperty(pid, "", "Size", "900,700");
setSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT, TOOL_TITLE);
setSUIProperty(pid, sui.LISTBOX_PROMPT, sui.PROP_TEXT, prompt);
sui.listboxButtonSetup(pid, sui.OK_CANCEL);
setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, "@ok");
setSUIProperty(pid, sui.LISTBOX_BTN_CANCEL, sui.PROP_TEXT, "@cancel");
obj_id[] allObjects = sortAllObjectsByMasterSpawnScript(getObjectsInRange(player, 50.0f));
String[] sortedList = formatMsoSelectionSortedObjectList(allObjects);
clearSUIDataSource(pid, sui.LISTBOX_DATASOURCE);
if (sortedList == null || sortedList.length == 0)
{
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 0);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 0, sui.PROP_TEXT, "No Available Objects In Range");
}
else
{
for (int i = 0; i < sortedList.length; i++)
{
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + i);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + i, sui.PROP_TEXT, sortedList[i]);
}
}
subscribeToSUIEvent(pid, sui_event_type.SET_onGenericSelection, sui.LISTBOX_LIST, "createSpawnGenerationSui");
subscribeToSUIPropertyForEvent(pid, sui_event_type.SET_onGenericSelection, sui.LISTBOX_LIST, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
utils.setScriptVar(player, LIST_MSO_SELECT, allObjects);
subscribeToSUIProperty(pid, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
subscribeToSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT);
showSUIPage(pid);
flushSUIPage(pid);
}
public void setAssociatedSpawnTable(obj_id player) throws InterruptedException
{
String prompt = getMsoAndAstDisplayData(player);
prompt += "Load existing Table or Create new Table?";
prompt += "\nExisting table Master Spawn Object must match your Master Spawn Object.";
int pid = createSUIPage(sui.SUI_LISTBOX, player, player, "handleAstChoice");
setSUIProperty(pid, "", "Size", "900,700");
setSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT, TOOL_TITLE);
setSUIProperty(pid, sui.LISTBOX_PROMPT, sui.PROP_TEXT, prompt);
sui.listboxButtonSetup(pid, sui.OK_CANCEL);
setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, "@ok");
setSUIProperty(pid, sui.LISTBOX_BTN_CANCEL, sui.PROP_TEXT, "@cancel");
clearSUIDataSource(pid, sui.LISTBOX_DATASOURCE);
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 0);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 0, sui.PROP_TEXT, "Create New Associated Spawn Table");
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 1);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 1, sui.PROP_TEXT, "Load Exisisting Associated Spawn Table");
subscribeToSUIEvent(pid, sui_event_type.SET_onGenericSelection, sui.LISTBOX_LIST, "createSpawnGenerationSui");
subscribeToSUIPropertyForEvent(pid, sui_event_type.SET_onGenericSelection, sui.LISTBOX_LIST, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
subscribeToSUIProperty(pid, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
subscribeToSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT);
showSUIPage(pid);
flushSUIPage(pid);
}
public void loadExistingSpawnData(obj_id player) throws InterruptedException
{
}
public void showStandardSpawnCreationSUI(obj_id player) throws InterruptedException
{
}
public void showCleanSlateSpawnCreationSUI(obj_id player) throws InterruptedException
{
}
public void presentNewAstSUI(obj_id player) throws InterruptedException
{
String prompt = getMsoAndAstDisplayData(player);
prompt += "datatables/spawning/spawn_manager/associated_master_list.tab is required for this operation. Open now";
prompt += "\ndatatables/spawning/spawn_manager/...";
prompt += "\nName the new table";
int pid = createSUIPage(sui.SUI_INPUTBOX, player, player, "handleNameNewTable");
setSUIProperty(pid, "", "Size", "900,700");
setSUIProperty(pid, sui.INPUTBOX_TITLE, sui.PROP_TEXT, TOOL_TITLE);
setSUIProperty(pid, sui.INPUTBOX_PROMPT, sui.PROP_TEXT, prompt);
sui.inputboxButtonSetup(pid, sui.OK_CANCEL);
sui.inputboxStyleSetup(pid, sui.INPUT_NORMAL);
clearSUIDataSource(pid, sui.INPUTBOX_DATASOURCE);
subscribeToSUIProperty(pid, sui.INPUTBOX_PROMPT, sui.PROP_TEXT);
subscribeToSUIProperty(pid, sui.INPUTBOX_TITLE, sui.PROP_TEXT);
subscribeToSUIProperty(pid, sui.INPUTBOX_INPUT, sui.PROP_LOCALTEXT);
showSUIPage(pid);
flushSUIPage(pid);
}
public void presentExistingTableSui(obj_id player) throws InterruptedException
{
}
public boolean createNewAssociatedSpawnTable(obj_id player, String tableName) throws InterruptedException
{
return true;
}
public obj_id[] sortAllObjectsByMasterSpawnScript(obj_id[] allObjects) throws InterruptedException
{
Vector objectsWithScript = new Vector();
objectsWithScript.setSize(0);
Vector objectsWithoutScript = new Vector();
objectsWithoutScript.setSize(0);
for (int i = 0; i < allObjects.length; i++)
{
if (!isPlayer(allObjects[i]) && !isMob(allObjects[i]))
{
if (hasScript(allObjects[i], MASTER_SPAWN_SCRIPT))
{
utils.addElement(objectsWithScript, allObjects[i]);
}
else
{
utils.addElement(objectsWithoutScript, allObjects[i]);
}
}
}
obj_id[] completeList = new obj_id[objectsWithScript.size() + objectsWithoutScript.size()];
int r = 0;
for (int k = 0; k < objectsWithScript.size(); k++)
{
completeList[r] = ((obj_id)objectsWithScript.get(k));
r++;
}
for (int i = 0; i < objectsWithoutScript.size(); i++)
{
completeList[r] = ((obj_id)objectsWithoutScript.get(i));
r++;
}
return completeList;
}
public String[] formatMsoSelectionSortedObjectList(obj_id[] allObjects) throws InterruptedException
{
String[] sortedList = new String[allObjects.length];
for (int i = 0; i < allObjects.length; i++)
{
if (hasScript(allObjects[i], MASTER_SPAWN_SCRIPT))
{
sortedList[i] = "* " + getTemplateName(allObjects[i]) + " : " + allObjects[i];
}
else
{
sortedList[i] = getTemplateName(allObjects[i]) + " : " + allObjects[i];
}
}
return sortedList;
}
public String getMsoAndAstDisplayData(obj_id player) throws InterruptedException
{
obj_id mso = null;
String ast = NOT_ASSIGNED;
String template = "";
if (hasObjVar(player, MASTER_SPAWN_OBJECT))
{
mso = getObjIdObjVar(player, MASTER_SPAWN_OBJECT);
template = getTemplateName(mso);
}
if (hasObjVar(player, ASSOCIATED_SPAWN_TABLE))
{
ast = getStringObjVar(player, ASSOCIATED_SPAWN_TABLE);
}
return "Master Spawn Object: " + mso + " - " + template + "\n" + "Associated Spawn Table: " + ast + "\n\n";
}
public void doLogging(String section, String message) throws InterruptedException
{
if (LOGGING)
{
LOG("doLogging/spawn_generation_tool/" + section, message);
}
}
}
@@ -1,468 +0,0 @@
include library.utils;
include library.sui;
include library.trial;
include library.datatable;
const string MASTER_SPAWN_OBJECT = "spawn.master_object";
const string ASSOCIATED_SPAWN_TABLE = "spawn.associated_table";
const string NOT_ASSIGNED = "Not Assigned";
const string TOOL_TITLE = "Spawn Creation Tool";
const string MASTER_SPAWN_SCRIPT = "systems.spawning.content_spawning_master";
const string LIST_MSO_SELECT = "list.mso_selection_array";
const boolean LOGGING = true;
//-----------------------------------------------------------------------------------------
// Message Handlers
messageHandler showSpawnManagerSui()
{
createSpawnGenerationSui(self);
return SCRIPT_CONTINUE;
}
messageHandler handleMasterListSelection()
{
if (sui.getIntButtonPressed(params) == sui.BP_CANCEL)
{
return SCRIPT_CONTINUE;
}
obj_id player = sui.getPlayerId(params);
int idx = sui.getListboxSelectedRow(params);
obj_id mso = getObjIdObjVar(player, MASTER_SPAWN_OBJECT);
string ast = getStringObjVar(player, ASSOCIATED_SPAWN_TABLE);
if (!isIdValid(mso) || ast.equals(NOT_ASSIGNED))
{
if (idx < 0 || idx > 1)
{
doLogging("handleMasterListSelection", "Unsigned mso/ast invalid selection occured");
return SCRIPT_CONTINUE;
}
switch (idx)
{
case 0:
setMasterSpawnObject(player);
break;
case 1:
loadExistingSpawnData(player);
break;
}
}
else
{
if (idx < 0 || idx > 2)
{
doLogging("handleMasterListSelection", "Signed mso/ast invalid selection occured");
return SCRIPT_CONTINUE;
}
switch (idx)
{
case 0:
showStandardSpawnCreationSUI(player);
break;
case 1:
showCleanSlateSpawnCreationSUI(player);
break;
case 2:
loadExistingSpawnData(player);
}
}
return SCRIPT_CONTINUE;
}
messageHandler handleSpawnGenerationSuiUpdate()
{
return SCRIPT_CONTINUE;
}
messageHandler handleSetMso()
{
if ( (params == null) || (params.isEmpty()) )
{
doLogging("handleSetMso", "Params were null");
return SCRIPT_CONTINUE;
}
obj_id player = sui.getPlayerId(params);
obj_id[] objectList = utils.getObjIdArrayScriptVar(self, LIST_MSO_SELECT);
int bp = sui.getIntButtonPressed(params);
int idx = sui.getListboxSelectedRow(params);
switch (bp)
{
case sui.BP_OK:
if (idx > -1 && idx < objectList.length)
{
obj_id masterObject = objectList[idx];
if (isIdValid(masterObject))
{
attachScript(masterObject, MASTER_SPAWN_SCRIPT);
setObjVar(player, MASTER_SPAWN_OBJECT, masterObject);
for (int i=0;i<objectList.length;i++)
{
if (objectList[i] != objectList[idx])
trial.cleanupNpc(objectList[i]);
}
}
}
else
{
doLogging("handleSetMso", "Idx was out of bounds");
return SCRIPT_CONTINUE;
}
break;
case sui.BP_CANCEL:
return SCRIPT_CONTINUE;
}
setAssociatedSpawnTable(player);
return SCRIPT_CONTINUE;
}
messageHandler handleAstChoice()
{
if ( (params == null) || (params.isEmpty()) )
{
doLogging("handleAstChoice", "Params were null");
return SCRIPT_CONTINUE;
}
obj_id player = sui.getPlayerId(params);
int bp = sui.getIntButtonPressed(params);
int idx = sui.getListboxSelectedRow(params);
if (idx < 0)
{
doLogging("handleAstChoice", "Index was invalid");
}
switch (bp)
{
case sui.BP_OK:
if (idx == 0)
presentNewAstSUI(player);
else if (idx == 1)
presentExistingTableSui(player);
break;
case sui.BP_CANCEL:
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
messageHandler handleNameNewTable()
{
if (params == null || params.isEmpty())
{
doLogging("handleNameNewTable", "Params were null");
return SCRIPT_CONTINUE;
}
obj_id player = sui.getPlayerId(params);
int bp = sui.getIntButtonPressed(params);
if (bp == sui.BP_CANCEL)
return SCRIPT_CONTINUE;
string tableName= sui.getInputBoxText(params);
if (tableName == null || tableName.equals(""))
{
sendSystemMessageTestingOnly(player, "You have entered a null or invalid name");
setAssociatedSpawnTable(player);
return SCRIPT_CONTINUE;
}
if (createNewAssociatedSpawnTable(player, tableName))
setObjVar(player, ASSOCIATED_SPAWN_TABLE, tableName);
else
{
sendSystemMessageTestingOnly(player, "Failed to create table with specified name");
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
//----------------------------------------------------------------------------------------
// Standard Option Functions
void createSpawnGenerationSui(obj_id player)
{
obj_id mso = null;
string ast = NOT_ASSIGNED;
if (hasObjVar(player, MASTER_SPAWN_OBJECT))
mso = getObjIdObjVar(player, MASTER_SPAWN_OBJECT);
if (hasObjVar(player, ASSOCIATED_SPAWN_TABLE))
ast = getStringObjVar(player, ASSOCIATED_SPAWN_TABLE);
else
setObjVar(player, ASSOCIATED_SPAWN_TABLE, NOT_ASSIGNED);
string prompt = getMsoAndAstDisplayData(player);
int pid = createSUIPage(sui.SUI_LISTBOX, player, player, "handleMasterListSelection");
setSUIProperty(pid, "", "Size", "900,700");
setSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT, TOOL_TITLE);
setSUIProperty(pid, sui.LISTBOX_PROMPT, sui.PROP_TEXT, prompt);
// Add buttons.
sui.listboxButtonSetup(pid, sui.OK_CANCEL);
setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, "@ok");
setSUIProperty(pid, sui.LISTBOX_BTN_CANCEL, sui.PROP_TEXT, "@cancel");
//sui.listboxUseOtherButton(pid, "@known_abilities");
clearSUIDataSource(pid, sui.LISTBOX_DATASOURCE);
if (!isIdValid(mso) || ast.equals(NOT_ASSIGNED))
{
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 0);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 0, sui.PROP_TEXT, "Create New Spawn Data");
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 1);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 1, sui.PROP_TEXT, "Load Existing Spawn Data");
subscribeToSUIProperty(pid, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
subscribeToSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT);
showSUIPage(pid);
flushSUIPage(pid);
return;
}
else
{
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 0);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 0, sui.PROP_TEXT, "Use Existing Data");
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 1);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 1, sui.PROP_TEXT, "Create New Spawn Data");
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 2);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 2, sui.PROP_TEXT, "Load Existing Spawn Data");
subscribeToSUIProperty(pid, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
subscribeToSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT);
showSUIPage(pid);
flushSUIPage(pid);
return;
}
}
void setMasterSpawnObject(obj_id player)
{
string prompt = getMsoAndAstDisplayData(player);
prompt += "Identify Master Spawning Object\nObjects with * have the master spawn script already present";
prompt += "\nSelect an object from the menu below, if the script is not attached it will be attached for you.";
prompt += "\nALL OTHER OBJECTS WILL BE DESTROYED TO PREVENT INADVERTANT CAPTURE IN THE SPAWNING TABLE";
int pid = createSUIPage(sui.SUI_LISTBOX, player, player, "handleSetMso");
setSUIProperty(pid, "", "Size", "900,700");
setSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT, TOOL_TITLE);
setSUIProperty(pid, sui.LISTBOX_PROMPT, sui.PROP_TEXT, prompt);
// Add buttons.
sui.listboxButtonSetup(pid, sui.OK_CANCEL);
setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, "@ok");
setSUIProperty(pid, sui.LISTBOX_BTN_CANCEL, sui.PROP_TEXT, "@cancel");
//sui.listboxUseOtherButton(pid, "@known_abilities");
obj_id[] allObjects = sortAllObjectsByMasterSpawnScript(getObjectsInRange(player, 50.0f));
string[] sortedList = formatMsoSelectionSortedObjectList(allObjects);
clearSUIDataSource(pid, sui.LISTBOX_DATASOURCE);
if(sortedList == null || sortedList.length == 0)
{
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 0);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 0, sui.PROP_TEXT, "No Available Objects In Range");
}
else
{
for (int i=0;i<sortedList.length;i++)
{
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + i);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + i, sui.PROP_TEXT, sortedList[i]);
}
}
subscribeToSUIEvent(pid, sui_event_type.SET_onGenericSelection, sui.LISTBOX_LIST, "createSpawnGenerationSui");
subscribeToSUIPropertyForEvent(pid, sui_event_type.SET_onGenericSelection, sui.LISTBOX_LIST, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
utils.setScriptVar(player, LIST_MSO_SELECT, allObjects);
subscribeToSUIProperty(pid, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
subscribeToSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT);
showSUIPage(pid);
flushSUIPage(pid);
}
void setAssociatedSpawnTable(obj_id player)
{
string prompt = getMsoAndAstDisplayData(player);
prompt += "Load existing Table or Create new Table?";
prompt += "\nExisting table Master Spawn Object must match your Master Spawn Object.";
int pid = createSUIPage(sui.SUI_LISTBOX, player, player, "handleAstChoice");
setSUIProperty(pid, "", "Size", "900,700");
setSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT, TOOL_TITLE);
setSUIProperty(pid, sui.LISTBOX_PROMPT, sui.PROP_TEXT, prompt);
// Add buttons.
sui.listboxButtonSetup(pid, sui.OK_CANCEL);
setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, "@ok");
setSUIProperty(pid, sui.LISTBOX_BTN_CANCEL, sui.PROP_TEXT, "@cancel");
//sui.listboxUseOtherButton(pid, "@known_abilities");
clearSUIDataSource(pid, sui.LISTBOX_DATASOURCE);
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 0);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 0, sui.PROP_TEXT, "Create New Associated Spawn Table");
addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, "" + 1);
setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "." + 1, sui.PROP_TEXT, "Load Exisisting Associated Spawn Table");
subscribeToSUIEvent(pid, sui_event_type.SET_onGenericSelection, sui.LISTBOX_LIST, "createSpawnGenerationSui");
subscribeToSUIPropertyForEvent(pid, sui_event_type.SET_onGenericSelection, sui.LISTBOX_LIST, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
subscribeToSUIProperty(pid, sui.LISTBOX_LIST, sui.PROP_SELECTEDROW);
subscribeToSUIProperty(pid, sui.LISTBOX_TITLE, sui.PROP_TEXT);
showSUIPage(pid);
flushSUIPage(pid);
}
void loadExistingSpawnData(obj_id player){}
void showStandardSpawnCreationSUI(obj_id player){}
void showCleanSlateSpawnCreationSUI(obj_id player){}
void presentNewAstSUI(obj_id player)
{
string prompt = getMsoAndAstDisplayData(player);
prompt += "datatables/spawning/spawn_manager/associated_master_list.tab is required for this operation. Open now";
prompt += "\ndatatables/spawning/spawn_manager/...";
prompt += "\nName the new table";
int pid = createSUIPage(sui.SUI_INPUTBOX, player, player, "handleNameNewTable");
setSUIProperty(pid, "", "Size", "900,700");
setSUIProperty(pid, sui.INPUTBOX_TITLE, sui.PROP_TEXT, TOOL_TITLE);
setSUIProperty(pid, sui.INPUTBOX_PROMPT, sui.PROP_TEXT, prompt);
// Add buttons.
sui.inputboxButtonSetup(pid, sui.OK_CANCEL);
sui.inputboxStyleSetup(pid, sui.INPUT_NORMAL);
clearSUIDataSource(pid, sui.INPUTBOX_DATASOURCE);
subscribeToSUIProperty(pid, sui.INPUTBOX_PROMPT, sui.PROP_TEXT);
subscribeToSUIProperty(pid, sui.INPUTBOX_TITLE, sui.PROP_TEXT);
subscribeToSUIProperty(pid, sui.INPUTBOX_INPUT, sui.PROP_LOCALTEXT);
showSUIPage(pid);
flushSUIPage(pid);
}
void presentExistingTableSui(obj_id player){}
boolean createNewAssociatedSpawnTable(obj_id player, string tableName)
{
return true;
}
//-----------------------------------------------------------------------------------------
// Utilities
obj_id[] sortAllObjectsByMasterSpawnScript(obj_id[] allObjects)
{
resizeable obj_id[] objectsWithScript = new obj_id[0];
resizeable obj_id[] objectsWithoutScript = new obj_id[0];
for (int i=0;i<allObjects.length;i++)
{
if (!isPlayer(allObjects[i]) && !isMob(allObjects[i]))
{
if (hasScript(allObjects[i], MASTER_SPAWN_SCRIPT))
utils.addElement(objectsWithScript, allObjects[i]);
else
utils.addElement(objectsWithoutScript, allObjects[i]);
}
}
obj_id[] completeList = new obj_id[objectsWithScript.length + objectsWithoutScript.length];
int r=0;
for(int k=0;k<objectsWithScript.length;k++)
{
completeList[r] = objectsWithScript[k];
r++;
}
for(int i=0;i<objectsWithoutScript.length;i++)
{
completeList[r] = objectsWithoutScript[i];
r++;
}
return completeList;
}
string[] formatMsoSelectionSortedObjectList(obj_id[] allObjects)
{
string[] sortedList = new string[allObjects.length];
for (int i=0;i<allObjects.length;i++)
{
if (hasScript(allObjects[i], MASTER_SPAWN_SCRIPT))
sortedList[i] = "* "+getTemplateName(allObjects[i])+" : "+allObjects[i];
else
sortedList[i] = getTemplateName(allObjects[i])+" : "+allObjects[i];
}
return sortedList;
}
string getMsoAndAstDisplayData(obj_id player)
{
obj_id mso = null;
string ast = NOT_ASSIGNED;
string template = "";
if (hasObjVar(player, MASTER_SPAWN_OBJECT))
{
mso = getObjIdObjVar(player, MASTER_SPAWN_OBJECT);
template = getTemplateName(mso);
}
if (hasObjVar(player, ASSOCIATED_SPAWN_TABLE))
ast = getStringObjVar(player, ASSOCIATED_SPAWN_TABLE);
return "Master Spawn Object: "+mso+" - "+template+"\n"+"Associated Spawn Table: "+ast+"\n\n";
}
void doLogging(string section, string message)
{
if (LOGGING)
LOG("doLogging/spawn_generation_tool/"+section, message);
}
@@ -0,0 +1,54 @@
package script.content_tools;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.sequencer;
import script.library.chat;
import script.library.utils;
public class test_stop extends script.base_script
{
public test_stop()
{
}
public int OnAttach(obj_id self) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int OnPreloadComplete(obj_id self) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int OnDestroy(obj_id self) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int OnHearSpeech(obj_id self, obj_id objSpeaker, String strText) throws InterruptedException
{
if (strText.equals("stop"))
{
sequencer.stopSequence(self);
stop(self);
debugSpeakMsg(self, "Stopping");
}
if (strText.equals("go"))
{
if (utils.hasScriptVar(self, "intSequenceStopped"))
{
utils.setScriptVar(self, "intSequenceContinue", 1);
}
else
{
messageTo(self, "doEvents", null, 1, false);
}
debugSpeakMsg(self, "Going!");
}
return SCRIPT_CONTINUE;
}
}
@@ -1,50 +0,0 @@
include library.sequencer;
include library.chat;
include library.utils;
trigger OnAttach()
{
return SCRIPT_CONTINUE;
}
trigger OnPreloadComplete()
{
return SCRIPT_CONTINUE;
}
trigger OnDestroy()
{
return SCRIPT_CONTINUE;
}
trigger OnHearSpeech(obj_id objSpeaker, string strText)
{
if(strText.equals("stop"))
{
sequencer.stopSequence(self);
stop(self);
debugSpeakMsg(self, "Stopping");
}
if(strText.equals("go"))
{
if(utils.hasScriptVar(self, "intSequenceStopped"))
{
utils.setScriptVar(self, "intSequenceContinue", 1);
}
else
{
messageTo(self, "doEvents", null, 1, false);
}
debugSpeakMsg(self, "Going!");
}
return SCRIPT_CONTINUE;
}