mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
169 lines
5.1 KiB
Plaintext
169 lines
5.1 KiB
Plaintext
include library.group;
|
|
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()
|
|
{
|
|
setObjVar(self, "strDefaultBehavior", "specialty");
|
|
// nothing
|
|
// we are the deestroyable
|
|
// strMyName
|
|
messageTo(self, "setupAttackTarget", null, 2, false);
|
|
setupPatrolPaths(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler setupAttackTarget()
|
|
{
|
|
string strTargetName = getStringObjVar(self, "strTargetName");
|
|
obj_id[] objTargets= getAllObjectsWithObjVar(getLocation(self), 320000, "strMyName");
|
|
if(objTargets!=null)
|
|
{
|
|
for(int intI = 0; intI< objTargets.length; intI++)
|
|
{
|
|
string strMyName = getStringObjVar(objTargets[intI], "strMyName");
|
|
if(strTargetName.equals(strMyName))
|
|
{
|
|
setObjVar(self, "objAttackTarget", objTargets[intI]);
|
|
intI = objTargets.length+1;
|
|
}
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
|
|
}
|
|
messageHandler singleAttackerSpawned()
|
|
{
|
|
obj_id objShip =params.getObjId("objShip");
|
|
//setObjVar(objShip, "objAttachTarget", getObjIdObjVar(self, "objAttackTarget"));
|
|
transform[] trPath = getRandomPathsFromSpawner(self);
|
|
|
|
transform trTest = trPath[trPath.length-1];
|
|
location locTest = utils.getLocationFromTransform(trTest);
|
|
//addLocationTarget3d(objShip, "spawnerArrival", locTest, 16);
|
|
ship_ai.spacePatrol(objShip, trPath);
|
|
return SCRIPT_CONTINUE;
|
|
|
|
|
|
}
|
|
messageHandler squadAttackerSpawned()
|
|
{
|
|
obj_id[] objMembers = params.getObjIdArray("objMembers");
|
|
//obj_id objAttackTarget = getObjIdObjVar(self, "objAttackTarget");
|
|
int intSquadId = ship_ai.unitGetSquadId(objMembers[0]);
|
|
|
|
//for(int intI = 0; intI< objMembers.length; intI++)
|
|
//{
|
|
//setObjVar(objMembers[intI], "objAttackTarget", objAttackTarget);
|
|
// ship_ai.unitAddDamageTaken(objMembers[intI], objAttackTarget, 1.0f);
|
|
//}
|
|
transform[] trPath = getRandomPathsFromSpawner(self);
|
|
|
|
|
|
|
|
//LOG("space", "SPACE_MOVETO!@!@!");
|
|
if((trPath==null)||(trPath.length==0))
|
|
{
|
|
//LOG("space", "NULL PATHS FOR "+self);
|
|
}
|
|
for(int intI = 0; intI < trPath.length; intI++)
|
|
{
|
|
location locFoo = space_utils.getLocationFromTransform(trPath[intI]);
|
|
//LOG("space", "point "+intI+" is "+ locFoo);
|
|
}
|
|
transform trTest = trPath[trPath.length-1];
|
|
location locTest = utils.getLocationFromTransform(trTest);
|
|
ship_ai.squadAddPatrolPath(intSquadId, trPath);
|
|
//addLocationTarget3d(objMembers[0], "leaderSpawnerArrival", locTest, 16);
|
|
return SCRIPT_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setupPatrolPaths(obj_id self)
|
|
{
|
|
//LOG("space", "SETTING UP PATROL PATHS FOR "+self);
|
|
if(hasObjVar(self, "strPaths"))
|
|
{
|
|
string[] strPaths = objvar_mangle.getMangledStringArrayObjVar(self, "strPaths");
|
|
|
|
int[] intPathCounts = getIntArrayObjVar(self, "intPathCounts");
|
|
for(int intM = 0; intM < strPaths.length; intM++)
|
|
{
|
|
int intPointCount = intPathCounts[intM];
|
|
|
|
resizeable transform[] trPatrolPoints = new transform[0];
|
|
obj_id[] objTestObjects = getAllObjectsWithTemplate(getLocation(self), 320000, "object/tangible/space/content_infrastructure/basic_patrol_point.iff");
|
|
//LOG("space", "length is "+objTestObjects.length);
|
|
if(objTestObjects==null)
|
|
{
|
|
//LOG("space", "HUGE PROBLEM WITH OBJECT "+self);
|
|
}
|
|
//LOG("space", "for "+strPaths[intM]+" count is "+intPointCount);
|
|
for(int intI =0; intI<intPointCount; intI++)
|
|
{
|
|
//LOG("space", "iterating, intI is "+intI+" name is "+strPaths[intM]);
|
|
for(int intJ = 0; intJ<objTestObjects.length; intJ++)
|
|
{
|
|
|
|
if(hasObjVar(objTestObjects[intJ], "strName"))
|
|
{
|
|
string strName = getStringObjVar(objTestObjects[intJ], "strName");
|
|
int intCheck = intI+1;
|
|
string strTest = "";
|
|
if(intCheck<10)
|
|
{
|
|
strTest =strPaths[intM]+"_0";
|
|
}
|
|
else
|
|
{
|
|
strTest =strPaths[intM]+"_";
|
|
}
|
|
strTest +=intCheck;
|
|
//LOG("space", "strTest is "+strTest);
|
|
if(strName.equals(strTest))
|
|
{
|
|
//LOG("space", "HasObjVar");
|
|
// that's our spawner
|
|
trPatrolPoints = utils.addElement(trPatrolPoints, getTransform_o2w(objTestObjects[intJ])); // add the transform so we can store these
|
|
|
|
// end the loop thingie
|
|
intJ = objTestObjects.length+10;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//LOG("space", "patrol points length is "+trPatrolPoints.length);
|
|
for(int intI = 0; intI < trPatrolPoints.length; intI++)
|
|
{
|
|
location locTest = space_utils.getLocationFromTransform(trPatrolPoints[intI]);
|
|
//LOG("space", "for Path "+strPaths[intM]+" entry "+intI+" location is "+locTest);
|
|
}
|
|
utils.setLocalVar(self, "trPath"+strPaths[intM], trPatrolPoints);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
transform[] getRandomPathsFromSpawner(obj_id objSpawner)
|
|
{
|
|
if(!hasObjVar(objSpawner, "strPaths"))
|
|
{
|
|
//LOG("space", "returning null from path check");
|
|
return null;
|
|
}
|
|
string[] strPaths = objvar_mangle.getMangledStringArrayObjVar(objSpawner, "strPaths");
|
|
int intRoll = rand(0, strPaths.length-1);
|
|
return utils.getTransformArrayLocalVar(objSpawner, "trPath"+strPaths[intRoll]);
|
|
} |