diff --git a/sku.0/sys.server/compiled/game/object/building/corellia/starport_corellia.tpf b/sku.0/sys.server/compiled/game/object/building/corellia/starport_corellia.tpf index b49d67385..f5c40c375 100755 --- a/sku.0/sys.server/compiled/game/object/building/corellia/starport_corellia.tpf +++ b/sku.0/sys.server/compiled/game/object/building/corellia/starport_corellia.tpf @@ -20,6 +20,7 @@ @class object_template 1 +scripts = +["city.ship_spawner"] sharedTemplate = "object/building/corellia/shared_starport_corellia.iff" diff --git a/sku.0/sys.server/compiled/game/object/building/naboo/starport_naboo.tpf b/sku.0/sys.server/compiled/game/object/building/naboo/starport_naboo.tpf index c74ca8813..3c158901e 100755 --- a/sku.0/sys.server/compiled/game/object/building/naboo/starport_naboo.tpf +++ b/sku.0/sys.server/compiled/game/object/building/naboo/starport_naboo.tpf @@ -20,6 +20,7 @@ @class object_template 1 +scripts = +["city.ship_spawner"] sharedTemplate = "object/building/naboo/shared_starport_naboo.iff" diff --git a/sku.0/sys.server/compiled/game/object/building/tatooine/starport_tatooine.tpf b/sku.0/sys.server/compiled/game/object/building/tatooine/starport_tatooine.tpf index 4b48316b8..bbf0fc56d 100755 --- a/sku.0/sys.server/compiled/game/object/building/tatooine/starport_tatooine.tpf +++ b/sku.0/sys.server/compiled/game/object/building/tatooine/starport_tatooine.tpf @@ -20,6 +20,7 @@ @class object_template 1 +scripts = +["city.ship_spawner"] sharedTemplate = "object/building/tatooine/shared_starport_tatooine.iff" diff --git a/sku.0/sys.server/compiled/game/script/city/ship_spawner.java b/sku.0/sys.server/compiled/game/script/city/ship_spawner.java index 6e9534aa0..937cdde22 100755 --- a/sku.0/sys.server/compiled/game/script/city/ship_spawner.java +++ b/sku.0/sys.server/compiled/game/script/city/ship_spawner.java @@ -1,6 +1,7 @@ package script.city; -import script.location; +import script.dictionary; +import script.library.gcw; import script.obj_id; public class ship_spawner extends script.base_script @@ -8,10 +9,44 @@ public class ship_spawner extends script.base_script public ship_spawner() { } - public int OnInitialize(obj_id self) throws InterruptedException - { - location here = getLocation(self); - obj_id npc = createObject("object/static/structure/general/distant_ship_controller2.iff", here); + + public int OnInitialize(obj_id self) throws InterruptedException { + messageTo(self, "evaluateSpawn", null, 0.0f, false); + return SCRIPT_CONTINUE; + } + + public int evaluateSpawn(obj_id self, dictionary params) throws InterruptedException{ + // get the current imperial GCW score for the location. + int impScore = gcw.getGcwImperialScorePercentile(gcw.getGcwRegion(self)); + + String template = "object/static/structure/general/distant_ship_controller2.iff"; + if(impScore < 50) { + template = "object/static/structure/general/distant_ship_controller_rebel.iff"; + } else if(impScore > 50){ + template = "object/static/structure/general/distant_ship_controller_imperial.iff"; + } + + if(null != params) { + obj_id controller = params.getObjId("currentController"); + String currentTemplate = getTemplateName(controller); + if (currentTemplate != null && currentTemplate.equals(template)) { + messageTo(self, "evaluateSpawn", params, 60.0f, false); + return SCRIPT_CONTINUE; + } + // our template is different, let's get rid of the old one before we create a new one. + destroyObject(params.getObjId("currentController")); + } else { + params = new dictionary(); + } + + obj_id controller = createObject(template, getLocation(self)); + + params.put("currentController", controller); + params.put("lastImperialScore", impScore); + + // check the spawn point again in 60 seconds. + messageTo(self, "evaluateSpawn", params, 60.0f, false); + return SCRIPT_CONTINUE; } }