mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-04 04:15:52 -04:00
WIP: all ship tests are complete - battle types as well - pre-system test.
This commit is contained in:
+458
-395
File diff suppressed because it is too large
Load Diff
@@ -19,9 +19,9 @@ keyan_farlander object/mobile/keyan_farlander.iff xwing_tier9 ace_rebel_keyan_fa
|
||||
pash_cracken object/mobile/pash_cracken.iff awing_tier9 ace_rebel_pash_cracken space/taunts/ace_reb_generic2 3 rebel
|
||||
soontir_fel object/mobile/soontir_fel.iff tieinterceptor_tier9 ace_imperial_soontir_fel space/taunts/ace_imp_fel 3 imperial
|
||||
tarrin_datch object/mobile/tarrin_datch.iff xwing_tier9 ace_rebel_tarrin_datch space/taunts/ace_reb_generic 3 rebel
|
||||
turr_phennir object/mobile/turr_phennir.iff tiefighter_tier8 ace_imperial_turr_phennir space/taunts/ace_imp_generic2 2 imperial
|
||||
turr_phennir object/mobile/turr_phennir.iff tieaggressor_tier8 ace_imperial_turr_phennir space/taunts/ace_imp_generic2 2 imperial
|
||||
tyber_zann object/mobile/tyber_zann.iff kimogilla_s02_tier9 ace_neutral_tyber_zann space/taunts/ace_neutral_generic2 2 neutral
|
||||
tycho_celchu object/mobile/tycho_celchu.iff awing_tier9 ace_rebel_tycho_celchu space/taunts/ace_reb_generic2 2 rebel
|
||||
tycho_celchu object/mobile/tycho_celchu.iff xwing_tier8 ace_rebel_tycho_celchu space/taunts/ace_reb_generic2 2 rebel
|
||||
vindoo_barvel object/mobile/vindoo_barvel.iff tiefighter_tier8 ace_imperial_vindoo_barvel space/taunts/ace_imp_generic2 2 imperial
|
||||
zardra object/mobile/zardra.iff dunelizard_s02_tier9 ace_neutral_zardra space/taunts/ace_neutral_generic 2 neutral
|
||||
mara_jade object/mobile/mara_jade.iff tieadvanced_tier9 ace_imperial_mara_jade space/taunts/ace_imp_marajade 3 imperial
|
||||
|
||||
Regular → Executable
+1
@@ -595,3 +595,4 @@ object/tangible/space/content_infrastructure/basic_patrol_point.iff -0.202991 0.
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff -0.202991 0.965038 0.165820 -0.961370 -0.228573 0.153372 1488.72 1562.78 -3194.32 strName|4|rebel_gunboat_patrol_03_03|$|
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff -0.202991 0.965038 0.165820 -0.961370 -0.228573 0.153372 48.72 7162.78 -5626.32 strName|4|rebel_gunboat_patrol_03_04|$|
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff -0.202991 0.965038 0.165820 -0.961370 -0.228573 0.153372 -2863.28 5850.78 -5738.32 strName|4|rebel_gunboat_patrol_03_05|$|
|
||||
object/tangible/space/content_infrastructure/space_gcw_battle_point.iff 0.484332 -0.747792 -0.454126 0.016503 0.526786 -0.849838 1200.0 3000.0 5500.0 strName|4|corellian_gcw_battle|$|
|
||||
|
||||
Regular → Executable
+1
@@ -1406,3 +1406,4 @@ object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.902661 -0.
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.890738 -0.156573 -0.426697 -0.439393 -0.056474 -0.896518 1427.69 -939.59 -2225.18 strName|4|mining_route_1_07|$|
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.510280 -0.269551 -0.816674 -0.572267 0.602431 -0.556406 1382.94 -895.20 -2277.41 strName|4|mining_route_1_08|$|
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.360168 -0.130056 -0.923777 0.278442 0.960084 -0.026607 1352.59 -767.10 -2311.27 strName|4|mining_route_1_09|$|
|
||||
object/tangible/space/content_infrastructure/space_gcw_battle_point.iff 0.484332 -0.747792 -0.454126 0.016503 0.526786 -0.849838 2700.0 4400.0 -2800.0 strName|4|tatoo_gcw_battle|$|
|
||||
|
||||
Regular → Executable
+1
@@ -681,3 +681,4 @@ object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.075949 0.9
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.451617 0.892205 0.003489 -0.846408 0.427192 0.317964 1272.35 -6135.08 -7037.98 strName|4|trade_fed_station_patrol_12|$|
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.509398 0.860225 -0.022960 -0.744418 0.453892 0.489719 436.41 -5653.30 -6579.18 strName|4|trade_fed_station_patrol_13|$|
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.528843 0.848108 -0.032223 -0.726480 0.471978 0.499463 -1373.58 -4465.47 -5356.12 strName|4|trade_fed_station_patrol_14|$|
|
||||
object/tangible/space/content_infrastructure/space_gcw_battle_point.iff 0.484332 -0.747792 -0.454126 0.016503 0.526786 -0.849838 2933.0 473.0 -1450.0 strName|4|karthak_gcw_battle|$|
|
||||
|
||||
Regular → Executable
+1
@@ -1143,3 +1143,4 @@ object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.229852 0.8
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.271674 0.896994 0.348704 0.569279 0.142360 -0.809726 371.17 1057.37 -1805.24 strName|4|commerce_route_1_02|$|
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.271674 0.896994 0.348704 0.569279 0.142360 -0.809726 785.85 1161.08 -2395.07 strName|4|commerce_route_1_03|$|
|
||||
object/tangible/space/content_infrastructure/basic_patrol_point.iff 0.271674 0.896994 0.348704 0.569279 0.142360 -0.809726 987.24 1211.45 -2681.53 strName|4|commerce_route_1_04|$|
|
||||
object/tangible/space/content_infrastructure/space_gcw_battle_point.iff 0.484332 -0.747792 -0.454126 0.016503 0.526786 -0.849838 -5032.0 -3958.0 4345.0 strName|4|naboo_gcw_battle|$|
|
||||
|
||||
@@ -4122,13 +4122,14 @@ public class space_combat extends script.base_script
|
||||
float[] fltRefire = dataTableGetFloatColumn(strFileName, "fltRefire");
|
||||
float[] fltDrain = dataTableGetFloatColumn(strFileName, "fltDrain");
|
||||
float[] fltShieldEfficiency = dataTableGetFloatColumn(strFileName, "fltShieldEfficiency");
|
||||
boolean targetable = !strDefinition.equals("imperial_lancer") && !strDefinition.equals("nebulon_frigate");
|
||||
for (int intI = 0; intI < strSlots.length; intI++)
|
||||
{
|
||||
if (intComponents[intI] != 0)
|
||||
{
|
||||
int intSlot = space_crafting.getComponentSlotInt(strSlots[intI]);
|
||||
if (shipPseudoInstallComponent(objShip, intSlot, intComponents[intI])) {
|
||||
setShipSlotTargetable(objShip, intSlot, true);
|
||||
setShipSlotTargetable(objShip, intSlot, targetable);
|
||||
setShipComponentArmorHitpointsMaximum(objShip, intSlot, fltArmorHitpoints[intI]);
|
||||
setShipComponentArmorHitpointsCurrent(objShip, intSlot, fltArmorHitpoints[intI]);
|
||||
setShipComponentHitpointsMaximum(objShip, intSlot, fltComponentHitpoints[intI]);
|
||||
|
||||
@@ -720,6 +720,7 @@ public class space_utils extends script.base_script
|
||||
if (crew != null)
|
||||
{
|
||||
_crew = new obj_id[crew.size()];
|
||||
crew.toArray(_crew);
|
||||
}
|
||||
return _crew;
|
||||
}
|
||||
|
||||
@@ -156,6 +156,9 @@ public class combat_ship extends script.base_script
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if(hasObjVar(self, "intPvPDamageOnly") && space_utils.isPlayerControlledShip(objAttacker) && !(pvpGetType(objAttacker) == PVPTYPE_DECLARED)){
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!isShipSlotTargetable(self, intTargetedComponent))
|
||||
{
|
||||
intTargetedComponent = space_combat.SHIP;
|
||||
@@ -228,6 +231,10 @@ public class combat_ship extends script.base_script
|
||||
fltRemainingDamage = space_combat.doArmorDamage(objAttacker, self, intWeaponSlot, fltRemainingDamage, intSide);
|
||||
if (fltRemainingDamage > 0)
|
||||
{
|
||||
// this case prevents a player from doing component or chassis damage during a space GCW fight.
|
||||
if(space_utils.isPlayerControlledShip(objAttacker) && hasScript(self, "systems.gcw.space.capital_ship")){
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (bossShip && !utils.hasScriptVar(self, "armorDepleted"))
|
||||
{
|
||||
messageTo(self, "armorDepleted", null, 0f, false);
|
||||
|
||||
@@ -2692,6 +2692,7 @@ public class combat_ship_player extends script.base_script
|
||||
String scene = zone == null ? getCurrentSceneName() : "space_" + zone;
|
||||
|
||||
String lastBattleType = battle_controller.getLastBattleType(scene);
|
||||
String currentBattleType = battle_controller.getCurrentBattleType(scene);
|
||||
int secondsUntilNextBattle = battle_controller.getTimeUntilNextBattleForZone(scene);
|
||||
String sys = getSpaceSystemName(scene.substring(6));
|
||||
|
||||
@@ -2700,12 +2701,12 @@ public class combat_ship_player extends script.base_script
|
||||
return;
|
||||
}
|
||||
else if(secondsUntilNextBattle == -2){
|
||||
sendSystemMessage(self, "There is currently a GCW Space Battle for the " + sys + " System in progress,", null);
|
||||
sendSystemMessage(self, "There is currently a GCW Space Battle for the " + sys + " System in progress.", null);
|
||||
return;
|
||||
}
|
||||
sendSystemMessage(self, "The next battle scheduled to take place in the " + sys + " System will start in " + getBattleTimeString(secondsUntilNextBattle), null);
|
||||
if(lastBattleType.equals(battle_spawner.BATTLE_TYPE_PVE))
|
||||
sendSystemMessage(self, "The battle wil require you to be Special Forces to participate", null);
|
||||
if(lastBattleType.equals(battle_spawner.BATTLE_TYPE_PVE) || currentBattleType.equals(battle_spawner.BATTLE_TYPE_PVP))
|
||||
sendSystemMessage(self, "The battle will require you to be Special Forces to participate", null);
|
||||
}
|
||||
|
||||
private String getSpaceSystemName(String zone) {
|
||||
|
||||
@@ -129,11 +129,15 @@ public class battle_controller extends script.base_script {
|
||||
|
||||
dictionary battleDetails = new dictionary();
|
||||
String battleType = getStringObjVar(self, "space_gcw." + spawner + ".lastBattleType");
|
||||
if(battleType != null && battleType.equals(battle_spawner.BATTLE_TYPE_PVE)) {
|
||||
battleType = battle_spawner.BATTLE_TYPE_PVP;
|
||||
if(battleType != null) {
|
||||
if (battleType.equals(battle_spawner.BATTLE_TYPE_PVE)) {
|
||||
battleType = battle_spawner.BATTLE_TYPE_PVP;
|
||||
} else {
|
||||
battleType = battle_spawner.BATTLE_TYPE_PVE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
battleType = battle_spawner.BATTLE_TYPE_PVE;
|
||||
else{
|
||||
battleType = scene[1];
|
||||
}
|
||||
battleDetails.put("battle_type", battleType);
|
||||
battleDetails.put("controller", self);
|
||||
@@ -141,7 +145,7 @@ public class battle_controller extends script.base_script {
|
||||
setObjVar(self, "space_gcw." + spawner + ".lastBattleType", battleType);
|
||||
|
||||
if(secondsUntilNextBattle == 0){
|
||||
LOG("space_gcw", "battle_controller.checkBattleStatus: The space battle sequencer object is starting a " + scene[1]+ " battle in zone " + scene[0] + " for the first time.");
|
||||
LOG("space_gcw", "battle_controller.checkBattleStatus: The space battle sequencer object is starting a " + scene[1] + " battle in zone " + scene[0] + " for the first time.");
|
||||
}
|
||||
else {
|
||||
LOG("space_gcw", "battle_controller.checkBattleStatus: The space battle sequencer is not starting a battle in zone " + scene[0] + " because it has " + String.format("%.0f", secondsUntilNextBattle / 60.0f) + " minutes until the next battle.");
|
||||
@@ -306,4 +310,29 @@ public class battle_controller extends script.base_script {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
/*
|
||||
* Helper method for command:
|
||||
* /spaceBattleStatus <zone>
|
||||
*
|
||||
* Method to get the current battle type (PvP or PvE) for the given zone.
|
||||
*
|
||||
*/
|
||||
public static String getCurrentBattleType(String zone){
|
||||
obj_id controller = getPlanetByName("tatooine");
|
||||
for (String[] scene : battle_controller.BATTLE_SCENES) {
|
||||
if (scene[0].equals(zone)) {
|
||||
obj_id spawner = getObjIdObjVar(controller, "space_gcw." + scene[0] + ".spawner");
|
||||
if (hasObjVar(spawner, "battle_type")) {
|
||||
return getStringObjVar(spawner, "battle_type");
|
||||
}
|
||||
else if (scene[1].equals(battle_spawner.BATTLE_TYPE_PVE)) {
|
||||
return battle_spawner.BATTLE_TYPE_PVE;
|
||||
}
|
||||
else {
|
||||
return battle_spawner.BATTLE_TYPE_PVP;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,15 @@ import script.library.*;
|
||||
import java.util.*;
|
||||
|
||||
public class battle_spawner extends script.base_class {
|
||||
private static final boolean debug = true;
|
||||
public static final String CONTROLLER_SCRIPT = "systems.gcw.space.battle_controller";
|
||||
public static final String IMPERIAL_SHIP_TEMPLATE = "imperial_lancer";
|
||||
public static final String REBEL_SHIP_TEMPLATE = "nebulon_frigate";
|
||||
public static final String IMPERIAL_STATION_TEMPLATE = "spacestation_imperial";
|
||||
public static final String REBEL_STATION_TEMPLATE = "spacestation_rebel";
|
||||
private static final String HERO_PILOT_DATA = "datatables/npc/space/space_gcw_hero.iff";
|
||||
public static float BATTLE_TIME_PREPATORY = 900.0f; // 900 == 15 minutes
|
||||
public static float BATTLE_TIME_LENGTH = 180.0f; // 3600 == 60 minutes
|
||||
public static float DEFAULT_BATTLE_TIME_PREPATORY = 900.0f; // 900 == 15 minutes
|
||||
public static float DEFAULT_BATTLE_TIME_LENGTH = 3600.0f; // 3600 == 60 minutes
|
||||
public static float MAX_SUPPORT_CRAFT = 30;
|
||||
public static final double HERO_SPAWN_CHANCE = 0.05d; // 0.20f == 20% chance a hero will spawn
|
||||
public static float MAX_SUPPORT_SPAWN = 60;
|
||||
public static final double HERO_SPAWN_CHANCE = 0.20d; // 0.20d == 20% chance a hero will spawn
|
||||
public static final float DEFAULT_PVP_POINT_MULTIPLIER = 2.0f;
|
||||
public static final float DEFAULT_PVE_POINT_MULTIPLIER = 1.0f;
|
||||
public static final float DEFAULT_PVP_TOKEN_MULTIPLIER = 2.0f;
|
||||
@@ -87,6 +85,8 @@ public class battle_spawner extends script.base_class {
|
||||
public int gunshipPlayerCeiling;
|
||||
public int customTokenAward;
|
||||
public int customPointAward;
|
||||
public float battleTimeLength;
|
||||
public float prepatoryTimeLength;
|
||||
|
||||
// This script is the spawner for the Space GCW (GCW 2) battles.
|
||||
// It uses Tatooine to track battles (the controller) and places the following object vars
|
||||
@@ -95,7 +95,6 @@ public class battle_spawner extends script.base_class {
|
||||
// space_gcw.<zone>.active = <0, 1> -- <zone> is the space zone, 0 means inactive, 1 means active
|
||||
// space_gcw.participant.<battle_id>.<participant> -- <battle_id> is the battle identifier, <participant> is the obj id of the player.
|
||||
|
||||
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "registerWithController", null, 30.0f, false);
|
||||
@@ -140,17 +139,29 @@ public class battle_spawner extends script.base_class {
|
||||
// spawn defender capital ship
|
||||
transform defenseSpawnPoint = transform.identity.setPosition_p(spaceLocation.x, spaceLocation.y, spaceLocation.z);
|
||||
obj_id defendingShip;
|
||||
|
||||
if(defendingFaction.equalsIgnoreCase("imperial")){
|
||||
defendingShip = space_create.createShipHyperspace(IMPERIAL_SHIP_TEMPLATE, defenseSpawnPoint);
|
||||
setObjVar(self, "defendingFaction", "imperial");
|
||||
setObjVar(self, "attackingFaction", "rebel");
|
||||
}
|
||||
else{
|
||||
defendingShip = space_create.createShipHyperspace(REBEL_SHIP_TEMPLATE, defenseSpawnPoint);
|
||||
setObjVar(self, "defendingFaction", "rebel");
|
||||
setObjVar(self, "attackingFaction", "imperial");
|
||||
}
|
||||
LOG("space_gcw", "In startSpaceGCWBattle... just created defending ship(" + defendingShip + ").");
|
||||
setObjVar(defendingShip, "intNoPlayerDamage", 1);
|
||||
if(params.getString("battle_type").equals(BATTLE_TYPE_PVP)){
|
||||
setObjVar(defendingShip, "intPvPDamageOnly",1);
|
||||
}
|
||||
setObjVar(defendingShip, "role", "defense");
|
||||
setObjVar(defendingShip, "spawner", self);
|
||||
setObjVar(self, "defendingShip", defendingShip);
|
||||
attachScript(defendingShip, "systems.gcw.space.capital_ship");
|
||||
|
||||
makeComponentsUntargetable(defendingShip);
|
||||
|
||||
// create configuration parameters that will be used throughout battle.
|
||||
params.put("controller", controller);
|
||||
params.put("defendingFaction", defendingFaction);
|
||||
@@ -158,12 +169,20 @@ public class battle_spawner extends script.base_class {
|
||||
params.put("defendingShip", defendingShip);
|
||||
|
||||
// spawn attacking capital ship
|
||||
if(debug) BATTLE_TIME_PREPATORY = 120.0f;
|
||||
LOG("space_gcw", "In startSpaceGCWBattle... starting battle in " + BATTLE_TIME_PREPATORY / 60.0f + " minutes.");
|
||||
messageTo(self, "spawnAttack", params, BATTLE_TIME_PREPATORY, false);
|
||||
LOG("space_gcw", "In startSpaceGCWBattle... starting battle in " + prepatoryTimeLength / 60.0f + " minutes.");
|
||||
messageTo(self, "spawnAttack", params, prepatoryTimeLength, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void makeComponentsUntargetable(obj_id ship) {
|
||||
LOG("space_gcw", "In makeComponentsUntargetable... now starting to disable component targeting for (" + ship + ").");
|
||||
int[] shipChassisSlots = getShipChassisSlots(ship);
|
||||
for (int shipChassisSlot : shipChassisSlots) {
|
||||
if (isShipSlotInstalled(ship, shipChassisSlot)) {
|
||||
setShipSlotTargetable(ship, shipChassisSlot, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
public int spawnAttack(obj_id self, dictionary params) throws InterruptedException {
|
||||
LOG("space_gcw", "In spawnAttack... beginning to spawn attack craft.");
|
||||
// get spawn point for the attacker ship - defaults to 2500 m away from battle point (use pythag theorum, a2 + b2 = c2 where c == 2500 and b == 1000)
|
||||
@@ -180,11 +199,18 @@ public class battle_spawner extends script.base_class {
|
||||
LOG("space_gcw", "In spawnAttack... just created attack capital ship (" + REBEL_SHIP_TEMPLATE + ":" + attackingShip + ").");
|
||||
params.put("attackingFaction", "rebel");
|
||||
}
|
||||
if(params.getString("battle_type").equals(BATTLE_TYPE_PVP)){
|
||||
setObjVar(attackingShip, "intPvPDamageOnly",1);
|
||||
}
|
||||
removeObjVar(params.getObjId("defendingShip"), "intNoPlayerDamage");
|
||||
setObjVar(attackingShip, "role", "attack");
|
||||
setObjVar(attackingShip, "spawner", self);
|
||||
setObjVar(self, "attackingShip", attackingShip);
|
||||
attachScript(attackingShip, "systems.gcw.space.capital_ship");
|
||||
params.put("attackingShip", attackingShip);
|
||||
|
||||
makeComponentsUntargetable(attackingShip);
|
||||
|
||||
// define the path
|
||||
transform[] flightPath = {
|
||||
transform.identity.setPosition_p(battleLocation.x - 925.0f, battleLocation.y, battleLocation.z - 1500.0f),
|
||||
@@ -199,7 +225,7 @@ public class battle_spawner extends script.base_class {
|
||||
messageTo(self, "spawnSupportCraft", params, 20.0f, false);
|
||||
|
||||
// set timer to keep track of battle time - set config value for length of battle
|
||||
messageTo(self, "endBattle", params, BATTLE_TIME_LENGTH, false);
|
||||
messageTo(self, "endBattle", params, battleTimeLength, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -232,6 +258,12 @@ public class battle_spawner extends script.base_class {
|
||||
return getIntObjVar(controller, "space_gcw." + self.toString() + ".active") == 0;
|
||||
}
|
||||
public static Vector spawnSupportShips(obj_id motherShip) throws InterruptedException{
|
||||
int totalSpawnedThisFight = 0;
|
||||
if(hasObjVar(motherShip, "totalSpawnedSupportCraft")){
|
||||
totalSpawnedThisFight = getIntObjVar(motherShip, "totalSpawnedSupportCraft");
|
||||
if(totalSpawnedThisFight >= MAX_SUPPORT_SPAWN)
|
||||
return getResizeableObjIdArrayObjVar(motherShip, "supportCraft");
|
||||
}
|
||||
String[] support_ship_types;
|
||||
String[] hero_pilots;
|
||||
if(shipGetSpaceFaction(motherShip) == 370444368){
|
||||
@@ -254,7 +286,7 @@ public class battle_spawner extends script.base_class {
|
||||
obj_id ship;
|
||||
|
||||
for (int i = shipList.size(); i < MAX_SUPPORT_CRAFT; i++) {
|
||||
if (heroSpawned || Math.random() < HERO_SPAWN_CHANCE) {
|
||||
if (heroSpawned || Math.random() > HERO_SPAWN_CHANCE) {
|
||||
ship = createUnit(motherShip, support_ship_types[rand(0, support_ship_types.length - 1)], 200.0f);
|
||||
attachScript(ship, "systems.gcw.space.support_ship");
|
||||
setObjVar(ship, "motherShip", motherShip);
|
||||
@@ -275,9 +307,14 @@ public class battle_spawner extends script.base_class {
|
||||
heroSpawned = true;
|
||||
LOG("space_gcw", "In spawnSupportShips... just spawned a hero ship (" + ship + ":" + pilot.getString("hero_name") + ") #" + (i+1) + " / " + MAX_SUPPORT_CRAFT + " ships.");
|
||||
}
|
||||
|
||||
transform[] trPatrolPoints = ship_ai.createPatrolPathLoiter(getTransform_o2p(motherShip), 500.0f, 1000.0f);
|
||||
ship_ai.spacePatrol(ship, trPatrolPoints);
|
||||
totalSpawnedThisFight++;
|
||||
shipList.add(ship);
|
||||
}
|
||||
LOG("space_gcw", "Returning array of ships of size " + shipList.size());
|
||||
setObjVar(motherShip, "totalSpawnedSupportCraft", totalSpawnedThisFight);
|
||||
return shipList;
|
||||
}
|
||||
private static dictionary choosePilot(String[] pilots){
|
||||
@@ -312,7 +349,6 @@ public class battle_spawner extends script.base_class {
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int endBattle(obj_id self, dictionary params) throws InterruptedException {
|
||||
obj_id controller = getObjIdObjVar(self, "controller");
|
||||
LOG("space_gcw", "In endBattle... ending the battle.");
|
||||
|
||||
if(!params.containsKey("destroyedShip")){
|
||||
@@ -320,6 +356,7 @@ public class battle_spawner extends script.base_class {
|
||||
params.put("destroyedShip", params.getObjId("attackingShip"));
|
||||
params.put("losingFaction", params.getString("attackingFaction"));
|
||||
params.put("losingRole", "attack");
|
||||
params.put("supportCraft", getResizeableObjIdArrayObjVar(params.getObjId("destroyedShip"), "supportCraft"));
|
||||
}
|
||||
else{
|
||||
LOG("space_gcw", "In endBattle... reason - " + params.getString("losingFaction") + " " + params.getString("losingRole") + " capital ship destroyed.");
|
||||
@@ -332,94 +369,72 @@ public class battle_spawner extends script.base_class {
|
||||
public void distributeAwards(obj_id self, dictionary params) throws InterruptedException {
|
||||
LOG("space_gcw", "In distributeAwards... distributing the awards to the participants.");
|
||||
String battleType = getStringObjVar(self, "battle_type");
|
||||
obj_id controller = getObjIdObjVar(self, "controller");
|
||||
String battleId = getStringObjVar(self, "battle_id");
|
||||
|
||||
String losingFaction = params.getString("losingFaction");
|
||||
String winningFaction = params.getString("losingFaction").equals("imperial") ? "imperial" : "rebel";
|
||||
boolean imperialsWon = !losingFaction.equals("imperial");
|
||||
obj_id destroyedShip = params.getObjId("destroyedShip");
|
||||
String shipTemplate = getTemplateName(destroyedShip);
|
||||
boolean shipWasDefending = getStringObjVar(destroyedShip, "role").equals("defense");
|
||||
String shipType;
|
||||
String attackingFaction = !shipWasDefending ? losingFaction : winningFaction;
|
||||
switch (shipTemplate) {
|
||||
case "object/ship/imperial_lancer.iff":
|
||||
case "object/ship/nebulon_frigate.iff":
|
||||
shipType = " capital ship";
|
||||
break;
|
||||
case "object/ship/spacestation_imperial.iff":
|
||||
case "object/ship/spacestation_rebel.iff":
|
||||
shipType = " Space Station";
|
||||
break;
|
||||
default:
|
||||
shipType = " Hulking Behemoth";
|
||||
}
|
||||
String shipType = " capital ship";
|
||||
String attackingFaction = getStringObjVar(self, "attackingFaction");
|
||||
|
||||
// keep track of players already awarded.
|
||||
List<obj_id> pointAwardedPlayers = new ArrayList<>();
|
||||
|
||||
// get all single-member participants in this battle.
|
||||
obj_var_list participants = getObjVarList(self, "space_gcw.participant." + battleId);
|
||||
if(participants == null || participants.getNumItems() == 0){
|
||||
LOG("space_gcw", "In distributeAwards... no participants were found for battle " + battleId);
|
||||
return;
|
||||
}
|
||||
|
||||
int numParticipants = participants.getNumItems();
|
||||
|
||||
attackingFaction = attackingFaction.equals("imperial") ? "Imperial" : "Rebel";
|
||||
|
||||
// TODO: Add check for multi-pilot non POB/GUNSHIP participants (i.e. Havoc and Wookiee ship)
|
||||
|
||||
LOG("space_gcw", "In distributeAwards... now checking single pilot participants.");
|
||||
// distribute to single pilots (non-pob or gunship)
|
||||
for (int i = 0; i < numParticipants; i++) {
|
||||
obj_var participantVar = participants.getObjVar(i);
|
||||
if (participantVar == null) continue;
|
||||
obj_id player = obj_id.getObjId(Long.parseLong(participantVar.getName()));
|
||||
|
||||
// if player is not in the same system, continue on to the next player (no soup for YOU!)
|
||||
if (!getLocation(player).area.equals(getLocation(self).area)) continue;
|
||||
handlePlayerAwards(player, attackingFaction, imperialsWon, shipType, battleType, battleId, 1);
|
||||
pointAwardedPlayers.add(player);
|
||||
}
|
||||
|
||||
LOG("space_gcw", "In distributeAwards... now checking POB participants.");
|
||||
LOG("space_gcw", "In distributeAwards... now checking single ship participants.");
|
||||
// distribute to pob qualifiers
|
||||
pointAwardedPlayers.addAll(
|
||||
processMultiPassengerShip(
|
||||
getObjVarList(controller, "space_gcw.pob.participant." + battleId),
|
||||
pobPlayerCeiling,
|
||||
self,
|
||||
pointAwardedPlayers,
|
||||
attackingFaction,
|
||||
imperialsWon,
|
||||
shipType,
|
||||
battleType,
|
||||
battleId
|
||||
)
|
||||
processShip(
|
||||
getObjVarList(self, "space_gcw.participant." + battleId),
|
||||
pobPlayerCeiling,
|
||||
self,
|
||||
pointAwardedPlayers,
|
||||
attackingFaction,
|
||||
imperialsWon,
|
||||
shipType,
|
||||
battleType,
|
||||
battleId
|
||||
)
|
||||
);
|
||||
|
||||
LOG("space_gcw", "In distributeAwards... now checking gunship participants.");
|
||||
// distribute to gunship qualifiers
|
||||
pointAwardedPlayers.addAll(
|
||||
processMultiPassengerShip(
|
||||
getObjVarList(controller, "space_gcw.gunship.participant." + battleId),
|
||||
gunshipPlayerCeiling,
|
||||
self,
|
||||
pointAwardedPlayers,
|
||||
attackingFaction,
|
||||
imperialsWon,
|
||||
shipType,
|
||||
battleType,
|
||||
battleId
|
||||
)
|
||||
processShip(
|
||||
getObjVarList(self, "space_gcw.gunship.participant." + battleId),
|
||||
gunshipPlayerCeiling,
|
||||
self,
|
||||
pointAwardedPlayers,
|
||||
attackingFaction,
|
||||
imperialsWon,
|
||||
shipType,
|
||||
battleType,
|
||||
battleId
|
||||
)
|
||||
);
|
||||
|
||||
LOG("space_gcw", "In distributeAwards... now checking POB participants.");
|
||||
// distribute to pob qualifiers
|
||||
processShip(
|
||||
getObjVarList(self, "space_gcw.pob.participant." + battleId),
|
||||
pobPlayerCeiling,
|
||||
self,
|
||||
pointAwardedPlayers,
|
||||
attackingFaction,
|
||||
imperialsWon,
|
||||
shipType,
|
||||
battleType,
|
||||
battleId
|
||||
);
|
||||
}
|
||||
public List<obj_id> processMultiPassengerShip(obj_var_list qualifiedShips, int playerCeiling, obj_id self, List<obj_id> pointAwardedPlayers, String attackingFaction, boolean imperialsWon, String shipType, String battleType, String battleId) throws InterruptedException{
|
||||
if(qualifiedShips == null || qualifiedShips.getNumItems() == 0) return Collections.EMPTY_LIST;
|
||||
public List<obj_id> processShip(obj_var_list qualifiedShips, int playerCeiling, obj_id self, List<obj_id> pointAwardedPlayers, String attackingFaction, boolean imperialsWon, String shipType, String battleType, String battleId) throws InterruptedException{
|
||||
LOG("space_gcw", "In processShip... now checking ship participants.");
|
||||
if(qualifiedShips == null || qualifiedShips.getNumItems() == 0){
|
||||
LOG("space_gcw", "In processShip... no participating ships of this type were found.");
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
int numQualifiedShips = qualifiedShips.getNumItems();
|
||||
LOG("space_gcw", "In processShip... processing " + numQualifiedShips + " ships.");
|
||||
|
||||
// iterate through all qualified ships
|
||||
for(int i = 0; i < numQualifiedShips; i++){
|
||||
@@ -427,24 +442,37 @@ public class battle_spawner extends script.base_class {
|
||||
if(shipObjVar == null) continue;
|
||||
|
||||
obj_id ship = obj_id.getObjId(Long.parseLong(shipObjVar.getName()));
|
||||
LOG("space_gcw", "In processShip... now processing ship " + ship + ".");
|
||||
|
||||
// make sure this ship is still in the game.
|
||||
if(!isValidId(ship)) continue;
|
||||
List<obj_id> currentShipMembers = Arrays.asList(space_utils.getAllPlayersInShip(ship));
|
||||
if(!isValidId(ship)){
|
||||
LOG("space_gcw", "In processShip... ship " + ship + " is no longer valid (destroyed? zoned out?) so skipping.");
|
||||
continue;
|
||||
}
|
||||
obj_id[] currentShipMembers = space_utils.getAllPlayersInShip(ship);
|
||||
int playerCount = currentShipMembers.length;
|
||||
// make sure players are still on this ship.
|
||||
if(currentShipMembers.size() == 0) continue;
|
||||
if(playerCount == 0){
|
||||
LOG("space_gcw", "In processShip... no valid players were found on this ship.");
|
||||
continue;
|
||||
}
|
||||
LOG("space_gcw", "In processShip... found " + playerCount + " player(s) on board ship " + ship + ".");
|
||||
|
||||
// if pob is not in the same system, continue on to the next gunship (no soup for YOU!)
|
||||
if(!getLocation(ship).area.equals(getLocation(self).area)) continue;
|
||||
|
||||
obj_id[] players = shipObjVar.getObjIdArrayData();
|
||||
int playerCount = 0;
|
||||
for(obj_id player : players){
|
||||
if(currentShipMembers.contains(player)) playerCount++;
|
||||
if(!getLocation(ship).area.equals(getLocation(self).area)){
|
||||
LOG("space_gcw", "In processShip... ship " + ship + " is no longer in the same zone as the space battle - skipping.");
|
||||
continue;
|
||||
}
|
||||
for(obj_id player : players){
|
||||
// make sure player is still in the ship and not somewhere else (i.e. their own ship) and make sure they haven't been given anything yet.
|
||||
if(!currentShipMembers.contains(player) || pointAwardedPlayers.contains(player)) continue;
|
||||
|
||||
LOG("space_gcw", "In processShip... now processing " + playerCount + " VALID players on board ship " + ship + " (i.e. not ejected, still on board ship, etc).");
|
||||
for(obj_id player : currentShipMembers){
|
||||
if(!factions.isImperialorImperialHelper(player) && !factions.isRebelorRebelHelper(player)) continue;
|
||||
LOG("space_gcw", "In processShip... now processing player " + player + ".");
|
||||
// make sure the player haven't been given anything yet.
|
||||
if(pointAwardedPlayers.contains(player)){
|
||||
LOG("space_gcw", "In processShip... player " + player + " has already been granted awards for this battle - skipping.");
|
||||
continue;
|
||||
}
|
||||
float pointAdjustment = (playerCount > playerCeiling ? playerCeiling / playerCount : 1);
|
||||
handlePlayerAwards(player, attackingFaction, imperialsWon, shipType, battleType, battleId, pointAdjustment);
|
||||
pointAwardedPlayers.add(player);
|
||||
@@ -454,8 +482,8 @@ public class battle_spawner extends script.base_class {
|
||||
}
|
||||
public void handlePlayerAwards(obj_id player, String attackingFaction, boolean imperialsWon, String shipType, String battleType, String battleId, float pointAdjustmentValue) throws InterruptedException {
|
||||
LOG("space_gcw", "In handlePlayerAwards... now awarding GCW points.");
|
||||
boolean playerIsImperial = factions.isImperial(player);
|
||||
boolean playerWasAttacking = (playerIsImperial && attackingFaction.equals("Imperial")) || (!playerIsImperial && attackingFaction.equals("Rebel"));
|
||||
boolean playerIsImperial = factions.isImperialorImperialHelper(player);
|
||||
boolean playerWasAttacking = (playerIsImperial && attackingFaction.equals("imperial")) || (factions.isRebelorRebelHelper(player) && attackingFaction.equals("rebel"));
|
||||
boolean playerWon = (playerIsImperial && imperialsWon) ||
|
||||
(!playerIsImperial && !imperialsWon);
|
||||
|
||||
@@ -521,15 +549,9 @@ public class battle_spawner extends script.base_class {
|
||||
// rebel attack win: "You have successfully aided in destroying the Imperial capital ship."
|
||||
// rebel attack loss: "You have failed to destroy the Imperial capital ship."
|
||||
|
||||
// the following messages are for the space station/capital ship battles only.
|
||||
// the following messages are for the capital ship battles only.
|
||||
// imperial defense win: same as cap v cap
|
||||
// rebel defense win: same as cap v cap
|
||||
// imperial defense loss: "You have failed to defend the Imperial Space Station from the Rebel attack force."
|
||||
// rebel defense loss: "You have failed to defend the Rebel Space Station from the Imperial attack force."
|
||||
// imperial attack win: "You have successfully aided in destroying the Rebel Space Station."
|
||||
// rebel attack win: "You have successfully aided in destroying the Imperial Space Station."
|
||||
// imperial attack loss: "You have failed to destroy the Rebel Space Station"
|
||||
// rebel attack loss: "You have failed to destroy the Imperial Space Station."
|
||||
|
||||
StringBuilder msg = new StringBuilder(playerWon ? "You have successfully" : "You have failed");
|
||||
msg.append(playerWasAttacking ? (playerWon ? " aided in destroying the " : " to destroy the ") : (playerWon ? " helped defend the " : " to defend the "));
|
||||
@@ -596,7 +618,13 @@ public class battle_spawner extends script.base_class {
|
||||
LOG("space_gcw", "In cleanup... attacking ship is (" + attackingShip + ") and defending ship is (" + defendingShip + ").");
|
||||
|
||||
LOG("space_gcw", "In cleanup... despawning attack support craft...");
|
||||
Vector supportShips = getResizeableObjIdArrayObjVar(attackingShip, "supportCraft");
|
||||
Vector supportShips;
|
||||
if(isValidId(attackingShip)) {
|
||||
supportShips = getResizeableObjIdArrayObjVar(attackingShip, "supportCraft");
|
||||
}
|
||||
else{
|
||||
supportShips = params.getResizeableObjIdArray("supportCraft");
|
||||
}
|
||||
if(supportShips != null) {
|
||||
for (Object ship : supportShips) {
|
||||
LOG("space_gcw", "...despawning attack ship (" + ship + ")");
|
||||
@@ -607,7 +635,12 @@ public class battle_spawner extends script.base_class {
|
||||
}
|
||||
}
|
||||
LOG("space_gcw", "In cleanup... despawning defense support craft...");
|
||||
supportShips = getResizeableObjIdArrayObjVar(defendingShip, "supportCraft");
|
||||
if(isValidId(defendingShip)) {
|
||||
supportShips = getResizeableObjIdArrayObjVar(defendingShip, "supportCraft");
|
||||
}
|
||||
else{
|
||||
supportShips = params.getResizeableObjIdArray("supportCraft");
|
||||
}
|
||||
if(supportShips != null) {
|
||||
for (Object ship : supportShips) {
|
||||
LOG("space_gcw", "...despawning defense ship (" + ship + ")");
|
||||
@@ -626,9 +659,24 @@ public class battle_spawner extends script.base_class {
|
||||
|
||||
// set obj vars on controller for next battle
|
||||
obj_id controller = params.getObjId("controller");
|
||||
setObjVar(controller, "space_gcw." + self.toString() + ".lastWinningFaction", params.getString("losingFaction").equals("imperial") ? "rebel" : "imperial");
|
||||
setObjVar(controller, "space_gcw." + self.toString() + ".lastDefendingFaction", params.getString("defendingFaction").equals("imperial") ? "imperial" : "rebel");
|
||||
setObjVar(controller, "space_gcw." + self.toString() + ".lastWinningRole", params.getString("losingRole").equals("attack") ? "defense" : "attack");
|
||||
String losingFaction = params.getString("losingFaction");
|
||||
String losingRole = params.getString("losingRole");
|
||||
String defendingFaction;
|
||||
if(losingFaction.equals("imperial") && losingRole.equals("attack")){
|
||||
defendingFaction = "rebel";
|
||||
}
|
||||
else if(losingFaction.equals("imperial") && losingRole.equals("defense")){
|
||||
defendingFaction = "imperial";
|
||||
}
|
||||
else if(losingFaction.equals("rebel") && losingRole.equals("attack")){
|
||||
defendingFaction = "imperial";
|
||||
}
|
||||
else{
|
||||
defendingFaction = "rebel";
|
||||
}
|
||||
setObjVar(controller, "space_gcw." + self.toString() + ".lastWinningFaction", losingFaction.equals("imperial") ? "rebel" : "imperial");
|
||||
setObjVar(controller, "space_gcw." + self.toString() + ".lastDefendingFaction", defendingFaction);
|
||||
setObjVar(controller, "space_gcw." + self.toString() + ".lastWinningRole", losingRole.equals("attack") ? "defense" : "attack");
|
||||
|
||||
if(isValidId(defendingShip)){
|
||||
messageTo(self, "despawnDefendingShip", params, 60.0f, false);
|
||||
@@ -672,10 +720,10 @@ public class battle_spawner extends script.base_class {
|
||||
customLossTokenModifier = utils.stringToFloat(getConfigSetting("GameServer", "spaceGcwLossTokenModifier"));
|
||||
if (customLossTokenModifier < 0) customLossTokenModifier = DEFAULT_LOSS_TOKEN_MULTIPLIER;
|
||||
|
||||
customTokenAward = utils.stringToInt(getConfigSetting("GameServer", "spaceGcwPvPTokenAward"));
|
||||
customTokenAward = utils.stringToInt(getConfigSetting("GameServer", "spaceGcwTokenAward"));
|
||||
if (customTokenAward < 0) customTokenAward = DEFAULT_TOKEN_AWARD;
|
||||
|
||||
customPointAward = utils.stringToInt(getConfigSetting("GameServer", "spaceGcwPvPPointAward"));
|
||||
customPointAward = utils.stringToInt(getConfigSetting("GameServer", "spaceGcwPointAward"));
|
||||
if (customPointAward < 0) customPointAward = DEFAULT_POINT_AWARD;
|
||||
|
||||
customWinPointModifier = utils.stringToFloat(getConfigSetting("GameServer", "spaceGcwWinPointModifier"));
|
||||
@@ -689,6 +737,12 @@ public class battle_spawner extends script.base_class {
|
||||
|
||||
gunshipPlayerCeiling = utils.stringToInt(getConfigSetting("GameServer", "spaceGcwGunshipPlayerCeiling"));
|
||||
if (gunshipPlayerCeiling < 0) gunshipPlayerCeiling = DEFAULT_GUNSHIP_PLAYER_CEILING;
|
||||
|
||||
battleTimeLength = utils.stringToFloat(getConfigSetting("GameServer", "spaceGcwLengthOfBattle"));
|
||||
if (battleTimeLength <= 0) battleTimeLength = DEFAULT_BATTLE_TIME_LENGTH;
|
||||
|
||||
prepatoryTimeLength = utils.stringToFloat(getConfigSetting("GameServer", "spaceGcwPrepatoryTime"));
|
||||
if (prepatoryTimeLength <= 0) prepatoryTimeLength = DEFAULT_BATTLE_TIME_PREPATORY;
|
||||
LOG("space_gcw", "Done getting settings...");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package script.systems.gcw.space;
|
||||
|
||||
import script.dictionary;
|
||||
import script.library.factions;
|
||||
import script.library.space_crafting;
|
||||
import script.library.space_utils;
|
||||
import script.obj_id;
|
||||
|
||||
@@ -12,20 +13,20 @@ public class capital_ship extends script.space.combat.combat_space_base {
|
||||
if(!space_utils.isPlayerControlledShip(attacker) || getShipFaction(attacker).equals(getShipFaction(self))) {
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
sendSystemMessageTestingOnly(attacker, "You hit the capital ship!");
|
||||
obj_id spawner = getObjIdObjVar(self, "spawner");
|
||||
String battleType = getStringObjVar(spawner, "battle_type");
|
||||
String battleId = getStringObjVar(spawner, "battle_id");
|
||||
if(space_utils.isPobType(attacker)){
|
||||
boolean isGunship = getShipChassisType(attacker).startsWith("player_gunship");
|
||||
if(!isGunship && space_utils.isPobType(attacker)){
|
||||
if (battleType.equals(battle_spawner.BATTLE_TYPE_PVP)) {
|
||||
if (!factions.isDeclared(getShipPilot(attacker)))
|
||||
if (!(pvpGetType(attacker) == PVPTYPE_DECLARED))
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
setObjVar(spawner, "space_gcw.pob.participant." + battleId + "." + attacker, space_utils.getAllPlayersInShip(attacker));
|
||||
}
|
||||
else if(getShipChassisType(attacker).startsWith("player_gunship")){
|
||||
else if(isGunship){
|
||||
if (battleType.equals(battle_spawner.BATTLE_TYPE_PVP)) {
|
||||
if (!factions.isDeclared(getShipPilot(attacker)))
|
||||
if (!(pvpGetType(attacker) == PVPTYPE_DECLARED))
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
setObjVar(spawner, "space_gcw.gunship.participant." + battleId + "." + attacker, space_utils.getAllPlayersInShip(attacker));
|
||||
@@ -34,10 +35,10 @@ public class capital_ship extends script.space.combat.combat_space_base {
|
||||
obj_id player = getShipPilot(attacker);
|
||||
|
||||
if (battleType.equals(battle_spawner.BATTLE_TYPE_PVP)) {
|
||||
if (!factions.isDeclared(player))
|
||||
if (!(pvpGetType(attacker) == PVPTYPE_DECLARED))
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
setObjVar(spawner, "space_gcw.participant." + battleId + "." + player, "1");
|
||||
setObjVar(spawner, "space_gcw.participant." + battleId + "." + attacker, space_utils.getAllPlayersInShip(attacker));
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -50,30 +51,44 @@ public class capital_ship extends script.space.combat.combat_space_base {
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
dictionary params = new dictionary();
|
||||
params.put("role", getObjVar(self, "role"));
|
||||
params.put("spawner", getObjVar(self, "spawner"));
|
||||
params.put("spawner", getObjIdObjVar(self, "spawner"));
|
||||
params.put("destroyedShip", self);
|
||||
params.put("losingFaction", getShipFaction(self));
|
||||
params.put("losingRole", getStringObjVar(self, "role"));
|
||||
params.put("supportCraft", getResizeableObjIdArrayObjVar(self, "supportCraft"));
|
||||
messageTo(spawner, "capitalShipDestroyed", params, 0.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
public int removeSupportShip(obj_id self, dictionary params) throws InterruptedException{
|
||||
public int removeSupportShip(obj_id self, dictionary params) {
|
||||
obj_id destroyedShip = params.getObjId("destroyedShip");
|
||||
Vector spawnedShips = getResizeableObjIdArrayObjVar(self, "supportCraft");
|
||||
if(spawnedShips == null) return SCRIPT_CONTINUE;
|
||||
if(hasObjVar(destroyedShip, "ace_pilot"))
|
||||
if (spawnedShips == null) return SCRIPT_CONTINUE;
|
||||
if (hasObjVar(destroyedShip, "ace_pilot"))
|
||||
removeObjVar(self, "heroSpawned");
|
||||
|
||||
// remove destroyed ship
|
||||
spawnedShips.remove(
|
||||
spawnedShips.indexOf(
|
||||
destroyedShip
|
||||
)
|
||||
);
|
||||
|
||||
setObjVar(self, "supportCraft", spawnedShips);
|
||||
|
||||
try {
|
||||
// remove destroyed ship
|
||||
spawnedShips.remove(
|
||||
spawnedShips.indexOf(
|
||||
destroyedShip
|
||||
)
|
||||
);
|
||||
setObjVar(self, "supportCraft", spawnedShips);
|
||||
} catch (Exception e) {
|
||||
LOG("space_gcw", "Could not remove support ship from the mothership's supportCraft array.");
|
||||
}
|
||||
messageTo(self, "spawnSupportShip", null, rand(15.0f, 45.0f), false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int spawnSupportShip(obj_id self, dictionary params) throws InterruptedException{
|
||||
// make sure we don't orphan ships if the battle is over.
|
||||
if(!isValidId(self)) return SCRIPT_CONTINUE;
|
||||
obj_id spawner = getObjIdObjVar(self, "spawner");
|
||||
if(isValidId(spawner)) {
|
||||
obj_id controller = getObjIdObjVar(spawner, "controller");
|
||||
if (getIntObjVar(controller, "space_gcw." + self.toString() + ".active") == 0) return SCRIPT_CONTINUE;
|
||||
}
|
||||
// create a new ship
|
||||
setObjVar(self, "supportCraft", battle_spawner.spawnSupportShips(self));
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
@@ -7,53 +7,50 @@ import script.dictionary;
|
||||
import script.obj_id;
|
||||
|
||||
public class support_ship extends script.space.combat.combat_ship {
|
||||
|
||||
@Override
|
||||
public int OnDestroy(obj_id self) throws InterruptedException {
|
||||
dictionary dict = space_combat.getKillPercentages(self);
|
||||
obj_id playerShip = dict.getObjId("objWinner");
|
||||
obj_id player = getShipPilot(playerShip);
|
||||
|
||||
if(!space_utils.isPlayerControlledShip(playerShip))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
obj_id motherShip = getObjIdObjVar(self, "motherShip");
|
||||
obj_id spawner = getObjIdObjVar(motherShip, "spawner");
|
||||
String battleType = getStringObjVar(spawner, "battle_type");
|
||||
String battleId = getStringObjVar(spawner, "battle_id");
|
||||
obj_id controller = getObjIdObjVar(spawner, "controller");
|
||||
|
||||
if(getIntObjVar(controller, "space_gcw." + spawner + ".active") == 0)
|
||||
return SCRIPT_CONTINUE;
|
||||
if (space_utils.isPlayerControlledShip(playerShip)){
|
||||
obj_id player = getOwner(playerShip);
|
||||
|
||||
if(space_utils.isPobType(playerShip)){
|
||||
if (battleType.equals(battle_spawner.BATTLE_TYPE_PVP)) {
|
||||
if (!factions.isDeclared(player))
|
||||
return SCRIPT_CONTINUE;
|
||||
obj_id spawner = getObjIdObjVar(motherShip, "spawner");
|
||||
String battleType = getStringObjVar(spawner, "battle_type");
|
||||
String battleId = getStringObjVar(spawner, "battle_id");
|
||||
obj_id controller = getObjIdObjVar(spawner, "controller");
|
||||
|
||||
if (getIntObjVar(controller, "space_gcw." + spawner + ".active") == 0)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if (space_utils.isPobType(playerShip)) {
|
||||
if (battleType.equals(battle_spawner.BATTLE_TYPE_PVP)) {
|
||||
if (!(pvpGetType(playerShip) == PVPTYPE_DECLARED))
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
LOG("space_gcw", "Ship \"" + playerShip + "\" (" + playerShip + ") has qualified for space battle " + battleId + " by destroying a support ship.");
|
||||
setObjVar(spawner, "space_gcw.pob.participant." + battleId + "." + playerShip, space_utils.getAllPlayersInShip(playerShip));
|
||||
} else if (getShipChassisType(playerShip).startsWith("player_gunship")) {
|
||||
if (battleType.equals(battle_spawner.BATTLE_TYPE_PVP)) {
|
||||
if (!(pvpGetType(playerShip) == PVPTYPE_DECLARED))
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
LOG("space_gcw", "Ship \"" + playerShip + "\" (" + playerShip + ") has qualified for space battle " + battleId + " by destroying a support ship.");
|
||||
setObjVar(spawner, "space_gcw.gunship.participant." + battleId + "." + playerShip, space_utils.getAllPlayersInShip(playerShip));
|
||||
} else {
|
||||
if (battleType.equals(battle_spawner.BATTLE_TYPE_PVP)) {
|
||||
if (!(pvpGetType(playerShip) == PVPTYPE_DECLARED))
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
LOG("space_gcw", "Ship \"" + playerShip + "\" (" + playerShip + ") has qualified for space battle " + battleId + " by destroying a support ship.");
|
||||
setObjVar(spawner, "space_gcw.participant." + battleId + "." + playerShip, space_utils.getAllPlayersInShip(playerShip));
|
||||
}
|
||||
LOG("space_gcw", "Player \"" + player + "\" (" + player + ") has qualified for space battle " + battleId + " by destroying a support ship.");
|
||||
setObjVar(spawner, "space_gcw.pob.participant." + battleId + "." + playerShip, space_utils.getAllPlayersInShip(playerShip));
|
||||
}
|
||||
else if(getShipChassisType(playerShip).startsWith("player_gunship")){
|
||||
if (battleType.equals(battle_spawner.BATTLE_TYPE_PVP)) {
|
||||
if (!factions.isDeclared(player))
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
LOG("space_gcw", "Player \"" + player + "\" (" + player + ") has qualified for space battle " + battleId + " by destroying a support ship.");
|
||||
setObjVar(spawner, "space_gcw.gunship.participant." + battleId + "." + playerShip, space_utils.getAllPlayersInShip(playerShip));
|
||||
}
|
||||
else {
|
||||
if (battleType.equals(battle_spawner.BATTLE_TYPE_PVP)) {
|
||||
if (!factions.isDeclared(player))
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
LOG("space_gcw", "Player \"" + player + "\" (" + player + ") has qualified for space battle " + battleId + " by destroying a support ship.");
|
||||
setObjVar(spawner, "space_gcw.participant." + battleId + "." + player, "1");
|
||||
}
|
||||
|
||||
dictionary params = new dictionary();
|
||||
params.put("destroyedShip", self);
|
||||
messageTo(motherShip, "removeSupportShip", params, 0f, false);
|
||||
messageTo(motherShip, "removeSupportShip", params, 0.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user