Files
dsrc/sku.0/sys.server/compiled/game/script/space/battlefields/battlefield_station.script
T

194 lines
5.8 KiB
Plaintext

include library.group;
include library.ship_ai;
include library.objvar_mangle;
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.space_battlefield;
include library.utils;
include java.lang.Math;
trigger OnAttach()
{
setShipFaction(self, "generic");
setObjVar(self, "intActivationPhase", 2);
setObjVar(self, "strMyName", "rebel_station");
setObjVar(self, "intDockable", 1);
setObjVar(self, "strTargetName", "star_destroyer");
string[] strPaths = {
"rebelTest1",
"rebelTest2",
"rebelTest3",
"rebelTest4",
"rebelTest5"
};
int[] intPathCounts = {
7,
7,
7,
7,
7
}; // how many path nodes in each
setObjVar(self, "strCapitalShipType","capital_ship_spacestation");
setObjVar(self, "strPaths", strPaths);
string strShipType = "spacestation_rebel";
string strPilot = "capital_ship_tier5";
int intXP = 10000;
setObjVar( self, "ship.shipName", strShipType );
setObjVar( self, "ship.pilotType", strPilot );
setObjVar( self, "xp.intXP", intXP );
string strFaction = "rebel";
setObjVar(self, "ship.space_faction", strFaction);
setShipFaction(self, strFaction);
int intMinCredits = 10000;
int intMaxCredits = 20000;
setObjVar( self, "loot.intCredits", rand(intMinCredits, intMaxCredits) );
int intRolls = 10;
float fltItemChance = .25f;
int intNumItems = rand(1, 5);
setObjVar( self, "loot.intNumItems", intNumItems );
setObjVar( self, "loot.strLootTable", "rebel_tier1" );
setObjVar(self, "intPathCounts", intPathCounts);
string strObjVars = "fltMaxSpawnDistance|2|1850.000000|fltMaxSpawnTime|2|600.000000|fltMinSpawnDistance|2|1000.000000|fltMinSpawnTime|2|180.000000|intSpawnCount|0|20|strDefaultBehavior|4|specialty|strPatrolPoints_mangled.count|0|7|strPatrolPoints_mangled.segment.0|5|rebel_invasion_1_1:rebel_invasion_1_2:rebel_invasion_1_3:rebel_invasion_1_4:rebel_invasion_1_5:rebel_invasion_1_6:rebel_invasion_1_7:|strSpawnerName|4|rebel_invasion_1|strSpawnerType|4|generic|strSpawns_mangled.count|0|5|strSpawns_mangled.segment.0|5|squad_rebel_station_1:squad_rebel_station_2:squad_rebel_station_3:squad_rebel_station_4:squad_rebel_station_5:|$|";
setPackedObjvars(self, strObjVars);
string_id strSpam = new string_id("space/space_mobile_type", "spacestation_rebel");
setName(self, strSpam);
LOG("space", "setting name to "+strSpam);
space_combat.setupCapitalShipFromTurretDefinition(self, "rebel_spacestation");
messageTo(self, "setupFaction", null, 1, false);
// nothing
// we are the deestroyable
return SCRIPT_CONTINUE;
}
messageHandler setupFaction()
{
int intFaction = ##"rebel";
int[] intAlliedFactions =
{
##"rebel"
};
int[] intEnemyFactions =
{
##"imperial"
};
LOG("space", "setting faction ");
shipSetSpaceFaction(self, intFaction);
shipSetSpaceFactionAllies(self, intAlliedFactions);
shipSetSpaceFactionEnemies(self, intEnemyFactions);
//shipSetSpaceFactionIsAggro(obj_id ship, boolean isAggro);
return SCRIPT_CONTINUE;
}
trigger OnDestroy()
{
// KABOOM!
LOG("space", "KABOOM SpACE STACEION");
obj_id objManager = space_battlefield.getManagerObject();
if(!hasObjVar(self, "intCleaningUp"))
{
if(!utils.hasScriptVar(objManager, "intResetting"))
{
utils.setScriptVar(objManager, "intResetting", 1);
space_battlefield.battlefieldCompleted(objManager, space_battlefield.STATE_IMPERIAL); // flip kessel to imperial
messageTo(objManager, "resetBattlefield", null, space_battlefield.RESET_TIME, false);
LOG("space", "I exploded");
CustomerServiceLog("battlefield", "Space Station destroyed in Battlefield Zone, flipping kessel to Imperial");
}
else
{
CustomerServiceLog("battlefield", "Space Station destroyed in Battlefield Zone, but no flip because the Empire already won");
}
}
detachScript(self, "space.battlefields.battlefield_spawner");
detachScript(self, "space.content_tools.spawner");
obj_id objEgg = createObject("object/tangible/space/content_infrastructure/generic_egg_small.iff", getTransform_o2p(self), null);
string strObjVars = getPackedObjvars(self);
string strScripts = utils.getPackedScripts(self);
string strTemplate = getTemplateName(self);
utils.setLocalVar(objEgg, "strObjVars", strObjVars);
utils.setLocalVar(objEgg, "strScripts", strScripts);
utils.setLocalVar(objEgg, "strTemplate", strTemplate);
setObjVar(objEgg, "intStationRespawner", 1);
setObjVar(objEgg, "intNoDump", 1);
LOG("space", "objEgg is "+objEgg);
return SCRIPT_CONTINUE;
}
messageHandler objectDocked()
{
LOG("space", "DOCKING");
obj_id objShip = params.getObjId("objShip");
obj_id objContentManager = space_battlefield.getManagerObject();
string strTemplate = getTemplateName(self);
int intIndex = strTemplate.indexOf("rebel");
string strObjVarName = "";
if(intIndex>-1)
{
// rebel
strObjVarName = "intRebelEscortsCompleted";
}
else
{
// imperial
strObjVarName = "intImperialEscortsCompleted";
}
LOG("space", "NAME IS "+strObjVarName);
LOG("space", "SHIP IS "+objShip);
int intCount = getIntObjVar(objContentManager, strObjVarName);
intCount = intCount+1;
setObjVar(objContentManager, strObjVarName, intCount);
messageTo(self, "undockAndLeave", params, 5, false);
return SCRIPT_CONTINUE;
}
messageHandler undockAndLeave()
{
obj_id objShip = params.getObjId("objShip");
ship_ai.unitUnDock(objShip);
transform trTest = space_utils.getRandomPositionInSphere(getTransform_o2p(self), 600, 900, false);
location locTest = space_utils.getLocationFromTransform(trTest);
addLocationTarget3d(objShip, "spawnerArrival", locTest, 16);
removeObjVar(objShip, "objDockingStation");
ship_ai.spaceMoveTo(objShip, trTest);
return SCRIPT_CONTINUE;
}