mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-04 04:15:52 -04:00
who isn't sick of converting the freaking scripts? this negates the need
This commit is contained in:
@@ -0,0 +1,189 @@
|
||||
package script.library;
|
||||
|
||||
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.poi;
|
||||
|
||||
public class uberlair extends script.base_script
|
||||
{
|
||||
public uberlair()
|
||||
{
|
||||
}
|
||||
public static void spawnBossMobiles(obj_id poiBaseObject, obj_id[] objLargeMobSpawners) throws InterruptedException
|
||||
{
|
||||
LOG("uber", "SPAWN BOSS MOBILES FUNCTION");
|
||||
String lairType = getStringObjVar(poiBaseObject, "spawning.lairType");
|
||||
String lairDatatable = "datatables/uberlair/" + lairType + ".iff";
|
||||
String[] strLargeMobs = dataTableGetStringColumnNoDefaults(lairDatatable, "strLargeMobs");
|
||||
String[] strLargeMobScript = dataTableGetStringColumnNoDefaults(lairDatatable, "strLargeMobScripts");
|
||||
LOG("uberlairs", "objLargeMobSpawners length is " + objLargeMobSpawners.length);
|
||||
for (int intI = 0; intI < objLargeMobSpawners.length; intI++)
|
||||
{
|
||||
if (strLargeMobs.length == 0)
|
||||
{
|
||||
LOG("DESIGNER_FATAL", lairType + " has large mob spawners but no large mobs!");
|
||||
break;
|
||||
}
|
||||
String strMobToSpawn = strLargeMobs[rand(0, strLargeMobs.length - 1)];
|
||||
location locSpawnLocation = getLocation(objLargeMobSpawners[intI]);
|
||||
obj_id objMob = poi.createObject(poiBaseObject, strMobToSpawn, locSpawnLocation);
|
||||
ai_lib.setDefaultCalmBehavior(objMob, ai_lib.BEHAVIOR_SENTINEL);
|
||||
if (strLargeMobScript.length > 0)
|
||||
{
|
||||
attachScript(objMob, strLargeMobScript[0]);
|
||||
setObjVar(objMob, "uberlair.strScript", strLargeMobScript[0]);
|
||||
}
|
||||
setObjVar(objMob, "uberlair.strType", strMobToSpawn);
|
||||
setObjVar(objMob, "uberlair.locSpawnLocation", locSpawnLocation);
|
||||
setObjVar(objMob, "uberlair.objParent", poiBaseObject);
|
||||
}
|
||||
return;
|
||||
}
|
||||
public static void spawnNpcLairMobiles(obj_id poiBaseObject, obj_id[] objMobSpawners) throws InterruptedException
|
||||
{
|
||||
final int SPAWNS_PER_EVENT = 3;
|
||||
String lairType = getStringObjVar(poiBaseObject, "spawning.lairType");
|
||||
LOG("uber", "SPAWN_NPC_LAIR_MOBILS");
|
||||
if (objMobSpawners == null)
|
||||
{
|
||||
LOG("DESIGNER_FATAL", "lair of " + lairType + " has no mob spawners in the theater it uses");
|
||||
return;
|
||||
}
|
||||
String lairDatatable = "datatables/uberlair/" + lairType + ".iff";
|
||||
String[] strMobs = dataTableGetStringColumnNoDefaults(lairDatatable, "strMobs");
|
||||
String[] strMobScript = dataTableGetStringColumnNoDefaults(lairDatatable, "strMobScripts");
|
||||
int intMaxSpawns[] = dataTableGetIntColumnNoDefaults(lairDatatable, "intMobCount");
|
||||
int intMobCount = intMaxSpawns[0];
|
||||
intMaxSpawns = dataTableGetIntColumnNoDefaults(lairDatatable, "intTotalMobs");
|
||||
int intTotalMobs = intMaxSpawns[0];
|
||||
setObjVar(poiBaseObject, "intTotalMobs", intTotalMobs);
|
||||
int intIndex = getIntObjVar(poiBaseObject, "intSpawnIndex");
|
||||
int intCounter = 0;
|
||||
for (int intI = intIndex; intI < intMobCount; intI++)
|
||||
{
|
||||
if (intCounter > SPAWNS_PER_EVENT)
|
||||
{
|
||||
setObjVar(poiBaseObject, "intSpawnIndex", intI);
|
||||
messageTo(poiBaseObject, "spawnMobiles", null, 3, false);
|
||||
return;
|
||||
}
|
||||
if (strMobs.length == 0)
|
||||
{
|
||||
LOG("DESIGNER_FATAL", lairType + " has large mob spawners but no large mobs!");
|
||||
break;
|
||||
}
|
||||
String strMobToSpawn = strMobs[rand(0, strMobs.length - 1)];
|
||||
location locSpawnLocation = getLocation(objMobSpawners[rand(0, objMobSpawners.length - 1)]);
|
||||
locSpawnLocation.x = locSpawnLocation.x + rand(-2, 2);
|
||||
locSpawnLocation.z = locSpawnLocation.z + rand(-2, 2);
|
||||
obj_id objMob = poi.createObject(poiBaseObject, strMobToSpawn, locSpawnLocation);
|
||||
ai_lib.setDefaultCalmBehavior(objMob, ai_lib.BEHAVIOR_SENTINEL);
|
||||
if (strMobScript.length > 0)
|
||||
{
|
||||
attachScript(objMob, strMobScript[0]);
|
||||
setObjVar(objMob, "uberlair.strScript", strMobScript[0]);
|
||||
}
|
||||
setObjVar(objMob, "uberlair.strType", strMobToSpawn);
|
||||
setObjVar(objMob, "uberlair.locSpawnLocation", locSpawnLocation);
|
||||
setObjVar(objMob, "uberlair.objParent", poiBaseObject);
|
||||
intCounter = intCounter + 1;
|
||||
}
|
||||
setObjVar(poiBaseObject, "intSpawnCount", intMobCount);
|
||||
removeObjVar(poiBaseObject, "intSpawnIndex");
|
||||
messageTo(poiBaseObject, "spawnFormations", null, 3, false);
|
||||
return;
|
||||
}
|
||||
public static void respawnMobile(obj_id poiBaseObject, location locSpawnLocation, String strMobToSpawn, String strScript) throws InterruptedException
|
||||
{
|
||||
int intTotalMobs = getIntObjVar(poiBaseObject, "intTotalMobs");
|
||||
int intCurrentSpawnCount = getIntObjVar(poiBaseObject, "intSpawnCount");
|
||||
intCurrentSpawnCount = intCurrentSpawnCount + 1;
|
||||
if (intCurrentSpawnCount > intTotalMobs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
obj_id objMob = poi.createObject(poiBaseObject, strMobToSpawn, locSpawnLocation);
|
||||
ai_lib.setDefaultCalmBehavior(objMob, ai_lib.BEHAVIOR_SENTINEL);
|
||||
if (strScript != null)
|
||||
{
|
||||
attachScript(objMob, strScript);
|
||||
}
|
||||
setObjVar(poiBaseObject, "intSpawnCount", intCurrentSpawnCount);
|
||||
return;
|
||||
}
|
||||
public static void createFormations(obj_id objParent) throws InterruptedException
|
||||
{
|
||||
LOG("uber", "SPAWN_formations FUNCTION");
|
||||
String lairType = getStringObjVar(objParent, "spawning.lairType");
|
||||
String lairDatatable = "datatables/uberlair/" + lairType + ".iff";
|
||||
LOG("uber", "lairDatatable is " + lairDatatable);
|
||||
String[] strFormations = dataTableGetStringColumnNoDefaults(lairDatatable, "strFormations");
|
||||
location[] locOffsets = getPatrolOffsets(getLocation(objParent), 50);
|
||||
for (int intI = 0; intI < strFormations.length; intI++)
|
||||
{
|
||||
String strFormationDataTable = "datatables/uberlair/formations/" + strFormations[intI] + ".iff";
|
||||
LOG("uber", "formation datatable is " + strFormationDataTable);
|
||||
String[] strMobs = dataTableGetStringColumnNoDefaults(strFormationDataTable, "strMobs");
|
||||
String[] strLeader = dataTableGetStringColumnNoDefaults(strFormationDataTable, "strLeader");
|
||||
if (strMobs.length == 0)
|
||||
{
|
||||
LOG("DESIGNER_FATAL", "mobs in a formation file of " + strFormationDataTable + " is blank");
|
||||
return;
|
||||
}
|
||||
if (strLeader.length == 0)
|
||||
{
|
||||
LOG("DESIGNER_FATAL", "leader in a formation file of " + strFormationDataTable + " is blank");
|
||||
return;
|
||||
}
|
||||
obj_id objLeader = poi.createObject(objParent, strLeader[0], locOffsets[intI]);
|
||||
LOG("uber", "created leader at " + locOffsets[intI]);
|
||||
if (objLeader != null)
|
||||
{
|
||||
attachScript(objLeader, "systems.npc_lair.uber_lair_formation_leader");
|
||||
dictionary dctParams = new dictionary();
|
||||
dctParams.put("locWaypoints", locOffsets);
|
||||
dctParams.put("strFormationMembers", strMobs);
|
||||
dctParams.put("intOffset", intI);
|
||||
LOG("uber", "messaging " + objLeader + " with createFormation command");
|
||||
setObjVar(objLeader, "objParent", objParent);
|
||||
messageTo(objLeader, "createFormation", dctParams, 3, false);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
public static location[] getPatrolOffsets(location locParentLocation, float fltDistance) throws InterruptedException
|
||||
{
|
||||
location[] locWaypoints = new location[4];
|
||||
locWaypoints[0] = new location(locParentLocation);
|
||||
locWaypoints[0].x = locWaypoints[0].x - fltDistance;
|
||||
locWaypoints[0].z = locWaypoints[0].z + fltDistance;
|
||||
LOG("uber", "distance is " + fltDistance);
|
||||
LOG("uber", "start is " + locParentLocation);
|
||||
LOG("uber", "waypoint 0 is " + locWaypoints[0]);
|
||||
locWaypoints[1] = new location(locParentLocation);
|
||||
locWaypoints[1].x = locWaypoints[1].x + fltDistance;
|
||||
locWaypoints[1].z = locWaypoints[1].z + fltDistance;
|
||||
LOG("uber", "distance is " + fltDistance);
|
||||
LOG("uber", "start is " + locParentLocation);
|
||||
LOG("uber", "waypoint 1 is " + locWaypoints[1]);
|
||||
locWaypoints[2] = new location(locParentLocation);
|
||||
locWaypoints[2].x = locWaypoints[2].x + fltDistance;
|
||||
locWaypoints[2].z = locWaypoints[2].z - fltDistance;
|
||||
LOG("uber", "distance is " + fltDistance);
|
||||
LOG("uber", "start is " + locParentLocation);
|
||||
LOG("uber", "waypoint 2 is " + locWaypoints[2]);
|
||||
locWaypoints[3] = new location(locParentLocation);
|
||||
locWaypoints[3].x = locWaypoints[3].x - fltDistance;
|
||||
locWaypoints[3].z = locWaypoints[3].z - fltDistance;
|
||||
LOG("uber", "distance is " + fltDistance);
|
||||
LOG("uber", "start is " + locParentLocation);
|
||||
LOG("uber", "waypoint 3 is " + locWaypoints[3]);
|
||||
return locWaypoints;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user