mirror of
https://github.com/RezecNoble/SWG-Evolution
synced 2026-01-17 01:04:32 -05:00
Delete Enable Turrets directory
Rearranging GitHub
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
These are the standalone server side files needed to re-enable turrets and mines for player bases.
|
||||
|
||||
Update: This has been updated to include the re-enabled exterior spawns for player bases.
|
||||
@@ -1,5 +0,0 @@
|
||||
small med large
|
||||
s s s
|
||||
"10,11" "0,-20" "-26,34"
|
||||
"-10,11" "-11,-1.5" "26,34"
|
||||
"13,-0.5"
|
||||
@@ -1,5 +0,0 @@
|
||||
small med large
|
||||
s s s
|
||||
"-15.5, -1.5" "0, 11.5"
|
||||
"15.5, -1.5" "0, -14"
|
||||
"0, 23.5"
|
||||
@@ -1,5 +0,0 @@
|
||||
small med large
|
||||
s s s
|
||||
"12,0" "0,18"
|
||||
"-12,0" "13,30"
|
||||
"-13,30"
|
||||
@@ -1,6 +0,0 @@
|
||||
small med large
|
||||
s s s
|
||||
"-20, 33" "0, 17.5"
|
||||
"20, 33" "0, 52"
|
||||
"-20, -10" "0, -20"
|
||||
"20, -10"
|
||||
@@ -1,4 +0,0 @@
|
||||
small med large
|
||||
s s s
|
||||
27,10 0,23 22,44
|
||||
-27,10 -22,44
|
||||
@@ -1,6 +0,0 @@
|
||||
small med large
|
||||
s s s
|
||||
"-9, 4" "0, 17.5"
|
||||
"9, 4" "-32, 7"
|
||||
"0, -12" "32, 7"
|
||||
"0, 40"
|
||||
@@ -1,4 +0,0 @@
|
||||
small med large
|
||||
s s s
|
||||
-12,6 0,22 13,34
|
||||
12,6 -13,34
|
||||
@@ -1,6 +0,0 @@
|
||||
small med large
|
||||
s s s
|
||||
"29, 11" "0, 20"
|
||||
"-29, 11" "0, 46"
|
||||
"-9, 5.5" "0, -25"
|
||||
"9, 5.5"
|
||||
@@ -1,5 +0,0 @@
|
||||
small med large
|
||||
s s s
|
||||
"35,25" "0,-41" "0,40"
|
||||
"-34,25" "40,70"
|
||||
"-40,70"
|
||||
@@ -1,7 +0,0 @@
|
||||
small med large
|
||||
s s s
|
||||
"-26, 50" "0, 35"
|
||||
"26, 50" "0, -37"
|
||||
"-26, -50" "50, 0"
|
||||
"26, -50" "-50, 0"
|
||||
"0, 70"
|
||||
@@ -1,472 +0,0 @@
|
||||
package script.faction_perk.hq;
|
||||
|
||||
import script.*;
|
||||
import script.library.*;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class defense_manager extends script.base_script
|
||||
{
|
||||
public defense_manager()
|
||||
{
|
||||
}
|
||||
private static final float RESOURCE_REPAIR_RATIO = 0.5f;
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!isInvulnerable(self))
|
||||
{
|
||||
setInvulnerable(self, true);
|
||||
}
|
||||
hq.prepareHqDefenses(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!isInvulnerable(self))
|
||||
{
|
||||
setInvulnerable(self, true);
|
||||
}
|
||||
messageTo(self, "handleDefenseValidation", null, 10.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
hq.cleanupHqDefenses(self);
|
||||
hq.cleanupHqSecurityTeam(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleCreateMinefield(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
hq.createMinefield(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnMaintenanceLoop(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "handleRepairDefenses", null, 10.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleRepairDefenses(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, hq.VAR_DEFENSE_BASE))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int ireserve = getIntObjVar(self, hq.VAR_HQ_RESOURCE_CNT);
|
||||
if (ireserve < 1)
|
||||
{
|
||||
messageTo(self, "handleDefenseValidation", null, 10.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
float reserve = ireserve;
|
||||
obj_var_list ovl = getObjVarList(self, hq.VAR_DEFENSE_BASE);
|
||||
if (ovl == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int numType = ovl.getNumItems();
|
||||
obj_var ov;
|
||||
obj_id[] defenses;
|
||||
for (int i = 0; i < numType; i++)
|
||||
{
|
||||
if (reserve < 1.0f)
|
||||
{
|
||||
break;
|
||||
}
|
||||
ov = ovl.getObjVar(i);
|
||||
defenses = ov.getObjIdArrayData();
|
||||
if (defenses != null && defenses.length > 0)
|
||||
{
|
||||
for (obj_id defense : defenses) {
|
||||
int curres = getIntObjVar(self, hq.VAR_HQ_RESOURCE_CNT);
|
||||
if (isIdValid(defense)) {
|
||||
int hp = getHitpoints(defense);
|
||||
int max = getMaxHitpoints(defense);
|
||||
if (hp < 1) {
|
||||
destroyObject(defense);
|
||||
} else if (hp < max) {
|
||||
int diff = max - hp;
|
||||
float cost = diff * RESOURCE_REPAIR_RATIO;
|
||||
if (cost > curres) {
|
||||
diff = (int) (curres / RESOURCE_REPAIR_RATIO);
|
||||
cost = curres;
|
||||
}
|
||||
curres -= cost;
|
||||
setHitpoints(defense, hp + diff);
|
||||
int used = (int) cost;
|
||||
int total = curres - used;
|
||||
if (total < 0) {
|
||||
removeObjVar(self, hq.VAR_HQ_RESOURCE_CNT);
|
||||
break;
|
||||
}
|
||||
setObjVar(self, hq.VAR_HQ_RESOURCE_CNT, total);
|
||||
if (curres < 1.0f) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
messageTo(self, "handleDefenseValidation", null, 10.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleAddDefense(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (params == null || params.isEmpty())
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String defenseType = params.getString("type");
|
||||
if (defenseType == null || defenseType.equals(""))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else if (defenseType.equals("mine"))
|
||||
{
|
||||
int mineType = params.getInt("mineType");
|
||||
addMine(self, mineType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String template = params.getString("template");
|
||||
if (template == null || template.equals(""))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else if (!hasObjVar(self, hq.VAR_DEFENSE_BASE))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id[] data = getObjIdArrayObjVar(self, hq.VAR_DEFENSE_BASE + "." + defenseType);
|
||||
if (data == null || data.length == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int pos = utils.getFirstNonValidIdIndex(data);
|
||||
if (pos < 0 || pos > data.length - 1)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else if (isIdValid(data[pos]))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String tbl = hq.TBL_DEFENSE_PATH + utils.getTemplateFilenameNoPath(self);
|
||||
String locData = dataTableGetString(tbl, pos, toUpper(defenseType));
|
||||
if (locData == null || locData.equals(""))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String[] locSplit = split(locData, ',');
|
||||
if (locSplit == null || locSplit.length == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
float dx = utils.stringToFloat(locSplit[0]);
|
||||
if (dx == Float.NEGATIVE_INFINITY)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
float dy = utils.stringToFloat(locSplit[1]);
|
||||
if (dy == Float.NEGATIVE_INFINITY)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
float dz = utils.stringToFloat(locSplit[2]);
|
||||
if (dz == Float.NEGATIVE_INFINITY)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
float dyaw = utils.stringToFloat(locSplit[3]);
|
||||
if (dyaw == Float.NEGATIVE_INFINITY)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
location here = getLocation(self);
|
||||
float yaw = getYaw(self);
|
||||
location there = player_structure.transformDeltaWorldCoord(here, dx, dz, getYaw(self));
|
||||
there.y = here.y;
|
||||
int myFac = pvpGetAlignedFaction(self);
|
||||
String myFacName = factions.getFaction(self);
|
||||
obj_id defense;
|
||||
//fixed some issues that was causing the wrong sized turrets to be spawned.
|
||||
if (defenseType.equals("turret"))
|
||||
{
|
||||
int turretType = advanced_turret.TYPE_BLOCK;
|
||||
int turretSize = advanced_turret.SIZE_SMALL;
|
||||
int turretMinDam = 3500;
|
||||
int turretMaxDam = 4500;
|
||||
int turretHitpoints = 200000;
|
||||
float turretRange = 64.0f;
|
||||
float turretSpeed = 2.0f;
|
||||
if (template.contains("tower"))
|
||||
{
|
||||
turretType = advanced_turret.TYPE_TOWER;
|
||||
turretMinDam = 5000;
|
||||
turretMaxDam = 7000;
|
||||
turretSpeed = 3.0f;
|
||||
if (template.contains("lg"))
|
||||
{
|
||||
turretSize = advanced_turret.SIZE_LARGE;
|
||||
turretHitpoints = 600000;
|
||||
turretRange = 96.0f;
|
||||
}
|
||||
else if (template.contains("med"))
|
||||
{
|
||||
turretSize = advanced_turret.SIZE_MEDIUM;
|
||||
turretHitpoints = 400000;
|
||||
turretRange = 80.0f;
|
||||
}
|
||||
}
|
||||
else if (template.contains("dish"))
|
||||
{
|
||||
turretType = advanced_turret.TYPE_DISH;
|
||||
turretMinDam = 1750;
|
||||
turretMaxDam = 2250;
|
||||
turretSpeed = 1.0f;
|
||||
if (template.contains("lg"))
|
||||
{
|
||||
turretSize = advanced_turret.SIZE_LARGE;
|
||||
turretHitpoints = 600000;
|
||||
turretRange = 96.0f;
|
||||
}
|
||||
else if (template.contains("med"))
|
||||
{
|
||||
turretSize = advanced_turret.SIZE_MEDIUM;
|
||||
turretHitpoints = 400000;
|
||||
turretRange = 80.0f;
|
||||
}
|
||||
}
|
||||
else if (template.contains("lg"))
|
||||
{
|
||||
turretSize = advanced_turret.SIZE_LARGE;
|
||||
turretHitpoints = 600000;
|
||||
turretRange = 96.0f;
|
||||
}
|
||||
else if (template.contains("med"))
|
||||
{
|
||||
turretSize = advanced_turret.SIZE_MEDIUM;
|
||||
turretHitpoints = 400000;
|
||||
turretRange = 80.0f;
|
||||
}
|
||||
defense = advanced_turret.createTurret(there, (yaw + dyaw), turretType, turretSize, DAMAGE_ENERGY, turretMinDam, turretMaxDam, turretHitpoints, turretRange, turretSpeed, myFacName);
|
||||
}
|
||||
else
|
||||
{
|
||||
defense = createObject(template, there);
|
||||
if (isIdValid(defense))
|
||||
{
|
||||
setYaw(defense, yaw + dyaw);
|
||||
pvpSetAlignedFaction(defense, myFac);
|
||||
pvpMakeDeclared(defense);
|
||||
if (myFacName != null && myFacName.equals(""))
|
||||
{
|
||||
factions.setFaction(defense, myFacName);
|
||||
}
|
||||
String temp = getTemplateName(defense);
|
||||
int index = player_structure.getStructureTableIndex(temp);
|
||||
if (index != -1)
|
||||
{
|
||||
int condition = dataTableGetInt(player_structure.PLAYER_STRUCTURE_DATATABLE, index, player_structure.DATATABLE_COL_CONDITION);
|
||||
if (condition > 0)
|
||||
{
|
||||
setMaxHitpoints(defense, condition);
|
||||
setInvulnerableHitpoints(defense, condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isIdValid(defense))
|
||||
{
|
||||
persistObject(defense);
|
||||
attachScript(defense, hq.SCRIPT_DEFENSE_OBJECT);
|
||||
setObjVar(defense, hq.VAR_DEFENSE_PARENT, self);
|
||||
setOwner(defense, self);
|
||||
data[pos] = defense;
|
||||
setObjVar(self, hq.VAR_DEFENSE_BASE + "." + defenseType, data);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleRemoveDefense(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (params == null || params.isEmpty())
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id sender = params.getObjId("sender");
|
||||
if (!isIdValid(sender))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else if (!hasObjVar(self, hq.VAR_DEFENSE_BASE))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_var_list ovl = getObjVarList(self, hq.VAR_DEFENSE_BASE);
|
||||
if (ovl == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int numTypes = ovl.getNumItems();
|
||||
obj_var ov;
|
||||
obj_id[] data;
|
||||
for (int i = 0; i < numTypes; i++)
|
||||
{
|
||||
ov = ovl.getObjVar(i);
|
||||
data = ov.getObjIdArrayData();
|
||||
int idx = utils.getElementPositionInArray(data, sender);
|
||||
if (idx > -1)
|
||||
{
|
||||
data[idx] = obj_id.NULL_ID;
|
||||
setObjVar(self, hq.VAR_DEFENSE_BASE + "." + ov.getName(), data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
messageTo(self, "terminalOff", null, 1, false);
|
||||
obj_id[] numTur = getObjIdArrayObjVar(self, "hq.defense.turret");
|
||||
if (numTur == null || numTur.length == 0)
|
||||
{
|
||||
detachScript(self, "faction_perk.hq.base_block");
|
||||
}
|
||||
int pos = utils.getFirstValidIdIndex(numTur);
|
||||
if (pos < 0 || (numTur != null && pos > numTur.length - 1))
|
||||
{
|
||||
detachScript(self, "faction_perk.hq.base_block");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleDefenseValidation(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
hq.validateDefenseTracking(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleMinefieldValidation(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(self, "mines"))
|
||||
{
|
||||
int[] mines = getIntArrayObjVar(self, "mines");
|
||||
if (mines.length >= hq.MAX_MINE_TYPES)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int[] new_mines = new int[hq.MAX_MINE_TYPES];
|
||||
// this may bomb... depends on how big "mines" ends up being... if mines.length is bigger than hq.MAX_MINE_TYPES
|
||||
// then it will bomb. Correct the issue by making arraycopy only go to hq.MAX_MINE_TYPES instead of mines.length
|
||||
System.arraycopy(mines, 0, new_mines, 0, mines.length);
|
||||
setObjVar(self, "mines", new_mines);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (hasObjVar(self, hq.VAR_DEFENSE_BASE + ".minefield"))
|
||||
{
|
||||
obj_id[] old_minefields = getObjIdArrayObjVar(self, hq.VAR_DEFENSE_BASE + ".minefield");
|
||||
for (obj_id old_minefield : old_minefields) {
|
||||
if (isIdValid(old_minefield)) {
|
||||
destroyObject(old_minefield);
|
||||
}
|
||||
}
|
||||
}
|
||||
messageTo(self, "handleCreateMinefield", null, 5.0f, false);
|
||||
setObjVar(self, "mines", new int[hq.MAX_MINE_TYPES]);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleTurretControl(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id turret = params.getObjId("defense");
|
||||
if (!isIdValid(turret))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_var_list ovl = getObjVarList(self, hq.VAR_DEFENSE_BASE);
|
||||
if (ovl == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int numTypes = ovl.getNumItems();
|
||||
obj_id[] data;
|
||||
for (int i = 0; i < numTypes; i++)
|
||||
{
|
||||
data = ovl.getObjVar(i).getObjIdArrayData();
|
||||
int pos = utils.getElementPositionInArray(data, turret);
|
||||
if (pos > -1 && pos < 4)
|
||||
{
|
||||
setObjVar(self, "turret" + (pos + 1), turret);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleResetTurretControl(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id turret = params.getObjId("sender");
|
||||
if (!isIdValid(turret))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!exists(turret))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_var_list ovl = getObjVarList(self, hq.VAR_DEFENSE_BASE);
|
||||
if (ovl == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int numTypes = ovl.getNumItems();
|
||||
obj_id[] data;
|
||||
for (int i = 0; i < numTypes; i++)
|
||||
{
|
||||
data = ovl.getObjVar(i).getObjIdArrayData();
|
||||
int pos = utils.getElementPositionInArray(data, turret);
|
||||
if (pos > -1 && pos < 4)
|
||||
{
|
||||
setObjVar(self, "turret" + (pos + 1), turret);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleSpawnSecurityRover(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
String guardType = params.getString("guard");
|
||||
location start = params.getLocation("start");
|
||||
obj_id guard = create.object(guardType, start);
|
||||
if (isIdValid(guard))
|
||||
{
|
||||
ai_lib.setPatrolPath(guard, params.getLocationArray("locs"));
|
||||
if (utils.hasScriptVar(self, "hq.spawn.security"))
|
||||
{
|
||||
Vector securityTeam = utils.getResizeableObjIdArrayScriptVar(self, "hq.spawn.security");
|
||||
securityTeam = utils.addElement(securityTeam, guard);
|
||||
utils.setScriptVar(self, "hq.spawn.security", securityTeam);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector securityTeam = new Vector();
|
||||
securityTeam.setSize(0);
|
||||
securityTeam = utils.addElement(securityTeam, guard);
|
||||
utils.setScriptVar(self, "hq.spawn.security", securityTeam);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
private boolean addMine(obj_id self, int mineType) throws InterruptedException
|
||||
{
|
||||
if (mineType == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int[] mines = new int[hq.MAX_MINE_TYPES];
|
||||
if (hasObjVar(self, "mines"))
|
||||
{
|
||||
mines = getIntArrayObjVar(self, "mines");
|
||||
}
|
||||
if (mineType >= mines.length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
mines[mineType]++;
|
||||
if (mines[mineType] <= 0)
|
||||
{
|
||||
mines[mineType] = 1;
|
||||
}
|
||||
setObjVar(self, "mines", mines);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,367 +0,0 @@
|
||||
package script.faction_perk.hq;
|
||||
|
||||
import script.dictionary;
|
||||
import script.library.*;
|
||||
import script.location;
|
||||
import script.obj_id;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class spawn_egg extends script.base_script
|
||||
{
|
||||
public spawn_egg()
|
||||
{
|
||||
}
|
||||
private static final String VAR_SPAWN_PATHPOINTS = hq.VAR_SPAWN_BASE + ".pathPoints";
|
||||
private static final String VAR_SPAWN_FORMATION = hq.VAR_SPAWN_BASE + ".formation";
|
||||
private static final String VAR_CLEANING_UP = hq.VAR_SPAWN_BASE + ".cleaningUp";
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
createPatrolPathPoints(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
setObjVar(self, VAR_CLEANING_UP, 1);
|
||||
obj_id[] children = getObjIdArrayObjVar(self, hq.VAR_SPAWN_CHILDREN);
|
||||
if (children == null || children.length == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
utils.destroyObjects(children);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleSpawnRequest(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(self, hq.VAR_SPAWN_CHILDREN))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id[] children = loadSpawns(self);
|
||||
if (children != null && children.length > 0)
|
||||
{
|
||||
setObjVar(self, hq.VAR_SPAWN_CHILDREN, children);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleLeaderIncapacitated(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(self, VAR_CLEANING_UP))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
Vector children = getResizeableObjIdArrayObjVar(self, hq.VAR_SPAWN_CHILDREN);
|
||||
if (children == null || children.size() == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id oid = params.getObjId("oid");
|
||||
if (!isIdValid(oid))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
children = utils.removeElement(children, oid);
|
||||
if (children != null && children.size() > 0)
|
||||
{
|
||||
int pos = 0;
|
||||
obj_id leader = null;
|
||||
int formation = getIntObjVar(self, VAR_SPAWN_FORMATION);
|
||||
location[] pathpoints = null;
|
||||
if (hasObjVar(self, VAR_SPAWN_PATHPOINTS)) {
|
||||
pathpoints = getLocationArrayObjVar(self, VAR_SPAWN_PATHPOINTS);
|
||||
}
|
||||
boolean hasPathPoints = (pathpoints != null && pathpoints.length > 0);
|
||||
for (Object child : children) {
|
||||
if (!ai_lib.aiIsDead(((obj_id) child))) {
|
||||
if (!isIdValid(leader)) {
|
||||
leader = ((obj_id) child);
|
||||
setObjVar(leader, hq.VAR_SPAWN_LEADER, true);
|
||||
if (hasPathPoints) {
|
||||
ai_lib.setPatrolPath(leader, pathpoints);
|
||||
} else {
|
||||
ai_lib.setDefaultCalmBehavior(leader, ai_lib.BEHAVIOR_LOITER);
|
||||
}
|
||||
} else {
|
||||
ai_lib.followInFormation(((obj_id) child), leader, formation, pos);
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleChildDestroyed(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(self, VAR_CLEANING_UP))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
Vector children = getResizeableObjIdArrayObjVar(self, hq.VAR_SPAWN_CHILDREN);
|
||||
if (children == null || children.size() == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id oid = params.getObjId("oid");
|
||||
if (!isIdValid(oid))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int original_count = getIntObjVar(self, hq.VAR_SPAWN_COUNT);
|
||||
children = utils.removeElement(children, oid);
|
||||
if (children == null || children.size() == 0 || original_count == 0 || children.size() < original_count / 4)
|
||||
{
|
||||
removeObjVar(self, hq.VAR_SPAWN_CHILDREN);
|
||||
float delay = 3600;
|
||||
if (getTopMostContainer(self) != self)
|
||||
{
|
||||
delay = 3600;
|
||||
}
|
||||
messageTo(self, "handleSpawnRequest", null, delay, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVar(self, hq.VAR_SPAWN_CHILDREN, children);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
private obj_id[] loadSpawns(obj_id self) throws InterruptedException
|
||||
{
|
||||
String faction = toLower(factions.getFaction(self));
|
||||
if (faction == null || faction.equals(""))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
obj_id parent = getObjIdObjVar(self, hq.VAR_SPAWN_PARENT);
|
||||
if (!isIdValid(parent))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String template = utils.getTemplateFilenameNoPath(parent);
|
||||
if (template == null || template.equals(""))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String tbl = hq.TBL_SPAWN_EGG_PATH + template;
|
||||
String[] spawnList;
|
||||
int spawnType = getIntObjVar(self, hq.VAR_SPAWN_TYPE);
|
||||
switch (spawnType)
|
||||
{
|
||||
case hq.ST_MEDIUM:
|
||||
spawnList = dataTableGetStringColumnNoDefaults(tbl, "medium");
|
||||
break;
|
||||
case hq.ST_LARGE:
|
||||
spawnList = dataTableGetStringColumnNoDefaults(tbl, "large");
|
||||
break;
|
||||
case hq.ST_SMALL:
|
||||
case hq.ST_NONE:
|
||||
default:
|
||||
spawnList = dataTableGetStringColumnNoDefaults(tbl, "small");
|
||||
break;
|
||||
}
|
||||
if (spawnList == null || spawnList.length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String spawnKey = getStringObjVar(self, hq.VAR_SPAWN_TEMPLATE);
|
||||
if (spawnKey == null || spawnKey.equals(""))
|
||||
{
|
||||
spawnKey = spawnList[rand(0, spawnList.length - 1)];
|
||||
if (spawnKey == null || spawnKey.equals(""))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
location here = getLocation(self);
|
||||
location spawnLoc = locations.getGoodLocationAroundLocation(here, 1.0f, 1.0f, 4.0f, 4.0f);
|
||||
if (spawnLoc == null)
|
||||
{
|
||||
spawnLoc = here;
|
||||
}
|
||||
Vector spawns = new Vector();
|
||||
spawns.setSize(0);
|
||||
if (spawnKey.startsWith("formation:"))
|
||||
{
|
||||
String[] args = split(spawnKey, ':');
|
||||
if (args == null || args.length != 3)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String tbl_formation = hq.TBL_SPAWN_FORMATION_PATH + args[1] + ".iff";
|
||||
String col = args[2];
|
||||
String[] tmpkeys = dataTableGetStringColumnNoDefaults(tbl_formation, col);
|
||||
if (tmpkeys == null || tmpkeys.length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//Vector keys = new Vector(); <--- This was never gonna work without putting something in it first.
|
||||
//one line fix for formation spawns
|
||||
Vector keys = new Vector(Arrays.asList(tmpkeys));
|
||||
int formation = utils.stringToInt(((String)keys.get(0)));
|
||||
if (formation < ai_lib.FORMATION_COLUMN)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
setObjVar(self, VAR_SPAWN_FORMATION, formation);
|
||||
keys = utils.removeElementAt(keys, 0);
|
||||
obj_id leader = null;
|
||||
float dtheta = 30;
|
||||
if (keys.size() > 1)
|
||||
{
|
||||
dtheta = 360.0f / (keys.size() - 1);
|
||||
}
|
||||
location baseLoc = null;
|
||||
obj_id spawn;
|
||||
location[] pathpoints = null;
|
||||
boolean hasPathPoints = false;
|
||||
if(hasObjVar(self, VAR_SPAWN_PATHPOINTS)) {
|
||||
pathpoints = getLocationArrayObjVar(self, VAR_SPAWN_PATHPOINTS);
|
||||
hasPathPoints = (pathpoints != null && pathpoints.length > 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < keys.size(); i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
baseLoc = spawnLoc;
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnLoc = utils.rotatePointXZ(baseLoc, 0.75f, dtheta * i);
|
||||
}
|
||||
spawn = createSpawn(((String)keys.get(i)), spawnLoc);
|
||||
if (isIdValid(spawn))
|
||||
{
|
||||
spawns = utils.addElement(spawns, spawn);
|
||||
if (isIdValid(leader))
|
||||
{
|
||||
ai_lib.followInFormation(spawn, leader, formation, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
leader = spawn;
|
||||
setObjVar(spawn, hq.VAR_SPAWN_LEADER, true);
|
||||
if (hasPathPoints){
|
||||
ai_lib.setPatrolPath(leader, pathpoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
ai_lib.setDefaultCalmBehavior(leader, ai_lib.BEHAVIOR_LOITER);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("hq", "unable to create formation spawn: " + keys.get(i));
|
||||
}
|
||||
spawnLoc = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj_id spawn = createSpawn(spawnKey, spawnLoc);
|
||||
if (isIdValid(spawn))
|
||||
{
|
||||
spawns = utils.addElement(spawns, spawn);
|
||||
setYaw(spawn, getFloatObjVar(self, hq.VAR_SPAWN_YAW));
|
||||
if (getTopMostContainer(self) == self)
|
||||
{
|
||||
ai_lib.setDefaultCalmBehavior(spawn, ai_lib.BEHAVIOR_LOITER);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (spawns == null || spawns.size() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
setObjVar(self, hq.VAR_SPAWN_COUNT, spawns.size());
|
||||
obj_id[] _spawns = new obj_id[spawns.size()];
|
||||
spawns.toArray(_spawns);
|
||||
return _spawns;
|
||||
}
|
||||
private obj_id createSpawn(String type, location there) throws InterruptedException
|
||||
{
|
||||
if (type == null || type.equals(""))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (there == null)
|
||||
{
|
||||
there = getLocation(getSelf());
|
||||
}
|
||||
obj_id spawn = create.object(type, there);
|
||||
if (isIdValid(spawn))
|
||||
{
|
||||
attachScript(spawn, hq.SCRIPT_SPAWN_CHILD);
|
||||
setObjVar(spawn, hq.VAR_SPAWN_PARENT, getSelf());
|
||||
return spawn;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private void createPatrolPathPoints(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (getTopMostContainer(self) != self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
obj_id parent = getObjIdObjVar(self, hq.VAR_SPAWN_PARENT);
|
||||
if (!isIdValid(parent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
float maxTheaterSpawn = getFloatObjVar(parent, "poi.fltSize") - 20.0f;
|
||||
location here = getLocation(self);
|
||||
location there = getLocation(parent);
|
||||
if (getDistance(here, there) > maxTheaterSpawn)
|
||||
{
|
||||
location[] pathpoints = new location[rand(4, 8)];
|
||||
float dTheta = 360.0f / pathpoints.length;
|
||||
float patrol_distance = maxTheaterSpawn + rand(15.0f, 30.0f);
|
||||
float minDistance = Float.POSITIVE_INFINITY;
|
||||
int closeIndex = 0;
|
||||
for (int i = 0; i < pathpoints.length; i++)
|
||||
{
|
||||
pathpoints[i] = utils.rotatePointXZ(there, patrol_distance, (i * dTheta) - 180.0f);
|
||||
float dist = getDistance(here, pathpoints[i]);
|
||||
if (dist < minDistance)
|
||||
{
|
||||
minDistance = dist;
|
||||
closeIndex = i;
|
||||
}
|
||||
}
|
||||
location[] toUse = new location[pathpoints.length];
|
||||
for (int i = 0; i < pathpoints.length; i++)
|
||||
{
|
||||
int idx = i + closeIndex;
|
||||
if (idx >= pathpoints.length) {
|
||||
idx -= pathpoints.length;
|
||||
}
|
||||
toUse[i] = pathpoints[idx];
|
||||
}
|
||||
setObjVar(self, VAR_SPAWN_PATHPOINTS, toUse);
|
||||
}
|
||||
}
|
||||
public int handleParentCleanup(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, hq.VAR_SPAWN_CHILDREN))
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
Vector children = getResizeableObjIdArrayObjVar(self, hq.VAR_SPAWN_CHILDREN);
|
||||
if (children == null || children.size() == 0)
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
for (Object child : children) {
|
||||
if (ai_lib.isInCombat(((obj_id) child))) {
|
||||
messageTo(self, "handleParentCleanup", null, 600, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
destroyObject(self);
|
||||
messageTo(self, "handleParentCleanup", null, 600, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package script.faction_perk.hq;
|
||||
|
||||
import script.dictionary;
|
||||
import script.library.hq;
|
||||
import script.obj_id;
|
||||
|
||||
public class spawn_manager extends script.base_script
|
||||
{
|
||||
public spawn_manager()
|
||||
{
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
//hq.loadInteriorHqSpawns(self);
|
||||
//re-enable exterior spawns
|
||||
hq.loadHqSpawns(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
hq.cleanupHqSpawns(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int clearSpawn(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
hq.cleanupHqSpawns(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int doSpawn(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
//hq.loadInteriorHqSpawns(self);
|
||||
//re-enable exterior spawns
|
||||
hq.loadHqSpawns(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleTheaterComplete(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
LOG("hq", "(" + self + ") received handleTheaterComplete...");
|
||||
LOG("hq", "handleTheaterComplete: attempting to load exterior spawns...");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleDefenderRespawn(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
LOG("hq", "faction_perk.hq.spawn_manager::handleDefenderRespawn -- ENTERED HANDLER. Figured out self. Self is: " + self);
|
||||
LOG("hq", "faction_perk.hq.spawn_manager::handleDefenderRespawn -- attempting to clear all spawns...");
|
||||
LOG("hq", "faction_perk.hq.spawn_manager::handleDefenderRespawn -- attempting to restart all spawns...");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,53 +0,0 @@
|
||||
package script.faction_perk.hq;
|
||||
|
||||
import script.dictionary;
|
||||
import script.library.hq;
|
||||
import script.obj_id;
|
||||
|
||||
public class terminal_manager extends script.base_script
|
||||
{
|
||||
public terminal_manager()
|
||||
{
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
hq.loadHqTerminals(self);
|
||||
hq.enableHqTerminals(self);
|
||||
hq.loadAlarmUnits(self);
|
||||
hq.loadTurretTerminals(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
hq.cleanupBaseAlarmUnits(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnMaintenanceLoop(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int hp = getHitpoints(self);
|
||||
boolean disabled = getBooleanObjVar(self, hq.VAR_TERMINAL_DISABLE);
|
||||
if (hp > 0 && disabled)
|
||||
{
|
||||
hq.enableHqTerminals(self);
|
||||
}
|
||||
else if (hp < 1 && !disabled)
|
||||
{
|
||||
hq.disableHqTerminals(self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int terminalOff(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(self, "hq.objective.tracking"))
|
||||
{
|
||||
setObjVar(self, "donateTerminalOff", getGameTime());
|
||||
messageTo(self, "terminalOn", null, 3600.0f, true);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int terminalOn(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, "donateTerminalOff");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user