From 351f1d6bd488a5db7b33301b569646945645cfca Mon Sep 17 00:00:00 2001 From: Light2 Date: Mon, 16 Sep 2013 16:42:30 +0200 Subject: [PATCH] Reworked script service, added cloning terminals to all cloning facilities --- .../building/corellia/cloning_corellia.py | 10 +++++- .../military/outpost_cloning_facility.py | 8 ++++- .../military/outpost_cloning_facility_s02.py | 9 ++++- .../military/outpost_cloning_facility_s03.py | 9 ++++- .../building/naboo/cloning_facility_naboo.py | 10 +++++- .../building/player/city/cantina_corellia.py | 10 +++++- .../building/player/city/cloning_corellia.py | 10 +++++- .../building/player/city/cloning_naboo.py | 10 +++++- .../building/player/city/cloning_tatooine.py | 10 +++++- .../tatooine/cloning_facility_tatooine.py | 6 ++++ .../cloning_facility_tatooine_small.py | 6 ++++ src/services/BuffService.java | 7 ++-- src/services/PlayerService.java | 2 +- src/services/ScriptService.java | 36 +++++++++++++------ src/services/SkillModService.java | 4 +-- src/services/StaticService.java | 2 +- src/services/combat/CombatService.java | 4 +-- src/services/command/CommandService.java | 4 +-- src/services/gcw/GCWService.java | 2 +- 19 files changed, 128 insertions(+), 31 deletions(-) diff --git a/scripts/object/building/corellia/cloning_corellia.py b/scripts/object/building/corellia/cloning_corellia.py index ccad8904..0214be67 100644 --- a/scripts/object/building/corellia/cloning_corellia.py +++ b/scripts/object/building/corellia/cloning_corellia.py @@ -1,4 +1,12 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(2) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(2.5), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(-1.35), float(1), float(0)) + + return + \ No newline at end of file diff --git a/scripts/object/building/military/outpost_cloning_facility.py b/scripts/object/building/military/outpost_cloning_facility.py index ccad8904..f32c6716 100644 --- a/scripts/object/building/military/outpost_cloning_facility.py +++ b/scripts/object/building/military/outpost_cloning_facility.py @@ -1,4 +1,10 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(3) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(0.0387871), float(0.125265), float(-6), float(-0.0595427), float(0.998226)) + + return diff --git a/scripts/object/building/military/outpost_cloning_facility_s02.py b/scripts/object/building/military/outpost_cloning_facility_s02.py index ccad8904..68c60b76 100644 --- a/scripts/object/building/military/outpost_cloning_facility_s02.py +++ b/scripts/object/building/military/outpost_cloning_facility_s02.py @@ -1,4 +1,11 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(6) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-5.5), float(0.125265), float(-3.43841), float(0.699512), float(0.714621)) + + return + \ No newline at end of file diff --git a/scripts/object/building/military/outpost_cloning_facility_s03.py b/scripts/object/building/military/outpost_cloning_facility_s03.py index ccad8904..cfecc438 100644 --- a/scripts/object/building/military/outpost_cloning_facility_s03.py +++ b/scripts/object/building/military/outpost_cloning_facility_s03.py @@ -1,4 +1,11 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(3) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-0.134662), float(0.125265), float(-5.80915), float(-0.0238176), float(0.998716)) + + return + \ No newline at end of file diff --git a/scripts/object/building/naboo/cloning_facility_naboo.py b/scripts/object/building/naboo/cloning_facility_naboo.py index ccad8904..0214be67 100644 --- a/scripts/object/building/naboo/cloning_facility_naboo.py +++ b/scripts/object/building/naboo/cloning_facility_naboo.py @@ -1,4 +1,12 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(2) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(2.5), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(-1.35), float(1), float(0)) + + return + \ No newline at end of file diff --git a/scripts/object/building/player/city/cantina_corellia.py b/scripts/object/building/player/city/cantina_corellia.py index ccad8904..f1033f3f 100644 --- a/scripts/object/building/player/city/cantina_corellia.py +++ b/scripts/object/building/player/city/cantina_corellia.py @@ -1,4 +1,12 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(4) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/terminal_player_structure.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.28604), float(-2.110639), float(-6.443224), float(0.707107), float(0.707107)) + stcSvc.spawnObject('object/tangible/terminal/terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.57625), float(-2.5), float(3.1), float(0.707107), float(0.707107)) + + return + \ No newline at end of file diff --git a/scripts/object/building/player/city/cloning_corellia.py b/scripts/object/building/player/city/cloning_corellia.py index ccad8904..e81f8587 100644 --- a/scripts/object/building/player/city/cloning_corellia.py +++ b/scripts/object/building/player/city/cloning_corellia.py @@ -1,4 +1,12 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(4) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_player_structure.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.28604), float(-2.110639), float(-6.443224), float(0.707107), float(0.707107)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.57625), float(-2.5), float(3.1), float(0.707107), float(0.707107)) + + return + \ No newline at end of file diff --git a/scripts/object/building/player/city/cloning_naboo.py b/scripts/object/building/player/city/cloning_naboo.py index ccad8904..e81f8587 100644 --- a/scripts/object/building/player/city/cloning_naboo.py +++ b/scripts/object/building/player/city/cloning_naboo.py @@ -1,4 +1,12 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(4) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_player_structure.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.28604), float(-2.110639), float(-6.443224), float(0.707107), float(0.707107)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.57625), float(-2.5), float(3.1), float(0.707107), float(0.707107)) + + return + \ No newline at end of file diff --git a/scripts/object/building/player/city/cloning_tatooine.py b/scripts/object/building/player/city/cloning_tatooine.py index ccad8904..e81f8587 100644 --- a/scripts/object/building/player/city/cloning_tatooine.py +++ b/scripts/object/building/player/city/cloning_tatooine.py @@ -1,4 +1,12 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(4) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_player_structure.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.28604), float(-2.110639), float(-6.443224), float(0.707107), float(0.707107)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.57625), float(-2.5), float(3.1), float(0.707107), float(0.707107)) + + return + \ No newline at end of file diff --git a/scripts/object/building/tatooine/cloning_facility_tatooine.py b/scripts/object/building/tatooine/cloning_facility_tatooine.py index 10c20b1b..330d8dba 100644 --- a/scripts/object/building/tatooine/cloning_facility_tatooine.py +++ b/scripts/object/building/tatooine/cloning_facility_tatooine.py @@ -1,6 +1,12 @@ import sys def setup(core, object): + stcSvc = core.staticService + cell = object.getCellByCellNumber(2) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(2.5), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(-1.35), float(1), float(0)) core.mapService.addLocation(object.getPlanet(), 'Cloning Facility', object.getPosition().x, object.getPosition().z, 5, 0, 0) return diff --git a/scripts/object/building/tatooine/cloning_facility_tatooine_small.py b/scripts/object/building/tatooine/cloning_facility_tatooine_small.py index ccad8904..e24f1252 100644 --- a/scripts/object/building/tatooine/cloning_facility_tatooine_small.py +++ b/scripts/object/building/tatooine/cloning_facility_tatooine_small.py @@ -1,4 +1,10 @@ import sys def setup(core, object): + stcSvc = core.staticService + cell = object.getCellByCellNumber(10) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-0.42), float(-0.38), float(-0.4), float(1), float(0)) + return \ No newline at end of file diff --git a/src/services/BuffService.java b/src/services/BuffService.java index 28eeefea..5673e37a 100644 --- a/src/services/BuffService.java +++ b/src/services/BuffService.java @@ -79,18 +79,19 @@ public class BuffService implements INetworkDispatch { removeBuffFromCreature(creature, otherBuff); System.out.println("buff removed " + buffName); break; - }else{ + } else { System.out.println("buff not added:" + buffName); return; } } - core.scriptService.callScript("scripts/buffs", "setup", buffName, core, creature, buff); + core.scriptService.callScript("scripts/buffs/", "setup", buffName, core, creature, buff); creature.addBuff(buff); if(buff.getDuration() > 0) { + scheduler.schedule(new Runnable() { @Override @@ -111,7 +112,7 @@ public class BuffService implements INetworkDispatch { if(!creature.getBuffList().contains(buff)) return; - core.scriptService.callScript("scripts/buffs", "removeBuff", buff.getBuffName(), core, creature, buff); + core.scriptService.callScript("scripts/buffs/", "removeBuff", buff.getBuffName(), core, creature, buff); creature.removeBuff(buff); } diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index dbbd06e5..52d90a1e 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -177,7 +177,7 @@ public class PlayerService implements INetworkDispatch { if(!FileUtilities.doesFileExist("scripts/expertise/" + expertiseBox + ".py")) return; - core.scriptService.callScript("scripts/expertise", "addExpertisePoint", expertiseBox, core, creature); + core.scriptService.callScript("scripts/expertise/", "addExpertisePoint", expertiseBox, core, creature); } diff --git a/src/services/ScriptService.java b/src/services/ScriptService.java index 563a8c46..beac5ff5 100644 --- a/src/services/ScriptService.java +++ b/src/services/ScriptService.java @@ -39,43 +39,59 @@ public class ScriptService { } public void callScript(String path, String module, String method) { - PythonInterpreter interpreter = new PythonInterpreter(); + /*PythonInterpreter interpreter = new PythonInterpreter(); interpreter.cleanup(); interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method); PyObject func = interpreter.get(method); - func.__call__(Py.java2py(core)); + func.__call__(Py.java2py(core));*/ + PythonInterpreter python = new PythonInterpreter(); + python.execfile(path + module + ".py"); + python.get(method).__call__(); } public void callScript(String path, String module, String method, Object arg1) { - PythonInterpreter interpreter = new PythonInterpreter(); + /*PythonInterpreter interpreter = new PythonInterpreter(); interpreter.cleanup(); interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method); PyObject func = interpreter.get(method); - func.__call__(Py.java2py(core), Py.java2py(arg1)); + func.__call__(Py.java2py(core), Py.java2py(arg1));*/ + PythonInterpreter python = new PythonInterpreter(); + python.execfile(path + module + ".py"); + python.get(method).__call__(Py.java2py(arg1)); } public void callScript(String path, String method, String module, Object arg1, Object arg2) { - PythonInterpreter interpreter = new PythonInterpreter(); + /*PythonInterpreter interpreter = new PythonInterpreter(); interpreter.cleanup(); interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method); PyObject func = interpreter.get(method); - func.__call__(Py.java2py(arg1), Py.java2py(arg2)); + func.__call__(Py.java2py(arg1), Py.java2py(arg2));*/ + PythonInterpreter python = new PythonInterpreter(); + python.execfile(path + module + ".py"); + python.get(method).__call__(Py.java2py(arg1), Py.java2py(arg2)); } public void callScript(String path, String method, String module, Object arg1, Object arg2, Object arg3) { - PythonInterpreter interpreter = new PythonInterpreter(); + /*PythonInterpreter interpreter = new PythonInterpreter(); interpreter.cleanup(); interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method); PyObject func = interpreter.get(method); - func.__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3)); + func.__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3));*/ + PythonInterpreter python = new PythonInterpreter(); + python.execfile(path + module + ".py"); + python.get(method).__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3)); + } public void callScript(String path, String module, String method, Object arg1, Object arg2, Object arg3, Object arg4) { - PythonInterpreter interpreter = new PythonInterpreter(); + /*PythonInterpreter interpreter = new PythonInterpreter(); interpreter.cleanup(); interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method); PyObject func = interpreter.get(method); - func.__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3), Py.java2py(arg4)); + func.__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3), Py.java2py(arg4));*/ + PythonInterpreter python = new PythonInterpreter(); + python.execfile(path + module + ".py"); + python.get(method).__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3), Py.java2py(arg4)); } public PyObject getMethod(String path, String module, String method) { diff --git a/src/services/SkillModService.java b/src/services/SkillModService.java index 8a68c282..8e4ec7c4 100644 --- a/src/services/SkillModService.java +++ b/src/services/SkillModService.java @@ -40,13 +40,13 @@ public class SkillModService implements INetworkDispatch { public void addSkillMod(CreatureObject creature, String skillMod, int value) { - core.scriptService.callScript("scripts/skillMods", skillMod, "add", core, creature, skillMod, value); + core.scriptService.callScript("scripts/skillMods/", skillMod, "add", core, creature, skillMod, value); } public void deductSkillMod(CreatureObject creature, String skillMod, int value) { - core.scriptService.callScript("scripts/skillMods", skillMod, "deduct", core, creature, skillMod, value); + core.scriptService.callScript("scripts/skillMods/", skillMod, "deduct", core, creature, skillMod, value); } diff --git a/src/services/StaticService.java b/src/services/StaticService.java index 645b85d1..77a80d26 100644 --- a/src/services/StaticService.java +++ b/src/services/StaticService.java @@ -58,7 +58,7 @@ public class StaticService implements INetworkDispatch { public void spawnPlanetStaticObjs(String planet) { Planet planetObj = (Planet) core.terrainService.getPlanetByName(planet); - core.scriptService.callScript("scripts/static_spawns", "addPlanetSpawns", planetObj.getName(), core, planetObj); + core.scriptService.callScript("scripts/static_spawns/", "addPlanetSpawns", planetObj.getName(), core, planetObj); System.out.println("Loaded static objs for " + planetObj.getName()); } diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 926b406b..79adfc10 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -314,8 +314,8 @@ public class CombatService implements INetworkDispatch { sendCombatPackets(attacker, target, weapon, command, actionCounter, damage, armorAbsorbed, hitType); - if(FileUtilities.doesFileExist("scripts/commands/combat" + command.getCommandName() + ".py")) - core.scriptService.callScript("scripts/commands/combat", command.getCommandName(), "run", core, attacker, target, null); + if(FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) + core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "run", core, attacker, target, null); } diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index afeb1a53..ccb554ec 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -96,12 +96,12 @@ public class CommandService implements INetworkDispatch { if(command instanceof CombatCommand) { CombatCommand command2 = (CombatCommand) command.clone(); if(FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) - core.scriptService.callScript("scripts/commands/combat", command.getCommandName(), "setup", core, actor, target, command2); + core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "setup", core, actor, target, command2); processCombatCommand(actor, target, command2, commandEnqueue.getActionCounter(), commandEnqueue.getCommandArguments()); return; } - + System.out.println(command.getCommandName()); core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandEnqueue.getCommandArguments()); } diff --git a/src/services/gcw/GCWService.java b/src/services/gcw/GCWService.java index 96062aee..e89c7e48 100644 --- a/src/services/gcw/GCWService.java +++ b/src/services/gcw/GCWService.java @@ -78,7 +78,7 @@ public class GCWService implements INetworkDispatch { private void afterInitialisation() { try { - core.scriptService.callScript("scripts/", "gcwzones", "addZones"); + core.scriptService.callScript("scripts/", "gcwzones", "addZones", core); } catch (Exception e) { e.printStackTrace(); }