Files
dsrc/sku.0/sys.server/compiled/game/script/e3demo/spawner_nebulon.script
T

152 lines
4.2 KiB
Plaintext

include library.utils;
include library.ship_ai;
include library.space_utils;
include library.space_combat;
include library.space_create;
const string[] ATTACKER_LIST = {
"tiefighter",
"tiefighter",
"tiefighter",
"tiefighter",
"tiefighter",
"tiefighter",
"tiefighter",
"tieinterceptor",
"tieinterceptor",
"tieinterceptor",
"tiebomber",
"tiebomber",
"tiebomber",
"tiebomber"
};
const string[] DEFENDER_LIST = {
"xwing",
"xwing",
"xwing",
"xwing",
"ywing_average",
"ywing_average",
"ywing_average"
};
trigger OnAttach()
{
removeObjVar(self, "intNoDump");// hack to make ship save out properly
return SCRIPT_CONTINUE;
}
trigger OnShipWasHit (obj_id objAttacker, int intWeaponIndex, boolean isMissile, int missileType, int intTargetedComponent, boolean fromPlayerAutoTurret, float hitLocationX_o, float hitLocationY_o, float hitLocationZ_o)
{
return SCRIPT_CONTINUE;
}
messageHandler spawnNebulon()
{
transform trMyTransform= getTransform_o2w(self);
// we modify it
vector vctTest = new vector(100f, 100f, 100f); // OFFSET FOR 2ND NEBULON
transform trNewTransform = trMyTransform.move_l(vctTest); // play with these
obj_id objNewNebulon = space_create.createShip("corellian_corvette", trNewTransform, null);
// disable the engines
space_utils.setComponentDisabled(objNewNebulon, ship_chassis_slot_type.SCST_engine, true);
space_utils.setComponentDisabled(self, ship_chassis_slot_type.SCST_engine, true);
setObjVar(self, "objBuddy", objNewNebulon);
setObjVar(objNewNebulon, "intNebulon", 1);
setObjVar(objNewNebulon, "intNoDump", 1);
attachScript(objNewNebulon, "e3demo.nebulon_damaged");
dictionary dctParams = new dictionary();
space_utils.notifyObject(self, "startNebulonAttack", dctParams);
return SCRIPT_CONTINUE;
}
messageHandler startNebulonAttack()
{
// DEFENDERS
obj_id objFoo = null;
obj_id objFoo2 = null;
for(int intI = 0; intI<DEFENDER_LIST.length; intI++)
{
transform trNewTransform = space_utils.getRandomPositionInSphere(getTransform_o2w(self), 100, 150, true);
obj_id objShip = space_create.createShip(DEFENDER_LIST[intI], trNewTransform, null);
if(isIdValid(objShip))
{
objFoo = objShip;
setObjVar(objShip, "intNebulon", 1);
setObjVar(objShip, "strType", DEFENDER_LIST[intI]);
setObjVar(objShip, "trSpawnLocation", trNewTransform);
setObjVar(objShip, "intNoDump", 1);
setObjVar(objShip, "objNebulon", self);
attachScript(objShip, "e3demo.nebulon_child_object");
}
else
{
LOG("space", "BAD DEFENDER NEBULON E3 SHIP OF TYPE "+DEFENDER_LIST[intI]);
}
}
for(int intI = 0; intI<ATTACKER_LIST.length; intI++)
{
transform trNewTransform = space_utils.getRandomPositionInSphere(getTransform_o2w(self), 500, 600, true);
obj_id objShip = space_create.createShip(ATTACKER_LIST[intI], trNewTransform, null);
if(isIdValid(objShip))
{
objFoo2 = objShip;
setObjVar(objShip, "intNebulon", 1);
setObjVar(objShip, "intAttacker", 1);
setObjVar(objShip, "strType", ATTACKER_LIST[intI]);
setObjVar(objShip, "trSpawnLocation", trNewTransform);
setObjVar(objShip, "intNoDump", 1);
setObjVar(objShip, "objNebulon", self);
attachScript(objShip, "e3demo.nebulon_child_object");
obj_id objBuddy = getObjIdObjVar(self, "objBuddy");
ship_ai.spaceAttack(objShip, objBuddy); // MUST KILL NEBULON!
}
else
{
LOG("space", "BAD DEFENDER NEBULON E3 SHIP OF TYPE "+DEFENDER_LIST[intI]);
}
}
ship_ai.spaceAttack(objFoo, objFoo2); // MUST KILL NEBULON!
return SCRIPT_CONTINUE;
}
messageHandler shipDestroyed()
{
string strType = params.getString("strType");
transform trSpawnLocation = params.getTransform("trSpawnLocation");
int intAttacker = params.getInt("intAttacker");
obj_id objShip = space_create.createShip(strType, trSpawnLocation, null);
if(isIdValid(objShip))
{
setObjVar(objShip, "intNebulon", 1);
setObjVar(objShip, "intAttacker", intAttacker);
setObjVar(objShip, "strType", strType);
setObjVar(objShip, "trSpawnLocation", trSpawnLocation);
setObjVar(objShip, "intNoDump", 1);
attachScript(objShip, "e3demo.nebulon_child_object");
if(intAttacker==1)
{
ship_ai.spaceAttack(objShip, self); // MUST KILL NEBULON!
}
}
return SCRIPT_CONTINUE;
}