From 2196a25a885fb48358a8b0ef9a5dde0ff5cc45bf Mon Sep 17 00:00:00 2001 From: Rezec Date: Sat, 7 May 2022 17:17:44 -0400 Subject: [PATCH] Delete Enable Turrets directory Rearranging GitHub --- Enable Turrets/README.md | 3 - .../hq/spawn/exterior/hq_s01_imp_pvp.tab | 5 - .../hq/spawn/exterior/hq_s01_rebel_pvp.tab | 5 - .../hq/spawn/exterior/hq_s02_imp_pvp.tab | 5 - .../hq/spawn/exterior/hq_s02_rebel_pvp.tab | 6 - .../hq/spawn/exterior/hq_s03_imp_pvp.tab | 4 - .../hq/spawn/exterior/hq_s03_rebel_pvp.tab | 6 - .../hq/spawn/exterior/hq_s04_imp_pvp.tab | 4 - .../hq/spawn/exterior/hq_s04_rebel_pvp.tab | 6 - .../hq/spawn/exterior/hq_s05_imp_pvp.tab | 5 - .../hq/spawn/exterior/hq_s05_rebel_pvp.tab | 7 - .../faction_perk/hq/defense_manager.java | 472 ----- .../script/faction_perk/hq/spawn_egg.java | 367 ---- .../script/faction_perk/hq/spawn_manager.java | 49 - .../game/script/faction_perk/hq/terminal.java | 1208 ------------- .../faction_perk/hq/terminal_manager.java | 53 - .../compiled/game/script/library/hq.java | 1552 ----------------- 17 files changed, 3757 deletions(-) delete mode 100644 Enable Turrets/README.md delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s01_imp_pvp.tab delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s01_rebel_pvp.tab delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s02_imp_pvp.tab delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s02_rebel_pvp.tab delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s03_imp_pvp.tab delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s03_rebel_pvp.tab delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s04_imp_pvp.tab delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s04_rebel_pvp.tab delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s05_imp_pvp.tab delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s05_rebel_pvp.tab delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/defense_manager.java delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/spawn_egg.java delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/spawn_manager.java delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/terminal.java delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/terminal_manager.java delete mode 100644 Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/library/hq.java diff --git a/Enable Turrets/README.md b/Enable Turrets/README.md deleted file mode 100644 index a61afdc..0000000 --- a/Enable Turrets/README.md +++ /dev/null @@ -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. diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s01_imp_pvp.tab b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s01_imp_pvp.tab deleted file mode 100644 index b98f961..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s01_imp_pvp.tab +++ /dev/null @@ -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" diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s01_rebel_pvp.tab b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s01_rebel_pvp.tab deleted file mode 100644 index 6acb105..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s01_rebel_pvp.tab +++ /dev/null @@ -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" diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s02_imp_pvp.tab b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s02_imp_pvp.tab deleted file mode 100644 index 799962a..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s02_imp_pvp.tab +++ /dev/null @@ -1,5 +0,0 @@ -small med large -s s s -"12,0" "0,18" -"-12,0" "13,30" - "-13,30" diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s02_rebel_pvp.tab b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s02_rebel_pvp.tab deleted file mode 100644 index 45a4037..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s02_rebel_pvp.tab +++ /dev/null @@ -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" diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s03_imp_pvp.tab b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s03_imp_pvp.tab deleted file mode 100644 index e1f450c..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s03_imp_pvp.tab +++ /dev/null @@ -1,4 +0,0 @@ -small med large -s s s -27,10 0,23 22,44 --27,10 -22,44 diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s03_rebel_pvp.tab b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s03_rebel_pvp.tab deleted file mode 100644 index b3fe36e..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s03_rebel_pvp.tab +++ /dev/null @@ -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" diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s04_imp_pvp.tab b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s04_imp_pvp.tab deleted file mode 100644 index 6d94bdd..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s04_imp_pvp.tab +++ /dev/null @@ -1,4 +0,0 @@ -small med large -s s s --12,6 0,22 13,34 -12,6 -13,34 diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s04_rebel_pvp.tab b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s04_rebel_pvp.tab deleted file mode 100644 index 5d6f951..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s04_rebel_pvp.tab +++ /dev/null @@ -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" diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s05_imp_pvp.tab b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s05_imp_pvp.tab deleted file mode 100644 index d4c1d0b..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s05_imp_pvp.tab +++ /dev/null @@ -1,5 +0,0 @@ -small med large -s s s -"35,25" "0,-41" "0,40" -"-34,25" "40,70" - "-40,70" diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s05_rebel_pvp.tab b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s05_rebel_pvp.tab deleted file mode 100644 index c173dc2..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/datatables/faction_perk/hq/spawn/exterior/hq_s05_rebel_pvp.tab +++ /dev/null @@ -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" diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/defense_manager.java b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/defense_manager.java deleted file mode 100644 index a193312..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/defense_manager.java +++ /dev/null @@ -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; - } -} diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/spawn_egg.java b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/spawn_egg.java deleted file mode 100644 index 6034a09..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/spawn_egg.java +++ /dev/null @@ -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; - } -} diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/spawn_manager.java b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/spawn_manager.java deleted file mode 100644 index dcc4649..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/spawn_manager.java +++ /dev/null @@ -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; - } -} diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/terminal.java b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/terminal.java deleted file mode 100644 index 816bc69..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/terminal.java +++ /dev/null @@ -1,1208 +0,0 @@ -package script.faction_perk.hq; - -import script.*; -import script.library.*; - -import java.util.Calendar; -import java.util.Vector; - -public class terminal extends script.terminal.base.base_terminal -{ - public terminal() - { - } - private static final string_id MNU_DONATE = new string_id("hq", "mnu_donate"); - private static final string_id MNU_DONATE_MONEY = new string_id("hq", "mnu_donate_money"); - public static final string_id MNU_DONATE_RESOURCE = new string_id("hq", "mnu_donate_resource"); - private static final string_id MNU_DONATE_DEED = new string_id("hq", "mnu_donate_deed"); - private static final string_id UNDER_ATTACK = new string_id("hq", "under_attack"); - private static final string_id MNU_OVERLOAD = new string_id("hq", "mnu_overload"); - private static final string_id MNU_OVERLOAD_GOD = new string_id("hq", "mnu_overload_god_intentional_code_string"); - private static final string_id MNU_SHUTDOWN = new string_id("hq", "mnu_shutdown"); - private static final string_id MNU_DEFENSE_STATUS = new string_id("hq", "mnu_defense_status"); - private static final string_id MNU_RESET_VULNERABILITY = new string_id("hq", "mnu_reset_vulnerability"); - private static final String[] ACCEPTED_DEED_TYPES = - { - "turret", - "mine" - }; - private static final String SCRIPTVAR_COUNTDOWN = "countdownInProgress"; - private static final string_id SID_TERMINAL_MANAGEMENT = new string_id("player_structure", "management"); - private static final string_id SID_TERMINAL_MANAGEMENT_STATUS = new string_id("player_structure", "management_status"); - private static final string_id SID_TERMINAL_MANAGEMENT_PAY = new string_id("player_structure", "management_pay"); - private static final string_id SID_TERMINAL_MANAGEMENT_DESTROY = new string_id("player_structure", "permission_destroy"); - private static final string_id SID_VULNERABILITY_RESET = new string_id("hq", "vulnerability_reset"); - public static final string_id SID_VULNERABILITY_RESET_BLACKOUT_PERIOD = new string_id("hq", "vulnerability_reset_blackout_period"); - private static final string_id SID_VULNERABILITY_RESET_WRONG_CELL = new string_id("hq", "vulnerability_reset_wrong_cell"); - private static final string_id SID_VULNERABILITY_RESET_NO_LONGER_IN_STRUCTURE = new string_id("hq", "vulnerability_reset_no_longer_in_structure"); - private static final string_id SID_VULNERABILITY_RESET_REQUEST_RECEIVED = new string_id("hq", "vulnerability_reset_request_received"); - private static final string_id SID_VULNERABILITY_RESET_NOT_ALIVE = new string_id("hq", "vulnerability_reset_not_alive"); - private static final String STRING_FILE_LOC = "faction/faction_hq/faction_hq_response"; - private static final string_id SID_NO_STEALTH = new string_id("hq", "no_stealth"); - public int OnInitialize(obj_id self) throws InterruptedException - { - if (hasScript(self, hq.SCRIPT_TERMINAL_DISABLE)) - { - detachScript(self, hq.SCRIPT_TERMINAL_DISABLE); - } - return super.OnInitialize(self); - } - public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException - { - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return super.OnObjectMenuRequest(self, player, mi); - } - if (isGod(player) && getGodLevel(player) >= 15) - { - mi.addRootMenu(menu_info_types.SERVER_MENU12, MNU_OVERLOAD_GOD); - } - int intState = getState(player, STATE_FEIGN_DEATH); - if (isDead(player) || isIncapacitated(player) || intState > 0) - { - return super.OnObjectMenuRequest(self, player, mi); - } - obj_id structure = player_structure.getStructure(player); - if (!isIdValid(structure)) - { - return super.OnObjectMenuRequest(self, player, mi); - } - String buildingTemplate = getTemplateName(structure); - if (pvpGetAlignedFaction(player) != pvpGetAlignedFaction(structure)) - { - if (pvpGetType(player) == PVPTYPE_NEUTRAL) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response01")); - return super.OnObjectMenuRequest(self, player, mi); - } - if (hasObjVar(structure, hq.VAR_OBJECTIVE_TRACKING)) - { - obj_id[] objectives = getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_ID); - if (objectives == null || objectives.length == 0) - { - return super.OnObjectMenuRequest(self, player, mi); - } - obj_id[] disabled = getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_DISABLED); - if (disabled == null || disabled.length != objectives.length) - { - prose_package ppDisableOther = prose.getPackage(hq.PROSE_DISABLE_OTHER, objectives[objectives.length - 1], self); - sendSystemMessageProse(player, ppDisableOther); - return super.OnObjectMenuRequest(self, player, mi); - } - mi.addRootMenu(menu_info_types.ITEM_USE, MNU_OVERLOAD); - } - return super.OnObjectMenuRequest(self, player, mi); - } - int management_root = mi.addRootMenu(menu_info_types.ITEM_USE, SID_TERMINAL_MANAGEMENT); - if (management_root > -1) - { - mi.addSubMenu(management_root, menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS, SID_TERMINAL_MANAGEMENT_STATUS); - if (player_structure.isAdmin(structure, player)) - { - if (!player_structure.isFactionPerkBase(buildingTemplate)) - { - mi.addSubMenu(management_root, menu_info_types.SERVER_TERMINAL_MANAGEMENT_PAY, SID_TERMINAL_MANAGEMENT_PAY); - } - if (hasObjVar(structure, "isPvpBase")) - { - int stamp = getIntObjVar(structure, "lastReset"); - int now = getGameTime(); - if (now > stamp + 1209600 || !hasObjVar(structure, "lastReset")) - { - mi.addSubMenu(management_root, menu_info_types.SERVER_MENU6, MNU_RESET_VULNERABILITY); - } - } - mi.addSubMenu(management_root, menu_info_types.SERVER_MENU5, MNU_DEFENSE_STATUS); - mi.addSubMenu(management_root, menu_info_types.SERVER_TERMINAL_MANAGEMENT_DESTROY, SID_TERMINAL_MANAGEMENT_DESTROY); - } - } - int mnuDonate = -1; - if (!player_structure.isFactionPerkBase(buildingTemplate)) - { - mnuDonate = mi.addRootMenu(menu_info_types.SERVER_MENU1, MNU_DONATE); - mi.addSubMenu(mnuDonate, menu_info_types.SERVER_MENU2, MNU_DONATE_MONEY); - } - if (hasObjVar(structure, hq.VAR_OBJECTIVE_TRACKING) || isGod(player)) - { - if (mnuDonate <= -1) - { - mnuDonate = mi.addRootMenu(menu_info_types.SERVER_MENU1, MNU_DONATE); - } - mi.addSubMenu(mnuDonate, menu_info_types.SERVER_MENU3, MNU_DONATE_DEED); - } - - //re-enable donatipn of turrents and mines - mnuDonate = mi.addRootMenu(menu_info_types.SERVER_MENU1, MNU_DONATE); - mi.addSubMenu(mnuDonate, menu_info_types.SERVER_MENU3, MNU_DONATE_DEED); - - if (utils.hasScriptVar(self, SCRIPTVAR_COUNTDOWN) && pvpGetType(player) != PVPTYPE_NEUTRAL) - { - if (hasObjVar(structure, "isPvpBase")) - { - mi.addRootMenu(menu_info_types.SERVER_MENU9, MNU_SHUTDOWN); - } - } - return super.OnObjectMenuRequest(self, player, mi); - } - public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException - { - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return SCRIPT_CONTINUE; - } - if (isGod(player) && item == menu_info_types.SERVER_MENU12 && getGodLevel(player) >= 15) - { - startCountdown(self, player); - } - int intState = getState(player, STATE_FEIGN_DEATH); - if (isDead(player) || isIncapacitated(player) || intState > 0) - { - return SCRIPT_CONTINUE; - } - obj_id structure = player_structure.getStructure(player); - if (!isIdValid(structure)) - { - return SCRIPT_CONTINUE; - } - String buildingTemplate = getTemplateName(structure); - if (pvpGetAlignedFaction(player) != pvpGetAlignedFaction(structure)) - { - if (pvpGetType(player) == PVPTYPE_NEUTRAL) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response01")); - return SCRIPT_CONTINUE; - } - if (item == menu_info_types.ITEM_USE) - { - if (hasObjVar(structure, hq.VAR_OBJECTIVE_TRACKING)) - { - if (utils.hasScriptVar(self, SCRIPTVAR_COUNTDOWN)) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response02")); - return SCRIPT_CONTINUE; - } - obj_id[] objectives = getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_ID); - if (objectives == null || objectives.length == 0) - { - return SCRIPT_CONTINUE; - } - obj_id[] disabled = getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_DISABLED); - if (disabled == null || disabled.length != objectives.length) - { - prose_package ppDisableOther = prose.getPackage(hq.PROSE_DISABLE_OTHER, objectives[objectives.length - 1], self); - sendSystemMessageProse(player, ppDisableOther); - return SCRIPT_CONTINUE; - } - if (!hasSkill(player, "class_officer_phase1_novice")) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response03")); - return SCRIPT_CONTINUE; - } - startCountdown(self, player); - return SCRIPT_CONTINUE; - } - } - return SCRIPT_OVERRIDE; - } - if ((item == menu_info_types.SERVER_TERMINAL_MANAGEMENT) || (item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS) || (item == menu_info_types.ITEM_USE)) - { - queueCommand(player, (335013253), null, "", COMMAND_PRIORITY_DEFAULT); - } - else if (item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_PAY) - { - if (!player_structure.isFactionPerkBase(buildingTemplate)) - { - queueCommand(player, (-404530384), null, "", COMMAND_PRIORITY_DEFAULT); - } - } - else if (item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_DESTROY) - { - queueCommand(player, (419174182), null, "", COMMAND_PRIORITY_DEFAULT); - } - if (item == menu_info_types.ITEM_USE) - { - return SCRIPT_CONTINUE; - } - if (item == menu_info_types.SERVER_MENU1) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response04")); - return SCRIPT_CONTINUE; - } - else if (item == menu_info_types.SERVER_MENU2) - { - if (!player_structure.isFactionPerkBase(buildingTemplate)) - { - int total = getTotalMoney(player); - if (total < 1) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response05")); - return SCRIPT_CONTINUE; - } - else - { - String title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response18")); - String prompt = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response17")); - sui.transfer(self, player, prompt, title, "@faction/faction_hq/faction_hq_response:terminal_response30", total, "@faction/faction_hq/faction_hq_response:terminal_response31", 0, "handleRequestDonation"); - } - } - } - else if (item == menu_info_types.SERVER_MENU3) - { - - if (hasObjVar(structure, "donateTerminalOff")) - { - int terminalOff_time = utils.getIntObjVar(structure, "donateTerminalOff"); - int termOff_remaining = 3600 - (getGameTime() - terminalOff_time); - String timeOff_remaining = player_structure.assembleTimeRemaining(player_structure.convertSecondsTime(termOff_remaining)); - prose_package ppTimeRemaining = prose.getPackage(UNDER_ATTACK, timeOff_remaining); - sendSystemMessageProse(player, ppTimeRemaining); - return SCRIPT_CONTINUE; - } - else - { - - //re-enable donation of turrets and mines - showDeedDonationUI(self, player); - /*if (hasObjVar(structure, hq.VAR_OBJECTIVE_TRACKING) || isGod(player)) - { - if (isGod(player)) - { - sendSystemMessage(player, "Warning: You are using donation function while in Godmode.", null); - } - showDeedDonationUI(self, player); - }*/ - } - } - else if (item == menu_info_types.SERVER_MENU5) - { - if (player_structure.isAdmin(structure, player)) - { - showDefenseStatusUI(self, player); - } - } - else if (item == menu_info_types.SERVER_MENU6) - { - if (player_structure.isAdmin(structure, player)) - { - if (hasObjVar(structure, "isPvpBase")) - { - int hqBlackoutPeriodStart = utils.getIntConfigSetting("ScriptFlags", "hqBlackoutPeriodStart"); - if (hqBlackoutPeriodStart == 0) - { - hqBlackoutPeriodStart = 2; - } - int hqBlackoutPeriodEnd = utils.getIntConfigSetting("ScriptFlags", "hqBlackoutPeriodEnd"); - if (hqBlackoutPeriodEnd == 0) - { - hqBlackoutPeriodEnd = 6; - } - Calendar currentCalendar = Calendar.getInstance(); - int currentHourOfDay = currentCalendar.get(Calendar.HOUR_OF_DAY); - if ((currentHourOfDay >= hqBlackoutPeriodStart) && (currentHourOfDay <= hqBlackoutPeriodEnd)) - { - prose_package pp1a = prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response32"), hqBlackoutPeriodStart); - prose_package pp2a = prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response37"), hqBlackoutPeriodEnd); - String oob1 = packOutOfBandProsePackage(null, pp1a); - oob1 = packOutOfBandProsePackage(oob1, pp2a); - sendSystemMessageOob(player, oob1); - sendSystemMessageProse(player, prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response38"), currentHourOfDay)); - } - else - { - long now = System.currentTimeMillis(); - long curTime = ((now / 1000) - 1072224000); - int currentTime = (int)curTime; - setObjVar(structure, hq.VAR_OBJECTIVE_STAMP, currentTime); - setObjVar(structure, "lastReset", getGameTime()); - sendSystemMessage(player, SID_VULNERABILITY_RESET); - } - } - } - } - else if (item == menu_info_types.SERVER_MENU9) - { - if (hasObjVar(structure, "isPvpBase")) - { - if (pvpGetType(player) != PVPTYPE_NEUTRAL) - { - if (factions.isNewlyDeclared(player)) - { - int declared_time = utils.getIntScriptVar(player, factions.VAR_NEWLY_DECLARED); - int time_remaining = factions.NEWLY_DECLARED_INTERVAL - (getGameTime() - declared_time); - LOG("LOG_CHANNEL", "declared_time ->" + declared_time + " time_remaining ->" + time_remaining); - if (time_remaining > 0) - { - String time_str = player_structure.assembleTimeRemaining(player_structure.convertSecondsTime(time_remaining)); - sendSystemMessageProse(player, prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response41"), time_str)); - } - else - { - utils.removeScriptVar(player, factions.VAR_NEWLY_DECLARED); - facilityShutdownDelay(self, player); - } - } - else - { - facilityShutdownDelay(self, player); - } - } - else - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response06")); - } - } - } - return SCRIPT_CONTINUE; - } - private void shutdownFacility(obj_id self) throws InterruptedException - { - attachScript(self, hq.SCRIPT_TERMINAL_DISABLE); - obj_id structure = player_structure.getStructure(self); - if (isIdValid(structure)) - { - hq.disableHqTerminals(structure); - } - abortCountdown(self); - hq.activateHackAlarms(structure, false); - messageTo(self, "handleFacilityReboot", null, 30.0f, false); - } - private void startCountdown(obj_id self, obj_id player) throws InterruptedException - { - int meleemod = getSkillStatMod(player, "group_melee_defense"); - int rangemod = getSkillStatMod(player, "group_range_defense"); - float mod = (100.0f - (meleemod + rangemod)) / 100.0f; - if (mod < 0.0f) - { - mod = 0.0f; - } - float delay = 300.0f + 300.0f * mod; - int minutes = Math.round(delay / 60.0f); - if (isGod(player) && getGodLevel(player) >= 15) - { - delay = 60; - } - obj_id[] players = player_structure.getPlayersInBuilding(getTopMostContainer(self)); - if (players != null && players.length > 0) - { - for (obj_id player1 : players) { - sendSystemMessageProse(player1, prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response40"), minutes)); - } - } - int stamp = getGameTime() + Math.round(delay); - utils.setScriptVar(self, SCRIPTVAR_COUNTDOWN, stamp); - dictionary d = new dictionary(); - d.put("player", player); - d.put("cnt", minutes); - messageTo(self, "handleCountdown", d, 10.0f, false); - } - private void abortCountdown(obj_id self) throws InterruptedException - { - obj_id structure = getTopMostContainer(self); - hq.activateDestructAlarms(structure, false); - utils.removeScriptVar(self, SCRIPTVAR_COUNTDOWN); - obj_id[] players = player_structure.getPlayersInBuilding(structure); - if (players != null && players.length > 0) - { - for (obj_id player : players) { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response07")); - } - } - } - public int handleFacilityReboot(obj_id self, dictionary params) throws InterruptedException - { - detachScript(self, hq.SCRIPT_TERMINAL_DISABLE); - obj_id structure = player_structure.getStructure(self); - if (isIdValid(structure)) - { - hq.enableHqTerminals(structure); - } - obj_id[] players = player_structure.getPlayersInBuilding(getTopMostContainer(self)); - if (players != null && players.length > 0) - { - for (obj_id player : players) { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response08")); - } - } - return SCRIPT_CONTINUE; - } - public int handleCountdown(obj_id self, dictionary params) throws InterruptedException - { - if (!utils.hasScriptVar(self, SCRIPTVAR_COUNTDOWN)) - { - return SCRIPT_CONTINUE; - } - obj_id player = params.getObjId("player"); - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return SCRIPT_CONTINUE; - } - if (!isIdValid(player)) - { - abortCountdown(self); - return SCRIPT_CONTINUE; - } - int cnt = params.getInt("cnt"); - int stamp = utils.getIntScriptVar(self, SCRIPTVAR_COUNTDOWN); - LOG("hqObjective", "stamp = " + stamp); - int now = getGameTime(); - LOG("hqObjective", "now = " + now); - int timeLeft = stamp - now; - int minutes = Math.round(timeLeft / 60.0f); - obj_id structure = player_structure.getStructure(self); - if (!isIdValid(structure)) - { - abortCountdown(self); - return SCRIPT_CONTINUE; - } - LOG("hqObjective", "timeLeft = " + timeLeft); - if (timeLeft < 1) - { - utils.setScriptVar(structure, "faction_hq.detonator", player); - hq.detonateHq(structure); - String hqName = getName(structure); - CustomerServiceLog("faction_hq", "Initiating destroy for Faction HQ " + hqName + " (" + structure + "), by normal terminal overload."); - return SCRIPT_CONTINUE; - } - prose_package msg = prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response39"), minutes); - if (minutes >= 1) { - if (minutes < cnt) - { - obj_id[] players = player_structure.getPlayersInBuilding(structure); - if (players != null && players.length > 0) - { - for (obj_id player1 : players) { - sendSystemMessageProse(player1, msg); - } - } - params.put("cnt", minutes); - } - } - hq.activateDestructAlarms(structure, true); - messageTo(self, "handleCountdown", params, 10.0f, false); - return SCRIPT_CONTINUE; - } - public int handleDonateDeed(obj_id self, dictionary params) throws InterruptedException - { - obj_id player = sui.getPlayerId(params); - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return SCRIPT_CONTINUE; - } - if (!isIdValid(player)) - { - return SCRIPT_CONTINUE; - } - String scriptvar_sui = player + ".deed.sui"; - String scriptvar_opt = player + ".deed.opt"; - obj_id[] deeds = utils.getObjIdBatchScriptVar(self, scriptvar_opt); - utils.removeScriptVar(self, scriptvar_sui); - utils.removeBatchScriptVar(self, scriptvar_opt); - if (deeds == null || deeds.length == 0) - { - return SCRIPT_CONTINUE; - } - int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { - return SCRIPT_CONTINUE; - } - int idx = sui.getListboxSelectedRow(params); - if (idx == -1 || idx > deeds.length - 1) - { - return SCRIPT_CONTINUE; - } - obj_id deed = deeds[idx]; - if (!isIdValid(deed)) - { - return SCRIPT_CONTINUE; - } - if (!utils.isNestedWithin(deed, player)) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response09")); - return SCRIPT_CONTINUE; - } - String deedType = getStringObjVar(deed, "perkDeedType"); - if (deedType != null && !deedType.equals("")) - { - if (utils.getElementPositionInArray(ACCEPTED_DEED_TYPES, deedType) == -1) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response10")); - return SCRIPT_CONTINUE; - } - else - { - if (deedType.equals("turret")) - { - obj_id objBuilding = getTopMostContainer(self); - if (isIdValid(objBuilding)) - { - //Enable turret donations to SF bases - /*if (hasObjVar(objBuilding, "isPvpBase")) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response_special_forces_no_turrets")); - return SCRIPT_CONTINUE; - }*/ - } - else - { - debugServerConsoleMsg(player, "Trying to donate turrets to a Factional HQ terminal without a topmost container"); - return SCRIPT_CONTINUE; - } - } - } - } - String displayType = utils.packStringId(new string_id("faction_perk", deedType)); - String template = ""; - int mineType = -1; - obj_id structure = player_structure.getStructure(player); - if (!isIdValid(structure)) - { - return SCRIPT_CONTINUE; - } - if (deedType != null && deedType.equals("mine")) - { - int numMines = hq.getTotalMines(structure); - if (numMines >= hq.getMaxMines(structure)) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "max_number_mines")); - return SCRIPT_CONTINUE; - } - if (hasObjVar(deed, "mineType")) - { - mineType = getIntObjVar(deed, "mineType"); - } - } - else - { - obj_id[] defensesOfType = getObjIdArrayObjVar(structure, hq.VAR_DEFENSE_BASE + "." + deedType); - if (defensesOfType == null || defensesOfType.length == 0) - { - sendSystemMessageProse(player, prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response43"), displayType)); - return SCRIPT_CONTINUE; - } - int pos = utils.getFirstNonValidIdIndex(defensesOfType); - if (pos < 0 || pos > defensesOfType.length - 1) - { - sendSystemMessageProse(player, prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response44"), displayType)); - return SCRIPT_CONTINUE; - } - template = player_structure.getDeedTemplate(deed); - if (template == null || template.equals("")) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response11")); - return SCRIPT_CONTINUE; - } - } - String sFacName = factions.getFaction(structure); - if (sFacName == null || sFacName.equals("")) - { - sendSystemMessageProse(player, prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response45"), displayType)); - CustomerServiceLog("faction_hq", "%TU donates a " + displayType + " deed to Factional HQ " + structure, player, null); - } - else - { - prose_package pp1b = prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response46"), displayType); - prose_package pp2b = prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response47"), sFacName); - String oob2 = packOutOfBandProsePackage(null, pp1b); - oob2 = packOutOfBandProsePackage(oob2, pp2b); - CustomerServiceLog("faction_hq", "%TU donates a " + displayType + " deed to Factional HQ " + structure, player, null); - sendSystemMessageOob(player, oob2); - } - destroyObject(deed); - dictionary d = new dictionary(); - d.put("template", template); - d.put("type", deedType); - d.put("mineType", mineType); - messageTo(structure, "handleAddDefense", d, 1, true); - return SCRIPT_CONTINUE; - } - public int handleDonateResourceType(obj_id self, dictionary params) throws InterruptedException - { - obj_id player = sui.getPlayerId(params); - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return SCRIPT_CONTINUE; - } - if (!isIdValid(player)) - { - return SCRIPT_CONTINUE; - } - String scriptvar_sui = player + ".resource.sui"; - String scriptvar_opt = player + ".resource.opt"; - obj_id[] crates = utils.getObjIdBatchScriptVar(self, scriptvar_opt); - utils.removeScriptVar(self, scriptvar_sui); - utils.removeBatchScriptVar(self, scriptvar_opt); - if (crates == null || crates.length == 0) - { - return SCRIPT_CONTINUE; - } - int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { - return SCRIPT_CONTINUE; - } - int idx = sui.getListboxSelectedRow(params); - if (idx == -1 || idx > crates.length - 1) - { - return SCRIPT_CONTINUE; - } - obj_id crate = crates[idx]; - if (!isIdValid(crate)) - { - return SCRIPT_CONTINUE; - } - if (!utils.isNestedWithin(crate, player)) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response12")); - return SCRIPT_CONTINUE; - } - int amt = getResourceContainerQuantity(crate); - String title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response20")); - String prompt = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response19")); - int pid = sui.transfer(self, player, prompt, title, "@faction/faction_hq/faction_hq_response:terminal_response36", amt, "@faction/faction_hq/faction_hq_response:terminal_response31", 0, "handleDonateResourceAmt"); - if (pid > -1) - { - utils.setScriptVar(self, scriptvar_sui, pid); - utils.setScriptVar(self, scriptvar_opt, crate); - } - return SCRIPT_CONTINUE; - } - public int handleDonateResourceAmt(obj_id self, dictionary params) throws InterruptedException - { - obj_id player = sui.getPlayerId(params); - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return SCRIPT_CONTINUE; - } - if (!isIdValid(player)) - { - return SCRIPT_CONTINUE; - } - String scriptvar_sui = player + ".resource.sui"; - String scriptvar_opt = player + ".resource.opt"; - obj_id crate = utils.getObjIdScriptVar(self, scriptvar_opt); - utils.removeScriptVar(self, scriptvar_sui); - utils.removeScriptVar(self, scriptvar_opt); - if (!isIdValid(crate)) - { - return SCRIPT_CONTINUE; - } - if (!utils.isNestedWithin(crate, player)) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response12")); - return SCRIPT_CONTINUE; - } - int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { - return SCRIPT_CONTINUE; - } - int amt = sui.getTransferInputTo(params); - if (amt == 0) - { - return SCRIPT_CONTINUE; - } - obj_id rtype = getResourceContainerResourceType(crate); - if (!isIdValid(rtype)) - { - return SCRIPT_CONTINUE; - } - String res_name = getResourceName(rtype); - if (removeResourceFromContainer(crate, rtype, amt)) - { - obj_id structure = player_structure.getStructure(player); - String sFacName = factions.getFaction(structure); - if (sFacName == null || sFacName.equals("")) - { - sendSystemMessageProse(player, prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response48"), amt)); - CustomerServiceLog("faction_hq", "%TU donates " + amt + " units of " + res_name + " to Factional HQ " + structure, player, null); - } - else - { - prose_package pp1c = prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response49"), amt); - prose_package pp2c = prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response50"), sFacName); - String oob3 = packOutOfBandProsePackage(null, pp1c); - oob3 = packOutOfBandProsePackage(oob3, pp2c); - CustomerServiceLog("faction_hq", "%TU donates " + amt + " units of " + res_name + " to Factional HQ " + structure, player, null); - sendSystemMessageOob(player, oob3); - } - if (!isIdValid(structure)) - { - return SCRIPT_CONTINUE; - } - int total = getIntObjVar(structure, hq.VAR_HQ_RESOURCE_CNT); - total += amt; - setObjVar(structure, hq.VAR_HQ_RESOURCE_CNT, total); - } - return SCRIPT_CONTINUE; - } - public int handleRequestDonation(obj_id self, dictionary params) throws InterruptedException - { - int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { - return SCRIPT_CONTINUE; - } - obj_id player = sui.getPlayerId(params); - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return SCRIPT_CONTINUE; - } - if (!isIdValid(player)) - { - return SCRIPT_CONTINUE; - } - int amt = sui.getTransferInputTo(params); - if (amt == 0) - { - return SCRIPT_CONTINUE; - } - money.requestPayment(player, self, amt, "handleCreditDonation", null, true); - return SCRIPT_CONTINUE; - } - public int handleCreditDonation(obj_id self, dictionary params) throws InterruptedException - { - if (params == null || params.isEmpty()) - { - return SCRIPT_CONTINUE; - } - int ret = params.getInt(money.DICT_CODE); - if (ret == money.RET_FAIL) - { - return SCRIPT_CONTINUE; - } - obj_id player = params.getObjId(money.DICT_PLAYER_ID); - if (!isIdValid(player)) - { - return SCRIPT_CONTINUE; - } - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return SCRIPT_CONTINUE; - } - obj_id structure = player_structure.getStructure(player); - int amt = params.getInt(money.DICT_TOTAL); - String sFacName = factions.getFaction(structure); - if (sFacName == null || sFacName.equals("")) - { - sendSystemMessageProse(player, prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response51"), amt)); - CustomerServiceLog("faction_hq", "%TU donated " + amt + " credits to Faction HQ " + structure, player, null); - } - else - { - prose_package pp1d = prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response52"), amt); - prose_package pp2d = prose.getPackage(new string_id(STRING_FILE_LOC, "terminal_response53"), sFacName); - String oob4 = packOutOfBandProsePackage(null, pp1d); - oob4 = packOutOfBandProsePackage(oob4, pp2d); - sendSystemMessageOob(player, oob4); - CustomerServiceLog("faction_hq", "%TU donated " + amt + " credits to Faction HQ " + structure, player, null); - } - if (isIdValid(structure)) - { - money.bankTo(self, structure, amt); - } - return SCRIPT_CONTINUE; - } - public int handleDefenseSelection(obj_id self, dictionary params) throws InterruptedException - { - obj_id player = sui.getPlayerId(params); - if (!isIdValid(player)) - { - return SCRIPT_CONTINUE; - } - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return SCRIPT_CONTINUE; - } - String scriptvar_sui = player + ".defense.sui"; - String scriptvar_opt = player + ".defense.opt"; - obj_id[] opt = utils.getObjIdBatchScriptVar(self, scriptvar_opt); - utils.removeScriptVar(self, scriptvar_sui); - utils.removeBatchScriptVar(self, scriptvar_opt); - if (opt == null || opt.length == 0) - { - return SCRIPT_CONTINUE; - } - int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { - return SCRIPT_CONTINUE; - } - int idx = sui.getListboxSelectedRow(params); - if (idx == -1 || idx > opt.length - 1) - { - return SCRIPT_CONTINUE; - } - obj_id defense = opt[idx]; - if (!isIdValid(defense)) - { - return SCRIPT_CONTINUE; - } - if (!exists(defense) || !defense.isLoaded()) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response13")); - return SCRIPT_CONTINUE; - } - int max_hp = getMaxHitpoints(defense); - int cur_hp = getHitpoints(defense); - String title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response24")); - String prompt = getString(new string_id(STRING_FILE_LOC, "terminal_response25")); - prompt += "/n/n" + getString(new string_id(STRING_FILE_LOC, "selected_defense")) + utils.getStringName(defense) + " [" + cur_hp + "/" + max_hp + "]"; - if (hasScript(defense, "faction_perk.minefield.advanced_minefield")) - { - prompt = getString(new string_id(STRING_FILE_LOC, "terminal_response25a")); - } - int pid = sui.msgbox(self, player, prompt, sui.YES_NO, title, "handleDefenseRemoveConfirm"); - if (pid > -1) - { - utils.setScriptVar(self, scriptvar_sui, pid); - utils.setScriptVar(self, scriptvar_opt, defense); - } - return SCRIPT_CONTINUE; - } - public int handleDefenseRemoveConfirm(obj_id self, dictionary params) throws InterruptedException - { - obj_id player = sui.getPlayerId(params); - if (!isIdValid(player)) - { - return SCRIPT_CONTINUE; - } - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return SCRIPT_CONTINUE; - } - int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { - return SCRIPT_CONTINUE; - } - String scriptvar_sui = player + ".defense.sui"; - String scriptvar_opt = player + ".defense.opt"; - obj_id defense = utils.getObjIdScriptVar(self, scriptvar_opt); - utils.removeScriptVar(self, scriptvar_sui); - utils.removeScriptVar(self, scriptvar_opt); - if (!isIdValid(defense) || !exists(defense) || !defense.isLoaded()) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response13")); - return SCRIPT_CONTINUE; - } - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response58")); - utils.setScriptVar(defense, "hq.defense.remover", player); - if (hasScript(defense, "faction_perk.minefield.advanced_minefield")) - { - hq.clearMinefield(player_structure.getStructure(player)); - } - else - { - destroyObject(defense); - } - return SCRIPT_CONTINUE; - } - public void showResourceDonationUI(obj_id terminal, obj_id player) throws InterruptedException - { - if (!isIdValid(terminal) || !isIdValid(player)) - { - return; - } - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return; - } - String scriptvar_sui = player + ".resource.sui"; - String scriptvar_opt = player + ".resource.opt"; - if (utils.hasScriptVar(terminal, scriptvar_sui)) - { - sui.closeSUI(player, utils.getIntScriptVar(terminal, scriptvar_sui)); - utils.removeScriptVar(terminal, scriptvar_sui); - utils.removeBatchScriptVar(terminal, scriptvar_opt); - } - obj_id[] crates = utils.getContainedGOTObjects(player, GOT_resource_container, true, true); - if (crates == null || crates.length == 0) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response14")); - return; - } - Vector entries = new Vector(); - entries.setSize(0); - for (obj_id crate : crates) { - if (isIdValid(crate)) { - entries = utils.addElement(entries, getString(getNameStringId(crate)) + " [" + getResourceContainerQuantity(crate) + "]"); - } - } - String title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response20")); - String prompt = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response29")); - int pid = sui.listbox(terminal, player, prompt, sui.OK_CANCEL, title, entries, "handleDonateResourceType"); - if (pid > -1) - { - utils.setScriptVar(terminal, scriptvar_sui, pid); - utils.setBatchScriptVar(terminal, scriptvar_opt, crates); - } - } - private void showDeedDonationUI(obj_id terminal, obj_id player) throws InterruptedException - { - if (!isIdValid(terminal) || !isIdValid(player)) - { - return; - } - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return; - } - LOG("hq", " //***// showDeedDonationUI entered... passed in terminal:" + terminal + " and player:" + player); - String scriptvar_sui = player + ".deed.sui"; - String scriptvar_opt = player + ".deed.opt"; - LOG("hq", " //***// showDeedDonationUI ... string scriptvar_sui =" + scriptvar_sui + " and string scriptvar_opt =" + scriptvar_opt); - if (utils.hasScriptVar(terminal, scriptvar_sui)) - { - LOG("hq", " //***// showDeedDonationUI ... utils.hasScriptVar(terminal, scriptvar_sui) is AFFIRM"); - sui.closeSUI(player, utils.getIntScriptVar(terminal, scriptvar_sui)); - utils.removeScriptVar(terminal, scriptvar_sui); - utils.removeScriptVar(terminal, scriptvar_opt); - } - obj_id[] deeds = utils.getContainedObjectsWithObjVar(player, "perkDeedType", true); - if (deeds == null || deeds.length == 0) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response15")); - return; - } - Vector entries = new Vector(); - entries.setSize(0); - Vector opt = new Vector(); - opt.setSize(0); - for (int i = 0; i < deeds.length; i++) - { - LOG("hq", " //***// showDeedDonationUI ... counting through GOT_deed objects in player inventory. Currently on item# " + i); - obj_id deed = deeds[i]; - if (isIdValid(deed)) - { - String deedType = getStringObjVar(deed, "perkDeedType"); - if (deedType != null && !deedType.equals("")) - { - LOG("hq", " //***// showDeedDonationUI ... deed item# " + i + " has 'perkDeedType' objvar of: " + deedType); - if (utils.getElementPositionInArray(ACCEPTED_DEED_TYPES, deedType) > -1) - { - opt = utils.addElement(opt, deed); - entries = utils.addElement(entries, getEncodedName(deed)); - } - } - } - } - String title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response26")); - String prompt = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response23")); - LOG("hq", " //***// showDeedDonationUI ... title= " + title + " and prompt = " + prompt + " size of 'entries' array is:" + entries.size()); - int pid = sui.listbox(terminal, player, prompt, sui.OK_CANCEL, title, entries, "handleDonateDeed"); - if (pid > -1) - { - utils.setScriptVar(terminal, scriptvar_sui, pid); - utils.setBatchScriptVar(terminal, scriptvar_opt, opt); - } - } - private void showDefenseStatusUI(obj_id terminal, obj_id player) throws InterruptedException - { - if (!isIdValid(terminal) || !isIdValid(player)) - { - return; - } - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return; - } - String scriptvar_sui = player + ".defense.sui"; - String scriptvar_opt = player + ".defense.opt"; - if (utils.hasScriptVar(terminal, scriptvar_sui)) - { - sui.closeSUI(player, utils.getIntScriptVar(terminal, scriptvar_sui)); - utils.removeScriptVar(terminal, scriptvar_sui); - utils.removeScriptVar(terminal, scriptvar_opt); - } - obj_id structure = player_structure.getStructure(player); - if (!isIdValid(structure)) - { - return; - } - Vector entries = new Vector(); - entries.setSize(0); - Vector opt = new Vector(); - opt.setSize(0); - obj_var_list ovl = getObjVarList(structure, hq.VAR_DEFENSE_BASE); - if (ovl == null) - { - sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response14")); - return; - } - int numTypes = ovl.getNumItems(); - obj_var ov; - String ovName; - obj_id[] data; - String sName; - for (int i = 0; i < numTypes; i++) - { - ov = ovl.getObjVar(i); - ovName = ov.getName(); - entries = utils.addElement(entries, toUpper(ovName)); - opt = utils.addElement(opt, obj_id.NULL_ID); - data = ov.getObjIdArrayData(); - if (data != null && data.length > 0) - { - int validCount = 0; - for (obj_id aData : data) { - if (isIdValid(aData)) { - sName = utils.getStringName(aData); - int max_hp = getMaxHitpoints(aData); - int cur_hp = getHitpoints(aData); - if (hasScript(aData, "faction_perk.minefield.advanced_minefield")) { - entries = utils.addElement(entries, "- " + hq.getTotalMines(structure) + "/" + hq.getMaxMines(structure) + " mines"); - } else { - entries = utils.addElement(entries, "- " + sName + " [" + cur_hp + "/" + max_hp + "]"); - } - opt = utils.addElement(opt, aData); - validCount++; - } - } - if (validCount == 0) - { - entries = utils.addElement(entries, "- none"); - opt = utils.addElement(opt, obj_id.NULL_ID); - } - } - } - String title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response23")); - String prompt = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response22")); - int pid = sui.listbox(terminal, player, prompt, sui.REMOVE_CANCEL, title, entries, "handleDefenseSelection"); - if (pid > -1) - { - utils.setScriptVar(terminal, scriptvar_sui, pid); - utils.setBatchScriptVar(terminal, scriptvar_opt, opt); - } - } - private void facilityShutdownDelay(obj_id terminal, obj_id player) throws InterruptedException - { - if (!isIdValid(terminal) || !isIdValid(player)) - { - return; - } - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return; - } - String currentCell = null; - location locTest = getLocation(player); - if (isIdValid(locTest.cell)) - { - currentCell = getCellName(locTest.cell); - } - sendSystemMessage(player, SID_VULNERABILITY_RESET_REQUEST_RECEIVED); - dictionary params = new dictionary(); - params.put("player", player); - if (currentCell != null && !currentCell.equals("null")) - { - params.put("cellName", currentCell); - } - messageTo(terminal, "handleShutdownCountdownComplete", params, 60.0f, false); - } - public int handleShutdownCountdownComplete(obj_id self, dictionary params) throws InterruptedException - { - obj_id player = params.getObjId("player"); - String triggeringCell = params.getString("cellName"); - if (!isIdValid(player) || !isIdValid(self)) - { - return SCRIPT_CONTINUE; - } - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return SCRIPT_CONTINUE; - } - obj_id structure = player_structure.getStructure(self); - if (!isIdValid(structure)) - { - return SCRIPT_CONTINUE; - } - if (hasObjVar(structure, hq.VAR_TERMINAL_DISABLE)) - { - boolean structureState = getBooleanObjVar(structure, hq.VAR_TERMINAL_DISABLE); - if (structureState) - { - return SCRIPT_CONTINUE; - } - } - String currentCell = null; - location locTest = getLocation(player); - if (isIdValid(locTest.cell)) - { - currentCell = getCellName(locTest.cell); - } - if ((!isIdValid(locTest.cell)) || (currentCell != null && !currentCell.equals(triggeringCell))) - { - sendSystemMessage(player, SID_VULNERABILITY_RESET_WRONG_CELL); - return SCRIPT_CONTINUE; - } - if (isIncapacitated(player) || isDead(player)) - { - sendSystemMessage(player, SID_VULNERABILITY_RESET_NOT_ALIVE); - return SCRIPT_CONTINUE; - } - String title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response27")); - String prompt = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response28")); - sui.msgbox(self, player, title, sui.YES_NO, prompt, "handleShutdownConfirm"); - return SCRIPT_CONTINUE; - } - public int handleShutdownConfirm(obj_id self, dictionary params) throws InterruptedException - { - obj_id player = sui.getPlayerId(params); - if (!isIdValid(player)) - { - return SCRIPT_CONTINUE; - } - if (stealth.hasInvisibleBuff(player)) - { - sendSystemMessage(player, SID_NO_STEALTH); - return SCRIPT_CONTINUE; - } - int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { - return SCRIPT_CONTINUE; - } - obj_id structure = player_structure.getStructure(self); - if (hasObjVar(structure, hq.VAR_TERMINAL_DISABLE)) - { - boolean structureState = getBooleanObjVar(structure, hq.VAR_TERMINAL_DISABLE); - if (structureState) - { - return SCRIPT_CONTINUE; - } - } - obj_id currentStructure = player_structure.getStructure(player); - if (currentStructure != structure) - { - sendSystemMessage(player, SID_VULNERABILITY_RESET_NO_LONGER_IN_STRUCTURE); - return SCRIPT_CONTINUE; - } - shutdownFacility(self); - return SCRIPT_CONTINUE; - } - public int handleAlarmMute(obj_id self, dictionary params) throws InterruptedException - { - obj_id structure = player_structure.getStructure(self); - if (isIdValid(structure)) - { - hq.activateHackAlarms(structure, false); - } - return SCRIPT_CONTINUE; - } -} diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/terminal_manager.java b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/terminal_manager.java deleted file mode 100644 index 2a97703..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/terminal_manager.java +++ /dev/null @@ -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; - } -} diff --git a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/library/hq.java b/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/library/hq.java deleted file mode 100644 index 8648cbf..0000000 --- a/Enable Turrets/dsrc/sku.0/sys.server/compiled/game/script/library/hq.java +++ /dev/null @@ -1,1552 +0,0 @@ -package script.library; - -import script.*; - -import java.util.StringTokenizer; -import java.util.Vector; - -public class hq extends script.base_script -{ - public hq() - { - } - public static final float VULNERABILITY_CYCLE = 172800.0f; - public static final float VULNERABILITY_LENGTH = 10800.0f; - public static final String SCRIPT_CLONING_OVERRIDE = "faction_perk.hq.terminal_cloning_override"; - public static final String SCRIPT_INSURANCE_OVERRIDE = "faction_perk.hq.terminal_insurance_override"; - public static final String SCRIPT_TERMINAL_DISABLE = "faction_perk.hq.terminal_disable"; - public static final String SCRIPT_DEFENSE_OBJECT = "faction_perk.hq.defense_object"; - public static final String VAR_HQ_BASE = "hq"; - public static final String SCRIPTVAR_FLATTENER = "hq.flattener"; - public static final String SCRIPTVAR_THEATER_OBJECTS = "hq.theaterObjects"; - public static final String SCRIPTVAR_TERMINALS = "hq.terminals"; - public static final String VAR_DEFENSE_TURTERMINALS = "hq.turterminals.terminals"; - public static final String VAR_SPAWN_BASE = VAR_HQ_BASE + ".spawn"; - public static final String SCRIPTVAR_SPAWN_INTERIOR = VAR_SPAWN_BASE + ".interior"; - public static final String SCRIPTVAR_SPAWN_EXTERIOR = VAR_SPAWN_BASE + ".exterior"; - public static final String SCRIPTVAR_SPAWN_REINFORCEMENT = VAR_SPAWN_BASE + ".reinforcement"; - public static final String VAR_HQ_RESOURCE_CNT = VAR_HQ_BASE + ".resource.cnt"; - public static final String VAR_DEFENSE_BASE = VAR_HQ_BASE + ".defense"; - public static final String VAR_DEFENSE_PARENT = VAR_DEFENSE_BASE + ".parent"; - public static final String VAR_OBJECTIVE_BASE = VAR_HQ_BASE + ".objective"; - public static final String VAR_OBJECTIVE_STAMP = VAR_OBJECTIVE_BASE + ".stamp"; - public static final String VAR_OBJECTIVE_TRACKING = VAR_OBJECTIVE_BASE + ".tracking"; - public static final String VAR_OBJECTIVE_ID = VAR_OBJECTIVE_TRACKING + ".id"; - public static final String VAR_OBJECTIVE_DISABLED = VAR_OBJECTIVE_TRACKING + ".disabled"; - public static final String VAR_VULNERABILITY_RESET = VAR_HQ_BASE + ".vulnerabilityReset"; - public static final int RESET_MAX = 1; - public static final String VAR_IS_DISABLED = VAR_OBJECTIVE_BASE + ".isDisabled"; - public static final String[] OBJECTIVE_TEMPLATE = - { - "object/tangible/hq_destructible/uplink_terminal.iff", - "object/tangible/hq_destructible/security_terminal.iff", - "object/tangible/hq_destructible/override_terminal.iff", - "object/tangible/hq_destructible/power_regulator.iff" - }; - public static final String VAR_TERMINAL_DISABLE = VAR_HQ_BASE + ".terminal.disable"; - public static final String TBL_TERMINAL_PATH = "datatables/faction_perk/hq/terminal/"; - public static final String TBL_TURRET_TERMINAL_PATH = "datatables/faction_perk/hq/turret_terminal/"; - public static final String TBL_SPAWN_PATH = "datatables/faction_perk/hq/spawn/"; - public static final String TBL_SPAWN_INTERIOR_PATH = TBL_SPAWN_PATH + "interior/"; - public static final String TBL_SPAWN_EXTERIOR_PATH = TBL_SPAWN_PATH + "exterior/"; - public static final String TBL_SPAWN_EGG_PATH = TBL_SPAWN_PATH + "egg/"; - public static final String TBL_SPAWN_FORMATION_PATH = TBL_SPAWN_PATH + "formation/"; - public static final String TBL_DEFENSE_PATH = "datatables/faction_perk/hq/defense/"; - public static final String TBL_OBJECTIVE_PATH = "datatables/faction_perk/hq/objective/"; - public static final string_id PROSE_DISABLE_OTHER = new string_id("hq", "prose_disable_other"); - public static final String HANDLER_LOAD_VULNERABILITY = "handleLoadVulnerability"; - public static final String HANDLER_UNLOAD_VULNERABILITY = "handleUnloadVulnerability"; - public static final String TEMPLATE_SPAWN_EGG = "object/tangible/hq_egg/hq_spawner.iff"; - public static final String VAR_SPAWN_TYPE = VAR_HQ_BASE + ".spawnType"; - public static final int ST_NONE = 0; - public static final int ST_SMALL = 1; - public static final int ST_MEDIUM = 2; - public static final int ST_LARGE = 3; - public static final String VAR_SPAWN_CHILDREN = VAR_SPAWN_BASE + ".children"; - public static final String VAR_SPAWN_PARENT = VAR_SPAWN_BASE + ".parent"; - public static final String VAR_SPAWN_TEMPLATE = VAR_SPAWN_BASE + ".template"; - public static final String VAR_SPAWN_YAW = VAR_SPAWN_BASE + ".yaw"; - public static final String VAR_SPAWN_COUNT = VAR_SPAWN_BASE + ".cnt"; - public static final String SCRIPT_SPAWN_CHILD = "faction_perk.hq.spawn_child"; - public static final String VAR_SPAWN_LEADER = VAR_SPAWN_BASE + ".leader"; - public static final float FACTION_BASE_REFUND_AMOUNT = 60000.0f; - public static final int MAX_MINE_TYPES = 3; - public static void loadHqTheater(obj_id hq) throws InterruptedException - { - LOG("hq", "loadHqTheater entered..."); - LOG("hq", "loadHqTheater: hq yaw = " + getYaw(hq)); - obj_id[] children = theater.spawnDatatableOffset(hq); - utils.removeBatchScriptVar(hq, SCRIPTVAR_THEATER_OBJECTS); - if (children != null && children.length > 0) - { - utils.setBatchScriptVar(hq, SCRIPTVAR_THEATER_OBJECTS, children); - messageTo(hq, "handleTheaterComplete", null, 5.0f, false); - } - } - public static void cleanupHqTheater(obj_id hq) throws InterruptedException - { - LOG("hq", "cleanupHqTheater entered..."); - obj_id[] children = utils.getObjIdBatchScriptVar(hq, SCRIPTVAR_THEATER_OBJECTS); - if (children != null && children.length > 0) - { - utils.destroyObjects(children); - } - } - public static void loadHqTerminals(obj_id hq) throws InterruptedException - { - LOG("hq", "loadHqTerminals entered..."); - String faction = factions.getFaction(hq); - if (faction != null && !faction.equals("")) - { - obj_id[] terminals = structure.createStructureTerminals(hq, TBL_TERMINAL_PATH + toLower(faction) + ".iff"); - if (terminals != null && terminals.length > 0) - { - utils.setBatchScriptVar(hq, SCRIPTVAR_TERMINALS, terminals); - for (obj_id terminal : terminals) { - int tGot = getGameObjectType(terminal); - if (tGot == GOT_terminal_cloning) { - attachScript(terminal, SCRIPT_CLONING_OVERRIDE); - } else if (tGot == GOT_terminal_insurance) { - attachScript(terminal, SCRIPT_INSURANCE_OVERRIDE); - } - } - } - } - else - { - destroyObject(hq); - } - } - public static void loadTurretTerminals(obj_id hq) throws InterruptedException - { - LOG("***hq***", "loadTurretTerminals entered..."); - String faction = factions.getFaction(hq); - if (faction != null && !faction.equals("")) - { - obj_id[] turTerminals = structure.createStructureTerminals(hq, TBL_TURRET_TERMINAL_PATH + toLower(faction) + ".iff"); - if (turTerminals != null && turTerminals.length > 0) - { - utils.setBatchObjVar(hq, VAR_DEFENSE_TURTERMINALS, turTerminals); - } - } - } - public static void loadHqSpawns(obj_id hq) throws InterruptedException - { - LOG("hq", "loadHqSpawns entered..."); - loadInteriorHqSpawns(hq); - loadExteriorHqSpawns(hq); - } - public static void loadInteriorHqSpawns(obj_id hq) throws InterruptedException - { - LOG("hq", "loadInteriorHqSpawns entered..."); - String filename = utils.getTemplateFilenameNoPath(hq); - if (filename != null && !filename.equals("")) - { - obj_id[] interiorSpawns = spawnInterior(hq, TBL_SPAWN_INTERIOR_PATH + filename); - if (interiorSpawns != null && interiorSpawns.length > 0) - { - utils.setBatchScriptVar(hq, SCRIPTVAR_SPAWN_INTERIOR, interiorSpawns); - } - } - } - public static obj_id[] spawnInterior(obj_id hq, String tbl) throws InterruptedException - { - LOG("hq", "spawnInterior entered..."); - if (!isIdValid(hq) || tbl == null || tbl.equals("")) - { - return null; - } - int numRow = dataTableGetNumRows(tbl); - if (numRow > 0) - { - Vector spawns = new Vector(); - spawns.setSize(0); - location here = getLocation(hq); - String myFac = factions.getFaction(hq); - if (myFac == null || myFac.equals("")) - { - return null; - } - LOG("hq", "spawnInterior: numRows = " + numRow); - for (int i = 0; i < numRow; i++) - { - dictionary params = dataTableGetRow(tbl, i); - String spawnType = params.getString("SPAWN"); - LOG("hq", "spawnInterior: (" + i + ") spawnType = " + spawnType); - if (spawnType != null && !spawnType.equals("")) - { - float x = params.getFloat("X"); - float y = params.getFloat("Y"); - float z = params.getFloat("Z"); - float yaw = params.getFloat("YAW"); - String cellname = params.getString("CELL"); - location there = null; - if (cellname != null && !cellname.equals("")) - { - if (cellname.equals("WORLD_DELTA")) - { - there = new location(here.x + x, here.y + y, here.z + z); - } - else - { - obj_id cellId = getCellId(hq, cellname); - if (isIdValid(cellId)) - { - there = new location(x, y, z, here.area, cellId); - } - else - { - LOG("hq", "spawnInterior: unable to determine id for hq = " + hq + " cell = " + cellname); - } - } - } - if (there != null) - { - obj_id spawn = null; - LOG("hq", "spawnInterior: attempting to load interior spawn with type: " + spawnType); - if (spawnType.startsWith("egg")) - { - spawn = createInteriorEgg(hq, there, myFac, yaw); - if (spawnType.contains(":")) - { - String[] tmpSplit = split(spawnType, ':'); - if (tmpSplit.length > 1) - { - setObjVar(spawn, VAR_SPAWN_TEMPLATE, tmpSplit[1]); - } - } - } - else - { - spawn = create.object(spawnType, there); - if (isIdValid(spawn)) - { - setYaw(spawn, yaw); - } - } - if (isIdValid(spawn)) - { - spawns = utils.addElement(spawns, spawn); - } - } - else - { - LOG("hq", "spawnInterior: unable to load valid location for #" + i + " -> spawnType = " + spawnType); - } - } - } - if (spawns != null && spawns.size() > 0) - { - obj_id[] _spawns = new obj_id[0]; - if (spawns != null) - { - _spawns = new obj_id[spawns.size()]; - spawns.toArray(_spawns); - } - return _spawns; - } - } - return null; - } - public static obj_id createInteriorEgg(obj_id hq, location there, String myFac, float yaw) throws InterruptedException - { - LOG("hq", "spawnInterior: loading interior spawn egg..."); - obj_id spawn = create.object(TEMPLATE_SPAWN_EGG, there); - if (isIdValid(spawn)) - { - LOG("hq", "spawnInterior: spawn egg loaded..."); - setObjVar(spawn, VAR_SPAWN_TYPE, ST_SMALL); - setObjVar(spawn, VAR_SPAWN_PARENT, hq); - setObjVar(spawn, VAR_SPAWN_YAW, yaw); - factions.setFaction(spawn, myFac); - messageTo(spawn, "handleSpawnRequest", null, rand(1, 5), false); - return spawn; - } - else - { - LOG("hq", "spawnInterior: UNABLE TO LOAD interior spawn egg..."); - } - return null; - } - public static void loadExteriorHqSpawns(obj_id hq) throws InterruptedException - { - LOG("hq", "loadExteriorHqSpawns entered..."); - String filename = utils.getTemplateFilenameNoPath(hq); - if (filename != null && !filename.equals("")) - { - //what did SOE have against SF bases? - /*if (!filename.contains("_pvp")) - { - obj_id[] exteriorSpawns = spawnExterior(hq, TBL_SPAWN_EXTERIOR_PATH + filename); - if (exteriorSpawns != null && exteriorSpawns.length > 0) - { - utils.setBatchScriptVar(hq, SCRIPTVAR_SPAWN_EXTERIOR, exteriorSpawns); - } - }*/ - - //re-enable exterior spawns regardless of normal or sf - obj_id[] exteriorSpawns = spawnExterior(hq, TBL_SPAWN_EXTERIOR_PATH + filename); - if (exteriorSpawns != null && exteriorSpawns.length > 0) - { - utils.setBatchScriptVar(hq, SCRIPTVAR_SPAWN_EXTERIOR, exteriorSpawns); - } - } - } - public static obj_id[] spawnExterior(obj_id hq, String tbl) throws InterruptedException - { - LOG("hq", "spawnExterior entered..."); - if (!isIdValid(hq) || tbl == null || tbl.equals("")) - { - return null; - } - Vector spawns = new Vector(); - spawns.setSize(0); - location here = getLocation(hq); - float yaw = getYaw(hq); - String myFac = factions.getFaction(hq); - if (myFac == null || myFac.equals("")) - { - return null; - } - int numCols = dataTableGetNumColumns(tbl); - for (int i = 0; i < numCols; i++) - { - String colName = dataTableGetColumnName(tbl, i); - String[] locs = dataTableGetStringColumnNoDefaults(tbl, i); - if (locs != null) - { - for (String loc : locs) { - StringTokenizer st = new StringTokenizer(loc, ","); - if (st.countTokens() == 2) { - float dx = utils.stringToFloat(st.nextToken()); - float dz = utils.stringToFloat(st.nextToken()); - if (dx != Float.NEGATIVE_INFINITY && dz != Float.NEGATIVE_INFINITY) { - location spawnLoc = player_structure.transformDeltaWorldCoord(here, dx, dz, yaw); - if (spawnLoc != null) { - obj_id spawn = create.object(TEMPLATE_SPAWN_EGG, spawnLoc); - LOG("hq", "spawnExterior: spawn egg id = " + spawn); - if (isIdValid(spawn)) { - if (colName.equalsIgnoreCase("small")) { - setObjVar(spawn, VAR_SPAWN_TYPE, ST_SMALL); - } else if (colName.equalsIgnoreCase("med")) { - setObjVar(spawn, VAR_SPAWN_TYPE, ST_MEDIUM); - } else if (colName.equalsIgnoreCase("large")) { - setObjVar(spawn, VAR_SPAWN_TYPE, ST_LARGE); - } - setObjVar(spawn, VAR_SPAWN_PARENT, hq); - factions.setFaction(spawn, myFac); - messageTo(spawn, "handleSpawnRequest", null, rand(1, 5), false); - spawns = utils.addElement(spawns, spawn); - } - } - } - } - } - } - } - if (spawns != null && spawns.size() > 0) - { - obj_id[] _spawns = new obj_id[0]; - if (spawns != null) - { - _spawns = new obj_id[spawns.size()]; - spawns.toArray(_spawns); - } - return _spawns; - } - return null; - } - public static location parseExteriorLocation(location home, String delta) throws InterruptedException - { - if (home == null || delta == null || delta.equals("")) - { - return null; - } - java.util.StringTokenizer st = new java.util.StringTokenizer(delta, ","); - if (st.countTokens() != 2) - { - return null; - } - float dx = utils.stringToFloat(st.nextToken()); - float dz = utils.stringToFloat(st.nextToken()); - if (dx == Float.NEGATIVE_INFINITY || dz == Float.NEGATIVE_INFINITY) - { - return null; - } - return new location(home.x + dx, home.y, home.z + dz, home.area); - } - public static void cleanupHqSpawns(obj_id hq) throws InterruptedException - { - LOG("hq", "cleanupHqSpawns entered..."); - obj_id[] intSpawn = utils.getObjIdBatchScriptVar(hq, SCRIPTVAR_SPAWN_INTERIOR); - if (intSpawn != null && intSpawn.length > 0) - { - utils.destroyObjects(intSpawn); - } - obj_id[] extSpawn = utils.getObjIdBatchScriptVar(hq, SCRIPTVAR_SPAWN_EXTERIOR); - if (extSpawn != null && extSpawn.length > 0) - { - utils.destroyObjects(extSpawn); - } - if (utils.hasScriptVar(hq, SCRIPTVAR_SPAWN_REINFORCEMENT)) - { - obj_id reinforcementSpawner = utils.getObjIdScriptVar(hq, SCRIPTVAR_SPAWN_REINFORCEMENT); - messageTo(reinforcementSpawner, "handleParentCleanup", null, 300, false); - } - } - public static void prepareHqDefenses(obj_id hq) throws InterruptedException - { - if (hasObjVar(hq, VAR_DEFENSE_BASE)) - { - return; - } - String filename = utils.getTemplateFilenameNoPath(hq); - if (filename != null && !filename.equals("")) - { - String tbl = TBL_DEFENSE_PATH + filename; - int numCol = dataTableGetNumColumns(tbl); - for (int i = 0; i < numCol; i++) - { - String colName = toLower(dataTableGetColumnName(tbl, i)); - String[] data = dataTableGetStringColumnNoDefaults(tbl, i); - if (data != null && data.length > 0) - { - obj_id[] tmp = new obj_id[data.length]; - for (int j = 0; j < tmp.length; ++j) - { - tmp[j] = obj_id.NULL_ID; - } - setObjVar(hq, VAR_DEFENSE_BASE + "." + colName, tmp); - } - } - messageTo(hq, "handleCreateMinefield", null, 5.0f, false); - int[] mines = new int[MAX_MINE_TYPES]; - setObjVar(hq, "mines", mines); - } - } - public static void cleanupHqDefenses(obj_id hq) throws InterruptedException - { - if (!hasObjVar(hq, VAR_DEFENSE_BASE)) - { - return; - } - obj_var_list ovl = getObjVarList(hq, VAR_DEFENSE_BASE); - if (ovl == null) - { - return; - } - int numItems = ovl.getNumItems(); - for (int i = 0; i < numItems; i++) - { - obj_var ov = ovl.getObjVar(i); - if (ov != null) - { - obj_id[] defenses = ov.getObjIdArrayData(); - if (defenses != null && defenses.length > 0) - { - for (obj_id defens : defenses) { - if (isIdValid(defens)) { - destroyObject(defens); - } - } - } - } - } - } - public static void disableHqTerminals(obj_id hq) throws InterruptedException - { - setObjVar(hq, VAR_TERMINAL_DISABLE, true); - obj_id[] terminals = utils.getObjIdBatchScriptVar(hq, SCRIPTVAR_TERMINALS); - if (terminals != null && terminals.length > 0) - { - for (obj_id terminal : terminals) { - if (!hasScript(terminal, SCRIPT_TERMINAL_DISABLE)) { - attachScript(terminal, SCRIPT_TERMINAL_DISABLE); - } - } - } - } - public static void enableHqTerminals(obj_id hq) throws InterruptedException - { - setObjVar(hq, VAR_TERMINAL_DISABLE, false); - removeObjVar(hq, VAR_OBJECTIVE_DISABLED); - obj_id[] objects = trial.getAllObjectsInDungeon(hq); - if (objects == null || objects.length == 0) - { - return; - } - for (obj_id object : objects) { - if (hasScript(object, SCRIPT_TERMINAL_DISABLE)) { - detachScript(object, SCRIPT_TERMINAL_DISABLE); - } - if (hasObjVar(object, VAR_IS_DISABLED)) { - removeObjVar(object, VAR_IS_DISABLED); - } - } - } - public static void loadVulnerability(obj_id hq) throws InterruptedException - { - setInvulnerable(hq, true); - if (hasObjVar(hq, VAR_OBJECTIVE_ID)) - { - unloadVulnerabilityForObjectReInit(hq); - } - int currentTime = getCurrentTimeInSecsNormalized(); - if (!hasObjVar(hq, VAR_OBJECTIVE_STAMP)) - { - setObjVar(hq, VAR_OBJECTIVE_STAMP, currentTime); - } - int stamp = getIntObjVar(hq, VAR_OBJECTIVE_STAMP); - int diff = stamp - currentTime; - int checkfutureclose = (int)VULNERABILITY_LENGTH / 2; - int checkfuturefar = (int)VULNERABILITY_CYCLE; - int checkpastclose = checkfutureclose * -1; - int checkpastfar = checkfuturefar * -1; - if (diff <= checkfutureclose && diff >= checkpastclose) - { - obj_id[] objectives = loadObjectives(hq); - if (objectives != null && objectives.length > 0) - { - LOG("hq", "loadVulnerability ********* OBJECTIVES LOADED..."); - setObjVar(hq, VAR_OBJECTIVE_ID, objectives); - int stampNew = stamp + ((int)VULNERABILITY_CYCLE); - if (stampNew < 0) - { - stampNew = overdueStampReplacer(stamp, currentTime); - } - dictionary mapParams = new dictionary(); - int newStatus = 1; - mapParams.put("status", newStatus); - messageTo(hq, "handleFlagVulnerabilityChange", mapParams, 10, false); - LOG("hq", "loadVulnerability \\\\\\\\\\\\\\\\\\\\\\\\ fired message to 'handleFlagVulnerabilityChange' with status of : " + newStatus); - setObjVar(hq, VAR_OBJECTIVE_STAMP, stampNew); - messageTo(hq, HANDLER_UNLOAD_VULNERABILITY, null, VULNERABILITY_LENGTH, false); - return; - } - else - { - } - messageTo(hq, HANDLER_LOAD_VULNERABILITY, null, VULNERABILITY_CYCLE + diff, false); - return; - } - else if (diff <= checkpastclose) - { - int stampNew = overdueStampReplacer(stamp, currentTime); - setObjVar(hq, VAR_OBJECTIVE_STAMP, stampNew); - int vulnerabilityDelay = stampNew - currentTime; - messageTo(hq, HANDLER_LOAD_VULNERABILITY, null, vulnerabilityDelay, false); - return; - } - else if (diff > checkfutureclose && diff < checkfuturefar) - { - messageTo(hq, HANDLER_LOAD_VULNERABILITY, null, diff, false); - return; - } - else if (diff >= checkfuturefar) - { - int stampNew = farFutureStampReplacer(stamp, currentTime); - setObjVar(hq, VAR_OBJECTIVE_STAMP, stampNew); - int vulnerabilityDelay = stampNew - currentTime; - messageTo(hq, HANDLER_LOAD_VULNERABILITY, null, vulnerabilityDelay, false); - } - } - public static obj_id[] loadObjectives(obj_id hq) throws InterruptedException - { - String filename = utils.getTemplateFilenameNoPath(hq); - if (filename == null || filename.equals("")) - { - return null; - } - String tbl = TBL_OBJECTIVE_PATH + filename; - int numRows = dataTableGetNumRows(tbl); - Vector opt = new Vector(); - opt.setSize(0); - for (int i = 0; i < numRows; i++) - { - opt = utils.addElement(opt, i); - } - location here = getLocation(hq); - float yaw = getYaw(hq); - Vector objectives = new Vector(); - objectives.setSize(0); - for (String s : OBJECTIVE_TEMPLATE) { - int idx = rand(0, opt.size() - 1); - int rowIdx = (Integer) opt.get(idx); - opt = utils.removeElementAt(opt, idx); - dictionary row = dataTableGetRow(tbl, rowIdx); - String cellName = row.getString("CELL"); - float dx = row.getFloat("X"); - float dy = row.getFloat("Y"); - float dz = row.getFloat("Z"); - float dyaw = row.getFloat("YAW"); - obj_id objective = null; - if (cellName == null || cellName.equals("") || cellName.equals("WORLD_DELTA")) { - location there = player_structure.transformDeltaWorldCoord(here, dx, dz, yaw); - objective = createObject(s, there); - if (isIdValid(objective)) { - setYaw(objective, yaw + dyaw); - utils.addElement(objectives, objective); - } - } else { - obj_id cellId = getCellId(hq, cellName); - if (isIdValid(cellId)) { - location iSpot = new location(dx, dy, dz, here.area, cellId); - objective = createObjectInCell(s, hq, cellName, iSpot); - if (isIdValid(objective)) { - setYaw(objective, dyaw); - utils.addElement(objectives, objective); - } - } - } - } - obj_id[] _objectives = new obj_id[0]; - if (objectives != null) - { - _objectives = new obj_id[objectives.size()]; - objectives.toArray(_objectives); - } - return _objectives; - } - public static int overdueStampReplacer(int stamp, int currentTime) throws InterruptedException - { - int timeOverdue = currentTime - stamp; - int timeOverdueMagnitude = timeOverdue / (int)(VULNERABILITY_CYCLE); - int stampNew = ((timeOverdueMagnitude + 1) * (int)(VULNERABILITY_CYCLE)) + stamp; - return stampNew; - } - public static int farFutureStampReplacer(int stamp, int currentTime) throws InterruptedException - { - int futureDiff = stamp - currentTime; - int futureMagnitude = futureDiff / (int)(VULNERABILITY_CYCLE); - int stampNew = stamp - (futureMagnitude + (int)(VULNERABILITY_CYCLE)); - return stampNew; - } - public static void unloadVulnerabilityForObjectReInit(obj_id hq) throws InterruptedException - { - obj_id[] objectives = getObjIdArrayObjVar(hq, VAR_OBJECTIVE_ID); - setObjVar(hq, "planetMap.flags", MLF_INACTIVE); - dictionary mapParams = new dictionary(); - int newStatus = 0; - mapParams.put("status", newStatus); - messageTo(hq, "handleFlagVulnerabilityChange", mapParams, 10, false); - LOG("hq", "unloadVulnerabilityForObjectReInit \\\\\\\\\\\\\\\\\\\\\\\\ fired message to 'handleFlagVulnerabilityChange' with status of : " + newStatus); - removeObjVar(hq, VAR_OBJECTIVE_TRACKING); - if (objectives != null && objectives.length > 0) - { - for (obj_id objective : objectives) { - destroyObject(objective); - } - } - activateHackAlarms(hq, false); - cleanupHqSecurityTeam(hq); - } - public static void unloadVulnerability(obj_id hq) throws InterruptedException - { - obj_id[] objectives = getObjIdArrayObjVar(hq, VAR_OBJECTIVE_ID); - dictionary mapParams = new dictionary(); - int newStatus = 0; - mapParams.put("status", newStatus); - messageTo(hq, "handleFlagVulnerabilityChange", mapParams, 10, false); - LOG("hq", "unloadVulnerability \\\\\\\\\\\\\\\\\\\\\\\\ fired message to 'handleFlagVulnerabilityChange' with status of : " + newStatus); - removeObjVar(hq, VAR_OBJECTIVE_TRACKING); - if (objectives != null && objectives.length > 0) - { - for (obj_id objective : objectives) { - destroyObject(objective); - } - } - int currentTime = getCurrentTimeInSecsNormalized(); - int reVulnerableDelay = (int)(VULNERABILITY_CYCLE - VULNERABILITY_LENGTH); - if (hasObjVar(hq, VAR_OBJECTIVE_STAMP)) - { - int stamp = getIntObjVar(hq, VAR_OBJECTIVE_STAMP); - if (stamp < 0) - { - stamp = overdueStampReplacer(stamp, currentTime); - } - else if (stamp > (stamp + (int)(VULNERABILITY_CYCLE * 2))) - { - stamp = farFutureStampReplacer(stamp, currentTime); - } - reVulnerableDelay = stamp - currentTime; - setObjVar(hq, VAR_OBJECTIVE_STAMP, stamp); - } - messageTo(hq, "handleDefenderRespawn", null, 5, false); - activateHackAlarms(hq, false); - cleanupHqSecurityTeam(hq); - messageTo(hq, HANDLER_LOAD_VULNERABILITY, null, reVulnerableDelay, false); - cleanUpHackAlarms(hq); - } - public static int getCurrentTimeInSecsNormalized() throws InterruptedException - { - long now = System.currentTimeMillis(); - long curTime = ((now / 1000) - 1072224000); - int currentTime = (int)curTime; - return currentTime; - } - public static boolean canDisableObjective(obj_id hq, obj_id objective) throws InterruptedException - { - LOG("gcw", "checking canDisable Objective for " + hq + " and " + objective); - if (!isIdValid(hq) || !isIdValid(objective)) - { - return false; - } - if (hasObjVar(objective, VAR_IS_DISABLED)) - { - return false; - } - LOG("gcw", "getNextObjective is " + getNextObjective(hq)); - if (objective == getNextObjective(hq)) - { - return true; - } - return false; - } - public static obj_id getNextObjective(obj_id hq) throws InterruptedException - { - obj_id[] objectives = getObjIdArrayObjVar(hq, VAR_OBJECTIVE_ID); - if (objectives == null || objectives.length == 0) - { - return null; - } - obj_id[] disabled = getObjIdArrayObjVar(hq, VAR_OBJECTIVE_DISABLED); - if (disabled == null || disabled.length == 0) - { - return objectives[0]; - } - else - { - if (disabled.length < objectives.length) - { - return objectives[disabled.length]; - } - } - return null; - } - public static obj_id getPriorObjective(obj_id hq, obj_id objective) throws InterruptedException - { - obj_id[] objectives = getObjIdArrayObjVar(hq, VAR_OBJECTIVE_ID); - if (objectives == null || objectives.length == 0) - { - return null; - } - int idx = utils.getElementPositionInArray(objectives, objective); - if (idx > 0 && idx < objectives.length) - { - return objectives[idx - 1]; - } - return null; - } - public static void disableObjective(obj_id hq, obj_id objective) throws InterruptedException - { - if (canDisableObjective(hq, objective)) - { - Vector disabled = getResizeableObjIdArrayObjVar(hq, VAR_OBJECTIVE_DISABLED); - disabled = utils.addElement(disabled, objective); - setObjVar(hq, VAR_OBJECTIVE_DISABLED, disabled); - setObjVar(objective, VAR_IS_DISABLED, true); - messageTo(objective, "handleObjectiveDisabled", null, 1, false); - activateHackAlarms(hq, true); - reportHackAlarmToPlanet(hq); - } - } - public static void disableObjective(obj_id objective) throws InterruptedException - { - obj_id hq = null; - if (hasObjVar(objective, "objParent")) - { - hq = getObjIdObjVar(objective, "objParent"); - } - else - { - hq = getTopMostContainer(objective); - } - if (isIdValid(hq)) - { - disableObjective(hq, objective); - } - else - { - LOG("hq", "library.hq::disableObjective(obj_id objective) ********* hq obj_id came in as invalid"); - } - } - public static void detonateHq(obj_id hq) throws InterruptedException - { - float maxDist = getFloatObjVar(hq, "poi.fltSize") - 20.0f; - location here = getLocation(hq); - obj_id[] players = player_structure.getPlayersInBuilding(hq); - if (players != null && players.length > 0) - { - location ejectLoc = getBuildingEjectLocation(hq); - location worldLoc = getWorldLocation(hq); - for (obj_id player : players) { - pclib.sendToAnyLocation(player, ejectLoc, worldLoc); - } - } - location[] locs = new location[rand(5, 9)]; - for (int i = 0; i < locs.length; i++) - { - location tmpLoc = utils.getRandomLocationInRing(here, 5.0f, maxDist); - if (tmpLoc != null) - { - tmpLoc.y = getHeightAtLocation(tmpLoc.x, tmpLoc.z) + rand(0.0f, 5.0f); - locs[i] = tmpLoc; - } - } - dictionary d = new dictionary(); - d.put("locs", locs); - messageTo(hq, "handleHqDetonation", d, rand(0.1f, 1.0f), true); - } - public static void validateDefenseTracking(obj_id hq) throws InterruptedException - { - if (!isIdValid(hq)) - { - return; - } - if (!hasObjVar(hq, VAR_DEFENSE_BASE)) - { - return; - } - obj_var_list ovl = getObjVarList(hq, VAR_DEFENSE_BASE); - if (ovl == null) - { - return; - } - String filename = utils.getTemplateFilenameNoPath(hq); - if (filename != null && !filename.equals("")) - { - String tbl = TBL_DEFENSE_PATH + filename; - String[] data = dataTableGetStringColumnNoDefaults(tbl, "TURRET"); - obj_id[] properTurretData = new obj_id[data.length]; - obj_id[] currentTurretData = getObjIdArrayObjVar(hq, VAR_DEFENSE_BASE + ".turret"); - if ((currentTurretData != null && properTurretData != null) && currentTurretData.length != properTurretData.length) - { - for (int i = 0; i < properTurretData.length; i++) - { - if (i < currentTurretData.length) - { - properTurretData[i] = currentTurretData[i]; - } - else - { - properTurretData[i] = obj_id.NULL_ID; - } - } - setObjVar(hq, VAR_DEFENSE_BASE + ".turret", properTurretData); - } - } - int numType = ovl.getNumItems(); - for (int i = 0; i < numType; i++) - { - obj_var ov = ovl.getObjVar(i); - obj_id[] defenses = ov.getObjIdArrayData(); - if (defenses != null && defenses.length > 0) - { - for (obj_id defens : defenses) { - if (isIdValid(defens)) { - if (!exists(defens) || (getHitpoints(defens) < 1)) { - dictionary d = new dictionary(); - d.put("sender", defens); - messageTo(hq, "handleRemoveDefense", d, 1.0f, false); - } else if (hasScript(defens, "systems.turret.turret_ai")) { - dictionary d = new dictionary(); - d.put("sender", defens); - messageTo(hq, "handleResetTurretControl", d, 1.0f, false); - } - } - } - } - } - obj_id[] numTur = getObjIdArrayObjVar(hq, "hq.defense.turret"); - if (numTur == null || numTur.length == 0) - { - detachScript(hq, "faction_perk.hq.base_block"); - } - int pos = utils.getFirstValidIdIndex(numTur); - if (pos > -1) - { - attachScript(hq, "faction_perk.hq.base_block"); - } - if (hasObjVar(hq, "mines")) - { - int[] mines = getIntArrayObjVar(hq, "mines"); - if (mines.length < MAX_MINE_TYPES) - { - messageTo(hq, "handleMinefieldValidation", null, 10.0f, false); - } - } - else - { - messageTo(hq, "handleMinefieldValidation", null, 10.0f, false); - } - } - public static void sealEntrance(obj_id hq) throws InterruptedException - { - if (!isIdValid(hq)) - { - return; - } - if (!hasObjVar(hq, VAR_DEFENSE_BASE)) - { - return; - } - attachScript(hq, "faction_perk.hq.base_block"); - } - public static void ejectEnemyFactionOnLogin(obj_id player) throws InterruptedException - { - obj_id structure = getTopMostContainer(player); - if (!isIdValid(structure)) - { - return; - } - int myFac = pvpGetAlignedFaction(structure); - int tFac = pvpGetAlignedFaction(player); - if (isPlayer(player) && pvpGetType(player) == PVPTYPE_NEUTRAL) - { - tFac = 0; - } - if (pvpAreFactionsOpposed(myFac, tFac)) - { - if (isIdValid(structure)) - { - string_id warning = new string_id("faction_perk", "destroy_turrets"); - sendSystemMessage(player, warning); - - { - location there = getBuildingEjectLocation(structure); - if (there == null) - { - return; - } - dictionary params = new dictionary(); - params.put("player", player); - params.put("loc", there); - messageTo(structure, "ejectPlayer", params, 1.0f, false); - } - } - return; - } - } - public static void loadFullTimeVulnerability(obj_id hq) throws InterruptedException - { - if (hasObjVar(hq, VAR_OBJECTIVE_ID)) - { - obj_id[] oldObjectives = getObjIdArrayObjVar(hq, VAR_OBJECTIVE_ID); - removeObjVar(hq, VAR_OBJECTIVE_TRACKING); - if (oldObjectives != null && oldObjectives.length > 0) - { - for (obj_id oldObjective : oldObjectives) { - if (isIdValid(oldObjective)) { - destroyObject(oldObjective); - } - } - } - } - obj_id[] objectives = loadObjectives(hq); - if (objectives != null && objectives.length > 0) - { - setObjVar(hq, VAR_OBJECTIVE_ID, objectives); - } - return; - } - public static void planetMapVulnerabilityStatusChange(obj_id hq, int newStatus) throws InterruptedException - { - map_location maploc = getPlanetaryMapLocation(hq); - byte statusFlag = MLF_INACTIVE; - if (newStatus == 1) - { - statusFlag = MLF_ACTIVE; - } - addPlanetaryMapLocation(hq, maploc.getLocationName(), (int)maploc.getX(), (int)maploc.getY(), maploc.getCategory(), maploc.getSubCategory(), MLT_STATIC, statusFlag); - return; - } - public static void refundFactionBaseLots(obj_id base) throws InterruptedException - { - if (hasObjVar(base, "lotsRefunded2")) - { - return; - } - obj_id baseOwner = getOwner(base); - String base_template = getTemplateName(base); - String base_fp_template = player_structure.getFootprintTemplate(base_template); - if (base_fp_template == null || base_fp_template.equals("")) - { - return; - } - int base_lot_cost = (getNumberOfLots(base_fp_template) / 4); - if (base_lot_cost < 1) - { - base_lot_cost = 1; - } - int base_lot_refund = base_lot_cost; - dictionary outparams = new dictionary(); - outparams.put("baseLotRefund", base_lot_refund); - float faction_point_refund = 60000.0f; - if (hasObjVar(base, "lotsRefunded")) - { - faction_point_refund = 0.0f; - } - outparams.put("baseFactionRefund", faction_point_refund); - int baseFaction = pvpGetAlignedFaction(base); - outparams.put("baseFaction", baseFaction); - gcw.incrementGCWScore(base); - setObjVar(base, "lotsRefunded2", 1); - messageTo(baseOwner, "factionBaseLotRefund", outparams, 1.0f, true); - return; - } - public static void refundBaseUnit(obj_id base) throws InterruptedException - { - obj_id baseOwner = getOwner(base); - messageTo(baseOwner, "factionBaseUnitRefund", null, 1.0f, true); - return; - } - public static boolean isPvpFactionBase(obj_id base) throws InterruptedException - { - if (hasObjVar(base, "isPvpBase")) - { - return true; - } - return false; - } - public static void removeCovertDetector(obj_id base) throws InterruptedException - { - if (hasObjVar(base, "hq.defense.covert_detector")) - { - removeObjVar(base, "hq.defense.covert_detector"); - } - return; - } - public static void loadAlarmUnits(obj_id hq) throws InterruptedException - { - LOG("hq", "loadAlarmUnits entered..."); - String filename = utils.getTemplateFilenameNoPath(hq); - if (filename != null && !filename.equals("")) - { - spawnAlarmUnits(hq); - } - } - public static void spawnAlarmUnits(obj_id hq) throws InterruptedException - { - cleanupBaseAlarmUnits(hq); - String filename = utils.getTemplateFilenameNoPath(hq); - if (filename == null || filename.equals("")) - { - return; - } - if (filename.contains("hq_s01")) - { - filename = "hq_s01.iff"; - } - else if (filename.contains("hq_s02")) - { - filename = "hq_s02.iff"; - } - else if (filename.contains("hq_s03")) - { - filename = "hq_s03.iff"; - } - else if (filename.contains("hq_s04")) - { - filename = "hq_s04.iff"; - } - String tbl = "datatables/faction_perk/hq/alarm/" + filename; - int numRows = dataTableGetNumRows(tbl); - location here = getLocation(hq); - Vector hackAlarms = new Vector(); - hackAlarms.setSize(0); - Vector destructAlarms = new Vector(); - destructAlarms.setSize(0); - for (int i = 0; i < numRows; i++) - { - dictionary row = dataTableGetRow(tbl, i); - String alarmType = row.getString("ALARM"); - LOG("hq", "hq::spawnAlarmUnits: (" + i + ") alarmType = " + alarmType); - if (alarmType != null && !alarmType.equals("")) - { - float x = row.getFloat("X"); - float y = row.getFloat("Y"); - float z = row.getFloat("Z"); - float yaw = row.getFloat("YAW"); - String cellName = row.getString("CELL"); - obj_id alarmUnit = null; - if (cellName != null && !cellName.equals("")) - { - obj_id cellId = getCellId(hq, cellName); - if (isIdValid(cellId)) - { - location loc = new location(x, y, z, here.area, cellId); - alarmUnit = createObjectInCell(alarmType, hq, cellName, loc); - setLocation(alarmUnit, loc); - setYaw(alarmUnit, yaw); - transform alarmTransform = getTransform_o2p(alarmUnit); - if (alarmType.contains("alarm_hack")) - { - alarmTransform = alarmTransform.pitch_l((float)((Math.PI) / 2)); - } - else - { - alarmTransform = alarmTransform.pitch_l((float)Math.PI); - } - setTransform_o2p(alarmUnit, alarmTransform); - if (isIdValid(alarmUnit)) - { - if (alarmType.contains("hack")) - { - utils.addElement(hackAlarms, alarmUnit); - } - else if (alarmType.contains("destruct")) - { - utils.addElement(destructAlarms, alarmUnit); - } - else - { - destroyObject(alarmUnit); - } - } - } - } - } - } - if (hackAlarms.size() > 0) - { - setObjVar(hq, "hq.alarm.hack", hackAlarms); - } - if (destructAlarms.size() > 0) - { - setObjVar(hq, "hq.alarm.destruct", destructAlarms); - } - return; - } - public static void activateHackAlarms(obj_id hq, boolean activate) throws InterruptedException - { - if (hasObjVar(hq, "hq.alarm.hack")) - { - Vector hackAlarmList = getResizeableObjIdArrayObjVar(hq, "hq.alarm.hack"); - for (Object o : hackAlarmList) { - if (activate == true) { - setCondition(((obj_id) o), CONDITION_ON); - messageTo(hq, "handleAlarmMute", null, 600, false); - } else { - clearCondition(((obj_id) o), CONDITION_ON); - } - } - } - return; - } - public static void activateDestructAlarms(obj_id hq, boolean activate) throws InterruptedException - { - if (hasObjVar(hq, "hq.alarm.destruct")) - { - Vector destructAlarmList = getResizeableObjIdArrayObjVar(hq, "hq.alarm.destruct"); - for (Object o : destructAlarmList) { - if (activate == true) { - setCondition(((obj_id) o), CONDITION_ON); - } else { - clearCondition(((obj_id) o), CONDITION_ON); - cleanUpHackAlarms(hq); - } - } - } - return; - } - public static void cleanupBaseAlarmUnits(obj_id hq) throws InterruptedException - { - if (hasObjVar(hq, "hq.alarm.hack")) - { - Vector hackAlarms = getResizeableObjIdArrayObjVar(hq, "hq.alarm.hack"); - if (hackAlarms.size() > 0) - { - obj_id[] hackAlarmList = new obj_id[hackAlarms.size()]; - hackAlarms.toArray(hackAlarmList); - utils.destroyObjects(hackAlarmList); - removeObjVar(hq, "hq.alarm.hack"); - } - } - if (hasObjVar(hq, "hq.alarm.destruct")) - { - Vector destructAlarms = getResizeableObjIdArrayObjVar(hq, "hq.alarm.destruct"); - if (destructAlarms.size() > 0) - { - obj_id[] destructAlarmList = new obj_id[destructAlarms.size()]; - destructAlarms.toArray(destructAlarmList); - utils.destroyObjects(destructAlarmList); - removeObjVar(hq, "hq.alarm.destruct"); - } - } - } - public static void spawnRovingSecurityTeam(obj_id hq) throws InterruptedException - { - String hqTemplate = utils.getTemplateFilenameNoPath(hq); - int sizeOfBase = 1; - if (hqTemplate.contains("hq_s02")) - { - sizeOfBase = 2; - } - else if (hqTemplate.contains("hq_s03")) - { - sizeOfBase = 3; - } - else if (hqTemplate.contains("hq_s04")) - { - sizeOfBase = 4; - } - location start = getGoodLocation(hq, "entry"); - String[] base_cells = getCellNames(hq); - location[] locs = new location[base_cells.length]; - for (int i = 0; i < base_cells.length; i++) - { - locs[i] = getGoodLocation(hq, base_cells[i]); - } - int numRespondersCheck = rand(0, 5); - int numResponders = 0; - switch (numRespondersCheck) - { - case 5: - numResponders = 3 * sizeOfBase; - break; - case 4: - numResponders = 2 * sizeOfBase; - break; - case 3: - numResponders = sizeOfBase; - break; - } - if (numResponders == 0) - { - return; - } - loadReinforcementSpawn(hq); - dictionary params = new dictionary(); - params.put("locs", locs); - params.put("start", start); - for (int i = 0; i < numResponders; i++) - { - String guard = guardKeyPicker(hq); - params.put("guard", guard); - messageTo(hq, "handleSpawnSecurityRover", params, rand(i, i + 5), false); - } - return; - } - public static String guardKeyPicker(obj_id hq) throws InterruptedException - { - int spawnType = ST_SMALL; - String template = utils.getTemplateFilenameNoPath(hq); - LOG("hq", "hq::guardKeyPicker -- parent template = " + template); - if (template == null || template.equals("")) - { - return null; - } - String tbl = TBL_SPAWN_EGG_PATH + template; - LOG("hq", "hq::guardKeyPicker -- tbl = " + tbl); - String[] spawnList = null; - spawnList = dataTableGetStringColumnNoDefaults(tbl, "small"); - if (spawnList == null || spawnList.length == 0) - { - LOG("hq", "hq::guardKeyPicker -- spawnList returned from datatable with invalid data..."); - return null; - } - String spawnKey = spawnList[rand(0, spawnList.length - 1)]; - LOG("hq", "hq::guardKeyPicker -- spawnKey = " + spawnKey); - if (spawnKey == null || spawnKey.equals("")) - { - return null; - } - return spawnKey; - } - public static void cleanupHqSecurityTeam(obj_id hq) throws InterruptedException - { - if (utils.hasScriptVar(hq, "hq.spawn.security")) - { - Vector securityTeam = utils.getResizeableObjIdArrayScriptVar(hq, "hq.spawn.security"); - if (securityTeam.size() > 0) - { - obj_id[] securityDetail = new obj_id[securityTeam.size()]; - securityTeam.toArray(securityDetail); - utils.destroyObjects(securityDetail); - } - } - } - public static void loadReinforcementSpawn(obj_id hq) throws InterruptedException - { - if (utils.hasScriptVar(hq, SCRIPTVAR_SPAWN_REINFORCEMENT)) - { - return; - } - String filename = utils.getTemplateFilenameNoPath(hq); - if (filename != null && !filename.equals("")) - { - if (filename.contains("_pvp")) - { - int idx = filename.indexOf("_pvp"); - if (idx >= 0) - { - filename = filename.substring(idx - 1); - } - } - obj_id reinforcementSpawner = spawnReinforcements(hq, TBL_SPAWN_EXTERIOR_PATH + filename); - if (isIdValid(reinforcementSpawner)) - { - utils.setScriptVar(hq, SCRIPTVAR_SPAWN_REINFORCEMENT, reinforcementSpawner); - } - } - } - public static obj_id spawnReinforcements(obj_id hq, String tbl) throws InterruptedException - { - if (!isIdValid(hq) || tbl == null || tbl.equals("")) - { - return null; - } - String myFac = factions.getFaction(hq); - if (myFac == null || myFac.equals("")) - { - return null; - } - location reinforcementSpawnLoc = utils.findLocInFrontOfTarget(hq, (float)(rand(30.0f, 50.0f))); - if (reinforcementSpawnLoc != null) - { - obj_id spawn = create.object(TEMPLATE_SPAWN_EGG, reinforcementSpawnLoc); - if (isIdValid(spawn)) - { - setObjVar(spawn, VAR_SPAWN_TYPE, ST_LARGE); - setObjVar(spawn, VAR_SPAWN_PARENT, hq); - setObjVar(spawn, "hq.spawn.reinforcements", 1); - factions.setFaction(spawn, myFac); - messageTo(spawn, "handleSpawnRequest", null, rand(1, 5), false); - return spawn; - } - } - return null; - } - public static void createMinefield(obj_id hq) throws InterruptedException - { - String filename = utils.getTemplateFilenameNoPath(hq); - String table = TBL_DEFENSE_PATH + "minefield.iff"; - float dx = dataTableGetFloat(table, filename, "x"); - float dz = dataTableGetFloat(table, filename, "z"); - float radius = dataTableGetFloat(table, filename, "radius"); - location here = getLocation(hq); - float yaw = getYaw(hq); - location there = player_structure.transformDeltaWorldCoord(here, dx, dz, yaw); - there.y = here.y; - obj_id minefield = createObject("object/tangible/faction_perk/faction_base_item/minefield.iff", there); - if (isIdValid(minefield)) - { - attachScript(minefield, "faction_perk.minefield.advanced_minefield"); - attachScript(minefield, SCRIPT_DEFENSE_OBJECT); - factions.setFaction(minefield, factions.getFaction(hq)); - setObjVar(minefield, "pvpCanAttack", 1); - setInvulnerable(minefield, false); - persistObject(minefield); - setObjVar(minefield, VAR_DEFENSE_PARENT, hq); - setOwner(minefield, hq); - obj_id[] data = new obj_id[1]; - data[0] = minefield; - setObjVar(hq, VAR_DEFENSE_BASE + ".minefield", data); - } - } - public static int getTotalMines(obj_id hq) throws InterruptedException - { - if (!hasObjVar(hq, "mines")) - { - return 0; - } - int[] mines = getIntArrayObjVar(hq, "mines"); - int total = 0; - if (mines == null || mines.length == 0) - { - return 0; - } - for (int mine : mines) { - total += mine; - } - return total; - } - public static float getMinefieldRadius(obj_id hq) throws InterruptedException - { - String filename = utils.getTemplateFilenameNoPath(hq); - String table = TBL_DEFENSE_PATH + "minefield.iff"; - return dataTableGetFloat(table, filename, "radius"); - } - public static int getMaxMines(obj_id hq) throws InterruptedException - { - String filename = utils.getTemplateFilenameNoPath(hq); - String table = TBL_DEFENSE_PATH + "minefield.iff"; - return dataTableGetInt(table, filename, "max"); - } - public static int getRandomMineType(obj_id hq) throws InterruptedException - { - if (!hasObjVar(hq, "mines")) - { - return -1; - } - int[] mines = getIntArrayObjVar(hq, "mines"); - if (mines == null || mines.length == 0) - { - return -1; - } - int max = getTotalMines(hq); - if (max == 0) - { - return -1; - } - int roll = rand(1, 100); - int base_chance = 0; - int type_counter = 0; - int type = -1; - while (type < 0 && type_counter < mines.length) - { - if (type_counter == (mines.length - 1)) - { - type = (mines.length - 1); - } - else - { - int chance = (int)(((float)mines[type_counter] / max) * 100.0f); - base_chance += chance; - if (roll <= base_chance) - { - type = type_counter; - } - } - type_counter++; - } - mines[type]--; - if (mines[type] < 0) - { - mines[type] = 0; - } - setObjVar(hq, "mines", mines); - return type; - } - public static void clearMinefield(obj_id hq) throws InterruptedException - { - if (!hasObjVar(hq, "mines")) - { - return; - } - int[] mines = getIntArrayObjVar(hq, "mines"); - if (mines == null || mines.length == 0) - { - return; - } - for (int i = 0; i < mines.length; i++) - { - mines[i] = 0; - } - setObjVar(hq, "mines", mines); - } - public static boolean reportHackAlarmToPlanet(obj_id hq) throws InterruptedException - { - if (!isValidId(hq)) - { - return false; - } - blog("inside reportHackAlarmToPlanet"); - String myFac = factions.getFaction(hq); - int intFac = myFac.equals("Rebel") ? gcw.FACTION_REBEL : gcw.FACTION_IMPERIAL; - blog("reportHackAlarmToPlanet " + intFac); - location baseLocation = getLocation(hq); - String planet = baseLocation.area; - if (planet == null || planet.equals("")) - { - return false; - } - blog("reportHackAlarmToPlanet " + planet); - obj_id planetId = getPlanetByName(planet); - if (!isIdValid(planetId)) - { - return false; - } - blog("reportHackAlarmToPlanet " + planetId); - String treePrefix = ".hq_"; - String treeSuffix = ""; - int maxBasesOnPlanet = gcw.getCurrentPlanetaryFactionBaseMaxPlanet(planet); - if (maxBasesOnPlanet <= 0) - { - return false; - } - blog("reportHackAlarmToPlanet " + maxBasesOnPlanet); - dictionary baseDic = new dictionary(); - if (utils.hasScriptVarTree(planetId, gcw.VAR_BASE_HACK_DICTIONARY)) - { - for (int i = 1; i < maxBasesOnPlanet; i++) - { - if (utils.hasScriptVar(planetId, gcw.VAR_BASE_HACK_DICTIONARY + treePrefix + i)) - { - baseDic = utils.getDictionaryScriptVar(planetId, gcw.VAR_BASE_HACK_DICTIONARY + treePrefix + i); - blog("reportHackAlarmToPlanet baseid: " + baseDic.getObjId("id")); - blog("reportHackAlarmToPlanet hq id: " + hq); - if (baseDic.getObjId("id") == hq) - { - return false; - } - continue; - } - treeSuffix = "" + i; - break; - } - } - else - { - treeSuffix = "1"; - } - blog("reportHackAlarmToPlanet " + treeSuffix); - dictionary baseData = new dictionary(); - baseData.put("id", hq); - baseData.put("faction", intFac); - baseData.put("location", baseLocation); - utils.setScriptVar(planetId, gcw.VAR_BASE_HACK_DICTIONARY + treePrefix + treeSuffix, baseData); - blog("reportHackAlarmToPlanet set script var: " + gcw.VAR_BASE_HACK_DICTIONARY + treePrefix + treeSuffix); - return true; - } - public static boolean cleanUpHackAlarms(obj_id hq) throws InterruptedException - { - if (!isValidId(hq)) - { - return false; - } - blog("in cleanUpHackAlarms "); - location baseLocation = getLocation(hq); - String planet = baseLocation.area; - obj_id planetId = getPlanetByName(planet); - if (!isIdValid(planetId)) - { - return false; - } - blog("cleanUpHackAlarms planet: " + planet); - blog("cleanUpHackAlarms planetId: " + planetId); - if (!utils.hasScriptVarTree(planetId, gcw.VAR_BASE_HACK_DICTIONARY)) - { - return false; - } - blog("cleanUpHackAlarms hasScriptVarTree"); - int maxBasesOnPlanet = gcw.getCurrentPlanetaryFactionBaseMaxPlanet(planet); - if (maxBasesOnPlanet <= 0) - { - return false; - } - blog("cleanUpHackAlarms hasScriptVarTree maxBasesOnPlanet: " + maxBasesOnPlanet); - String treePrefix = ".hq_"; - dictionary baseDic = new dictionary(); - for (int i = 1; i < maxBasesOnPlanet; i++) - { - baseDic = utils.getDictionaryScriptVar(planetId, gcw.VAR_BASE_HACK_DICTIONARY + treePrefix + i); - if (baseDic == null) - { - blog("cleanUpHackAlarms hasScriptVarTree baseDic: " + baseDic); - return false; - } - else if (baseDic.getObjId("id") != hq) - { - continue; - } - utils.removeScriptVar(planetId, gcw.VAR_BASE_HACK_DICTIONARY + treePrefix + i); - blog("cleanUpHackAlarms removeScriptVar: " + gcw.VAR_BASE_HACK_DICTIONARY + treePrefix + i); - } - return true; - } - public static boolean blog(String msg) throws InterruptedException - { - return true; - } -}