mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
137 lines
4.1 KiB
Plaintext
137 lines
4.1 KiB
Plaintext
include library.group;
|
|
include library.space_utils;
|
|
include library.space_create;
|
|
include library.load_test;
|
|
include library.prose;
|
|
include library.ship_ai;
|
|
include library.space_combat;
|
|
include library.space_transition;
|
|
include library.utils;
|
|
include library.space_battlefield;
|
|
include java.lang.Math;
|
|
|
|
//constants
|
|
string RETAIN_TABLE = "datatables/space_content/battlefields/kessel_no_destroy.iff";
|
|
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
messageTo(self, "handlerInitialize", null, 2.0f, false);
|
|
return SCRIPT_CONTINUE;
|
|
|
|
}
|
|
trigger OnAttach()
|
|
{
|
|
//setObjVar(self, "intSpawnersDeactivated", 1);
|
|
setObjVar(self, "intPhase", 0);
|
|
obj_id objKesselObject = getPlanetByName("space_light1");
|
|
LOG("space", "setting scriptVar of "+self+" on "+objKesselObject);
|
|
utils.setScriptVar(objKesselObject,"objKesselManager", self);
|
|
messageTo(self, "handlerInitialize", null, 2.0f, false);
|
|
return SCRIPT_CONTINUE;
|
|
|
|
}
|
|
messageHandler changeSpawnerPhase()
|
|
{
|
|
// flip
|
|
LOG("space", "Changing phase");
|
|
int intPhase = getIntObjVar(self, "intPhase");
|
|
int intNewPhase = params.getInt("intCompletionId");
|
|
if(intPhase==intNewPhase)
|
|
{
|
|
LOG("space", "no change of kessel");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
setObjVar(self, "intPhase", intNewPhase);
|
|
//find all spawners in zone
|
|
obj_id[] objTestObjects = getAllObjectsWithTemplate(getLocation(self), 320000, "object/tangible/space/content_infrastructure/basic_spawner.iff");
|
|
//find all ships in zone
|
|
obj_id[] objShips = getObjectsInRange(getLocation(self), 320000);
|
|
//get list of all ships we dont want to destroy, because the are part of a quest
|
|
string[] noDeleteShipTypes = dataTableGetStringColumn(RETAIN_TABLE, "strShipType");
|
|
//gather list of all spawners that we dont to force a respawn on
|
|
string[] noReSpawnSpawnerNames = dataTableGetStringColumn(RETAIN_TABLE, "strSpawnerName");
|
|
|
|
//loop thru all spawners in zone
|
|
for(int intI = 0; intI< objTestObjects.length; intI++)
|
|
{
|
|
//bool to track whether this spawner is in list
|
|
boolean foundInList = false;
|
|
//string to determine what type of spawner we are
|
|
string spawnerType = getStringObjVar(objTestObjects[intI], "strSpawnerType");
|
|
//loop thru list of all spawners we dont want to respawn
|
|
for(int j = 0; j < noReSpawnSpawnerNames.length; ++j)
|
|
{
|
|
//verify that it is truly a spawner
|
|
if(hasObjVar(objTestObjects[intI], "strSpawnerName"))
|
|
{
|
|
//we dont want to respawn asteroids
|
|
if(spawnerType != "asteroid")
|
|
{
|
|
//verify it still exists
|
|
if(exists(objTestObjects[intI]))
|
|
{
|
|
//get the spawners name
|
|
string spawnerName = getStringObjVar(objTestObjects[intI],"strSpawnerName");
|
|
//verify whether the spawner is on the list
|
|
if(spawnerName.equals(noReSpawnSpawnerNames[j]))
|
|
{
|
|
//it is on the list, we dont want to respawn its mobs.
|
|
foundInList = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//if it is not on the list, force a respawn
|
|
if(foundInList == false && spawnerType != "asteroid")
|
|
messageTo(objTestObjects[intI], "startSpawning", null, intI, false);
|
|
}
|
|
|
|
//loop thru ships in zone
|
|
for(int k =0; k < objShips.length; ++k)
|
|
{
|
|
//bool for tracking whether the ship is on the list
|
|
boolean isNoDeleteShip = false;
|
|
//verify object is a ship
|
|
if(hasObjVar(objShips[k], "ship.shipName"))
|
|
{
|
|
//loop thru list of ships we want to keep
|
|
for(int l = 0; l < noDeleteShipTypes.length; ++l)
|
|
{
|
|
//check to see if the ship still exists
|
|
if(exists(objShips[k]))
|
|
{
|
|
//get the ships name
|
|
string shipName = getStringObjVar(objShips[k], "ship.shipName");
|
|
//check to see if the name is listed
|
|
if(shipName.equals(noDeleteShipTypes[l]))
|
|
{
|
|
//it is listed, so we dont want to delete
|
|
isNoDeleteShip = true;
|
|
}
|
|
}
|
|
}
|
|
//if the wasnt on the list, we need to delete it
|
|
if(isNoDeleteShip == false)
|
|
{
|
|
destroyObject(objShips[k]);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handlerInitialize()
|
|
{
|
|
//setObjVar(self, "intSpawnersDeactivated", 1);
|
|
obj_id objKesselObject = getPlanetByName("space_light1");
|
|
LOG("space", "setting scriptVar of "+self+" on "+objKesselObject);
|
|
utils.setScriptVar(objKesselObject,"objKesselManager", self);
|
|
setObjVar(self, "intPhase", 0);
|
|
return SCRIPT_CONTINUE;
|
|
} |