From 29b6738852594385f5c496a5792c1e65c3ae75c2 Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Sat, 5 Apr 2014 23:59:42 +0200 Subject: [PATCH 01/68] Jedi - Fixed Force Throw and Spark --- scripts/commands/combat/fs_force_spark.py | 11 +++++++++++ src/services/combat/CombatCommands.java | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 scripts/commands/combat/fs_force_spark.py diff --git a/scripts/commands/combat/fs_force_spark.py b/scripts/commands/combat/fs_force_spark.py new file mode 100644 index 00000000..b3a17b88 --- /dev/null +++ b/scripts/commands/combat/fs_force_spark.py @@ -0,0 +1,11 @@ +import sys + +def setup(core, actor, target, command): + + command.setBuffNameTarget('') + + return + +def run(core, actor, target, commandString): + return + \ No newline at end of file diff --git a/src/services/combat/CombatCommands.java b/src/services/combat/CombatCommands.java index 7a66c472..17aab1eb 100644 --- a/src/services/combat/CombatCommands.java +++ b/src/services/combat/CombatCommands.java @@ -197,7 +197,9 @@ public class CombatCommands { core.commandService.registerCommand("forcerun"); // Force Run core.commandService.registerCommand("fs_buff_invis_1"); // Force Cloak core.commandService.registerCombatCommand("fs_force_throw_1"); - core.commandService.registerCommand("forceThrow"); + core.commandService.registerCombatCommand("forceThrow"); + core.commandService.registerCombatCommand("fs_set_heroic_taunt_1"); // Guardian Strike + core.commandService.registerCombatCommand("fs_force_spark"); // Commando From bc8172a008b4dd7a51cc105be4d670a39c0dd902 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Mon, 7 Apr 2014 01:56:46 +0200 Subject: [PATCH 02/68] Fix at suspicion of concurrency problem in surveyingservice --- src/services/SurveyService.java | 89 +++++++++++++++++---------------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/src/services/SurveyService.java b/src/services/SurveyService.java index 1f14fe8d..333db3f7 100644 --- a/src/services/SurveyService.java +++ b/src/services/SurveyService.java @@ -86,48 +86,47 @@ public class SurveyService implements INetworkDispatch { } public void ServiceProcessing(){ - // All tools sampling - SurveyTool removeTool=null; - for (SurveyTool surveyTool : activeSurveyTools){ - if (surveyTool.getCurrentlySurveying()){ - // Check if survey process has finished - if (System.currentTimeMillis()>surveyTool.getLastSurveyTime()+3000){ - removeTool = surveyTool; - surveyTool.setCurrentlySurveying(false); - surveyTool.sendConstructSurveyMapMessage(); + synchronized(activeSurveyTools){ + // All tools sampling + SurveyTool removeTool=null; + for (SurveyTool surveyTool : activeSurveyTools){ + if (surveyTool.getCurrentlySurveying()){ + // Check if survey process has finished + if (System.currentTimeMillis()>surveyTool.getLastSurveyTime()+3000){ + removeTool = surveyTool; + surveyTool.setCurrentlySurveying(false); + surveyTool.sendConstructSurveyMapMessage(); + } + } + if (surveyTool.getCurrentlySampling()){ + // Check if sampling process has finished + if ((System.currentTimeMillis()>surveyTool.getLastSampleTime()+3000) && !surveyTool.getCurrentlyCoolingDown()){ + surveyTool.setCurrentlyCoolingDown(true); + // Update inventory + handleSamplingStages(surveyTool); + + } + // Check if sampling recovery is over + long sampleRecoveryTime = surveyTool.getRecoveryTime(); + if (System.currentTimeMillis()>surveyTool.getLastSampleTime()+sampleRecoveryTime && ! surveyTool.isExceptionalState()){ + // kick off another sampling attempt + surveyTool.setCurrentlyCoolingDown(false); + continueSampling(surveyTool); + } + if (surveyTool.getUser().getPosture()!=1){ + surveyTool.setExceptionalState(false); + surveyTool.setCurrentlySampling(false); + removeTool = surveyTool; + if (surveyTool.getUser().getPosture()==0) + surveyTool.getUser().sendSystemMessage("You stand up", (byte) 0); + + surveyTool.getUser().sendSystemMessage("@survey:sample_cancel", (byte) 0); + } } } - if (surveyTool.getCurrentlySampling()){ - // Check if sampling process has finished - if ((System.currentTimeMillis()>surveyTool.getLastSampleTime()+3000) && !surveyTool.getCurrentlyCoolingDown()){ - surveyTool.setCurrentlyCoolingDown(true); - // Update inventory - handleSamplingStages(surveyTool); - - } - // Check if sampling recovery is over - long sampleRecoveryTime = surveyTool.getRecoveryTime(); - if (System.currentTimeMillis()>surveyTool.getLastSampleTime()+sampleRecoveryTime && ! surveyTool.isExceptionalState()){ - // kick off another sampling attempt - surveyTool.setCurrentlyCoolingDown(false); - continueSampling(surveyTool); - } - if (surveyTool.getUser().getPosture()!=1){ - surveyTool.setExceptionalState(false); - surveyTool.setCurrentlySampling(false); - removeTool = surveyTool; - if (surveyTool.getUser().getPosture()==0) - surveyTool.getUser().sendSystemMessage("You stand up", (byte) 0); - - surveyTool.getUser().sendSystemMessage("@survey:sample_cancel", (byte) 0); - } - } - } - if (removeTool!=null) - activeSurveyTools.remove(removeTool); // remove after notification - - - + if (removeTool!=null) + activeSurveyTools.remove(removeTool); // remove after notification + } } public void handleSamplingStages(SurveyTool surveyTool){ @@ -567,8 +566,10 @@ public class SurveyService implements INetworkDispatch { } public void addActiveSurveyTool(SurveyTool tool){ - if (! activeSurveyTools.contains(tool)) - activeSurveyTools.add(tool); + synchronized(activeSurveyTools){ + if (! activeSurveyTools.contains(tool)) + activeSurveyTools.add(tool); + } } public Vector getActiveSurveyTools(){ @@ -576,7 +577,9 @@ public class SurveyService implements INetworkDispatch { } public void removeActiveSurveyTool(SurveyTool surveyTool){ - activeSurveyTools.remove(surveyTool); + synchronized(activeSurveyTools){ + activeSurveyTools.remove(surveyTool); + } } public boolean toolIsInList(SurveyTool surveyTool){ From 01fedd5cdbaa4567b25b2e95d41848af1c0bfff4 Mon Sep 17 00:00:00 2001 From: Bronco69 Date: Mon, 7 Apr 2014 03:18:46 +0200 Subject: [PATCH 03/68] fixes in Jedi expertise multi expertise commands fixed --- .../expertise_fs_general_force_shockwave_1.py | 23 ++++++++----------- .../expertise_fs_path_dark_lightning_1.py | 18 ++++++++++++++- .../expertise_fs_path_force_choke_1.py | 18 ++++++++++++++- .../expertise_fs_path_force_drain_1.py | 15 +++++++++++- .../expertise_fs_path_maelstrom_1.py | 15 +++++++++++- .../expertise_fs_path_saber_reflect_1.py | 4 ++-- 6 files changed, 74 insertions(+), 19 deletions(-) diff --git a/scripts/expertise/expertise_fs_general_force_shockwave_1.py b/scripts/expertise/expertise_fs_general_force_shockwave_1.py index bd222493..a17dbe47 100644 --- a/scripts/expertise/expertise_fs_general_force_shockwave_1.py +++ b/scripts/expertise/expertise_fs_general_force_shockwave_1.py @@ -2,24 +2,21 @@ import sys def addAbilities(core, actor, player): if actor.getLevel() >= 26: - actor.addAbility("fs_ae_dm_cc_1") + actor.addAbility("fs_dm_cc_crit_1") if actor.getLevel() >= 34: - actor.addAbility("fs_ae_dm_cc_2") + actor.addAbility("fs_dm_cc_crit_2") if actor.getLevel() >= 48: - actor.addAbility("fs_ae_dm_cc_3") + actor.addAbility("fs_dm_cc_crit_3") if actor.getLevel() >= 62: - actor.addAbility("fs_ae_dm_cc_4") + actor.addAbility("fs_dm_cc_crit_4") if actor.getLevel() >= 76: - actor.addAbility("fs_ae_dm_cc_5") - if actor.getLevel() >= 90: - actor.addAbility("fs_ae_dm_cc_6") + actor.addAbility("fs_dm_cc_crit_5") return def removeAbilities(core, actor, player): - actor.removeAbility("fs_ae_dm_cc_1") - actor.removeAbility("fs_ae_dm_cc_2") - actor.removeAbility("fs_ae_dm_cc_3") - actor.removeAbility("fs_ae_dm_cc_4") - actor.removeAbility("fs_ae_dm_cc_5") - actor.removeAbility("fs_ae_dm_cc_6") + actor.removeAbility("fs_dm_cc_crit_1") + actor.removeAbility("fs_dm_cc_crit_2") + actor.removeAbility("fs_dm_cc_crit_3") + actor.removeAbility("fs_dm_cc_crit_4") + actor.removeAbility("fs_dm_cc_crit_5") return diff --git a/scripts/expertise/expertise_fs_path_dark_lightning_1.py b/scripts/expertise/expertise_fs_path_dark_lightning_1.py index 0e8503fd..bd222493 100644 --- a/scripts/expertise/expertise_fs_path_dark_lightning_1.py +++ b/scripts/expertise/expertise_fs_path_dark_lightning_1.py @@ -1,9 +1,25 @@ import sys def addAbilities(core, actor, player): - actor.addAbility("fs_ae_dm_cc_1") + if actor.getLevel() >= 26: + actor.addAbility("fs_ae_dm_cc_1") + if actor.getLevel() >= 34: + actor.addAbility("fs_ae_dm_cc_2") + if actor.getLevel() >= 48: + actor.addAbility("fs_ae_dm_cc_3") + if actor.getLevel() >= 62: + actor.addAbility("fs_ae_dm_cc_4") + if actor.getLevel() >= 76: + actor.addAbility("fs_ae_dm_cc_5") + if actor.getLevel() >= 90: + actor.addAbility("fs_ae_dm_cc_6") return def removeAbilities(core, actor, player): actor.removeAbility("fs_ae_dm_cc_1") + actor.removeAbility("fs_ae_dm_cc_2") + actor.removeAbility("fs_ae_dm_cc_3") + actor.removeAbility("fs_ae_dm_cc_4") + actor.removeAbility("fs_ae_dm_cc_5") + actor.removeAbility("fs_ae_dm_cc_6") return diff --git a/scripts/expertise/expertise_fs_path_force_choke_1.py b/scripts/expertise/expertise_fs_path_force_choke_1.py index 7ceb9e53..ad9a5d82 100644 --- a/scripts/expertise/expertise_fs_path_force_choke_1.py +++ b/scripts/expertise/expertise_fs_path_force_choke_1.py @@ -1,9 +1,25 @@ import sys def addAbilities(core, actor, player): - actor.addAbility("fs_dm_cc_1") + if actor.getLevel() >= 26: + actor.addAbility("fs_dm_cc_1") + if actor.getLevel() >= 34: + actor.addAbility("fs_dm_cc_2") + if actor.getLevel() >= 48: + actor.addAbility("fs_dm_cc_3") + if actor.getLevel() >= 62: + actor.addAbility("fs_dm_cc_4") + if actor.getLevel() >= 76: + actor.addAbility("fs_dm_cc_5") + if actor.getLevel() >= 90: + actor.addAbility("fs_dm_cc_6") return def removeAbilities(core, actor, player): actor.removeAbility("fs_dm_cc_1") + actor.removeAbility("fs_dm_cc_2") + actor.removeAbility("fs_dm_cc_3") + actor.removeAbility("fs_dm_cc_4") + actor.removeAbility("fs_dm_cc_5") + actor.removeAbility("fs_dm_cc_6") return diff --git a/scripts/expertise/expertise_fs_path_force_drain_1.py b/scripts/expertise/expertise_fs_path_force_drain_1.py index 1ec21f58..6d310e3a 100644 --- a/scripts/expertise/expertise_fs_path_force_drain_1.py +++ b/scripts/expertise/expertise_fs_path_force_drain_1.py @@ -1,9 +1,22 @@ import sys def addAbilities(core, actor, player): - actor.addAbility("fs_drain_1") + if actor.getLevel() >= 26: + actor.addAbility("fs_drain_1") + if actor.getLevel() >= 34: + actor.addAbility("fs_drain_2") + if actor.getLevel() >= 48: + actor.addAbility("fs_drain_3") + if actor.getLevel() >= 62: + actor.addAbility("fs_drain_4") + if actor.getLevel() >= 76: + actor.addAbility("fs_drain_5") return def removeAbilities(core, actor, player): actor.removeAbility("fs_drain_1") + actor.removeAbility("fs_drain_2") + actor.removeAbility("fs_drain_3") + actor.removeAbility("fs_drain_4") + actor.removeAbility("fs_drain_5") return diff --git a/scripts/expertise/expertise_fs_path_maelstrom_1.py b/scripts/expertise/expertise_fs_path_maelstrom_1.py index 3fbdb051..84a05ef5 100644 --- a/scripts/expertise/expertise_fs_path_maelstrom_1.py +++ b/scripts/expertise/expertise_fs_path_maelstrom_1.py @@ -1,9 +1,22 @@ import sys def addAbilities(core, actor, player): - actor.addAbility("fs_maelstrom_1") + if actor.getLevel() >= 26: + actor.addAbility("fs_maelstrom_1") + if actor.getLevel() >= 34: + actor.addAbility("fs_maelstrom_2") + if actor.getLevel() >= 48: + actor.addAbility("fs_maelstrom_3") + if actor.getLevel() >= 62: + actor.addAbility("fs_maelstrom_4") + if actor.getLevel() >= 76: + actor.addAbility("fs_maelstrom_5") return def removeAbilities(core, actor, player): actor.removeAbility("fs_maelstrom_1") + actor.removeAbility("fs_maelstrom_2") + actor.removeAbility("fs_maelstrom_3") + actor.removeAbility("fs_maelstrom_4") + actor.removeAbility("fs_maelstrom_5") return diff --git a/scripts/expertise/expertise_fs_path_saber_reflect_1.py b/scripts/expertise/expertise_fs_path_saber_reflect_1.py index ff019b2d..8a78f62b 100644 --- a/scripts/expertise/expertise_fs_path_saber_reflect_1.py +++ b/scripts/expertise/expertise_fs_path_saber_reflect_1.py @@ -1,9 +1,9 @@ import sys def addAbilities(core, actor, player): - actor.addAbility("fs_saber_reflect_buff") + actor.addAbility("fs_saber_reflect") return def removeAbilities(core, actor, player): - actor.removeAbility("fs_saber_reflect_buff") + actor.removeAbility("fs_saber_reflect") return From 5516a557623d4a042629a917458bdd2ad1ea6265 Mon Sep 17 00:00:00 2001 From: Bronco69 Date: Mon, 7 Apr 2014 04:25:56 +0200 Subject: [PATCH 04/68] fix in Medic expertise realized that the health buff is linked to the stamina box in expertise http://i.imgur.com/hW0L0zp.jpg ive chosen CL48 for mark 2 because you get initially mark 1 at CL48 too. --- .../expertise/expertise_me_enhancement_specialist_1.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/expertise/expertise_me_enhancement_specialist_1.py b/scripts/expertise/expertise_me_enhancement_specialist_1.py index 4c9429e5..ebf28d79 100644 --- a/scripts/expertise/expertise_me_enhancement_specialist_1.py +++ b/scripts/expertise/expertise_me_enhancement_specialist_1.py @@ -7,10 +7,18 @@ def addAbilities(core, actor, player): actor.addAbility("me_enhance_action_2") if actor.getLevel() >= 62: actor.addAbility("me_enhance_action_3") + + if actor.getLevel() >= 48: + actor.addAbility("me_buff_health_2") + if actor.getLevel() >= 76: + actor.addAbility("me_buff_health_3") return def removeAbilities(core, actor, player): actor.removeAbility("me_enhance_action_1") actor.removeAbility("me_enhance_action_2") actor.removeAbility("me_enhance_action_3") + + actor.removeAbility("me_buff_health_2") + actor.removeAbility("me_buff_health_3") return From 0bf30444fcd50c7ab791214509874e5c6259f5b8 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:02:52 +0100 Subject: [PATCH 05/68] Fixed null errors --- src/services/command/CommandService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 7e395b55..9e8ce4ed 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -485,9 +485,9 @@ public class CommandService implements INetworkDispatch { } - @Deprecated public BaseSWGCommand registerCommand(String name) { return null; } - @Deprecated public CombatCommand registerCombatCommand(String name) { return null; } - @Deprecated public BaseSWGCommand registerGmCommand(String name) { return null; } - @Deprecated public void registerAlias(String name, String target) { } + public BaseSWGCommand registerCommand(String name) { return getCommandByName(name); } + public CombatCommand registerCombatCommand(String name) { return getCommandByName(name); } + public BaseSWGCommand registerGmCommand(String name) { return getCommandByName(name); } + public void registerAlias(String name, String target) { } } From 8398a2dc56c1279c79dac2425bf859e66a1c51a1 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:15:53 +0100 Subject: [PATCH 06/68] Cooldowns only added if they are more than a 1 sec It's probably not worth it otherwise. --- src/services/command/CommandService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 9e8ce4ed..9884af7a 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -308,7 +308,9 @@ public class CommandService implements INetworkDispatch { } public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { - actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); + if (command.getCooldown() > (float) 1) { + actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); + } if (command instanceof CombatCommand) { processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); From 131841520bf4f1497f4fabcf1d9386a142ced354 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:21:32 +0100 Subject: [PATCH 07/68] Fixed a few things --- src/services/command/CommandService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 9884af7a..f12ddf31 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -285,8 +285,8 @@ public class CommandService implements INetworkDispatch { if (visitor.getObject(i, 0) != null) { String commandName = ((String) visitor.getObject(i, 0)).toLowerCase(); - if (commandName.equalsIgnoreCase(name) { - boolean combatCommand = ((String) (visitor.getObject(i, 7)).length() > 0); + if (commandName.equalsIgnoreCase(name)) { + boolean combatCommand = (((String) (visitor.getObject(i, 7)).length() > 0); if (combatCommand) { CombatCommand command = new CombatCommand(commandName); From 9dded0943277f0c67f552026ebd00508f7a7fd9e Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:27:42 +0100 Subject: [PATCH 08/68] Fixed a few more things --- src/services/command/CommandService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index f12ddf31..04ebf1b0 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -248,7 +248,7 @@ public class CommandService implements INetworkDispatch { String name = ((String) visitor.getObject(i, 0)).toLowerCase(); if (CRC.StringtoCRC(name) == CRC) { - boolean combatCommand = ((String) (visitor.getObject(i, 7)).length() > 0); + boolean combatCommand = (((String) visitor.getObject(i, 7)).length() > 0); if (combatCommand) { CombatCommand command = new CombatCommand(name.toLowerCase()); @@ -286,7 +286,7 @@ public class CommandService implements INetworkDispatch { String commandName = ((String) visitor.getObject(i, 0)).toLowerCase(); if (commandName.equalsIgnoreCase(name)) { - boolean combatCommand = (((String) (visitor.getObject(i, 7)).length() > 0); + boolean combatCommand = (((String) visitor.getObject(i, 7)).length() > 0); if (combatCommand) { CombatCommand command = new CombatCommand(commandName); From b7eef0cf357cec9f9b1113137ea83711fb66a409 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:32:03 +0100 Subject: [PATCH 09/68] Fixed duplicate maxRangeToTargets --- src/services/command/BaseSWGCommand.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index 07e55e19..69d1a9cf 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -33,7 +33,6 @@ public class BaseSWGCommand implements Cloneable { private String commandName; private String clientEffectSelf; private String clientEffectTarget; - private int maxRangeToTarget; private int commandCRC; private boolean isGmCommand = false; private String characterAbility; @@ -177,14 +176,6 @@ public class BaseSWGCommand implements Cloneable { this.clientEffectTarget = clientEffectTarget; } - public int getMaxRangeToTarget() { - return maxRangeToTarget; - } - - public void setMaxRangeToTarget(int maxRangeToTarget) { - this.maxRangeToTarget = maxRangeToTarget; - } - public int getCommandCRC() { return commandCRC; } From 4aa3b7058ab86177afed7a2aa42c54c2dfa09f79 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:38:03 +0100 Subject: [PATCH 10/68] Fixed byte adding error in command reading --- src/services/command/BaseSWGCommand.java | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index 69d1a9cf..292e8be6 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -85,20 +85,20 @@ public class BaseSWGCommand implements Cloneable { executeTime = (Float) visitor2.getObject(i, 87); cooldown = (Float) visitor2.getObject(i, 88); - if (!((Boolean) visitor2.getObject(8))) invalidPostures.add(0B); - if (!((Boolean) visitor2.getObject(9))) invalidPostures.add(3B); - if (!((Boolean) visitor2.getObject(16))) invalidPostures.add(2B); - if (!((Boolean) visitor2.getObject(19))) invalidPostures.add(5B); - if (!((Boolean) visitor2.getObject(21))) invalidPostures.add(6B); - if (!((Boolean) visitor2.getObject(22))) invalidPostures.add(7B); - if (!((Boolean) visitor2.getObject(23))) invalidPostures.add(8B); - if (!((Boolean) visitor2.getObject(24))) invalidPostures.add(9B); - if (!((Boolean) visitor2.getObject(25))) invalidPostures.add(10B); - if (!((Boolean) visitor2.getObject(26))) invalidPostures.add(11B); - if (!((Boolean) visitor2.getObject(27))) invalidPostures.add(12B); - if (!((Boolean) visitor2.getObject(28))) invalidPostures.add(13B); - if (!((Boolean) visitor2.getObject(29))) invalidPostures.add(14B); - if (!((Boolean) visitor2.getObject(30))) invalidPostures.add(4B); + if (!((Boolean) visitor2.getObject(8))) invalidPostures.add((byte) 0); + if (!((Boolean) visitor2.getObject(9))) invalidPostures.add((byte) 3); + if (!((Boolean) visitor2.getObject(16))) invalidPostures.add((byte) 2); + if (!((Boolean) visitor2.getObject(19))) invalidPostures.add((byte) 5); + if (!((Boolean) visitor2.getObject(21))) invalidPostures.add((byte) 6); + if (!((Boolean) visitor2.getObject(22))) invalidPostures.add((byte) 7); + if (!((Boolean) visitor2.getObject(23))) invalidPostures.add((byte) 8); + if (!((Boolean) visitor2.getObject(24))) invalidPostures.add((byte) 9); + if (!((Boolean) visitor2.getObject(25))) invalidPostures.add((byte) 10); + if (!((Boolean) visitor2.getObject(26))) invalidPostures.add((byte) 11); + if (!((Boolean) visitor2.getObject(27))) invalidPostures.add((byte) 12); + if (!((Boolean) visitor2.getObject(28))) invalidPostures.add((byte) 13); + if (!((Boolean) visitor2.getObject(29))) invalidPostures.add((byte) 14); + if (!((Boolean) visitor2.getObject(30))) invalidPostures.add((byte) 4); if (!((Boolean) visitor2.getObject(32))) invalidStates.add(1L); if (!((Boolean) visitor2.getObject(33))) invalidStates.add(2L); From 8cbf80b2ce9d9fc234a2192f6709ff910adc2bae Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:45:59 +0100 Subject: [PATCH 11/68] Fixed a few more errors --- src/services/command/BaseSWGCommand.java | 120 +++++++++++------------ 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index 292e8be6..4c0766fe 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -51,9 +51,9 @@ public class BaseSWGCommand implements Cloneable { private float cooldown; private float executeTime; private float warmupTime; - //private long[] invalidLocomotions; // Not tracked anywhere - private byte[] invalidPostures; - private long[] invalidStates; + //private Long[] invalidLocomotions; // Not tracked anywhere + private Byte[] invalidPostures; + private Long[] invalidStates; public BaseSWGCommand(String commandName) { setCommandName(commandName); @@ -85,63 +85,63 @@ public class BaseSWGCommand implements Cloneable { executeTime = (Float) visitor2.getObject(i, 87); cooldown = (Float) visitor2.getObject(i, 88); - if (!((Boolean) visitor2.getObject(8))) invalidPostures.add((byte) 0); - if (!((Boolean) visitor2.getObject(9))) invalidPostures.add((byte) 3); - if (!((Boolean) visitor2.getObject(16))) invalidPostures.add((byte) 2); - if (!((Boolean) visitor2.getObject(19))) invalidPostures.add((byte) 5); - if (!((Boolean) visitor2.getObject(21))) invalidPostures.add((byte) 6); - if (!((Boolean) visitor2.getObject(22))) invalidPostures.add((byte) 7); - if (!((Boolean) visitor2.getObject(23))) invalidPostures.add((byte) 8); - if (!((Boolean) visitor2.getObject(24))) invalidPostures.add((byte) 9); - if (!((Boolean) visitor2.getObject(25))) invalidPostures.add((byte) 10); - if (!((Boolean) visitor2.getObject(26))) invalidPostures.add((byte) 11); - if (!((Boolean) visitor2.getObject(27))) invalidPostures.add((byte) 12); - if (!((Boolean) visitor2.getObject(28))) invalidPostures.add((byte) 13); - if (!((Boolean) visitor2.getObject(29))) invalidPostures.add((byte) 14); - if (!((Boolean) visitor2.getObject(30))) invalidPostures.add((byte) 4); + if (!((Boolean) visitor2.getObject(i, 8))) invalidPostures.add((byte) 0); + if (!((Boolean) visitor2.getObject(i, 9))) invalidPostures.add((byte) 3); + if (!((Boolean) visitor2.getObject(i, 16))) invalidPostures.add((byte) 2); + if (!((Boolean) visitor2.getObject(i, 19))) invalidPostures.add((byte) 5); + if (!((Boolean) visitor2.getObject(i, 21))) invalidPostures.add((byte) 6); + if (!((Boolean) visitor2.getObject(i, 22))) invalidPostures.add((byte) 7); + if (!((Boolean) visitor2.getObject(i, 23))) invalidPostures.add((byte) 8); + if (!((Boolean) visitor2.getObject(i, 24))) invalidPostures.add((byte) 9); + if (!((Boolean) visitor2.getObject(i, 25))) invalidPostures.add((byte) 10); + if (!((Boolean) visitor2.getObject(i, 26))) invalidPostures.add((byte) 11); + if (!((Boolean) visitor2.getObject(i, 27))) invalidPostures.add((byte) 12); + if (!((Boolean) visitor2.getObject(i, 28))) invalidPostures.add((byte) 13); + if (!((Boolean) visitor2.getObject(i, 29))) invalidPostures.add((byte) 14); + if (!((Boolean) visitor2.getObject(i, 30))) invalidPostures.add((byte) 4); - if (!((Boolean) visitor2.getObject(32))) invalidStates.add(1L); - if (!((Boolean) visitor2.getObject(33))) invalidStates.add(2L); - if (!((Boolean) visitor2.getObject(34))) invalidStates.add(4L); - if (!((Boolean) visitor2.getObject(35))) invalidStates.add(8L); - if (!((Boolean) visitor2.getObject(36))) invalidStates.add(16L); - if (!((Boolean) visitor2.getObject(37))) invalidStates.add(32L); - if (!((Boolean) visitor2.getObject(38))) invalidStates.add(64L); - if (!((Boolean) visitor2.getObject(39))) invalidStates.add(128L); - if (!((Boolean) visitor2.getObject(40))) invalidStates.add(256L); - if (!((Boolean) visitor2.getObject(41))) invalidStates.add(512L); - if (!((Boolean) visitor2.getObject(42))) invalidStates.add(1024L); - if (!((Boolean) visitor2.getObject(43))) invalidStates.add(2048L); - if (!((Boolean) visitor2.getObject(44))) invalidStates.add(4096L); - if (!((Boolean) visitor2.getObject(45))) invalidStates.add(8192L); - if (!((Boolean) visitor2.getObject(46))) invalidStates.add(16384L); - if (!((Boolean) visitor2.getObject(47))) invalidStates.add(32768L); - if (!((Boolean) visitor2.getObject(48))) invalidStates.add(65536L); - if (!((Boolean) visitor2.getObject(49))) invalidStates.add(131072L); - if (!((Boolean) visitor2.getObject(50))) invalidStates.add(262144L); - if (!((Boolean) visitor2.getObject(51))) invalidStates.add(524288L); - if (!((Boolean) visitor2.getObject(52))) invalidStates.add(1048576L); - if (!((Boolean) visitor2.getObject(53))) invalidStates.add(2097152L); - if (!((Boolean) visitor2.getObject(54))) invalidStates.add(4194304L); - if (!((Boolean) visitor2.getObject(55))) invalidStates.add(8388608L); - if (!((Boolean) visitor2.getObject(56))) invalidStates.add(16777216L); - if (!((Boolean) visitor2.getObject(57))) invalidStates.add(33554432L); - if (!((Boolean) visitor2.getObject(58))) invalidStates.add(67108864L); - if (!((Boolean) visitor2.getObject(59))) invalidStates.add(134217728L); - if (!((Boolean) visitor2.getObject(60))) invalidStates.add(268435456L); - if (!((Boolean) visitor2.getObject(61))) invalidStates.add(536870912L); - if (!((Boolean) visitor2.getObject(62))) invalidStates.add(1073741824L); - if (!((Boolean) visitor2.getObject(63))) invalidStates.add(2147483648L); - if (!((Boolean) visitor2.getObject(64))) invalidStates.add(4294967296L); - if (!((Boolean) visitor2.getObject(65))) invalidStates.add(8589934592L); - if (!((Boolean) visitor2.getObject(66))) invalidStates.add(17179869184L); - if (!((Boolean) visitor2.getObject(67))) invalidStates.add(34359738368L); - if (!((Boolean) visitor2.getObject(68))) invalidStates.add(68719476736L); - if (!((Boolean) visitor2.getObject(69))) invalidStates.add(137438953472L); - if (!((Boolean) visitor2.getObject(70))) invalidStates.add(274877906944L); + if (!((Boolean) visitor2.getObject(i, 32))) invalidStates.add(1L); + if (!((Boolean) visitor2.getObject(i, 33))) invalidStates.add(2L); + if (!((Boolean) visitor2.getObject(i, 34))) invalidStates.add(4L); + if (!((Boolean) visitor2.getObject(i, 35))) invalidStates.add(8L); + if (!((Boolean) visitor2.getObject(i, 36))) invalidStates.add(16L); + if (!((Boolean) visitor2.getObject(i, 37))) invalidStates.add(32L); + if (!((Boolean) visitor2.getObject(i, 38))) invalidStates.add(64L); + if (!((Boolean) visitor2.getObject(i, 39))) invalidStates.add(128L); + if (!((Boolean) visitor2.getObject(i, 40))) invalidStates.add(256L); + if (!((Boolean) visitor2.getObject(i, 41))) invalidStates.add(512L); + if (!((Boolean) visitor2.getObject(i, 42))) invalidStates.add(1024L); + if (!((Boolean) visitor2.getObject(i, 43))) invalidStates.add(2048L); + if (!((Boolean) visitor2.getObject(i, 44))) invalidStates.add(4096L); + if (!((Boolean) visitor2.getObject(i, 45))) invalidStates.add(8192L); + if (!((Boolean) visitor2.getObject(i, 46))) invalidStates.add(16384L); + if (!((Boolean) visitor2.getObject(i, 47))) invalidStates.add(32768L); + if (!((Boolean) visitor2.getObject(i, 48))) invalidStates.add(65536L); + if (!((Boolean) visitor2.getObject(i, 49))) invalidStates.add(131072L); + if (!((Boolean) visitor2.getObject(i, 50))) invalidStates.add(262144L); + if (!((Boolean) visitor2.getObject(i, 51))) invalidStates.add(524288L); + if (!((Boolean) visitor2.getObject(i, 52))) invalidStates.add(1048576L); + if (!((Boolean) visitor2.getObject(i, 53))) invalidStates.add(2097152L); + if (!((Boolean) visitor2.getObject(i, 54))) invalidStates.add(4194304L); + if (!((Boolean) visitor2.getObject(i, 55))) invalidStates.add(8388608L); + if (!((Boolean) visitor2.getObject(i, 56))) invalidStates.add(16777216L); + if (!((Boolean) visitor2.getObject(i, 57))) invalidStates.add(33554432L); + if (!((Boolean) visitor2.getObject(i, 58))) invalidStates.add(67108864L); + if (!((Boolean) visitor2.getObject(i, 59))) invalidStates.add(134217728L); + if (!((Boolean) visitor2.getObject(i, 60))) invalidStates.add(268435456L); + if (!((Boolean) visitor2.getObject(i, 61))) invalidStates.add(536870912L); + if (!((Boolean) visitor2.getObject(i, 62))) invalidStates.add(1073741824L); + if (!((Boolean) visitor2.getObject(i, 63))) invalidStates.add(2147483648L); + if (!((Boolean) visitor2.getObject(i, 64))) invalidStates.add(4294967296L); + if (!((Boolean) visitor2.getObject(i, 65))) invalidStates.add(8589934592L); + if (!((Boolean) visitor2.getObject(i, 66))) invalidStates.add(17179869184L); + if (!((Boolean) visitor2.getObject(i, 67))) invalidStates.add(34359738368L); + if (!((Boolean) visitor2.getObject(i, 68))) invalidStates.add(68719476736L); + if (!((Boolean) visitor2.getObject(i, 69))) invalidStates.add(137438953472L); + if (!((Boolean) visitor2.getObject(i, 70))) invalidStates.add(274877906944L); - this.invalidPostures = (byte[]) invalidPostures.toArray(); - this.invalidStates = (long[]) invalidStates.toArray(); + this.invalidPostures = (Byte[]) invalidPostures.toArray(); + this.invalidStates = (Long[]) invalidStates.toArray(); break; } @@ -204,11 +204,11 @@ public class BaseSWGCommand implements Cloneable { this.characterAbility = characterAbility; } - public byte[] getInvalidPostures() { + public Byte[] getInvalidPostures() { return invalidPostures; } - public long[] getInvalidStates() { + public Long[] getInvalidStates() { return invalidStates; } From 78b6b52740324b06890ea6289b80eeebcbc684ba Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:53:38 +0100 Subject: [PATCH 12/68] Fixed cast exception (maxRangeToTarget is a float) --- src/services/command/BaseSWGCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index 4c0766fe..bb799265 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -74,7 +74,7 @@ public class BaseSWGCommand implements Cloneable { callOnTarget = (Boolean) visitor2.getObject(i, 76); commandGroup = (Integer) visitor2.getObject(i, 77); disabled = (Boolean) visitor2.getObject(i, 78); - maxRangeToTarget = (Integer) visitor2.getObject(i, 79); + maxRangeToTarget = (int) ((Float) visitor2.getObject(i, 79)); godLevel = (Integer) visitor2.getObject(i, 80); displayGroup = (Integer) visitor2.getObject(i, 81); combatCommand = (Boolean) visitor2.getObject(i, 82); From e3cf93fbb19c1c8f457d15246e59e093ea63700f Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 05:02:39 +0100 Subject: [PATCH 13/68] Fixed float error properly --- src/services/command/BaseSWGCommand.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index bb799265..b44dd319 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -41,7 +41,7 @@ public class BaseSWGCommand implements Cloneable { private boolean callOnTarget = false; private int commandGroup; private boolean disabled = true; - private int maxRangeToTarget; + private float maxRangeToTarget; private int godLevel; private int displayGroup; private boolean combatCommand = false; @@ -74,7 +74,7 @@ public class BaseSWGCommand implements Cloneable { callOnTarget = (Boolean) visitor2.getObject(i, 76); commandGroup = (Integer) visitor2.getObject(i, 77); disabled = (Boolean) visitor2.getObject(i, 78); - maxRangeToTarget = (int) ((Float) visitor2.getObject(i, 79)); + maxRangeToTarget = (Float) visitor2.getObject(i, 79); godLevel = (Integer) visitor2.getObject(i, 80); displayGroup = (Integer) visitor2.getObject(i, 81); combatCommand = (Boolean) visitor2.getObject(i, 82); @@ -252,11 +252,11 @@ public class BaseSWGCommand implements Cloneable { this.disabled = disabled; } - public int getMaxRangeToTarget() { + public float getMaxRangeToTarget() { return maxRangeToTarget; } - public void setMaxRangeToTarget(int maxRangeToTarget) { + public void setMaxRangeToTarget(float maxRangeToTarget) { this.maxRangeToTarget = maxRangeToTarget; } From 78d0f90ee7faa6d1ff02450dab0b2f838248f13b Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 05:12:43 +0100 Subject: [PATCH 14/68] Fixed invalid postures/states problem --- src/services/command/BaseSWGCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index b44dd319..6eee3c22 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -140,8 +140,8 @@ public class BaseSWGCommand implements Cloneable { if (!((Boolean) visitor2.getObject(i, 69))) invalidStates.add(137438953472L); if (!((Boolean) visitor2.getObject(i, 70))) invalidStates.add(274877906944L); - this.invalidPostures = (Byte[]) invalidPostures.toArray(); - this.invalidStates = (Long[]) invalidStates.toArray(); + this.invalidPostures = invalidPostures.toArray(new Byte[] { }); + this.invalidStates = invalidStates.toArray(new Long[] { }); break; } From 3ff8d7b9407961f614808a1788724a9f2db0af02 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 05:22:44 +0100 Subject: [PATCH 15/68] Fixed issue with returning combat commands --- src/services/command/CommandService.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 04ebf1b0..1d5675e9 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -487,8 +487,17 @@ public class CommandService implements INetworkDispatch { } + public CombatCommand registerCombatCommand(String name) { + BaseSWGCommand command = getCommandByName(name); + + if (command instanceof CombatCommand) { + return (CombatCommand) command; + } + + return null; + } + public BaseSWGCommand registerCommand(String name) { return getCommandByName(name); } - public CombatCommand registerCombatCommand(String name) { return getCommandByName(name); } public BaseSWGCommand registerGmCommand(String name) { return getCommandByName(name); } public void registerAlias(String name, String target) { } From 144e483769a8772c99a8047c49e668b42af51307 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 05:54:20 +0100 Subject: [PATCH 16/68] Few command improvements --- src/services/command/CommandService.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 1d5675e9..3fe05618 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -248,9 +248,10 @@ public class CommandService implements INetworkDispatch { String name = ((String) visitor.getObject(i, 0)).toLowerCase(); if (CRC.StringtoCRC(name) == CRC) { - boolean combatCommand = (((String) visitor.getObject(i, 7)).length() > 0); + boolean hasCharacterAbility = (((String) visitor.getObject(i, 7)).length() > 0); + boolean isCombatCommand = (Boolean) visitor.getObject(i, 82); - if (combatCommand) { + if (hasCharacterAbility || isCombatCommand) { CombatCommand command = new CombatCommand(name.toLowerCase()); commandLookup.add(command); return command; @@ -272,6 +273,8 @@ public class CommandService implements INetworkDispatch { public BaseSWGCommand getCommandByName(String name) { Vector commands = new Vector(commandLookup); + name = name.toLowerCase(); + for (BaseSWGCommand command : commands) { if (command.getCommandName().equalsIgnoreCase(name)) { return command; @@ -286,9 +289,10 @@ public class CommandService implements INetworkDispatch { String commandName = ((String) visitor.getObject(i, 0)).toLowerCase(); if (commandName.equalsIgnoreCase(name)) { - boolean combatCommand = (((String) visitor.getObject(i, 7)).length() > 0); + boolean hasCharacterAbility = (((String) visitor.getObject(i, 7)).length() > 0); + boolean isCombatCommand = (Boolean) visitor.getObject(i, 82); - if (combatCommand) { + if (hasCharacterAbility || isCombatCommand) { CombatCommand command = new CombatCommand(commandName); commandLookup.add(command); return command; @@ -490,8 +494,18 @@ public class CommandService implements INetworkDispatch { public CombatCommand registerCombatCommand(String name) { BaseSWGCommand command = getCommandByName(name); + if (command == null) { + return null; + } + if (command instanceof CombatCommand) { return (CombatCommand) command; + } else { + System.out.println("Warning: Forced to make non-combat command " + name + " a combat command."); + commandLookup.remove(command); + CombatCommand combatCommand = new CombatCommand(name.toLowerCase()); + commandLookup.add(combatCommand); + return combatCommand; } return null; From 4de112037629e944390fa0e0ff14d1948ea1399a Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 06:06:39 +0100 Subject: [PATCH 17/68] Fixed unreachable code --- src/services/command/CommandService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 3fe05618..ebf769d1 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -507,8 +507,6 @@ public class CommandService implements INetworkDispatch { commandLookup.add(combatCommand); return combatCommand; } - - return null; } public BaseSWGCommand registerCommand(String name) { return getCommandByName(name); } From 51f89dced761bb178e5a2f761ea98baa9ce8d7d0 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 06:41:32 +0100 Subject: [PATCH 18/68] More command service improvements --- src/services/command/CommandService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index ebf769d1..729a9f8f 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -88,10 +88,6 @@ public class CommandService implements INetworkDispatch { return false; } - if (target != null && actor.getPosition().getDistance(target.getPosition) > command.getMaxRangeToTarget()) { - return false; - } - WeaponObject weapon = (WeaponObject) core.objectService.getObject(actor.getWeaponId()); if (weapon != null && weapon.getWeaponType() == command.getInvalidWeapon()) { @@ -182,6 +178,10 @@ public class CommandService implements INetworkDispatch { break; } + if (target != null && actor.getPosition().getDistance(target.getPosition) > command.getMaxRangeToTarget()) { + return false; + } + if (command.shouldCallOnTarget()) { if (target == null || !(target instanceof CreatureObject)) { return false; @@ -468,7 +468,7 @@ public class CommandService implements INetworkDispatch { SWGObject target = core.objectService.getObject(commandEnqueue.getTargetID()); - if (!callCommand(actor, command, target, commandEnqueue.getActionCounter(), commandEnqueue.getCommandArguments())) { + if (!callCommand(actor, target, command, commandEnqueue.getActionCounter(), commandEnqueue.getCommandArguments())) { // Call failScriptHook } } From 9b87eb0f597bb311a3150d474feffba5dbdae927 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 07:19:31 +0100 Subject: [PATCH 19/68] Commands check LOS & distance if correct type --- src/services/command/CommandService.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 729a9f8f..f3364e5b 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -118,6 +118,14 @@ public class CommandService implements INetworkDispatch { return false; } + if (target != null && actor.getPosition().getDistance(target.getPosition) > command.getMaxRangeToTarget()) { + return false; + } + + if (!core.simulationService.checkLineOfSight(actor, target)) { + return false; + } + break; case 2: // Self Only if (target == null) { @@ -138,6 +146,10 @@ public class CommandService implements INetworkDispatch { target = actor; } + if (!core.simulationService.checkLineOfSight(actor, target)) { + return false; + } + break; default: break; @@ -159,6 +171,11 @@ public class CommandService implements INetworkDispatch { return false; } + // Without this we could be buffing ally NPCs and such + if (object.getSlottedObject("ghost") == null) { + return; + } + break; case 1: // Enemy Only if (target == null || !(target instanceof TangibleObject)) { @@ -178,10 +195,6 @@ public class CommandService implements INetworkDispatch { break; } - if (target != null && actor.getPosition().getDistance(target.getPosition) > command.getMaxRangeToTarget()) { - return false; - } - if (command.shouldCallOnTarget()) { if (target == null || !(target instanceof CreatureObject)) { return false; From 3bff39bd2e218d80437119a873e63c2163f56f05 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 09:29:19 +0100 Subject: [PATCH 20/68] Added alias "afk" for "toggleawayfromkeyboard" --- scripts/commands/afk.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 scripts/commands/afk.py diff --git a/scripts/commands/afk.py b/scripts/commands/afk.py new file mode 100644 index 00000000..68670816 --- /dev/null +++ b/scripts/commands/afk.py @@ -0,0 +1,13 @@ +from resources.datatables import PlayerFlags +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + command = core.commandService.getCommandByName("toggleawayfromkeyboard") + + if command: + core.commandService.processCommand(actor, target, command, 0, commandString) + + return From e9f4f39fd0ed8a41fa203d99e7f2adb07359c890 Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Mon, 7 Apr 2014 10:33:12 +0200 Subject: [PATCH 21/68] Commands - Fixed minor variable naming error --- src/services/command/CommandService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index f3364e5b..268b34b2 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -244,11 +244,11 @@ public class CommandService implements INetworkDispatch { core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandArgs); } - public BaseSWGCommand getCommandByCRC(int CRC) { + public BaseSWGCommand getCommandByCRC(int commandCRC) { Vector commands = new Vector(commandLookup); for (BaseSWGCommand command : commands) { - if (command.getCommandCRC() == CRC) { + if (command.getCommandCRC() == commandCRC) { return command; } } @@ -260,7 +260,7 @@ public class CommandService implements INetworkDispatch { if (visitor.getObject(i, 0) != null) { String name = ((String) visitor.getObject(i, 0)).toLowerCase(); - if (CRC.StringtoCRC(name) == CRC) { + if (CRC.StringtoCRC(name) == commandCRC) { boolean hasCharacterAbility = (((String) visitor.getObject(i, 7)).length() > 0); boolean isCombatCommand = (Boolean) visitor.getObject(i, 82); From 7fae180c9d155e5b512e47cd04c4e369f9eecc5c Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 09:46:12 +0100 Subject: [PATCH 22/68] Add OutOfBand constructor for simpler conv scripts --- src/resources/common/OutOfBand.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/resources/common/OutOfBand.java b/src/resources/common/OutOfBand.java index 63505020..fd86c2dc 100644 --- a/src/resources/common/OutOfBand.java +++ b/src/resources/common/OutOfBand.java @@ -31,6 +31,14 @@ public class OutOfBand { private short count; private Vector prosePackages = new Vector(); + public OutOfBand(ProsePackage prosePackage) { + addProsePackage(prosePackage); + } + + public OutOfBand() { + + } + public void addProsePackage(ProsePackage prosePackage) { prosePackages.add(prosePackage); setCount((short) (getCount() + 1)); @@ -114,6 +122,4 @@ public class OutOfBand { this.prosePackages = prosePackages; } - - } From c99e7c4bff72c6ff149efe7e75446028e7010345 Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Mon, 7 Apr 2014 10:48:33 +0200 Subject: [PATCH 23/68] Revert "Jedi - Fixed Force Throw and Spark" This reverts commit e05a5b4bf548015996b79ea6f52adb55d9cb3bdd. --- scripts/commands/combat/fs_force_spark.py | 11 ----------- src/services/combat/CombatCommands.java | 4 +--- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 scripts/commands/combat/fs_force_spark.py diff --git a/scripts/commands/combat/fs_force_spark.py b/scripts/commands/combat/fs_force_spark.py deleted file mode 100644 index b3a17b88..00000000 --- a/scripts/commands/combat/fs_force_spark.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -def setup(core, actor, target, command): - - command.setBuffNameTarget('') - - return - -def run(core, actor, target, commandString): - return - \ No newline at end of file diff --git a/src/services/combat/CombatCommands.java b/src/services/combat/CombatCommands.java index 17aab1eb..7a66c472 100644 --- a/src/services/combat/CombatCommands.java +++ b/src/services/combat/CombatCommands.java @@ -197,9 +197,7 @@ public class CombatCommands { core.commandService.registerCommand("forcerun"); // Force Run core.commandService.registerCommand("fs_buff_invis_1"); // Force Cloak core.commandService.registerCombatCommand("fs_force_throw_1"); - core.commandService.registerCombatCommand("forceThrow"); - core.commandService.registerCombatCommand("fs_set_heroic_taunt_1"); // Guardian Strike - core.commandService.registerCombatCommand("fs_force_spark"); + core.commandService.registerCommand("forceThrow"); // Commando From 4b11146f782a782a9dd5b43ae05e4124765e15de Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 10:08:41 +0100 Subject: [PATCH 24/68] Added example conversation script Made a simpler script that uses less code, so it's easier to grasp. In most cases there will only be one ProsePackage. Copy-paste friendly. --- scripts/conversation/demo.py | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 scripts/conversation/demo.py diff --git a/scripts/conversation/demo.py b/scripts/conversation/demo.py new file mode 100644 index 00000000..31bb59f2 --- /dev/null +++ b/scripts/conversation/demo.py @@ -0,0 +1,60 @@ +from resources.common import ConversationOption +from resources.common import OutOfBand +from resources.common import ProsePackage +from java.util import Vector +import sys + +def startConversation(core, actor, npc): + convSvc = core.conversationService + + convSvc.sendConversationMessage(actor, npc, OutOfBand(ProsePackage('conversation/respecseller', 's_31'))) + + options = Vector() + options.add(ConversationOption(OutOfBand(ProsePackage('conversation/respecseller', 's_32')), 0)) + options.add(ConversationOption(OutOfBand(ProsePackage('conversation/respecseller', 's_33')), 1)) + convSvc.sendConversationOptions(actor, npc, options, handleFirstScreen) + + return + +def handleFirstScreen(core, actor, npc, selection): + convSvc = core.conversationService + + # TODO: check for prices + + if selection == 0: # respec + convSvc.sendConversationMessage(actor, npc, OutOfBand(ProsePackage('conversation/respecseller', 's_58'))) + + options = Vector() + options.add(ConversationOption(OutOfBand(ProsePackage('conversation/respecseller', 's_60')), 0)) + options.add(ConversationOption(OutOfBand(ProsePackage('conversation/respecseller', 's_64')), 1)) + convSvc.sendConversationOptions(actor, npc, options, handleRespecScreen) + + if selection == 1: # expertise reset + convSvc.sendConversationMessage(actor, npc, OutOfBand(ProsePackage('conversation/respecseller', 's_35'))) + + options = Vector() + options.add(ConversationOption(OutOfBand(ProsePackage('conversation/respecseller', 's_71')), 0)) + options.add(ConversationOption(OutOfBand(ProsePackage('conversation/respecseller', 's_72')), 1)) + convSvc.sendConversationOptions(actor, npc, options, handleResetScreen) + + return + +def handleRespecScreen(core, actor, npc, selection): + if selection == 0: + core.skillService.sendRespecWindow(actor) + + core.conversationService.handleEndConversation(actor, npc) + + return + +def handleResetScreen(core, actor, npc, selection): + if selection == 0: + core.skillService.resetExpertise(actor) + + core.conversationService.handleEndConversation(actor, npc) + + return + +def endConversation(core, actor, npc): + core.conversationService.sendStopConversation(actor, npc, 'conversation/respecseller', 's_38') + return From b03a2d7051fe341b567045c2e08456c31ce74c7a Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Mon, 7 Apr 2014 11:29:19 +0200 Subject: [PATCH 25/68] Commands - Fixed getters and setter for targetType --- src/services/command/BaseSWGCommand.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index 6eee3c22..9ac776a1 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -220,12 +220,12 @@ public class BaseSWGCommand implements Cloneable { this.target = target; } - public void getTargetType() { + public int getTargetType() { return targetType; } - public void setTargetType() { - return targetType; + public void setTargetType(int targetType) { + this.targetType = targetType; } public boolean shouldCallOnTarget() { From 9a141802b9e4a5539fe9a6c5bfb555299c6e34f9 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 10:37:11 +0100 Subject: [PATCH 26/68] Script syntax error --- scripts/conversation/demo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/conversation/demo.py b/scripts/conversation/demo.py index 31bb59f2..802329db 100644 --- a/scripts/conversation/demo.py +++ b/scripts/conversation/demo.py @@ -17,10 +17,10 @@ def startConversation(core, actor, npc): return def handleFirstScreen(core, actor, npc, selection): - convSvc = core.conversationService - - # TODO: check for prices - + convSvc = core.conversationService + + # TODO: check for prices + if selection == 0: # respec convSvc.sendConversationMessage(actor, npc, OutOfBand(ProsePackage('conversation/respecseller', 's_58'))) From f7bcd6416d05b9ca8461cb74ed0363810c3b3aef Mon Sep 17 00:00:00 2001 From: Levarrishawk Date: Mon, 7 Apr 2014 05:50:25 -0400 Subject: [PATCH 27/68] More unnecessary distractive Content Development --- scripts/static_spawns/kaas.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/static_spawns/kaas.py b/scripts/static_spawns/kaas.py index 41460025..7bcd17d9 100644 --- a/scripts/static_spawns/kaas.py +++ b/scripts/static_spawns/kaas.py @@ -21,11 +21,24 @@ def addPlanetSpawns(core, planet): stcSvc.spawnObject('object/building/content/aurilia/shared_aurilia_pyramid_hut.iff', 'kaas', long(0), float(-5163.9), float(79.0), float(-2351.6), float(0.71), float(0.71)) stcSvc.spawnObject('object/building/content/aurilia/shared_aurilia_pyramid_hut.iff', 'kaas', long(0), float(-5072.1), float(79.0), float(-2369.6), float(-0.71), float(0.71)) stcSvc.spawnObject('object/building/content/aurilia/shared_aurilia_pyramid_hut.iff', 'kaas', long(0), float(-5072.1), float(79.0), float(-2351.6), float(-0.71), float(0.71)) + stcSvc.spawnObject('object/building/military/shared_outpost_cloning_facility_s02.iff', long(0), 'kaas', long(0), float(-5072.1), float(80.0), float(-2279.5), float(0.71), float(0), float(-0.71), float(0)) + + #Terminals + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_bank.iff', 'kaas', long(0), float(-5080.8), float(80.0), float(-2275.7), float(-0.71), float(0.71)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_mission.iff', 'kaas', long(0), float(-5108.7), float(80.0), float(-2289.2), float(0), float(0)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_mission.iff', 'kaas', long(0), float(-5127.3), float(80.0), float(-2289.2), float(0), float(0)) + #Decor stcSvc.spawnObject('object/static/vehicle/shared_static_lambda_shuttle.iff', 'kaas', long(0), float(-5078.1), float(80.0), float(-2256.0), float(-0.70), float(0.70)) stcSvc.spawnObject('object/building/content/aurilia/shared_aurilia_crystal_centerpiece.iff', 'kaas', long(0), float(-5121.5), float(80.0), float(-2360.5), float(0), float(0)) stcSvc.spawnObject('object/static/structure/tatooine/shared_antenna_tatt_style_1.iff', 'kaas', long(0), float(-5146.7), float(80.0), float(-2301.7), float(0), float(0)) + stcSvc.spawnObject('object/static/installation/shared_mockup_power_generator_fusion_style_1.iff', 'kaas', long(0), float(-5146.7), float(80.0), float(-2301.7), float(0.71), float(0.71)) + stcSvc.spawnObject('object/static/installation/shared_mockup_power_generator_photo_bio_style_1.iff', 'kaas', long(0), float(-5146.9), float(80.0), float(-2294.5), float(0), float(0)) + stcSvc.spawnObject('object/static/vehicle/shared_static_tie_bomber.iff', 'kaas', long(0), float(-5158.5), float(80.5), float(-2232.4), float(0.70), float(0.70)) + stcSvc.spawnObject('object/static/vehicle/shared_static_tie_fighter.iff', 'kaas', long(0), float(-5158.5), float(85.0), float(-2257.4), float(0.70), float(0.70)) + + #Streetlamps stcSvc.spawnObject('object/static/structure/general/shared_streetlamp_large_blue_style_01_on.iff', 'kaas', long(0), float(-5109.9), float(80.0), float(-2289.9), float(0), float(0)) stcSvc.spawnObject('object/static/structure/general/shared_streetlamp_large_blue_style_01_on.iff', 'kaas', long(0), float(-5125.9), float(80.0), float(-2289.9), float(0), float(0)) From 9a8975dcbcb29f47958a9a19a614ecd5d24d497d Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 14:47:56 +0100 Subject: [PATCH 28/68] Made cooldowns more efficient Isn't really necessary for them to have their own thread each. There's an old trick from a time before thread pools were possible: System.currentTimeMillis(). --- .../objects/creature/CreatureObject.java | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 2043b928..74b2d7f3 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -21,6 +21,8 @@ ******************************************************************************/ package resources.objects.creature; +import java.lang.System; + import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -182,7 +184,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { @NotPersistent private TangibleObject conversingNpc; @NotPersistent - private ConcurrentHashMap cooldowns = new ConcurrentHashMap(); + private ConcurrentHashMap cooldowns = new ConcurrentHashMap(); public CreatureObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) { super(objectID, planet, Template, position, orientation); @@ -1733,24 +1735,21 @@ public class CreatureObject extends TangibleObject implements IPersistent { cooldowns.remove(cooldownGroup); } - long duration = ((long) (cooldownTime * 1000F)); + long duration = System.currentTimeMillis() + ((long) (cooldownTime * 1000F)); - Cooldown cooldown = new Cooldown(duration); - - cooldown.setRemovalTask(Executors.newScheduledThreadPool(1).schedule(new Runnable() { - - @Override - public void run() { - removeCooldown(cooldownGroup); - } - - }, duration, TimeUnit.MILLISECONDS)); - - cooldowns.put(cooldownGroup, cooldown); + cooldowns.put(cooldownGroup, duration); } public boolean hasCooldown(String cooldownGroup) { - return cooldowns.containsKey(cooldownGroup); + if (cooldowns.containsKey(cooldownGroup)) { + if (System.currentTimeMillis() < cooldowns.get(cooldownGroup)) { + return true; + } else { + removeCooldown(cooldownGroup); + } + } + + return false; } public boolean removeCooldown(String cooldownGroup) { @@ -1763,7 +1762,23 @@ public class CreatureObject extends TangibleObject implements IPersistent { } public Cooldown getCooldown(String cooldownGroup) { - return cooldowns.get(cooldownGroup); + return new Cooldown(getRemainingCooldown(cooldownGroup)); } + public long getRemainingCooldown(String cooldownGroup) { + if (cooldowns.containsKey(cooldownGroup)) { + if (System.currentTimeMillis() < cooldowns.get(cooldownGroup)) { + return (long) (cooldowns.get(cooldownGroup) - System.currentTimeMillis()); + } else { + removeCooldown(cooldownGroup); + } + } + + return 0L; + } + + //public float getCooldown(String cooldownGroup) { + //return ((float) getCooldown(cooldownGroup) / (float) 1000); + //} + } From fa90012d5c86282ac020744607f7dd066eadd735 Mon Sep 17 00:00:00 2001 From: Seefo Date: Mon, 7 Apr 2014 10:32:25 -0400 Subject: [PATCH 29/68] Fixed some errors in the Command Service --- src/services/command/CommandService.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 268b34b2..55af0017 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -80,7 +80,7 @@ public class CommandService implements INetworkDispatch { return false; } - if (command.getGodLevel() > 0 && !client.isGM()) { + if (command.getGodLevel() > 0 && !actor.getClient().isGM()) { return false; } @@ -118,7 +118,7 @@ public class CommandService implements INetworkDispatch { return false; } - if (target != null && actor.getPosition().getDistance(target.getPosition) > command.getMaxRangeToTarget()) { + if (target != null && actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) { return false; } @@ -167,13 +167,13 @@ public class CommandService implements INetworkDispatch { TangibleObject object = (TangibleObject) target; - if (object.isAttackableBy(actor) || actor.getFactionStatus() < object.getFactionStatus() || (!object.getFaction().equals("") && !object.getFaction().equals(actor.getFaction()))) { + if (object.isAttackableBy(actor) || actor.getFactionStatus() < ((CreatureObject) object).getFactionStatus() || (!object.getFaction().equals("") && !object.getFaction().equals(actor.getFaction()))) { return false; } // Without this we could be buffing ally NPCs and such if (object.getSlottedObject("ghost") == null) { - return; + return false; } break; @@ -182,9 +182,9 @@ public class CommandService implements INetworkDispatch { return false; } - TangibleObject object = (TangibleObject) target; + TangibleObject targetObject = (TangibleObject) target; - if (!object.isAttackableBy(actor)) { + if (!targetObject.isAttackableBy(actor)) { return false; } @@ -203,14 +203,16 @@ public class CommandService implements INetworkDispatch { actor = (CreatureObject) target; } - long warmupTime = (command.getWarmupTime() * 1000F); + long warmupTime = (long) (command.getWarmupTime() * 1000F); + final CreatureObject actorObject = actor; + final SWGObject targetObject = target; if (warmupTime != 0) { scheduler.schedule(new Runnable() { @Override public void run() { - processCommand(actor, target, command, actionCounter, commandArgs); + processCommand(actorObject, targetObject, command, actionCounter, commandArgs); } }, warmupTime, TimeUnit.MILLISECONDS); @@ -333,7 +335,7 @@ public class CommandService implements INetworkDispatch { processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); } else { if (FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName() + ".py")) { - core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandEnqueue.getCommandArguments()); + core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandArgs); } } } From 7d4291b16e3331780d39dd7d416d2bf9ba5435a5 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 16:31:23 +0100 Subject: [PATCH 30/68] All command tables now get read --- src/services/command/BaseSWGCommand.java | 178 ++++++++++++----------- 1 file changed, 94 insertions(+), 84 deletions(-) diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index 9ac776a1..7ded241d 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -35,7 +35,7 @@ public class BaseSWGCommand implements Cloneable { private String clientEffectTarget; private int commandCRC; private boolean isGmCommand = false; - private String characterAbility; + private String characterAbility = null; private int target; private int targetType; private boolean callOnTarget = false; @@ -60,92 +60,102 @@ public class BaseSWGCommand implements Cloneable { setCommandCRC(CRC.StringtoCRC(commandName)); try { - List invalidStates = new ArrayList(); - List invalidPostures = new ArrayList(); + String[] tableArray = new String[] { + "client_command_table", "client_command_table_ground", "client_command_table_space", + "command_table", "command_table_ground", "command_table_space", "command_table_atmospheric_flight" }; - DatatableVisitor visitor2 = ClientFileManager.loadFile("datatables/command/command_table.iff", DatatableVisitor.class); - - for (int i = 0; i < visitor2.getRowCount(); i++) { - if (visitor2.getObject(i, 0) != null) { - if (((String) visitor2.getObject(i, 0)).equalsIgnoreCase(commandName)) { - characterAbility = (String) visitor2.getObject(i, 7); - target = (Integer) visitor2.getObject(i, 72); - targetType = (Integer) visitor2.getObject(i, 73); - callOnTarget = (Boolean) visitor2.getObject(i, 76); - commandGroup = (Integer) visitor2.getObject(i, 77); - disabled = (Boolean) visitor2.getObject(i, 78); - maxRangeToTarget = (Float) visitor2.getObject(i, 79); - godLevel = (Integer) visitor2.getObject(i, 80); - displayGroup = (Integer) visitor2.getObject(i, 81); - combatCommand = (Boolean) visitor2.getObject(i, 82); - validWeapon = (Integer) visitor2.getObject(i, 83); - invalidWeapon = (Integer) visitor2.getObject(i, 84); - cooldownGroup = (String) visitor2.getObject(i, 85); - warmupTime = (Float) visitor2.getObject(i, 86); - executeTime = (Float) visitor2.getObject(i, 87); - cooldown = (Float) visitor2.getObject(i, 88); - - if (!((Boolean) visitor2.getObject(i, 8))) invalidPostures.add((byte) 0); - if (!((Boolean) visitor2.getObject(i, 9))) invalidPostures.add((byte) 3); - if (!((Boolean) visitor2.getObject(i, 16))) invalidPostures.add((byte) 2); - if (!((Boolean) visitor2.getObject(i, 19))) invalidPostures.add((byte) 5); - if (!((Boolean) visitor2.getObject(i, 21))) invalidPostures.add((byte) 6); - if (!((Boolean) visitor2.getObject(i, 22))) invalidPostures.add((byte) 7); - if (!((Boolean) visitor2.getObject(i, 23))) invalidPostures.add((byte) 8); - if (!((Boolean) visitor2.getObject(i, 24))) invalidPostures.add((byte) 9); - if (!((Boolean) visitor2.getObject(i, 25))) invalidPostures.add((byte) 10); - if (!((Boolean) visitor2.getObject(i, 26))) invalidPostures.add((byte) 11); - if (!((Boolean) visitor2.getObject(i, 27))) invalidPostures.add((byte) 12); - if (!((Boolean) visitor2.getObject(i, 28))) invalidPostures.add((byte) 13); - if (!((Boolean) visitor2.getObject(i, 29))) invalidPostures.add((byte) 14); - if (!((Boolean) visitor2.getObject(i, 30))) invalidPostures.add((byte) 4); - - if (!((Boolean) visitor2.getObject(i, 32))) invalidStates.add(1L); - if (!((Boolean) visitor2.getObject(i, 33))) invalidStates.add(2L); - if (!((Boolean) visitor2.getObject(i, 34))) invalidStates.add(4L); - if (!((Boolean) visitor2.getObject(i, 35))) invalidStates.add(8L); - if (!((Boolean) visitor2.getObject(i, 36))) invalidStates.add(16L); - if (!((Boolean) visitor2.getObject(i, 37))) invalidStates.add(32L); - if (!((Boolean) visitor2.getObject(i, 38))) invalidStates.add(64L); - if (!((Boolean) visitor2.getObject(i, 39))) invalidStates.add(128L); - if (!((Boolean) visitor2.getObject(i, 40))) invalidStates.add(256L); - if (!((Boolean) visitor2.getObject(i, 41))) invalidStates.add(512L); - if (!((Boolean) visitor2.getObject(i, 42))) invalidStates.add(1024L); - if (!((Boolean) visitor2.getObject(i, 43))) invalidStates.add(2048L); - if (!((Boolean) visitor2.getObject(i, 44))) invalidStates.add(4096L); - if (!((Boolean) visitor2.getObject(i, 45))) invalidStates.add(8192L); - if (!((Boolean) visitor2.getObject(i, 46))) invalidStates.add(16384L); - if (!((Boolean) visitor2.getObject(i, 47))) invalidStates.add(32768L); - if (!((Boolean) visitor2.getObject(i, 48))) invalidStates.add(65536L); - if (!((Boolean) visitor2.getObject(i, 49))) invalidStates.add(131072L); - if (!((Boolean) visitor2.getObject(i, 50))) invalidStates.add(262144L); - if (!((Boolean) visitor2.getObject(i, 51))) invalidStates.add(524288L); - if (!((Boolean) visitor2.getObject(i, 52))) invalidStates.add(1048576L); - if (!((Boolean) visitor2.getObject(i, 53))) invalidStates.add(2097152L); - if (!((Boolean) visitor2.getObject(i, 54))) invalidStates.add(4194304L); - if (!((Boolean) visitor2.getObject(i, 55))) invalidStates.add(8388608L); - if (!((Boolean) visitor2.getObject(i, 56))) invalidStates.add(16777216L); - if (!((Boolean) visitor2.getObject(i, 57))) invalidStates.add(33554432L); - if (!((Boolean) visitor2.getObject(i, 58))) invalidStates.add(67108864L); - if (!((Boolean) visitor2.getObject(i, 59))) invalidStates.add(134217728L); - if (!((Boolean) visitor2.getObject(i, 60))) invalidStates.add(268435456L); - if (!((Boolean) visitor2.getObject(i, 61))) invalidStates.add(536870912L); - if (!((Boolean) visitor2.getObject(i, 62))) invalidStates.add(1073741824L); - if (!((Boolean) visitor2.getObject(i, 63))) invalidStates.add(2147483648L); - if (!((Boolean) visitor2.getObject(i, 64))) invalidStates.add(4294967296L); - if (!((Boolean) visitor2.getObject(i, 65))) invalidStates.add(8589934592L); - if (!((Boolean) visitor2.getObject(i, 66))) invalidStates.add(17179869184L); - if (!((Boolean) visitor2.getObject(i, 67))) invalidStates.add(34359738368L); - if (!((Boolean) visitor2.getObject(i, 68))) invalidStates.add(68719476736L); - if (!((Boolean) visitor2.getObject(i, 69))) invalidStates.add(137438953472L); - if (!((Boolean) visitor2.getObject(i, 70))) invalidStates.add(274877906944L); - - this.invalidPostures = invalidPostures.toArray(new Byte[] { }); - this.invalidStates = invalidStates.toArray(new Long[] { }); - - break; + for (int n = 0; n < tableArray.length; n++) { + List invalidStates = new ArrayList(); + List invalidPostures = new ArrayList(); + + DatatableVisitor visitor2 = ClientFileManager.loadFile("datatables/command/" + tableArray[n] + ".iff", DatatableVisitor.class); + + for (int i = 0; i < visitor2.getRowCount(); i++) { + if (visitor2.getObject(i, 0) != null) { + if (((String) visitor2.getObject(i, 0)).equalsIgnoreCase(commandName)) { + characterAbility = (String) visitor2.getObject(i, 7); + target = (Integer) visitor2.getObject(i, 72); + targetType = (Integer) visitor2.getObject(i, 73); + callOnTarget = (Boolean) visitor2.getObject(i, 76); + commandGroup = (Integer) visitor2.getObject(i, 77); + disabled = (Boolean) visitor2.getObject(i, 78); + maxRangeToTarget = (Float) visitor2.getObject(i, 79); + godLevel = (Integer) visitor2.getObject(i, 80); + displayGroup = (Integer) visitor2.getObject(i, 81); + combatCommand = (Boolean) visitor2.getObject(i, 82); + validWeapon = (Integer) visitor2.getObject(i, 83); + invalidWeapon = (Integer) visitor2.getObject(i, 84); + cooldownGroup = (String) visitor2.getObject(i, 85); + warmupTime = (Float) visitor2.getObject(i, 86); + executeTime = (Float) visitor2.getObject(i, 87); + cooldown = (Float) visitor2.getObject(i, 88); + + if (!((Boolean) visitor2.getObject(i, 8))) invalidPostures.add((byte) 0); + if (!((Boolean) visitor2.getObject(i, 9))) invalidPostures.add((byte) 3); + if (!((Boolean) visitor2.getObject(i, 16))) invalidPostures.add((byte) 2); + if (!((Boolean) visitor2.getObject(i, 19))) invalidPostures.add((byte) 5); + if (!((Boolean) visitor2.getObject(i, 21))) invalidPostures.add((byte) 6); + if (!((Boolean) visitor2.getObject(i, 22))) invalidPostures.add((byte) 7); + if (!((Boolean) visitor2.getObject(i, 23))) invalidPostures.add((byte) 8); + if (!((Boolean) visitor2.getObject(i, 24))) invalidPostures.add((byte) 9); + if (!((Boolean) visitor2.getObject(i, 25))) invalidPostures.add((byte) 10); + if (!((Boolean) visitor2.getObject(i, 26))) invalidPostures.add((byte) 11); + if (!((Boolean) visitor2.getObject(i, 27))) invalidPostures.add((byte) 12); + if (!((Boolean) visitor2.getObject(i, 28))) invalidPostures.add((byte) 13); + if (!((Boolean) visitor2.getObject(i, 29))) invalidPostures.add((byte) 14); + if (!((Boolean) visitor2.getObject(i, 30))) invalidPostures.add((byte) 4); + + if (!((Boolean) visitor2.getObject(i, 32))) invalidStates.add(1L); + if (!((Boolean) visitor2.getObject(i, 33))) invalidStates.add(2L); + if (!((Boolean) visitor2.getObject(i, 34))) invalidStates.add(4L); + if (!((Boolean) visitor2.getObject(i, 35))) invalidStates.add(8L); + if (!((Boolean) visitor2.getObject(i, 36))) invalidStates.add(16L); + if (!((Boolean) visitor2.getObject(i, 37))) invalidStates.add(32L); + if (!((Boolean) visitor2.getObject(i, 38))) invalidStates.add(64L); + if (!((Boolean) visitor2.getObject(i, 39))) invalidStates.add(128L); + if (!((Boolean) visitor2.getObject(i, 40))) invalidStates.add(256L); + if (!((Boolean) visitor2.getObject(i, 41))) invalidStates.add(512L); + if (!((Boolean) visitor2.getObject(i, 42))) invalidStates.add(1024L); + if (!((Boolean) visitor2.getObject(i, 43))) invalidStates.add(2048L); + if (!((Boolean) visitor2.getObject(i, 44))) invalidStates.add(4096L); + if (!((Boolean) visitor2.getObject(i, 45))) invalidStates.add(8192L); + if (!((Boolean) visitor2.getObject(i, 46))) invalidStates.add(16384L); + if (!((Boolean) visitor2.getObject(i, 47))) invalidStates.add(32768L); + if (!((Boolean) visitor2.getObject(i, 48))) invalidStates.add(65536L); + if (!((Boolean) visitor2.getObject(i, 49))) invalidStates.add(131072L); + if (!((Boolean) visitor2.getObject(i, 50))) invalidStates.add(262144L); + if (!((Boolean) visitor2.getObject(i, 51))) invalidStates.add(524288L); + if (!((Boolean) visitor2.getObject(i, 52))) invalidStates.add(1048576L); + if (!((Boolean) visitor2.getObject(i, 53))) invalidStates.add(2097152L); + if (!((Boolean) visitor2.getObject(i, 54))) invalidStates.add(4194304L); + if (!((Boolean) visitor2.getObject(i, 55))) invalidStates.add(8388608L); + if (!((Boolean) visitor2.getObject(i, 56))) invalidStates.add(16777216L); + if (!((Boolean) visitor2.getObject(i, 57))) invalidStates.add(33554432L); + if (!((Boolean) visitor2.getObject(i, 58))) invalidStates.add(67108864L); + if (!((Boolean) visitor2.getObject(i, 59))) invalidStates.add(134217728L); + if (!((Boolean) visitor2.getObject(i, 60))) invalidStates.add(268435456L); + if (!((Boolean) visitor2.getObject(i, 61))) invalidStates.add(536870912L); + if (!((Boolean) visitor2.getObject(i, 62))) invalidStates.add(1073741824L); + if (!((Boolean) visitor2.getObject(i, 63))) invalidStates.add(2147483648L); + if (!((Boolean) visitor2.getObject(i, 64))) invalidStates.add(4294967296L); + if (!((Boolean) visitor2.getObject(i, 65))) invalidStates.add(8589934592L); + if (!((Boolean) visitor2.getObject(i, 66))) invalidStates.add(17179869184L); + if (!((Boolean) visitor2.getObject(i, 67))) invalidStates.add(34359738368L); + if (!((Boolean) visitor2.getObject(i, 68))) invalidStates.add(68719476736L); + if (!((Boolean) visitor2.getObject(i, 69))) invalidStates.add(137438953472L); + if (!((Boolean) visitor2.getObject(i, 70))) invalidStates.add(274877906944L); + + this.invalidPostures = invalidPostures.toArray(new Byte[] { }); + this.invalidStates = invalidStates.toArray(new Long[] { }); + + break; + } } } + + if (characterAbility != null) { + break; + } } } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); From f70811f6b723f14f16c015691ed4f76b8d83803d Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 16:42:19 +0100 Subject: [PATCH 31/68] CommandSvc reads all command tables (in priority) --- src/services/command/CommandService.java | 76 ++++++++++++++---------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 55af0017..c6b5fab0 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -256,24 +256,30 @@ public class CommandService implements INetworkDispatch { } try { - DatatableVisitor visitor = ClientFileManager.loadFile("datatables/command/command_table.iff", DatatableVisitor.class); + String[] tableArray = new String[] { + "client_command_table", "command_table", "client_command_table_ground", "command_table_ground", + "client_command_table_space", "command_table_space", "command_table_atmospheric_flight" }; - for (int i = 0; i < visitor.getRowCount(); i++) { - if (visitor.getObject(i, 0) != null) { - String name = ((String) visitor.getObject(i, 0)).toLowerCase(); - - if (CRC.StringtoCRC(name) == commandCRC) { - boolean hasCharacterAbility = (((String) visitor.getObject(i, 7)).length() > 0); - boolean isCombatCommand = (Boolean) visitor.getObject(i, 82); + for (int n = 0; n < tableArray.length; n++) { + DatatableVisitor visitor = ClientFileManager.loadFile("datatables/command/" + tableArray[n] + ".iff", DatatableVisitor.class); + + for (int i = 0; i < visitor.getRowCount(); i++) { + if (visitor.getObject(i, 0) != null) { + String name = ((String) visitor.getObject(i, 0)).toLowerCase(); - if (hasCharacterAbility || isCombatCommand) { - CombatCommand command = new CombatCommand(name.toLowerCase()); - commandLookup.add(command); - return command; - } else { - BaseSWGCommand command = new BaseSWGCommand(name.toLowerCase()); - commandLookup.add(command); - return command; + if (CRC.StringtoCRC(name) == commandCRC) { + boolean hasCharacterAbility = (((String) visitor.getObject(i, 7)).length() > 0); + boolean isCombatCommand = (Boolean) visitor.getObject(i, 82); + + if (hasCharacterAbility || isCombatCommand) { + CombatCommand command = new CombatCommand(name.toLowerCase()); + commandLookup.add(command); + return command; + } else { + BaseSWGCommand command = new BaseSWGCommand(name.toLowerCase()); + commandLookup.add(command); + return command; + } } } } @@ -297,24 +303,30 @@ public class CommandService implements INetworkDispatch { } try { - DatatableVisitor visitor = ClientFileManager.loadFile("datatables/command/command_table.iff", DatatableVisitor.class); + String[] tableArray = new String[] { + "client_command_table", "command_table", "client_command_table_ground", "command_table_ground", + "client_command_table_space", "command_table_space", "command_table_atmospheric_flight" }; - for (int i = 0; i < visitor.getRowCount(); i++) { - if (visitor.getObject(i, 0) != null) { - String commandName = ((String) visitor.getObject(i, 0)).toLowerCase(); - - if (commandName.equalsIgnoreCase(name)) { - boolean hasCharacterAbility = (((String) visitor.getObject(i, 7)).length() > 0); - boolean isCombatCommand = (Boolean) visitor.getObject(i, 82); + for (int n = 0; n < tableArray.length; n++) { + DatatableVisitor visitor = ClientFileManager.loadFile("datatables/command/" + tableArray[n] + ".iff", DatatableVisitor.class); + + for (int i = 0; i < visitor.getRowCount(); i++) { + if (visitor.getObject(i, 0) != null) { + String commandName = ((String) visitor.getObject(i, 0)).toLowerCase(); - if (hasCharacterAbility || isCombatCommand) { - CombatCommand command = new CombatCommand(commandName); - commandLookup.add(command); - return command; - } else { - BaseSWGCommand command = new BaseSWGCommand(commandName); - commandLookup.add(command); - return command; + if (commandName.equalsIgnoreCase(name)) { + boolean hasCharacterAbility = (((String) visitor.getObject(i, 7)).length() > 0); + boolean isCombatCommand = (Boolean) visitor.getObject(i, 82); + + if (hasCharacterAbility || isCombatCommand) { + CombatCommand command = new CombatCommand(commandName); + commandLookup.add(command); + return command; + } else { + BaseSWGCommand command = new BaseSWGCommand(commandName); + commandLookup.add(command); + return command; + } } } } From 06fe72e647ba9d73ecf1720b17a4639bd712adc2 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Mon, 7 Apr 2014 23:49:51 +0200 Subject: [PATCH 32/68] Implementation of LootService First steps --- scripts/object/mobile/tusken_raider.py | 13 ++ src/resources/objects/loot/LootDrop.java | 21 +++ .../objects/tangible/TangibleObject.java | 19 ++- src/services/DevService.java | 3 + src/services/LootService.java | 161 ++++++++++++++++++ 5 files changed, 215 insertions(+), 2 deletions(-) create mode 100644 src/resources/objects/loot/LootDrop.java create mode 100644 src/services/LootService.java diff --git a/scripts/object/mobile/tusken_raider.py b/scripts/object/mobile/tusken_raider.py index ccad8904..37e94fa4 100644 --- a/scripts/object/mobile/tusken_raider.py +++ b/scripts/object/mobile/tusken_raider.py @@ -1,4 +1,17 @@ import sys def setup(core, object): + + lootSpecification = [ + [ + ['Junk',90], + ['Rifles',70], + ['ParentProbability',60] + ], + [ + ['Colorcrystal',100], + ['ParentProbability',50] + ] + ] + object.setLootSpecification(lootSpecification) return \ No newline at end of file diff --git a/src/resources/objects/loot/LootDrop.java b/src/resources/objects/loot/LootDrop.java new file mode 100644 index 00000000..211fdca3 --- /dev/null +++ b/src/resources/objects/loot/LootDrop.java @@ -0,0 +1,21 @@ +package resources.objects.loot; + +import java.util.ArrayList; +import java.util.List; + +public class LootDrop { + + private List elements = new ArrayList(); + + public LootDrop(){ + + } + + public void addElement(String element){ + elements.add(element); + } + + public List getElements(){ + return elements; + } +} diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index dce95545..6639ac5f 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -23,12 +23,17 @@ package resources.objects.tangible; import java.io.ByteArrayOutputStream; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; import java.util.Vector; import javax.xml.bind.DatatypeConverter; @@ -54,7 +59,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=1) +@Persistent(version=2) public class TangibleObject extends SWGObject { // TODO: Thread safety @@ -77,6 +82,8 @@ public class TangibleObject extends SWGObject { private int respawnTime = 0; private Point3D spawnCoordinates = new Point3D(0, 0, 0); + private TreeSet> lootSpecification = new TreeSet>(); + @NotPersistent private TangibleObject killer = null; @@ -444,6 +451,15 @@ public class TangibleObject extends SWGObject { } } + public TreeSet> getLootSpecification() { + return lootSpecification; + } + + public void setLootSpecification( + TreeSet> lootSpecification) { + this.lootSpecification = lootSpecification; + } + @Override public void sendBaselines(Client destination) { @@ -467,5 +483,4 @@ public class TangibleObject extends SWGObject { } - } diff --git a/src/services/DevService.java b/src/services/DevService.java index 0cde2b83..2ce2c1f6 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -991,6 +991,9 @@ public class DevService implements INetworkDispatch { solarSurveyTool.setCustomName("Solar Survey Device"); inventory.add(solarSurveyTool); + + core.staticService.spawnObject("object/mobile/shared_tusken_raider.iff", "tatooine", 0L, 3522F, 4F, -4801F, 0.70F, 0.71F); + break; } } diff --git a/src/services/LootService.java b/src/services/LootService.java new file mode 100644 index 00000000..bfa233aa --- /dev/null +++ b/src/services/LootService.java @@ -0,0 +1,161 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Random; +import java.util.TreeMap; +import java.util.TreeSet; + +import resources.objects.creature.CreatureObject; +import resources.objects.group.GroupObject; +import resources.objects.loot.LootDrop; +import resources.objects.player.PlayerObject; +import resources.objects.tangible.TangibleObject; +import resources.objects.tool.SurveyTool; +import main.NGECore; +import engine.resources.objects.SWGObject; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; + +/** + * @author Charon + */ + +public class LootService implements INetworkDispatch { + + private NGECore core; + + public LootService(NGECore core) { + this.core = core; + //core.commandService.registerCommand(""); + } + + @Override + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + + } + + @Override + public void shutdown() { + + } + + public void handleLootRequest(CreatureObject requester, TangibleObject lootedObject) { + + String lootedObjectType = "Tangible"; + if (lootedObject instanceof CreatureObject) + lootedObjectType = "Creature"; + + // Credit drop is depending on the CL of the looted CreatureObject + // or if explicitely assigned in the .py script + int lootedCredits = 0; + if (lootedObjectType.equals("Creature")){ + CreatureObject lootedCreature = (CreatureObject) lootedObject; + int creatureCL = lootedCreature.getLevel(); + int minimalCredits = 40 * creatureCL; // Predetermined factor of 40 per CL + int spanOfCredits = 15 * creatureCL; // Predetermined factor of 15 per CL + lootedCredits = minimalCredits + new Random().nextInt(spanOfCredits); + } + + if (lootedObjectType.equals("Tangible")){ + // This is for chests etc. + // Check the py script + } + + + List lootDrops = new ArrayList(); + List lootElements = new ArrayList(); + + TreeSet> lootSpec = lootedObject.getLootSpecification(); + Iterator> iterator = lootSpec.iterator(); + + while (iterator.hasNext()){ + TreeMap lootPool = iterator.next(); + int poolProbability = lootPool.lastEntry().getValue(); + int lootPoolRoll = new Random().nextInt(100); + if (lootPoolRoll <= poolProbability){ + lootElements = handleLootPool(lootPool); //this lootPool will drop + } + } + + // Now handle the chosen pools and determine the according items + + for (String element : lootElements){ + lootDrops = handleLootPoolElement(element); + } + + // ********** Phase 1 complete, loot items determined ********** + + // Distribute the loot drops according to group loot rules + + + // For now just spawn items into requester's inventory + for (LootDrop dropElem : lootDrops){ + PlayerObject requesterObj = (PlayerObject) requester.getSlottedObject("ghost"); + SWGObject requesterInventory = requesterObj.getSlottedObject("inventory"); + List elementList = dropElem.getElements(); + for (String template : elementList){ + TangibleObject droppedItem = (TangibleObject) core.objectService.createObject(template, requester.getPlanet()); + requesterInventory.add(droppedItem); + } + } + + + // ToDo: Group loot settings etc. + + // [20:35] <@_Light> your actual loot chance was lootgroupchance*lootchance + long leaderGroupId = requester.getGroupId(); + GroupObject group = (GroupObject) core.objectService.getObject(leaderGroupId); + if(group.getMemberList().size() == 1) { + // looter is alone + } + } + + + private List handleLootPool(TreeMap lootPool){ + List lootElements = new ArrayList(); + for(Map.Entry entry : lootPool.entrySet()) { + String poolElementName = entry.getKey(); + int poolElementProbability = entry.getValue(); + int lootPoolElementRoll = new Random().nextInt(100); + if (lootPoolElementRoll <= poolElementProbability){ + lootElements.add(poolElementName); + } + } + + return lootElements; + } + + private List handleLootPoolElement(String element){ + List lootDropList = new ArrayList(); + // This is just a random element from the python + + return lootDropList; + } +} From ce183ad337a8c59007590c1418a13032687d9a2e Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Mon, 7 Apr 2014 23:59:42 +0200 Subject: [PATCH 33/68] merge conflict resolve --- src/services/command/BaseSWGCommand.java | 365 +++++++++++++++ src/services/command/CommandService.java | 571 +++++++++++++++++++++++ 2 files changed, 936 insertions(+) create mode 100644 src/services/command/BaseSWGCommand.java create mode 100644 src/services/command/CommandService.java diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java new file mode 100644 index 00000000..0448a8ea --- /dev/null +++ b/src/services/command/BaseSWGCommand.java @@ -0,0 +1,365 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.command; + +import engine.clientdata.ClientFileManager; +import engine.clientdata.visitors.DatatableVisitor; +import engine.resources.common.CRC; + +import java.util.ArrayList; +import java.util.List; + +public class BaseSWGCommand implements Cloneable { + + private String commandName; + private String clientEffectSelf; + private String clientEffectTarget; + private int commandCRC; + private boolean isGmCommand = false; + private String characterAbility; + private int target; + private int targetType; + private boolean callOnTarget = false; + private int commandGroup; + private boolean disabled = true; + private float maxRangeToTarget; + private int godLevel; + private int displayGroup; + private boolean combatCommand = false; + private int validWeapon; + private int invalidWeapon; + private String cooldownGroup; + private float cooldown; + private float executeTime; + private float warmupTime; + //private Long[] invalidLocomotions; // Not tracked anywhere + private Byte[] invalidPostures; + private Long[] invalidStates; + + public BaseSWGCommand(String commandName) { + setCommandName(commandName); + setCommandCRC(CRC.StringtoCRC(commandName)); + + try { + boolean foundCommand = false; + + String[] tableArray = new String[] { + "client_command_table", "client_command_table_ground", "client_command_table_space", + "command_table", "command_table_ground", "command_table_space" }; + + for (int n = 0; n < tableArray.length; n++) { + List invalidStates = new ArrayList(); + List invalidPostures = new ArrayList(); + + DatatableVisitor visitor2 = ClientFileManager.loadFile("datatables/command/" + tableArray[n] + ".iff", DatatableVisitor.class); + + for (int i = 0; i < visitor2.getRowCount(); i++) { + if (visitor2.getObject(i, 0) != null) { + if (((String) visitor2.getObject(i, 0)).equalsIgnoreCase(commandName)) { + int sub = 0; // Subtract due to command table structures being different + + characterAbility = (String) visitor2.getObject(i, 7); + + if (!((Boolean) visitor2.getObject(i, 8-sub))) invalidPostures.add((byte) 0); + if (!((Boolean) visitor2.getObject(i, 9-sub))) invalidPostures.add((byte) 3); + if (!((Boolean) visitor2.getObject(i, 15-sub))) invalidPostures.add((byte) 2); + if (!((Boolean) visitor2.getObject(i, 18-sub))) invalidPostures.add((byte) 5); + if (!((Boolean) visitor2.getObject(i, 20-sub))) invalidPostures.add((byte) 6); + if (!((Boolean) visitor2.getObject(i, 21-sub))) invalidPostures.add((byte) 7); + if (!((Boolean) visitor2.getObject(i, 22-sub))) invalidPostures.add((byte) 8); + if (!((Boolean) visitor2.getObject(i, 23-sub))) invalidPostures.add((byte) 9); + if (!((Boolean) visitor2.getObject(i, 24-sub))) invalidPostures.add((byte) 10); + if (!((Boolean) visitor2.getObject(i, 25-sub))) invalidPostures.add((byte) 11); + if (!((Boolean) visitor2.getObject(i, 26-sub))) invalidPostures.add((byte) 12); + if (!((Boolean) visitor2.getObject(i, 27-sub))) invalidPostures.add((byte) 13); + if (!((Boolean) visitor2.getObject(i, 28-sub))) invalidPostures.add((byte) 14); + if (!((Boolean) visitor2.getObject(i, 29-sub))) invalidPostures.add((byte) 4); + + if (tableArray[n].startsWith("client_") || tableArray[n].startsWith("command_table_")) { + sub += 1; + } + + if (!((Boolean) visitor2.getObject(i, 32-sub))) invalidStates.add(1L); + if (!((Boolean) visitor2.getObject(i, 33-sub))) invalidStates.add(2L); + if (!((Boolean) visitor2.getObject(i, 34-sub))) invalidStates.add(4L); + if (!((Boolean) visitor2.getObject(i, 35-sub))) invalidStates.add(8L); + if (!((Boolean) visitor2.getObject(i, 36-sub))) invalidStates.add(16L); + if (!((Boolean) visitor2.getObject(i, 37-sub))) invalidStates.add(32L); + if (!((Boolean) visitor2.getObject(i, 38-sub))) invalidStates.add(64L); + if (!((Boolean) visitor2.getObject(i, 39-sub))) invalidStates.add(128L); + if (!((Boolean) visitor2.getObject(i, 40-sub))) invalidStates.add(256L); + if (!((Boolean) visitor2.getObject(i, 41-sub))) invalidStates.add(512L); + if (!((Boolean) visitor2.getObject(i, 42-sub))) invalidStates.add(1024L); + if (!((Boolean) visitor2.getObject(i, 43-sub))) invalidStates.add(2048L); + if (!((Boolean) visitor2.getObject(i, 44-sub))) invalidStates.add(4096L); + if (!((Boolean) visitor2.getObject(i, 45-sub))) invalidStates.add(8192L); + if (!((Boolean) visitor2.getObject(i, 46-sub))) invalidStates.add(16384L); + if (!((Boolean) visitor2.getObject(i, 47-sub))) invalidStates.add(32768L); + if (!((Boolean) visitor2.getObject(i, 48-sub))) invalidStates.add(65536L); + if (!((Boolean) visitor2.getObject(i, 49-sub))) invalidStates.add(131072L); + if (!((Boolean) visitor2.getObject(i, 50-sub))) invalidStates.add(262144L); + if (!((Boolean) visitor2.getObject(i, 51-sub))) invalidStates.add(524288L); + if (!((Boolean) visitor2.getObject(i, 52-sub))) invalidStates.add(1048576L); + if (!((Boolean) visitor2.getObject(i, 53-sub))) invalidStates.add(2097152L); + if (!((Boolean) visitor2.getObject(i, 54-sub))) invalidStates.add(4194304L); + if (!((Boolean) visitor2.getObject(i, 55-sub))) invalidStates.add(8388608L); + if (!((Boolean) visitor2.getObject(i, 56-sub))) invalidStates.add(16777216L); + if (!((Boolean) visitor2.getObject(i, 57-sub))) invalidStates.add(33554432L); + if (!((Boolean) visitor2.getObject(i, 58-sub))) invalidStates.add(67108864L); + if (!((Boolean) visitor2.getObject(i, 59-sub))) invalidStates.add(134217728L); + + if (!tableArray[n].equals("client_command_table_space")) { + if (!((Boolean) visitor2.getObject(i, 60-sub))) invalidStates.add(268435456L); + if (!((Boolean) visitor2.getObject(i, 61-sub))) invalidStates.add(536870912L); + if (!((Boolean) visitor2.getObject(i, 62-sub))) invalidStates.add(1073741824L); + if (!((Boolean) visitor2.getObject(i, 63-sub))) invalidStates.add(2147483648L); + if (!((Boolean) visitor2.getObject(i, 64-sub))) invalidStates.add(4294967296L); + } else { + sub += 5; + } + + if (!tableArray[n].startsWith("client_") && !tableArray[n].startsWith("command_table_")) { + if (!((Boolean) visitor2.getObject(i, 65-sub))) invalidStates.add(8589934592L); + if (!((Boolean) visitor2.getObject(i, 66-sub))) invalidStates.add(17179869184L); + if (!((Boolean) visitor2.getObject(i, 67-sub))) invalidStates.add(34359738368L); + if (!((Boolean) visitor2.getObject(i, 68-sub))) invalidStates.add(68719476736L); + if (!((Boolean) visitor2.getObject(i, 69-sub))) invalidStates.add(137438953472L); + if (!((Boolean) visitor2.getObject(i, 70-sub))) invalidStates.add(274877906944L); + } else { + sub += 6; + } + + target = (Integer) visitor2.getObject(i, 72-sub); + targetType = (Integer) visitor2.getObject(i, 73-sub); + callOnTarget = (Boolean) visitor2.getObject(i, 76-sub); + commandGroup = (Integer) visitor2.getObject(i, 77-sub); + disabled = (Boolean) visitor2.getObject(i, 78-sub); + maxRangeToTarget = (Float) visitor2.getObject(i, 79-sub); + godLevel = (Integer) visitor2.getObject(i, 80-sub); + displayGroup = (Integer) visitor2.getObject(i, 81-sub); + combatCommand = (Boolean) visitor2.getObject(i, 82-sub); + validWeapon = (Integer) visitor2.getObject(i, 83-sub); + invalidWeapon = (Integer) visitor2.getObject(i, 84-sub); + cooldownGroup = (String) visitor2.getObject(i, 85-sub); + warmupTime = (Float) visitor2.getObject(i, 86-sub); + executeTime = (Float) visitor2.getObject(i, 87-sub); + cooldown = (Float) visitor2.getObject(i, 88-sub); + + this.invalidPostures = invalidPostures.toArray(new Byte[] { }); + this.invalidStates = invalidStates.toArray(new Long[] { }); + + foundCommand = true; + break; + } + } + } + + if (foundCommand) { + break; + } + } + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + } + + public String getCommandName() { + return commandName; + } + + public void setCommandName(String commandName) { + this.commandName = commandName; + } + + public String getClientEffectSelf() { + return clientEffectSelf; + } + + public void setClientEffectSelf(String clientEffectSelf) { + this.clientEffectSelf = clientEffectSelf; + } + + public String getClientEffectTarget() { + return clientEffectTarget; + } + + public void setClientEffectTarget(String clientEffectTarget) { + this.clientEffectTarget = clientEffectTarget; + } + + public int getCommandCRC() { + return commandCRC; + } + + public void setCommandCRC(int commandCRC) { + this.commandCRC = commandCRC; + } + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public boolean isGmCommand() { + return (godLevel > 0); + } + + public void setGmCommand(boolean isGmCommand) { + this.isGmCommand = isGmCommand; + } + + public String getCharacterAbility() { + return characterAbility; + } + + public void setcharacterAbility(String characterAbility) { + this.characterAbility = characterAbility; + } + + public Byte[] getInvalidPostures() { + return invalidPostures; + } + + public Long[] getInvalidStates() { + return invalidStates; + } + + public int getTarget() { + return target; + } + + public void setTarget(int target) { + this.target = target; + } + + public int getTargetType() { + return targetType; + } + + public void setTargetType(int targetType) { + this.targetType = targetType; + } + + public boolean shouldCallOnTarget() { + return callOnTarget; + } + + public void setCallOnTarget(boolean callOnTarget) { + this.callOnTarget = callOnTarget; + } + + public int getCommandGroup() { + return commandGroup; + } + + public void setCommandGroup(int commandGroup) { + this.commandGroup = commandGroup; + } + + public boolean isDisabled() { + return disabled; + } + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + public float getMaxRangeToTarget() { + return maxRangeToTarget; + } + + public void setMaxRangeToTarget(float maxRangeToTarget) { + this.maxRangeToTarget = maxRangeToTarget; + } + + public int getGodLevel() { + return godLevel; + } + + public void setGodLevel(int godLevel) { + this.godLevel = godLevel; + } + + public int getDisplayGroup() { + return displayGroup; + } + + public void setDisplayGroup(int displayGroup) { + this.displayGroup = displayGroup; + } + + public boolean isCombatCommand() { + return combatCommand; + } + + public void setCombatCommand(boolean combatCommand) { + this.combatCommand = combatCommand; + } + + public int getValidWeapon() { + return validWeapon; + } + + public void setValidWeapon(int validWeapon) { + this.validWeapon = validWeapon; + } + + public int getInvalidWeapon() { + return invalidWeapon; + } + + public void setInvalidWeapon(int invalidWeapon) { + this.invalidWeapon = invalidWeapon; + } + + public String getCooldownGroup() { + return cooldownGroup; + } + + public void setCooldownGroup(String cooldownGroup) { + this.cooldownGroup = cooldownGroup; + } + + public float getCooldown() { + return cooldown; + } + + public void setCooldown(float cooldown) { + this.cooldown = cooldown; + } + + public float getExecuteTime() { + return executeTime; + } + + public void setExecuteTime(float executeTime) { + this.executeTime = executeTime; + } + + public float getWarmupTime() { + return warmupTime; + } + + public void setWarmupTime(float warmupTime) { + this.warmupTime = warmupTime; + } + +} diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java new file mode 100644 index 00000000..8e9bcf44 --- /dev/null +++ b/src/services/command/CommandService.java @@ -0,0 +1,571 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.command; + +import java.nio.ByteOrder; +import java.util.Map; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import main.NGECore; + +import org.apache.mina.core.buffer.IoBuffer; +import org.apache.mina.core.session.IoSession; + +import engine.clientdata.ClientFileManager; +import engine.clientdata.visitors.DatatableVisitor; +import engine.clients.Client; +import engine.resources.common.CRC; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Point3D; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; +import resources.common.*; +import resources.datatables.StateStatus; +import protocol.swg.ObjControllerMessage; +import protocol.swg.objectControllerObjects.CommandEnqueue; +import protocol.swg.objectControllerObjects.CommandEnqueueRemove; +import protocol.swg.objectControllerObjects.ShowFlyText; +import protocol.swg.objectControllerObjects.StartTask; +import resources.objects.creature.CreatureObject; +import resources.objects.tangible.TangibleObject; +import resources.objects.weapon.WeaponObject; + +public class CommandService implements INetworkDispatch { + + private Vector commandLookup = new Vector(); + private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + private NGECore core; + + public CommandService(NGECore core) { + this.core = core; + } + + public boolean callCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { + if (actor == null) { + return false; + } + + if (command == null) { + return false; + } + + if (command.getCharacterAbility().length() > 0 && !actor.hasAbility(command.getCharacterAbility())) { + return false; + } + + if (command.isDisabled()) { + return false; + } + + if (command.getGodLevel() > 0 && !actor.getClient().isGM()) { + return false; + } + + if (actor.hasCooldown(command.getCooldownGroup()) || actor.hasCooldown(command.getCommandName())) { + return false; + } + + WeaponObject weapon = (WeaponObject) core.objectService.getObject(actor.getWeaponId()); + + if (weapon != null && weapon.getWeaponType() == command.getInvalidWeapon()) { + return false; + } + + // The two below statements need testing before use + + for (long state : command.getInvalidStates()) { + if ((actor.getStateBitmask() & state) == state) { + //return false; + } + } + + for (byte posture : command.getInvalidPostures()) { + if (actor.getPosture() == posture) { + //return false; + } + } + + switch (command.getTargetType()) { + case 0: // Target Not Used For This Command or Self + target = actor; + + break; + case 1: // Other Only + if (target == null || target == actor) { + return false; + } + + if (target != null && actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) { + return false; + } + + if (!core.simulationService.checkLineOfSight(actor, target)) { + return false; + } + + break; + case 2: // Self Only + if (target == null) { + target = actor; + } + + if (target != actor) { + return false; + } + + break; + case 3: // Free Target Mode (rally points, group waypoints) + target = null; + + break; + case 4: // Anyone + if (target == null) { + target = actor; + } + + if (!core.simulationService.checkLineOfSight(actor, target)) { + return false; + } + + break; + default: + break; + } + + switch (command.getTarget()) { + case 0: // Ally Only + if (target == null) { + target = actor; + } + + if (!(target instanceof TangibleObject)) { + return false; + } + + TangibleObject object = (TangibleObject) target; + + if (object.isAttackableBy(actor) || actor.getFactionStatus() < ((CreatureObject) object).getFactionStatus() || (!object.getFaction().equals("") && !object.getFaction().equals(actor.getFaction()))) { + return false; + } + + // Without this we could be buffing ally NPCs and such + if (object.getSlottedObject("ghost") == null) { + return false; + } + + break; + case 1: // Enemy Only + if (target == null || !(target instanceof TangibleObject)) { + return false; + } + + TangibleObject targetObject = (TangibleObject) target; + + if (!targetObject.isAttackableBy(actor)) { + return false; + } + + break; + case 2: // Indifferent + break; + default: + break; + } + + if (command.shouldCallOnTarget()) { + if (target == null || !(target instanceof CreatureObject)) { + return false; + } + + actor = (CreatureObject) target; + } + + long warmupTime = (long) (command.getWarmupTime() * 1000F); + final CreatureObject actorObject = actor; + final SWGObject targetObject = target; + + if (warmupTime != 0) { + scheduler.schedule(new Runnable() { + + @Override + public void run() { + processCommand(actorObject, targetObject, command, actionCounter, commandArgs); + } + + }, warmupTime, TimeUnit.MILLISECONDS); + } else { + processCommand(actor, target, command, actionCounter, commandArgs); + } + + return true; + } + + public void callCommand(SWGObject actor, String commandName, SWGObject target, String commandArgs) { + if (actor == null) + return; + + BaseSWGCommand command = getCommandByName(commandName); + + if (command == null) + return; + + if(command instanceof CombatCommand) { + CombatCommand command2; + try { + command2 = (CombatCommand) command.clone(); + processCombatCommand((CreatureObject) actor, target, command2, 0, ""); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + return; + } + + core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandArgs); + } + + public BaseSWGCommand getCommandByCRC(int commandCRC) { + Vector commands = new Vector(commandLookup); + + for (BaseSWGCommand command : commands) { + if (command.getCommandCRC() == commandCRC) { + return command; + } + } + + try { + String[] tableArray = new String[] { + "client_command_table", "command_table", "client_command_table_ground", "command_table_ground", + "client_command_table_space", "command_table_space" }; + + for (int n = 0; n < tableArray.length; n++) { + DatatableVisitor visitor = ClientFileManager.loadFile("datatables/command/" + tableArray[n] + ".iff", DatatableVisitor.class); + + for (int i = 0; i < visitor.getRowCount(); i++) { + if (visitor.getObject(i, 0) != null) { + String name = ((String) visitor.getObject(i, 0)).toLowerCase(); + + if (CRC.StringtoCRC(name) == commandCRC) { + int sub = 0; + + boolean hasCharacterAbility = (((String) visitor.getObject(i, 7-sub)).length() > 0); + + if (tableArray[n].startsWith("client_") && tableArray[n].startsWith("command_table_")) { + sub += 7; + } + + if (tableArray[n].equals("client_command_table_space")) { + sub += 5; + } + + boolean isCombatCommand = false; + + if(visitor.getObject(i, 82-sub) instanceof Boolean) + isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); + + if (hasCharacterAbility || isCombatCommand) { + CombatCommand command = new CombatCommand(name.toLowerCase()); + commandLookup.add(command); + return command; + } else { + BaseSWGCommand command = new BaseSWGCommand(name.toLowerCase()); + commandLookup.add(command); + return command; + } + } + } + } + } + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + + return null; + } + + public BaseSWGCommand getCommandByName(String name) { + Vector commands = new Vector(commandLookup); + + name = name.toLowerCase(); + + for (BaseSWGCommand command : commands) { + if (command.getCommandName().equalsIgnoreCase(name)) { + return command; + } + } + + try { + String[] tableArray = new String[] { + "client_command_table", "command_table", "client_command_table_ground", "command_table_ground", + "client_command_table_space", "command_table_space" }; + + for (int n = 0; n < tableArray.length; n++) { + DatatableVisitor visitor = ClientFileManager.loadFile("datatables/command/" + tableArray[n] + ".iff", DatatableVisitor.class); + + for (int i = 0; i < visitor.getRowCount(); i++) { + if (visitor.getObject(i, 0) != null) { + String commandName = ((String) visitor.getObject(i, 0)).toLowerCase(); + + if (commandName.equalsIgnoreCase(name)) { + int sub = 0; + + boolean hasCharacterAbility = (((String) visitor.getObject(i, 7-sub)).length() > 0); + + if (tableArray[n].startsWith("client_") && tableArray[n].startsWith("command_table_")) { + sub += 7; + } + + if (tableArray[n].equals("client_command_table_space")) { + sub += 5; + } + + boolean isCombatCommand = false; + + if(visitor.getObject(i, 82-sub) instanceof Boolean) + isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); + + if (hasCharacterAbility || isCombatCommand) { + CombatCommand command = new CombatCommand(commandName); + commandLookup.add(command); + return command; + } else { + BaseSWGCommand command = new BaseSWGCommand(commandName); + commandLookup.add(command); + return command; + } + } + } + } + } + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + + return null; + } + + public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { + if (command.getCooldown() > (float) 1) { + actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); + } + + if (command instanceof CombatCommand) { + processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); + } else { + if (FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName() + ".py")) { + core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandArgs); + } + } + } + + public void processCombatCommand(CreatureObject attacker, SWGObject target, CombatCommand command, int actionCounter, String commandArgs) { + + // Check if the person has access to this ability. + // Abilities (inc expertise ones) are added automatically as they level + // by reading the datatables. + // disabled for now (breaks all combat) + //if (!attacker.hasAbility(command.getCommandName())) { + // return; + //} + + if(FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) + core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "setup", core, attacker, target, command); + + boolean success = true; + + //if((command.getHitType() == 5 || command.getHitType() == 7) && !(target instanceof CreatureObject)) + // success = false; + + if(!(command.getAttackType() == 2) && !(command.getHitType() == 5) && !(command.getHitType() == 0)) { + if(target == null || !(target instanceof TangibleObject) || target == attacker) + success = false; + } else { + if(target == null) + target = attacker; + else if(!(target instanceof TangibleObject)) + return; + } + + if(attacker.getPosture() == 13 || attacker.getPosture() == 14) + success = false; + + if(target instanceof CreatureObject) { + if(!(command.getHitType() == 5)) + if(((CreatureObject) target).getPosture() == 13) + success = false; + if(!(command.getHitType() == 7)) + if(((CreatureObject) target).getPosture() == 14) + success = false; + } + + if(command.getHitType() == 7 && target.getClient() == null) + success = false; + + WeaponObject weapon; + + if(attacker.getWeaponId() == 0) + weapon = (WeaponObject) attacker.getSlottedObject("default_weapon"); // use unarmed/default weapon if no weapon is equipped + else + weapon = (WeaponObject) core.objectService.getObject(attacker.getWeaponId()); + + float maxRange = 0; + + if(command.getMaxRange() == 0) + maxRange = weapon.getMaxRange(); + else + maxRange = command.getMaxRange(); + + Point3D attackerPos = attacker.getWorldPosition(); + Point3D defenderPos = attacker.getWorldPosition(); + + if(attackerPos.getDistance(defenderPos) > maxRange && maxRange != 0) + success = false; + + if(command.getMinRange() > 0) { + if(attackerPos.getDistance(defenderPos) < command.getMinRange()) + success = false; + } + + + if(target != attacker && success && !core.simulationService.checkLineOfSight(attacker, target)) { + + ShowFlyText los = new ShowFlyText(attacker.getObjectID(), attacker.getObjectID(), "combat_effects", "cant_see", (float) 1.5, new RGB(72, 209, 204), 1); + ObjControllerMessage objController = new ObjControllerMessage(0x1B, los); + attacker.getClient().getSession().write(objController.serialize()); + success = false; + + } + + if(!success && attacker.getClient() != null) { + IoSession session = attacker.getClient().getSession(); + CommandEnqueueRemove commandRemove = new CommandEnqueueRemove(attacker.getObjectId(), actionCounter); + session.write(new ObjControllerMessage(0x0B, commandRemove).serialize()); + StartTask startTask = new StartTask(actionCounter, attacker.getObjectID(), command.getCommandCRC(), CRC.StringtoCRC(command.getCooldownGroup()), -1); + session.write(new ObjControllerMessage(0x0B, startTask).serialize()); + } else { + + if(command.getHitType() == 5) { + core.combatService.doHeal(attacker, (CreatureObject) target, weapon, command, actionCounter); + return; + } + + if(command.getHitType() == 7) { + core.combatService.doRevive(attacker, (CreatureObject) target, weapon, command, actionCounter); + return; + } + + if(command.getHitType() == 0 && command.getBuffNameSelf().length() > 0) { + core.combatService.doSelfBuff(attacker, weapon, command, actionCounter); + return; + } + for(int i = 0 ; i < command.getAttack_rolls(); i++) { + core.combatService.doCombat(attacker, (TangibleObject) target, weapon, command, actionCounter); + } + + } + + } + + @Override + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + + objControllerOpcodes.put(ObjControllerOpcodes.COMMAND_QUEUE_ENQUEUE, new INetworkRemoteEvent() { + + @Override + public void handlePacket(IoSession session, IoBuffer data) throws Exception { + + data.order(ByteOrder.LITTLE_ENDIAN); + Client client = core.getClient(session); + + if (client == null) { + System.out.println("NULL Client"); + return; + } + + CommandEnqueue commandEnqueue = new CommandEnqueue(); + commandEnqueue.deserialize(data); + + BaseSWGCommand command = getCommandByCRC(commandEnqueue.getCommandCRC()); + + if (command == null) { + //System.out.println("Unknown Command CRC: " + commandEnqueue.getCommandCRC()); + return; + } + + if (client.getParent() == null) { + System.out.println("NULL Object"); + return; + } + + CreatureObject actor = (CreatureObject) client.getParent(); + + SWGObject target = core.objectService.getObject(commandEnqueue.getTargetID()); + + if (!callCommand(actor, target, command, commandEnqueue.getActionCounter(), commandEnqueue.getCommandArguments())) { + // Call failScriptHook + } + } + + }); + + objControllerOpcodes.put(ObjControllerOpcodes.COMMAND_QUEUE_REMOVE, new INetworkRemoteEvent() { + + @Override + public void handlePacket(IoSession session, IoBuffer data) throws Exception { + + } + + }); + + + } + + public void shutdown() { + + } + + public CombatCommand registerCombatCommand(String name) { + BaseSWGCommand command = getCommandByName(name); + + if (command == null) { + return null; + } + + if (command instanceof CombatCommand) { + return (CombatCommand) command; + } else { + System.out.println("Warning: Forced to make non-combat command " + name + " a combat command."); + commandLookup.remove(command); + CombatCommand combatCommand = new CombatCommand(name.toLowerCase()); + commandLookup.add(combatCommand); + return combatCommand; + } + } + + public BaseSWGCommand registerCommand(String name) { return getCommandByName(name); } + public BaseSWGCommand registerGmCommand(String name) { return getCommandByName(name); } + public void registerAlias(String name, String target) { } + +} From 9526eee9d60a943560c6c1e1744ac1df6d8381d0 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Tue, 8 Apr 2014 02:12:36 +0200 Subject: [PATCH 34/68] Object-orientated approach to storing the loot info --- options.cfg | 5 +- scripts/object/mobile/tusken_raider.py | 33 ++++++++----- src/main/NGECore.java | 3 ++ src/resources/objects/loot/LootDrop.java | 21 ++++++++ src/resources/objects/loot/LootGroup.java | 49 +++++++++++++++++++ .../objects/tangible/TangibleObject.java | 23 +++++---- src/services/DevService.java | 6 ++- src/services/LootService.java | 26 +++++++++- 8 files changed, 139 insertions(+), 27 deletions(-) create mode 100644 src/resources/objects/loot/LootGroup.java diff --git a/options.cfg b/options.cfg index 4f6d91ad..cb743c88 100644 --- a/options.cfg +++ b/options.cfg @@ -1,2 +1,3 @@ -LOAD.SNAPSHOT_OBJECTS=1 -LOAD.BUILDOUT_OBJECTS=1 \ No newline at end of file +LOAD.SNAPSHOT_OBJECTS=0 +LOAD.BUILDOUT_OBJECTS=0 +LOAD.RESOURCE.SYSTEM=1 \ No newline at end of file diff --git a/scripts/object/mobile/tusken_raider.py b/scripts/object/mobile/tusken_raider.py index 37e94fa4..8c20d758 100644 --- a/scripts/object/mobile/tusken_raider.py +++ b/scripts/object/mobile/tusken_raider.py @@ -1,17 +1,24 @@ import sys +from java.util import TreeSet +from java.util import TreeMap def setup(core, object): - - lootSpecification = [ - [ - ['Junk',90], - ['Rifles',70], - ['ParentProbability',60] - ], - [ - ['Colorcrystal',100], - ['ParentProbability',50] - ] - ] - object.setLootSpecification(lootSpecification) + + lootSpecification = TreeSet() + #lootSpecification = [[['Junk',90],['Rifles',70],['ParentProbability',60]],[['Colorcrystal',100],['ParentProbability',50]]] + #object.setLootSpecification(lootSpecification) + + lootPoolNames_1 = ['Junk','Rifles'] + lootPoolChances_1 = [90,70] + lootGroupChance_1 = 80 + core.lootService.saveLootData(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + #object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames2 = ['Colorcrystal'] + lootPoolChances2 = [50] + lootGroupChance2 = 60 + #core.lootService.saveLootData(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + #object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + #core.lootService.test3(allLootPoolNames) return \ No newline at end of file diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 0762507f..d465c5f1 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -59,6 +59,7 @@ import services.EquipmentService; import services.GroupService; import services.InstanceService; import services.LoginService; +import services.LootService; import services.MissionService; import services.PlayerService; import services.ScriptService; @@ -175,6 +176,7 @@ public class NGECore { public ResourceService resourceService; public ConversationService conversationService; + public LootService lootService; // Login Server @@ -286,6 +288,7 @@ public class NGECore { entertainmentService = new EntertainmentService(this); devService = new DevService(this); conversationService = new ConversationService(this); + lootService = new LootService(this); if (config.keyExists("JYTHONCONSOLE.PORT")) { int jythonPort = config.getInt("JYTHONCONSOLE.PORT"); diff --git a/src/resources/objects/loot/LootDrop.java b/src/resources/objects/loot/LootDrop.java index 211fdca3..08e01fbf 100644 --- a/src/resources/objects/loot/LootDrop.java +++ b/src/resources/objects/loot/LootDrop.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package resources.objects.loot; import java.util.ArrayList; diff --git a/src/resources/objects/loot/LootGroup.java b/src/resources/objects/loot/LootGroup.java new file mode 100644 index 00000000..1558a624 --- /dev/null +++ b/src/resources/objects/loot/LootGroup.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.objects.loot; + +/** + * @author Charon + */ + +public class LootGroup { + + private String[] lootPoolNames; + private int[] lootPoolChances; + private int lootGroupChance; + + public LootGroup(){ + + } + + public LootGroup(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance){ + this.lootPoolNames = lootPoolNames; + this.lootPoolChances = lootPoolChances; + this.lootGroupChance = lootGroupChance; + } + + public void addLootData(String[] lootPoolNames, int[] lootPoolChances, int lootGroupChance){ + this.lootPoolNames = lootPoolNames; + this.lootPoolChances = lootPoolChances; + this.lootGroupChance = lootGroupChance; + } +} diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 6639ac5f..69dc7d65 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -46,6 +46,7 @@ import protocol.swg.UpdatePVPStatusMessage; import protocol.swg.objectControllerObjects.ShowFlyText; import resources.common.RGB; import resources.objects.creature.CreatureObject; +import resources.objects.loot.LootGroup; import resources.visitors.IDManagerVisitor; import services.ai.AIActor; @@ -82,8 +83,9 @@ public class TangibleObject extends SWGObject { private int respawnTime = 0; private Point3D spawnCoordinates = new Point3D(0, 0, 0); - private TreeSet> lootSpecification = new TreeSet>(); - + //private TreeSet> lootSpecification = new TreeSet>(); + private List lootGroups = new ArrayList(); + @NotPersistent private TangibleObject killer = null; @@ -451,14 +453,6 @@ public class TangibleObject extends SWGObject { } } - public TreeSet> getLootSpecification() { - return lootSpecification; - } - - public void setLootSpecification( - TreeSet> lootSpecification) { - this.lootSpecification = lootSpecification; - } @Override public void sendBaselines(Client destination) { @@ -483,4 +477,13 @@ public class TangibleObject extends SWGObject { } + + public List getLootGroups() { + return lootGroups; + } + + public void addToLootGroups(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance) { + LootGroup lootGroup = new LootGroup(lootPoolName, lootPoolChance, lootGroupChance); + this.lootGroups.add(lootGroup); + } } diff --git a/src/services/DevService.java b/src/services/DevService.java index 2ce2c1f6..306958f1 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -85,6 +85,7 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 22, "Misc Items"); suiOptions.put((long) 23, "Jedi Items"); suiOptions.put((long) 110, "Survey Devices"); + suiOptions.put((long) 111, "Spawn Tusken"); break; case 3: // [Items] Weapons suiOptions.put((long) 30, "Jedi Weapons"); @@ -992,8 +993,11 @@ public class DevService implements INetworkDispatch { inventory.add(solarSurveyTool); - core.staticService.spawnObject("object/mobile/shared_tusken_raider.iff", "tatooine", 0L, 3522F, 4F, -4801F, 0.70F, 0.71F); + + break; + case 111: + core.staticService.spawnObject("object/mobile/shared_tusken_raider.iff", "tatooine", 0L, 3522F, 4F, -4801F, 0.70F, 0.71F); break; } } diff --git a/src/services/LootService.java b/src/services/LootService.java index bfa233aa..32039cb5 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -126,7 +126,7 @@ public class LootService implements INetworkDispatch { } } - + // ToDo: Group loot settings etc. // [20:35] <@_Light> your actual loot chance was lootgroupchance*lootchance @@ -158,4 +158,28 @@ public class LootService implements INetworkDispatch { return lootDropList; } + + + public void test(TreeSet test1){ + + } + + public void test2(String test2){ + System.out.println(test2); + } + + public void saveLootData(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance){ + for (String ui : lootPoolName){ + System.out.println(ui); + } + for (int ui : lootPoolChance){ + System.out.println(ui); + } + + System.out.println(lootGroupChance); + + } + + + } From d848e89edb64f487bfad0b87ba2c12d96e71096f Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Tue, 8 Apr 2014 04:08:52 +0200 Subject: [PATCH 35/68] Script integration A few example .py scripts Improvements on the lootservice design --- scripts/lootPools/colorcrystals.py | 0 scripts/lootPools/jediholocrons.py | 0 scripts/lootPools/junk.py | 8 ++ scripts/lootPools/kraytpearls.py | 8 ++ scripts/lootPools/rareloot.py | 0 scripts/lootPools/rifles.py | 0 scripts/lootPools/sithholocrons.py | 0 scripts/object/mobile/tusken_raider.py | 8 +- src/resources/objects/loot/LootGroup.java | 12 +++ src/resources/objects/loot/LootPool.java | 33 +++++++ .../objects/loot/LootRollSession.java | 33 +++++++ .../objects/tangible/TangibleObject.java | 18 ++-- src/services/LootService.java | 92 +++++++++---------- 13 files changed, 150 insertions(+), 62 deletions(-) create mode 100644 scripts/lootPools/colorcrystals.py create mode 100644 scripts/lootPools/jediholocrons.py create mode 100644 scripts/lootPools/junk.py create mode 100644 scripts/lootPools/kraytpearls.py create mode 100644 scripts/lootPools/rareloot.py create mode 100644 scripts/lootPools/rifles.py create mode 100644 scripts/lootPools/sithholocrons.py create mode 100644 src/resources/objects/loot/LootPool.java create mode 100644 src/resources/objects/loot/LootRollSession.java diff --git a/scripts/lootPools/colorcrystals.py b/scripts/lootPools/colorcrystals.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/lootPools/jediholocrons.py b/scripts/lootPools/jediholocrons.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/lootPools/junk.py b/scripts/lootPools/junk.py new file mode 100644 index 00000000..3a139e37 --- /dev/null +++ b/scripts/lootPools/junk.py @@ -0,0 +1,8 @@ + +def itemTemplates(): + + templates=['1','2','3'] + return templates + +def itemChances(): + return [1,2,3] \ No newline at end of file diff --git a/scripts/lootPools/kraytpearls.py b/scripts/lootPools/kraytpearls.py new file mode 100644 index 00000000..8463ef39 --- /dev/null +++ b/scripts/lootPools/kraytpearls.py @@ -0,0 +1,8 @@ + +def itemTemplates(): + + templates=['1','2','3','Flawless'] + return templates + +def itemChances(): + return [60,20,10,5] \ No newline at end of file diff --git a/scripts/lootPools/rareloot.py b/scripts/lootPools/rareloot.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/lootPools/rifles.py b/scripts/lootPools/rifles.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/lootPools/sithholocrons.py b/scripts/lootPools/sithholocrons.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/object/mobile/tusken_raider.py b/scripts/object/mobile/tusken_raider.py index 8c20d758..3a133a38 100644 --- a/scripts/object/mobile/tusken_raider.py +++ b/scripts/object/mobile/tusken_raider.py @@ -11,14 +11,14 @@ def setup(core, object): lootPoolNames_1 = ['Junk','Rifles'] lootPoolChances_1 = [90,70] lootGroupChance_1 = 80 - core.lootService.saveLootData(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) - #object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + #core.lootService.saveLootData(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) lootPoolNames2 = ['Colorcrystal'] lootPoolChances2 = [50] lootGroupChance2 = 60 #core.lootService.saveLootData(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) - #object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) #core.lootService.test3(allLootPoolNames) - return \ No newline at end of file + return \ No newline at end of file diff --git a/src/resources/objects/loot/LootGroup.java b/src/resources/objects/loot/LootGroup.java index 1558a624..efedc799 100644 --- a/src/resources/objects/loot/LootGroup.java +++ b/src/resources/objects/loot/LootGroup.java @@ -46,4 +46,16 @@ public class LootGroup { this.lootPoolChances = lootPoolChances; this.lootGroupChance = lootGroupChance; } + + public String[] getLootPoolNames() { + return lootPoolNames; + } + + public int[] getLootPoolChances() { + return lootPoolChances; + } + + public int getLootGroupChance() { + return lootGroupChance; + } } diff --git a/src/resources/objects/loot/LootPool.java b/src/resources/objects/loot/LootPool.java new file mode 100644 index 00000000..2e74cf8b --- /dev/null +++ b/src/resources/objects/loot/LootPool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.objects.loot; + +/** + * @author Charon + */ + +public class LootPool { + + public LootPool(){ + + } +} diff --git a/src/resources/objects/loot/LootRollSession.java b/src/resources/objects/loot/LootRollSession.java new file mode 100644 index 00000000..d2416102 --- /dev/null +++ b/src/resources/objects/loot/LootRollSession.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.objects.loot; + +/** + * @author Charon + */ + +public class LootRollSession { + + public LootRollSession(){ + + } +} diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 69dc7d65..be7d869e 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -453,6 +453,15 @@ public class TangibleObject extends SWGObject { } } + public List getLootGroups() { + return lootGroups; + } + + public void addToLootGroups(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance) { + LootGroup lootGroup = new LootGroup(lootPoolName, lootPoolChance, lootGroupChance); + this.lootGroups.add(lootGroup); + } + @Override public void sendBaselines(Client destination) { @@ -477,13 +486,4 @@ public class TangibleObject extends SWGObject { } - - public List getLootGroups() { - return lootGroups; - } - - public void addToLootGroups(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance) { - LootGroup lootGroup = new LootGroup(lootPoolName, lootPoolChance, lootGroupChance); - this.lootGroups.add(lootGroup); - } } diff --git a/src/services/LootService.java b/src/services/LootService.java index 32039cb5..04d44feb 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -35,6 +35,8 @@ import java.util.TreeSet; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; import resources.objects.loot.LootDrop; +import resources.objects.loot.LootGroup; +import resources.objects.loot.LootPool; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.tool.SurveyTool; @@ -89,32 +91,27 @@ public class LootService implements INetworkDispatch { } + CreatureObject lootedCreature = (CreatureObject) lootedObject; + List lootDrops = new ArrayList(); List lootElements = new ArrayList(); - TreeSet> lootSpec = lootedObject.getLootSpecification(); - Iterator> iterator = lootSpec.iterator(); + //TreeSet> lootSpec = lootedObject.getLootSpecification(); + List lootGroups = lootedCreature.getLootGroups(); + Iterator iterator = lootGroups.iterator(); while (iterator.hasNext()){ - TreeMap lootPool = iterator.next(); - int poolProbability = lootPool.lastEntry().getValue(); - int lootPoolRoll = new Random().nextInt(100); - if (lootPoolRoll <= poolProbability){ - lootElements = handleLootPool(lootPool); //this lootPool will drop + LootGroup lootGroup = iterator.next(); + int groupChance = lootGroup.getLootGroupChance(); + int lootGroupRoll = new Random().nextInt(100); + if (lootGroupRoll <= groupChance){ + handleLootGroup(lootGroup); //this lootGroup will drop something } } - - // Now handle the chosen pools and determine the according items - - for (String element : lootElements){ - lootDrops = handleLootPoolElement(element); - } - + // ********** Phase 1 complete, loot items determined ********** - // Distribute the loot drops according to group loot rules - - + // Distribute the loot drops according to group loot rules // For now just spawn items into requester's inventory for (LootDrop dropElem : lootDrops){ PlayerObject requesterObj = (PlayerObject) requester.getSlottedObject("ghost"); @@ -125,49 +122,42 @@ public class LootService implements INetworkDispatch { requesterInventory.add(droppedItem); } } - - - // ToDo: Group loot settings etc. - - // [20:35] <@_Light> your actual loot chance was lootgroupchance*lootchance - long leaderGroupId = requester.getGroupId(); - GroupObject group = (GroupObject) core.objectService.getObject(leaderGroupId); - if(group.getMemberList().size() == 1) { - // looter is alone - } + + // ToDo: Group loot settings etc. } - private List handleLootPool(TreeMap lootPool){ + private List handleLootGroup(LootGroup lootGroup){ List lootElements = new ArrayList(); - for(Map.Entry entry : lootPool.entrySet()) { - String poolElementName = entry.getKey(); - int poolElementProbability = entry.getValue(); + int[] lootPoolChances = lootGroup.getLootPoolChances(); + String[] lootPoolNames = lootGroup.getLootPoolNames(); + for(int i=0;i handleLootPoolElement(String element){ + private List handleLootPool(String poolName){ List lootDropList = new ArrayList(); - // This is just a random element from the python + LootDrop lootDrop = new LootDrop(); + // Fetch the loot pool data from the poolName.py script + + String path = "scripts/lootPools/"+poolName; // + ".py"; + //Vector quantityList = (Vector)core.scriptService.fetchStringVector(path,"resourceQuantities"); + +// for (String s : quantityList){ +// System.out.println("OOO: " + s); +// } + + //LootPool lootPool = loadfrompyreturn(); return lootDropList; } - - - public void test(TreeSet test1){ - - } - - public void test2(String test2){ - System.out.println(test2); - } - + public void saveLootData(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance){ for (String ui : lootPoolName){ System.out.println(ui); @@ -178,8 +168,12 @@ public class LootService implements INetworkDispatch { System.out.println(lootGroupChance); - } - - - + } } + +////[20:35] <@_Light> your actual loot chance was lootgroupchance*lootchance +// long leaderGroupId = requester.getGroupId(); +// GroupObject group = (GroupObject) core.objectService.getObject(leaderGroupId); +// if(group.getMemberList().size() == 1) { +// // looter is alone +// } From 70964ef14aa637cabb5b6b0b225bb0f179167867 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Tue, 8 Apr 2014 15:39:48 +0200 Subject: [PATCH 36/68] Lootpool scripts added Data transfer from py script to java --- options.cfg | 2 +- scripts/lootPools/colorcrystals.py | 9 ++ scripts/lootPools/junk.py | 4 +- scripts/lootPools/rareloot.py | 9 ++ scripts/lootPools/rifles.py | 9 ++ scripts/object/mobile/tusken_raider.py | 20 ++-- src/resources/objects/loot/LootDrop.java | 9 ++ src/resources/objects/loot/LootGroup.java | 5 +- .../objects/loot/LootRollSession.java | 45 +++++++- .../objects/tangible/TangibleObject.java | 5 +- src/services/DevService.java | 4 +- src/services/LootService.java | 103 +++++++++--------- src/services/ScriptService.java | 23 ++++ 13 files changed, 175 insertions(+), 72 deletions(-) diff --git a/options.cfg b/options.cfg index cb743c88..9a9489b6 100644 --- a/options.cfg +++ b/options.cfg @@ -1,3 +1,3 @@ LOAD.SNAPSHOT_OBJECTS=0 LOAD.BUILDOUT_OBJECTS=0 -LOAD.RESOURCE.SYSTEM=1 \ No newline at end of file +LOAD.RESOURCE.SYSTEM=0 \ No newline at end of file diff --git a/scripts/lootPools/colorcrystals.py b/scripts/lootPools/colorcrystals.py index e69de29b..f5e4e85a 100644 --- a/scripts/lootPools/colorcrystals.py +++ b/scripts/lootPools/colorcrystals.py @@ -0,0 +1,9 @@ + + +def itemTemplates(): + + templates=['object/tangible/loot/npc_loot/shared_generic_crystal.iff'] + return templates + +def itemChances(): + return [70] \ No newline at end of file diff --git a/scripts/lootPools/junk.py b/scripts/lootPools/junk.py index 3a139e37..65deb632 100644 --- a/scripts/lootPools/junk.py +++ b/scripts/lootPools/junk.py @@ -1,8 +1,8 @@ def itemTemplates(): - templates=['1','2','3'] + templates=['object/tangible/loot/misc/shared_damaged_datapad.iff','object/tangible/loot/npc_loot/shared_red_wiring_generic.iff','object/tangible/loot/npc_loot/shared_worklight_generic.iff'] return templates def itemChances(): - return [1,2,3] \ No newline at end of file + return [70,50,40] \ No newline at end of file diff --git a/scripts/lootPools/rareloot.py b/scripts/lootPools/rareloot.py index e69de29b..19ffe37f 100644 --- a/scripts/lootPools/rareloot.py +++ b/scripts/lootPools/rareloot.py @@ -0,0 +1,9 @@ + + +def itemTemplates(): + + templates=['object/tangible/item/shared_rare_loot_chest_3.iff'] + return templates + +def itemChances(): + return [1] \ No newline at end of file diff --git a/scripts/lootPools/rifles.py b/scripts/lootPools/rifles.py index e69de29b..c3402805 100644 --- a/scripts/lootPools/rifles.py +++ b/scripts/lootPools/rifles.py @@ -0,0 +1,9 @@ + + +def itemTemplates(): + + templates=['object/weapon/ranged/rifle/shared_rifle_cdef.iff'] + return templates + +def itemChances(): + return [70] \ No newline at end of file diff --git a/scripts/object/mobile/tusken_raider.py b/scripts/object/mobile/tusken_raider.py index 3a133a38..d4aa322f 100644 --- a/scripts/object/mobile/tusken_raider.py +++ b/scripts/object/mobile/tusken_raider.py @@ -1,24 +1,20 @@ import sys -from java.util import TreeSet -from java.util import TreeMap def setup(core, object): - lootSpecification = TreeSet() - #lootSpecification = [[['Junk',90],['Rifles',70],['ParentProbability',60]],[['Colorcrystal',100],['ParentProbability',50]]] - #object.setLootSpecification(lootSpecification) - lootPoolNames_1 = ['Junk','Rifles'] lootPoolChances_1 = [90,70] lootGroupChance_1 = 80 - #core.lootService.saveLootData(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) - lootPoolNames2 = ['Colorcrystal'] - lootPoolChances2 = [50] - lootGroupChance2 = 60 - #core.lootService.saveLootData(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + lootPoolNames_2 = ['Colorcrystals'] + lootPoolChances_2 = [50] + lootGroupChance_2 = 60 object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) - #core.lootService.test3(allLootPoolNames) + lootPoolNames_3 = ['Rareloot'] + lootPoolChances_3 = [100] + lootGroupChance_3 = 1 + object.addToLootGroups(lootPoolNames_3,lootPoolChances_3,lootGroupChance_3) + return \ No newline at end of file diff --git a/src/resources/objects/loot/LootDrop.java b/src/resources/objects/loot/LootDrop.java index 08e01fbf..371c1727 100644 --- a/src/resources/objects/loot/LootDrop.java +++ b/src/resources/objects/loot/LootDrop.java @@ -27,6 +27,7 @@ import java.util.List; public class LootDrop { private List elements = new ArrayList(); + private String droppedItemTemplate; public LootDrop(){ @@ -39,4 +40,12 @@ public class LootDrop { public List getElements(){ return elements; } + + public String getDroppedItemTemplate() { + return droppedItemTemplate; + } + + public void setDroppedItemTemplate(String droppedItemTemplate) { + this.droppedItemTemplate = droppedItemTemplate; + } } diff --git a/src/resources/objects/loot/LootGroup.java b/src/resources/objects/loot/LootGroup.java index efedc799..e349eaac 100644 --- a/src/resources/objects/loot/LootGroup.java +++ b/src/resources/objects/loot/LootGroup.java @@ -21,10 +21,13 @@ ******************************************************************************/ package resources.objects.loot; +import com.sleepycat.persist.model.Persistent; + /** * @author Charon */ +@Persistent(version=0) public class LootGroup { private String[] lootPoolNames; @@ -35,7 +38,7 @@ public class LootGroup { } - public LootGroup(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance){ + public LootGroup(String[] lootPoolNames, int[] lootPoolChances, int lootGroupChance){ this.lootPoolNames = lootPoolNames; this.lootPoolChances = lootPoolChances; this.lootGroupChance = lootGroupChance; diff --git a/src/resources/objects/loot/LootRollSession.java b/src/resources/objects/loot/LootRollSession.java index d2416102..5d1937b6 100644 --- a/src/resources/objects/loot/LootRollSession.java +++ b/src/resources/objects/loot/LootRollSession.java @@ -21,13 +21,54 @@ ******************************************************************************/ package resources.objects.loot; +import java.util.ArrayList; +import java.util.List; + +import main.NGECore; +import resources.objects.creature.CreatureObject; +import resources.objects.group.GroupObject; + /** * @author Charon */ public class LootRollSession { - public LootRollSession(){ - + private String SessionID; // leaderName-SystemTime + private GroupObject playerGroup; + private List droppedItemTemplates; + + public LootRollSession(){ + } + + public LootRollSession(CreatureObject requester){ + long requesterGroupId = requester.getGroupId(); + if (requesterGroupId>0){ + this.playerGroup = (GroupObject) NGECore.getInstance().objectService.getObject(requesterGroupId); + this.SessionID = playerGroup.getGroupLeader().getCustomName()+"-"+System.currentTimeMillis(); + } else { + this.SessionID = requester.getCustomName()+"-"+System.currentTimeMillis(); + } + droppedItemTemplates = new ArrayList(); + } + + public List getDroppedItemTemplates() { + return droppedItemTemplates; + } + + public void addDroppedItemTemplate(String droppedItemTemplate) { + this.droppedItemTemplates.add(droppedItemTemplate); + } + + public String getSessionID() { + return SessionID; + } + + public void setSessionID(String sessionID) { + SessionID = sessionID; + } + + public void generateSessionID(String sessionID) { + SessionID = sessionID; } } diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index be7d869e..7ac2c6ea 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -457,8 +457,9 @@ public class TangibleObject extends SWGObject { return lootGroups; } - public void addToLootGroups(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance) { - LootGroup lootGroup = new LootGroup(lootPoolName, lootPoolChance, lootGroupChance); + public void addToLootGroups(String[] lootPoolNames, int[] lootPoolChances, int lootGroupChance) { + System.out.println("lootPoolNames[0] " + lootPoolNames[0]); + LootGroup lootGroup = new LootGroup(lootPoolNames, lootPoolChances, lootGroupChance); this.lootGroups.add(lootGroup); } diff --git a/src/services/DevService.java b/src/services/DevService.java index 306958f1..ca387de1 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -997,7 +997,9 @@ public class DevService implements INetworkDispatch { break; case 111: - core.staticService.spawnObject("object/mobile/shared_tusken_raider.iff", "tatooine", 0L, 3522F, 4F, -4801F, 0.70F, 0.71F); + SWGObject spawned = core.staticService.spawnObject("object/mobile/shared_tusken_raider.iff", "tatooine", 0L, 3522F, 4F, -4801F, 0.70F, 0.71F); + + core.lootService.handleLootRequest(player,(TangibleObject)spawned); break; } } diff --git a/src/services/LootService.java b/src/services/LootService.java index 04d44feb..7ad8fdb8 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -31,12 +31,14 @@ import java.util.Map.Entry; import java.util.Random; import java.util.TreeMap; import java.util.TreeSet; +import java.util.Vector; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; import resources.objects.loot.LootDrop; import resources.objects.loot.LootGroup; import resources.objects.loot.LootPool; +import resources.objects.loot.LootRollSession; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.tool.SurveyTool; @@ -70,6 +72,7 @@ public class LootService implements INetworkDispatch { public void handleLootRequest(CreatureObject requester, TangibleObject lootedObject) { + LootRollSession lootRollSession = new LootRollSession(requester); String lootedObjectType = "Tangible"; if (lootedObject instanceof CreatureObject) lootedObjectType = "Creature"; @@ -80,9 +83,12 @@ public class LootService implements INetworkDispatch { if (lootedObjectType.equals("Creature")){ CreatureObject lootedCreature = (CreatureObject) lootedObject; int creatureCL = lootedCreature.getLevel(); + creatureCL = 90; int minimalCredits = 40 * creatureCL; // Predetermined factor of 40 per CL int spanOfCredits = 15 * creatureCL; // Predetermined factor of 15 per CL + System.out.println("spanOfCredits " + spanOfCredits); lootedCredits = minimalCredits + new Random().nextInt(spanOfCredits); + requester.sendSystemMessage("You looted " + lootedCredits + " credits.", (byte)1); } if (lootedObjectType.equals("Tangible")){ @@ -93,11 +99,9 @@ public class LootService implements INetworkDispatch { CreatureObject lootedCreature = (CreatureObject) lootedObject; - List lootDrops = new ArrayList(); - List lootElements = new ArrayList(); - //TreeSet> lootSpec = lootedObject.getLootSpecification(); List lootGroups = lootedCreature.getLootGroups(); + System.out.println("lootGroups size " + lootGroups.size()); Iterator iterator = lootGroups.iterator(); while (iterator.hasNext()){ @@ -105,75 +109,72 @@ public class LootService implements INetworkDispatch { int groupChance = lootGroup.getLootGroupChance(); int lootGroupRoll = new Random().nextInt(100); if (lootGroupRoll <= groupChance){ - handleLootGroup(lootGroup); //this lootGroup will drop something + System.out.println("this lootGroup will drop something"); + handleLootGroup(lootGroup,lootRollSession); //this lootGroup will drop something } } + + for (String s : lootRollSession.getDroppedItemTemplates()){ + System.out.println("lootRollSession template: " + s); + } + // ********** Phase 1 complete, loot items determined ********** + // stored in the lootSession // Distribute the loot drops according to group loot rules // For now just spawn items into requester's inventory - for (LootDrop dropElem : lootDrops){ - PlayerObject requesterObj = (PlayerObject) requester.getSlottedObject("ghost"); - SWGObject requesterInventory = requesterObj.getSlottedObject("inventory"); - List elementList = dropElem.getElements(); - for (String template : elementList){ - TangibleObject droppedItem = (TangibleObject) core.objectService.createObject(template, requester.getPlanet()); - requesterInventory.add(droppedItem); - } - } - - // ToDo: Group loot settings etc. + SWGObject requesterInventory = requester.getSlottedObject("inventory"); + System.out.println("requesterInventory " + requesterInventory); + for (String template : lootRollSession.getDroppedItemTemplates()){ + TangibleObject droppedItem = (TangibleObject) core.objectService.createObject(template, requester.getPlanet()); + System.out.println("droppedItem " + droppedItem); + requesterInventory.add(droppedItem); + } + + // ToDo: Group loot settings etc. actual loot chance was lootgroupchance*lootchance } - private List handleLootGroup(LootGroup lootGroup){ - List lootElements = new ArrayList(); + private void handleLootGroup(LootGroup lootGroup,LootRollSession lootRollSession){ + int[] lootPoolChances = lootGroup.getLootPoolChances(); String[] lootPoolNames = lootGroup.getLootPoolNames(); + if (lootPoolChances==null || lootPoolNames==null){ + System.err.println("Lootpools are null!"); + return; + } + if (lootPoolChances.length==0 || lootPoolNames.length==0){ + System.err.println("No Lootpools in Lootgroup!"); + return; + } for(int i=0;i handleLootPool(String poolName){ - List lootDropList = new ArrayList(); - LootDrop lootDrop = new LootDrop(); - // Fetch the loot pool data from the poolName.py script - - String path = "scripts/lootPools/"+poolName; // + ".py"; - //Vector quantityList = (Vector)core.scriptService.fetchStringVector(path,"resourceQuantities"); - -// for (String s : quantityList){ -// System.out.println("OOO: " + s); -// } - - //LootPool lootPool = loadfrompyreturn(); - - return lootDropList; - } + private void handleLootPool(String poolName,LootRollSession lootRollSession){ - public void saveLootData(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance){ - for (String ui : lootPoolName){ - System.out.println(ui); - } - for (int ui : lootPoolChance){ - System.out.println(ui); + // Fetch the loot pool data from the poolName.py script + String path = "scripts/lootPools/"+poolName.toLowerCase(); + Vector itemTemplates = (Vector)core.scriptService.fetchStringVector(path,"itemTemplates"); + + for (String s : itemTemplates){ + System.out.println("template: " + s); } - System.out.println(lootGroupChance); + Vector itemChances = (Vector)core.scriptService.fetchIntegerVector(path,"itemChances"); + // Now here maybe all items in pool have an equal chance to spawn + // or they have percentages assigned to them as well + + int randomItemFromPool = new Random().nextInt(100); + int itemIndex = (int)Math.floor(randomItemFromPool/100*itemTemplates.size()); // 5 Elements,rnd is 83 -> 0.83*5= + + lootRollSession.addDroppedItemTemplate(itemTemplates.get(itemIndex)); } -} - -////[20:35] <@_Light> your actual loot chance was lootgroupchance*lootchance -// long leaderGroupId = requester.getGroupId(); -// GroupObject group = (GroupObject) core.objectService.getObject(leaderGroupId); -// if(group.getMemberList().size() == 1) { -// // looter is alone -// } +} diff --git a/src/services/ScriptService.java b/src/services/ScriptService.java index 9ea1c999..ba1ea259 100644 --- a/src/services/ScriptService.java +++ b/src/services/ScriptService.java @@ -21,6 +21,9 @@ ******************************************************************************/ package services; +import java.util.Iterator; +import java.util.Vector; + import org.python.core.Py; import org.python.core.PyObject; import org.python.util.PythonInterpreter; @@ -107,4 +110,24 @@ public class ScriptService { return func; } + public Vector fetchStringVector(String path, String method) { + Vector vector = new Vector(); + PyObject result = core.scriptService.callScript(path, "", method); + Iterable comp = (Iterable)result.asIterable(); + for (Iterator temp = comp.iterator(); temp.hasNext();){ + vector.add(temp.next().asString()); + } + return vector; + } + + public Vector fetchIntegerVector(String path, String method) { + Vector vector = new Vector(); + PyObject result = core.scriptService.callScript(path, "", method); + Iterable comp = (Iterable)result.asIterable(); + for (Iterator temp = comp.iterator(); temp.hasNext();){ + vector.add(temp.next().asInt()); + } + return vector; + } + } From f60583dff2c9acba2f62b08a9cf2fb6edd4297e9 Mon Sep 17 00:00:00 2001 From: Seefo Date: Tue, 8 Apr 2014 10:30:16 -0400 Subject: [PATCH 37/68] Temporary fix for certain commands being registered as combat commands even though the are not combat commands --- src/services/command/CommandService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index c6a62435..5470f7cb 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -350,6 +350,7 @@ public class CommandService implements INetworkDispatch { if(visitor.getObject(i, 82-sub) instanceof Boolean) isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); + // "isCombatCommand" needs to be changed so that non-combat commands that are flagged to added to a combat queue are not considered combat commands if (hasCharacterAbility || isCombatCommand) { CombatCommand command = new CombatCommand(commandName); commandLookup.add(command); @@ -393,7 +394,15 @@ public class CommandService implements INetworkDispatch { //} if(FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) + { core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "setup", core, attacker, target, command); + } + // Temporary fix for certain non-combat commands being registered as combat commands + else if(FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName() + ".py")) + { + core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, attacker, target, commandArgs); + return; + } boolean success = true; From 2c4356188a5fefbb949b0955729872c87c3a01f1 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Tue, 8 Apr 2014 16:30:19 -0400 Subject: [PATCH 38/68] Fixed #396: Environmental Purge not granting. --- scripts/expertise/expertise_of_purge_1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/expertise/expertise_of_purge_1.py b/scripts/expertise/expertise_of_purge_1.py index 36e8c855..3598d236 100644 --- a/scripts/expertise/expertise_of_purge_1.py +++ b/scripts/expertise/expertise_of_purge_1.py @@ -1,9 +1,9 @@ import sys def addAbilities(core, actor, player): - actor.addAbility("expertise_of_purge_1") + actor.addAbility("of_purge_1") return def removeAbilities(core, actor, player): - actor.removeAbility("expertise_of_purge_1") + actor.removeAbility("of_purge_1") return From c5fdad3092a6d563ad47d85fee0f875cb053dc23 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Tue, 8 Apr 2014 22:36:43 +0200 Subject: [PATCH 39/68] crystal template change --- scripts/lootPools/colorcrystals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lootPools/colorcrystals.py b/scripts/lootPools/colorcrystals.py index f5e4e85a..714a540c 100644 --- a/scripts/lootPools/colorcrystals.py +++ b/scripts/lootPools/colorcrystals.py @@ -2,7 +2,7 @@ def itemTemplates(): - templates=['object/tangible/loot/npc_loot/shared_generic_crystal.iff'] + templates=['object/tangible/component/weapon/lightsaber/lightsaber_module_force_crystal.iff'] return templates def itemChances(): From 5dcd7801959d2b37ba858e8a8763a7b6acd75acd Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Tue, 8 Apr 2014 22:37:21 +0200 Subject: [PATCH 40/68] Math change --- src/services/LootService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/LootService.java b/src/services/LootService.java index 7ad8fdb8..a7376d69 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -84,9 +84,9 @@ public class LootService implements INetworkDispatch { CreatureObject lootedCreature = (CreatureObject) lootedObject; int creatureCL = lootedCreature.getLevel(); creatureCL = 90; - int minimalCredits = 40 * creatureCL; // Predetermined factor of 40 per CL - int spanOfCredits = 15 * creatureCL; // Predetermined factor of 15 per CL - System.out.println("spanOfCredits " + spanOfCredits); + int maximalCredits = (int)Math.floor(4*creatureCL + creatureCL*creatureCL*4/100); + int minimalCredits = (int)Math.floor(creatureCL*2 + maximalCredits/2); + int spanOfCredits = maximalCredits - minimalCredits; lootedCredits = minimalCredits + new Random().nextInt(spanOfCredits); requester.sendSystemMessage("You looted " + lootedCredits + " credits.", (byte)1); } From 6e84d1334102f3dc0e9741e82e853c3a96b6c28c Mon Sep 17 00:00:00 2001 From: Waverunner Date: Tue, 8 Apr 2014 19:42:38 -0400 Subject: [PATCH 41/68] Able to create a chat room now Work still needs to be done on joining the rooms. However, you can create custom rooms. --- src/protocol/swg/ChatCreateRoom.java | 29 ++++++++++++++ src/protocol/swg/ChatEnterRoomById.java | 19 ++++++--- src/protocol/swg/ChatOnCreateRoom.java | 52 +++++++++++++++++++++++-- src/protocol/swg/ChatOnEnteredRoom.java | 1 + src/services/chat/ChatService.java | 46 ++++++++++++++++++---- 5 files changed, 131 insertions(+), 16 deletions(-) diff --git a/src/protocol/swg/ChatCreateRoom.java b/src/protocol/swg/ChatCreateRoom.java index 5f63614a..640cba0e 100644 --- a/src/protocol/swg/ChatCreateRoom.java +++ b/src/protocol/swg/ChatCreateRoom.java @@ -23,11 +23,23 @@ package protocol.swg; import org.apache.mina.core.buffer.IoBuffer; + public class ChatCreateRoom extends SWGMessage { + private String address, title; + private boolean privacy, moderatorOnly; + private int request; + + public ChatCreateRoom() { } @Override public void deserialize(IoBuffer data) { + this.privacy = (boolean) ((data.get() == 1) ? false : true); + this.moderatorOnly = (boolean) ((data.get() == 1) ? true : false); + data.getShort(); // unk + this.address = getAsciiString(data); + this.title = getAsciiString(data); + this.request = data.getInt(); } @Override @@ -35,4 +47,21 @@ public class ChatCreateRoom extends SWGMessage { return null; } + public String getAddress() { + return address; + } + public String getTitle() { + return title; + } + public boolean isPrivacy() { + return privacy; + } + public boolean isModeratorOnly() { + return moderatorOnly; + } + + public int getRequest() { + return request; + } + } diff --git a/src/protocol/swg/ChatEnterRoomById.java b/src/protocol/swg/ChatEnterRoomById.java index 29fd69cd..a5b2d4c3 100644 --- a/src/protocol/swg/ChatEnterRoomById.java +++ b/src/protocol/swg/ChatEnterRoomById.java @@ -23,15 +23,24 @@ package protocol.swg; import org.apache.mina.core.buffer.IoBuffer; +import resources.common.StringUtilities; + public class ChatEnterRoomById extends SWGMessage { private int roomId; + private int requestId; public ChatEnterRoomById() { } @Override public void deserialize(IoBuffer data) { - setRoomId(data.getInt()); + StringUtilities.printBytes(data.array()); + data.getShort(); + data.getInt(); + + this.requestId = data.getInt(); + this.roomId = data.getInt(); + // getAsciiString(data); // name of the room but don't need it since we have id. } @Override @@ -39,12 +48,12 @@ public class ChatEnterRoomById extends SWGMessage { return null; } + public int getRequestId() { + return requestId; + } + public int getRoomId() { return roomId; } - public void setRoomId(int roomId) { - this.roomId = roomId; - } - } diff --git a/src/protocol/swg/ChatOnCreateRoom.java b/src/protocol/swg/ChatOnCreateRoom.java index be54a71d..0492800c 100644 --- a/src/protocol/swg/ChatOnCreateRoom.java +++ b/src/protocol/swg/ChatOnCreateRoom.java @@ -21,6 +21,10 @@ ******************************************************************************/ package protocol.swg; +import java.nio.ByteOrder; + +import main.NGECore; + import org.apache.mina.core.buffer.IoBuffer; import services.chat.ChatRoom; @@ -28,9 +32,13 @@ import services.chat.ChatRoom; public class ChatOnCreateRoom extends SWGMessage { private ChatRoom room; + private int error; + private int requestId; - public ChatOnCreateRoom(ChatRoom room) { + public ChatOnCreateRoom(ChatRoom room, int error, int requestId) { this.room = room; + this.error = error; + this.requestId = requestId; } @Override @@ -40,8 +48,46 @@ public class ChatOnCreateRoom extends SWGMessage { @Override public IoBuffer serialize() { - // TODO Auto-generated method stub - return null; + String server = NGECore.getInstance().getGalaxyName(); + IoBuffer data = IoBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN); + data.setAutoExpand(true); + + data.putShort((short) 4); + data.putInt(0x35D7CC9F); + + data.putInt(error); + data.putInt(room.getRoomId()); + data.putInt(room.isPrivateRoom() ? 0 : 1); + data.put((byte) (room.isModeratorsOnly() ? 1 : 0)); + data.put(getAsciiString(room.getRoomAddress())); + data.put(getAsciiString("SWG")); + data.put(getAsciiString(server)); + data.put(getAsciiString(room.getCreator())); + data.put(getAsciiString("SWG")); + data.put(getAsciiString(server)); + data.put(getAsciiString(room.getOwner())); + data.put(getUnicodeString(room.getDescription())); + + data.putInt(0); + /*if (room.getModeratorList().size() > 0) { + for (CreatureObject creo : room.getModeratorList()) { + data.put(getAsciiString("SWG")); + data.put(getAsciiString(server)); + data.put(getAsciiString(creo.getCustomName())); + } + }*/ + + data.putInt(0); + /*if (room.getUserList().size() > 0) { + for (CreatureObject creo : room.getUserList()) { + data.put(getAsciiString("SWG")); + data.put(getAsciiString(server)); + data.put(getAsciiString(creo.getCustomName())); + } + }*/ + + data.putInt(requestId); + return data.flip(); } } diff --git a/src/protocol/swg/ChatOnEnteredRoom.java b/src/protocol/swg/ChatOnEnteredRoom.java index b040c1bf..179f981a 100644 --- a/src/protocol/swg/ChatOnEnteredRoom.java +++ b/src/protocol/swg/ChatOnEnteredRoom.java @@ -62,6 +62,7 @@ public class ChatOnEnteredRoom extends SWGMessage { buffer.put(getAsciiString(characterName)); buffer.putInt(success); buffer.putInt(roomId); + buffer.putInt(0); return buffer.flip(); } diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index 562686dc..8d4a159f 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -49,6 +49,7 @@ import resources.common.*; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import protocol.swg.AddIgnoreMessage; +import protocol.swg.ChatCreateRoom; import protocol.swg.ChatEnterRoomById; import protocol.swg.ChatOnChangeFriendStatus; import protocol.swg.ChatDeletePersistentMessage; @@ -56,6 +57,7 @@ import protocol.swg.ChatFriendsListUpdate; import protocol.swg.ChatInstantMessageToCharacter; import protocol.swg.ChatInstantMessagetoClient; import protocol.swg.ChatOnAddFriend; +import protocol.swg.ChatOnCreateRoom; import protocol.swg.ChatOnEnteredRoom; import protocol.swg.ChatOnSendInstantMessage; import protocol.swg.ChatOnSendPersistentMessage; @@ -369,13 +371,37 @@ public class ChatService implements INetworkDispatch { }); swgOpcodes.put(Opcodes.ChatCreateRoom, (session, data) -> { - //System.out.println("CREATE:"); - //StringUtilities.printBytes(data.array()); + data.order(ByteOrder.LITTLE_ENDIAN); + + Client client = core.getClient(session); + + if(client == null) + return; + + SWGObject obj = client.getParent(); + + if (obj == null) + return; + + CreatureObject creo = (CreatureObject) obj; + + ChatCreateRoom sentPacket = new ChatCreateRoom(); + sentPacket.deserialize(data); + + ChatRoom room = createChatRoom(sentPacket.getTitle(), sentPacket.getAddress(), creo.getCustomName().toLowerCase(), true, false); + room.setPrivateRoom(sentPacket.isPrivacy()); + room.setModeratorsOnly(sentPacket.isModeratorOnly()); + + if (room != null) { + room.getUserList().add(creo); + room.getModeratorList().add(creo); + ChatOnCreateRoom response = new ChatOnCreateRoom(room, 0, sentPacket.getRequest()); + session.write(response.serialize()); + } + }); swgOpcodes.put(Opcodes.ChatQueryRoom, (session, data) -> { - //System.out.println("QUERY: "); - //StringUtilities.printBytes(data.array()); }); swgOpcodes.put(Opcodes.ChatSendToRoom, (session, data) -> { @@ -408,13 +434,14 @@ public class ChatService implements INetworkDispatch { if (obj == null) return; - + data.order(ByteOrder.LITTLE_ENDIAN); + data.position(0); ChatEnterRoomById sentPacket = new ChatEnterRoomById(); sentPacket.deserialize(data); joinChatRoom((CreatureObject) obj, sentPacket.getRoomId()); - //System.out.println("Entering room..."); + System.out.println("Entering room... " + sentPacket.getRoomId()); }); } @@ -684,7 +711,7 @@ public class ChatService implements INetworkDispatch { } private void loadChatRooms() { - ChatRoom system = createChatRoom("Waves Dungeon", "ProjectSWGTest.Dungeon", "Waverunner", true); + ChatRoom system = createChatRoom("", "Chat", "system", true); chatRooms.put(system.getRoomId(), system); EntityCursor cursor = chatRoomsODB.getCursor(Integer.class, ChatRoom.class); @@ -704,7 +731,10 @@ public class ChatService implements INetworkDispatch { ChatRoom room = new ChatRoom(); room.setDescription(roomName); - room.setRoomAddress("SWG." + core.getGalaxyName() + "." + address); + if (!address.startsWith("SWG.")) + room.setRoomAddress("SWG." + core.getGalaxyName() + "." + address); + else + room.setRoomAddress(address); room.setCreator(creator); room.setOwner(creator); room.setVisible(showInList); From 4d264f8c8a23736d2631463c70d66ed4d22159f4 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Wed, 9 Apr 2014 04:57:26 +0200 Subject: [PATCH 42/68] Refined the loot system Added more py scripts for krayt pearls and junk Made system more flexible --- scripts/loot/lootItems/colorcrystal.py | 21 +++ scripts/loot/lootItems/damaged_datapad.py | 20 +++ scripts/loot/lootItems/kraytpearl_cracked.py | 8 + scripts/loot/lootItems/kraytpearl_fair.py | 8 + scripts/loot/lootItems/kraytpearl_flawless.py | 8 + scripts/loot/lootItems/kraytpearl_good.py | 8 + scripts/loot/lootItems/kraytpearl_poor.py | 8 + scripts/loot/lootItems/kraytpearl_premium.py | 8 + scripts/loot/lootItems/kraytpearl_quality.py | 8 + .../loot/lootItems/kraytpearl_scratched.py | 8 + scripts/loot/lootItems/kraytpearl_select.py | 8 + scripts/loot/lootItems/red_wiring.py | 20 +++ scripts/loot/lootItems/shared_rifle_cdef.py | 20 +++ scripts/loot/lootItems/worklight_generic.py | 21 +++ scripts/loot/lootPools/colorcrystals.py | 8 + scripts/{ => loot}/lootPools/jediholocrons.py | 0 scripts/loot/lootPools/junk.py | 8 + scripts/loot/lootPools/kraytpearl_lowq.py | 8 + scripts/loot/lootPools/kraytpearls_range.py | 6 + scripts/{ => loot}/lootPools/rareloot.py | 2 +- scripts/loot/lootPools/rifles.py | 8 + scripts/{ => loot}/lootPools/sithholocrons.py | 0 scripts/lootPools/colorcrystals.py | 9 - scripts/lootPools/junk.py | 8 - scripts/lootPools/kraytpearls.py | 8 - scripts/lootPools/rifles.py | 9 - scripts/object/mobile/krayt_dragon.py | 13 +- scripts/object/mobile/tusken_raider.py | 6 +- .../objects/loot/LootRollSession.java | 20 ++- .../objects/tangible/TangibleObject.java | 2 +- src/services/LootService.java | 155 ++++++++++++++---- src/services/ScriptService.java | 10 ++ 32 files changed, 372 insertions(+), 82 deletions(-) create mode 100644 scripts/loot/lootItems/colorcrystal.py create mode 100644 scripts/loot/lootItems/damaged_datapad.py create mode 100644 scripts/loot/lootItems/kraytpearl_cracked.py create mode 100644 scripts/loot/lootItems/kraytpearl_fair.py create mode 100644 scripts/loot/lootItems/kraytpearl_flawless.py create mode 100644 scripts/loot/lootItems/kraytpearl_good.py create mode 100644 scripts/loot/lootItems/kraytpearl_poor.py create mode 100644 scripts/loot/lootItems/kraytpearl_premium.py create mode 100644 scripts/loot/lootItems/kraytpearl_quality.py create mode 100644 scripts/loot/lootItems/kraytpearl_scratched.py create mode 100644 scripts/loot/lootItems/kraytpearl_select.py create mode 100644 scripts/loot/lootItems/red_wiring.py create mode 100644 scripts/loot/lootItems/shared_rifle_cdef.py create mode 100644 scripts/loot/lootItems/worklight_generic.py create mode 100644 scripts/loot/lootPools/colorcrystals.py rename scripts/{ => loot}/lootPools/jediholocrons.py (100%) create mode 100644 scripts/loot/lootPools/junk.py create mode 100644 scripts/loot/lootPools/kraytpearl_lowq.py create mode 100644 scripts/loot/lootPools/kraytpearls_range.py rename scripts/{ => loot}/lootPools/rareloot.py (85%) create mode 100644 scripts/loot/lootPools/rifles.py rename scripts/{ => loot}/lootPools/sithholocrons.py (100%) delete mode 100644 scripts/lootPools/colorcrystals.py delete mode 100644 scripts/lootPools/junk.py delete mode 100644 scripts/lootPools/kraytpearls.py delete mode 100644 scripts/lootPools/rifles.py diff --git a/scripts/loot/lootItems/colorcrystal.py b/scripts/loot/lootItems/colorcrystal.py new file mode 100644 index 00000000..cce04300 --- /dev/null +++ b/scripts/loot/lootItems/colorcrystal.py @@ -0,0 +1,21 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' + +def customItemName(): + + return '' + +def customItemStackCount(): + + return 1 + +def customizationAttributes(): + + return [] + +def customizationValues(): + + return [] + diff --git a/scripts/loot/lootItems/damaged_datapad.py b/scripts/loot/lootItems/damaged_datapad.py new file mode 100644 index 00000000..7757a473 --- /dev/null +++ b/scripts/loot/lootItems/damaged_datapad.py @@ -0,0 +1,20 @@ + +def itemTemplate(): + + return 'object/tangible/loot/misc/shared_damaged_datapad.iff' + +def customItemName(): + + return '' + +def customItemStackCount(): + + return 1 + +def customizationAttributes(): + + return [] + +def customizationValues(): + + return [] \ No newline at end of file diff --git a/scripts/loot/lootItems/kraytpearl_cracked.py b/scripts/loot/lootItems/kraytpearl_cracked.py new file mode 100644 index 00000000..33536979 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_cracked.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_fair.py b/scripts/loot/lootItems/kraytpearl_fair.py new file mode 100644 index 00000000..33536979 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_fair.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_flawless.py b/scripts/loot/lootItems/kraytpearl_flawless.py new file mode 100644 index 00000000..33536979 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_flawless.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_good.py b/scripts/loot/lootItems/kraytpearl_good.py new file mode 100644 index 00000000..33536979 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_good.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_poor.py b/scripts/loot/lootItems/kraytpearl_poor.py new file mode 100644 index 00000000..33536979 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_poor.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_premium.py b/scripts/loot/lootItems/kraytpearl_premium.py new file mode 100644 index 00000000..33536979 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_premium.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_quality.py b/scripts/loot/lootItems/kraytpearl_quality.py new file mode 100644 index 00000000..33536979 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_quality.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_scratched.py b/scripts/loot/lootItems/kraytpearl_scratched.py new file mode 100644 index 00000000..33536979 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_scratched.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_select.py b/scripts/loot/lootItems/kraytpearl_select.py new file mode 100644 index 00000000..33536979 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_select.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/red_wiring.py b/scripts/loot/lootItems/red_wiring.py new file mode 100644 index 00000000..483dc8f7 --- /dev/null +++ b/scripts/loot/lootItems/red_wiring.py @@ -0,0 +1,20 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_red_wiring_generic.iff' + +def customItemName(): + + return '' + +def customItemStackCount(): + + return 1 + +def customizationAttributes(): + + return [] + +def customizationValues(): + + return [] diff --git a/scripts/loot/lootItems/shared_rifle_cdef.py b/scripts/loot/lootItems/shared_rifle_cdef.py new file mode 100644 index 00000000..0d683b7f --- /dev/null +++ b/scripts/loot/lootItems/shared_rifle_cdef.py @@ -0,0 +1,20 @@ + +def itemTemplate(): + + return 'object/weapon/ranged/rifle/shared_rifle_cdef.iff' + +def customItemName(): + + return '' + +def customItemStackCount(): + + return 1 + +def customizationAttributes(): + + return [] + +def customizationValues(): + + return [] diff --git a/scripts/loot/lootItems/worklight_generic.py b/scripts/loot/lootItems/worklight_generic.py new file mode 100644 index 00000000..86a9231b --- /dev/null +++ b/scripts/loot/lootItems/worklight_generic.py @@ -0,0 +1,21 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_worklight_generic.iff' + +def customItemName(): + + return '' + +def customItemStackCount(): + + return 1 + +def customizationAttributes(): + + return [] + +def customizationValues(): + + return [] + diff --git a/scripts/loot/lootPools/colorcrystals.py b/scripts/loot/lootPools/colorcrystals.py new file mode 100644 index 00000000..d372b968 --- /dev/null +++ b/scripts/loot/lootPools/colorcrystals.py @@ -0,0 +1,8 @@ + +def itemNames(): + + return ['colorCrystal'] + +def itemChances(): + + return [70] \ No newline at end of file diff --git a/scripts/lootPools/jediholocrons.py b/scripts/loot/lootPools/jediholocrons.py similarity index 100% rename from scripts/lootPools/jediholocrons.py rename to scripts/loot/lootPools/jediholocrons.py diff --git a/scripts/loot/lootPools/junk.py b/scripts/loot/lootPools/junk.py new file mode 100644 index 00000000..32ec26c3 --- /dev/null +++ b/scripts/loot/lootPools/junk.py @@ -0,0 +1,8 @@ + +def itemNames(): + + templates=['damaged_datapad','red_wiring','worklight_generic'] + return templates + +def itemChances(): + return [70,50,40] \ No newline at end of file diff --git a/scripts/loot/lootPools/kraytpearl_lowq.py b/scripts/loot/lootPools/kraytpearl_lowq.py new file mode 100644 index 00000000..4fe709c2 --- /dev/null +++ b/scripts/loot/lootPools/kraytpearl_lowq.py @@ -0,0 +1,8 @@ + +def itemNames(): + + return ['kraytpearl_cracked','kraytpearl_scratched','kraytpearl_poor'] + +def itemChances(): + + return [33,33,34] \ No newline at end of file diff --git a/scripts/loot/lootPools/kraytpearls_range.py b/scripts/loot/lootPools/kraytpearls_range.py new file mode 100644 index 00000000..23477840 --- /dev/null +++ b/scripts/loot/lootPools/kraytpearls_range.py @@ -0,0 +1,6 @@ + +def itemTemplates(): + return ['kraytpearl_fair','kraytpearl_good','kraytpearl_quality','kraytpearl_select','kraytpearl_premium','kraytpearl_flawless'] + +def itemChances(): + return [10,20,30,34,5,1] #= 100% \ No newline at end of file diff --git a/scripts/lootPools/rareloot.py b/scripts/loot/lootPools/rareloot.py similarity index 85% rename from scripts/lootPools/rareloot.py rename to scripts/loot/lootPools/rareloot.py index 19ffe37f..4487075d 100644 --- a/scripts/lootPools/rareloot.py +++ b/scripts/loot/lootPools/rareloot.py @@ -1,6 +1,6 @@ -def itemTemplates(): +def itemNames(): templates=['object/tangible/item/shared_rare_loot_chest_3.iff'] return templates diff --git a/scripts/loot/lootPools/rifles.py b/scripts/loot/lootPools/rifles.py new file mode 100644 index 00000000..c24909b7 --- /dev/null +++ b/scripts/loot/lootPools/rifles.py @@ -0,0 +1,8 @@ + +def itemNames(): + + return ['shared_rifle_cdef'] + +def itemChances(): + return [100] + \ No newline at end of file diff --git a/scripts/lootPools/sithholocrons.py b/scripts/loot/lootPools/sithholocrons.py similarity index 100% rename from scripts/lootPools/sithholocrons.py rename to scripts/loot/lootPools/sithholocrons.py diff --git a/scripts/lootPools/colorcrystals.py b/scripts/lootPools/colorcrystals.py deleted file mode 100644 index 714a540c..00000000 --- a/scripts/lootPools/colorcrystals.py +++ /dev/null @@ -1,9 +0,0 @@ - - -def itemTemplates(): - - templates=['object/tangible/component/weapon/lightsaber/lightsaber_module_force_crystal.iff'] - return templates - -def itemChances(): - return [70] \ No newline at end of file diff --git a/scripts/lootPools/junk.py b/scripts/lootPools/junk.py deleted file mode 100644 index 65deb632..00000000 --- a/scripts/lootPools/junk.py +++ /dev/null @@ -1,8 +0,0 @@ - -def itemTemplates(): - - templates=['object/tangible/loot/misc/shared_damaged_datapad.iff','object/tangible/loot/npc_loot/shared_red_wiring_generic.iff','object/tangible/loot/npc_loot/shared_worklight_generic.iff'] - return templates - -def itemChances(): - return [70,50,40] \ No newline at end of file diff --git a/scripts/lootPools/kraytpearls.py b/scripts/lootPools/kraytpearls.py deleted file mode 100644 index 8463ef39..00000000 --- a/scripts/lootPools/kraytpearls.py +++ /dev/null @@ -1,8 +0,0 @@ - -def itemTemplates(): - - templates=['1','2','3','Flawless'] - return templates - -def itemChances(): - return [60,20,10,5] \ No newline at end of file diff --git a/scripts/lootPools/rifles.py b/scripts/lootPools/rifles.py deleted file mode 100644 index c3402805..00000000 --- a/scripts/lootPools/rifles.py +++ /dev/null @@ -1,9 +0,0 @@ - - -def itemTemplates(): - - templates=['object/weapon/ranged/rifle/shared_rifle_cdef.iff'] - return templates - -def itemChances(): - return [70] \ No newline at end of file diff --git a/scripts/object/mobile/krayt_dragon.py b/scripts/object/mobile/krayt_dragon.py index ccad8904..c65d802c 100644 --- a/scripts/object/mobile/krayt_dragon.py +++ b/scripts/object/mobile/krayt_dragon.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['kraytpearl_loq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 35 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/tusken_raider.py b/scripts/object/mobile/tusken_raider.py index d4aa322f..961975a9 100644 --- a/scripts/object/mobile/tusken_raider.py +++ b/scripts/object/mobile/tusken_raider.py @@ -4,12 +4,12 @@ def setup(core, object): lootPoolNames_1 = ['Junk','Rifles'] lootPoolChances_1 = [90,70] - lootGroupChance_1 = 80 + lootGroupChance_1 = 90 object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) lootPoolNames_2 = ['Colorcrystals'] - lootPoolChances_2 = [50] - lootGroupChance_2 = 60 + lootPoolChances_2 = [100] + lootGroupChance_2 = 20 object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) lootPoolNames_3 = ['Rareloot'] diff --git a/src/resources/objects/loot/LootRollSession.java b/src/resources/objects/loot/LootRollSession.java index 5d1937b6..62d12077 100644 --- a/src/resources/objects/loot/LootRollSession.java +++ b/src/resources/objects/loot/LootRollSession.java @@ -24,9 +24,11 @@ package resources.objects.loot; import java.util.ArrayList; import java.util.List; +import engine.resources.scene.Planet; import main.NGECore; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; +import resources.objects.tangible.TangibleObject; /** * @author Charon @@ -36,7 +38,8 @@ public class LootRollSession { private String SessionID; // leaderName-SystemTime private GroupObject playerGroup; - private List droppedItemTemplates; + private List droppedItems; + private Planet sessionPlanet; public LootRollSession(){ } @@ -49,15 +52,16 @@ public class LootRollSession { } else { this.SessionID = requester.getCustomName()+"-"+System.currentTimeMillis(); } - droppedItemTemplates = new ArrayList(); + droppedItems = new ArrayList(); + sessionPlanet = requester.getPlanet(); } - public List getDroppedItemTemplates() { - return droppedItemTemplates; + public List getDroppedItems() { + return droppedItems; } - public void addDroppedItemTemplate(String droppedItemTemplate) { - this.droppedItemTemplates.add(droppedItemTemplate); + public void addDroppedItem(TangibleObject droppedItem) { + this.droppedItems.add(droppedItem); } public String getSessionID() { @@ -71,4 +75,8 @@ public class LootRollSession { public void generateSessionID(String sessionID) { SessionID = sessionID; } + + public Planet getSessionPlanet() { + return sessionPlanet; + } } diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 7ac2c6ea..ee415959 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -60,7 +60,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=2) +@Persistent(version=3) public class TangibleObject extends SWGObject { // TODO: Thread safety diff --git a/src/services/LootService.java b/src/services/LootService.java index a7376d69..b16a125d 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -21,29 +21,18 @@ ******************************************************************************/ package services; -import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Random; -import java.util.TreeMap; -import java.util.TreeSet; import java.util.Vector; - import resources.objects.creature.CreatureObject; -import resources.objects.group.GroupObject; -import resources.objects.loot.LootDrop; import resources.objects.loot.LootGroup; -import resources.objects.loot.LootPool; import resources.objects.loot.LootRollSession; -import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; -import resources.objects.tool.SurveyTool; import main.NGECore; import engine.resources.objects.SWGObject; +import engine.resources.scene.Planet; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -110,27 +99,23 @@ public class LootService implements INetworkDispatch { int lootGroupRoll = new Random().nextInt(100); if (lootGroupRoll <= groupChance){ System.out.println("this lootGroup will drop something"); - handleLootGroup(lootGroup,lootRollSession); //this lootGroup will drop something + handleLootGroup(lootGroup,lootRollSession); //this lootGroup will drop something e.g. {kraytpearl_range,krayt_tissue_rare} } } - for (String s : lootRollSession.getDroppedItemTemplates()){ - System.out.println("lootRollSession template: " + s); - } - // ********** Phase 1 complete, loot items determined ********** // stored in the lootSession // Distribute the loot drops according to group loot rules // For now just spawn items into requester's inventory SWGObject requesterInventory = requester.getSlottedObject("inventory"); - System.out.println("requesterInventory " + requesterInventory); - for (String template : lootRollSession.getDroppedItemTemplates()){ - TangibleObject droppedItem = (TangibleObject) core.objectService.createObject(template, requester.getPlanet()); - System.out.println("droppedItem " + droppedItem); + + for (TangibleObject droppedItem : lootRollSession.getDroppedItems()){ + requesterInventory.add(droppedItem); } + // ToDo: Group loot settings etc. actual loot chance was lootgroupchance*lootchance } @@ -148,33 +133,131 @@ public class LootService implements INetworkDispatch { System.err.println("No Lootpools in Lootgroup!"); return; } + + int randomItemFromGroup = new Random().nextInt(100); + int remainder = 0; // [10,20,30,34,5,1] + for(int i=0;i itemTemplates = (Vector)core.scriptService.fetchStringVector(path,"itemTemplates"); + String path = "scripts/loot/lootPools/"+poolName.toLowerCase(); + Vector itemNames = (Vector)core.scriptService.fetchStringVector(path,"itemNames"); - for (String s : itemTemplates){ + for (String s : itemNames){ System.out.println("template: " + s); } Vector itemChances = (Vector)core.scriptService.fetchIntegerVector(path,"itemChances"); - - // Now here maybe all items in pool have an equal chance to spawn - // or they have percentages assigned to them as well - + int randomItemFromPool = new Random().nextInt(100); - int itemIndex = (int)Math.floor(randomItemFromPool/100*itemTemplates.size()); // 5 Elements,rnd is 83 -> 0.83*5= + int remainder = 0; // [10,20,30,34,5,1] - lootRollSession.addDroppedItemTemplate(itemTemplates.get(itemIndex)); + for (int i=0;i customizationAttributes = (Vector)core.scriptService.fetchStringVector(path,"customizationAttributes"); + Vector customizationValues = (Vector)core.scriptService.fetchIntegerVector(path,"customizationValues"); + + System.out.println("itemTemplate " + itemTemplate); + + /* + craftingValues = { + {"mindamage",25,35,0}, + {"maxdamage",40,50,0}, + {"attackspeed",1,-1,5}, + {"woundchance",4,8,5}, + {"hitpoints",800,1200,0}, + {"attackhealthcost",0,9,0}, + {"attackactioncost",0,9,0}, + {"attackmindcost",0,9,0}, + {"forcecost",0,9.9,0}, + {"color",31,31,0}, + {"quality",6,6,0}, + }, + */ + + + + + + + + + TangibleObject droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet()); + + handleCustomDropName(droppedItem); + handleStats(droppedItem); + setCustomization(droppedItem); + + lootRollSession.addDroppedItem(droppedItem); + } + + + + private void handleCustomDropName(TangibleObject droppedItem) { + String customName = droppedItem.getCustomName(); + + if (customName!=null) { + if (customName.charAt(0) == '@' || customName.contains("_n:")) { + customName = ""; // Look the name up in some tre table + } + } + droppedItem.setCustomName(customName); + } + + private TangibleObject createDroppedItem(String template,Planet planet){ + TangibleObject droppedItem = (TangibleObject) core.objectService.createObject(template, planet); + System.out.println("droppedItem " + droppedItem); + return droppedItem; + } + + + + private void setCustomization(TangibleObject droppedItem) { + + // Example color crystal + droppedItem.setCustomizationVariable("/private/index_color_1", (byte) new Random().nextInt(7)); // 4 blue + + // More general +// String path = "scripts/loot/lootItems/"+droppedItem.getCustomName().toLowerCase(); +// Vector customizationPaths = (Vector)core.scriptService.fetchStringVector(path,"itemCustomizationPaths"); +// Vector customizationValues = (Vector)core.scriptService.fetchIntegerVector(path,"itemCustomizationValues"); +// for (int i=0;i fetchStringVector(String path, String method) { Vector vector = new Vector(); PyObject result = core.scriptService.callScript(path, "", method); From 46c2c1bf2c73111b09fff86e414ab4457c894127 Mon Sep 17 00:00:00 2001 From: Seefo Date: Tue, 8 Apr 2014 23:47:59 -0400 Subject: [PATCH 43/68] Preliminary housing --- scripts/commands/placestructure.py | 26 +++ .../player_house_generic_small_style_01.py | 14 ++ .../player_house_generic_small_style_01.py | 5 + .../generic_house_small_deed.py | 4 + scripts/radial/structureDeed.py | 11 ++ src/main/NGECore.java | 5 + .../EnterStructurePlacementModeMessage.java | 64 +++++++ src/services/DevService.java | 7 +- src/services/housing/HouseTemplate.java | 55 ++++++ src/services/housing/HousingService.java | 166 ++++++++++++++++++ src/services/object/ObjectService.java | 12 +- 11 files changed, 362 insertions(+), 7 deletions(-) create mode 100644 scripts/commands/placestructure.py create mode 100644 scripts/houses/player_house_generic_small_style_01.py create mode 100644 scripts/radial/structureDeed.py create mode 100644 src/protocol/swg/EnterStructurePlacementModeMessage.java create mode 100644 src/services/housing/HouseTemplate.java create mode 100644 src/services/housing/HousingService.java diff --git a/scripts/commands/placestructure.py b/scripts/commands/placestructure.py new file mode 100644 index 00000000..edddb24e --- /dev/null +++ b/scripts/commands/placestructure.py @@ -0,0 +1,26 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + cmdArgs = commandString.split(" ") + + deedId = long(cmdArgs[0]) + deed = core.objectService.getObject(deedId) + + positionX = float(cmdArgs[1]) + positionZ = float(cmdArgs[2]) + #positionY = core.terrainService.getHeight(actor.getPlanetId(), positionX, positionZ) + 2 + + rotation = float(cmdArgs[3]) + + + #structureTemplate = deed.getAttachment("structureTemplate") + + core.housingService.placeStructure(actor, deed, positionX, positionZ, rotation) + + #building = core.objectService.createObject(structureTemplate, actor.getPlanet(), positionX, positionZ, positionY); + #core.simulationService.add(building, building.getPosition().x, building.getPosition().z); + + return \ No newline at end of file diff --git a/scripts/houses/player_house_generic_small_style_01.py b/scripts/houses/player_house_generic_small_style_01.py new file mode 100644 index 00000000..95d9f2b4 --- /dev/null +++ b/scripts/houses/player_house_generic_small_style_01.py @@ -0,0 +1,14 @@ +import sys +from services.housing import HouseTemplate +from engine.resources.scene import Point3D + +def setup(core): + houseTemplate = HouseTemplate("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", "object/building/player/shared_player_house_generic_small_style_01.iff", 2) + + houseTemplate.addBuildingSign("object/tangible/sign/player/shared_house_address.iff", Point3D(1, 2, 3)) + houseTemplate.addPlaceablePlanet("tatooine") + houseTemplate.addPlaceablePlanet("corellia") + houseTemplate.addPlaceablePlanet("naboo") + + core.housingService.addHousingTemplate(houseTemplate) + return \ No newline at end of file diff --git a/scripts/object/building/player/player_house_generic_small_style_01.py b/scripts/object/building/player/player_house_generic_small_style_01.py index ccad8904..17c11b52 100644 --- a/scripts/object/building/player/player_house_generic_small_style_01.py +++ b/scripts/object/building/player/player_house_generic_small_style_01.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + sign = core.objectService.createChildObject(object, 'object/tangible/sign/player/shared_house_address.iff', -7.39, 2.36, 2, -1, 0, -1) + print(sign) + object.setAttachment("structureSign", sign) + + core.objectService.createChildObject(object, 'object/tangible/terminal/shared_terminal_player_structure.iff', -5, 0.74, -1.81, 0.707107, -0.707107, 1) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py b/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py index ccad8904..e100519a 100644 --- a/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py +++ b/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'structureDeed'); + return + +def use(core, actor, object): return \ No newline at end of file diff --git a/scripts/radial/structureDeed.py b/scripts/radial/structureDeed.py new file mode 100644 index 00000000..0ddee9f3 --- /dev/null +++ b/scripts/radial/structureDeed.py @@ -0,0 +1,11 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + return + +def handleSelection(core, owner, target, option): + if option == 21 and target: + core.housingService.enterStructureMode(owner, target) + return + \ No newline at end of file diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 0762507f..050e213b 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -57,6 +57,7 @@ import services.DevService; import services.EntertainmentService; import services.EquipmentService; import services.GroupService; +import services.housing.HousingService; import services.InstanceService; import services.LoginService; import services.MissionService; @@ -175,6 +176,8 @@ public class NGECore { public ResourceService resourceService; public ConversationService conversationService; + + public HousingService housingService; // Login Server @@ -286,6 +289,7 @@ public class NGECore { entertainmentService = new EntertainmentService(this); devService = new DevService(this); conversationService = new ConversationService(this); + housingService = new HousingService(this); if (config.keyExists("JYTHONCONSOLE.PORT")) { int jythonPort = config.getInt("JYTHONCONSOLE.PORT"); @@ -449,6 +453,7 @@ public class NGECore { spawnService.loadLairGroups(); spawnService.loadSpawnAreas(); + housingService.loadHousingTemplates(); equipmentService.loadBonusSets(); retroService.run(); diff --git a/src/protocol/swg/EnterStructurePlacementModeMessage.java b/src/protocol/swg/EnterStructurePlacementModeMessage.java new file mode 100644 index 00000000..3f12cf0a --- /dev/null +++ b/src/protocol/swg/EnterStructurePlacementModeMessage.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg; + +import java.nio.ByteOrder; + +import main.NGECore; + +import org.apache.mina.core.buffer.IoBuffer; + +import services.travel.TravelPoint; +import engine.resources.objects.SWGObject; + +@SuppressWarnings("unused") +public class EnterStructurePlacementModeMessage extends SWGMessage { + + private SWGObject deed; + private String structureTemplate; + + public EnterStructurePlacementModeMessage(SWGObject deed, String structureTemplate) { + this.deed = deed; + this.structureTemplate = structureTemplate; + } + + @Override + public void deserialize(IoBuffer data) { + + } + + @Override + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(16 + structureTemplate.length()).order(ByteOrder.LITTLE_ENDIAN); + + result.putShort((short) 3); + result.putInt(0xE8A54DC1); + + result.putLong(deed.getObjectID()); + + deed.setAttachment("structureTemplate", structureTemplate); + result.put(getAsciiString(structureTemplate)); + + return result.flip(); + } + +} \ No newline at end of file diff --git a/src/services/DevService.java b/src/services/DevService.java index 0cde2b83..fe8c6e21 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -84,6 +84,7 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 21, "Weapons"); suiOptions.put((long) 22, "Misc Items"); suiOptions.put((long) 23, "Jedi Items"); + //suiOptions.put((long) 120, "House Deeds"); suiOptions.put((long) 110, "Survey Devices"); break; case 3: // [Items] Weapons @@ -990,8 +991,12 @@ public class DevService implements INetworkDispatch { SurveyTool solarSurveyTool = (SurveyTool) core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_solar.iff", planet); solarSurveyTool.setCustomName("Solar Survey Device"); inventory.add(solarSurveyTool); + return; - break; + case 120: + SWGObject houseDeed = core.objectService.createObject("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", planet); + inventory.add(houseDeed); + return; } } }); diff --git a/src/services/housing/HouseTemplate.java b/src/services/housing/HouseTemplate.java new file mode 100644 index 00000000..aaba8d7e --- /dev/null +++ b/src/services/housing/HouseTemplate.java @@ -0,0 +1,55 @@ +package services.housing; + +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + +import engine.resources.scene.Point3D; + +public class HouseTemplate +{ + private String deedTemplate; + private String buildingTemplate; + private int lotCost; + private Vector placeablePlanets; + private Map buildingSigns; + + public HouseTemplate(String deedTemplate, String buildingTemplate, int lotCost) + { + this.deedTemplate = deedTemplate; + this.buildingTemplate = buildingTemplate; + this.lotCost = lotCost; + this.placeablePlanets = new Vector(); + this.buildingSigns = new HashMap(); + } + + public void addBuildingSign(String signTemplate, Point3D signPosition) + { + buildingSigns.put(signTemplate, signPosition); + } + public void addPlaceablePlanet(String planetName) + { + this.placeablePlanets.add(planetName); + } + + public String getDeedTemplate() + { + return this.deedTemplate; + } + public String getBuildingTemplate() + { + return this.buildingTemplate; + } + public Map getBuildingSigns() + { + return this.buildingSigns; + } + public Vector getPlaceablePlanets() + { + return this.placeablePlanets; + } + public int getLotCost() + { + return this.lotCost; + } +} diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java new file mode 100644 index 00000000..bbeab9f9 --- /dev/null +++ b/src/services/housing/HousingService.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.housing; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.FileVisitor; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.Map; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; + +import com.sleepycat.persist.EntityCursor; + +import main.NGECore; +import protocol.swg.EnterStructurePlacementModeMessage; +import resources.objects.building.BuildingObject; +import resources.objects.creature.CreatureObject; +import resources.objects.player.PlayerObject; +import resources.objects.tangible.TangibleObject; +import services.chat.Mail; +import services.equipment.BonusSetTemplate; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; + +public class HousingService implements INetworkDispatch { + + private NGECore core; + private Map housingTemplates = new ConcurrentHashMap(); + + public HousingService(NGECore core) { + this.core = core; + core.commandService.registerCommand("placestructure"); + core.commandService.registerCommand("movefurniture"); + core.commandService.registerCommand("rotatefurniture"); + } + + public void enterStructureMode(CreatureObject player, TangibleObject deed) + { + if(housingTemplates.containsKey(deed.getTemplate())) + { + HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate()); + EnterStructurePlacementModeMessage packet = new EnterStructurePlacementModeMessage(deed, houseTemplate.getBuildingTemplate()); + player.getClient().getSession().write(packet.serialize()); + } + } + + public void placeStructure(final CreatureObject actor, TangibleObject deed, float positionX, float positionZ, float rotation) + { + HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate()); + + int structureLotCost = houseTemplate.getLotCost(); + String structureTemplate = houseTemplate.getBuildingTemplate(); + + // Lot stuff + if(actor.getAttachment("structureLots") == null) actor.setAttachment("structureLots", 10); // Temporary until better + + int playerLots = (int) actor.getAttachment("structureLots"); + if(playerLots - structureLotCost < 0) + { + actor.sendSystemMessage("You do not have enough available lots to place this structure.", (byte) 0); // should probably load this from an stf + return; + } + actor.setAttachment("structureLots", playerLots - structureLotCost); + + // Calculate our orientation and height + Quaternion quaternion = new Quaternion(1, 0, 0, 0); + quaternion = resources.common.MathUtilities.rotateQuaternion(quaternion, (float)((Math.PI/2) * rotation), new Point3D(0, 1, 0)); + + float positionY = core.terrainService.getHeight(actor.getPlanetId(), positionX, positionZ) + 2f; + + // Create the building + BuildingObject building = (BuildingObject) core.objectService.createObject(structureTemplate, 0, actor.getPlanet(), new Point3D(positionX, positionY, positionZ), quaternion); + core.simulationService.add(building, building.getPosition().x, building.getPosition().z, true); + + // Name the sign + TangibleObject sign = (TangibleObject) building.getAttachment("structureSign"); + sign.setCustomName2(actor.getCustomName() + "'s House"); + //building.add(sign); + + core.objectService.destroyObject(deed); + + // Structure management + Vector admins = new Vector<>(); + admins.add(actor.getObjectID()); + + building.setAttachment("structureOwner", actor.getObjectID()); + building.setAttachment("structureAdmins", admins); + + // Save structure to DB + //building.createTransaction(core.getBuildingODB().getEnvironment()); + //core.getBuildingODB().put(building, Long.class, BuildingObject.class, building.getTransaction()); + //building.getTransaction().commitSync(); + } + + @SuppressWarnings("unchecked") + public boolean getPermissions(SWGObject player, SWGObject container) + { + if(((Vector) container.getContainer().getAttachment("structureAdmins")).contains(player.getObjectID())) return true; + return false; + } + + public void addHousingTemplate(HouseTemplate houseTemplate) + { + housingTemplates.put(houseTemplate.getDeedTemplate(), houseTemplate); + } + + public void loadHousingTemplates() { + Path p = Paths.get("scripts/houses/"); + FileVisitor fv = new SimpleFileVisitor() + { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException + { + System.out.println("Loading housing template " + file.getFileName()); + core.scriptService.callScript("scripts/houses/", file.getFileName().toString().replace(".py", ""), "setup", core); + return FileVisitResult.CONTINUE; + } + }; + try + { + Files.walkFileTree(p, fv); + } + catch (IOException e) { e.printStackTrace(); } + } + + + + @Override + public void insertOpcodes(Map arg0, + Map arg1) { + // TODO Auto-generated method stub + + } + + @Override + public void shutdown() { + + } +} \ No newline at end of file diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index cb85e06d..6c5a44a4 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -877,7 +877,7 @@ public class ObjectService implements INetworkDispatch { * @param position The position as an offset to the parent object. * @param orientation The orientation as an offset to the parent object. */ - public void createChildObject(SWGObject parent, String template, Point3D position, Quaternion orientation, int cellNumber) { + public SWGObject createChildObject(SWGObject parent, String template, Point3D position, Quaternion orientation, int cellNumber) { if(cellNumber == -1) { @@ -907,15 +907,15 @@ public class ObjectService implements INetworkDispatch { child.setAttachment("cellNumber", cellNumber); //core.simulationService.add(child, x, z); - + return child; } - public void createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw) { - createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), -1); + public SWGObject createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw) { + return createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), -1); } - public void createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw, int cellNumber) { - createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), cellNumber); + public SWGObject createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw, int cellNumber) { + return createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), cellNumber); } public void loadBuildoutObjects(Planet planet) throws InstantiationException, IllegalAccessException { From 8025bc7ad09d971010dd7a60cdde96c841e99a25 Mon Sep 17 00:00:00 2001 From: Seefo Date: Wed, 9 Apr 2014 11:56:56 -0400 Subject: [PATCH 44/68] Changes to housing, added real player lot count to character sheet --- .../player_house_generic_small_style_01.py | 5 ++++ .../swg/CharacterSheetResponseMessage.java | 2 +- .../objects/creature/CreatureObject.java | 7 ++++- .../objects/player/PlayerObject.java | 30 ++++++++++++++++++- src/services/housing/HouseTemplate.java | 15 ++++++++++ src/services/housing/HousingService.java | 16 ++++++---- 6 files changed, 66 insertions(+), 9 deletions(-) diff --git a/scripts/houses/player_house_generic_small_style_01.py b/scripts/houses/player_house_generic_small_style_01.py index 95d9f2b4..3b1f0a4c 100644 --- a/scripts/houses/player_house_generic_small_style_01.py +++ b/scripts/houses/player_house_generic_small_style_01.py @@ -9,6 +9,11 @@ def setup(core): houseTemplate.addPlaceablePlanet("tatooine") houseTemplate.addPlaceablePlanet("corellia") houseTemplate.addPlaceablePlanet("naboo") + houseTemplate.addPlaceablePlanet("talus") + houseTemplate.addPlaceablePlanet("rori") + houseTemplate.addPlaceablePlanet("dantooine") + houseTemplate.addPlaceablePlanet("lok") + houseTemplate.setDefaultItemLimit(200) core.housingService.addHousingTemplate(houseTemplate) return \ No newline at end of file diff --git a/src/protocol/swg/CharacterSheetResponseMessage.java b/src/protocol/swg/CharacterSheetResponseMessage.java index 28de844d..70e14124 100644 --- a/src/protocol/swg/CharacterSheetResponseMessage.java +++ b/src/protocol/swg/CharacterSheetResponseMessage.java @@ -99,7 +99,7 @@ public class CharacterSheetResponseMessage extends SWGMessage { buffer.put(getUnicodeString(spouse)); - buffer.putInt(10); // lots remaining + buffer.putInt(creature.getPlayerObject().getLotsRemaining()); // lots remaining return buffer.flip(); } diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 74b2d7f3..da90caec 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -22,7 +22,6 @@ package resources.objects.creature; import java.lang.System; - import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -63,6 +62,7 @@ import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; +import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; @@ -1777,6 +1777,11 @@ public class CreatureObject extends TangibleObject implements IPersistent { return 0L; } + public PlayerObject getPlayerObject() + { + return (PlayerObject) this.getSlottedObject("ghost"); + } + //public float getCooldown(String cooldownGroup) { //return ((float) getCooldown(cooldownGroup) / (float) 1000); //} diff --git a/src/resources/objects/player/PlayerObject.java b/src/resources/objects/player/PlayerObject.java index 9448144d..1a50837d 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -45,7 +45,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=9) +@Persistent(version=10) public class PlayerObject extends IntangibleObject { // PLAY 3 @@ -127,6 +127,8 @@ public class PlayerObject extends IntangibleObject { private String holoEmote; private int holoEmoteUses; + private int lotsRemaining = 10; + @NotPersistent private PlayerMessageBuilder messageBuilder; @@ -822,4 +824,30 @@ public class PlayerObject extends IntangibleObject { public void setRecentContainer(ResourceContainerObject recentContainer) { this.recentContainer = recentContainer; } + + public void setLotsRemaining(int amount) + { + this.lotsRemaining = amount; + } + + public boolean addLots(int amount) + { + this.lotsRemaining += amount; + return true; + } + + public boolean deductLots(int amount) + { + if(this.lotsRemaining - amount > 0) + { + this.lotsRemaining -= amount; + return true; + } + return false; + } + + public int getLotsRemaining() + { + return this.lotsRemaining; + } } diff --git a/src/services/housing/HouseTemplate.java b/src/services/housing/HouseTemplate.java index aaba8d7e..fc2861df 100644 --- a/src/services/housing/HouseTemplate.java +++ b/src/services/housing/HouseTemplate.java @@ -11,6 +11,7 @@ public class HouseTemplate private String deedTemplate; private String buildingTemplate; private int lotCost; + private int defaultItemLimit; private Vector placeablePlanets; private Map buildingSigns; @@ -19,6 +20,7 @@ public class HouseTemplate this.deedTemplate = deedTemplate; this.buildingTemplate = buildingTemplate; this.lotCost = lotCost; + this.defaultItemLimit = 50; this.placeablePlanets = new Vector(); this.buildingSigns = new HashMap(); } @@ -31,6 +33,10 @@ public class HouseTemplate { this.placeablePlanets.add(planetName); } + public void setDefaultItemLimit(int itemLimit) + { + this.defaultItemLimit = itemLimit; + } public String getDeedTemplate() { @@ -48,8 +54,17 @@ public class HouseTemplate { return this.placeablePlanets; } + public boolean canBePlacedOn(String planetName) + { + if(placeablePlanets.contains(planetName)) return true; + else return false; + } public int getLotCost() { return this.lotCost; } + public int getDefaultItemLimit() + { + return this.defaultItemLimit; + } } diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index bbeab9f9..a8f2034b 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -78,16 +78,19 @@ public class HousingService implements INetworkDispatch { int structureLotCost = houseTemplate.getLotCost(); String structureTemplate = houseTemplate.getBuildingTemplate(); - // Lot stuff - if(actor.getAttachment("structureLots") == null) actor.setAttachment("structureLots", 10); // Temporary until better + if(!houseTemplate.canBePlacedOn(actor.getPlanet().getName())) + { + actor.sendSystemMessage("You may not place this structure on this planet.", (byte) 0); // should probably load this from an stf + return; + } - int playerLots = (int) actor.getAttachment("structureLots"); - if(playerLots - structureLotCost < 0) + // Lot stuff + if(actor.getPlayerObject().getLotsRemaining() - structureLotCost < 0) { actor.sendSystemMessage("You do not have enough available lots to place this structure.", (byte) 0); // should probably load this from an stf return; } - actor.setAttachment("structureLots", playerLots - structureLotCost); + actor.getPlayerObject().deductLots(structureLotCost); // Calculate our orientation and height Quaternion quaternion = new Quaternion(1, 0, 0, 0); @@ -101,7 +104,8 @@ public class HousingService implements INetworkDispatch { // Name the sign TangibleObject sign = (TangibleObject) building.getAttachment("structureSign"); - sign.setCustomName2(actor.getCustomName() + "'s House"); + String playerFirstName = actor.getCustomName().split(" ")[0]; + sign.setCustomName2(playerFirstName + "'s House"); //building.add(sign); core.objectService.destroyObject(deed); From bf2422923597c71754f5b2a083ab5fb6827a37c9 Mon Sep 17 00:00:00 2001 From: Seefo Date: Wed, 9 Apr 2014 13:05:36 -0400 Subject: [PATCH 45/68] Added no-build checks when placing structures --- src/services/DevService.java | 2 +- src/services/housing/HousingService.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/services/DevService.java b/src/services/DevService.java index fe8c6e21..30ee710c 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -84,8 +84,8 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 21, "Weapons"); suiOptions.put((long) 22, "Misc Items"); suiOptions.put((long) 23, "Jedi Items"); - //suiOptions.put((long) 120, "House Deeds"); suiOptions.put((long) 110, "Survey Devices"); + //suiOptions.put((long) 120, "House Deeds"); break; case 3: // [Items] Weapons suiOptions.put((long) 30, "Jedi Weapons"); diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index a8f2034b..3bcc9188 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -61,13 +61,19 @@ public class HousingService implements INetworkDispatch { core.commandService.registerCommand("rotatefurniture"); } - public void enterStructureMode(CreatureObject player, TangibleObject deed) + public void enterStructureMode(CreatureObject actor, TangibleObject deed) { + if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, actor.getWorldPosition().x, actor.getWorldPosition().z)) + { + actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf + return; + } + if(housingTemplates.containsKey(deed.getTemplate())) { HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate()); EnterStructurePlacementModeMessage packet = new EnterStructurePlacementModeMessage(deed, houseTemplate.getBuildingTemplate()); - player.getClient().getSession().write(packet.serialize()); + actor.getClient().getSession().write(packet.serialize()); } } @@ -84,6 +90,12 @@ public class HousingService implements INetworkDispatch { return; } + if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, positionX, positionZ)) + { + actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf + return; + } + // Lot stuff if(actor.getPlayerObject().getLotsRemaining() - structureLotCost < 0) { From 118d622c6d0b1a43eaa5b53faaef9347236de5f0 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Wed, 9 Apr 2014 21:16:28 +0200 Subject: [PATCH 46/68] More Junk, Krayt Pearls added The System has been more generalized, but also deals with special cases of Krayt Pearls/Power Crystals. More itemscripts created --- scripts/loot/lootItems/damaged_datapad.py | 20 -- scripts/loot/lootItems/junk/antenna.py | 4 + .../lootItems/junk/armor_repair_device.py | 4 + scripts/loot/lootItems/junk/brain.py | 4 + .../loot/lootItems/junk/chassis_blueprint.py | 4 + scripts/loot/lootItems/junk/comlink.py | 8 + .../loot/lootItems/junk/damaged_datapad.py | 9 + scripts/loot/lootItems/junk/ear_jewel.py | 4 + scripts/loot/lootItems/junk/explosive_dud.py | 4 + scripts/loot/lootItems/junk/eye.py | 4 + scripts/loot/lootItems/junk/gland.py | 8 + scripts/loot/lootItems/junk/heart.py | 4 + .../loot/lootItems/junk/hyperdrive_unit.py | 4 + scripts/loot/lootItems/junk/id_chip.py | 8 + .../loot/lootItems/junk/impulse_detector.py | 4 + scripts/loot/lootItems/junk/laser_trap.py | 4 + scripts/loot/lootItems/junk/launcher_tube.py | 4 + scripts/loot/lootItems/junk/ledger.py | 4 + .../loot/lootItems/junk/magseal_detector.py | 4 + .../loot/lootItems/junk/medical_console.py | 4 + scripts/loot/lootItems/junk/medical_device.py | 4 + scripts/loot/lootItems/junk/motor.py | 4 + .../lootItems/junk/power_output_analyzer.py | 4 + scripts/loot/lootItems/junk/red_wiring.py | 4 + scripts/loot/lootItems/junk/shield_module.py | 4 + .../loot/lootItems/junk/software_module.py | 4 + scripts/loot/lootItems/junk/stomach.py | 4 + scripts/loot/lootItems/junk/survival_gear.py | 4 + .../lootItems/junk/underpowered_survey_pad.py | 4 + .../lootItems/junk/unidentified_serum_vial.py | 4 + scripts/loot/lootItems/junk/used_notebook.py | 4 + .../loot/lootItems/junk/weak_droid_battery.py | 4 + .../lootItems/{ => junk}/worklight_generic.py | 0 scripts/loot/lootItems/kraytpearl_cracked.py | 2 +- scripts/loot/lootItems/kraytpearl_fair.py | 6 +- scripts/loot/lootItems/kraytpearl_flawless.py | 2 +- scripts/loot/lootItems/kraytpearl_good.py | 2 +- scripts/loot/lootItems/kraytpearl_poor.py | 2 +- scripts/loot/lootItems/kraytpearl_premium.py | 2 +- scripts/loot/lootItems/kraytpearl_quality.py | 2 +- .../loot/lootItems/kraytpearl_scratched.py | 2 +- scripts/loot/lootItems/kraytpearl_select.py | 2 +- scripts/loot/lootItems/powercrystal_fair.py | 12 + .../loot/lootItems/powercrystal_flawless.py | 8 + scripts/loot/lootItems/powercrystal_good.py | 8 + scripts/loot/lootItems/powercrystal_poor.py | 8 + .../loot/lootItems/powercrystal_premium.py | 8 + .../loot/lootItems/powercrystal_quality.py | 8 + scripts/loot/lootItems/powercrystal_select.py | 8 + scripts/loot/lootItems/red_wiring.py | 20 -- .../{ => weapons}/shared_rifle_cdef.py | 0 scripts/loot/lootPools/junk.py | 11 +- scripts/object/mobile/krayt_dragon.py | 4 +- scripts/radial/tunable.py | 15 ++ .../objects/loot/LootRollSession.java | 10 + src/services/DevService.java | 6 + src/services/LootService.java | 246 ++++++++++++++---- 57 files changed, 456 insertions(+), 99 deletions(-) delete mode 100644 scripts/loot/lootItems/damaged_datapad.py create mode 100644 scripts/loot/lootItems/junk/antenna.py create mode 100644 scripts/loot/lootItems/junk/armor_repair_device.py create mode 100644 scripts/loot/lootItems/junk/brain.py create mode 100644 scripts/loot/lootItems/junk/chassis_blueprint.py create mode 100644 scripts/loot/lootItems/junk/comlink.py create mode 100644 scripts/loot/lootItems/junk/damaged_datapad.py create mode 100644 scripts/loot/lootItems/junk/ear_jewel.py create mode 100644 scripts/loot/lootItems/junk/explosive_dud.py create mode 100644 scripts/loot/lootItems/junk/eye.py create mode 100644 scripts/loot/lootItems/junk/gland.py create mode 100644 scripts/loot/lootItems/junk/heart.py create mode 100644 scripts/loot/lootItems/junk/hyperdrive_unit.py create mode 100644 scripts/loot/lootItems/junk/id_chip.py create mode 100644 scripts/loot/lootItems/junk/impulse_detector.py create mode 100644 scripts/loot/lootItems/junk/laser_trap.py create mode 100644 scripts/loot/lootItems/junk/launcher_tube.py create mode 100644 scripts/loot/lootItems/junk/ledger.py create mode 100644 scripts/loot/lootItems/junk/magseal_detector.py create mode 100644 scripts/loot/lootItems/junk/medical_console.py create mode 100644 scripts/loot/lootItems/junk/medical_device.py create mode 100644 scripts/loot/lootItems/junk/motor.py create mode 100644 scripts/loot/lootItems/junk/power_output_analyzer.py create mode 100644 scripts/loot/lootItems/junk/red_wiring.py create mode 100644 scripts/loot/lootItems/junk/shield_module.py create mode 100644 scripts/loot/lootItems/junk/software_module.py create mode 100644 scripts/loot/lootItems/junk/stomach.py create mode 100644 scripts/loot/lootItems/junk/survival_gear.py create mode 100644 scripts/loot/lootItems/junk/underpowered_survey_pad.py create mode 100644 scripts/loot/lootItems/junk/unidentified_serum_vial.py create mode 100644 scripts/loot/lootItems/junk/used_notebook.py create mode 100644 scripts/loot/lootItems/junk/weak_droid_battery.py rename scripts/loot/lootItems/{ => junk}/worklight_generic.py (100%) create mode 100644 scripts/loot/lootItems/powercrystal_fair.py create mode 100644 scripts/loot/lootItems/powercrystal_flawless.py create mode 100644 scripts/loot/lootItems/powercrystal_good.py create mode 100644 scripts/loot/lootItems/powercrystal_poor.py create mode 100644 scripts/loot/lootItems/powercrystal_premium.py create mode 100644 scripts/loot/lootItems/powercrystal_quality.py create mode 100644 scripts/loot/lootItems/powercrystal_select.py delete mode 100644 scripts/loot/lootItems/red_wiring.py rename scripts/loot/lootItems/{ => weapons}/shared_rifle_cdef.py (100%) create mode 100644 scripts/radial/tunable.py diff --git a/scripts/loot/lootItems/damaged_datapad.py b/scripts/loot/lootItems/damaged_datapad.py deleted file mode 100644 index 7757a473..00000000 --- a/scripts/loot/lootItems/damaged_datapad.py +++ /dev/null @@ -1,20 +0,0 @@ - -def itemTemplate(): - - return 'object/tangible/loot/misc/shared_damaged_datapad.iff' - -def customItemName(): - - return '' - -def customItemStackCount(): - - return 1 - -def customizationAttributes(): - - return [] - -def customizationValues(): - - return [] \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/antenna.py b/scripts/loot/lootItems/junk/antenna.py new file mode 100644 index 00000000..747de5b7 --- /dev/null +++ b/scripts/loot/lootItems/junk/antenna.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_generic_antennae.iff' diff --git a/scripts/loot/lootItems/junk/armor_repair_device.py b/scripts/loot/lootItems/junk/armor_repair_device.py new file mode 100644 index 00000000..713dc0ce --- /dev/null +++ b/scripts/loot/lootItems/junk/armor_repair_device.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_armor_repair_device_generic.iff' diff --git a/scripts/loot/lootItems/junk/brain.py b/scripts/loot/lootItems/junk/brain.py new file mode 100644 index 00000000..d0e8f837 --- /dev/null +++ b/scripts/loot/lootItems/junk/brain.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_brain_s01.iff' diff --git a/scripts/loot/lootItems/junk/chassis_blueprint.py b/scripts/loot/lootItems/junk/chassis_blueprint.py new file mode 100644 index 00000000..5c2445a8 --- /dev/null +++ b/scripts/loot/lootItems/junk/chassis_blueprint.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/generic_usable/shared_chassis_blueprint_usuable.iff' diff --git a/scripts/loot/lootItems/junk/comlink.py b/scripts/loot/lootItems/junk/comlink.py new file mode 100644 index 00000000..648802c6 --- /dev/null +++ b/scripts/loot/lootItems/junk/comlink.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_comlink_civilian_generic.iff' + +def customItemName(): + + return 'Comlink' \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/damaged_datapad.py b/scripts/loot/lootItems/junk/damaged_datapad.py new file mode 100644 index 00000000..4fc1a9a9 --- /dev/null +++ b/scripts/loot/lootItems/junk/damaged_datapad.py @@ -0,0 +1,9 @@ + +def itemTemplate(): + + return 'object/tangible/loot/misc/shared_damaged_datapad.iff' + +def customItemName(): + + return 'Damaged Datapad' + diff --git a/scripts/loot/lootItems/junk/ear_jewel.py b/scripts/loot/lootItems/junk/ear_jewel.py new file mode 100644 index 00000000..abe14c33 --- /dev/null +++ b/scripts/loot/lootItems/junk/ear_jewel.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return '/object/tangible/loot/npc_loot/shared_jewelry_ear_s02.iff' diff --git a/scripts/loot/lootItems/junk/explosive_dud.py b/scripts/loot/lootItems/junk/explosive_dud.py new file mode 100644 index 00000000..bc7091a7 --- /dev/null +++ b/scripts/loot/lootItems/junk/explosive_dud.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return '/object/tangible/loot/npc_loot/shared_firework_dud_s1.iff' diff --git a/scripts/loot/lootItems/junk/eye.py b/scripts/loot/lootItems/junk/eye.py new file mode 100644 index 00000000..aa7c6cff --- /dev/null +++ b/scripts/loot/lootItems/junk/eye.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_generic_eye.iff' diff --git a/scripts/loot/lootItems/junk/gland.py b/scripts/loot/lootItems/junk/gland.py new file mode 100644 index 00000000..071a60ef --- /dev/null +++ b/scripts/loot/lootItems/junk/gland.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_lungs_gland.iff' + +def customItemName(): + + return 'Gland' \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/heart.py b/scripts/loot/lootItems/junk/heart.py new file mode 100644 index 00000000..3715f029 --- /dev/null +++ b/scripts/loot/lootItems/junk/heart.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_generic_heart.iff' diff --git a/scripts/loot/lootItems/junk/hyperdrive_unit.py b/scripts/loot/lootItems/junk/hyperdrive_unit.py new file mode 100644 index 00000000..25afcd63 --- /dev/null +++ b/scripts/loot/lootItems/junk/hyperdrive_unit.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/miscshared_hyperdrive_part_s01.iff' diff --git a/scripts/loot/lootItems/junk/id_chip.py b/scripts/loot/lootItems/junk/id_chip.py new file mode 100644 index 00000000..e4738035 --- /dev/null +++ b/scripts/loot/lootItems/junk/id_chip.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_id_chip_generic.iff' + +def customItemName(): + + return 'ID Chip' diff --git a/scripts/loot/lootItems/junk/impulse_detector.py b/scripts/loot/lootItems/junk/impulse_detector.py new file mode 100644 index 00000000..17f08a9d --- /dev/null +++ b/scripts/loot/lootItems/junk/impulse_detector.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_impulse_detector_01_generic.iff' diff --git a/scripts/loot/lootItems/junk/laser_trap.py b/scripts/loot/lootItems/junk/laser_trap.py new file mode 100644 index 00000000..4bbcdb48 --- /dev/null +++ b/scripts/loot/lootItems/junk/laser_trap.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_laser_trap_generic.iff' diff --git a/scripts/loot/lootItems/junk/launcher_tube.py b/scripts/loot/lootItems/junk/launcher_tube.py new file mode 100644 index 00000000..5612b566 --- /dev/null +++ b/scripts/loot/lootItems/junk/launcher_tube.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_launcher_tube_generic.iff' diff --git a/scripts/loot/lootItems/junk/ledger.py b/scripts/loot/lootItems/junk/ledger.py new file mode 100644 index 00000000..093e2caf --- /dev/null +++ b/scripts/loot/lootItems/junk/ledger.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_ledger_generic.iff' diff --git a/scripts/loot/lootItems/junk/magseal_detector.py b/scripts/loot/lootItems/junk/magseal_detector.py new file mode 100644 index 00000000..bce0a6c7 --- /dev/null +++ b/scripts/loot/lootItems/junk/magseal_detector.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_magseal_detector_generic.iff' diff --git a/scripts/loot/lootItems/junk/medical_console.py b/scripts/loot/lootItems/junk/medical_console.py new file mode 100644 index 00000000..db82ffa3 --- /dev/null +++ b/scripts/loot/lootItems/junk/medical_console.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_medical_console_generic.iff' diff --git a/scripts/loot/lootItems/junk/medical_device.py b/scripts/loot/lootItems/junk/medical_device.py new file mode 100644 index 00000000..eb55b264 --- /dev/null +++ b/scripts/loot/lootItems/junk/medical_device.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_medical_device_generic.iff' diff --git a/scripts/loot/lootItems/junk/motor.py b/scripts/loot/lootItems/junk/motor.py new file mode 100644 index 00000000..63d2def6 --- /dev/null +++ b/scripts/loot/lootItems/junk/motor.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_small_motor_generic.iff' diff --git a/scripts/loot/lootItems/junk/power_output_analyzer.py b/scripts/loot/lootItems/junk/power_output_analyzer.py new file mode 100644 index 00000000..b44f9808 --- /dev/null +++ b/scripts/loot/lootItems/junk/power_output_analyzer.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_power_output_analyzer_generic.iff' diff --git a/scripts/loot/lootItems/junk/red_wiring.py b/scripts/loot/lootItems/junk/red_wiring.py new file mode 100644 index 00000000..d2f31c46 --- /dev/null +++ b/scripts/loot/lootItems/junk/red_wiring.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_red_wiring_generic.iff' diff --git a/scripts/loot/lootItems/junk/shield_module.py b/scripts/loot/lootItems/junk/shield_module.py new file mode 100644 index 00000000..43335cfa --- /dev/null +++ b/scripts/loot/lootItems/junk/shield_module.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_shield_module_generic.iff' diff --git a/scripts/loot/lootItems/junk/software_module.py b/scripts/loot/lootItems/junk/software_module.py new file mode 100644 index 00000000..8041a85a --- /dev/null +++ b/scripts/loot/lootItems/junk/software_module.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_software_module_generic.iff' diff --git a/scripts/loot/lootItems/junk/stomach.py b/scripts/loot/lootItems/junk/stomach.py new file mode 100644 index 00000000..e3692923 --- /dev/null +++ b/scripts/loot/lootItems/junk/stomach.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_generic_stomach.iff' diff --git a/scripts/loot/lootItems/junk/survival_gear.py b/scripts/loot/lootItems/junk/survival_gear.py new file mode 100644 index 00000000..e8ad23ae --- /dev/null +++ b/scripts/loot/lootItems/junk/survival_gear.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_survival_equipment_generic.iff' diff --git a/scripts/loot/lootItems/junk/underpowered_survey_pad.py b/scripts/loot/lootItems/junk/underpowered_survey_pad.py new file mode 100644 index 00000000..3dca4fa8 --- /dev/null +++ b/scripts/loot/lootItems/junk/underpowered_survey_pad.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_survey_pad_adv_generic.iff' diff --git a/scripts/loot/lootItems/junk/unidentified_serum_vial.py b/scripts/loot/lootItems/junk/unidentified_serum_vial.py new file mode 100644 index 00000000..1f4f8e84 --- /dev/null +++ b/scripts/loot/lootItems/junk/unidentified_serum_vial.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_serum_vial_generic.iff' diff --git a/scripts/loot/lootItems/junk/used_notebook.py b/scripts/loot/lootItems/junk/used_notebook.py new file mode 100644 index 00000000..9a3acb30 --- /dev/null +++ b/scripts/loot/lootItems/junk/used_notebook.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_notebook_generic.iff' diff --git a/scripts/loot/lootItems/junk/weak_droid_battery.py b/scripts/loot/lootItems/junk/weak_droid_battery.py new file mode 100644 index 00000000..5ba36675 --- /dev/null +++ b/scripts/loot/lootItems/junk/weak_droid_battery.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/generic/shared_battery_useable_generic.iff' diff --git a/scripts/loot/lootItems/worklight_generic.py b/scripts/loot/lootItems/junk/worklight_generic.py similarity index 100% rename from scripts/loot/lootItems/worklight_generic.py rename to scripts/loot/lootItems/junk/worklight_generic.py diff --git a/scripts/loot/lootItems/kraytpearl_cracked.py b/scripts/loot/lootItems/kraytpearl_cracked.py index 33536979..8e532580 100644 --- a/scripts/loot/lootItems/kraytpearl_cracked.py +++ b/scripts/loot/lootItems/kraytpearl_cracked.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' def customItemName(): diff --git a/scripts/loot/lootItems/kraytpearl_fair.py b/scripts/loot/lootItems/kraytpearl_fair.py index 33536979..ef8d2dc0 100644 --- a/scripts/loot/lootItems/kraytpearl_fair.py +++ b/scripts/loot/lootItems/kraytpearl_fair.py @@ -1,8 +1,12 @@ def itemTemplate(): - return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' def customItemName(): return '' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_flawless.py b/scripts/loot/lootItems/kraytpearl_flawless.py index 33536979..8e532580 100644 --- a/scripts/loot/lootItems/kraytpearl_flawless.py +++ b/scripts/loot/lootItems/kraytpearl_flawless.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' def customItemName(): diff --git a/scripts/loot/lootItems/kraytpearl_good.py b/scripts/loot/lootItems/kraytpearl_good.py index 33536979..8e532580 100644 --- a/scripts/loot/lootItems/kraytpearl_good.py +++ b/scripts/loot/lootItems/kraytpearl_good.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' def customItemName(): diff --git a/scripts/loot/lootItems/kraytpearl_poor.py b/scripts/loot/lootItems/kraytpearl_poor.py index 33536979..8e532580 100644 --- a/scripts/loot/lootItems/kraytpearl_poor.py +++ b/scripts/loot/lootItems/kraytpearl_poor.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' def customItemName(): diff --git a/scripts/loot/lootItems/kraytpearl_premium.py b/scripts/loot/lootItems/kraytpearl_premium.py index 33536979..8e532580 100644 --- a/scripts/loot/lootItems/kraytpearl_premium.py +++ b/scripts/loot/lootItems/kraytpearl_premium.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' def customItemName(): diff --git a/scripts/loot/lootItems/kraytpearl_quality.py b/scripts/loot/lootItems/kraytpearl_quality.py index 33536979..8e532580 100644 --- a/scripts/loot/lootItems/kraytpearl_quality.py +++ b/scripts/loot/lootItems/kraytpearl_quality.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' def customItemName(): diff --git a/scripts/loot/lootItems/kraytpearl_scratched.py b/scripts/loot/lootItems/kraytpearl_scratched.py index 33536979..8e532580 100644 --- a/scripts/loot/lootItems/kraytpearl_scratched.py +++ b/scripts/loot/lootItems/kraytpearl_scratched.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' def customItemName(): diff --git a/scripts/loot/lootItems/kraytpearl_select.py b/scripts/loot/lootItems/kraytpearl_select.py index 33536979..8e532580 100644 --- a/scripts/loot/lootItems/kraytpearl_select.py +++ b/scripts/loot/lootItems/kraytpearl_select.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' def customItemName(): diff --git a/scripts/loot/lootItems/powercrystal_fair.py b/scripts/loot/lootItems/powercrystal_fair.py new file mode 100644 index 00000000..ef8d2dc0 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_fair.py @@ -0,0 +1,12 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_flawless.py b/scripts/loot/lootItems/powercrystal_flawless.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_flawless.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_good.py b/scripts/loot/lootItems/powercrystal_good.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_good.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_poor.py b/scripts/loot/lootItems/powercrystal_poor.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_poor.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_premium.py b/scripts/loot/lootItems/powercrystal_premium.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_premium.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_quality.py b/scripts/loot/lootItems/powercrystal_quality.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_quality.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_select.py b/scripts/loot/lootItems/powercrystal_select.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_select.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/red_wiring.py b/scripts/loot/lootItems/red_wiring.py deleted file mode 100644 index 483dc8f7..00000000 --- a/scripts/loot/lootItems/red_wiring.py +++ /dev/null @@ -1,20 +0,0 @@ - -def itemTemplate(): - - return 'object/tangible/loot/npc_loot/shared_red_wiring_generic.iff' - -def customItemName(): - - return '' - -def customItemStackCount(): - - return 1 - -def customizationAttributes(): - - return [] - -def customizationValues(): - - return [] diff --git a/scripts/loot/lootItems/shared_rifle_cdef.py b/scripts/loot/lootItems/weapons/shared_rifle_cdef.py similarity index 100% rename from scripts/loot/lootItems/shared_rifle_cdef.py rename to scripts/loot/lootItems/weapons/shared_rifle_cdef.py diff --git a/scripts/loot/lootPools/junk.py b/scripts/loot/lootPools/junk.py index 32ec26c3..ef757825 100644 --- a/scripts/loot/lootPools/junk.py +++ b/scripts/loot/lootPools/junk.py @@ -1,8 +1,15 @@ def itemNames(): - templates=['damaged_datapad','red_wiring','worklight_generic'] + templates=['damaged_datapad','red_wiring','worklight_generic','antenna','brain','eye','gland','heart','stomach','armor_repair_device'] #10 + templates=templates+['brain','chassis_blueprint','comlink','explosive_dud','hyperdrive_unit','id_chip','impulse_detector','laser_trap'] #8 + templates=templates+['launcher_tube','ledger','magseal_detector','medical_console','medical_device','motor','power_output_analyzer','shield_module'] #8 + templates=templates+['software_module','survival_gear','underpowered_survey_pad','unidentified_serum_vial','used_notebook','weak_droid_battery'] #6 return templates def itemChances(): - return [70,50,40] \ No newline at end of file + chances=[3.125,3.125,3.125,3.125,3.125,3.125,3.125,3.125] + chances=chances+[3.125,3.125,3.125,3.125,3.125,3.125,3.125,3.125] + chances=chances+[3.125,3.125,3.125,3.125,3.125,3.125,3.125,3.125] + chances=chances+[3.125,3.125,3.125,3.125,3.125,3.125,3.125,3.125] + return chances #32 \ No newline at end of file diff --git a/scripts/object/mobile/krayt_dragon.py b/scripts/object/mobile/krayt_dragon.py index c65d802c..e023f206 100644 --- a/scripts/object/mobile/krayt_dragon.py +++ b/scripts/object/mobile/krayt_dragon.py @@ -7,9 +7,9 @@ def setup(core, object): lootGroupChance_1 = 65 object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) - lootPoolNames_2 = ['kraytpearl_loq'] + lootPoolNames_2 = ['kraytpearl_lowq'] lootPoolChances_2 = [100] - lootGroupChance_2 = 35 + lootGroupChance_2 = 85 object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) return \ No newline at end of file diff --git a/scripts/radial/tunable.py b/scripts/radial/tunable.py new file mode 100644 index 00000000..f226f86b --- /dev/null +++ b/scripts/radial/tunable.py @@ -0,0 +1,15 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + radials.clear() + radials.add(RadialOptions(0, 7, 0, 'Examine')) + radials.add(RadialOptions(0, 15, 0, 'Destroy')) + radials.add(RadialOptions(0, 19, 0, 'Tune')) + return + +def handleSelection(core, owner, target, option): + if option == 19 and target: + if owner is not None: + owner.sendSystemMessage('You are not attuned enough with the force yet.',1) + return diff --git a/src/resources/objects/loot/LootRollSession.java b/src/resources/objects/loot/LootRollSession.java index 62d12077..cb7c93e4 100644 --- a/src/resources/objects/loot/LootRollSession.java +++ b/src/resources/objects/loot/LootRollSession.java @@ -40,6 +40,7 @@ public class LootRollSession { private GroupObject playerGroup; private List droppedItems; private Planet sessionPlanet; + private List errorMessages; public LootRollSession(){ } @@ -53,6 +54,7 @@ public class LootRollSession { this.SessionID = requester.getCustomName()+"-"+System.currentTimeMillis(); } droppedItems = new ArrayList(); + errorMessages = new ArrayList(); sessionPlanet = requester.getPlanet(); } @@ -79,4 +81,12 @@ public class LootRollSession { public Planet getSessionPlanet() { return sessionPlanet; } + + public List getErrorMessages() { + return errorMessages; + } + + public void addErrorMessage(String errorMessage) { + this.errorMessages.add(errorMessage); + } } diff --git a/src/services/DevService.java b/src/services/DevService.java index ca387de1..dc5b9a29 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -86,6 +86,7 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 23, "Jedi Items"); suiOptions.put((long) 110, "Survey Devices"); suiOptions.put((long) 111, "Spawn Tusken"); + suiOptions.put((long) 112, "Spawn Krayt"); break; case 3: // [Items] Weapons suiOptions.put((long) 30, "Jedi Weapons"); @@ -1001,6 +1002,11 @@ public class DevService implements INetworkDispatch { core.lootService.handleLootRequest(player,(TangibleObject)spawned); break; + case 112: + SWGObject spawned2 = core.staticService.spawnObject("object/mobile/shared_krayt_dragon.iff", "tatooine", 0L, 3512F, 4F, -4801F, 0.70F, 0.71F); + + core.lootService.handleLootRequest(player,(TangibleObject)spawned2); + break; } } }); diff --git a/src/services/LootService.java b/src/services/LootService.java index b16a125d..d405e95d 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -21,11 +21,23 @@ ******************************************************************************/ package services; +import java.io.File; +import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.DirectoryStream.Filter; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributeView; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Vector; + import resources.objects.creature.CreatureObject; import resources.objects.loot.LootGroup; import resources.objects.loot.LootRollSession; @@ -60,7 +72,13 @@ public class LootService implements INetworkDispatch { } public void handleLootRequest(CreatureObject requester, TangibleObject lootedObject) { - + + if (requester.getCustomName().contains("Kun")){ + requester.setCashCredits(requester.getCashCredits()+1); + requester.sendSystemMessage("You looted 1 lousy credit.", (byte)1); + return; + } + LootRollSession lootRollSession = new LootRollSession(requester); String lootedObjectType = "Tangible"; if (lootedObject instanceof CreatureObject) @@ -109,6 +127,14 @@ public class LootService implements INetworkDispatch { // Distribute the loot drops according to group loot rules // For now just spawn items into requester's inventory + + if (lootRollSession.getErrorMessages().size()>0){ + for (String msg : lootRollSession.getErrorMessages()){ + // ToDo: Show this for each group member later! + requester.sendSystemMessage(msg,(byte) 1); + } + } + SWGObject requesterInventory = requester.getSlottedObject("inventory"); for (TangibleObject droppedItem : lootRollSession.getDroppedItems()){ @@ -172,60 +198,92 @@ public class LootService implements INetworkDispatch { } } + private static class DirectoriesFilter implements Filter { + @Override + public boolean accept(Path entry) throws IOException { + return Files.isDirectory(entry); + } + } + private void handleLootPoolItems(String itemName,LootRollSession lootRollSession){ - String path = "scripts/loot/lootItems/"+itemName.toLowerCase(); - System.out.println("path: " + path); - String itemTemplate = (String)core.scriptService.fetchString(path,"itemTemplate"); - String customName = (String)core.scriptService.fetchString(path,"customItemName"); - int stackCount = (Integer)core.scriptService.fetchInteger(path,"customItemStackCount"); - Vector customizationAttributes = (Vector)core.scriptService.fetchStringVector(path,"customizationAttributes"); - Vector customizationValues = (Vector)core.scriptService.fetchIntegerVector(path,"customizationValues"); + List subfolders = new ArrayList(); // Consider all sub-folders + try (DirectoryStream ds = Files.newDirectoryStream(FileSystems.getDefault().getPath("scripts/loot/lootItems/"), new DirectoriesFilter())) { + for (Path p : ds) { + subfolders.add(p.getFileName().toString()); + } + } catch (IOException e) { + lootRollSession.addErrorMessage("File system check caused an error. Please contact Charon about this issue."); + return; + } + + String itemPath = "scripts/loot/lootItems/"+itemName.toLowerCase()+".py"; + File file = new File(itemPath); + if (!file.isFile()){ + for (String subfolderName : subfolders){ + itemPath = "scripts/loot/lootItems/"+ subfolderName +"/"+itemName.toLowerCase()+".py"; + File subfile = new File(itemPath); + if (subfile.isFile()) + break; + } + } + + File checkfile = new File(itemPath); + if (!checkfile.isFile()){ + String errorMessage = "Loot item '" + itemName + "' not found in file system. Please contact Charon about this issue."; + lootRollSession.addErrorMessage(errorMessage); + return; + } + + itemPath = itemPath.substring(0, itemPath.length()-3); // remove the file type + + String customName = ""; + String itemTemplate = ""; + int stackCount = 1; + Vector customizationAttributes = null; + Vector customizationValues = null; + + if(core.scriptService.getMethod(itemPath,"","itemTemplate")==null){ + String errorMessage = "Loot item '" + itemName + "' has no template function assigned in its script. Please contact Charon about this issue."; + lootRollSession.addErrorMessage(errorMessage); + return; + } + + itemTemplate = (String)core.scriptService.fetchString(itemPath,"itemTemplate"); + + // only consider the following variables, if they are in the python-script file + if(core.scriptService.getMethod(itemPath,"","customItemName")!=null) + customName = (String)core.scriptService.fetchString(itemPath,"customItemName"); + + if(core.scriptService.getMethod(itemPath,"","customItemStackCount")!=null) + stackCount = (Integer)core.scriptService.fetchInteger(itemPath,"customItemStackCount"); + + if(core.scriptService.getMethod(itemPath,"","customizationAttributes")!=null) + customizationAttributes = (Vector)core.scriptService.fetchStringVector(itemPath,"customizationAttributes"); + + if(core.scriptService.getMethod(itemPath,"","customizationValues")!=null) + customizationValues = (Vector)core.scriptService.fetchIntegerVector(itemPath,"customizationValues"); System.out.println("itemTemplate " + itemTemplate); - /* - craftingValues = { - {"mindamage",25,35,0}, - {"maxdamage",40,50,0}, - {"attackspeed",1,-1,5}, - {"woundchance",4,8,5}, - {"hitpoints",800,1200,0}, - {"attackhealthcost",0,9,0}, - {"attackactioncost",0,9,0}, - {"attackmindcost",0,9,0}, - {"forcecost",0,9.9,0}, - {"color",31,31,0}, - {"quality",6,6,0}, - }, - */ - - - - - - - - TangibleObject droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet()); - handleCustomDropName(droppedItem); + droppedItem.setAttachment("LootItemName", itemName); + handleCustomDropName(droppedItem,customName); handleStats(droppedItem); setCustomization(droppedItem); + handleSpecialItems(droppedItem); lootRollSession.addDroppedItem(droppedItem); } - - - private void handleCustomDropName(TangibleObject droppedItem) { - String customName = droppedItem.getCustomName(); - - if (customName!=null) { - if (customName.charAt(0) == '@' || customName.contains("_n:")) { - customName = ""; // Look the name up in some tre table - } - } + private void handleCustomDropName(TangibleObject droppedItem,String customName) { +// String customItemName = droppedItem.getCustomName(); +// if (customName.charAt(0) == '@' || customName.contains("_n:")) { +// if (customName!=null) { +// customName = ""; // Look the name up in some tre table +// } +// } droppedItem.setCustomName(customName); } @@ -234,9 +292,7 @@ public class LootService implements INetworkDispatch { System.out.println("droppedItem " + droppedItem); return droppedItem; } - - - + private void setCustomization(TangibleObject droppedItem) { // Example color crystal @@ -253,11 +309,109 @@ public class LootService implements INetworkDispatch { // } } + private void handleSpecialItems(TangibleObject droppedItem) { + if (droppedItem.getTemplate().contains("shared_lightsaber_module_krayt_dragon_pearl")){ + handleKraytPearl(droppedItem); + } + if (droppedItem.getTemplate().contains("shared_lightsaber_module_force_crystal.iff")){ + handlePowerCrystal(droppedItem); + } + } + private void handleStats(TangibleObject droppedItem) { // ToDo: Min,Max for weapons , Dots on weapons etc. // This must be considered for the python scripts as well // So basically every item needs to have loot-related data in their py scripts as well + + + } + + // ************* Special items ************ + private void handleKraytPearl(TangibleObject droppedItem) { + + String itemName = (String)droppedItem.getAttachment("LootItemName"); + String qualityString = ""; + switch (itemName) { + case "kraytpearl_cracked": + droppedItem.setStfFilename("static_item_n"); + droppedItem.setStfName("item_junk_imitation_pearl_01_02"); + droppedItem.setDetailFilename("static_item_d"); + droppedItem.setDetailName("item_junk_imitation_pearl_01_02"); + return; + case "kraytpearl_scratched": + droppedItem.setStfFilename("static_item_n"); + droppedItem.setStfName("item_junk_imitation_pearl_01_01"); + droppedItem.setDetailFilename("static_item_d"); + droppedItem.setDetailName("item_junk_imitation_pearl_01_01"); + return; + case "kraytpearl_poor": + qualityString="Poor"; + break; + case "kraytpearl_fair": + qualityString="Fair"; + break; + case "kraytpearl_good": + qualityString="Good"; + break; + case "kraytpearl_quality": + qualityString="Quality"; + break; + case "kraytpearl_select": + qualityString="Select"; + break; + case "kraytpearl_premium": + qualityString="Premium"; + break; + case "kraytpearl_flawless": + qualityString="Flawless"; + break; + default: + qualityString="Undetermined"; + break; + } + droppedItem.getAttributes().put("@obj_attr_n:condition", "100/100"); + droppedItem.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF "); + droppedItem.getAttributes().put("@obj_attr_n:crystal_quality", qualityString); + droppedItem.setAttachment("radial_filename", "tunable"); } - + private void handlePowerCrystal(TangibleObject droppedItem) { + + String itemName = (String)droppedItem.getAttachment("LootItemName"); + String qualityString = ""; + switch (itemName) { + + case "powercrystal_poor": + qualityString="Poor"; + break; + case "powercrystal_fair": + qualityString="Fair"; + break; + case "powercrystal_good": + qualityString="Good"; + break; + case "powercrystal_quality": + qualityString="Quality"; + break; + case "powercrystal_select": + qualityString="Select"; + break; + case "powercrystal_premium": + qualityString="Premium"; + break; + case "powercrystal_flawless": + qualityString="Flawless"; + break; + case "powercrystal_perfect": + qualityString="Perfect"; + break; + default: + qualityString="Undetermined"; + break; + } + droppedItem.getAttributes().put("@obj_attr_n:condition", "100/100"); + droppedItem.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF "); + droppedItem.getAttributes().put("@obj_attr_n:crystal_quality", qualityString); + droppedItem.setAttachment("radial_filename", "tunable"); + } } From 399cf7a5352c093d96caee3f5defa7779b4e02d3 Mon Sep 17 00:00:00 2001 From: Seefo Date: Wed, 9 Apr 2014 16:32:15 -0400 Subject: [PATCH 47/68] Fixed combat commands and added a better check for combat commands --- src/services/command/CommandService.java | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 5470f7cb..efb0fd84 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -122,7 +122,7 @@ public class CommandService implements INetworkDispatch { break; } - if (actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) { + if (command.getMaxRangeToTarget() != 0 && actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) { return false; } @@ -286,8 +286,11 @@ public class CommandService implements INetworkDispatch { boolean isCombatCommand = false; - if(visitor.getObject(i, 82-sub) instanceof Boolean) - isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); + System.out.println(((String) visitor.getObject(i, 85-sub))); + + if(((String) visitor.getObject(i, 3)).equals("failSpecialAttack") || ((String) visitor.getObject(i, 85-sub)).equals("defaultattack")) + isCombatCommand = true; + if (hasCharacterAbility || isCombatCommand) { CombatCommand command = new CombatCommand(name.toLowerCase()); @@ -347,8 +350,8 @@ public class CommandService implements INetworkDispatch { boolean isCombatCommand = false; - if(visitor.getObject(i, 82-sub) instanceof Boolean) - isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); + if(((String) visitor.getObject(i, 3)).equals("failSpecialAttack") || ((String) visitor.getObject(i, 85-sub)).equals("defaultattack")) + isCombatCommand = true; // "isCombatCommand" needs to be changed so that non-combat commands that are flagged to added to a combat queue are not considered combat commands if (hasCharacterAbility || isCombatCommand) { @@ -373,7 +376,6 @@ public class CommandService implements INetworkDispatch { public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); - if (command instanceof CombatCommand) { processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); } else { @@ -397,12 +399,6 @@ public class CommandService implements INetworkDispatch { { core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "setup", core, attacker, target, command); } - // Temporary fix for certain non-combat commands being registered as combat commands - else if(FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName() + ".py")) - { - core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, attacker, target, commandArgs); - return; - } boolean success = true; From b12e47ad3a7d13b1cc3bcab05ce80a37ed539e9f Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Thu, 10 Apr 2014 00:41:17 +0200 Subject: [PATCH 48/68] merge conflict resolve --- src/main/NGECore.java | 711 ++++++++++++++++++++++++ src/services/DevService.java | 1018 ++++++++++++++++++++++++++++++++++ 2 files changed, 1729 insertions(+) create mode 100644 src/main/NGECore.java create mode 100644 src/services/DevService.java diff --git a/src/main/NGECore.java b/src/main/NGECore.java new file mode 100644 index 00000000..050e213b --- /dev/null +++ b/src/main/NGECore.java @@ -0,0 +1,711 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package main; + +import java.io.IOException; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import org.apache.mina.core.service.IoHandler; +import org.apache.mina.core.session.IoSession; + +import com.sleepycat.je.Transaction; +import com.sleepycat.persist.EntityCursor; + +import protocol.swg.ChatSystemMessage; +import net.engio.mbassy.bus.config.BusConfiguration; +import resources.common.RadialOptions; +import resources.common.ThreadMonitor; +import resources.objects.creature.CreatureObject; +import services.AttributeService; +import services.BuffService; +import services.CharacterService; +import services.ConnectionService; +import services.ConversationService; +import services.DevService; +import services.EntertainmentService; +import services.EquipmentService; +import services.GroupService; +import services.housing.HousingService; +import services.InstanceService; +import services.LoginService; +import services.MissionService; +import services.PlayerService; +import services.ScriptService; +import services.SimulationService; +import services.SkillModService; +import services.SkillService; +import services.StaticService; +import services.SurveyService; +import services.TerrainService; +import services.WeatherService; +import services.ai.AIService; +import services.chat.ChatService; +import services.collections.CollectionService; +import services.combat.CombatService; +import services.command.CombatCommand; +import services.command.CommandService; +import services.gcw.FactionService; +import services.gcw.GCWService; +import services.guild.GuildService; +import services.LoginService; +import services.map.MapService; +import services.object.ObjectService; +import services.object.UpdateService; +import services.resources.ResourceService; +import services.retro.RetroService; +import services.spawn.SpawnService; +import services.sui.SUIService; +import services.trade.TradeService; +import services.travel.TravelService; +import engine.clientdata.ClientFileManager; +import engine.clientdata.visitors.CrcStringTableVisitor; +import engine.clientdata.visitors.DatatableVisitor; +import engine.clientdata.visitors.LevelOfDetailVisitor; +import engine.clientdata.visitors.MeshVisitor; +import engine.clientdata.visitors.PortalVisitor; +import engine.clientdata.visitors.TerrainVisitor; +import engine.clientdata.visitors.WorldSnapshotVisitor; +import engine.clientdata.visitors.WorldSnapshotVisitor.SnapshotChunk; +import engine.clients.Client; +import engine.resources.common.CRC; +import engine.resources.common.PHPBB3Auth; +import engine.resources.config.Config; +import engine.resources.config.DefaultConfig; +import engine.resources.container.Traverser; +import engine.resources.database.DatabaseConnection; +import engine.resources.database.ObjectDatabase; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import engine.resources.service.InteractiveJythonAcceptor; +import engine.resources.service.NetworkDispatch; +import engine.servers.InteractiveJythonServer; +import engine.servers.MINAServer; +import engine.servers.PingServer; + +@SuppressWarnings("unused") + +public class NGECore { + + public static boolean didServerCrash = false; + + private static NGECore instance; + + private Config config = null; + + private volatile boolean isShuttingDown = false; + private long galacticTime = System.currentTimeMillis(); + + private ConcurrentHashMap clients = new ConcurrentHashMap(); + + // Database + + private DatabaseConnection databaseConnection = null; + private DatabaseConnection databaseConnection2 = null; + + // Services + public LoginService loginService; + public RetroService retroService; + public ConnectionService connectionService; + public CommandService commandService; + public CharacterService characterService; + public FactionService factionService; + public ObjectService objectService; + public MapService mapService; + public UpdateService updateService; + public TerrainService terrainService; + public SimulationService simulationService; + public ScriptService scriptService; + public ChatService chatService; + public AttributeService attributeService; + public SUIService suiService; + public GuildService guildService; + public GCWService gcwService; + public TradeService tradeService; + public CombatService combatService; + public PlayerService playerService; + public BuffService buffService; + public StaticService staticService; + public GroupService groupService; + public SkillService skillService; + public SkillModService skillModService; + public EquipmentService equipmentService; + public TravelService travelService; + public CollectionService collectionService; + public EntertainmentService entertainmentService; + public WeatherService weatherService; + public SpawnService spawnService; + public AIService aiService; + //public MissionService missionService; + public InstanceService instanceService; + public DevService devService; + + public SurveyService surveyService; + public ResourceService resourceService; + + public ConversationService conversationService; + + public HousingService housingService; + + + // Login Server + public NetworkDispatch loginDispatch; + private MINAServer loginServer; + + // Zone Server + public NetworkDispatch zoneDispatch; + private MINAServer zoneServer; + + // Interactive Jython Console + public InteractiveJythonAcceptor jythonAcceptor; + private InteractiveJythonServer jythonServer; + + private ObjectDatabase creatureODB; + private ObjectDatabase mailODB; + private ObjectDatabase guildODB; + private ObjectDatabase objectIdODB; + private ObjectDatabase duplicateIdODB; + private ObjectDatabase chatRoomODB; + + private BusConfiguration eventBusConfig = BusConfiguration.Default(1, new ThreadPoolExecutor(1, 4, 1, TimeUnit.MINUTES, new LinkedBlockingQueue())); + + private ObjectDatabase buildingODB; + + private ObjectDatabase resourcesODB; + private ObjectDatabase resourceRootsODB; + private ObjectDatabase resourceHistoryODB; + + public static boolean PACKET_DEBUG = false; + + + + + + public NGECore() { + + } + + public void start() { + + instance = this; + final ThreadMonitor deadlockDetector = new ThreadMonitor(); + Thread deadlockMonitor = new Thread(new Runnable() { + @Override + public void run() { + try { + deadlockDetector.findDeadlock(); + Thread.sleep(60000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + deadlockMonitor.start(); + config = new Config(); + config.setFilePath("nge.cfg"); + if (!(config.loadConfigFile())) { + config = DefaultConfig.getConfig(); + } + // Database + databaseConnection = new DatabaseConnection(); + databaseConnection.connect(config.getString("DB.URL"), config.getString("DB.NAME"), config.getString("DB.USER"), config.getString("DB.PASS"), "postgresql"); + + String db2Url = config.getString("DB2.URL"); + if (db2Url == null || db2Url.matches("^\\s*$")) { + databaseConnection2 = null; + } else { + databaseConnection2 = new DatabaseConnection(); + databaseConnection2.connect(config.getString("DB2.URL"), config.getString("DB2.NAME"), config.getString("DB2.USER"), config.getString("DB2.PASS"), "mysql"); + } + + setGalaxyStatus(1); + creatureODB = new ObjectDatabase("creature", true, false, true); + buildingODB = new ObjectDatabase("building", true, false, true); + mailODB = new ObjectDatabase("mails", true, false, true); + guildODB = new ObjectDatabase("guild", true, false, true); + objectIdODB = new ObjectDatabase("oids", true, false, false); + duplicateIdODB = new ObjectDatabase("doids", true, false, true); + chatRoomODB = new ObjectDatabase("chatRooms", true, false, true); + resourcesODB = new ObjectDatabase("resources", true, false, true); + resourceRootsODB = new ObjectDatabase("resourceroots", true, false, true); + resourceHistoryODB = new ObjectDatabase("resourcehistory", true, false, true); + + // Services + loginService = new LoginService(this); + retroService = new RetroService(this); + connectionService = new ConnectionService(this); + characterService = new CharacterService(this); + mapService = new MapService(this); + travelService = new TravelService(this); + + factionService = new FactionService(this); + objectService = new ObjectService(this); + terrainService = new TerrainService(this); + updateService = new UpdateService(this); + scriptService = new ScriptService(this); + commandService = new CommandService(this); + chatService = new ChatService(this); + attributeService = new AttributeService(this); + suiService = new SUIService(this); + combatService = new CombatService(this); + playerService = new PlayerService(this); + buffService = new BuffService(this); + groupService = new GroupService(this); + skillService = new SkillService(this); + skillModService = new SkillModService(this); + equipmentService = new EquipmentService(this); + entertainmentService = new EntertainmentService(this); + devService = new DevService(this); + conversationService = new ConversationService(this); + housingService = new HousingService(this); + + if (config.keyExists("JYTHONCONSOLE.PORT")) { + int jythonPort = config.getInt("JYTHONCONSOLE.PORT"); + if (jythonPort > 0) { + + System.out.println("Starting InteractiveJythonServer on Port " + jythonPort); + jythonAcceptor = new InteractiveJythonAcceptor(); + jythonServer = new InteractiveJythonServer((IoHandler) jythonAcceptor, jythonPort, this); + jythonAcceptor.setServer(jythonServer); + jythonServer.start(); + } + } + spawnService = new SpawnService(this); + aiService = new AIService(this); + //missionService = new MissionService(this); + + if (config.getInt("LOAD.RESOURCE.SYSTEM") == 1) { + surveyService = new SurveyService(this); + resourceService = new ResourceService(this); + } + + // Ping Server + try { + PingServer pingServer = new PingServer(config.getInt("PING.PORT")); + pingServer.bind(); + } catch (IOException e) { + e.printStackTrace(); + } + + // Login Server + loginDispatch = new NetworkDispatch(this, false); + loginDispatch.addService(loginService); + + loginServer = new MINAServer(loginDispatch, config.getInt("LOGIN.PORT")); + loginServer.start(); + + // Zone Server + zoneDispatch = new NetworkDispatch(this, true); + zoneDispatch.addService(retroService); + zoneDispatch.addService(connectionService); + zoneDispatch.addService(characterService); + zoneDispatch.addService(factionService); + zoneDispatch.addService(objectService); + zoneDispatch.addService(commandService); + zoneDispatch.addService(chatService); + zoneDispatch.addService(suiService); + zoneDispatch.addService(mapService); + zoneDispatch.addService(travelService); + zoneDispatch.addService(playerService); + zoneDispatch.addService(buffService); + zoneDispatch.addService(entertainmentService); + //zoneDispatch.addService(missionService); + + zoneServer = new MINAServer(zoneDispatch, config.getInt("ZONE.PORT")); + zoneServer.start(); + staticService = new StaticService(this); + //Start terrainList + // Original Planets + terrainService.addPlanet(1, "tatooine", "terrain/tatooine.trn", true); + terrainService.addPlanet(2, "naboo", "terrain/naboo.trn", true); + terrainService.addPlanet(3, "corellia", "terrain/corellia.trn", true); + terrainService.addPlanet(4, "rori", "terrain/rori.trn", true); + terrainService.addPlanet(5, "lok", "terrain/lok.trn", true); + terrainService.addPlanet(6, "dantooine", "terrain/dantooine.trn", true); + terrainService.addPlanet(7, "talus", "terrain/talus.trn", true); + terrainService.addPlanet(8, "yavin4", "terrain/yavin4.trn", true); + terrainService.addPlanet(9, "endor", "terrain/endor.trn", true); + terrainService.addPlanet(10, "dathomir", "terrain/dathomir.trn", true); + terrainService.addPlanet(11, "mustafar", "terrain/mustafar.trn", true); + terrainService.addPlanet(12, "kashyyyk_main", "terrain/kashyyyk_main.trn", true); + //Dungeon Terrains + // TODO: Fix BufferUnderFlow Errors on loaded of dungeon instances. + /*terrainService.addPlanet(13, "kashyyyk_dead_forest", "terrain/kashyyyk_dead_forest.trn", true); + terrainService.addPlanet(14, "kashyyyk_hunting", "terrain/kashyyyk_hunting.trn", true); + terrainService.addPlanet(15, "kashyyyk_north_dungeons", "terrain/kashyyyk_north_dungeons.trn", true); + terrainService.addPlanet(16, "kashyyyk_rryatt_trail", "terrain/kashyyyk_rryatt_trail.trn", true); + terrainService.addPlanet(17, "kashyyyk_south_dungeons", "terrain/kashyyyk_south_dungeons.trn", true);*/ + terrainService.addPlanet(18, "adventure1", "terrain/adventure1.trn", true); + terrainService.addPlanet(19, "adventure2", "terrain/adventure2.trn", true); + terrainService.addPlanet(20, "dungeon1", "terrain/dungeon1.trn", true); + //Space Zones + // NOTE: Commented out for now until space is implemented. No need to be loaded into memory when space is not implemented. + /*terrainService.addPlanet(21, "space_corellia", "terrain/space_corellia.trn", true); + terrainService.addPlanet(22, "space_corellia_2", "terrain/space_corellia_2.trn", true); + terrainService.addPlanet(23, "space_dantooine", "terrain/space_dantooine.trn", true); + terrainService.addPlanet(24, "space_dathomir", "terrain/space_dathomir.trn", true); + terrainService.addPlanet(25, "space_endor", "terrain/space_endor.trn", true); + terrainService.addPlanet(26, "space_env", "terrain/space_env.trn", true); + terrainService.addPlanet(27, "space_halos", "terrain/space_halos.trn", true); + terrainService.addPlanet(28, "space_heavy1", "terrain/space_heavy1.trn", true); + terrainService.addPlanet(29, "space_kashyyyk", "terrain/space_kashyyyk.trn", true); + terrainService.addPlanet(30, "space_light1", "terrain/space_light1.trn", true); + terrainService.addPlanet(31, "space_lok", "terrain/space_lok.trn", true); + terrainService.addPlanet(32, "space_naboo", "terrain/space_naboo.trn", true); + terrainService.addPlanet(33, "space_naboo_2", "terrain/space_naboo_2.trn", true); + terrainService.addPlanet(34, "space_nova_orion", "terrain/space_nova_orion.trn", true); + terrainService.addPlanet(35, "space_npe_falcon", "terrain/space_npe_falcon.trn", true); // TODO: New Player Tutorial + terrainService.addPlanet(36, "space_npe_falcon_2", "terrain/space_npe_falcon_2.trn", true); // TODO: New Player Tutorial + terrainService.addPlanet(37, "space_ord_mantell", "terrain/space_ord_mantell.trn", true); + terrainService.addPlanet(38, "space_ord_mantell_2", "terrain/space_ord_mantell_2.trn", true); + terrainService.addPlanet(39, "space_ord_mantell_3", "terrain/space_ord_mantell_3.trn", true); + terrainService.addPlanet(40, "space_ord_mantell_4", "terrain/space_ord_mantell_4.trn", true); + terrainService.addPlanet(41, "space_ord_mantell_5", "terrain/space_ord_mantell_5.trn", true); + terrainService.addPlanet(42, "space_ord_mantell_6", "terrain/space_ord_mantell_6.trn", true); + terrainService.addPlanet(43, "space_tatooine", "terrain/space_tatooine.trn", true); + terrainService.addPlanet(44, "space_tatooine_2", "terrain/space_tatooine_2.trn", true); + terrainService.addPlanet(45, "space_yavin4", "terrain/space_yavin4.trn", true);*/ + //PSWG New Content Terrains (WARNING Keep commented out unless you have the current build of kaas!) + + //terrainService.addPlanet(46, "kaas", "terrain/kaas.trn", true); + + //end terrainList + spawnService = new SpawnService(this); + terrainService.loadClientPois(); + // Travel Points + travelService.loadTravelPoints(); + simulationService = new SimulationService(this); + + objectService.loadBuildings(); + + if (config.getInt("LOAD.RESOURCE.SYSTEM") == 1) { + objectService.loadResourceRoots(); + objectService.loadResources(); + } + + terrainService.loadSnapShotObjects(); + objectService.loadServerTemplates(); + simulationService.insertSnapShotObjects(); + simulationService.insertPersistentBuildings(); + // Zone services that need to be loaded after the above + zoneDispatch.addService(simulationService); + + + // Static Spawns + staticService.spawnStatics(); + + guildService = new GuildService(this); + zoneDispatch.addService(guildService); + + gcwService = new GCWService(this); + zoneDispatch.addService(gcwService); + + collectionService = new CollectionService(this); + zoneDispatch.addService(collectionService); + + tradeService = new TradeService(this); + zoneDispatch.addService(tradeService); + + zoneDispatch.addService(skillService); + + instanceService = new InstanceService(this); + zoneDispatch.addService(instanceService); + + //travelService.startShuttleSchedule(); + + weatherService = new WeatherService(this); + weatherService.loadPlanetSettings(); + + spawnService.loadMobileTemplates(); + spawnService.loadLairTemplates(); + spawnService.loadLairGroups(); + spawnService.loadSpawnAreas(); + + housingService.loadHousingTemplates(); + equipmentService.loadBonusSets(); + + retroService.run(); + + didServerCrash = false; + System.out.println("Started Server."); + cleanupCreatureODB(); + setGalaxyStatus(2); + + } + + private void cleanupCreatureODB() { + EntityCursor cursor = creatureODB.getCursor(Long.class, CreatureObject.class); + + Iterator it = cursor.iterator(); + List deletedObjects = new ArrayList(); + + while(it.hasNext()) { + CreatureObject creature = it.next(); + if(!characterService.playerExists(creature.getObjectID())) + deletedObjects.add(creature); + } + + cursor.close(); + + Transaction txn = creatureODB.getEnvironment().beginTransaction(null, null); + for(CreatureObject creature : deletedObjects) { + creatureODB.delete(creature.getObjectID(), Long.class, CreatureObject.class, txn); + } + txn.commitSync(); + System.out.println("Deleted " + deletedObjects.size() + " creatures."); + } + + public void stop() { + System.out.println("Stopping Servers and Connections."); + databaseConnection.close(); + databaseConnection2.close(); + } + + public void cleanUp() { + System.out.println("Cleaning Up..."); + long memoryUsed = Runtime.getRuntime().freeMemory(); + System.out.println("Using " + memoryUsed + " bytes of memory."); + + config = null; + databaseConnection = null; + databaseConnection2 = null; + Runtime.getRuntime().gc(); + System.out.println("Cleaned Up " + (Runtime.getRuntime().freeMemory() - memoryUsed) + " bytes of memory."); + } + + public void restart() { + stop(); + cleanUp(); + try { + Thread.sleep(30000); + } catch (InterruptedException e) { + + } + start(); + } + + public static void main(String[] args) { + + NGECore core = new NGECore(); + + core.start(); + + do { + if (didServerCrash) { + core.restart(); + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + + } + } while (true); + + } + + public void setGalaxyStatus(int statusId) { + + int galaxyId = config.getInt("GALAXY_ID"); + + try { + PreparedStatement ps = databaseConnection.preparedStatement("UPDATE \"connectionServers\" SET \"statusId\"=? WHERE \"galaxyId\"=?"); + ps.setInt(1, statusId); + ps.setInt(2, galaxyId); + ps.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } + + } + + /* + * ---------- Getter methods for NGECore ---------- + */ + public Config getConfig() { + return config; + } + + public String getGalaxyName() { + return config.getString("GALAXY_NAME"); + } + + public DatabaseConnection getDatabase1() { + return databaseConnection; + } + + public DatabaseConnection getDatabase2() { + return databaseConnection2; + } + + public ObjectDatabase getCreatureODB() { + return creatureODB; + } + + public ObjectDatabase getMailODB() { + return mailODB; + } + + public ObjectDatabase getGuildODB() { + return guildODB; + } + + public ObjectDatabase getBuildingODB() { + return buildingODB; + } + + public ObjectDatabase getObjectIdODB() { + return objectIdODB; + } + + public ObjectDatabase getDuplicateIdODB() { + return duplicateIdODB; + } + + public ObjectDatabase getChatRoomODB() { + return chatRoomODB; + } + + public ObjectDatabase getResourcesODB() { + return resourcesODB; + } + + public ObjectDatabase getResourceRootsODB() { + return resourceRootsODB; + } + + public ObjectDatabase getResourceHistoryODB() { + return resourceHistoryODB; + } + + + public int getActiveClients() { + int connections = 0; + for (Map.Entry c : clients.entrySet()) { + if(c.getValue().getSession() != null) { + if (c.getValue().getSession().isConnected()) { + connections++; + } + } + } + return connections; + } + + public int getActiveZoneClients() { + int connections = 0; + for (Map.Entry c : clients.entrySet()) { + if(c.getValue().getSession() != null) { + if (c.getValue().getSession().isConnected() && c.getValue().getParent() != null) { + connections++; + } + } + } + return connections; + } + + + public Client getClient(IoSession session) { + return clients.get(session); + } + + public ConcurrentHashMap getActiveConnectionsMap() { + return clients; + } + + /* + * --------------- Other methods for services --------------- + */ + public void addClient(IoSession session, Client client) { + clients.put(session, client); + } + + public void removeClient(IoSession session) { + clients.remove(session); + } + + // for python scripts + public Thread getCurrentThread() { + return Thread.currentThread(); + } + + public static NGECore getInstance() { + return instance; + } + + public BusConfiguration getEventBusConfig() { + return eventBusConfig; + } + + public void initiateShutdown() { + if(isShuttingDown) + return; + try { + + for(int minutes = 15; minutes > 1; minutes--) { + simulationService.notifyAllClients(new ChatSystemMessage("The server will be shutting down soon. Please find a safe place to logout. (" + minutes + " minutes left)", (byte) 0 ).serialize()); + Thread.sleep(60000); + } + setGalaxyStatus(3); + simulationService.notifyAllClients(new ChatSystemMessage("The server will be shutting down soon. Please find a safe place to logout. (" + 1 + " minutes left)", (byte) 0 ).serialize()); + Thread.sleep(30000); + simulationService.notifyAllClients(new ChatSystemMessage("You will be disconnected in 30 seconds so the server can perform a final save before shutting down. Please find a safe place to logout now.", (byte) 0 ).serialize()); + Thread.sleep(20000); + simulationService.notifyAllClients(new ChatSystemMessage("You will be disconnected in 10 seconds so the server can perform a final save before shutting down. Please find a safe place to logout now.", (byte) 0 ).serialize()); + Thread.sleep(10000); + simulationService.notifyAllClients(new ChatSystemMessage("You will now be disconnected so the server can perform a final save before shutting down.", (byte) 0 ).serialize()); + + synchronized(getActiveConnectionsMap()) { + for(Client client : getActiveConnectionsMap().values()) { + client.getSession().close(true); + connectionService.disconnect(client); + } + } + + System.exit(0); + + } catch (InterruptedException e) { + e.printStackTrace(); + } + + + + } + + public long getGalacticTime() { + return System.currentTimeMillis() - galacticTime; + } + + +} + diff --git a/src/services/DevService.java b/src/services/DevService.java new file mode 100644 index 00000000..30ee710c --- /dev/null +++ b/src/services/DevService.java @@ -0,0 +1,1018 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services; + +import java.nio.ByteOrder; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Vector; + +import org.apache.mina.core.buffer.IoBuffer; +import org.apache.mina.core.session.IoSession; + +import protocol.swg.ExpertiseRequestMessage; +import resources.common.Console; +import resources.common.FileUtilities; +import resources.common.Opcodes; +import resources.common.SpawnPoint; +import resources.objects.building.BuildingObject; +import resources.objects.creature.CreatureObject; +import resources.objects.player.PlayerObject; +import resources.objects.tangible.TangibleObject; +import resources.objects.tool.SurveyTool; +import services.sui.SUIWindow; +import services.sui.SUIService.ListBoxType; +import services.sui.SUIWindow.SUICallback; +import services.sui.SUIWindow.Trigger; +import main.NGECore; +import engine.clientdata.ClientFileManager; +import engine.clientdata.visitors.DatatableVisitor; +import engine.clients.Client; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; + +@SuppressWarnings("unused") +public class DevService implements INetworkDispatch { + + private NGECore core; + + public DevService(NGECore core) { + this.core = core; + } + + public void sendCharacterBuilderSUI(CreatureObject creature, int childMenu) + { + Map suiOptions = new HashMap(); + + switch(childMenu) + { + case 0: // Root + suiOptions.put((long) 1, "Character"); + suiOptions.put((long) 2, "Items"); + break; + case 1: // Character + suiOptions.put((long) 10, "Set combat level to 90"); + suiOptions.put((long) 11, "Give 100,000 credits"); + suiOptions.put((long) 12, "Reset expertise"); + break; + case 2: // Items + suiOptions.put((long) 20, "Armor"); + suiOptions.put((long) 21, "Weapons"); + suiOptions.put((long) 22, "Misc Items"); + suiOptions.put((long) 23, "Jedi Items"); + suiOptions.put((long) 110, "Survey Devices"); + //suiOptions.put((long) 120, "House Deeds"); + break; + case 3: // [Items] Weapons + suiOptions.put((long) 30, "Jedi Weapons"); + suiOptions.put((long) 31, "Melee Weapons"); + suiOptions.put((long) 32, "Ranged Weapons"); + break; + case 4: // [Items] Misc Items + suiOptions.put((long) 40, "Unity Ring"); + suiOptions.put((long) 41, "Tusken Rucksack"); + suiOptions.put((long) 42, "Heroism Jewlery Set"); + break; + case 5: // [Items] Armor + suiOptions.put((long) 50, "Assault Armor"); + suiOptions.put((long) 51, "Battle Armor"); + suiOptions.put((long) 52, "Reconnaissance Armor"); + break; + case 6: // [Items] Assault Armor + suiOptions.put((long) 60, "Composite"); + suiOptions.put((long) 61, "Ithorian Sentinel"); + suiOptions.put((long) 62, "Kashyyykian Hunting"); + break; + case 7: // [Items] Battle Armor + suiOptions.put((long) 70, "Bone"); + suiOptions.put((long) 71, "Ithorian Defender"); + suiOptions.put((long) 72, "Kashyyykian Black Mountain"); + break; + case 8: // [Items] Reconnaissance Armor + suiOptions.put((long) 80, "Marauder"); + suiOptions.put((long) 81, "Ithorian Guardian"); + suiOptions.put((long) 82, "Kashyyykian Ceremonial"); + break; + case 9: // [Items] Jedi Items + suiOptions.put((long) 90, "(Light) Jedi Robe"); + suiOptions.put((long) 91, "(Dark) Jedi Robe"); + suiOptions.put((long) 92, "Belt of Master Bodo Baas"); + break; + + } + + final SUIWindow window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "Character Builder Terminal", "Select the desired option and click OK.", suiOptions, creature, null, 10); + Vector returnList = new Vector(); + + returnList.add("List.lstList:SelectedRow"); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() + { + public void process(SWGObject owner, int eventType, Vector returnList) + { + int index = Integer.parseInt(returnList.get(0)); + int childIndex = (int) window.getObjectIdByIndex(index); + + CreatureObject player = (CreatureObject) owner; + SWGObject inventory = player.getSlottedObject("inventory"); + Planet planet = player.getPlanet(); + + switch(childIndex) + { + // Root + case 1: // Character + sendCharacterBuilderSUI(player, 1); + return; + case 2: // Items + sendCharacterBuilderSUI(player, 2); + return; + + // Character + case 10: // Set combat level to 90 + core.playerService.grantLevel(player, 90); // Commented out until fixed + //core.playerService.giveExperience(player, 999999999); + return; + case 11: // Give 100,000 credits + player.setCashCredits(player.getCashCredits() + 100000); + return; + case 12: // Reset expertise + // Seefo->Light: I commented out the below line because it gave us an error and didn't properly remove the skill, could you try the method SWGList.reverseGet that I added? + //player.getSkills().get().stream().filter(s -> s.contains("expertise")).forEach(s -> core.skillService.removeSkill(creature, s)); + + // Using this for now + for(int i = creature.getSkills().size() - 1; i >= 0; i-- ) + { + String skill = creature.getSkills().get(i); + if(skill.contains("expertise")) core.skillService.removeSkill(player, skill); + } + return; + + // Items + case 20: // Armor + sendCharacterBuilderSUI(player, 5); + return; + case 21: // Weapons + sendCharacterBuilderSUI(player, 3); + return; + case 22: // Misc Items + sendCharacterBuilderSUI(player, 4); + return; + case 23: // Jedi Items + sendCharacterBuilderSUI(player, 9); + return; + case 25: // Tools + sendCharacterBuilderSUI(player, 15); + return; + + // [Items] Weapons + case 30: // Jedi Weapons + TangibleObject lightsaber1 = (TangibleObject) core.objectService.createObject("object/weapon/melee/sword/crafted_saber/shared_sword_lightsaber_one_handed_gen5.iff", planet); + lightsaber1.setIntAttribute("required_combat_level", 90); + lightsaber1.setFloatAttribute("cat_wpn_damage.wpn_attack_speed", 1); + lightsaber1.setStringAttribute("class_required", "Jedi"); + lightsaber1.setStringAttribute("cat_wpn_damage.wpn_damage_type", "Energy"); + lightsaber1.setStringAttribute("cat_wpn_damage.damage", "689-1379"); + + TangibleObject lightsaber2 = (TangibleObject) core.objectService.createObject("object/weapon/melee/2h_sword/crafted_saber/shared_sword_lightsaber_two_handed_gen5.iff", planet); + lightsaber2.setIntAttribute("required_combat_level", 90); + lightsaber2.setFloatAttribute("cat_wpn_damage.wpn_attack_speed", 1); + lightsaber2.setStringAttribute("class_required", "Jedi"); + lightsaber2.setStringAttribute("cat_wpn_damage.wpn_damage_type", "Energy"); + lightsaber2.setStringAttribute("cat_wpn_damage.damage", "689-1379"); + + TangibleObject lightsaber3 = (TangibleObject) core.objectService.createObject("object/weapon/melee/polearm/crafted_saber/shared_sword_lightsaber_polearm_gen5.iff", planet); + lightsaber3.setIntAttribute("required_combat_level", 90); + lightsaber3.setFloatAttribute("cat_wpn_damage.wpn_attack_speed", 1); + lightsaber3.setStringAttribute("class_required", "Jedi"); + lightsaber3.setStringAttribute("cat_wpn_damage.wpn_damage_type", "Energy"); + lightsaber3.setStringAttribute("cat_wpn_damage.damage", "689-1379"); + + Random random = new Random(); + + lightsaber1.setCustomizationVariable("/private/index_color_blade", (byte) random.nextInt(47)); + lightsaber2.setCustomizationVariable("/private/index_color_blade", (byte) random.nextInt(47)); + lightsaber3.setCustomizationVariable("/private/index_color_blade", (byte) random.nextInt(47)); + + inventory.add(lightsaber1); + inventory.add(lightsaber2); + inventory.add(lightsaber3); + return; + case 31: // Melee Weapons + SWGObject sword1 = core.objectService.createObject("object/weapon/melee/sword/shared_sword_01.iff", planet); + sword1.setIntAttribute("required_combat_level", 90); + sword1.setFloatAttribute("cat_wpn_damage.wpn_attack_speed", 1); + sword1.setStringAttribute("class_required", "None"); + sword1.setStringAttribute("cat_wpn_damage.wpn_damage_type", "Energy"); + sword1.setStringAttribute("cat_wpn_damage.damage", "1100-1200"); + + inventory.add(sword1); + return; + case 32: // Ranged Weapons + SWGObject rifle1 = core.objectService.createObject("object/weapon/ranged/rifle/shared_rifle_e11.iff", planet); + rifle1.setIntAttribute("required_combat_level", 90); + rifle1.setFloatAttribute("cat_wpn_damage.wpn_attack_speed", (float) 0.8); + rifle1.setStringAttribute("class_required", "None"); + rifle1.setStringAttribute("cat_wpn_damage.wpn_damage_type", "Energy"); + rifle1.setStringAttribute("cat_wpn_damage.damage", "800-1250"); + + inventory.add(rifle1); + + SWGObject pistol = core.objectService.createObject("object/weapon/ranged/pistol/shared_pistol_cdef.iff", planet); + pistol.setIntAttribute("required_combat_level", 90); + pistol.setFloatAttribute("cat_wpn_damage.wpn_attack_speed", (float) 0.4); + pistol.setStringAttribute("class_required", "None"); + pistol.setStringAttribute("cat_wpn_damage.wpn_damage_type", "Energy"); + pistol.setStringAttribute("cat_wpn_damage.damage", "400-559"); + + inventory.add(pistol); + + /* == Disabled until Elemental Damage is implemented. == + SWGObject heavy = core.objectService.createObject("object/weapon/ranged/heavy/shared_som_lava_cannon_generic.iff", planet); + heavy.setIntAttribute("required_combat_level", 90); + heavy.setFloatAttribute("cat_wpn_damage.wpn_attack_speed", 1); + heavy.setStringAttribute("class_required", "Commando"); + heavy.setStringAttribute("cat_wpn_damage.wpn_damage_type", "Energy"); + heavy.setStringAttribute("cat_wpn_damage.damage", "700-1400"); + + inventory.add(heavy);*/ + return; + case 40: + TangibleObject ring = (TangibleObject) core.objectService.createObject("object/tangible/wearables/ring/shared_ring_s01.iff", planet); + ring.setCustomName("Unity Ring"); + inventory.add(ring); + case 41: + TangibleObject backpack = (TangibleObject) core.objectService.createObject("object/tangible/wearables/backpack/shared_backpack_krayt_skull.iff", planet); + backpack.setIntAttribute("cat_stat_mod_bonus.@stat_n:agility_modified", 25); + backpack.setIntAttribute("cat_stat_mod_bonus.@stat_n:constitution_modified", 30); + backpack.setIntAttribute("cat_stat_mod_bonus.@stat_n:luck_modified", 25); + backpack.setIntAttribute("cat_stat_mod_bonus.@stat_n:precision_modified", 35); + backpack.setIntAttribute("cat_stat_mod_bonus.@stat_n:stamina_modified", 30); + backpack.setIntAttribute("cat_stat_mod_bonus.@stat_n:strength_modified", 35); + inventory.add(backpack); + return; + case 42: + TangibleObject heroismBand = (TangibleObject) core.objectService.createObject("object/tangible/wearables/ring/shared_ring_s01.iff", planet); + heroismBand.setStfFilename("static_item_n"); + heroismBand.setStfName("item_band_set_hero_01_01"); + heroismBand.setStringAttribute("@set_bonus:piece_bonus_count_3", "@set_bonus:set_bonus_hero_1"); + heroismBand.setStringAttribute("@set_bonus:piece_bonus_count_4", "@set_bonus:set_bonus_hero_2"); + heroismBand.setStringAttribute("@set_bonus:piece_bonus_count_5", "@set_bonus:set_bonus_hero_3"); + heroismBand.setAttachment("setBonus", "set_bonus_hero"); + + TangibleObject heroismRing = (TangibleObject) core.objectService.createObject("object/tangible/wearables/ring/shared_ring_s01.iff", planet); + heroismRing.setStfFilename("static_item_n"); + heroismRing.setStfName("item_ring_set_hero_01_01"); + heroismRing.setStringAttribute("@set_bonus:piece_bonus_count_3", "@set_bonus:set_bonus_hero_1"); + heroismRing.setStringAttribute("@set_bonus:piece_bonus_count_4", "@set_bonus:set_bonus_hero_2"); + heroismRing.setStringAttribute("@set_bonus:piece_bonus_count_5", "@set_bonus:set_bonus_hero_3"); + heroismRing.setAttachment("setBonus", "set_bonus_hero"); + + TangibleObject heroismNecklace = (TangibleObject) core.objectService.createObject("object/tangible/wearables/necklace/shared_necklace_s01.iff", planet); + heroismNecklace.setStfFilename("static_item_n"); + heroismNecklace.setStfName("item_necklace_set_hero_01_01"); + heroismNecklace.setStringAttribute("@set_bonus:piece_bonus_count_3", "@set_bonus:set_bonus_hero_1"); + heroismNecklace.setStringAttribute("@set_bonus:piece_bonus_count_4", "@set_bonus:set_bonus_hero_2"); + heroismNecklace.setStringAttribute("@set_bonus:piece_bonus_count_5", "@set_bonus:set_bonus_hero_3"); + heroismNecklace.setAttachment("setBonus", "set_bonus_hero"); + + TangibleObject heroismBraceletRight = (TangibleObject) core.objectService.createObject("object/tangible/wearables/bracelet/shared_bracelet_s02_r.iff", planet); + heroismBraceletRight.setStfFilename("static_item_n"); + heroismBraceletRight.setStfName("item_bracelet_r_set_hero_01_01"); + heroismBraceletRight.setStringAttribute("@set_bonus:piece_bonus_count_3", "@set_bonus:set_bonus_hero_1"); + heroismBraceletRight.setStringAttribute("@set_bonus:piece_bonus_count_4", "@set_bonus:set_bonus_hero_2"); + heroismBraceletRight.setStringAttribute("@set_bonus:piece_bonus_count_5", "@set_bonus:set_bonus_hero_3"); + heroismBraceletRight.setAttachment("setBonus", "set_bonus_hero"); + + TangibleObject heroismBraceletLeft = (TangibleObject) core.objectService.createObject("object/tangible/wearables/bracelet/shared_bracelet_s02_l.iff", planet); + heroismBraceletLeft.setStfFilename("static_item_n"); + heroismBraceletLeft.setStfName("item_bracelet_l_set_hero_01_01"); + heroismBraceletLeft.setStringAttribute("@set_bonus:piece_bonus_count_3", "@set_bonus:set_bonus_hero_1"); + heroismBraceletLeft.setStringAttribute("@set_bonus:piece_bonus_count_4", "@set_bonus:set_bonus_hero_2"); + heroismBraceletLeft.setStringAttribute("@set_bonus:piece_bonus_count_5", "@set_bonus:set_bonus_hero_3"); + heroismBraceletLeft.setAttachment("setBonus", "set_bonus_hero"); + + inventory.add(heroismBand); + inventory.add(heroismRing); + inventory.add(heroismNecklace); + inventory.add(heroismBraceletRight); + inventory.add(heroismBraceletLeft); + return; + case 50: // [Items] Assault Armor + sendCharacterBuilderSUI(player, 6); + return; + case 51: // [Items] Battle Armor + sendCharacterBuilderSUI(player, 7); + return; + case 52: // [Items] Reconnaissance Armor + sendCharacterBuilderSUI(player, 8); + return; + case 60: // Composite Armor + SWGObject comp_bicep_r = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_bicep_r.iff", planet); + comp_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + comp_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + comp_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + comp_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + comp_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + comp_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject comp_bicep_l = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_bicep_l.iff", planet); + comp_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + comp_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + comp_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + comp_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + comp_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + comp_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject comp_bracer_r = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_bracer_r.iff", planet); + comp_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + comp_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + comp_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + comp_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + comp_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + comp_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject comp_bracer_l = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_bracer_l.iff", planet); + comp_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + comp_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + comp_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + comp_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + comp_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + comp_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject comp_leggings = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_leggings.iff", planet); + comp_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + comp_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + comp_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + comp_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + comp_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + comp_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject comp_helmet = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_helmet.iff", planet); + comp_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + comp_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + comp_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + comp_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + comp_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + comp_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject comp_chest = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_chest_plate.iff", planet); + comp_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + comp_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + comp_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + comp_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + comp_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + comp_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject comp_boots = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_boots.iff", planet); + SWGObject comp_gloves = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_gloves.iff", planet); + + + + inventory.add(comp_bicep_r); + inventory.add(comp_bicep_l); + inventory.add(comp_bracer_r); + inventory.add(comp_bracer_l); + inventory.add(comp_leggings); + inventory.add(comp_helmet); + inventory.add(comp_chest); + inventory.add(comp_boots); + inventory.add(comp_gloves); + + + return; + case 61: // Ithorian Sentinel + SWGObject sent_bicep_r = core.objectService.createObject("object/tangible/wearables/armor/ithorian_sentinel/shared_ith_armor_s03_bicep_r.iff", planet); + sent_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + sent_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + sent_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + sent_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + sent_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + sent_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject sent_bicep_l = core.objectService.createObject("object/tangible/wearables/armor/ithorian_sentinel/shared_ith_armor_s03_bicep_l.iff", planet); + sent_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + sent_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + sent_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + sent_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + sent_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + sent_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject sent_bracer_r = core.objectService.createObject("object/tangible/wearables/armor/ithorian_sentinel/shared_ith_armor_s03_bracer_r.iff", planet); + sent_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + sent_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + sent_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + sent_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + sent_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + sent_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject sent_bracer_l = core.objectService.createObject("object/tangible/wearables/armor/ithorian_sentinel/shared_ith_armor_s03_bracer_l.iff", planet); + sent_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + sent_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + sent_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + sent_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + sent_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + sent_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject sent_leggings = core.objectService.createObject("object/tangible/wearables/armor/ithorian_sentinel/shared_ith_armor_s03_leggings.iff", planet); + sent_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + sent_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + sent_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + sent_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + sent_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + sent_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject sent_helmet = core.objectService.createObject("object/tangible/wearables/armor/ithorian_sentinel/shared_ith_armor_s03_helmet.iff", planet); + sent_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + sent_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + sent_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + sent_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + sent_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + sent_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject sent_chest = core.objectService.createObject("object/tangible/wearables/armor/ithorian_sentinel/shared_ith_armor_s03_chest_plate.iff", planet); + sent_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + sent_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + sent_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + sent_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + sent_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + sent_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject sent_boots = core.objectService.createObject("object/tangible/wearables/armor/ithorian_sentinel/shared_ith_armor_s03_boots.iff", planet); + SWGObject sent_gloves = core.objectService.createObject("object/tangible/wearables/armor/ithorian_sentinel/shared_ith_armor_s03_gloves.iff", planet); + + + + inventory.add(sent_bicep_r); + inventory.add(sent_bicep_l); + inventory.add(sent_bracer_r); + inventory.add(sent_bracer_l); + inventory.add(sent_leggings); + inventory.add(sent_helmet); + inventory.add(sent_chest); + inventory.add(sent_boots); + inventory.add(sent_gloves); + + + return; + case 62: // Kashyyykian Hunting + SWGObject hunt_bicep_r = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_hunting/shared_armor_kashyyykian_hunting_bicep_r.iff", planet); + hunt_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + hunt_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + hunt_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + hunt_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + hunt_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + hunt_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject hunt_bicep_l = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_hunting/shared_armor_kashyyykian_hunting_bicep_l.iff", planet); + hunt_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + hunt_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + hunt_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + hunt_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + hunt_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + hunt_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject hunt_bracer_r = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_hunting/shared_armor_kashyyykian_hunting_bracer_r.iff", planet); + hunt_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + hunt_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + hunt_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + hunt_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + hunt_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + hunt_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject hunt_bracer_l = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_hunting/shared_armor_kashyyykian_hunting_bracer_l.iff", planet); + hunt_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + hunt_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + hunt_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + hunt_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + hunt_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + hunt_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject hunt_leggings = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_hunting/shared_armor_kashyyykian_hunting_leggings.iff", planet); + hunt_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + hunt_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + hunt_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + hunt_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + hunt_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + hunt_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject hunt_chest = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_hunting/shared_armor_kashyyykian_hunting_chestplate.iff", planet); + hunt_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000); + hunt_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000); + hunt_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + hunt_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + hunt_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + hunt_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + + + inventory.add(hunt_bicep_r); + inventory.add(hunt_bicep_l); + inventory.add(hunt_bracer_r); + inventory.add(hunt_bracer_l); + inventory.add(hunt_leggings); + inventory.add(hunt_chest); + + + return; + case 70: // Bone Armor + SWGObject bone_bicep_r = core.objectService.createObject("object/tangible/wearables/armor/bone/shared_armor_bone_s01_bicep_r.iff", planet); + bone_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + bone_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + bone_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + bone_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + bone_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + bone_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject bone_bicep_l = core.objectService.createObject("object/tangible/wearables/armor/bone/shared_armor_bone_s01_bicep_l.iff", planet); + bone_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + bone_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + bone_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + bone_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + bone_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + bone_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject bone_bracer_r = core.objectService.createObject("object/tangible/wearables/armor/bone/shared_armor_bone_s01_bracer_r.iff", planet); + bone_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + bone_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + bone_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + bone_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + bone_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + bone_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject bone_bracer_l = core.objectService.createObject("object/tangible/wearables/armor/bone/shared_armor_bone_s01_bracer_l.iff", planet); + bone_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + bone_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + bone_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + bone_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + bone_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + bone_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject bone_leggings = core.objectService.createObject("object/tangible/wearables/armor/bone/shared_armor_bone_s01_leggings.iff", planet); + bone_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + bone_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + bone_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + bone_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + bone_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + bone_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject bone_helmet = core.objectService.createObject("object/tangible/wearables/armor/bone/shared_armor_bone_s01_helmet.iff", planet); + bone_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + bone_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + bone_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + bone_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + bone_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + bone_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject bone_chest = core.objectService.createObject("object/tangible/wearables/armor/bone/shared_armor_bone_s01_chest_plate.iff", planet); + bone_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + bone_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + bone_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + bone_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + bone_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + bone_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject bone_boots = core.objectService.createObject("object/tangible/wearables/armor/bone/shared_armor_bone_s01_boots.iff", planet); + SWGObject bone_gloves = core.objectService.createObject("object/tangible/wearables/armor/bone/shared_armor_bone_s01_gloves.iff", planet); + + + + inventory.add(bone_bicep_r); + inventory.add(bone_bicep_l); + inventory.add(bone_bracer_r); + inventory.add(bone_bracer_l); + inventory.add(bone_leggings); + inventory.add(bone_helmet); + inventory.add(bone_chest); + inventory.add(bone_boots); + inventory.add(bone_gloves); + + + return; + case 71: // Ithorian Defender + SWGObject def_bicep_r = core.objectService.createObject("object/tangible/wearables/armor/ithorian_defender/shared_ith_armor_s01_bicep_r.iff", planet); + def_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + def_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + def_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + def_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + def_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + def_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject def_bicep_l = core.objectService.createObject("object/tangible/wearables/armor/ithorian_defender/shared_ith_armor_s01_bicep_l.iff", planet); + def_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + def_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + def_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + def_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + def_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + def_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject def_bracer_r = core.objectService.createObject("object/tangible/wearables/armor/ithorian_defender/shared_ith_armor_s01_bracer_r.iff", planet); + def_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + def_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + def_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + def_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + def_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + def_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject def_bracer_l = core.objectService.createObject("object/tangible/wearables/armor/ithorian_defender/shared_ith_armor_s01_bracer_l.iff", planet); + def_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + def_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + def_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + def_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + def_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + def_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject def_leggings = core.objectService.createObject("object/tangible/wearables/armor/ithorian_defender/shared_ith_armor_s01_leggings.iff", planet); + def_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + def_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + def_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + def_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + def_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + def_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject def_helmet = core.objectService.createObject("object/tangible/wearables/armor/ithorian_defender/shared_ith_armor_s01_helmet.iff", planet); + def_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + def_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + def_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + def_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + def_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + def_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject def_chest = core.objectService.createObject("object/tangible/wearables/armor/ithorian_defender/shared_ith_armor_s01_chest_plate.iff", planet); + def_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + def_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + def_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + def_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + def_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + def_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject def_boots = core.objectService.createObject("object/tangible/wearables/armor/ithorian_defender/shared_ith_armor_s01_boots.iff", planet); + SWGObject def_gloves = core.objectService.createObject("object/tangible/wearables/armor/ithorian_defender/shared_ith_armor_s01_gloves.iff", planet); + + + + inventory.add(def_bicep_r); + inventory.add(def_bicep_l); + inventory.add(def_bracer_r); + inventory.add(def_bracer_l); + inventory.add(def_leggings); + inventory.add(def_helmet); + inventory.add(def_chest); + inventory.add(def_boots); + inventory.add(def_gloves); + + + return; + case 72: // Kashyyykian Black Mountain + SWGObject moun_bicep_r = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_black_mtn/shared_armor_kashyyykian_black_mtn_bicep_r.iff", planet); + moun_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + moun_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + moun_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + moun_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + moun_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + moun_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject moun_bicep_l = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_black_mtn/shared_armor_kashyyykian_black_mtn_bicep_l.iff", planet); + moun_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + moun_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + moun_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + moun_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + moun_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + moun_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject moun_bracer_r = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_black_mtn/shared_armor_kashyyykian_black_mtn_bracer_r.iff", planet); + moun_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + moun_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + moun_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + moun_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + moun_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + moun_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject moun_bracer_l = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_black_mtn/shared_armor_kashyyykian_black_mtn_bracer_l.iff", planet); + moun_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + moun_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + moun_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + moun_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + moun_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + moun_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject moun_leggings = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_black_mtn/shared_armor_kashyyykian_black_mtn_leggings.iff", planet); + moun_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + moun_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + moun_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + moun_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + moun_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + moun_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject moun_chest = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_black_mtn/shared_armor_kashyyykian_black_mtn_chestplate.iff", planet); + moun_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000); + moun_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 6000); + moun_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + moun_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + moun_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + moun_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + + + inventory.add(moun_bicep_r); + inventory.add(moun_bicep_l); + inventory.add(moun_bracer_r); + inventory.add(moun_bracer_l); + inventory.add(moun_leggings); + inventory.add(moun_chest); + + + return; + case 80: // Marauder Armor + SWGObject mar_bicep_r = core.objectService.createObject("object/tangible/wearables/armor/marauder/shared_armor_marauder_s02_bicep_r.iff", planet); + mar_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + mar_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + mar_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + mar_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + mar_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + mar_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject mar_bicep_l = core.objectService.createObject("object/tangible/wearables/armor/marauder/shared_armor_marauder_s02_bicep_l.iff", planet); + mar_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + mar_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + mar_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + mar_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + mar_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + mar_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject mar_bracer_r = core.objectService.createObject("object/tangible/wearables/armor/marauder/shared_armor_marauder_s02_bracer_r.iff", planet); + mar_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + mar_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + mar_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + mar_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + mar_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + mar_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject mar_bracer_l = core.objectService.createObject("object/tangible/wearables/armor/marauder/shared_armor_marauder_s02_bracer_l.iff", planet); + mar_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + mar_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + mar_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + mar_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + mar_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + mar_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject mar_leggings = core.objectService.createObject("object/tangible/wearables/armor/marauder/shared_armor_marauder_s02_leggings.iff", planet); + mar_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + mar_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + mar_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + mar_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + mar_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + mar_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject mar_helmet = core.objectService.createObject("object/tangible/wearables/armor/marauder/shared_armor_marauder_s02_helmet.iff", planet); + mar_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + mar_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + mar_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + mar_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + mar_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + mar_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject mar_chest = core.objectService.createObject("object/tangible/wearables/armor/marauder/shared_armor_marauder_s02_chest_plate.iff", planet); + mar_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + mar_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + mar_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + mar_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + mar_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + mar_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject mar_boots = core.objectService.createObject("object/tangible/wearables/armor/marauder/shared_armor_marauder_s02_boots.iff", planet); + SWGObject mar_gloves = core.objectService.createObject("object/tangible/wearables/armor/marauder/shared_armor_marauder_s02_gloves.iff", planet); + + + + inventory.add(mar_bicep_r); + inventory.add(mar_bicep_l); + inventory.add(mar_bracer_r); + inventory.add(mar_bracer_l); + inventory.add(mar_leggings); + inventory.add(mar_helmet); + inventory.add(mar_chest); + inventory.add(mar_boots); + inventory.add(mar_gloves); + + + return; + case 81: // Ithorian Guardian + SWGObject gau_bicep_r = core.objectService.createObject("object/tangible/wearables/armor/ithorian_guardian/shared_ith_armor_s02_bicep_r.iff", planet); + gau_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + gau_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + gau_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + gau_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + gau_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + gau_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject gau_bicep_l = core.objectService.createObject("object/tangible/wearables/armor/ithorian_guardian/shared_ith_armor_s02_bicep_l.iff", planet); + gau_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + gau_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + gau_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + gau_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + gau_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + gau_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject gau_bracer_r = core.objectService.createObject("object/tangible/wearables/armor/ithorian_guardian/shared_ith_armor_s02_bracer_r.iff", planet); + gau_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + gau_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + gau_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + gau_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + gau_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + gau_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject gau_bracer_l = core.objectService.createObject("object/tangible/wearables/armor/ithorian_guardian/shared_ith_armor_s02_bracer_l.iff", planet); + gau_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + gau_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + gau_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + gau_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + gau_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + gau_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject gau_leggings = core.objectService.createObject("object/tangible/wearables/armor/ithorian_guardian/shared_ith_armor_s02_leggings.iff", planet); + gau_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + gau_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + gau_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + gau_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + gau_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + gau_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject gau_helmet = core.objectService.createObject("object/tangible/wearables/armor/ithorian_guardian/shared_ith_armor_s02_helmet.iff", planet); + gau_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + gau_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + gau_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + gau_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + gau_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + gau_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject gau_chest = core.objectService.createObject("object/tangible/wearables/armor/ithorian_guardian/shared_ith_armor_s02_chest_plate.iff", planet); + gau_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + gau_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + gau_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + gau_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + gau_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + gau_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject gau_boots = core.objectService.createObject("object/tangible/wearables/armor/ithorian_guardian/shared_ith_armor_s02_boots.iff", planet); + SWGObject gau_gloves = core.objectService.createObject("object/tangible/wearables/armor/ithorian_guardian/shared_ith_armor_s02_gloves.iff", planet); + + + + inventory.add(gau_bicep_r); + inventory.add(gau_bicep_l); + inventory.add(gau_bracer_r); + inventory.add(gau_bracer_l); + inventory.add(gau_leggings); + inventory.add(gau_helmet); + inventory.add(gau_chest); + inventory.add(gau_boots); + inventory.add(gau_gloves); + + + return; + case 82: // Kashyyykian Ceremonial + SWGObject cer_bicep_r = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_ceremonial/shared_armor_kashyyykian_ceremonial_bicep_r.iff", planet); + cer_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + cer_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + cer_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + cer_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + cer_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + cer_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject cer_bicep_l = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_ceremonial/shared_armor_kashyyykian_ceremonial_bicep_l.iff", planet); + cer_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + cer_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + cer_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + cer_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + cer_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + cer_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject cer_bracer_r = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_ceremonial/shared_armor_kashyyykian_ceremonial_bracer_r.iff", planet); + cer_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + cer_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + cer_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + cer_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + cer_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + cer_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject cer_bracer_l = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_ceremonial/shared_armor_kashyyykian_ceremonial_bracer_l.iff", planet); + cer_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + cer_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + cer_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + cer_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + cer_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + cer_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject cer_leggings = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_ceremonial/shared_armor_kashyyykian_ceremonial_leggings.iff", planet); + cer_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + cer_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + cer_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + cer_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + cer_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + cer_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + SWGObject cer_chest = core.objectService.createObject("object/tangible/wearables/armor/kashyyykian_ceremonial/shared_armor_kashyyykian_ceremonial_chestplate.iff", planet); + cer_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 5000); + cer_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 7000); + cer_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000); + cer_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000); + cer_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000); + cer_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000); + + + + inventory.add(cer_bicep_r); + inventory.add(cer_bicep_l); + inventory.add(cer_bracer_r); + inventory.add(cer_bracer_l); + inventory.add(cer_leggings); + inventory.add(cer_chest); + + return; + + case 90: // (Light) Jedi Robe + inventory.add(core.objectService.createObject("object/tangible/wearables/robe/shared_robe_jedi_light_s03.iff", planet)); + return; + case 91: // (Dark) Jedi Robe + inventory.add(core.objectService.createObject("object/tangible/wearables/robe/shared_robe_jedi_dark_s03.iff", planet)); + return; + case 92: // Belt of Master Bodo Baas + inventory.add(core.objectService.createObject("object/tangible/wearables/backpack/shared_fannypack_s01.iff", planet)); + return; + case 110: + SurveyTool mineralSurveyTool = (SurveyTool) core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_mineral.iff", planet); + mineralSurveyTool.setCustomName("Mineral Survey Device"); + inventory.add(mineralSurveyTool); + + SurveyTool chemicalSurveyTool = (SurveyTool) core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_inorganic.iff", planet); + chemicalSurveyTool.setCustomName("Chemical Survey Device"); + inventory.add(chemicalSurveyTool); + + SurveyTool floraSurveyTool = (SurveyTool) core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_lumber.iff", planet); + floraSurveyTool.setCustomName("Flora Survey Device"); + inventory.add(floraSurveyTool); + + SurveyTool gasSurveyTool = (SurveyTool) core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_gas.iff", planet); + gasSurveyTool.setCustomName("Gas Survey Device"); + inventory.add(gasSurveyTool); + + SurveyTool waterSurveyTool = (SurveyTool) core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_moisture.iff", planet); + waterSurveyTool.setCustomName("Water Survey Device"); + inventory.add(waterSurveyTool); + + SurveyTool windSurveyTool = (SurveyTool) core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_wind.iff", planet); + windSurveyTool.setCustomName("Wind Survey Device"); + inventory.add(windSurveyTool); + + SurveyTool solarSurveyTool = (SurveyTool) core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_solar.iff", planet); + solarSurveyTool.setCustomName("Solar Survey Device"); + inventory.add(solarSurveyTool); + return; + + case 120: + SWGObject houseDeed = core.objectService.createObject("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", planet); + inventory.add(houseDeed); + return; + } + } + }); + + core.suiService.openSUIWindow(window); + } + + @Override + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + } + + + @Override + public void shutdown() { + + } + +} + From d776b52292d822e748aa16d87572fd0389236be5 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Thu, 10 Apr 2014 00:46:38 +0200 Subject: [PATCH 49/68] restored loot NGECore and Devservice --- src/main/NGECore.java | 3 +++ src/services/DevService.java | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 050e213b..ab271d74 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -60,6 +60,7 @@ import services.GroupService; import services.housing.HousingService; import services.InstanceService; import services.LoginService; +import services.LootService; import services.MissionService; import services.PlayerService; import services.ScriptService; @@ -178,6 +179,7 @@ public class NGECore { public ConversationService conversationService; public HousingService housingService; + public LootService lootService; // Login Server @@ -290,6 +292,7 @@ public class NGECore { devService = new DevService(this); conversationService = new ConversationService(this); housingService = new HousingService(this); + lootService = new LootService(this); if (config.keyExists("JYTHONCONSOLE.PORT")) { int jythonPort = config.getInt("JYTHONCONSOLE.PORT"); diff --git a/src/services/DevService.java b/src/services/DevService.java index 30ee710c..3b303a8a 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -86,6 +86,8 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 23, "Jedi Items"); suiOptions.put((long) 110, "Survey Devices"); //suiOptions.put((long) 120, "House Deeds"); + suiOptions.put((long) 111, "Spawn Tusken"); + suiOptions.put((long) 112, "Spawn Krayt"); break; case 3: // [Items] Weapons suiOptions.put((long) 30, "Jedi Weapons"); @@ -993,6 +995,17 @@ public class DevService implements INetworkDispatch { inventory.add(solarSurveyTool); return; + case 111: + SWGObject spawned = core.staticService.spawnObject("object/mobile/shared_tusken_raider.iff", "tatooine", 0L, 3522F, 4F, -4801F, 0.70F, 0.71F); + + core.lootService.handleLootRequest(player,(TangibleObject)spawned); + break; + case 112: + SWGObject spawned2 = core.staticService.spawnObject("object/mobile/shared_krayt_dragon.iff", "tatooine", 0L, 3512F, 4F, -4801F, 0.70F, 0.71F); + + core.lootService.handleLootRequest(player,(TangibleObject)spawned2); + break; + case 120: SWGObject houseDeed = core.objectService.createObject("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", planet); inventory.add(houseDeed); From 931404bf3f0de69a44373f1f772c9f98c6d7c5d4 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Wed, 9 Apr 2014 18:49:27 -0400 Subject: [PATCH 50/68] Organized chat packets, disabled chat channels temporarily --- src/main/NGECore.java | 2 +- src/protocol/swg/SWGMessageFactory.java | 1 + .../swg/{ => chat}/ChatCreateRoom.java | 4 +- .../ChatDeletePersistentMessage.java | 4 +- .../swg/{ => chat}/ChatEnterRoomById.java | 4 +- .../swg/{ => chat}/ChatFriendsListUpdate.java | 4 +- .../ChatInstantMessageToCharacter.java | 4 +- .../ChatInstantMessagetoClient.java | 4 +- .../swg/{ => chat}/ChatOnAddFriend.java | 4 +- .../{ => chat}/ChatOnChangeFriendStatus.java | 3 +- .../swg/chat/ChatOnConnectAvatar.java | 48 ++++++++ .../swg/{ => chat}/ChatOnCreateRoom.java | 3 +- .../swg/{ => chat}/ChatOnEnteredRoom.java | 3 +- .../swg/{ => chat}/ChatOnGetFriendsList.java | 3 +- .../{ => chat}/ChatOnSendInstantMessage.java | 4 +- .../ChatOnSendPersistentMessage.java | 4 +- .../swg/{ => chat}/ChatOnSendRoomMessage.java | 4 +- .../ChatPersistentMessageToClient.java | 5 +- .../ChatPersistentMessageToServer.java | 5 +- .../swg/chat/ChatQueryRoomResults.java | 113 ++++++++++++++++++ .../ChatRequestPersistentMessage.java | 4 +- src/protocol/swg/{ => chat}/ChatRoomList.java | 10 +- .../swg/{ => chat}/ChatRoomMessage.java | 4 +- .../swg/{ => chat}/ChatSendToRoom.java | 4 +- src/protocol/swg/chat/ChatServerStatus.java | 44 +++++++ .../swg/{ => chat}/ChatSystemMessage.java | 3 +- .../objects/creature/CreatureObject.java | 2 +- src/services/SimulationService.java | 6 +- src/services/chat/ChatRoom.java | 13 -- src/services/chat/ChatService.java | 75 +++++++----- src/services/object/ObjectService.java | 18 ++- 31 files changed, 334 insertions(+), 75 deletions(-) rename src/protocol/swg/{ => chat}/ChatCreateRoom.java (97%) rename src/protocol/swg/{ => chat}/ChatDeletePersistentMessage.java (96%) rename src/protocol/swg/{ => chat}/ChatEnterRoomById.java (96%) rename src/protocol/swg/{ => chat}/ChatFriendsListUpdate.java (94%) rename src/protocol/swg/{ => chat}/ChatInstantMessageToCharacter.java (98%) rename src/protocol/swg/{ => chat}/ChatInstantMessagetoClient.java (97%) rename src/protocol/swg/{ => chat}/ChatOnAddFriend.java (96%) rename src/protocol/swg/{ => chat}/ChatOnChangeFriendStatus.java (97%) create mode 100644 src/protocol/swg/chat/ChatOnConnectAvatar.java rename src/protocol/swg/{ => chat}/ChatOnCreateRoom.java (97%) rename src/protocol/swg/{ => chat}/ChatOnEnteredRoom.java (97%) rename src/protocol/swg/{ => chat}/ChatOnGetFriendsList.java (95%) rename src/protocol/swg/{ => chat}/ChatOnSendInstantMessage.java (96%) rename src/protocol/swg/{ => chat}/ChatOnSendPersistentMessage.java (96%) rename src/protocol/swg/{ => chat}/ChatOnSendRoomMessage.java (96%) rename src/protocol/swg/{ => chat}/ChatPersistentMessageToClient.java (98%) rename src/protocol/swg/{ => chat}/ChatPersistentMessageToServer.java (98%) create mode 100644 src/protocol/swg/chat/ChatQueryRoomResults.java rename src/protocol/swg/{ => chat}/ChatRequestPersistentMessage.java (96%) rename src/protocol/swg/{ => chat}/ChatRoomList.java (90%) rename src/protocol/swg/{ => chat}/ChatRoomMessage.java (97%) rename src/protocol/swg/{ => chat}/ChatSendToRoom.java (96%) create mode 100644 src/protocol/swg/chat/ChatServerStatus.java rename src/protocol/swg/{ => chat}/ChatSystemMessage.java (98%) diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 050e213b..7676a83a 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -43,7 +43,7 @@ import org.apache.mina.core.session.IoSession; import com.sleepycat.je.Transaction; import com.sleepycat.persist.EntityCursor; -import protocol.swg.ChatSystemMessage; +import protocol.swg.chat.ChatSystemMessage; import net.engio.mbassy.bus.config.BusConfiguration; import resources.common.RadialOptions; import resources.common.ThreadMonitor; diff --git a/src/protocol/swg/SWGMessageFactory.java b/src/protocol/swg/SWGMessageFactory.java index fc5bd8c3..640b019e 100644 --- a/src/protocol/swg/SWGMessageFactory.java +++ b/src/protocol/swg/SWGMessageFactory.java @@ -24,6 +24,7 @@ package protocol.swg; import java.nio.ByteBuffer; import protocol.Message; +import protocol.swg.chat.ChatInstantMessageToCharacter; public class SWGMessageFactory { diff --git a/src/protocol/swg/ChatCreateRoom.java b/src/protocol/swg/chat/ChatCreateRoom.java similarity index 97% rename from src/protocol/swg/ChatCreateRoom.java rename to src/protocol/swg/chat/ChatCreateRoom.java index 640cba0e..841c1614 100644 --- a/src/protocol/swg/ChatCreateRoom.java +++ b/src/protocol/swg/chat/ChatCreateRoom.java @@ -19,10 +19,12 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatCreateRoom extends SWGMessage { diff --git a/src/protocol/swg/ChatDeletePersistentMessage.java b/src/protocol/swg/chat/ChatDeletePersistentMessage.java similarity index 96% rename from src/protocol/swg/ChatDeletePersistentMessage.java rename to src/protocol/swg/chat/ChatDeletePersistentMessage.java index 1e812255..3f0d1b70 100644 --- a/src/protocol/swg/ChatDeletePersistentMessage.java +++ b/src/protocol/swg/chat/ChatDeletePersistentMessage.java @@ -19,10 +19,12 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatDeletePersistentMessage extends SWGMessage { diff --git a/src/protocol/swg/ChatEnterRoomById.java b/src/protocol/swg/chat/ChatEnterRoomById.java similarity index 96% rename from src/protocol/swg/ChatEnterRoomById.java rename to src/protocol/swg/chat/ChatEnterRoomById.java index a5b2d4c3..15e9bb0c 100644 --- a/src/protocol/swg/ChatEnterRoomById.java +++ b/src/protocol/swg/chat/ChatEnterRoomById.java @@ -19,10 +19,11 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import resources.common.StringUtilities; public class ChatEnterRoomById extends SWGMessage { @@ -34,7 +35,6 @@ public class ChatEnterRoomById extends SWGMessage { @Override public void deserialize(IoBuffer data) { - StringUtilities.printBytes(data.array()); data.getShort(); data.getInt(); diff --git a/src/protocol/swg/ChatFriendsListUpdate.java b/src/protocol/swg/chat/ChatFriendsListUpdate.java similarity index 94% rename from src/protocol/swg/ChatFriendsListUpdate.java rename to src/protocol/swg/chat/ChatFriendsListUpdate.java index 962b2ad2..f3a17a34 100644 --- a/src/protocol/swg/ChatFriendsListUpdate.java +++ b/src/protocol/swg/chat/ChatFriendsListUpdate.java @@ -1,4 +1,4 @@ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; @@ -6,6 +6,8 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatFriendsListUpdate extends SWGMessage { private String friendName; diff --git a/src/protocol/swg/ChatInstantMessageToCharacter.java b/src/protocol/swg/chat/ChatInstantMessageToCharacter.java similarity index 98% rename from src/protocol/swg/ChatInstantMessageToCharacter.java rename to src/protocol/swg/chat/ChatInstantMessageToCharacter.java index 1d0efccd..8a1414f9 100644 --- a/src/protocol/swg/ChatInstantMessageToCharacter.java +++ b/src/protocol/swg/chat/ChatInstantMessageToCharacter.java @@ -19,13 +19,15 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + @SuppressWarnings("unused") public class ChatInstantMessageToCharacter extends SWGMessage { diff --git a/src/protocol/swg/ChatInstantMessagetoClient.java b/src/protocol/swg/chat/ChatInstantMessagetoClient.java similarity index 97% rename from src/protocol/swg/ChatInstantMessagetoClient.java rename to src/protocol/swg/chat/ChatInstantMessagetoClient.java index f87c0da8..f11903fc 100644 --- a/src/protocol/swg/ChatInstantMessagetoClient.java +++ b/src/protocol/swg/chat/ChatInstantMessagetoClient.java @@ -19,12 +19,14 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatInstantMessagetoClient extends SWGMessage{ diff --git a/src/protocol/swg/ChatOnAddFriend.java b/src/protocol/swg/chat/ChatOnAddFriend.java similarity index 96% rename from src/protocol/swg/ChatOnAddFriend.java rename to src/protocol/swg/chat/ChatOnAddFriend.java index 0b84e6ff..44b0b8ac 100644 --- a/src/protocol/swg/ChatOnAddFriend.java +++ b/src/protocol/swg/chat/ChatOnAddFriend.java @@ -19,12 +19,14 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatOnAddFriend extends SWGMessage { @Override diff --git a/src/protocol/swg/ChatOnChangeFriendStatus.java b/src/protocol/swg/chat/ChatOnChangeFriendStatus.java similarity index 97% rename from src/protocol/swg/ChatOnChangeFriendStatus.java rename to src/protocol/swg/chat/ChatOnChangeFriendStatus.java index a11c85bb..1c770233 100644 --- a/src/protocol/swg/ChatOnChangeFriendStatus.java +++ b/src/protocol/swg/chat/ChatOnChangeFriendStatus.java @@ -19,7 +19,7 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; @@ -27,6 +27,7 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import engine.resources.config.Config; public class ChatOnChangeFriendStatus extends SWGMessage { diff --git a/src/protocol/swg/chat/ChatOnConnectAvatar.java b/src/protocol/swg/chat/ChatOnConnectAvatar.java new file mode 100644 index 00000000..faebcf9d --- /dev/null +++ b/src/protocol/swg/chat/ChatOnConnectAvatar.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.chat; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class ChatOnConnectAvatar extends SWGMessage { + + public ChatOnConnectAvatar() { } + + @Override + public void deserialize(IoBuffer data) { + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer = IoBuffer.allocate(6).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putShort((short) 1); + buffer.putInt(0xD72FE9BE); + + return buffer.flip(); + } + +} diff --git a/src/protocol/swg/ChatOnCreateRoom.java b/src/protocol/swg/chat/ChatOnCreateRoom.java similarity index 97% rename from src/protocol/swg/ChatOnCreateRoom.java rename to src/protocol/swg/chat/ChatOnCreateRoom.java index 0492800c..fc690fae 100644 --- a/src/protocol/swg/ChatOnCreateRoom.java +++ b/src/protocol/swg/chat/ChatOnCreateRoom.java @@ -19,7 +19,7 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; @@ -27,6 +27,7 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import services.chat.ChatRoom; public class ChatOnCreateRoom extends SWGMessage { diff --git a/src/protocol/swg/ChatOnEnteredRoom.java b/src/protocol/swg/chat/ChatOnEnteredRoom.java similarity index 97% rename from src/protocol/swg/ChatOnEnteredRoom.java rename to src/protocol/swg/chat/ChatOnEnteredRoom.java index 179f981a..786f16a6 100644 --- a/src/protocol/swg/ChatOnEnteredRoom.java +++ b/src/protocol/swg/chat/ChatOnEnteredRoom.java @@ -19,7 +19,7 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; @@ -27,6 +27,7 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import engine.resources.common.CRC; import resources.common.Opcodes; diff --git a/src/protocol/swg/ChatOnGetFriendsList.java b/src/protocol/swg/chat/ChatOnGetFriendsList.java similarity index 95% rename from src/protocol/swg/ChatOnGetFriendsList.java rename to src/protocol/swg/chat/ChatOnGetFriendsList.java index 3e497bf1..14d5ac8f 100644 --- a/src/protocol/swg/ChatOnGetFriendsList.java +++ b/src/protocol/swg/chat/ChatOnGetFriendsList.java @@ -1,4 +1,4 @@ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; import java.util.List; @@ -7,6 +7,7 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import resources.objects.player.PlayerObject; // This is possibly unused diff --git a/src/protocol/swg/ChatOnSendInstantMessage.java b/src/protocol/swg/chat/ChatOnSendInstantMessage.java similarity index 96% rename from src/protocol/swg/ChatOnSendInstantMessage.java rename to src/protocol/swg/chat/ChatOnSendInstantMessage.java index 9bcb41da..f1be9e0a 100644 --- a/src/protocol/swg/ChatOnSendInstantMessage.java +++ b/src/protocol/swg/chat/ChatOnSendInstantMessage.java @@ -19,12 +19,14 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatOnSendInstantMessage extends SWGMessage { private int errorType; diff --git a/src/protocol/swg/ChatOnSendPersistentMessage.java b/src/protocol/swg/chat/ChatOnSendPersistentMessage.java similarity index 96% rename from src/protocol/swg/ChatOnSendPersistentMessage.java rename to src/protocol/swg/chat/ChatOnSendPersistentMessage.java index 3d8a3a48..9dc28eff 100644 --- a/src/protocol/swg/ChatOnSendPersistentMessage.java +++ b/src/protocol/swg/chat/ChatOnSendPersistentMessage.java @@ -19,12 +19,14 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatOnSendPersistentMessage extends SWGMessage { diff --git a/src/protocol/swg/ChatOnSendRoomMessage.java b/src/protocol/swg/chat/ChatOnSendRoomMessage.java similarity index 96% rename from src/protocol/swg/ChatOnSendRoomMessage.java rename to src/protocol/swg/chat/ChatOnSendRoomMessage.java index 0d7729e5..21d03390 100644 --- a/src/protocol/swg/ChatOnSendRoomMessage.java +++ b/src/protocol/swg/chat/ChatOnSendRoomMessage.java @@ -19,12 +19,14 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatOnSendRoomMessage extends SWGMessage { private int errorCode; diff --git a/src/protocol/swg/ChatPersistentMessageToClient.java b/src/protocol/swg/chat/ChatPersistentMessageToClient.java similarity index 98% rename from src/protocol/swg/ChatPersistentMessageToClient.java rename to src/protocol/swg/chat/ChatPersistentMessageToClient.java index 3db681b6..a5013ab8 100644 --- a/src/protocol/swg/ChatPersistentMessageToClient.java +++ b/src/protocol/swg/chat/ChatPersistentMessageToClient.java @@ -19,11 +19,14 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; import java.util.List; + import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; import services.chat.WaypointAttachment; diff --git a/src/protocol/swg/ChatPersistentMessageToServer.java b/src/protocol/swg/chat/ChatPersistentMessageToServer.java similarity index 98% rename from src/protocol/swg/ChatPersistentMessageToServer.java rename to src/protocol/swg/chat/ChatPersistentMessageToServer.java index a8602f83..84fa1e52 100644 --- a/src/protocol/swg/ChatPersistentMessageToServer.java +++ b/src/protocol/swg/chat/ChatPersistentMessageToServer.java @@ -19,13 +19,16 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; + import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; import services.chat.WaypointAttachment; diff --git a/src/protocol/swg/chat/ChatQueryRoomResults.java b/src/protocol/swg/chat/ChatQueryRoomResults.java new file mode 100644 index 00000000..da760c20 --- /dev/null +++ b/src/protocol/swg/chat/ChatQueryRoomResults.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.chat; + +import java.nio.ByteOrder; +import java.util.Vector; + +import main.NGECore; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; +import resources.objects.creature.CreatureObject; +import services.chat.ChatRoom; + +public class ChatQueryRoomResults extends SWGMessage { + + private ChatRoom room; + private int requestId; + + public ChatQueryRoomResults(ChatRoom room, int requestId) { + this.room = room; + this.requestId = requestId; + } + + @Override + public void deserialize(IoBuffer data) { + } + + @Override + public IoBuffer serialize() { + String server = NGECore.getInstance().getGalaxyName(); + IoBuffer buffer = IoBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putShort((short) 7); + buffer.putInt(0xC4DE864E); + + Vector users = room.getUserList(); + + buffer.putInt(users.size()); + if (users.size() > 0) { + for (CreatureObject creo : users) { + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(creo.getCustomName())); + } + } + + buffer.putInt(0); // TODO: Invited list for chat rooms + + Vector moderators = room.getModeratorList(); + + buffer.putInt(moderators.size()); + if (moderators.size() > 0) { + for (CreatureObject creo : users) { + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(creo.getCustomName())); + } + } + + Vector banned = room.getBanList(); + buffer.putInt(banned.size()); + if (banned.size() > 0) { + for (CreatureObject creo : users) { + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(creo.getCustomName())); + } + } + + buffer.putInt(requestId); + buffer.putInt(room.getRoomId()); + buffer.putInt(room.isPrivateRoom() ? 0 : 1); + buffer.put((byte) (room.isModeratorsOnly() ? 1 : 0)); + + buffer.put(getAsciiString(room.getRoomAddress())); + + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(room.getOwner())); + + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(room.getCreator())); + + buffer.put(getUnicodeString(room.getDescription())); + + buffer.putInt(0); // moderator list + buffer.putInt(0); // user list + return buffer.flip(); + } + +} diff --git a/src/protocol/swg/ChatRequestPersistentMessage.java b/src/protocol/swg/chat/ChatRequestPersistentMessage.java similarity index 96% rename from src/protocol/swg/ChatRequestPersistentMessage.java rename to src/protocol/swg/chat/ChatRequestPersistentMessage.java index d52b4afd..dd9ec88f 100644 --- a/src/protocol/swg/ChatRequestPersistentMessage.java +++ b/src/protocol/swg/chat/ChatRequestPersistentMessage.java @@ -19,10 +19,12 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatRequestPersistentMessage extends SWGMessage { diff --git a/src/protocol/swg/ChatRoomList.java b/src/protocol/swg/chat/ChatRoomList.java similarity index 90% rename from src/protocol/swg/ChatRoomList.java rename to src/protocol/swg/chat/ChatRoomList.java index e2bff284..042d930a 100644 --- a/src/protocol/swg/ChatRoomList.java +++ b/src/protocol/swg/chat/ChatRoomList.java @@ -19,7 +19,7 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; import java.util.concurrent.ConcurrentHashMap; @@ -28,6 +28,8 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; +import resources.common.StringUtilities; import services.chat.ChatRoom; public class ChatRoomList extends SWGMessage { @@ -46,7 +48,7 @@ public class ChatRoomList extends SWGMessage { @Override public IoBuffer serialize() { String server = NGECore.getInstance().getGalaxyName(); - IoBuffer buffer = IoBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN); + IoBuffer buffer = IoBuffer.allocate(53).order(ByteOrder.LITTLE_ENDIAN); buffer.setAutoExpand(true); buffer.putShort((short) 2); @@ -70,7 +72,9 @@ public class ChatRoomList extends SWGMessage { buffer.putInt(0); // user list (not used by client) } }); - return buffer.flip(); + buffer.flip(); + //StringUtilities.printBytes(buffer.array()); + return buffer; } } diff --git a/src/protocol/swg/ChatRoomMessage.java b/src/protocol/swg/chat/ChatRoomMessage.java similarity index 97% rename from src/protocol/swg/ChatRoomMessage.java rename to src/protocol/swg/chat/ChatRoomMessage.java index 209db832..616d019d 100644 --- a/src/protocol/swg/ChatRoomMessage.java +++ b/src/protocol/swg/chat/ChatRoomMessage.java @@ -19,7 +19,7 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; @@ -27,6 +27,8 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatRoomMessage extends SWGMessage { private String character; diff --git a/src/protocol/swg/ChatSendToRoom.java b/src/protocol/swg/chat/ChatSendToRoom.java similarity index 96% rename from src/protocol/swg/ChatSendToRoom.java rename to src/protocol/swg/chat/ChatSendToRoom.java index c3a07dac..0a751ac0 100644 --- a/src/protocol/swg/ChatSendToRoom.java +++ b/src/protocol/swg/chat/ChatSendToRoom.java @@ -19,10 +19,12 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; + public class ChatSendToRoom extends SWGMessage { private String message; diff --git a/src/protocol/swg/chat/ChatServerStatus.java b/src/protocol/swg/chat/ChatServerStatus.java new file mode 100644 index 00000000..a867a244 --- /dev/null +++ b/src/protocol/swg/chat/ChatServerStatus.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.chat; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class ChatServerStatus extends SWGMessage { + + @Override + public void deserialize(IoBuffer data) { + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer = IoBuffer.allocate(7).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 2); + buffer.putInt(0x7102B15F); + buffer.put((byte) 1); + return buffer.flip(); + } +} diff --git a/src/protocol/swg/ChatSystemMessage.java b/src/protocol/swg/chat/ChatSystemMessage.java similarity index 98% rename from src/protocol/swg/ChatSystemMessage.java rename to src/protocol/swg/chat/ChatSystemMessage.java index e12aa1f4..af1b516d 100644 --- a/src/protocol/swg/ChatSystemMessage.java +++ b/src/protocol/swg/chat/ChatSystemMessage.java @@ -19,12 +19,13 @@ * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. ******************************************************************************/ -package protocol.swg; +package protocol.swg.chat; import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import protocol.swg.SWGMessage; import resources.common.Opcodes; public class ChatSystemMessage extends SWGMessage{ diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index da90caec..8391ac82 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -34,12 +34,12 @@ import java.util.concurrent.TimeUnit; import org.apache.mina.core.buffer.IoBuffer; -import protocol.swg.ChatSystemMessage; import protocol.swg.ObjControllerMessage; import protocol.swg.PlayClientEffectObjectMessage; import protocol.swg.PlayMusicMessage; import protocol.swg.UpdatePostureMessage; import protocol.swg.UpdatePVPStatusMessage; +import protocol.swg.chat.ChatSystemMessage; import protocol.swg.objectControllerObjects.Animation; import protocol.swg.objectControllerObjects.Posture; diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index d7c05496..1479a107 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -60,15 +60,15 @@ import engine.resources.scene.Quaternion; import engine.resources.scene.quadtree.QuadTree; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; -import protocol.swg.ChatFriendsListUpdate; -import protocol.swg.ChatOnChangeFriendStatus; -import protocol.swg.ChatOnGetFriendsList; import protocol.swg.CmdStartScene; import protocol.swg.HeartBeatMessage; import protocol.swg.ObjControllerMessage; import protocol.swg.OpenedContainerMessage; import protocol.swg.UpdateTransformMessage; import protocol.swg.UpdateTransformWithParentMessage; +import protocol.swg.chat.ChatFriendsListUpdate; +import protocol.swg.chat.ChatOnChangeFriendStatus; +import protocol.swg.chat.ChatOnGetFriendsList; import protocol.swg.objectControllerObjects.DataTransform; import protocol.swg.objectControllerObjects.DataTransformWithParent; import protocol.swg.objectControllerObjects.TargetUpdate; diff --git a/src/services/chat/ChatRoom.java b/src/services/chat/ChatRoom.java index 41ee1565..a2428907 100644 --- a/src/services/chat/ChatRoom.java +++ b/src/services/chat/ChatRoom.java @@ -21,7 +21,6 @@ ******************************************************************************/ package services.chat; -import java.util.List; import java.util.Vector; import resources.objects.creature.CreatureObject; @@ -29,8 +28,6 @@ import resources.objects.creature.CreatureObject; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.NotPersistent; import com.sleepycat.persist.model.PrimaryKey; -import com.sleepycat.persist.model.Relationship; -import com.sleepycat.persist.model.SecondaryKey; @Entity public class ChatRoom { @@ -45,8 +42,6 @@ public class ChatRoom { @NotPersistent private Vector userList = new Vector(); // current users - @NotPersistent - private int requestId; // not-persistent private boolean moderatorsOnly; private boolean privateRoom; private boolean visible; @@ -92,14 +87,6 @@ public class ChatRoom { this.userList = userList; } - public int getRequestId() { - return requestId; - } - - public void setRequestId(int requestId) { - this.requestId = requestId; - } - public boolean isModeratorsOnly() { return moderatorsOnly; } diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index 8d4a159f..274fcd4e 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -49,27 +49,28 @@ import resources.common.*; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import protocol.swg.AddIgnoreMessage; -import protocol.swg.ChatCreateRoom; -import protocol.swg.ChatEnterRoomById; -import protocol.swg.ChatOnChangeFriendStatus; -import protocol.swg.ChatDeletePersistentMessage; -import protocol.swg.ChatFriendsListUpdate; -import protocol.swg.ChatInstantMessageToCharacter; -import protocol.swg.ChatInstantMessagetoClient; -import protocol.swg.ChatOnAddFriend; -import protocol.swg.ChatOnCreateRoom; -import protocol.swg.ChatOnEnteredRoom; -import protocol.swg.ChatOnSendInstantMessage; -import protocol.swg.ChatOnSendPersistentMessage; -import protocol.swg.ChatOnSendRoomMessage; -import protocol.swg.ChatPersistentMessageToClient; -import protocol.swg.ChatPersistentMessageToServer; -import protocol.swg.ChatRequestPersistentMessage; -import protocol.swg.ChatRoomList; -import protocol.swg.ChatRoomMessage; -import protocol.swg.ChatSendToRoom; -import protocol.swg.ChatSystemMessage; import protocol.swg.ObjControllerMessage; +import protocol.swg.chat.ChatCreateRoom; +import protocol.swg.chat.ChatDeletePersistentMessage; +import protocol.swg.chat.ChatEnterRoomById; +import protocol.swg.chat.ChatFriendsListUpdate; +import protocol.swg.chat.ChatInstantMessageToCharacter; +import protocol.swg.chat.ChatInstantMessagetoClient; +import protocol.swg.chat.ChatOnAddFriend; +import protocol.swg.chat.ChatOnChangeFriendStatus; +import protocol.swg.chat.ChatOnCreateRoom; +import protocol.swg.chat.ChatOnEnteredRoom; +import protocol.swg.chat.ChatOnSendInstantMessage; +import protocol.swg.chat.ChatOnSendPersistentMessage; +import protocol.swg.chat.ChatOnSendRoomMessage; +import protocol.swg.chat.ChatPersistentMessageToClient; +import protocol.swg.chat.ChatPersistentMessageToServer; +import protocol.swg.chat.ChatRequestPersistentMessage; +import protocol.swg.chat.ChatRoomList; +import protocol.swg.chat.ChatRoomMessage; +import protocol.swg.chat.ChatSendToRoom; +import protocol.swg.chat.ChatServerStatus; +import protocol.swg.chat.ChatSystemMessage; import protocol.swg.objectControllerObjects.PlayerEmote; import protocol.swg.objectControllerObjects.SpatialChat; import main.NGECore; @@ -363,15 +364,17 @@ public class ChatService implements INetworkDispatch { if (obj == null) return; - ChatRoomList listMessage = new ChatRoomList(chatRooms); + //ChatServerStatus chatServerStatus = new ChatServerStatus(); + //client.getSession().write(chatServerStatus.serialize()); + ChatRoomList listMessage = new ChatRoomList(chatRooms); client.getSession().write(listMessage.serialize()); } }); swgOpcodes.put(Opcodes.ChatCreateRoom, (session, data) -> { - data.order(ByteOrder.LITTLE_ENDIAN); + /*data.order(ByteOrder.LITTLE_ENDIAN); Client client = core.getClient(session); @@ -389,19 +392,33 @@ public class ChatService implements INetworkDispatch { sentPacket.deserialize(data); ChatRoom room = createChatRoom(sentPacket.getTitle(), sentPacket.getAddress(), creo.getCustomName().toLowerCase(), true, false); - room.setPrivateRoom(sentPacket.isPrivacy()); - room.setModeratorsOnly(sentPacket.isModeratorOnly()); if (room != null) { + room.setPrivateRoom(sentPacket.isPrivacy()); + room.setModeratorsOnly(sentPacket.isModeratorOnly()); room.getUserList().add(creo); room.getModeratorList().add(creo); ChatOnCreateRoom response = new ChatOnCreateRoom(room, 0, sentPacket.getRequest()); session.write(response.serialize()); - } + }*/ }); swgOpcodes.put(Opcodes.ChatQueryRoom, (session, data) -> { + data.order(ByteOrder.LITTLE_ENDIAN); + //StringUtilities.printBytes(data.array()); + Client client = core.getClient(session); + + if(client == null) + return; + + SWGObject obj = client.getParent(); + + if (obj == null) + return; + + + }); swgOpcodes.put(Opcodes.ChatSendToRoom, (session, data) -> { @@ -441,7 +458,7 @@ public class ChatService implements INetworkDispatch { joinChatRoom((CreatureObject) obj, sentPacket.getRoomId()); - System.out.println("Entering room... " + sentPacket.getRoomId()); + //System.out.println("Entering room... " + sentPacket.getRoomId()); }); } @@ -728,15 +745,15 @@ public class ChatService implements INetworkDispatch { if (creator.contains(" ")) creator = creator.split(" ")[0]; - + ChatRoom room = new ChatRoom(); room.setDescription(roomName); if (!address.startsWith("SWG.")) room.setRoomAddress("SWG." + core.getGalaxyName() + "." + address); else room.setRoomAddress(address); - room.setCreator(creator); - room.setOwner(creator); + room.setCreator(creator.toLowerCase()); + room.setOwner(creator.toLowerCase()); room.setVisible(showInList); room.setRoomId(generateChatRoomId()); diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 6c5a44a4..816d910b 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -58,10 +58,6 @@ import com.sleepycat.persist.EntityCursor; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.PrimaryKey; -import protocol.swg.ChatFriendsListUpdate; -import protocol.swg.ChatOnChangeFriendStatus; -import protocol.swg.ChatOnGetFriendsList; -import protocol.swg.ChatRoomList; import protocol.swg.CmdSceneReady; import protocol.swg.CmdStartScene; import protocol.swg.HeartBeatMessage; @@ -70,6 +66,12 @@ import protocol.swg.ParametersMessage; import protocol.swg.SelectCharacter; import protocol.swg.ServerTimeMessage; import protocol.swg.UnkByteFlag; +import protocol.swg.chat.ChatFriendsListUpdate; +import protocol.swg.chat.ChatOnChangeFriendStatus; +import protocol.swg.chat.ChatOnConnectAvatar; +import protocol.swg.chat.ChatOnGetFriendsList; +import protocol.swg.chat.ChatRoomList; +import protocol.swg.chat.ChatServerStatus; import protocol.swg.objectControllerObjects.UiPlayEffect; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.CrcStringTableVisitor; @@ -783,10 +785,18 @@ public class ObjectService implements INetworkDispatch { core.chatService.loadMailHeaders(client); core.simulationService.handleZoneIn(client); + creature.makeAware(creature); + ChatServerStatus chatStatus = new ChatServerStatus(); + creature.getClient().getSession().write(chatStatus.serialize()); + + ChatOnConnectAvatar chatConnect = new ChatOnConnectAvatar(); + creature.getClient().getSession().write(chatConnect.serialize()); + ChatRoomList chatRooms = new ChatRoomList(core.chatService.getChatRooms()); creature.getClient().getSession().write(chatRooms.serialize()); + //ChatOnGetFriendsList friendsListMessage = new ChatOnGetFriendsList(ghost); //client.getSession().write(friendsListMessage.serialize()); From 70b7507bb015bddb7a76a095053e4c826d444524 Mon Sep 17 00:00:00 2001 From: Seefo Date: Wed, 9 Apr 2014 19:53:11 -0400 Subject: [PATCH 51/68] Added /movefurniture & /rotatefurniture, see ext. The permission system thing I'm doing needs to be adjusted to the Container permission system in the Engine. To Light: Please contact me in regards to this --- scripts/commands/movefurniture.py | 38 ++++++++++++++++++++++++++++ scripts/commands/rotatefurniture.py | 29 +++++++++++++++++++++ scripts/commands/transferitemmisc.py | 21 +++++++++++---- src/services/DevService.java | 4 +-- src/services/SimulationService.java | 21 +++++++++++++++ 5 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 scripts/commands/movefurniture.py create mode 100644 scripts/commands/rotatefurniture.py diff --git a/scripts/commands/movefurniture.py b/scripts/commands/movefurniture.py new file mode 100644 index 00000000..3c45c55e --- /dev/null +++ b/scripts/commands/movefurniture.py @@ -0,0 +1,38 @@ +import sys +from engine.resources.scene import Point3D + +def setup(): + return + +def run(core, actor, target, commandString): + tarObj = core.objectService.getObject(actor.getTargetId()) + + container = actor.getContainer() + parsedMsg = commandString.split(' ', 2) + + if core.housingService.getPermissions(actor, container): # i should probably relook into my permissions system... it kinda sucks + if parsedMsg[0] == "up": + core.simulationService.transform(tarObj, Point3D(0, float(parsedMsg[1]) * 0.01, 0)) + return + elif parsedMsg[0] == "down": + core.simulationService.transform(tarObj, Point3D(0, float(parsedMsg[1]) * -0.01, 0)) + return + elif parsedMsg[0] == "forward": + core.simulationService.transform(tarObj, Point3D(0, 0, float(parsedMsg[1]) * 0.01)) + return + elif parsedMsg[0] == "back": + core.simulationService.transform(tarObj, Point3D(0, 0, float(parsedMsg[1]) * -0.01)) + return + elif parsedMsg[0] == "right": + core.simulationService.transform(tarObj, Point3D(float(parsedMsg[1]) * 0.01, 0, 0)) + return + elif parsedMsg[0] == "left": + core.simulationService.transform(tarObj, Point3D(float(parsedMsg[1]) * -0.01, 0, 0)) + return + + elif container.getTemplate() == "object/cell/shared_cell.iff": + actor.sendSystemMessage("You do not have permission to access that container!", 0) + return + + return + \ No newline at end of file diff --git a/scripts/commands/rotatefurniture.py b/scripts/commands/rotatefurniture.py new file mode 100644 index 00000000..9d019d0c --- /dev/null +++ b/scripts/commands/rotatefurniture.py @@ -0,0 +1,29 @@ +import sys +from engine.resources.scene import Point3D + +def setup(): + return + +def run(core, actor, target, commandString): + tarObj = core.objectService.getObject(actor.getTargetId()) + + container = actor.getContainer() + parsedMsg = commandString.split(' ', 2) + + if core.housingService.getPermissions(actor, container): # i should probably relook into my permissions system... it kinda sucks + if parsedMsg[0] == "pitch": + core.simulationService.transform(tarObj, float(parsedMsg[1]), Point3D(1, 0, 0)) # this is messed up ??? + return + elif parsedMsg[0] == "yaw": + core.simulationService.transform(tarObj, float(parsedMsg[1]), Point3D(0, 1, 0)) # this is correct + return + elif parsedMsg[0] == "roll": + core.simulationService.transform(tarObj, float(parsedMsg[1]), Point3D(0, 0, 1)) # this is messed up ??? + return + + elif container.getTemplate() == "object/cell/shared_cell.iff": + actor.sendSystemMessage("You do not have permission to access that container!", 0) + return + + return + \ No newline at end of file diff --git a/scripts/commands/transferitemmisc.py b/scripts/commands/transferitemmisc.py index 5dc726fd..27bfde45 100644 --- a/scripts/commands/transferitemmisc.py +++ b/scripts/commands/transferitemmisc.py @@ -1,18 +1,29 @@ import sys - +from engine.resources.scene import Quaternion + def setup(): return def run(core, actor, target, commandString): + parsedMsg = commandString.split(' ', 3) + objService = core.objectService + containerID = long(parsedMsg[1]) + container = objService.getObject(containerID) + actorContainer = actor.getContainer() + + if actorContainer != None and (container.getTemplate() == "object/cell/shared_cell.iff") & core.housingService.getPermissions(actor, actorContainer): + target.getContainer().transferTo(actor, container, target) + core.simulationService.teleport(target, actor.getPosition(), Quaternion(1,0,0,0), containerID) + return + elif actorContainer != None and container.getTemplate() == "object/cell/shared_cell.iff": + actor.sendSystemMessage("You do not have permission to access that container!", 0) + return + if core.equipmentService.canEquip(actor, target) is False: actor.sendSystemMessage('@error_message:insufficient_skill', 0) return - parsedMsg = commandString.split(' ', 3) - objService = core.objectService - containerID = long(parsedMsg[1]) - container = objService.getObject(containerID) if target and container and target.getContainer(): oldContainer = target.getContainer() diff --git a/src/services/DevService.java b/src/services/DevService.java index 30ee710c..ef265f41 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -67,7 +67,7 @@ public class DevService implements INetworkDispatch { public void sendCharacterBuilderSUI(CreatureObject creature, int childMenu) { Map suiOptions = new HashMap(); - + switch(childMenu) { case 0: // Root @@ -85,7 +85,7 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 22, "Misc Items"); suiOptions.put((long) 23, "Jedi Items"); suiOptions.put((long) 110, "Survey Devices"); - //suiOptions.put((long) 120, "House Deeds"); + if(creature.getClient().isGM()) suiOptions.put((long) 120, "House Deeds"); break; case 3: // [Items] Weapons suiOptions.put((long) 30, "Jedi Weapons"); diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index d7c05496..71b86388 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -886,6 +886,24 @@ public class SimulationService implements INetworkDispatch { } + public void transform(TangibleObject obj, Point3D position) + { + Point3D oldPosition = obj.getPosition(); + Point3D newPosition = new Point3D(oldPosition.x + position.x, oldPosition.y + position.y, oldPosition.z + position.z); + + teleport(obj, newPosition, obj.getOrientation(), obj.getParentId()); + } + + public void transform(SWGObject obj, float rotation, Point3D axis) + { + rotation *= (Math.PI / 180); + + Quaternion oldRotation = obj.getOrientation(); + Quaternion newRotation = resources.common.MathUtilities.rotateQuaternion(oldRotation, rotation, axis); + + teleport(obj, obj.getPosition(), newRotation, obj.getParentId()); + } + public void teleport(SWGObject obj, Point3D position, Quaternion orientation, long cellId) { if(cellId == 0) { @@ -900,6 +918,9 @@ public class SimulationService implements INetworkDispatch { DataTransformWithParent dataTransform = new DataTransformWithParent(new Point3D(position.x, position.y, position.z), orientation, obj.getMovementCounter(), obj.getObjectID(), cellId); ObjControllerMessage objController = new ObjControllerMessage(0x1B, dataTransform); obj.notifyObservers(objController, true); + + obj.setPosition(position); + obj.setOrientation(orientation); } } From 38283f335125576e97fc073a3e0cb3a3b1288295 Mon Sep 17 00:00:00 2001 From: Seefo Date: Wed, 9 Apr 2014 21:23:12 -0400 Subject: [PATCH 52/68] Added house radials and fixed a lot calculation mistake --- scripts/radial/moveable.py | 25 +++++++++++++++++++ .../objects/player/PlayerObject.java | 2 +- src/services/housing/HouseTemplate.java | 2 +- src/services/housing/HousingService.java | 3 +-- src/services/sui/SUIService.java | 10 ++++++++ 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 scripts/radial/moveable.py diff --git a/scripts/radial/moveable.py b/scripts/radial/moveable.py new file mode 100644 index 00000000..4bbb4120 --- /dev/null +++ b/scripts/radial/moveable.py @@ -0,0 +1,25 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + radials.clear() + radials.add(RadialOptions(0, 11, 1, '')) + + radials.add(RadialOptions(0, 55, 0, '')) + radials.add(RadialOptions(3, 56, 1, '')) + radials.add(RadialOptions(3, 57, 1, '')) + radials.add(RadialOptions(3, 58, 1, '')) + radials.add(RadialOptions(3, 59, 1, '')) + + radials.add(RadialOptions(0, 52, 0, '')) + radials.add(RadialOptions(4, 53, 1, '')) + radials.add(RadialOptions(4, 54, 1, '')) + return + +def handleSelection(core, owner, target, option): + + if option == 56: + core.commandService.callCommand(owner, 'movefurniture', target, 'forward 10') + + return + \ No newline at end of file diff --git a/src/resources/objects/player/PlayerObject.java b/src/resources/objects/player/PlayerObject.java index 1a50837d..aecf070a 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -838,7 +838,7 @@ public class PlayerObject extends IntangibleObject { public boolean deductLots(int amount) { - if(this.lotsRemaining - amount > 0) + if(this.lotsRemaining - amount >= 0) { this.lotsRemaining -= amount; return true; diff --git a/src/services/housing/HouseTemplate.java b/src/services/housing/HouseTemplate.java index fc2861df..3918cf55 100644 --- a/src/services/housing/HouseTemplate.java +++ b/src/services/housing/HouseTemplate.java @@ -57,7 +57,7 @@ public class HouseTemplate public boolean canBePlacedOn(String planetName) { if(placeablePlanets.contains(planetName)) return true; - else return false; + return false; } public int getLotCost() { diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index 3bcc9188..37da6f3a 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -97,12 +97,11 @@ public class HousingService implements INetworkDispatch { } // Lot stuff - if(actor.getPlayerObject().getLotsRemaining() - structureLotCost < 0) + if(!actor.getPlayerObject().deductLots(structureLotCost)) { actor.sendSystemMessage("You do not have enough available lots to place this structure.", (byte) 0); // should probably load this from an stf return; } - actor.getPlayerObject().deductLots(structureLotCost); // Calculate our orientation and height Quaternion quaternion = new Quaternion(1, 0, 0, 0); diff --git a/src/services/sui/SUIService.java b/src/services/sui/SUIService.java index f74c20d0..8c2240f7 100644 --- a/src/services/sui/SUIService.java +++ b/src/services/sui/SUIService.java @@ -82,6 +82,16 @@ public class SUIService implements INetworkDispatch { if(target == null || owner == null) return; + if(target.getGrandparent() != null && target.getGrandparent().getAttachment("structureAdmins") != null) + { + if(core.housingService.getPermissions(owner, target.getContainer())) + { + core.scriptService.callScript("scripts/radial/", "moveable", "createRadial", core, owner, target, request.getRadialOptions()); + sendRadial(owner, target, request.getRadialOptions(), request.getRadialCount()); + return; + } + } + core.scriptService.callScript("scripts/radial/", getRadialFilename(target), "createRadial", core, owner, target, request.getRadialOptions()); if(getRadialFilename(target).equals("default")) return; From 221f9a93fc1283561b612c2605f5def79ee56fad Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Thu, 10 Apr 2014 04:22:54 +0200 Subject: [PATCH 53/68] Loot radial and power crystal items Connected loot radial to corpse. Made powercrystal scripts. Allowed the mobile scripts to drop loot now. --- scripts/loot/lootItems/junk/brain.py | 4 + .../loot/lootItems/junk/chassis_blueprint.py | 4 + scripts/loot/lootItems/junk/launcher_tube.py | 4 + scripts/loot/lootItems/powercrystal_fair.py | 2 +- .../loot/lootItems/powercrystal_flawless.py | 2 +- scripts/loot/lootItems/powercrystal_good.py | 2 +- .../loot/lootItems/powercrystal_perfect.py | 8 ++ scripts/loot/lootItems/powercrystal_poor.py | 2 +- .../loot/lootItems/powercrystal_premium.py | 2 +- .../loot/lootItems/powercrystal_quality.py | 2 +- scripts/loot/lootItems/powercrystal_select.py | 2 +- scripts/loot/lootItems/rarelootchest1.py | 8 ++ scripts/loot/lootItems/rarelootchest2.py | 8 ++ scripts/loot/lootPools/powercrystals_hiq.py | 6 ++ scripts/loot/lootPools/rareloot.py | 4 +- scripts/mobiles/tatooine/krayt_dragon.py | 19 +++++ scripts/mobiles/tatooine/tusken_raider.py | 28 +++++++ .../dressed_dark_jedi_master_female_twk_01.py | 13 +++- .../dressed_dark_jedi_master_female_twk_02.py | 13 +++- .../dressed_dark_jedi_master_female_zab_01.py | 13 +++- .../dressed_dark_jedi_master_female_zab_02.py | 13 +++- .../dressed_dark_jedi_master_male_human_01.py | 13 +++- .../dressed_dark_jedi_master_male_human_02.py | 13 +++- .../dressed_dark_jedi_master_male_human_03.py | 13 +++- .../dressed_dark_jedi_master_male_human_04.py | 13 +++- .../dressed_dark_jedi_master_male_human_05.py | 13 +++- .../dressed_dark_jedi_master_male_human_06.py | 13 +++- .../object/mobile/dressed_stormtrooper_m.py | 18 ++++- scripts/radial/npc/corpse.py | 16 ++++ .../objects/tangible/TangibleObject.java | 12 ++- src/services/DevService.java | 20 ++++- src/services/LootService.java | 78 +++++++++++-------- src/services/spawn/SpawnService.java | 2 + 33 files changed, 326 insertions(+), 57 deletions(-) create mode 100644 scripts/loot/lootItems/powercrystal_perfect.py create mode 100644 scripts/loot/lootItems/rarelootchest1.py create mode 100644 scripts/loot/lootItems/rarelootchest2.py create mode 100644 scripts/loot/lootPools/powercrystals_hiq.py create mode 100644 scripts/mobiles/tatooine/krayt_dragon.py create mode 100644 scripts/mobiles/tatooine/tusken_raider.py create mode 100644 scripts/radial/npc/corpse.py diff --git a/scripts/loot/lootItems/junk/brain.py b/scripts/loot/lootItems/junk/brain.py index d0e8f837..bb01bf52 100644 --- a/scripts/loot/lootItems/junk/brain.py +++ b/scripts/loot/lootItems/junk/brain.py @@ -2,3 +2,7 @@ def itemTemplate(): return 'object/tangible/loot/creature_loot/generic/shared_brain_s01.iff' + +def customItemName(): + + return 'Brain' \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/chassis_blueprint.py b/scripts/loot/lootItems/junk/chassis_blueprint.py index 5c2445a8..b876b351 100644 --- a/scripts/loot/lootItems/junk/chassis_blueprint.py +++ b/scripts/loot/lootItems/junk/chassis_blueprint.py @@ -2,3 +2,7 @@ def itemTemplate(): return 'object/tangible/loot/generic_usable/shared_chassis_blueprint_usuable.iff' + +def customItemName(): + + return 'Chassis Blueprint' \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/launcher_tube.py b/scripts/loot/lootItems/junk/launcher_tube.py index 5612b566..4159a299 100644 --- a/scripts/loot/lootItems/junk/launcher_tube.py +++ b/scripts/loot/lootItems/junk/launcher_tube.py @@ -2,3 +2,7 @@ def itemTemplate(): return 'object/tangible/loot/npc_loot/shared_launcher_tube_generic.iff' + +def customItemName(): + + return 'Launcher Tube' \ No newline at end of file diff --git a/scripts/loot/lootItems/powercrystal_fair.py b/scripts/loot/lootItems/powercrystal_fair.py index ef8d2dc0..3c533136 100644 --- a/scripts/loot/lootItems/powercrystal_fair.py +++ b/scripts/loot/lootItems/powercrystal_fair.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' def customItemName(): diff --git a/scripts/loot/lootItems/powercrystal_flawless.py b/scripts/loot/lootItems/powercrystal_flawless.py index 8e532580..8163cb74 100644 --- a/scripts/loot/lootItems/powercrystal_flawless.py +++ b/scripts/loot/lootItems/powercrystal_flawless.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' def customItemName(): diff --git a/scripts/loot/lootItems/powercrystal_good.py b/scripts/loot/lootItems/powercrystal_good.py index 8e532580..8163cb74 100644 --- a/scripts/loot/lootItems/powercrystal_good.py +++ b/scripts/loot/lootItems/powercrystal_good.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' def customItemName(): diff --git a/scripts/loot/lootItems/powercrystal_perfect.py b/scripts/loot/lootItems/powercrystal_perfect.py new file mode 100644 index 00000000..8163cb74 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_perfect.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_poor.py b/scripts/loot/lootItems/powercrystal_poor.py index 8e532580..8163cb74 100644 --- a/scripts/loot/lootItems/powercrystal_poor.py +++ b/scripts/loot/lootItems/powercrystal_poor.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' def customItemName(): diff --git a/scripts/loot/lootItems/powercrystal_premium.py b/scripts/loot/lootItems/powercrystal_premium.py index 8e532580..8163cb74 100644 --- a/scripts/loot/lootItems/powercrystal_premium.py +++ b/scripts/loot/lootItems/powercrystal_premium.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' def customItemName(): diff --git a/scripts/loot/lootItems/powercrystal_quality.py b/scripts/loot/lootItems/powercrystal_quality.py index 8e532580..8163cb74 100644 --- a/scripts/loot/lootItems/powercrystal_quality.py +++ b/scripts/loot/lootItems/powercrystal_quality.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' def customItemName(): diff --git a/scripts/loot/lootItems/powercrystal_select.py b/scripts/loot/lootItems/powercrystal_select.py index 8e532580..8163cb74 100644 --- a/scripts/loot/lootItems/powercrystal_select.py +++ b/scripts/loot/lootItems/powercrystal_select.py @@ -1,7 +1,7 @@ def itemTemplate(): - return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' def customItemName(): diff --git a/scripts/loot/lootItems/rarelootchest1.py b/scripts/loot/lootItems/rarelootchest1.py new file mode 100644 index 00000000..1541e62a --- /dev/null +++ b/scripts/loot/lootItems/rarelootchest1.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/item/shared_rare_loot_chest_3.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/rarelootchest2.py b/scripts/loot/lootItems/rarelootchest2.py new file mode 100644 index 00000000..1541e62a --- /dev/null +++ b/scripts/loot/lootItems/rarelootchest2.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/item/shared_rare_loot_chest_3.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootPools/powercrystals_hiq.py b/scripts/loot/lootPools/powercrystals_hiq.py new file mode 100644 index 00000000..63d33a9b --- /dev/null +++ b/scripts/loot/lootPools/powercrystals_hiq.py @@ -0,0 +1,6 @@ + +def itemNames(): + return ['powercrystal_premium','powercrystal_flawless','powercrystal_perfect'] + +def itemChances(): + return [94,5,1] #= 100% \ No newline at end of file diff --git a/scripts/loot/lootPools/rareloot.py b/scripts/loot/lootPools/rareloot.py index 4487075d..435ebfce 100644 --- a/scripts/loot/lootPools/rareloot.py +++ b/scripts/loot/lootPools/rareloot.py @@ -2,8 +2,8 @@ def itemNames(): - templates=['object/tangible/item/shared_rare_loot_chest_3.iff'] + templates=['rarelootchest1','rarelootchest2'] return templates def itemChances(): - return [1] \ No newline at end of file + return [70,30] \ No newline at end of file diff --git a/scripts/mobiles/tatooine/krayt_dragon.py b/scripts/mobiles/tatooine/krayt_dragon.py new file mode 100644 index 00000000..aded5429 --- /dev/null +++ b/scripts/mobiles/tatooine/krayt_dragon.py @@ -0,0 +1,19 @@ +import sys +from services.spawn import MobileTemplate +from java.util import Vector + +def addTemplate(core): + mobileTemplate = MobileTemplate() + templates = Vector() + templates.add('object/mobile/shared_krayt_dragon.iff') + mobileTemplate.setTemplates(templates) + mobileTemplate.setLevel(10) + mobileTemplate.setDifficulty(2) + attacks = Vector() + mobileTemplate.setDefaultAttack('creatureMeleeAttack') + mobileTemplate.setAttacks(attacks) + mobileTemplate.setCreatureName('krayt_dragon') + mobileTemplate.setScale(2) + mobileTemplate.setAttackRange(12) + core.spawnService.addMobileTemplate('krayt_dragon', mobileTemplate) + \ No newline at end of file diff --git a/scripts/mobiles/tatooine/tusken_raider.py b/scripts/mobiles/tatooine/tusken_raider.py new file mode 100644 index 00000000..8daec628 --- /dev/null +++ b/scripts/mobiles/tatooine/tusken_raider.py @@ -0,0 +1,28 @@ +import sys +from services.spawn import MobileTemplate +from java.util import Vector + +def addTemplate(core): + mobileTemplate = MobileTemplate() + + mobileTemplate.setCreatureName('tuskenraider') + mobileTemplate.setLevel(90) + mobileTemplate.setDifficulty(0) + mobileTemplate.setAttackRange(24) + + templates = Vector() + templates.add('object/mobile/shared_tusken_raider.iff') + mobileTemplate.setTemplates(templates) + + weaponTemplates = Vector() + weaponTemplates.add('object/weapon/ranged/rifle/shared_rifle_e11.iff') + weaponTemplates.add('object/weapon/ranged/rifle/shared_rifle_t21.iff') + mobileTemplate.setWeaponTemplates(weaponTemplates) + + + attacks = Vector() + mobileTemplate.setDefaultAttack('rangedShot') + mobileTemplate.setAttacks(attacks) + + core.spawnService.addMobileTemplate('tuskenraider', mobileTemplate) + \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_female_twk_01.py b/scripts/object/mobile/dressed_dark_jedi_master_female_twk_01.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_female_twk_01.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_female_twk_01.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_female_twk_02.py b/scripts/object/mobile/dressed_dark_jedi_master_female_twk_02.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_female_twk_02.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_female_twk_02.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_female_zab_01.py b/scripts/object/mobile/dressed_dark_jedi_master_female_zab_01.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_female_zab_01.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_female_zab_01.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_female_zab_02.py b/scripts/object/mobile/dressed_dark_jedi_master_female_zab_02.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_female_zab_02.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_female_zab_02.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_01.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_01.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_01.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_01.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_02.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_02.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_02.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_02.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_03.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_03.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_03.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_03.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_04.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_04.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_04.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_04.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_05.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_05.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_05.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_05.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_06.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_06.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_06.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_06.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_stormtrooper_m.py b/scripts/object/mobile/dressed_stormtrooper_m.py index ccad8904..961975a9 100644 --- a/scripts/object/mobile/dressed_stormtrooper_m.py +++ b/scripts/object/mobile/dressed_stormtrooper_m.py @@ -1,4 +1,20 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk','Rifles'] + lootPoolChances_1 = [90,70] + lootGroupChance_1 = 90 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['Colorcrystals'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 20 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + lootPoolNames_3 = ['Rareloot'] + lootPoolChances_3 = [100] + lootGroupChance_3 = 1 + object.addToLootGroups(lootPoolNames_3,lootPoolChances_3,lootGroupChance_3) + + return \ No newline at end of file diff --git a/scripts/radial/npc/corpse.py b/scripts/radial/npc/corpse.py new file mode 100644 index 00000000..3155798a --- /dev/null +++ b/scripts/radial/npc/corpse.py @@ -0,0 +1,16 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + radials.clear() + radials.add(RadialOptions(0, 36, 0, 'Loot')) + + return + +def handleSelection(core, owner, target, option): + if option == 36 and target: + core.lootService.handleLootRequest(owner,target) + if option == 15 and target: + core.objectService.destroyObject(target) + return + \ No newline at end of file diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index ee415959..3001915f 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -60,7 +60,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=3) +@Persistent(version=4) public class TangibleObject extends SWGObject { // TODO: Thread safety @@ -86,6 +86,8 @@ public class TangibleObject extends SWGObject { //private TreeSet> lootSpecification = new TreeSet>(); private List lootGroups = new ArrayList(); + private boolean looted = false; + @NotPersistent private TangibleObject killer = null; @@ -463,6 +465,14 @@ public class TangibleObject extends SWGObject { this.lootGroups.add(lootGroup); } + public boolean isLooted() { + return looted; + } + + public void setLooted(boolean looted) { + this.looted = looted; + } + @Override public void sendBaselines(Client destination) { diff --git a/src/services/DevService.java b/src/services/DevService.java index 3b303a8a..f6b387be 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -996,14 +996,26 @@ public class DevService implements INetworkDispatch { return; case 111: - SWGObject spawned = core.staticService.spawnObject("object/mobile/shared_tusken_raider.iff", "tatooine", 0L, 3522F, 4F, -4801F, 0.70F, 0.71F); - core.lootService.handleLootRequest(player,(TangibleObject)spawned); + + CreatureObject spawned2 = core.spawnService.spawnCreature("object/mobile/shared_tusken_raider.iff", "tatooine", 0, player.getPosition().x, player.getPosition().y, player.getPosition().z, 1, 0, 1, 0, 5); + // core.spawnService.spawnCreature(arg1, actor.getPlanet().getName(), 0, pos.x, pos.y, pos.z, 1, 0, 1, 0, int(arg2)) + //SWGObject spawned = core.staticService.spawnObject("object/mobile/shared_tusken_raider.iff", "tatooine", 0L, 3522F, 4F, -4801F, 0.70F, 0.71F); + //CreatureObject spawned2 = (CreatureObject) spawned; +// spawned2.setLevel((short)5); +// spawned2.setCombatFlag((byte)1); +// spawned2.setStateBitmask(1); +// spawned2.setOptionsBitmask(128); + + //core.lootService.handleLootRequest(player,(TangibleObject)spawned2); break; case 112: - SWGObject spawned2 = core.staticService.spawnObject("object/mobile/shared_krayt_dragon.iff", "tatooine", 0L, 3512F, 4F, -4801F, 0.70F, 0.71F); + SWGObject spawned3 = core.staticService.spawnObject("object/mobile/shared_krayt_dragon.iff", "tatooine", 0L, 3512F, 4F, -4801F, 0.70F, 0.71F); - core.lootService.handleLootRequest(player,(TangibleObject)spawned2); +// pos = actor.getWorldPosition() +// core.spawnService.spawnCreature(arg1, actor.getPlanet().getName(), 0, pos.x, pos.y, pos.z, 1, 0, 1, 0, int(arg2)) +// + core.lootService.handleLootRequest(player,(TangibleObject)spawned3); break; case 120: diff --git a/src/services/LootService.java b/src/services/LootService.java index d405e95d..2b38bf74 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -58,7 +58,6 @@ public class LootService implements INetworkDispatch { public LootService(NGECore core) { this.core = core; - //core.commandService.registerCommand(""); } @Override @@ -73,37 +72,19 @@ public class LootService implements INetworkDispatch { public void handleLootRequest(CreatureObject requester, TangibleObject lootedObject) { + if (lootedObject.isLooted()) + return; + if (requester.getCustomName().contains("Kun")){ requester.setCashCredits(requester.getCashCredits()+1); - requester.sendSystemMessage("You looted 1 lousy credit.", (byte)1); + requester.sendSystemMessage("You looted 1 credit.", (byte)1); return; } LootRollSession lootRollSession = new LootRollSession(requester); - String lootedObjectType = "Tangible"; - if (lootedObject instanceof CreatureObject) - lootedObjectType = "Creature"; - - // Credit drop is depending on the CL of the looted CreatureObject - // or if explicitely assigned in the .py script - int lootedCredits = 0; - if (lootedObjectType.equals("Creature")){ - CreatureObject lootedCreature = (CreatureObject) lootedObject; - int creatureCL = lootedCreature.getLevel(); - creatureCL = 90; - int maximalCredits = (int)Math.floor(4*creatureCL + creatureCL*creatureCL*4/100); - int minimalCredits = (int)Math.floor(creatureCL*2 + maximalCredits/2); - int spanOfCredits = maximalCredits - minimalCredits; - lootedCredits = minimalCredits + new Random().nextInt(spanOfCredits); - requester.sendSystemMessage("You looted " + lootedCredits + " credits.", (byte)1); - } - - if (lootedObjectType.equals("Tangible")){ - // This is for chests etc. - // Check the py script - } - + handleCreditDrop(requester,lootedObject); + CreatureObject lootedCreature = (CreatureObject) lootedObject; //TreeSet> lootSpec = lootedObject.getLootSpecification(); @@ -141,6 +122,8 @@ public class LootService implements INetworkDispatch { requesterInventory.add(droppedItem); } + + lootedObject.setLooted(true); // ToDo: Group loot settings etc. actual loot chance was lootgroupchance*lootchance @@ -271,8 +254,8 @@ public class LootService implements INetworkDispatch { droppedItem.setAttachment("LootItemName", itemName); handleCustomDropName(droppedItem,customName); handleStats(droppedItem); - setCustomization(droppedItem); - handleSpecialItems(droppedItem); + setCustomization(droppedItem, itemName); + handleSpecialItems(droppedItem,itemName); lootRollSession.addDroppedItem(droppedItem); } @@ -293,10 +276,19 @@ public class LootService implements INetworkDispatch { return droppedItem; } - private void setCustomization(TangibleObject droppedItem) { + private void setCustomization(TangibleObject droppedItem,String itemName) { // Example color crystal - droppedItem.setCustomizationVariable("/private/index_color_1", (byte) new Random().nextInt(7)); // 4 blue + if (itemName.contains("colorcrystal")) { + System.out.println("colorcrystal"); + droppedItem.setCustomizationVariable("/private/index_color_1", (byte) new Random().nextInt(11)); + } + + // Example power crystal + if (itemName.contains("powercrystal")) { + System.out.println("powercrystal"); + droppedItem.setCustomizationVariable("/private/index_color_1", (byte) 0x21); // 0x1F + } // More general // String path = "scripts/loot/lootItems/"+droppedItem.getCustomName().toLowerCase(); @@ -309,11 +301,11 @@ public class LootService implements INetworkDispatch { // } } - private void handleSpecialItems(TangibleObject droppedItem) { - if (droppedItem.getTemplate().contains("shared_lightsaber_module_krayt_dragon_pearl")){ + private void handleSpecialItems(TangibleObject droppedItem,String itemName) { + if (itemName.contains("kraytpearl")){ handleKraytPearl(droppedItem); } - if (droppedItem.getTemplate().contains("shared_lightsaber_module_force_crystal.iff")){ + if (itemName.contains("powercrystal")){ handlePowerCrystal(droppedItem); } } @@ -326,6 +318,28 @@ public class LootService implements INetworkDispatch { } + private void handleCreditDrop(CreatureObject requester,TangibleObject lootedObject){ + int lootedCredits = 0; + // Credit drop is depending on the CL of the looted CreatureObject + // or if explicitely assigned in the .py script + if (lootedObject instanceof CreatureObject){ + CreatureObject lootedCreature = (CreatureObject) lootedObject; + int creatureCL = lootedCreature.getLevel(); + creatureCL = 90; + int maximalCredits = (int)Math.floor(4*creatureCL + creatureCL*creatureCL*4/100); + int minimalCredits = (int)Math.floor(creatureCL*2 + maximalCredits/2); + int spanOfCredits = maximalCredits - minimalCredits; + lootedCredits = minimalCredits + new Random().nextInt(spanOfCredits); + requester.setCashCredits(requester.getCashCredits()+lootedCredits); + requester.sendSystemMessage("You looted " + lootedCredits + " credits.", (byte)1); + } + + if (lootedObject instanceof TangibleObject){ + // This is for chests etc. + // Check the py script + } + } + // ************* Special items ************ private void handleKraytPearl(TangibleObject droppedItem) { diff --git a/src/services/spawn/SpawnService.java b/src/services/spawn/SpawnService.java index bd0aadd1..a9ef4522 100644 --- a/src/services/spawn/SpawnService.java +++ b/src/services/spawn/SpawnService.java @@ -166,6 +166,8 @@ public class SpawnService { AIActor actor = new AIActor(creature, creature.getPosition(), scheduler); creature.setAttachment("AI", actor); actor.setMobileTemplate(mobileTemplate); + + creature.setAttachment("radial_filename", "npc/corpse"); if(cell == null) { From ce8bb06629bf812c186491da177ffa4b64ea258f Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 10 Apr 2014 09:16:55 +0100 Subject: [PATCH 54/68] Removed options.cfg from gitignore If this is removed, then people don't download it on their first clone of the core. The best option is to either not modify it, uncheck it before committing things or add to the local ignore. --- .gitignore | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 89882a7e..8560d241 100644 --- a/.gitignore +++ b/.gitignore @@ -61,9 +61,6 @@ odb/resourcehistory/je.info.* odb/resourceroots/je.info.* odb/resources/je.info.* -# PSWG Configs -options.cfg - # External tool builders .externalToolBuilders/ @@ -214,4 +211,4 @@ pip-log.txt ############# ## PyCharm ############# -.idea \ No newline at end of file +.idea From 351910c04afe7530bb45e0ffe561b49b8d439158 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 10 Apr 2014 10:18:20 +0100 Subject: [PATCH 55/68] Various command bugfixes --- scripts/commands/afk.py | 13 -- src/services/combat/CombatService.java | 5 +- src/services/command/BaseSWGCommand.java | 183 +++++++++++++++++++++ src/services/command/CombatCommand.java | 194 +---------------------- src/services/command/CommandService.java | 93 ++++------- 5 files changed, 217 insertions(+), 271 deletions(-) delete mode 100644 scripts/commands/afk.py diff --git a/scripts/commands/afk.py b/scripts/commands/afk.py deleted file mode 100644 index 68670816..00000000 --- a/scripts/commands/afk.py +++ /dev/null @@ -1,13 +0,0 @@ -from resources.datatables import PlayerFlags -import sys - -def setup(): - return - -def run(core, actor, target, commandString): - command = core.commandService.getCommandByName("toggleawayfromkeyboard") - - if command: - core.commandService.processCommand(actor, target, command, 0, commandString) - - return diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 08a6cee5..712c5ca0 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -52,6 +52,7 @@ import resources.objects.waypoint.WaypointObject; import resources.objects.weapon.WeaponObject; import services.ai.AIActor; import services.combat.CombatEvents.DamageTaken; +import services.command.BaseSWGCommand; import services.command.CombatCommand; import services.sui.SUIService.MessageBoxType; import services.sui.SUIWindow; @@ -400,7 +401,7 @@ public class CombatService implements INetworkDispatch { } - private void sendCombatPackets(CreatureObject attacker, TangibleObject target, WeaponObject weapon, CombatCommand command, int actionCounter, float damage, int armorAbsorbed, int hitType) { + private void sendCombatPackets(CreatureObject attacker, TangibleObject target, WeaponObject weapon, BaseSWGCommand command, int actionCounter, float damage, int armorAbsorbed, int hitType) { String animationStr = command.getRandomAnimation(weapon); CombatAction combatAction = new CombatAction(CRC.StringtoCRC(animationStr), attacker.getObjectID(), weapon.getObjectID(), target.getObjectID(), command.getCommandCRC()); @@ -429,7 +430,7 @@ public class CombatService implements INetworkDispatch { } - private void sendHealPackets(CreatureObject attacker, CreatureObject target, WeaponObject weapon, CombatCommand command, int actionCounter) { + private void sendHealPackets(CreatureObject attacker, CreatureObject target, WeaponObject weapon, BaseSWGCommand command, int actionCounter) { CombatAction combatAction = new CombatAction(CRC.StringtoCRC(command.getDefaultAnimations()[0]), attacker.getObjectID(), weapon.getObjectID(), target.getObjectID(), command.getCommandCRC()); ObjControllerMessage objController = new ObjControllerMessage(0x1B, combatAction); diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index 0448a8ea..f228aa16 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -27,6 +27,9 @@ import engine.resources.common.CRC; import java.util.ArrayList; import java.util.List; +import java.util.Random; + +import resources.objects.weapon.WeaponObject; public class BaseSWGCommand implements Cloneable { @@ -55,6 +58,21 @@ public class BaseSWGCommand implements Cloneable { private Byte[] invalidPostures; private Long[] invalidStates; + private String[] defaultAnimations = new String[]{}; + private String[] oneHandedAnimations = new String[]{}; + private String[] twoHandedAnimations = new String[]{}; + private String[] polearmAnimations = new String[]{}; + private String[] unarmedAnimations = new String[]{}; + private String[] pistolAnimations = new String[]{}; + private String[] carbineAnimations = new String[]{}; + private String[] lightRifleAnimations = new String[]{}; + private String[] rifleAnimations = new String[]{}; + private String[] heavyWpnAnimations = new String[]{}; + private String[] oneHandedLSAnimations = new String[]{}; + private String[] twoHandedLSAnimations = new String[]{}; + private String[] polearmLSAnimations = new String[]{}; + private String[] thrownAnimations = new String[]{}; + public BaseSWGCommand(String commandName) { setCommandName(commandName); setCommandCRC(CRC.StringtoCRC(commandName)); @@ -362,4 +380,169 @@ public class BaseSWGCommand implements Cloneable { this.warmupTime = warmupTime; } + public String[] getDefaultAnimations() { + return defaultAnimations; + } + + public void setDefaultAnimations(String[] defaultAnimations) { + this.defaultAnimations = defaultAnimations; + } + + public String[] getOneHandedAnimations() { + return oneHandedAnimations; + } + + public void setOneHandedAnimations(String[] oneHandedAnimations) { + this.oneHandedAnimations = oneHandedAnimations; + } + + public String[] getTwoHandedAnimations() { + return twoHandedAnimations; + } + + public void setTwoHandedAnimations(String[] twoHandedAnimations) { + this.twoHandedAnimations = twoHandedAnimations; + } + + public String[] getPolearmAnimations() { + return polearmAnimations; + } + + public void setPolearmAnimations(String[] polearmAnimations) { + this.polearmAnimations = polearmAnimations; + } + + public String[] getUnarmedAnimations() { + return unarmedAnimations; + } + + public void setUnarmedAnimations(String[] unarmedAnimations) { + this.unarmedAnimations = unarmedAnimations; + } + + public String[] getPistolAnimations() { + return pistolAnimations; + } + + public void setPistolAnimations(String[] pistolAnimations) { + this.pistolAnimations = pistolAnimations; + } + + public String[] getCarbineAnimations() { + return carbineAnimations; + } + + public void setCarbineAnimations(String[] carbineAnimations) { + this.carbineAnimations = carbineAnimations; + } + + public String[] getLightRifleAnimations() { + return lightRifleAnimations; + } + + public void setLightRifleAnimations(String[] lightRifleAnimations) { + this.lightRifleAnimations = lightRifleAnimations; + } + + public String[] getRifleAnimations() { + return rifleAnimations; + } + + public void setRifleAnimations(String[] rifleAnimations) { + this.rifleAnimations = rifleAnimations; + } + + public String[] getHeavyWpnAnimations() { + return heavyWpnAnimations; + } + + public void setHeavyWpnAnimations(String[] heavyWpnAnimations) { + this.heavyWpnAnimations = heavyWpnAnimations; + } + + public String[] getOneHandedLSAnimations() { + return oneHandedLSAnimations; + } + + public void setOneHandedLSAnimations(String[] oneHandedLSAnimations) { + this.oneHandedLSAnimations = oneHandedLSAnimations; + } + + public String[] getTwoHandedLSAnimations() { + return twoHandedLSAnimations; + } + + public void setTwoHandedLSAnimations(String[] twoHandedLSAnimations) { + this.twoHandedLSAnimations = twoHandedLSAnimations; + } + + public String[] getPolearmLSAnimations() { + return polearmLSAnimations; + } + + public void setPolearmLSAnimations(String[] polearmLSAnimations) { + this.polearmLSAnimations = polearmLSAnimations; + } + + public String[] getThrownAnimations() { + return thrownAnimations; + } + + public void setThrownAnimations(String[] thrownAnimations) { + this.thrownAnimations = thrownAnimations; + } + + public String getRandomAnimation(WeaponObject weapon) { + int weaponType = weapon.getWeaponType(); + String[] animations; + + switch (weaponType) { + case 0: + animations = rifleAnimations; + break; + case 1: + animations = carbineAnimations; + break; + case 2: + animations = pistolAnimations; + break; + case 3: + animations = heavyWpnAnimations; + break; + case 4: + animations = oneHandedAnimations; + break; + case 5: + animations = twoHandedAnimations; + break; + case 6: + animations = defaultAnimations; + break; + case 7: + animations = polearmAnimations; + break; + case 8: + animations = thrownAnimations; + break; + case 9: + animations = oneHandedLSAnimations; + break; + case 10: + animations = twoHandedLSAnimations; + break; + case 11: + animations = polearmLSAnimations; + break; + default: + animations = defaultAnimations; + break; + } + + if (animations.length == 0) { + animations = defaultAnimations; + } + + return animations[new Random().nextInt(animations.length)]; + } + } diff --git a/src/services/command/CombatCommand.java b/src/services/command/CombatCommand.java index cab1f4ef..77ecde00 100644 --- a/src/services/command/CombatCommand.java +++ b/src/services/command/CombatCommand.java @@ -21,28 +21,11 @@ ******************************************************************************/ package services.command; -import java.util.Random; - -import resources.objects.weapon.WeaponObject; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; public class CombatCommand extends BaseSWGCommand { - private String[] defaultAnimations = new String[]{}; - private String[] oneHandedAnimations = new String[]{}; - private String[] twoHandedAnimations = new String[]{}; - private String[] polearmAnimations = new String[]{}; - private String[] unarmedAnimations = new String[]{}; - private String[] pistolAnimations = new String[]{}; - private String[] carbineAnimations = new String[]{}; - private String[] lightRifleAnimations = new String[]{}; - private String[] rifleAnimations = new String[]{}; - private String[] heavyWpnAnimations = new String[]{}; - private String[] oneHandedLSAnimations = new String[]{}; - private String[] twoHandedLSAnimations = new String[]{}; - private String[] polearmLSAnimations = new String[]{}; - private String[] thrownAnimations = new String[]{}; private byte validTargetType; private byte hitType; private byte healType; @@ -67,16 +50,12 @@ public class CombatCommand extends BaseSWGCommand { private int damageType, elementalType, elementalValue; private String performanceSpam; private byte hitSpam; - //private float cooldown; private String delayAttackEggTemplate; private String delayAttackParticle; private float initialAttackDelay; private float delayAttackInterval; private int delayAttackLoops; private int delayAttackEggPosition; - //private String cooldownGroup; - //private float executeTime; - //private float warmupTime; private float vigorCost; // for commando kill meter and bm specials private float criticalChance; private int attack_rolls; @@ -166,119 +145,7 @@ public class CombatCommand extends BaseSWGCommand { e.printStackTrace(); } } - - public String[] getDefaultAnimations() { - return defaultAnimations; - } - - public void setDefaultAnimations(String[] defaultAnimations) { - this.defaultAnimations = defaultAnimations; - } - - public String[] getOneHandedAnimations() { - return oneHandedAnimations; - } - - public void setOneHandedAnimations(String[] oneHandedAnimations) { - this.oneHandedAnimations = oneHandedAnimations; - } - - public String[] getTwoHandedAnimations() { - return twoHandedAnimations; - } - - public void setTwoHandedAnimations(String[] twoHandedAnimations) { - this.twoHandedAnimations = twoHandedAnimations; - } - - public String[] getPolearmAnimations() { - return polearmAnimations; - } - - public void setPolearmAnimations(String[] polearmAnimations) { - this.polearmAnimations = polearmAnimations; - } - - public String[] getUnarmedAnimations() { - return unarmedAnimations; - } - - public void setUnarmedAnimations(String[] unarmedAnimations) { - this.unarmedAnimations = unarmedAnimations; - } - - public String[] getPistolAnimations() { - return pistolAnimations; - } - - public void setPistolAnimations(String[] pistolAnimations) { - this.pistolAnimations = pistolAnimations; - } - - public String[] getCarbineAnimations() { - return carbineAnimations; - } - - public void setCarbineAnimations(String[] carbineAnimations) { - this.carbineAnimations = carbineAnimations; - } - - public String[] getLightRifleAnimations() { - return lightRifleAnimations; - } - - public void setLightRifleAnimations(String[] lightRifleAnimations) { - this.lightRifleAnimations = lightRifleAnimations; - } - - public String[] getRifleAnimations() { - return rifleAnimations; - } - - public void setRifleAnimations(String[] rifleAnimations) { - this.rifleAnimations = rifleAnimations; - } - - public String[] getHeavyWpnAnimations() { - return heavyWpnAnimations; - } - - public void setHeavyWpnAnimations(String[] heavyWpnAnimations) { - this.heavyWpnAnimations = heavyWpnAnimations; - } - - public String[] getOneHandedLSAnimations() { - return oneHandedLSAnimations; - } - - public void setOneHandedLSAnimations(String[] oneHandedLSAnimations) { - this.oneHandedLSAnimations = oneHandedLSAnimations; - } - - public String[] getTwoHandedLSAnimations() { - return twoHandedLSAnimations; - } - - public void setTwoHandedLSAnimations(String[] twoHandedLSAnimations) { - this.twoHandedLSAnimations = twoHandedLSAnimations; - } - - public String[] getPolearmLSAnimations() { - return polearmLSAnimations; - } - - public void setPolearmLSAnimations(String[] polearmLSAnimations) { - this.polearmLSAnimations = polearmLSAnimations; - } - - public String[] getThrownAnimations() { - return thrownAnimations; - } - - public void setThrownAnimations(String[] thrownAnimations) { - this.thrownAnimations = thrownAnimations; - } - + public byte getValidTargetType() { return validTargetType; } @@ -550,64 +417,7 @@ public class CombatCommand extends BaseSWGCommand { public void setHitSpam(byte hitSpam) { this.hitSpam = hitSpam; } - - public String getRandomAnimation(WeaponObject weapon) { - - int weaponType = weapon.getWeaponType(); - String[] animations; - - switch(weaponType) { - - case 0: - animations = rifleAnimations; - break; - case 1: - animations = carbineAnimations; - break; - case 2: - animations = pistolAnimations; - break; - case 3: - animations = heavyWpnAnimations; - break; - case 4: - animations = oneHandedAnimations; - break; - case 5: - animations = twoHandedAnimations; - break; - case 6: - animations = defaultAnimations; - break; - case 7: - animations = polearmAnimations; - break; - case 8: - animations = thrownAnimations; - break; - case 9: - animations = oneHandedLSAnimations; - break; - case 10: - animations = twoHandedLSAnimations; - break; - case 11: - animations = polearmLSAnimations; - break; - - default: - animations = defaultAnimations; - break; - - } - - if(animations.length == 0) - animations = defaultAnimations; - - return animations[new Random().nextInt(animations.length)]; - - } - + public String getDelayAttackEggTemplate() { return delayAttackEggTemplate; } diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index efb0fd84..ad76e992 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -27,7 +27,6 @@ import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; import main.NGECore; @@ -43,7 +42,6 @@ import engine.resources.scene.Point3D; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.common.*; -import resources.datatables.StateStatus; import protocol.swg.ObjControllerMessage; import protocol.swg.objectControllerObjects.CommandEnqueue; import protocol.swg.objectControllerObjects.CommandEnqueueRemove; @@ -56,6 +54,7 @@ import resources.objects.weapon.WeaponObject; public class CommandService implements INetworkDispatch { private Vector commandLookup = new Vector(); + private ConcurrentHashMap aliases = new ConcurrentHashMap(); private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); private NGECore core; @@ -63,6 +62,10 @@ public class CommandService implements INetworkDispatch { this.core = core; } + public void registerAlias(String name, String target) { + aliases.put(CRC.StringtoCRC(name.toLowerCase()), CRC.StringtoCRC(target.toLowerCase())); + } + public boolean callCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { if (actor == null) { return false; @@ -109,9 +112,7 @@ public class CommandService implements INetworkDispatch { } switch (command.getTargetType()) { - case 0: // Target Not Used For This Command or Self - target = actor; - + case 0: // Target Not Used For This Command break; case 1: // Other Only if (target == null || target == actor) { @@ -208,26 +209,21 @@ public class CommandService implements INetworkDispatch { } long warmupTime = (long) (command.getWarmupTime() * 1000F); - final CreatureObject actorObject = actor; - final SWGObject targetObject = target; - if (warmupTime != 0) { - scheduler.schedule(new Runnable() { - - @Override - public void run() { - processCommand(actorObject, targetObject, command, actionCounter, commandArgs); - } - - }, warmupTime, TimeUnit.MILLISECONDS); - } else { - processCommand(actor, target, command, actionCounter, commandArgs); + try { + Thread.sleep(warmupTime); + } catch (InterruptedException e) { + e.printStackTrace(); } + processCommand(actor, target, command, actionCounter, commandArgs); + return true; } public void callCommand(SWGObject actor, String commandName, SWGObject target, String commandArgs) { + System.out.println("CommandService: void callCommand(actor, commandName, target, commandArgs): This shouldn't be called anymore."); + if (actor == null) return; @@ -284,15 +280,7 @@ public class CommandService implements INetworkDispatch { sub += 5; } - boolean isCombatCommand = false; - - System.out.println(((String) visitor.getObject(i, 85-sub))); - - if(((String) visitor.getObject(i, 3)).equals("failSpecialAttack") || ((String) visitor.getObject(i, 85-sub)).equals("defaultattack")) - isCombatCommand = true; - - - if (hasCharacterAbility || isCombatCommand) { + if (hasCharacterAbility) { CombatCommand command = new CombatCommand(name.toLowerCase()); commandLookup.add(command); return command; @@ -348,13 +336,7 @@ public class CommandService implements INetworkDispatch { sub += 5; } - boolean isCombatCommand = false; - - if(((String) visitor.getObject(i, 3)).equals("failSpecialAttack") || ((String) visitor.getObject(i, 85-sub)).equals("defaultattack")) - isCombatCommand = true; - - // "isCombatCommand" needs to be changed so that non-combat commands that are flagged to added to a combat queue are not considered combat commands - if (hasCharacterAbility || isCombatCommand) { + if (hasCharacterAbility) { CombatCommand command = new CombatCommand(commandName); commandLookup.add(command); return command; @@ -376,25 +358,21 @@ public class CommandService implements INetworkDispatch { public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); + if (command instanceof CombatCommand) { processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); } else { if (FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName() + ".py")) { core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandArgs); } + + if (FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) { + core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "run", core, actor, target, commandArgs); + } } } public void processCombatCommand(CreatureObject attacker, SWGObject target, CombatCommand command, int actionCounter, String commandArgs) { - - // Check if the person has access to this ability. - // Abilities (inc expertise ones) are added automatically as they level - // by reading the datatables. - // disabled for now (breaks all combat) - //if (!attacker.hasAbility(command.getCommandName())) { - // return; - //} - if(FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) { core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "setup", core, attacker, target, command); @@ -502,7 +480,6 @@ public class CommandService implements INetworkDispatch { @Override public void handlePacket(IoSession session, IoBuffer data) throws Exception { - data.order(ByteOrder.LITTLE_ENDIAN); Client client = core.getClient(session); @@ -514,7 +491,13 @@ public class CommandService implements INetworkDispatch { CommandEnqueue commandEnqueue = new CommandEnqueue(); commandEnqueue.deserialize(data); - BaseSWGCommand command = getCommandByCRC(commandEnqueue.getCommandCRC()); + int commandCRC = commandEnqueue.getCommandCRC(); + + if (aliases.containsKey(commandEnqueue.getCommandCRC())) { + commandCRC = aliases.get(commandCRC); + } + + BaseSWGCommand command = getCommandByCRC(commandCRC); if (command == null) { //System.out.println("Unknown Command CRC: " + commandEnqueue.getCommandCRC()); @@ -553,26 +536,8 @@ public class CommandService implements INetworkDispatch { } - public CombatCommand registerCombatCommand(String name) { - BaseSWGCommand command = getCommandByName(name); - - if (command == null) { - return null; - } - - if (command instanceof CombatCommand) { - return (CombatCommand) command; - } else { - System.out.println("Warning: Forced to make non-combat command " + name + " a combat command."); - commandLookup.remove(command); - CombatCommand combatCommand = new CombatCommand(name.toLowerCase()); - commandLookup.add(combatCommand); - return combatCommand; - } - } - + public BaseSWGCommand registerCombatCommand(String name) { return getCommandByName(name); } public BaseSWGCommand registerCommand(String name) { return getCommandByName(name); } public BaseSWGCommand registerGmCommand(String name) { return getCommandByName(name); } - public void registerAlias(String name, String target) { } } From e91362a12f83c47f69054a74ce0683758ac4ce8e Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 10 Apr 2014 11:52:09 +0100 Subject: [PATCH 56/68] Fixed most warnings --- src/protocol/swg/AttributeListMessage.java | 1 - .../CollectionServerFirstListResponse.java | 2 -- src/protocol/swg/CommPlayerMessage.java | 1 - src/protocol/swg/GuildRequestMessage.java | 3 -- src/protocol/swg/GuildResponseMessage.java | 5 --- src/protocol/swg/ObjControllerMessage.java | 1 - .../swg/ResourceListForSurveyMessage.java | 4 +-- src/protocol/swg/SurveyMapUpdateMessage.java | 2 +- src/protocol/swg/chat/ChatEnterRoomById.java | 1 - src/protocol/swg/chat/ChatRoomList.java | 1 - .../BiographyUpdate.java | 4 --- .../objectControllerObjects/CombatSpam.java | 6 ++-- .../ImageDesignMessage.java | 3 -- .../MissionListRequest.java | 3 -- .../NpcConversationMessage.java | 1 - .../NpcConversationOptions.java | 5 +-- .../SetProfessionTemplate.java | 2 -- .../objectControllerObjects/ShowFlyText.java | 1 - .../objectControllerObjects/ShowLootBox.java | 2 -- .../StartNpcConversation.java | 1 - .../StopNpcConversation.java | 1 - src/resources/common/Cooldown.java | 2 -- src/resources/common/IDAttribute.java | 2 -- src/resources/common/ThreadMonitor.java | 3 +- src/resources/objects/Buff.java | 2 -- .../objects/building/BuildingObject.java | 2 -- .../creature/CreatureMessageBuilder.java | 1 - .../objects/creature/CreatureObject.java | 7 +---- .../objects/player/PlayerMessageBuilder.java | 2 -- .../objects/player/PlayerObject.java | 1 - .../objects/resource/GalacticResource.java | 3 -- .../resource/ResourceConcentration.java | 2 +- .../resource/ResourceContainerObject.java | 2 ++ .../objects/tangible/TangibleObject.java | 3 -- src/services/BuffService.java | 1 - src/services/ConversationService.java | 2 +- src/services/EntertainmentService.java | 10 ------ src/services/EquipmentService.java | 3 -- src/services/GroupService.java | 1 - src/services/InstanceService.java | 1 - src/services/MissionService.java | 2 -- src/services/SurveyService.java | 13 -------- src/services/TerrainService.java | 6 ---- src/services/ai/AIActor.java | 2 -- src/services/ai/AIService.java | 3 -- src/services/ai/states/RetreatState.java | 2 -- src/services/chat/ChatService.java | 5 --- src/services/combat/CombatCommands.java | 1 - src/services/combat/CombatService.java | 2 -- src/services/command/BaseSWGCommand.java | 5 --- src/services/command/CommandService.java | 31 +++---------------- src/services/gcw/FactionService.java | 1 - src/services/guild/GuildService.java | 1 - src/services/housing/HousingService.java | 5 --- src/services/resources/ResourceService.java | 1 - src/services/spawn/DynamicSpawnArea.java | 1 - src/services/spawn/MobileTemplate.java | 2 -- src/services/spawn/SpawnArea.java | 1 - src/services/spawn/SpawnService.java | 2 -- src/services/spawn/StaticSpawnArea.java | 1 - src/services/sui/SUIService.java | 1 - src/services/travel/TravelService.java | 1 - src/tools/CharonPacketUtils.java | 2 +- 63 files changed, 18 insertions(+), 173 deletions(-) diff --git a/src/protocol/swg/AttributeListMessage.java b/src/protocol/swg/AttributeListMessage.java index ce9cf865..55721a52 100644 --- a/src/protocol/swg/AttributeListMessage.java +++ b/src/protocol/swg/AttributeListMessage.java @@ -22,7 +22,6 @@ package protocol.swg; import java.nio.ByteOrder; -import java.util.Map.Entry; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.buffer.SimpleBufferAllocator; diff --git a/src/protocol/swg/CollectionServerFirstListResponse.java b/src/protocol/swg/CollectionServerFirstListResponse.java index 163627da..0373dc5a 100644 --- a/src/protocol/swg/CollectionServerFirstListResponse.java +++ b/src/protocol/swg/CollectionServerFirstListResponse.java @@ -25,8 +25,6 @@ import java.nio.ByteOrder; import java.util.Map; import java.util.Map.Entry; -import main.NGECore; - import org.apache.mina.core.buffer.IoBuffer; import services.collections.ServerFirst; diff --git a/src/protocol/swg/CommPlayerMessage.java b/src/protocol/swg/CommPlayerMessage.java index 631d4c1c..59648d21 100644 --- a/src/protocol/swg/CommPlayerMessage.java +++ b/src/protocol/swg/CommPlayerMessage.java @@ -27,7 +27,6 @@ import org.apache.mina.core.buffer.IoBuffer; import resources.common.Console; import resources.common.StringUtilities; -import engine.resources.common.CRC; public class CommPlayerMessage extends SWGMessage { diff --git a/src/protocol/swg/GuildRequestMessage.java b/src/protocol/swg/GuildRequestMessage.java index 211536e4..d9f1f368 100644 --- a/src/protocol/swg/GuildRequestMessage.java +++ b/src/protocol/swg/GuildRequestMessage.java @@ -2,9 +2,6 @@ package protocol.swg; import org.apache.mina.core.buffer.IoBuffer; -import resources.common.Console; -import resources.common.StringUtilities; - public class GuildRequestMessage extends SWGMessage { private long characterId; diff --git a/src/protocol/swg/GuildResponseMessage.java b/src/protocol/swg/GuildResponseMessage.java index e0c8eb42..f98e6713 100644 --- a/src/protocol/swg/GuildResponseMessage.java +++ b/src/protocol/swg/GuildResponseMessage.java @@ -25,11 +25,6 @@ import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; -import resources.common.Console; -import resources.common.StringUtilities; -import resources.guild.Guild; -import resources.objects.creature.CreatureObject; - public class GuildResponseMessage extends SWGMessage { private long player; diff --git a/src/protocol/swg/ObjControllerMessage.java b/src/protocol/swg/ObjControllerMessage.java index a8b3d10a..b3aa94eb 100644 --- a/src/protocol/swg/ObjControllerMessage.java +++ b/src/protocol/swg/ObjControllerMessage.java @@ -32,7 +32,6 @@ import protocol.swg.objectControllerObjects.DataTransform; import protocol.swg.objectControllerObjects.DataTransformWithParent; import protocol.swg.objectControllerObjects.ObjControllerObject; import protocol.swg.objectControllerObjects.UnknownObjController; -import resources.common.StringUtilities; public class ObjControllerMessage extends SWGMessage { diff --git a/src/protocol/swg/ResourceListForSurveyMessage.java b/src/protocol/swg/ResourceListForSurveyMessage.java index 5263255c..e1c9c886 100644 --- a/src/protocol/swg/ResourceListForSurveyMessage.java +++ b/src/protocol/swg/ResourceListForSurveyMessage.java @@ -34,8 +34,6 @@ import protocol.swg.SWGMessage; import resources.objects.creature.CreatureObject; import resources.objects.resource.GalacticResource; import resources.objects.tangible.TangibleObject; -import resources.objects.tool.SurveyTool; - public class ResourceListForSurveyMessage extends SWGMessage { @@ -71,7 +69,7 @@ public class ResourceListForSurveyMessage extends SWGMessage { Vector planetVector = core.resourceService.getSpawnedResourcesByPlanetAndType(surveyor.getPlanetId(),generalType); - resourceList = new ArrayList(planetVector); + resourceList = new ArrayList(planetVector); } diff --git a/src/protocol/swg/SurveyMapUpdateMessage.java b/src/protocol/swg/SurveyMapUpdateMessage.java index 7ea62318..21a2728f 100644 --- a/src/protocol/swg/SurveyMapUpdateMessage.java +++ b/src/protocol/swg/SurveyMapUpdateMessage.java @@ -63,7 +63,7 @@ public class SurveyMapUpdateMessage extends SWGMessage { highestConcentration = concentration; } } - int size = buffer.position(); + //int size = buffer.position(); buffer.flip(); } diff --git a/src/protocol/swg/chat/ChatEnterRoomById.java b/src/protocol/swg/chat/ChatEnterRoomById.java index 15e9bb0c..b6715b09 100644 --- a/src/protocol/swg/chat/ChatEnterRoomById.java +++ b/src/protocol/swg/chat/ChatEnterRoomById.java @@ -24,7 +24,6 @@ package protocol.swg.chat; import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.SWGMessage; -import resources.common.StringUtilities; public class ChatEnterRoomById extends SWGMessage { diff --git a/src/protocol/swg/chat/ChatRoomList.java b/src/protocol/swg/chat/ChatRoomList.java index 042d930a..b183b140 100644 --- a/src/protocol/swg/chat/ChatRoomList.java +++ b/src/protocol/swg/chat/ChatRoomList.java @@ -29,7 +29,6 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.SWGMessage; -import resources.common.StringUtilities; import services.chat.ChatRoom; public class ChatRoomList extends SWGMessage { diff --git a/src/protocol/swg/objectControllerObjects/BiographyUpdate.java b/src/protocol/swg/objectControllerObjects/BiographyUpdate.java index 30e2f1a2..290d4580 100644 --- a/src/protocol/swg/objectControllerObjects/BiographyUpdate.java +++ b/src/protocol/swg/objectControllerObjects/BiographyUpdate.java @@ -25,10 +25,6 @@ import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; -import protocol.swg.ObjControllerMessage; -import resources.common.Console; -import resources.common.StringUtilities; - public class BiographyUpdate extends ObjControllerObject { private long objectId; diff --git a/src/protocol/swg/objectControllerObjects/CombatSpam.java b/src/protocol/swg/objectControllerObjects/CombatSpam.java index 75eaf9cd..fbf836de 100644 --- a/src/protocol/swg/objectControllerObjects/CombatSpam.java +++ b/src/protocol/swg/objectControllerObjects/CombatSpam.java @@ -33,9 +33,9 @@ public class CombatSpam extends ObjControllerObject{ private long attackerId; private long defenderId; private int damage; - private String file; - private String text; - private byte colorFlag; + //private String file; + //private String text; + //private byte colorFlag; private boolean hit = true; private boolean critical = false; private boolean dodge = false; diff --git a/src/protocol/swg/objectControllerObjects/ImageDesignMessage.java b/src/protocol/swg/objectControllerObjects/ImageDesignMessage.java index 8678ec4d..8c99498e 100644 --- a/src/protocol/swg/objectControllerObjects/ImageDesignMessage.java +++ b/src/protocol/swg/objectControllerObjects/ImageDesignMessage.java @@ -21,8 +21,6 @@ ******************************************************************************/ package protocol.swg.objectControllerObjects; -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Vector; @@ -30,7 +28,6 @@ import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ObjControllerMessage; import resources.common.IDAttribute; -import resources.common.StringUtilities; public class ImageDesignMessage extends ObjControllerObject { diff --git a/src/protocol/swg/objectControllerObjects/MissionListRequest.java b/src/protocol/swg/objectControllerObjects/MissionListRequest.java index 7fbe2d02..aacf1bd0 100644 --- a/src/protocol/swg/objectControllerObjects/MissionListRequest.java +++ b/src/protocol/swg/objectControllerObjects/MissionListRequest.java @@ -21,11 +21,8 @@ ******************************************************************************/ package protocol.swg.objectControllerObjects; -import java.nio.ByteOrder; - import org.apache.mina.core.buffer.IoBuffer; -import protocol.swg.ObjControllerMessage; import resources.common.Console; import resources.common.StringUtilities; diff --git a/src/protocol/swg/objectControllerObjects/NpcConversationMessage.java b/src/protocol/swg/objectControllerObjects/NpcConversationMessage.java index 93a05982..12a2d822 100644 --- a/src/protocol/swg/objectControllerObjects/NpcConversationMessage.java +++ b/src/protocol/swg/objectControllerObjects/NpcConversationMessage.java @@ -26,7 +26,6 @@ import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ObjControllerMessage; -import resources.common.ObjControllerOpcodes; import resources.common.OutOfBand; public class NpcConversationMessage extends ObjControllerObject { diff --git a/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java b/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java index b85e42e2..e80a92c6 100644 --- a/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java +++ b/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java @@ -28,17 +28,14 @@ import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ObjControllerMessage; import resources.common.ConversationOption; -import resources.common.ObjControllerOpcodes; public class NpcConversationOptions extends ObjControllerObject { - private long npcId; private long objectId; private Vector conversationOptions = new Vector(); - public NpcConversationOptions(long objectId, long npcId) { + public NpcConversationOptions(long objectId) { this.objectId = objectId; - this.npcId = npcId; } @Override diff --git a/src/protocol/swg/objectControllerObjects/SetProfessionTemplate.java b/src/protocol/swg/objectControllerObjects/SetProfessionTemplate.java index 775a8322..f9c0bb77 100644 --- a/src/protocol/swg/objectControllerObjects/SetProfessionTemplate.java +++ b/src/protocol/swg/objectControllerObjects/SetProfessionTemplate.java @@ -26,8 +26,6 @@ import java.nio.ByteBuffer; import org.apache.mina.core.buffer.IoBuffer; -import engine.resources.common.Utilities; - public class SetProfessionTemplate extends ObjControllerObject { private String profession; diff --git a/src/protocol/swg/objectControllerObjects/ShowFlyText.java b/src/protocol/swg/objectControllerObjects/ShowFlyText.java index f47bbbb2..0413b576 100644 --- a/src/protocol/swg/objectControllerObjects/ShowFlyText.java +++ b/src/protocol/swg/objectControllerObjects/ShowFlyText.java @@ -27,7 +27,6 @@ import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ObjControllerMessage; import resources.common.RGB; -import resources.common.StringUtilities; public class ShowFlyText extends ObjControllerObject { diff --git a/src/protocol/swg/objectControllerObjects/ShowLootBox.java b/src/protocol/swg/objectControllerObjects/ShowLootBox.java index d4c83d33..c20121a3 100644 --- a/src/protocol/swg/objectControllerObjects/ShowLootBox.java +++ b/src/protocol/swg/objectControllerObjects/ShowLootBox.java @@ -22,14 +22,12 @@ package protocol.swg.objectControllerObjects; import java.nio.ByteOrder; -import java.util.List; import java.util.Vector; import org.apache.mina.core.buffer.IoBuffer; import engine.resources.objects.SWGObject; import protocol.swg.ObjControllerMessage; -import resources.common.StringUtilities; public class ShowLootBox extends ObjControllerObject { diff --git a/src/protocol/swg/objectControllerObjects/StartNpcConversation.java b/src/protocol/swg/objectControllerObjects/StartNpcConversation.java index d4056d90..a696ca70 100644 --- a/src/protocol/swg/objectControllerObjects/StartNpcConversation.java +++ b/src/protocol/swg/objectControllerObjects/StartNpcConversation.java @@ -26,7 +26,6 @@ import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ObjControllerMessage; -import resources.common.ObjControllerOpcodes; public class StartNpcConversation extends ObjControllerObject { diff --git a/src/protocol/swg/objectControllerObjects/StopNpcConversation.java b/src/protocol/swg/objectControllerObjects/StopNpcConversation.java index 469b1725..4690140d 100644 --- a/src/protocol/swg/objectControllerObjects/StopNpcConversation.java +++ b/src/protocol/swg/objectControllerObjects/StopNpcConversation.java @@ -26,7 +26,6 @@ import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ObjControllerMessage; -import resources.common.ObjControllerOpcodes; public class StopNpcConversation extends ObjControllerObject { diff --git a/src/resources/common/Cooldown.java b/src/resources/common/Cooldown.java index edaf7e94..2c7e2240 100644 --- a/src/resources/common/Cooldown.java +++ b/src/resources/common/Cooldown.java @@ -21,9 +21,7 @@ ******************************************************************************/ package resources.common; -import java.util.concurrent.Executors; import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; public class Cooldown { private long startTimestamp; diff --git a/src/resources/common/IDAttribute.java b/src/resources/common/IDAttribute.java index 6accf7e3..b17edf9d 100644 --- a/src/resources/common/IDAttribute.java +++ b/src/resources/common/IDAttribute.java @@ -21,8 +21,6 @@ ******************************************************************************/ package resources.common; -import java.math.BigInteger; - public class IDAttribute { private float floatValue; diff --git a/src/resources/common/ThreadMonitor.java b/src/resources/common/ThreadMonitor.java index 19c83baa..bf5c2cb8 100644 --- a/src/resources/common/ThreadMonitor.java +++ b/src/resources/common/ThreadMonitor.java @@ -187,7 +187,8 @@ public class ThreadMonitor { return true; } - private void parseMBeanInfo() throws IOException { + @SuppressWarnings("unused") + private void parseMBeanInfo() throws IOException { try { MBeanOperationInfo[] mopis = server.getMBeanInfo(objname).getOperations(); diff --git a/src/resources/objects/Buff.java b/src/resources/objects/Buff.java index f8fc8dff..fd6aa4e0 100644 --- a/src/resources/objects/Buff.java +++ b/src/resources/objects/Buff.java @@ -36,8 +36,6 @@ import resources.objects.creature.CreatureObject; import com.sleepycat.persist.model.NotPersistent; import com.sleepycat.persist.model.Persistent; -import engine.clientdata.ClientFileManager; -import engine.clientdata.visitors.DatatableVisitor; import engine.resources.common.CRC; @Persistent(version=10) diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index 68f59f6a..f604d0a3 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -30,9 +30,7 @@ import resources.objects.tangible.TangibleObject; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.NotPersistent; import engine.clients.Client; -import engine.resources.container.Traverser; import engine.resources.objects.IPersistent; -import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index 1893b318..d70cf87c 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -30,7 +30,6 @@ import org.apache.mina.core.buffer.IoBuffer; import com.sleepycat.persist.model.Persistent; import engine.resources.common.CRC; -import resources.common.StringUtilities; import resources.objects.Buff; import resources.objects.ObjectMessageBuilder; import resources.objects.SkillMod; diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 8391ac82..d53ff7e2 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -28,14 +28,11 @@ import java.util.Iterator; import java.util.List; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executors; import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ObjControllerMessage; -import protocol.swg.PlayClientEffectObjectMessage; import protocol.swg.PlayMusicMessage; import protocol.swg.UpdatePostureMessage; import protocol.swg.UpdatePVPStatusMessage; @@ -64,7 +61,6 @@ import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; -import resources.objects.weapon.WeaponObject; @Entity(version=6) public class CreatureObject extends TangibleObject implements IPersistent { @@ -1090,8 +1086,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { appearanceEquipmentList.get().remove(object); } } - - @SuppressWarnings("unused") + @Override public void sendBaselines(Client destination) { diff --git a/src/resources/objects/player/PlayerMessageBuilder.java b/src/resources/objects/player/PlayerMessageBuilder.java index 41df49b1..aae6f5c3 100644 --- a/src/resources/objects/player/PlayerMessageBuilder.java +++ b/src/resources/objects/player/PlayerMessageBuilder.java @@ -27,8 +27,6 @@ import java.util.Map.Entry; import org.apache.mina.core.buffer.IoBuffer; -import engine.resources.common.CRC; -import resources.common.StringUtilities; import resources.objects.ObjectMessageBuilder; import resources.objects.waypoint.WaypointObject; diff --git a/src/resources/objects/player/PlayerObject.java b/src/resources/objects/player/PlayerObject.java index aecf070a..d1c23985 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; -import resources.common.Console; import resources.objects.intangible.IntangibleObject; import resources.objects.resource.ResourceContainerObject; import resources.objects.tool.SurveyTool; diff --git a/src/resources/objects/resource/GalacticResource.java b/src/resources/objects/resource/GalacticResource.java index ebd728d4..643e1444 100644 --- a/src/resources/objects/resource/GalacticResource.java +++ b/src/resources/objects/resource/GalacticResource.java @@ -24,20 +24,17 @@ package resources.objects.resource; import java.util.List; import java.util.Random; import java.util.Vector; -import java.util.concurrent.TimeUnit; import main.NGECore; import protocol.swg.SurveyMapUpdateMessage; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; -import resources.objects.tangible.TangibleObject; import resources.objects.waypoint.WaypointObject; import com.sleepycat.je.Environment; import com.sleepycat.je.Transaction; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; import engine.clients.Client; import engine.resources.objects.IPersistent; diff --git a/src/resources/objects/resource/ResourceConcentration.java b/src/resources/objects/resource/ResourceConcentration.java index 332eed7e..c2104b9e 100644 --- a/src/resources/objects/resource/ResourceConcentration.java +++ b/src/resources/objects/resource/ResourceConcentration.java @@ -27,7 +27,7 @@ public class ResourceConcentration { return coordsZ; } - public void setCoordsZ(float coordsY) { + public void setCoordsZ(float coordsZ) { this.coordsZ = coordsZ; } diff --git a/src/resources/objects/resource/ResourceContainerObject.java b/src/resources/objects/resource/ResourceContainerObject.java index 20ef9dfd..b2a0eada 100644 --- a/src/resources/objects/resource/ResourceContainerObject.java +++ b/src/resources/objects/resource/ResourceContainerObject.java @@ -70,6 +70,7 @@ public class ResourceContainerObject extends TangibleObject { private short overallQuality; private short flavor; + /* private static byte CONTAINER_TYPE_INORGANIC_MINERALS = 0; private static byte CONTAINER_TYPE_INORGANIC_CHEMICALS = 1; private static byte CONTAINER_TYPE_INORGANIC_GAS = 2; @@ -127,6 +128,7 @@ public class ResourceContainerObject extends TangibleObject { "object/resource_container/shared_resource_container_energy_radioactive.iff", "object/resource_container/shared_resource_container_energy_solid.iff" }; + */ @NotPersistent public static int maximalStackCapacity = 100000; diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index dce95545..6a8433ef 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -31,8 +31,6 @@ import java.util.Map; import java.util.Set; import java.util.Vector; -import javax.xml.bind.DatatypeConverter; - import main.NGECore; import protocol.swg.ObjControllerMessage; import protocol.swg.PlayClientEffectObjectMessage; @@ -42,7 +40,6 @@ import protocol.swg.objectControllerObjects.ShowFlyText; import resources.common.RGB; import resources.objects.creature.CreatureObject; import resources.visitors.IDManagerVisitor; -import services.ai.AIActor; import com.sleepycat.persist.model.NotPersistent; import com.sleepycat.persist.model.Persistent; diff --git a/src/services/BuffService.java b/src/services/BuffService.java index 97032e4e..36a0154f 100644 --- a/src/services/BuffService.java +++ b/src/services/BuffService.java @@ -178,7 +178,6 @@ public class BuffService implements INetworkDispatch { // I'm not sure if all aura effects follow the same rules, so this is simply restricted to officer aura's atm ScheduledFuture task = scheduler.scheduleAtFixedRate(new Runnable() { - @SuppressWarnings("unused") @Override public void run() { if (buffer == null || buffer.getClient() == null) diff --git a/src/services/ConversationService.java b/src/services/ConversationService.java index a4f624dc..b2b3854a 100644 --- a/src/services/ConversationService.java +++ b/src/services/ConversationService.java @@ -124,7 +124,7 @@ public class ConversationService implements INetworkDispatch { conversationHandlers.put(player, handler); - NpcConversationOptions convoOptions = new NpcConversationOptions(player.getObjectID(), npc.getObjectID()); + NpcConversationOptions convoOptions = new NpcConversationOptions(player.getObjectID()); options.forEach(convoOptions::addOption); ObjControllerMessage objController = new ObjControllerMessage(0x0B, convoOptions); player.getClient().getSession().write(objController.serialize()); diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index 2821f0f1..3c6772a9 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -2,10 +2,8 @@ package services; import java.nio.ByteOrder; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; -import java.util.Random; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; @@ -19,25 +17,18 @@ import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.session.IoSession; import protocol.swg.ObjControllerMessage; -import protocol.swg.OkMessage; -import protocol.swg.PlayClientEffectObjectMessage; import protocol.swg.objectControllerObjects.BuffBuilderChangeMessage; import protocol.swg.objectControllerObjects.BuffBuilderEndMessage; -import protocol.swg.objectControllerObjects.BuffBuilderStartMessage; import protocol.swg.objectControllerObjects.ImageDesignMessage; import resources.common.BuffBuilder; -import resources.common.Console; import resources.common.IDAttribute; import resources.common.MathUtilities; import resources.common.ObjControllerOpcodes; import resources.common.Performance; import resources.common.PerformanceEffect; import resources.common.RGB; -import resources.common.StringUtilities; import resources.datatables.Posture; -import resources.objects.Buff; import resources.objects.BuffItem; -import resources.objects.SWGList; import resources.objects.SkillMod; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; @@ -45,7 +36,6 @@ import resources.objects.tangible.TangibleObject; import resources.visitors.IDManagerVisitor; import services.sui.SUIService.InputBoxType; import services.sui.SUIWindow; -import services.sui.SUIWindow.SUICallback; import services.sui.SUIWindow.Trigger; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; diff --git a/src/services/EquipmentService.java b/src/services/EquipmentService.java index d19d838f..12764c94 100644 --- a/src/services/EquipmentService.java +++ b/src/services/EquipmentService.java @@ -35,7 +35,6 @@ import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import java.util.TreeMap; -import org.python.antlr.ast.Str; import org.python.core.Py; import org.python.core.PyObject; @@ -46,9 +45,7 @@ import engine.resources.objects.SWGObject; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.objects.player.PlayerObject; -import resources.objects.tangible.TangibleObject; import services.equipment.BonusSetTemplate; -import services.spawn.MobileTemplate; public class EquipmentService implements INetworkDispatch { diff --git a/src/services/GroupService.java b/src/services/GroupService.java index b9504a8c..ba159d69 100644 --- a/src/services/GroupService.java +++ b/src/services/GroupService.java @@ -28,7 +28,6 @@ import java.util.Map; import resources.objects.Buff; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; -import services.chat.ChatRoom; import main.NGECore; import engine.clients.Client; import engine.resources.objects.SWGObject; diff --git a/src/services/InstanceService.java b/src/services/InstanceService.java index 386cc3cf..09ec11d4 100644 --- a/src/services/InstanceService.java +++ b/src/services/InstanceService.java @@ -36,7 +36,6 @@ import java.util.concurrent.TimeUnit; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; -import services.object.ObjectService; import main.NGECore; import engine.clientdata.ClientFileManager; diff --git a/src/services/MissionService.java b/src/services/MissionService.java index 78fce706..77e9dca7 100644 --- a/src/services/MissionService.java +++ b/src/services/MissionService.java @@ -24,7 +24,6 @@ package services; import java.nio.ByteOrder; import java.util.Map; import java.util.Random; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import main.NGECore; @@ -44,7 +43,6 @@ import engine.clientdata.visitors.DatatableVisitor; import engine.clients.Client; import engine.resources.container.Traverser; import engine.resources.objects.SWGObject; -import engine.resources.scene.Planet; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; diff --git a/src/services/SurveyService.java b/src/services/SurveyService.java index 333db3f7..db662c14 100644 --- a/src/services/SurveyService.java +++ b/src/services/SurveyService.java @@ -22,7 +22,6 @@ package services; import java.util.Map; -import java.util.Observable; import java.util.Random; import java.util.Vector; import java.util.concurrent.Executors; @@ -31,27 +30,19 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import protocol.swg.PlayClientEffectLocMessage; -import protocol.swg.SceneCreateObjectByCrc; -import protocol.swg.SceneEndBaselines; -import protocol.swg.SurveyMapUpdateMessage; -import protocol.swg.UpdateContainmentMessage; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import resources.objects.resource.GalacticResource; -import resources.objects.resource.ResourceConcentration; import resources.objects.resource.ResourceContainerObject; import resources.objects.resource.ResourceRoot; import resources.objects.tangible.TangibleObject; import resources.objects.tool.SurveyTool; -import resources.objects.waypoint.WaypointObject; import services.sui.SUIWindow; import services.sui.SUIWindow.SUICallback; import services.sui.SUIWindow.Trigger; import main.NGECore; -import engine.resources.common.CRC; import engine.resources.container.Traverser; import engine.resources.objects.SWGObject; -import engine.resources.scene.Point3D; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -479,7 +470,6 @@ public class SurveyService implements INetworkDispatch { returnList.add("List.lstList:SelectedRow"); window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { - @SuppressWarnings("unchecked") @Override public void process(SWGObject owner, int eventType, Vector returnList) { int index = Integer.parseInt(returnList.get(0)); @@ -627,7 +617,6 @@ public class SurveyService implements INetworkDispatch { final SurveyTool outerSurveyTool = (SurveyTool)target; window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { - @SuppressWarnings("unchecked") @Override public void process(SWGObject owner, int eventType, Vector returnList) { CreatureObject crafter = (CreatureObject)owner; @@ -673,14 +662,12 @@ public class SurveyService implements INetworkDispatch { final SurveyTool outerSurveyTool = (SurveyTool)target; window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { - @SuppressWarnings("unchecked") @Override public void process(SWGObject owner, int eventType, Vector returnList) { ((CreatureObject)owner).sendSystemMessage("Rad confirmed", (byte) 0); } }); window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { - @SuppressWarnings("unchecked") @Override public void process(SWGObject owner, int eventType, Vector returnList) { ((CreatureObject)owner).sendSystemMessage("Rad declined", (byte) 0); diff --git a/src/services/TerrainService.java b/src/services/TerrainService.java index 151cf9a6..c8b3aaf5 100644 --- a/src/services/TerrainService.java +++ b/src/services/TerrainService.java @@ -24,22 +24,16 @@ package services; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import resources.common.FileUtilities; import resources.common.collidables.CollidableCircle; -import resources.objects.building.BuildingObject; -import resources.objects.cell.CellObject; -import resources.objects.creature.CreatureObject; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; import engine.resources.config.Config; -import engine.resources.container.Traverser; import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; diff --git a/src/services/ai/AIActor.java b/src/services/ai/AIActor.java index f3f406b7..c34ed1fc 100644 --- a/src/services/ai/AIActor.java +++ b/src/services/ai/AIActor.java @@ -22,7 +22,6 @@ package services.ai; import java.util.Map; -import java.util.Map.Entry; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledExecutorService; @@ -42,7 +41,6 @@ import services.ai.states.AttackState; import services.ai.states.DeathState; import services.ai.states.IdleState; import services.ai.states.RetreatState; -import services.ai.states.SpawnState; import services.combat.CombatEvents.DamageTaken; import services.spawn.MobileTemplate; diff --git a/src/services/ai/AIService.java b/src/services/ai/AIService.java index 786ac66d..5f2f3e63 100644 --- a/src/services/ai/AIService.java +++ b/src/services/ai/AIService.java @@ -26,14 +26,11 @@ import java.util.Map.Entry; import java.util.Random; import java.util.Vector; -import resources.objects.cell.CellObject; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; import resources.objects.player.PlayerObject; -import engine.resources.scene.Planet; import engine.resources.scene.Point3D; -import engine.resources.scene.Quaternion; import main.NGECore; diff --git a/src/services/ai/states/RetreatState.java b/src/services/ai/states/RetreatState.java index 61db1785..315f8cb3 100644 --- a/src/services/ai/states/RetreatState.java +++ b/src/services/ai/states/RetreatState.java @@ -21,9 +21,7 @@ ******************************************************************************/ package services.ai.states; -import resources.objects.creature.CreatureObject; import services.ai.AIActor; -import services.ai.states.AIState.StateResult; public class RetreatState extends AIState { diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index 274fcd4e..06afbab6 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -34,8 +34,6 @@ import org.apache.mina.core.session.IoSession; import com.sleepycat.je.Transaction; import com.sleepycat.persist.EntityCursor; -import com.sleepycat.persist.PrimaryIndex; -import com.sleepycat.persist.SecondaryIndex; import engine.clients.Client; import engine.resources.config.Config; @@ -50,7 +48,6 @@ import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import protocol.swg.AddIgnoreMessage; import protocol.swg.ObjControllerMessage; -import protocol.swg.chat.ChatCreateRoom; import protocol.swg.chat.ChatDeletePersistentMessage; import protocol.swg.chat.ChatEnterRoomById; import protocol.swg.chat.ChatFriendsListUpdate; @@ -58,7 +55,6 @@ import protocol.swg.chat.ChatInstantMessageToCharacter; import protocol.swg.chat.ChatInstantMessagetoClient; import protocol.swg.chat.ChatOnAddFriend; import protocol.swg.chat.ChatOnChangeFriendStatus; -import protocol.swg.chat.ChatOnCreateRoom; import protocol.swg.chat.ChatOnEnteredRoom; import protocol.swg.chat.ChatOnSendInstantMessage; import protocol.swg.chat.ChatOnSendPersistentMessage; @@ -69,7 +65,6 @@ import protocol.swg.chat.ChatRequestPersistentMessage; import protocol.swg.chat.ChatRoomList; import protocol.swg.chat.ChatRoomMessage; import protocol.swg.chat.ChatSendToRoom; -import protocol.swg.chat.ChatServerStatus; import protocol.swg.chat.ChatSystemMessage; import protocol.swg.objectControllerObjects.PlayerEmote; import protocol.swg.objectControllerObjects.SpatialChat; diff --git a/src/services/combat/CombatCommands.java b/src/services/combat/CombatCommands.java index 7a66c472..dcdc875d 100644 --- a/src/services/combat/CombatCommands.java +++ b/src/services/combat/CombatCommands.java @@ -21,7 +21,6 @@ ******************************************************************************/ package services.combat; -import services.command.CombatCommand; import main.NGECore; public class CombatCommands { diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 712c5ca0..1f455338 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -36,7 +36,6 @@ import org.apache.mina.core.session.IoSession; import protocol.swg.ObjControllerMessage; import protocol.swg.PlayClientEffectLocMessage; -import protocol.swg.UpdatePVPStatusMessage; import protocol.swg.objectControllerObjects.CombatAction; import protocol.swg.objectControllerObjects.CombatSpam; import protocol.swg.objectControllerObjects.CommandEnqueueRemove; @@ -821,7 +820,6 @@ public class CombatService implements INetworkDispatch { target.getEventBus().publish(event); } - @SuppressWarnings("unused") public void doDrainHeal(CreatureObject receiver, int drainAmount) { synchronized(receiver.getMutex()) { receiver.setHealth(receiver.getHealth() + drainAmount); diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index f228aa16..3205bd5e 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -37,7 +37,6 @@ public class BaseSWGCommand implements Cloneable { private String clientEffectSelf; private String clientEffectTarget; private int commandCRC; - private boolean isGmCommand = false; private String characterAbility; private int target; private int targetType; @@ -240,10 +239,6 @@ public class BaseSWGCommand implements Cloneable { return (godLevel > 0); } - public void setGmCommand(boolean isGmCommand) { - this.isGmCommand = isGmCommand; - } - public String getCharacterAbility() { return characterAbility; } diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index ad76e992..7d90f6bb 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -83,7 +83,7 @@ public class CommandService implements INetworkDispatch { return false; } - if (command.getGodLevel() > 0 && !actor.getClient().isGM()) { + if (command.getGodLevel() > 0 && (actor.getClient() == null || !actor.getClient().isGM())) { return false; } @@ -177,7 +177,7 @@ public class CommandService implements INetworkDispatch { } // Without this we could be buffing ally NPCs and such - if (object.getSlottedObject("ghost") == null) { + if (actor.getSlottedObject("ghost") != null && object.getSlottedObject("ghost") == null) { return false; } @@ -222,28 +222,7 @@ public class CommandService implements INetworkDispatch { } public void callCommand(SWGObject actor, String commandName, SWGObject target, String commandArgs) { - System.out.println("CommandService: void callCommand(actor, commandName, target, commandArgs): This shouldn't be called anymore."); - - if (actor == null) - return; - - BaseSWGCommand command = getCommandByName(commandName); - - if (command == null) - return; - - if(command instanceof CombatCommand) { - CombatCommand command2; - try { - command2 = (CombatCommand) command.clone(); - processCombatCommand((CreatureObject) actor, target, command2, 0, ""); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - return; - } - - core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandArgs); + callCommand((CreatureObject) actor, target, getCommandByName(commandName), 0, commandArgs); } public BaseSWGCommand getCommandByCRC(int commandCRC) { @@ -364,9 +343,7 @@ public class CommandService implements INetworkDispatch { } else { if (FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName() + ".py")) { core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandArgs); - } - - if (FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) { + } else if (FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) { core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "run", core, actor, target, commandArgs); } } diff --git a/src/services/gcw/FactionService.java b/src/services/gcw/FactionService.java index afe73fd5..4148f969 100644 --- a/src/services/gcw/FactionService.java +++ b/src/services/gcw/FactionService.java @@ -37,7 +37,6 @@ import protocol.swg.FactionResponseMessage; import resources.common.FileUtilities; import resources.common.Opcodes; import resources.datatables.FactionStatus; -import resources.datatables.Options; import resources.datatables.PvpStatus; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; diff --git a/src/services/guild/GuildService.java b/src/services/guild/GuildService.java index f591db3e..022895de 100644 --- a/src/services/guild/GuildService.java +++ b/src/services/guild/GuildService.java @@ -23,7 +23,6 @@ package services.guild; import java.util.Map; -import resources.common.Console; import resources.guild.Guild; import resources.objects.SWGList; import resources.objects.guild.GuildObject; diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index 37da6f3a..a9f427b5 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -33,16 +33,11 @@ import java.util.Map; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; -import com.sleepycat.persist.EntityCursor; - import main.NGECore; import protocol.swg.EnterStructurePlacementModeMessage; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; -import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; -import services.chat.Mail; -import services.equipment.BonusSetTemplate; import engine.resources.objects.SWGObject; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; diff --git a/src/services/resources/ResourceService.java b/src/services/resources/ResourceService.java index fa546a01..efc62fe1 100644 --- a/src/services/resources/ResourceService.java +++ b/src/services/resources/ResourceService.java @@ -28,7 +28,6 @@ import java.util.Random; import java.util.Vector; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; import com.sleepycat.persist.EntityCursor; import main.NGECore; import engine.resources.common.CRC; diff --git a/src/services/spawn/DynamicSpawnArea.java b/src/services/spawn/DynamicSpawnArea.java index a5df57d7..e588e4cd 100644 --- a/src/services/spawn/DynamicSpawnArea.java +++ b/src/services/spawn/DynamicSpawnArea.java @@ -25,7 +25,6 @@ import net.engio.mbassy.listener.Handler; import resources.common.collidables.AbstractCollidable; import resources.common.collidables.AbstractCollidable.EnterEvent; import resources.common.collidables.AbstractCollidable.ExitEvent; -import services.SimulationService.MoveEvent; import engine.resources.scene.Planet; public class DynamicSpawnArea extends SpawnArea { diff --git a/src/services/spawn/MobileTemplate.java b/src/services/spawn/MobileTemplate.java index 4d289bb8..78664aa2 100644 --- a/src/services/spawn/MobileTemplate.java +++ b/src/services/spawn/MobileTemplate.java @@ -23,10 +23,8 @@ package services.spawn; import java.util.Vector; -import main.NGECore; import resources.datatables.Options; import resources.datatables.PvpStatus; -import resources.objects.weapon.WeaponObject; public class MobileTemplate { diff --git a/src/services/spawn/SpawnArea.java b/src/services/spawn/SpawnArea.java index aadb1746..2d64c576 100644 --- a/src/services/spawn/SpawnArea.java +++ b/src/services/spawn/SpawnArea.java @@ -28,7 +28,6 @@ import net.engio.mbassy.listener.Handler; import resources.common.collidables.AbstractCollidable; import resources.common.collidables.AbstractCollidable.EnterEvent; import resources.common.collidables.AbstractCollidable.ExitEvent; -import services.SimulationService.MoveEvent; import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; diff --git a/src/services/spawn/SpawnService.java b/src/services/spawn/SpawnService.java index bd0aadd1..eddfffa7 100644 --- a/src/services/spawn/SpawnService.java +++ b/src/services/spawn/SpawnService.java @@ -38,8 +38,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import org.python.core.Py; - import resources.common.collidables.CollidableCircle; import resources.datatables.Options; import resources.datatables.PvpStatus; diff --git a/src/services/spawn/StaticSpawnArea.java b/src/services/spawn/StaticSpawnArea.java index 2bce6aef..64de8d63 100644 --- a/src/services/spawn/StaticSpawnArea.java +++ b/src/services/spawn/StaticSpawnArea.java @@ -25,7 +25,6 @@ import net.engio.mbassy.listener.Handler; import resources.common.collidables.AbstractCollidable; import resources.common.collidables.AbstractCollidable.EnterEvent; import resources.common.collidables.AbstractCollidable.ExitEvent; -import services.SimulationService.MoveEvent; import engine.resources.scene.Planet; public class StaticSpawnArea extends SpawnArea { diff --git a/src/services/sui/SUIService.java b/src/services/sui/SUIService.java index 8c2240f7..eb853838 100644 --- a/src/services/sui/SUIService.java +++ b/src/services/sui/SUIService.java @@ -23,7 +23,6 @@ package services.sui; import java.nio.ByteOrder; import java.util.Map; -import java.util.Map.Entry; import java.util.Random; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; diff --git a/src/services/travel/TravelService.java b/src/services/travel/TravelService.java index 6cd5c7c1..a6929851 100644 --- a/src/services/travel/TravelService.java +++ b/src/services/travel/TravelService.java @@ -25,7 +25,6 @@ import java.nio.ByteOrder; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Random; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; diff --git a/src/tools/CharonPacketUtils.java b/src/tools/CharonPacketUtils.java index b7eb10a1..7c091133 100644 --- a/src/tools/CharonPacketUtils.java +++ b/src/tools/CharonPacketUtils.java @@ -56,7 +56,7 @@ public class CharonPacketUtils { public static void printAnalysis(IoBuffer pack){ - if (!NGECore.getInstance().PACKET_DEBUG) + if (!NGECore.PACKET_DEBUG) return; byte[] packArray = pack.array(); From e4b07bd51be7358d6a596f32f05a456e40b753b1 Mon Sep 17 00:00:00 2001 From: DAK- Date: Thu, 10 Apr 2014 06:39:52 -0500 Subject: [PATCH 57/68] Swapped correct Dantooine travel point names. Imperial / Mining Outpost(s) travel point names on Dantooine were swapped - now correct. --- scripts/static_travel_points.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/static_travel_points.py b/scripts/static_travel_points.py index 26ac3f85..b1814ec9 100644 --- a/scripts/static_travel_points.py +++ b/scripts/static_travel_points.py @@ -49,8 +49,8 @@ def corelliaPoints(core, planet): def dantooinePoints(core, planet): trvSvc = core.travelService - trvSvc.addTravelPoint(planet, "Imperial Outpost", -635, 3, 2507) - trvSvc.addTravelPoint(planet, "Mining Outpost", -4208, 3, -2350) + trvSvc.addTravelPoint(planet, "Mining Outpost", -635, 3, 2507) + trvSvc.addTravelPoint(planet, "Imperial Outpost", -4208, 3, -2350) trvSvc.addTravelPoint(planet, "Agro Outpost", 1569, 4, -6415) return @@ -149,4 +149,4 @@ def mustafarPoints(core, planet): trvSvc = core.travelService trvSvc.addTravelPoint(planet, "Mensix Mining Facility", 405, 230, -1352) - return \ No newline at end of file + return From 97df8d8f5fa24403f39571ebf69e708671ef65a4 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 10 Apr 2014 15:54:49 +0100 Subject: [PATCH 58/68] Commands checked if they are combat cmds --- src/services/command/CommandService.java | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 7d90f6bb..34e02ecf 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -97,14 +97,14 @@ public class CommandService implements INetworkDispatch { return false; } - // The two below statements need testing before use - for (long state : command.getInvalidStates()) { if ((actor.getStateBitmask() & state) == state) { //return false; } } + // This SHOULD be invalid locomotions but we don't track these currently. + // Postures are the best we can do. for (byte posture : command.getInvalidPostures()) { if (actor.getPosture() == posture) { //return false; @@ -259,7 +259,7 @@ public class CommandService implements INetworkDispatch { sub += 5; } - if (hasCharacterAbility) { + if (hasCharacterAbility || isCombatCommand(name)) { CombatCommand command = new CombatCommand(name.toLowerCase()); commandLookup.add(command); return command; @@ -315,7 +315,7 @@ public class CommandService implements INetworkDispatch { sub += 5; } - if (hasCharacterAbility) { + if (hasCharacterAbility || isCombatCommand(commandName)) { CombatCommand command = new CombatCommand(commandName); commandLookup.add(command); return command; @@ -335,6 +335,22 @@ public class CommandService implements INetworkDispatch { return null; } + public boolean isCombatCommand(String commandName) { + try { + DatatableVisitor visitor = ClientFileManager.loadFile("datatables/combat/combat_data.iff", DatatableVisitor.class); + + for (int i = 0; i < visitor.getRowCount(); i++) { + if (visitor.getObject(i, 0) != null && ((String) (visitor.getObject(i, 0))).equalsIgnoreCase(commandName)) { + return true; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + return false; + } + public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); From 4bb055ca19545030b28b623180158f8f50bc148d Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Thu, 10 Apr 2014 17:04:52 +0200 Subject: [PATCH 59/68] Rare loot system stage added Rare loot system stage in effect for every loot session. Added legendary,exceptional,rare loot chests --- .../rarelootchestcontents/exceptionaltable.py | 12 +++ .../rarelootchestcontents/legendarytable.py | 8 ++ .../loot/rarelootchestcontents/raretable.py | 0 .../object/tangible/item/rare_loot_chest_1.py | 1 + .../object/tangible/item/rare_loot_chest_2.py | 1 + .../object/tangible/item/rare_loot_chest_3.py | 1 + scripts/radial/lootchest.py | 13 +++ src/resources/objects/group/GroupObject.java | 5 + .../objects/loot/LootRollSession.java | 63 +++++++++++- .../objects/tangible/TangibleObject.java | 12 ++- src/services/LootService.java | 98 ++++++++++++++++++- 11 files changed, 207 insertions(+), 7 deletions(-) create mode 100644 scripts/loot/rarelootchestcontents/exceptionaltable.py create mode 100644 scripts/loot/rarelootchestcontents/legendarytable.py create mode 100644 scripts/loot/rarelootchestcontents/raretable.py create mode 100644 scripts/radial/lootchest.py diff --git a/scripts/loot/rarelootchestcontents/exceptionaltable.py b/scripts/loot/rarelootchestcontents/exceptionaltable.py new file mode 100644 index 00000000..b8c4ba4d --- /dev/null +++ b/scripts/loot/rarelootchestcontents/exceptionaltable.py @@ -0,0 +1,12 @@ + +def itemTemplates(): + templates = ['Biological_Focus_Crystal','Synapse_Focus_Crystal','Concentrated_Bacta_Tank','DNA_Storage_Device_Kowakian'] + templates = templates + ['Dug_Costume_Instructions','Dusk_in_Kachirho','Mercenaries_Despair','Mercenaries_Lament','Nightsister_Melee_Armguard'] + templates = templates + ['Rare_Painting','Sunriders_Destiny'] + return templates + +def itemChances(): + chances = [9,9,9,9] + chances = chances+[9,9,9,9,9] + chances = chances+[9,9] #= 100% + return chances \ No newline at end of file diff --git a/scripts/loot/rarelootchestcontents/legendarytable.py b/scripts/loot/rarelootchestcontents/legendarytable.py new file mode 100644 index 00000000..d372b968 --- /dev/null +++ b/scripts/loot/rarelootchestcontents/legendarytable.py @@ -0,0 +1,8 @@ + +def itemNames(): + + return ['colorCrystal'] + +def itemChances(): + + return [70] \ No newline at end of file diff --git a/scripts/loot/rarelootchestcontents/raretable.py b/scripts/loot/rarelootchestcontents/raretable.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/object/tangible/item/rare_loot_chest_1.py b/scripts/object/tangible/item/rare_loot_chest_1.py index ccad8904..33b2b963 100644 --- a/scripts/object/tangible/item/rare_loot_chest_1.py +++ b/scripts/object/tangible/item/rare_loot_chest_1.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'lootchest') return \ No newline at end of file diff --git a/scripts/object/tangible/item/rare_loot_chest_2.py b/scripts/object/tangible/item/rare_loot_chest_2.py index ccad8904..33b2b963 100644 --- a/scripts/object/tangible/item/rare_loot_chest_2.py +++ b/scripts/object/tangible/item/rare_loot_chest_2.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'lootchest') return \ No newline at end of file diff --git a/scripts/object/tangible/item/rare_loot_chest_3.py b/scripts/object/tangible/item/rare_loot_chest_3.py index ccad8904..33b2b963 100644 --- a/scripts/object/tangible/item/rare_loot_chest_3.py +++ b/scripts/object/tangible/item/rare_loot_chest_3.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'lootchest') return \ No newline at end of file diff --git a/scripts/radial/lootchest.py b/scripts/radial/lootchest.py new file mode 100644 index 00000000..1a0c9889 --- /dev/null +++ b/scripts/radial/lootchest.py @@ -0,0 +1,13 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + radials.add(RadialOptions(0, 21, 1, 'Open')) + radials.add(RadialOptions(0, 7, 1, '')) + return + +def handleSelection(core, owner, target, option): + if option == 21 and target: + owner.sendSystemMessage('RLS chest content system not yet implemented.',1) + return + \ No newline at end of file diff --git a/src/resources/objects/group/GroupObject.java b/src/resources/objects/group/GroupObject.java index 0cac422d..0f5c4622 100644 --- a/src/resources/objects/group/GroupObject.java +++ b/src/resources/objects/group/GroupObject.java @@ -41,6 +41,11 @@ public class GroupObject extends UniverseObject { private GroupMessageBuilder messageBuilder; private int chatRoomId; + public static int FREE_FOR_ALL = 0; + public static int MASTER_LOOTER = 1; + public static int LOTTERY = 2; + + public GroupObject(long objectId) { super(objectId, null, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), "object/group/shared_group_object.iff"); messageBuilder = new GroupMessageBuilder(this); diff --git a/src/resources/objects/loot/LootRollSession.java b/src/resources/objects/loot/LootRollSession.java index cb7c93e4..59e06267 100644 --- a/src/resources/objects/loot/LootRollSession.java +++ b/src/resources/objects/loot/LootRollSession.java @@ -37,25 +37,50 @@ import resources.objects.tangible.TangibleObject; public class LootRollSession { private String SessionID; // leaderName-SystemTime + private boolean sessionValid; private GroupObject playerGroup; private List droppedItems; private Planet sessionPlanet; private List errorMessages; + private int sessionLootMode; + private boolean allowRareLoot; + private boolean increasedRLSChance; public LootRollSession(){ } - public LootRollSession(CreatureObject requester){ + public LootRollSession(CreatureObject requester, TangibleObject lootedObject){ long requesterGroupId = requester.getGroupId(); if (requesterGroupId>0){ this.playerGroup = (GroupObject) NGECore.getInstance().objectService.getObject(requesterGroupId); this.SessionID = playerGroup.getGroupLeader().getCustomName()+"-"+System.currentTimeMillis(); + } else { this.SessionID = requester.getCustomName()+"-"+System.currentTimeMillis(); } + + if (lootedObject instanceof CreatureObject){ + CreatureObject lootedCreature = (CreatureObject)lootedObject; + // Exclude rare loot depending on creature level + // For groups maybe average CL? + if (requester.getLevel()-lootedCreature.getLevel()<=6){ + this.setAllowRareLoot(true); + } + } + + // Group situation + if (this.getPlayerGroup()!=null){ + if (this.getPlayerGroup().getMemberList().size()>=4) + this.setIncreasedRLSChance(true); + } + + // Possible AFKer check here + + droppedItems = new ArrayList(); errorMessages = new ArrayList(); sessionPlanet = requester.getPlanet(); + allowRareLoot = false; } public List getDroppedItems() { @@ -89,4 +114,40 @@ public class LootRollSession { public void addErrorMessage(String errorMessage) { this.errorMessages.add(errorMessage); } + + public int getSessionLootMode() { + return sessionLootMode; + } + + public void setSessionLootMode(int sessionLootMode) { + this.sessionLootMode = sessionLootMode; + } + + public boolean isAllowRareLoot() { + return allowRareLoot; + } + + public void setAllowRareLoot(boolean allowRareLoot) { + this.allowRareLoot = allowRareLoot; + } + + public GroupObject getPlayerGroup() { + return playerGroup; + } + + public boolean isIncreasedRLSChance() { + return increasedRLSChance; + } + + public void setIncreasedRLSChance(boolean increasedRLSChance) { + this.increasedRLSChance = increasedRLSChance; + } + + public boolean isSessionValid() { + return sessionValid; + } + + public void setSessionValid(boolean sessionValid) { + this.sessionValid = sessionValid; + } } diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 3001915f..eccd631f 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -60,7 +60,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=4) +@Persistent(version=5) public class TangibleObject extends SWGObject { // TODO: Thread safety @@ -87,6 +87,7 @@ public class TangibleObject extends SWGObject { private List lootGroups = new ArrayList(); private boolean looted = false; + private boolean lootLock = false; @NotPersistent private TangibleObject killer = null; @@ -473,6 +474,14 @@ public class TangibleObject extends SWGObject { this.looted = looted; } + public boolean isLootLock() { + return lootLock; + } + + public void setLootLock(boolean lootLock) { + this.lootLock = lootLock; + } + @Override public void sendBaselines(Client destination) { @@ -497,4 +506,5 @@ public class TangibleObject extends SWGObject { } + } diff --git a/src/services/LootService.java b/src/services/LootService.java index 2b38bf74..4084d8fd 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -39,6 +39,7 @@ import java.util.Random; import java.util.Vector; import resources.objects.creature.CreatureObject; +import resources.objects.group.GroupObject; import resources.objects.loot.LootGroup; import resources.objects.loot.LootRollSession; import resources.objects.tangible.TangibleObject; @@ -72,18 +73,23 @@ public class LootService implements INetworkDispatch { public void handleLootRequest(CreatureObject requester, TangibleObject lootedObject) { - if (lootedObject.isLooted()) + if (lootedObject.isLooted() || lootedObject.isLootLock()) return; + lootedObject.setLootLock(true); + if (requester.getCustomName().contains("Kun")){ requester.setCashCredits(requester.getCashCredits()+1); requester.sendSystemMessage("You looted 1 credit.", (byte)1); + lootedObject.setLooted(true); return; } - LootRollSession lootRollSession = new LootRollSession(requester); + LootRollSession lootRollSession = new LootRollSession(requester,lootedObject); handleCreditDrop(requester,lootedObject); + + lootSituationAssessment(requester,lootedObject,lootRollSession); CreatureObject lootedCreature = (CreatureObject) lootedObject; @@ -96,12 +102,23 @@ public class LootService implements INetworkDispatch { LootGroup lootGroup = iterator.next(); int groupChance = lootGroup.getLootGroupChance(); int lootGroupRoll = new Random().nextInt(100); - if (lootGroupRoll <= groupChance){ + if (lootGroupRoll <= groupChance){ System.out.println("this lootGroup will drop something"); handleLootGroup(lootGroup,lootRollSession); //this lootGroup will drop something e.g. {kraytpearl_range,krayt_tissue_rare} } } + // Rare Loot System Stage (Is in place for all looted creatures) + if (lootRollSession.isAllowRareLoot()){ + int randomRareLoot = new Random().nextInt(100); + int chanceRequirement = 1; + if (lootRollSession.isIncreasedRLSChance()) + chanceRequirement+=3; // RLS chance is at 4% for groupsize >= 4 + if (randomRareLoot <= chanceRequirement){ + handleRareLootChest(lootRollSession); + } + } + // ********** Phase 1 complete, loot items determined ********** // stored in the lootSession @@ -113,6 +130,8 @@ public class LootService implements INetworkDispatch { for (String msg : lootRollSession.getErrorMessages()){ // ToDo: Show this for each group member later! requester.sendSystemMessage(msg,(byte) 1); + lootedObject.setLootLock(false); + return; } } @@ -121,6 +140,9 @@ public class LootService implements INetworkDispatch { for (TangibleObject droppedItem : lootRollSession.getDroppedItems()){ requesterInventory.add(droppedItem); + if (droppedItem.getAttachment("LootItemName").toString().contains("Loot Chest")){ + requester.playEffectObject("clienteffect/level_granted.cef", ""); + } } lootedObject.setLooted(true); @@ -148,7 +170,7 @@ public class LootService implements INetworkDispatch { for(int i=0;i Date: Thu, 10 Apr 2014 17:49:47 +0200 Subject: [PATCH 60/68] Clean up Cleaned up classes Moved loot radial to death state --- options.cfg | 6 ++-- .../object/mobile/dressed_stormtrooper_m.py | 5 ---- scripts/object/mobile/tusken_raider.py | 5 ---- .../objects/tangible/TangibleObject.java | 5 ---- src/services/DevService.java | 29 ++----------------- src/services/ai/states/DeathState.java | 1 + src/services/spawn/SpawnService.java | 2 +- 7 files changed, 7 insertions(+), 46 deletions(-) diff --git a/options.cfg b/options.cfg index 9a9489b6..5a3a7f8e 100644 --- a/options.cfg +++ b/options.cfg @@ -1,3 +1,3 @@ -LOAD.SNAPSHOT_OBJECTS=0 -LOAD.BUILDOUT_OBJECTS=0 -LOAD.RESOURCE.SYSTEM=0 \ No newline at end of file +LOAD.SNAPSHOT_OBJECTS=1 +LOAD.BUILDOUT_OBJECTS=1 +LOAD.RESOURCE.SYSTEM=1 \ No newline at end of file diff --git a/scripts/object/mobile/dressed_stormtrooper_m.py b/scripts/object/mobile/dressed_stormtrooper_m.py index 961975a9..a4b0d784 100644 --- a/scripts/object/mobile/dressed_stormtrooper_m.py +++ b/scripts/object/mobile/dressed_stormtrooper_m.py @@ -11,10 +11,5 @@ def setup(core, object): lootPoolChances_2 = [100] lootGroupChance_2 = 20 object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) - - lootPoolNames_3 = ['Rareloot'] - lootPoolChances_3 = [100] - lootGroupChance_3 = 1 - object.addToLootGroups(lootPoolNames_3,lootPoolChances_3,lootGroupChance_3) return \ No newline at end of file diff --git a/scripts/object/mobile/tusken_raider.py b/scripts/object/mobile/tusken_raider.py index 961975a9..97f7842a 100644 --- a/scripts/object/mobile/tusken_raider.py +++ b/scripts/object/mobile/tusken_raider.py @@ -12,9 +12,4 @@ def setup(core, object): lootGroupChance_2 = 20 object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) - lootPoolNames_3 = ['Rareloot'] - lootPoolChances_3 = [100] - lootGroupChance_3 = 1 - object.addToLootGroups(lootPoolNames_3,lootPoolChances_3,lootGroupChance_3) - return \ No newline at end of file diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index eccd631f..3ac40cf1 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -23,17 +23,12 @@ package resources.objects.tangible; import java.io.ByteArrayOutputStream; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; import java.util.Vector; import javax.xml.bind.DatatypeConverter; diff --git a/src/services/DevService.java b/src/services/DevService.java index f6b387be..ef265f41 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -67,7 +67,7 @@ public class DevService implements INetworkDispatch { public void sendCharacterBuilderSUI(CreatureObject creature, int childMenu) { Map suiOptions = new HashMap(); - + switch(childMenu) { case 0: // Root @@ -85,9 +85,7 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 22, "Misc Items"); suiOptions.put((long) 23, "Jedi Items"); suiOptions.put((long) 110, "Survey Devices"); - //suiOptions.put((long) 120, "House Deeds"); - suiOptions.put((long) 111, "Spawn Tusken"); - suiOptions.put((long) 112, "Spawn Krayt"); + if(creature.getClient().isGM()) suiOptions.put((long) 120, "House Deeds"); break; case 3: // [Items] Weapons suiOptions.put((long) 30, "Jedi Weapons"); @@ -995,29 +993,6 @@ public class DevService implements INetworkDispatch { inventory.add(solarSurveyTool); return; - case 111: - - - CreatureObject spawned2 = core.spawnService.spawnCreature("object/mobile/shared_tusken_raider.iff", "tatooine", 0, player.getPosition().x, player.getPosition().y, player.getPosition().z, 1, 0, 1, 0, 5); - // core.spawnService.spawnCreature(arg1, actor.getPlanet().getName(), 0, pos.x, pos.y, pos.z, 1, 0, 1, 0, int(arg2)) - //SWGObject spawned = core.staticService.spawnObject("object/mobile/shared_tusken_raider.iff", "tatooine", 0L, 3522F, 4F, -4801F, 0.70F, 0.71F); - //CreatureObject spawned2 = (CreatureObject) spawned; -// spawned2.setLevel((short)5); -// spawned2.setCombatFlag((byte)1); -// spawned2.setStateBitmask(1); -// spawned2.setOptionsBitmask(128); - - //core.lootService.handleLootRequest(player,(TangibleObject)spawned2); - break; - case 112: - SWGObject spawned3 = core.staticService.spawnObject("object/mobile/shared_krayt_dragon.iff", "tatooine", 0L, 3512F, 4F, -4801F, 0.70F, 0.71F); - -// pos = actor.getWorldPosition() -// core.spawnService.spawnCreature(arg1, actor.getPlanet().getName(), 0, pos.x, pos.y, pos.z, 1, 0, 1, 0, int(arg2)) -// - core.lootService.handleLootRequest(player,(TangibleObject)spawned3); - break; - case 120: SWGObject houseDeed = core.objectService.createObject("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", planet); inventory.add(houseDeed); diff --git a/src/services/ai/states/DeathState.java b/src/services/ai/states/DeathState.java index 13abdec0..14df1485 100644 --- a/src/services/ai/states/DeathState.java +++ b/src/services/ai/states/DeathState.java @@ -29,6 +29,7 @@ public class DeathState extends AIState { @Override public byte onEnter(AIActor actor) { NGECore.getInstance().aiService.awardExperience(actor); + actor.getCreature().setAttachment("radial_filename", "npc/corpse"); actor.scheduleDespawn(); return 0; } diff --git a/src/services/spawn/SpawnService.java b/src/services/spawn/SpawnService.java index a9ef4522..915c0498 100644 --- a/src/services/spawn/SpawnService.java +++ b/src/services/spawn/SpawnService.java @@ -167,7 +167,7 @@ public class SpawnService { creature.setAttachment("AI", actor); actor.setMobileTemplate(mobileTemplate); - creature.setAttachment("radial_filename", "npc/corpse"); + //creature.setAttachment("radial_filename", "npc/corpse"); if(cell == null) { From 20de91205b6b231311d8cca5d55db0a5199677ed Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Thu, 10 Apr 2014 17:56:02 +0200 Subject: [PATCH 61/68] More cleanup --- src/services/spawn/SpawnService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/services/spawn/SpawnService.java b/src/services/spawn/SpawnService.java index 915c0498..74da646a 100644 --- a/src/services/spawn/SpawnService.java +++ b/src/services/spawn/SpawnService.java @@ -167,7 +167,6 @@ public class SpawnService { creature.setAttachment("AI", actor); actor.setMobileTemplate(mobileTemplate); - //creature.setAttachment("radial_filename", "npc/corpse"); if(cell == null) { From b8b33a5019cc4ac6dd151082e1270aaa6d7908be Mon Sep 17 00:00:00 2001 From: Waverunner Date: Thu, 10 Apr 2014 14:44:27 -0400 Subject: [PATCH 62/68] Refactored ChatRoom to store Strings for lists instead of CreatureObject --- .../swg/chat/ChatQueryRoomResults.java | 18 +++---- src/services/chat/ChatRoom.java | 54 +++++++++++-------- src/services/chat/ChatService.java | 30 +++++------ 3 files changed, 56 insertions(+), 46 deletions(-) diff --git a/src/protocol/swg/chat/ChatQueryRoomResults.java b/src/protocol/swg/chat/ChatQueryRoomResults.java index da760c20..33d29f77 100644 --- a/src/protocol/swg/chat/ChatQueryRoomResults.java +++ b/src/protocol/swg/chat/ChatQueryRoomResults.java @@ -54,37 +54,37 @@ public class ChatQueryRoomResults extends SWGMessage { buffer.putShort((short) 7); buffer.putInt(0xC4DE864E); - Vector users = room.getUserList(); + Vector users = room.getUserList(); buffer.putInt(users.size()); if (users.size() > 0) { - for (CreatureObject creo : users) { + for (String str : users) { buffer.put(getAsciiString("SWG")); buffer.put(getAsciiString(server)); - buffer.put(getAsciiString(creo.getCustomName())); + buffer.put(getAsciiString(str)); } } buffer.putInt(0); // TODO: Invited list for chat rooms - Vector moderators = room.getModeratorList(); + Vector moderators = room.getModeratorList(); buffer.putInt(moderators.size()); if (moderators.size() > 0) { - for (CreatureObject creo : users) { + for (String str : moderators) { buffer.put(getAsciiString("SWG")); buffer.put(getAsciiString(server)); - buffer.put(getAsciiString(creo.getCustomName())); + buffer.put(getAsciiString(str)); } } - Vector banned = room.getBanList(); + Vector banned = room.getBanList(); buffer.putInt(banned.size()); if (banned.size() > 0) { - for (CreatureObject creo : users) { + for (String str : banned) { buffer.put(getAsciiString("SWG")); buffer.put(getAsciiString(server)); - buffer.put(getAsciiString(creo.getCustomName())); + buffer.put(getAsciiString(str)); } } diff --git a/src/services/chat/ChatRoom.java b/src/services/chat/ChatRoom.java index a2428907..d489e3e1 100644 --- a/src/services/chat/ChatRoom.java +++ b/src/services/chat/ChatRoom.java @@ -37,10 +37,10 @@ public class ChatRoom { private int roomId; private String roomAddress; // name - private Vector moderatorList = new Vector(); - private Vector banList = new Vector(); + private Vector moderatorList = new Vector(); + private Vector banList = new Vector(); @NotPersistent - private Vector userList = new Vector(); // current users + private Vector userList = new Vector(); // current users private boolean moderatorsOnly; private boolean privateRoom; @@ -50,9 +50,9 @@ public class ChatRoom { public String getCreator() { return creator; } - + public void setCreator(String creator) { - this.creator = creator; + this.creator = creator.toLowerCase(); } public String getRoomAddress() { @@ -71,22 +71,14 @@ public class ChatRoom { this.roomId = roomId; } - public Vector getModeratorList() { + public Vector getModeratorList() { return moderatorList; } - public void setModeratorList(Vector moderatorList) { - this.moderatorList = moderatorList; - } - - public Vector getUserList() { + public Vector getUserList() { return userList; } - public void setUserList(Vector userList) { - this.userList = userList; - } - public boolean isModeratorsOnly() { return moderatorsOnly; } @@ -108,17 +100,13 @@ public class ChatRoom { } public void setOwner(String owner) { - this.owner = owner; + this.owner = owner.toLowerCase(); } - public Vector getBanList() { + public Vector getBanList() { return banList; } - public void setBanList(Vector banList) { - this.banList = banList; - } - public String getDescription() { return description; } @@ -134,4 +122,28 @@ public class ChatRoom { public void setVisible(boolean visible) { this.visible = visible; } + + public void addUser(String user) { + userList.add(user.toLowerCase()); + } + + public void addModerator(String moderator) { + moderatorList.add(moderator.toLowerCase()); + } + + public void banUser(String user) { + banList.add(user.toLowerCase()); + } + + public boolean hasUser(String user) { + return userList.contains(user.toLowerCase()); + } + + public boolean hasModerator(String moderator) { + return moderatorList.contains(moderator.toLowerCase()); + } + + public boolean hasBan(String user) { + return banList.contains(user.toLowerCase()); + } } diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index 06afbab6..06844115 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -451,7 +451,7 @@ public class ChatService implements INetworkDispatch { ChatEnterRoomById sentPacket = new ChatEnterRoomById(); sentPacket.deserialize(data); - joinChatRoom((CreatureObject) obj, sentPacket.getRoomId()); + joinChatRoom(obj.getCustomName(), sentPacket.getRoomId()); //System.out.println("Entering room... " + sentPacket.getRoomId()); @@ -763,24 +763,25 @@ public class ChatService implements INetworkDispatch { return room; } - public void joinChatRoom(CreatureObject player, int roomId) { + public void joinChatRoom(String user, int roomId) { - String playerName = player.getCustomName().toLowerCase(); - - if (playerName.contains(" ")) - playerName = playerName.split(" ")[0]; + if (user.contains(" ")) + user = user.split(" ")[0]; ChatRoom room = getChatRoom(roomId); if (room == null) return; - ChatOnEnteredRoom enterRoom = new ChatOnEnteredRoom(playerName, 0, roomId, true); - - if (!room.getUserList().contains(player)) - room.getUserList().add(player); - - room.getUserList().stream().forEach(user -> user.getClient().getSession().write(enterRoom.serialize())); + if (!room.hasUser(user)) { + ChatOnEnteredRoom enterRoom = new ChatOnEnteredRoom(user, 0, roomId, true); + room.addUser(user); + + room.getUserList().stream().forEach(str -> { + SWGObject userObj = getObjectByFirstName(str); + if (userObj != null) { userObj.getClient().getSession().write(enterRoom.serialize()); } + }); + } } public void leaveChatRoom(CreatureObject player, int roomId) { @@ -815,11 +816,8 @@ public class ChatService implements INetworkDispatch { sender.getClient().getSession().write(onSend.serialize()); ChatRoomMessage roomMessage = new ChatRoomMessage(roomId, senderName, message); - Vector users = room.getUserList(); + Vector users = room.getUserList(); - for (CreatureObject user : users) { - user.getClient().getSession().write(roomMessage.serialize()); - } } public ConcurrentHashMap getChatRooms() { From e23fd23c2ac2534ae7af7dbc0b4ee2c6b3c5e71c Mon Sep 17 00:00:00 2001 From: Waverunner Date: Thu, 10 Apr 2014 15:32:45 -0400 Subject: [PATCH 63/68] Fixed null error on startup --- nge.cfg | 1 - src/main/NGECore.java | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nge.cfg b/nge.cfg index 6d4d88df..036d6202 100644 --- a/nge.cfg +++ b/nge.cfg @@ -13,5 +13,4 @@ GALAXY_ID=2 GALAXY_NAME=Local Connection XPMULTIPLIER=1.0 MAXNUMBEROFCHARACTERS=2 -LOAD.RESOURCE.SYSTEM=1 MOTD=Welcome to PSWG Test Center! \ No newline at end of file diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 02469dff..b081dc0b 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -240,6 +240,11 @@ public class NGECore { if (!(config.loadConfigFile())) { config = DefaultConfig.getConfig(); } + + Config options = new Config(); + options.setFilePath("options.cfg"); + boolean optionsConfigLoaded = options.loadConfigFile(); + // Database databaseConnection = new DatabaseConnection(); databaseConnection.connect(config.getString("DB.URL"), config.getString("DB.NAME"), config.getString("DB.USER"), config.getString("DB.PASS"), "postgresql"); @@ -309,7 +314,7 @@ public class NGECore { aiService = new AIService(this); //missionService = new MissionService(this); - if (config.getInt("LOAD.RESOURCE.SYSTEM") == 1) { + if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") == 1) { surveyService = new SurveyService(this); resourceService = new ResourceService(this); } @@ -413,7 +418,7 @@ public class NGECore { objectService.loadBuildings(); - if (config.getInt("LOAD.RESOURCE.SYSTEM") == 1) { + if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") > 0) { objectService.loadResourceRoots(); objectService.loadResources(); } From 0eab2ff8c93a2645afb4543b3f11633ff101a15b Mon Sep 17 00:00:00 2001 From: Seefo Date: Thu, 10 Apr 2014 17:38:37 -0400 Subject: [PATCH 64/68] Fixed an issue where killing an NPC did not set you as the killer object --- src/services/combat/CombatService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 1f455338..f8cbb7fc 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -191,7 +191,9 @@ public class CombatService implements INetworkDispatch { { defender.removeDefender(creature); creature.removeDefender(defender); - } + } + + if(((CreatureObject) target).getPlayerObject() == null) target.setKiller(attacker); } } else if(target instanceof TangibleObject) From f7bac13377eac7d9f95f62be051719ce36e0ffb4 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Thu, 10 Apr 2014 18:13:45 -0400 Subject: [PATCH 65/68] Added chat channels for all planets (system and planetary chat) --- src/protocol/swg/chat/ChatRoomList.java | 59 ++++++++++++------ src/protocol/swg/chat/ChatServerStatus.java | 2 + src/protocol/swg/chat/VoiceChatStatus.java | 47 +++++++++++++++ src/services/TerrainService.java | 5 ++ src/services/chat/ChatRoom.java | 1 - src/services/chat/ChatService.java | 66 ++++++++++++++++----- src/services/object/ObjectService.java | 24 ++++---- 7 files changed, 159 insertions(+), 45 deletions(-) create mode 100644 src/protocol/swg/chat/VoiceChatStatus.java diff --git a/src/protocol/swg/chat/ChatRoomList.java b/src/protocol/swg/chat/ChatRoomList.java index b183b140..3021f72f 100644 --- a/src/protocol/swg/chat/ChatRoomList.java +++ b/src/protocol/swg/chat/ChatRoomList.java @@ -34,11 +34,16 @@ import services.chat.ChatRoom; public class ChatRoomList extends SWGMessage { private ConcurrentHashMap chatRooms; + private ChatRoom room; public ChatRoomList(ConcurrentHashMap chatRooms) { this.chatRooms = chatRooms; } + public ChatRoomList(ChatRoom room) { + this.room = room; + } + @Override public void deserialize(IoBuffer data) { @@ -53,24 +58,42 @@ public class ChatRoomList extends SWGMessage { buffer.putShort((short) 2); buffer.putInt(0x70DEB197); - buffer.putInt(chatRooms.size()); - chatRooms.forEach((key, value) -> { - if (value.isVisible()) { - buffer.putInt(value.getRoomId()); - buffer.putInt((int) ((value.isPrivateRoom() ? 1 : 0))); - buffer.put((byte) ((value.isModeratorsOnly() ? 1 : 0))); - buffer.put(getAsciiString(value.getRoomAddress())); - buffer.put(getAsciiString("SWG")); - buffer.put(getAsciiString(server)); - buffer.put(getAsciiString(value.getOwner())); - buffer.put(getAsciiString("SWG")); - buffer.put(getAsciiString(server)); - buffer.put(getAsciiString(value.getCreator())); - buffer.put(getUnicodeString(value.getDescription())); - buffer.putInt(0); // moderator list (not used by client) - buffer.putInt(0); // user list (not used by client) - } - }); + if (room != null) { + buffer.putInt(1); + + buffer.putInt(room.getRoomId()); + buffer.putInt((int) ((room.isPrivateRoom() ? 1 : 0))); + buffer.put((byte) ((room.isModeratorsOnly() ? 1 : 0))); + buffer.put(getAsciiString(room.getRoomAddress())); + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(room.getOwner())); + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(room.getCreator())); + buffer.put(getUnicodeString(room.getDescription())); + buffer.putInt(0); // moderator list (not used by client) + buffer.putInt(0); // user list (not used by client) + } else { + buffer.putInt(chatRooms.size()); + chatRooms.forEach((key, value) -> { + if (value.isVisible()) { + buffer.putInt(value.getRoomId()); + buffer.putInt((int) ((value.isPrivateRoom() ? 1 : 0))); + buffer.put((byte) ((value.isModeratorsOnly() ? 1 : 0))); + buffer.put(getAsciiString(value.getRoomAddress())); + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(value.getOwner())); + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(value.getCreator())); + buffer.put(getUnicodeString(value.getDescription())); + buffer.putInt(0); // moderator list (not used by client) + buffer.putInt(0); // user list (not used by client) + } + }); + } buffer.flip(); //StringUtilities.printBytes(buffer.array()); return buffer; diff --git a/src/protocol/swg/chat/ChatServerStatus.java b/src/protocol/swg/chat/ChatServerStatus.java index a867a244..2de0db65 100644 --- a/src/protocol/swg/chat/ChatServerStatus.java +++ b/src/protocol/swg/chat/ChatServerStatus.java @@ -29,6 +29,8 @@ import protocol.swg.SWGMessage; public class ChatServerStatus extends SWGMessage { + public ChatServerStatus() { } + @Override public void deserialize(IoBuffer data) { } diff --git a/src/protocol/swg/chat/VoiceChatStatus.java b/src/protocol/swg/chat/VoiceChatStatus.java new file mode 100644 index 00000000..97936a19 --- /dev/null +++ b/src/protocol/swg/chat/VoiceChatStatus.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.chat; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class VoiceChatStatus extends SWGMessage { + + public VoiceChatStatus() { } + + @Override + public void deserialize(IoBuffer data) { + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 2); + buffer.putInt(0x9E601905); + buffer.putInt(1); + return buffer.flip(); + } + +} diff --git a/src/services/TerrainService.java b/src/services/TerrainService.java index c8b3aaf5..497477db 100644 --- a/src/services/TerrainService.java +++ b/src/services/TerrainService.java @@ -175,6 +175,11 @@ public class TerrainService { core.mapService.addPlanet(planet); noBuildAreas.put(planet, new ArrayList()); loadClientRegions(planet); + + core.chatService.createChatRoom("public chat for this planet, cannot create rooms here", name + ".Planet", "SYSTEM", true); + core.chatService.createChatRoom("system messages for this planet, cannot create rooms here", name + ".system", "SYSTEM", true); + + System.out.println("Created chat rooms for " + name); } diff --git a/src/services/chat/ChatRoom.java b/src/services/chat/ChatRoom.java index d489e3e1..1cc7f2a2 100644 --- a/src/services/chat/ChatRoom.java +++ b/src/services/chat/ChatRoom.java @@ -23,7 +23,6 @@ package services.chat; import java.util.Vector; -import resources.objects.creature.CreatureObject; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.NotPersistent; diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index 06844115..4175d886 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -24,6 +24,7 @@ package services.chat; import java.nio.ByteOrder; import java.util.Date; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Random; import java.util.Vector; @@ -40,6 +41,7 @@ import engine.resources.config.Config; import engine.resources.config.DefaultConfig; import engine.resources.database.ObjectDatabase; import engine.resources.objects.SWGObject; +import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -48,6 +50,7 @@ import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import protocol.swg.AddIgnoreMessage; import protocol.swg.ObjControllerMessage; +import protocol.swg.chat.ChatCreateRoom; import protocol.swg.chat.ChatDeletePersistentMessage; import protocol.swg.chat.ChatEnterRoomById; import protocol.swg.chat.ChatFriendsListUpdate; @@ -55,6 +58,7 @@ import protocol.swg.chat.ChatInstantMessageToCharacter; import protocol.swg.chat.ChatInstantMessagetoClient; import protocol.swg.chat.ChatOnAddFriend; import protocol.swg.chat.ChatOnChangeFriendStatus; +import protocol.swg.chat.ChatOnCreateRoom; import protocol.swg.chat.ChatOnEnteredRoom; import protocol.swg.chat.ChatOnSendInstantMessage; import protocol.swg.chat.ChatOnSendPersistentMessage; @@ -65,6 +69,7 @@ import protocol.swg.chat.ChatRequestPersistentMessage; import protocol.swg.chat.ChatRoomList; import protocol.swg.chat.ChatRoomMessage; import protocol.swg.chat.ChatSendToRoom; +import protocol.swg.chat.ChatServerStatus; import protocol.swg.chat.ChatSystemMessage; import protocol.swg.objectControllerObjects.PlayerEmote; import protocol.swg.objectControllerObjects.SpatialChat; @@ -359,11 +364,10 @@ public class ChatService implements INetworkDispatch { if (obj == null) return; - //ChatServerStatus chatServerStatus = new ChatServerStatus(); - //client.getSession().write(chatServerStatus.serialize()); - ChatRoomList listMessage = new ChatRoomList(chatRooms); client.getSession().write(listMessage.serialize()); + + //System.out.println("Sent the room request responses."); } }); @@ -391,11 +395,13 @@ public class ChatService implements INetworkDispatch { if (room != null) { room.setPrivateRoom(sentPacket.isPrivacy()); room.setModeratorsOnly(sentPacket.isModeratorOnly()); - room.getUserList().add(creo); - room.getModeratorList().add(creo); + room.addUser(creo.getCustomName()); + room.addModerator(creo.getCustomName()); ChatOnCreateRoom response = new ChatOnCreateRoom(room, 0, sentPacket.getRequest()); session.write(response.serialize()); - }*/ + } + + System.out.println("Created room.");*/ }); @@ -417,6 +423,7 @@ public class ChatService implements INetworkDispatch { }); swgOpcodes.put(Opcodes.ChatSendToRoom, (session, data) -> { + //System.out.println("send to room!"); Client client = core.getClient(session); if(client == null) @@ -723,8 +730,19 @@ public class ChatService implements INetworkDispatch { } private void loadChatRooms() { - ChatRoom system = createChatRoom("", "Chat", "system", true); - chatRooms.put(system.getRoomId(), system); + + /* + * Battlefields channel format: + * SWG.serverName.battlefield.bfMapName + * + * TODO: Research other channel address formats + */ + + ChatRoom system = createChatRoom("", "system", "system", true); + System.out.println("Created chat room " + system.getRoomAddress()); + + //createChatRoom("Bounty Hunter chat for this galaxy", "BountyHunter", "SYSTEM", true); + //createChatRoom("Commando chat for this galaxy", "Commando", "SYSTEM", true); EntityCursor cursor = chatRoomsODB.getCursor(Integer.class, ChatRoom.class); cursor.forEach(room -> { @@ -763,25 +781,43 @@ public class ChatService implements INetworkDispatch { return room; } - public void joinChatRoom(String user, int roomId) { + public boolean joinChatRoom(String user, String roomAddress) { + chatRooms.forEach((k, v) -> { + if (v.getRoomAddress().equals(roomAddress)) { + joinChatRoom(user, k); + return; + } + }); + return false; + } + public boolean joinChatRoom(String user, int roomId) { if (user.contains(" ")) user = user.split(" ")[0]; ChatRoom room = getChatRoom(roomId); if (room == null) - return; - - if (!room.hasUser(user)) { + return false; + if (!room.hasUser(user.toLowerCase())) { + room.addUser(user.toLowerCase()); + + if (!room.isVisible()) { + CreatureObject creo = (CreatureObject) getObjectByFirstName(user); + if (creo != null) { + ChatRoomList listMessage = new ChatRoomList(room); + creo.getClient().getSession().write(listMessage.serialize()); + } + } ChatOnEnteredRoom enterRoom = new ChatOnEnteredRoom(user, 0, roomId, true); - room.addUser(user); - + room.getUserList().stream().forEach(str -> { SWGObject userObj = getObjectByFirstName(str); - if (userObj != null) { userObj.getClient().getSession().write(enterRoom.serialize()); } + userObj.getClient().getSession().write(enterRoom.serialize()); }); + return true; } + return false; } public void leaveChatRoom(CreatureObject player, int roomId) { diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 816d910b..61aba9b9 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -72,6 +72,7 @@ import protocol.swg.chat.ChatOnConnectAvatar; import protocol.swg.chat.ChatOnGetFriendsList; import protocol.swg.chat.ChatRoomList; import protocol.swg.chat.ChatServerStatus; +import protocol.swg.chat.VoiceChatStatus; import protocol.swg.objectControllerObjects.UiPlayEffect; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.CrcStringTableVisitor; @@ -752,7 +753,7 @@ public class ObjectService implements INetworkDispatch { objectList.put(object.getObjectID(), object); } - }); + }); if(creature.getParentId() != 0) { SWGObject parent = getObject(creature.getParentId()); @@ -778,25 +779,25 @@ public class ObjectService implements INetworkDispatch { CmdStartScene startScene = new CmdStartScene((byte) 0, objectId, creature.getPlanet().getPath(), creature.getTemplate(), position.x, position.y, position.z, core.getGalacticTime(), 0); session.write(startScene.serialize()); + ChatServerStatus chatServerStatus = new ChatServerStatus(); + client.getSession().write(chatServerStatus.serialize()); + + VoiceChatStatus voiceStatus = new VoiceChatStatus(); + client.getSession().write(voiceStatus.serialize()); + ParametersMessage parameters = new ParametersMessage(); session.write(parameters.serialize()); - creature.makeAware(core.guildService.getGuildObject()); + ChatOnConnectAvatar chatConnect = new ChatOnConnectAvatar(); + creature.getClient().getSession().write(chatConnect.serialize()); + + creature.makeAware(core.guildService.getGuildObject()); core.chatService.loadMailHeaders(client); core.simulationService.handleZoneIn(client); creature.makeAware(creature); - ChatServerStatus chatStatus = new ChatServerStatus(); - creature.getClient().getSession().write(chatStatus.serialize()); - - ChatOnConnectAvatar chatConnect = new ChatOnConnectAvatar(); - creature.getClient().getSession().write(chatConnect.serialize()); - - ChatRoomList chatRooms = new ChatRoomList(core.chatService.getChatRooms()); - creature.getClient().getSession().write(chatRooms.serialize()); - //ChatOnGetFriendsList friendsListMessage = new ChatOnGetFriendsList(ghost); //client.getSession().write(friendsListMessage.serialize()); @@ -832,6 +833,7 @@ public class ObjectService implements INetworkDispatch { if(!core.getConfig().getString("MOTD").equals("")) creature.sendSystemMessage(core.getConfig().getString("MOTD"), (byte) 2); + core.chatService.joinChatRoom(creature.getCustomName().toLowerCase(), "SWG." + core.getGalaxyName() + "." + creature.getPlanet().getName() + ".Planet"); core.playerService.postZoneIn(creature); } From 646476c17dda40f8bfed0713c5309f8d0001587f Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Fri, 11 Apr 2014 01:48:27 +0200 Subject: [PATCH 66/68] Harvesters introduced Working harvesters and generators Big update --- scripts/commands/harvesteractivate.py | 10 + scripts/commands/harvesterdeactivate.py | 10 + scripts/commands/harvesterdiscardhopper.py | 11 + scripts/commands/harvesterselectresource.py | 10 + scripts/commands/permissionlistmodify.py | 10 + scripts/commands/placestructure.py | 8 +- scripts/commands/resourceemptyhopper.py | 10 + .../power_generator_fusion_style_1.py | 4 + .../power_generator_geothermal_style_1.py | 4 + .../power_generator_photo_bio_style_1.py | 4 + .../power_generator_solar_style_1.py | 4 + .../power_generator_wind_style_1.py | 4 + .../mining_gas_harvester_style_1.py | 4 + .../mining_gas_harvester_style_2.py | 4 + .../mining_gas_harvester_style_3.py | 4 + .../mining_gas_harvester_style_4.py | 4 + .../mining_liquid_harvester_style_1.py | 4 + .../mining_liquid_harvester_style_2.py | 4 + .../mining_liquid_harvester_style_3.py | 4 + .../mining_liquid_harvester_style_4.py | 4 + .../mining_liquid_moisture_harvester.py | 4 + .../mining_liquid_moisture_harvester_elite.py | 4 + .../mining_liquid_moisture_harvester_heavy.py | 4 + ...mining_liquid_moisture_harvester_medium.py | 4 + .../mining_ore/mining_ore_harvester_elite.py | 4 + .../mining_ore/mining_ore_harvester_heavy.py | 4 + .../mining_ore_harvester_style_1.py | 4 + .../mining_ore_harvester_style_2.py | 4 + .../mining_organic_flora_farm.py | 4 + .../mining_organic_flora_farm_elite.py | 4 + .../mining_organic_flora_farm_heavy.py | 4 + .../mining_organic_flora_farm_medium.py | 4 + .../harvester_deed/harvester_flora_deed.py | 5 + .../harvester_flora_deed_elite.py | 5 + .../harvester_flora_deed_heavy.py | 5 + .../harvester_flora_deed_medium.py | 5 + .../deed/harvester_deed/harvester_gas_deed.py | 5 + .../harvester_gas_deed_elite.py | 5 + .../harvester_gas_deed_heavy.py | 5 + .../harvester_gas_deed_medium.py | 5 + .../harvester_deed/harvester_liquid_deed.py | 5 + .../harvester_liquid_deed_elite.py | 5 + .../harvester_liquid_deed_heavy.py | 5 + .../harvester_liquid_deed_medium.py | 5 + .../harvester_deed/harvester_moisture_deed.py | 5 + .../harvester_moisture_deed_elite.py | 5 + .../harvester_moisture_deed_heavy.py | 5 + .../harvester_moisture_deed_medium.py | 5 + .../harvester_ore_deed_elite.py | 5 + .../harvester_ore_heavy_deed.py | 5 + .../harvester_deed/harvester_ore_s1_deed.py | 5 + .../harvester_deed/harvester_ore_s2_deed.py | 5 + scripts/radial/generator.py | 53 + scripts/radial/harvester.py | 58 + scripts/radial/harvesterDeed.py | 23 + scripts/radial/harvesterHopper.py | 21 + src/main/NGECore.java | 3 + .../common/ObjControllerOpcodes.java | 3 +- src/resources/objects/deed/Deed.java | 37 + .../objects/deed/Harvester_Deed.java | 121 ++ .../harvester/HarvesterMessageBuilder.java | 803 ++++++++++++- .../objects/harvester/HarvesterObject.java | 490 ++++++++ .../InstallationMessageBuilder.java | 201 +++- .../installation/InstallationObject.java | 11 +- .../resource/ResourceContainerObject.java | 4 +- src/services/DevService.java | 198 +++ src/services/command/CommandService.java | 42 +- src/services/object/ObjectService.java | 26 +- src/services/resources/HarvesterService.java | 1070 +++++++++++++++++ src/services/resources/ResourceService.java | 33 + src/services/sui/SUIService.java | 21 + 71 files changed, 3476 insertions(+), 11 deletions(-) create mode 100644 scripts/commands/harvesteractivate.py create mode 100644 scripts/commands/harvesterdeactivate.py create mode 100644 scripts/commands/harvesterdiscardhopper.py create mode 100644 scripts/commands/harvesterselectresource.py create mode 100644 scripts/commands/permissionlistmodify.py create mode 100644 scripts/commands/resourceemptyhopper.py create mode 100644 scripts/radial/generator.py create mode 100644 scripts/radial/harvester.py create mode 100644 scripts/radial/harvesterDeed.py create mode 100644 scripts/radial/harvesterHopper.py create mode 100644 src/resources/objects/deed/Deed.java create mode 100644 src/resources/objects/deed/Harvester_Deed.java create mode 100644 src/services/resources/HarvesterService.java diff --git a/scripts/commands/harvesteractivate.py b/scripts/commands/harvesteractivate.py new file mode 100644 index 00000000..5411445a --- /dev/null +++ b/scripts/commands/harvesteractivate.py @@ -0,0 +1,10 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + core.harvesterService.handleHarvesterActivateCommand(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/commands/harvesterdeactivate.py b/scripts/commands/harvesterdeactivate.py new file mode 100644 index 00000000..3a225b3f --- /dev/null +++ b/scripts/commands/harvesterdeactivate.py @@ -0,0 +1,10 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + core.harvesterService.handleHarvesterDeactivateCommand(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/commands/harvesterdiscardhopper.py b/scripts/commands/harvesterdiscardhopper.py new file mode 100644 index 00000000..3a52f754 --- /dev/null +++ b/scripts/commands/harvesterdiscardhopper.py @@ -0,0 +1,11 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + actor.sendSystemMessage('handleEmptyHarvester', 0) + core.harvesterService.handleEmptyHarvester(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/commands/harvesterselectresource.py b/scripts/commands/harvesterselectresource.py new file mode 100644 index 00000000..69c8c725 --- /dev/null +++ b/scripts/commands/harvesterselectresource.py @@ -0,0 +1,10 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + core.harvesterService.handleHarvesterSelectResourceCommand(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/commands/permissionlistmodify.py b/scripts/commands/permissionlistmodify.py new file mode 100644 index 00000000..a34f8d43 --- /dev/null +++ b/scripts/commands/permissionlistmodify.py @@ -0,0 +1,10 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + core.harvesterService.handlePermissionListModify(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/commands/placestructure.py b/scripts/commands/placestructure.py index edddb24e..f6f5c122 100644 --- a/scripts/commands/placestructure.py +++ b/scripts/commands/placestructure.py @@ -1,4 +1,5 @@ import sys +import resources.objects.deed.Harvester_Deed def setup(): return @@ -8,7 +9,12 @@ def run(core, actor, target, commandString): deedId = long(cmdArgs[0]) deed = core.objectService.getObject(deedId) - + + if (actor.getAttachment('UsingHarvesterDeed') == '1'): + actor.setAttachment('UsingHarvesterDeed', '0'); + core.harvesterService.handlePlaceStructureCommand(actor, target, commandString) + return + positionX = float(cmdArgs[1]) positionZ = float(cmdArgs[2]) #positionY = core.terrainService.getHeight(actor.getPlanetId(), positionX, positionZ) + 2 diff --git a/scripts/commands/resourceemptyhopper.py b/scripts/commands/resourceemptyhopper.py new file mode 100644 index 00000000..3a225b3f --- /dev/null +++ b/scripts/commands/resourceemptyhopper.py @@ -0,0 +1,10 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + core.harvesterService.handleHarvesterDeactivateCommand(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/object/installation/generators/power_generator_fusion_style_1.py b/scripts/object/installation/generators/power_generator_fusion_style_1.py index ccad8904..be7d0439 100644 --- a/scripts/object/installation/generators/power_generator_fusion_style_1.py +++ b/scripts/object/installation/generators/power_generator_fusion_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'generator') + object.setHarvester_type(5) + object.setMaintenanceCost(30) + object.setGenerator(1) return \ No newline at end of file diff --git a/scripts/object/installation/generators/power_generator_geothermal_style_1.py b/scripts/object/installation/generators/power_generator_geothermal_style_1.py index ccad8904..be7d0439 100644 --- a/scripts/object/installation/generators/power_generator_geothermal_style_1.py +++ b/scripts/object/installation/generators/power_generator_geothermal_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'generator') + object.setHarvester_type(5) + object.setMaintenanceCost(30) + object.setGenerator(1) return \ No newline at end of file diff --git a/scripts/object/installation/generators/power_generator_photo_bio_style_1.py b/scripts/object/installation/generators/power_generator_photo_bio_style_1.py index ccad8904..be7d0439 100644 --- a/scripts/object/installation/generators/power_generator_photo_bio_style_1.py +++ b/scripts/object/installation/generators/power_generator_photo_bio_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'generator') + object.setHarvester_type(5) + object.setMaintenanceCost(30) + object.setGenerator(1) return \ No newline at end of file diff --git a/scripts/object/installation/generators/power_generator_solar_style_1.py b/scripts/object/installation/generators/power_generator_solar_style_1.py index ccad8904..be7d0439 100644 --- a/scripts/object/installation/generators/power_generator_solar_style_1.py +++ b/scripts/object/installation/generators/power_generator_solar_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'generator') + object.setHarvester_type(5) + object.setMaintenanceCost(30) + object.setGenerator(1) return \ No newline at end of file diff --git a/scripts/object/installation/generators/power_generator_wind_style_1.py b/scripts/object/installation/generators/power_generator_wind_style_1.py index ccad8904..b82445bb 100644 --- a/scripts/object/installation/generators/power_generator_wind_style_1.py +++ b/scripts/object/installation/generators/power_generator_wind_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'generator') + object.setHarvester_type(5) + object.setMaintenanceCost(20) + object.setGenerator(1) return \ No newline at end of file diff --git a/scripts/object/installation/mining_gas/mining_gas_harvester_style_1.py b/scripts/object/installation/mining_gas/mining_gas_harvester_style_1.py index ccad8904..e90b9514 100644 --- a/scripts/object/installation/mining_gas/mining_gas_harvester_style_1.py +++ b/scripts/object/installation/mining_gas/mining_gas_harvester_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(3) + object.setPowerCost(25); + object.setMaintenanceCost(16); return \ No newline at end of file diff --git a/scripts/object/installation/mining_gas/mining_gas_harvester_style_2.py b/scripts/object/installation/mining_gas/mining_gas_harvester_style_2.py index ccad8904..f90bf1bf 100644 --- a/scripts/object/installation/mining_gas/mining_gas_harvester_style_2.py +++ b/scripts/object/installation/mining_gas/mining_gas_harvester_style_2.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(3) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/installation/mining_gas/mining_gas_harvester_style_3.py b/scripts/object/installation/mining_gas/mining_gas_harvester_style_3.py index ccad8904..5b0bb40b 100644 --- a/scripts/object/installation/mining_gas/mining_gas_harvester_style_3.py +++ b/scripts/object/installation/mining_gas/mining_gas_harvester_style_3.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(3) + object.setPowerCost(75); + object.setMaintenanceCost(90); return \ No newline at end of file diff --git a/scripts/object/installation/mining_gas/mining_gas_harvester_style_4.py b/scripts/object/installation/mining_gas/mining_gas_harvester_style_4.py index ccad8904..145b1356 100644 --- a/scripts/object/installation/mining_gas/mining_gas_harvester_style_4.py +++ b/scripts/object/installation/mining_gas/mining_gas_harvester_style_4.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(3) + object.setPowerCost(100); + object.setMaintenanceCost(120); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_1.py b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_1.py index ccad8904..25f6673f 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_1.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(1) + object.setPowerCost(25); + object.setMaintenanceCost(16); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_2.py b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_2.py index ccad8904..1fc10f74 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_2.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_2.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(1) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_3.py b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_3.py index ccad8904..dab15cfd 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_3.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_3.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(1) + object.setPowerCost(75); + object.setMaintenanceCost(90); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_4.py b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_4.py index ccad8904..b848b851 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_4.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_4.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(1) + object.setPowerCost(100); + object.setMaintenanceCost(120); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester.py b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester.py index ccad8904..3e112037 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(4) + object.setPowerCost(25); + object.setMaintenanceCost(16); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_elite.py b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_elite.py index ccad8904..7577292f 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_elite.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_elite.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(4) + object.setPowerCost(100); + object.setMaintenanceCost(120); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_heavy.py b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_heavy.py index ccad8904..1fcc5436 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_heavy.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_heavy.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(4) + object.setPowerCost(75); + object.setMaintenanceCost(90); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_medium.py b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_medium.py index ccad8904..41919756 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_medium.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_medium.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(4) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/installation/mining_ore/mining_ore_harvester_elite.py b/scripts/object/installation/mining_ore/mining_ore_harvester_elite.py index ccad8904..05c3be8a 100644 --- a/scripts/object/installation/mining_ore/mining_ore_harvester_elite.py +++ b/scripts/object/installation/mining_ore/mining_ore_harvester_elite.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(0) + object.setPowerCost(100); + object.setMaintenanceCost(120); return \ No newline at end of file diff --git a/scripts/object/installation/mining_ore/mining_ore_harvester_heavy.py b/scripts/object/installation/mining_ore/mining_ore_harvester_heavy.py index ccad8904..5dfeb966 100644 --- a/scripts/object/installation/mining_ore/mining_ore_harvester_heavy.py +++ b/scripts/object/installation/mining_ore/mining_ore_harvester_heavy.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(0) + object.setPowerCost(75); + object.setMaintenanceCost(90); return \ No newline at end of file diff --git a/scripts/object/installation/mining_ore/mining_ore_harvester_style_1.py b/scripts/object/installation/mining_ore/mining_ore_harvester_style_1.py index ccad8904..2973a685 100644 --- a/scripts/object/installation/mining_ore/mining_ore_harvester_style_1.py +++ b/scripts/object/installation/mining_ore/mining_ore_harvester_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(0) + object.setPowerCost(25); + object.setMaintenanceCost(16); return \ No newline at end of file diff --git a/scripts/object/installation/mining_ore/mining_ore_harvester_style_2.py b/scripts/object/installation/mining_ore/mining_ore_harvester_style_2.py index ccad8904..e6cfc1b1 100644 --- a/scripts/object/installation/mining_ore/mining_ore_harvester_style_2.py +++ b/scripts/object/installation/mining_ore/mining_ore_harvester_style_2.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(0) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/installation/mining_organic/mining_organic_flora_farm.py b/scripts/object/installation/mining_organic/mining_organic_flora_farm.py index ccad8904..ace61f59 100644 --- a/scripts/object/installation/mining_organic/mining_organic_flora_farm.py +++ b/scripts/object/installation/mining_organic/mining_organic_flora_farm.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(2) + object.setPowerCost(25); + object.setMaintenanceCost(16); return \ No newline at end of file diff --git a/scripts/object/installation/mining_organic/mining_organic_flora_farm_elite.py b/scripts/object/installation/mining_organic/mining_organic_flora_farm_elite.py index ccad8904..53ef7fa9 100644 --- a/scripts/object/installation/mining_organic/mining_organic_flora_farm_elite.py +++ b/scripts/object/installation/mining_organic/mining_organic_flora_farm_elite.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(2) + object.setPowerCost(100); + object.setMaintenanceCost(120); return \ No newline at end of file diff --git a/scripts/object/installation/mining_organic/mining_organic_flora_farm_heavy.py b/scripts/object/installation/mining_organic/mining_organic_flora_farm_heavy.py index ccad8904..08daa7ee 100644 --- a/scripts/object/installation/mining_organic/mining_organic_flora_farm_heavy.py +++ b/scripts/object/installation/mining_organic/mining_organic_flora_farm_heavy.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(2) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/installation/mining_organic/mining_organic_flora_farm_medium.py b/scripts/object/installation/mining_organic/mining_organic_flora_farm_medium.py index ccad8904..08daa7ee 100644 --- a/scripts/object/installation/mining_organic/mining_organic_flora_farm_medium.py +++ b/scripts/object/installation/mining_organic/mining_organic_flora_farm_medium.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(2) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed.py index ccad8904..d6d7b4a8 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff') + object.setStructureTemplate('object/installation/mining_organic/shared_mining_organic_flora_farm.iff') + object.setLotRequirement(1) + object.setBMR(16) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_elite.py b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_elite.py index ccad8904..66784568 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_elite.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_elite.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_organic/shared_mining_organic_flora_farm_elite.iff') + object.setLotRequirement(3) + object.setBMR(120) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_heavy.py b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_heavy.py index ccad8904..097a35ea 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_heavy.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_heavy.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_organic/shared_mining_organic_flora_farm_heavy.iff') + object.setLotRequirement(1) + object.setBMR(90) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_medium.py b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_medium.py index ccad8904..70ea50f2 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_medium.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_medium.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_2.iff') + object.setStructureTemplate('object/installation/mining_organic/shared_mining_organic_flora_farm_medium.iff') + object.setLotRequirement(1) + object.setBMR(60) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed.py index ccad8904..a11974a2 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff') + object.setStructureTemplate('object/installation/mining_gas/shared_mining_gas_harvester_style_1.iff') + object.setLotRequirement(1) + object.setBMR(16) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_elite.py b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_elite.py index ccad8904..814daa8a 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_elite.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_elite.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_gas/shared_mining_gas_harvester_style_4.iff') + object.setLotRequirement(3) + object.setBMR(120) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_heavy.py b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_heavy.py index ccad8904..2111f7bf 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_heavy.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_heavy.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_gas/shared_mining_gas_harvester_style_3.iff') + object.setLotRequirement(1) + object.setBMR(90) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_medium.py b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_medium.py index ccad8904..401da10e 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_medium.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_medium.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_2.iff') + object.setStructureTemplate('object/installation/mining_gas/shared_mining_gas_harvester_style_2.iff') + object.setLotRequirement(1) + object.setBMR(60) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed.py index ccad8904..9bce9e66 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_harvester_style_1.iff') + object.setLotRequirement(1) + object.setBMR(16) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_elite.py b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_elite.py index ccad8904..15cbfa5d 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_elite.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_elite.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_harvester_style_4.iff') + object.setLotRequirement(3) + object.setBMR(120) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_heavy.py b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_heavy.py index ccad8904..ae4c3c71 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_heavy.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_heavy.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_harvester_style_3.iff') + object.setLotRequirement(1) + object.setBMR(90) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_medium.py b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_medium.py index ccad8904..4de7136b 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_medium.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_medium.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_2.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_harvester_style_2.iff') + object.setLotRequirement(1) + object.setBMR(60) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed.py index ccad8904..6540aa1d 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_moisture_harvester.iff') + object.setLotRequirement(1) + object.setBMR(16) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_elite.py b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_elite.py index ccad8904..21dc0cfc 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_elite.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_elite.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_elite.iff') + object.setLotRequirement(3) + object.setBMR(120) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_heavy.py b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_heavy.py index ccad8904..afeb3a4b 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_heavy.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_heavy.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_heavy.iff') + object.setLotRequirement(1) + object.setBMR(90) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_medium.py b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_medium.py index ccad8904..7e9a5efe 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_medium.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_medium.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_2.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_medium.iff') + object.setLotRequirement(1) + object.setBMR(60) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_ore_deed_elite.py b/scripts/object/tangible/deed/harvester_deed/harvester_ore_deed_elite.py index ccad8904..5e0dde67 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_ore_deed_elite.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_ore_deed_elite.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_ore/shared_mining_ore_harvester_elite.iff') + object.setLotRequirement(3) + object.setBMR(120) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_ore_heavy_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_ore_heavy_deed.py index ccad8904..7f765aa8 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_ore_heavy_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_ore_heavy_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_ore/shared_mining_ore_harvester_heavy.iff') + object.setLotRequirement(1) + object.setBMR(90) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_ore_s1_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_ore_s1_deed.py index ccad8904..d2edcd91 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_ore_s1_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_ore_s1_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff') + object.setStructureTemplate('object/installation/mining_ore/shared_mining_ore_harvester_style_1.iff') + object.setLotRequirement(1) + object.setBMR(16) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_ore_s2_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_ore_s2_deed.py index ccad8904..34c6d56c 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_ore_s2_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_ore_s2_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_2.iff') + object.setStructureTemplate('object/installation/mining_ore/shared_mining_ore_harvester_style_2.iff') + object.setLotRequirement(1) + object.setBMR(60) return \ No newline at end of file diff --git a/scripts/radial/generator.py b/scripts/radial/generator.py new file mode 100644 index 00000000..44d7a9b4 --- /dev/null +++ b/scripts/radial/generator.py @@ -0,0 +1,53 @@ +from resources.common import RadialOptions +from protocol.swg import ResourceListForSurveyMessage +from services.sui.SUIService import MessageBoxType +from services.SurveyService import createSurveyRangeSUIWindow +from services.sui.SUIWindow import Trigger +from java.util import Vector +import sys + +def createRadial(core, owner, target, radials): + #(byte parentId, short optionId, byte optionType, String description) + radials.clear() + radials.add(RadialOptions(0, 7, 0, 'Examine')) + radials.add(RadialOptions(0, 78, 0, '@player_structure:management')) + radials.add(RadialOptions(0, 117, 0, '@player_structure:permissions')) + radials.add(RadialOptions(2, 118, 0, '@harvester:manage')) + radials.add(RadialOptions(2, 128, 0, '@player_structure:permission_destroy')) + radials.add(RadialOptions(2, 124, 0, '@player_structure:management_status')) + radials.add(RadialOptions(2, 129, 0, '@player_structure:management_pay')) + radials.add(RadialOptions(2, 50, 0, '@base_player:set_name')) + radials.add(RadialOptions(3, 121, 0, '@player_structure:permission_admin')) + radials.add(RadialOptions(3, 123, 0, '@player_structure:permissions')) + + return + +def handleSelection(core, owner, target, option): + if option == 118 and target: + if owner is not None: + core.harvesterService.handleOperateMachinery(owner,target) + return + if option == 128: + if owner is not None: + core.harvesterService.createDestroySUIPage(owner,target) + return + if option == 124: + if owner is not None: + core.harvesterService.createStatusSUIPage(owner,target) + return + if option == 129: + if owner is not None: + core.harvesterService.createPayMaintenanceSUIPage(owner,target) + return + if option == 50: + if owner is not None: + core.harvesterService.createRenameSUIPage(owner,target) + return + if option == 121: + if owner is not None: + core.harvesterService.handlePermissionAdmin(owner,target) + return + if option == 123: + if owner is not None: + core.harvesterService.handlePermissionHopper(owner,target) + return diff --git a/scripts/radial/harvester.py b/scripts/radial/harvester.py new file mode 100644 index 00000000..079c99ae --- /dev/null +++ b/scripts/radial/harvester.py @@ -0,0 +1,58 @@ +from resources.common import RadialOptions +from protocol.swg import ResourceListForSurveyMessage +from services.sui.SUIService import MessageBoxType +from services.SurveyService import createSurveyRangeSUIWindow +from services.sui.SUIWindow import Trigger +from java.util import Vector +import sys + +def createRadial(core, owner, target, radials): + #(byte parentId, short optionId, byte optionType, String description) + radials.clear() + radials.add(RadialOptions(0, 7, 0, 'Examine')) + radials.add(RadialOptions(0, 78, 0, '@player_structure:management')) + radials.add(RadialOptions(0, 117, 0, '@player_structure:permissions')) + radials.add(RadialOptions(2, 118, 0, '@harvester:manage')) + radials.add(RadialOptions(2, 128, 0, '@player_structure:permission_destroy')) + radials.add(RadialOptions(2, 124, 0, '@player_structure:management_status')) + radials.add(RadialOptions(2, 129, 0, '@player_structure:management_pay')) + radials.add(RadialOptions(2, 50, 0, '@base_player:set_name')) + radials.add(RadialOptions(2, 51, 0, '@player_structure:management_power')) + radials.add(RadialOptions(3, 121, 0, '@player_structure:permission_admin')) + radials.add(RadialOptions(3, 123, 0, '@player_structure:permissions')) + + return + +def handleSelection(core, owner, target, option): + if option == 118 and target: + if owner is not None: + core.harvesterService.handleOperateMachinery(owner,target) + return + if option == 128: + if owner is not None: + core.harvesterService.createDestroySUIPage(owner,target) + return + if option == 124: + if owner is not None: + core.harvesterService.createStatusSUIPage(owner,target) + return + if option == 129: + if owner is not None: + core.harvesterService.createPayMaintenanceSUIPage(owner,target) + return + if option == 50: + if owner is not None: + core.harvesterService.createRenameSUIPage(owner,target) + return + if option == 51: + if owner is not None: + core.harvesterService.handleDepositPower(owner,target) + return + if option == 121: + if owner is not None: + core.harvesterService.handlePermissionAdmin(owner,target) + return + if option == 123: + if owner is not None: + core.harvesterService.handlePermissionHopper(owner,target) + return diff --git a/scripts/radial/harvesterDeed.py b/scripts/radial/harvesterDeed.py new file mode 100644 index 00000000..cc8fdc7a --- /dev/null +++ b/scripts/radial/harvesterDeed.py @@ -0,0 +1,23 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + radials.clear() + radials.add(RadialOptions(0, 21, 1, 'Use Deed')) + #radials.add(RadialOptions(0, 7, 1, '111111')) + #radials.add(RadialOptions(0, 15, 1, '')) + #radials.add(RadialOptions(0, 61, 1, '')) + return + +def handleSelection(core, owner, target, option): + + if option == 21 and target: + owner.setAttachment('UsingHarvesterDeed', '1'); + core.harvesterService.enterStructurePlacementMode(target,owner) + if option == 61 and target: + object5 = core.harvesterService.constructionSite(owner,target) + core.objectService.useObject(owner, target) + if option == 15 and target: + core.objectService.destroyObject(target) + return + \ No newline at end of file diff --git a/scripts/radial/harvesterHopper.py b/scripts/radial/harvesterHopper.py new file mode 100644 index 00000000..3323d45b --- /dev/null +++ b/scripts/radial/harvesterHopper.py @@ -0,0 +1,21 @@ +from resources.common import RadialOptions +from protocol.swg import ResourceListForSurveyMessage +from services.sui.SUIService import MessageBoxType +from services.SurveyService import createSurveyRangeSUIWindow +from services.sui.SUIWindow import Trigger +from java.util import Vector +import sys + +def createRadial(core, owner, target, radials): + #(byte parentId, short optionId, byte optionType, String description) + radials.clear() + radials.add(RadialOptions(0, 7, 0, 'Examine')) + radials.add(RadialOptions(0, 78, 0, '@player_structure:management')) + radials.add(RadialOptions(2, 118, 0, '@harvester:manage')) + return + +def handleSelection(core, owner, target, option): + if option == 118 and target: + if owner is not None: + core.harvesterService.handleOperateMachinery(owner,target) + return diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 02469dff..2f04ffb5 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -84,6 +84,7 @@ import services.LoginService; import services.map.MapService; import services.object.ObjectService; import services.object.UpdateService; +import services.resources.HarvesterService; import services.resources.ResourceService; import services.retro.RetroService; import services.spawn.SpawnService; @@ -180,6 +181,7 @@ public class NGECore { public HousingService housingService; public LootService lootService; + public HarvesterService harvesterService; // Login Server @@ -293,6 +295,7 @@ public class NGECore { conversationService = new ConversationService(this); housingService = new HousingService(this); lootService = new LootService(this); + harvesterService = new HarvesterService(this); if (config.keyExists("JYTHONCONSOLE.PORT")) { int jythonPort = config.getInt("JYTHONCONSOLE.PORT"); diff --git a/src/resources/common/ObjControllerOpcodes.java b/src/resources/common/ObjControllerOpcodes.java index c2d117bd..1c7b626b 100644 --- a/src/resources/common/ObjControllerOpcodes.java +++ b/src/resources/common/ObjControllerOpcodes.java @@ -42,5 +42,6 @@ public class ObjControllerOpcodes { public static final int STOP_NPC_CONVERSATION = 0xDE000000; public static final int NPC_CONVERSATION_OPTIONS = 0xE0000000; public static final int SET_PROFESSION_TEMPLATE = 0x5C040000; - + public static final int RESOURCE_EMPTY_HOPPER = 0xED000000; + } diff --git a/src/resources/objects/deed/Deed.java b/src/resources/objects/deed/Deed.java new file mode 100644 index 00000000..f98c6398 --- /dev/null +++ b/src/resources/objects/deed/Deed.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.objects.deed; + +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import resources.objects.tangible.TangibleObject; + +/** + * @author Charon + */ +public class Deed extends TangibleObject { + + public Deed(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ + super(objectID, planet, template, position, orientation); + } +} diff --git a/src/resources/objects/deed/Harvester_Deed.java b/src/resources/objects/deed/Harvester_Deed.java new file mode 100644 index 00000000..945d9eb3 --- /dev/null +++ b/src/resources/objects/deed/Harvester_Deed.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.objects.deed; +import com.sleepycat.persist.model.Persistent; + +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; + +/** + * @author Charon + */ +@Persistent(version=0) +public class Harvester_Deed extends Deed { + + private String name; + private String structureTemplate; + private String constructorTemplate; + private int outputHopperCapacity=0; + private int BER=0; + private int BMR=0; + private int surplusMaintenance=0; + private int surplusPower=0; + private int lotRequirement; + + + public Harvester_Deed(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ + super(objectID, planet, template, position, orientation); + } + + public int getOutputHopperCapacity() { + return outputHopperCapacity; + } + public void setOutputHopperCapacity(int outputHopperCapacity) { + this.outputHopperCapacity = outputHopperCapacity; + } + public int getBER() { + return BER; + } + public void setBER(int bER) { + this.BER = bER; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getStructureTemplate() { + return structureTemplate; + } + public void setStructureTemplate(String structureTemplate) { + this.structureTemplate = structureTemplate; + } + public int getLotRequirement() { + return lotRequirement; + } + public void setLotRequirement(int lotRequirement) { + this.lotRequirement = lotRequirement; + } + public String getConstructorTemplate() { + return constructorTemplate; + } + public void setConstructorTemplate(String constructorTemplate) { + this.constructorTemplate = constructorTemplate; + } + public int getBMR() { + return BMR; + } + public void setBMR(int BMR) { + this.BMR = BMR; + } + public int getSurplusMaintenance() { + return surplusMaintenance; + } + public void setSurplusMaintenance(int surplusMaintenance) { + this.surplusMaintenance = surplusMaintenance; + } + + public int getSurplusPower() { + return surplusPower; + } + + public void setSurplusPower(int surplusPower) { + this.surplusPower = surplusPower; + } + + + public void setAttributes() { + this.getAttributes().put("@obj_attr_n:volume", "1"); + this.getAttributes().put("@obj_attr_n:examine_maintenance_rate", ""+this.getBMR() + "/hour"); + if (this.getSurplusMaintenance()>0) + this.getAttributes().put("@obj_attr_n:examine_maintenance", ""+this.getSurplusMaintenance()); + + //this.getAttributes().put("@obj_attr_n:energy_maintenance", "0"); + if (this.getSurplusPower()>0) + this.getAttributes().put("@obj_attr_n:examine_power", ""+this.getSurplusPower()); + + this.getAttributes().put("@obj_attr_n:examine_hoppersize", ""+this.getOutputHopperCapacity()); + this.getAttributes().put("@obj_attr_n:examine_extractionrate", ""+this.getBER()); + } +} diff --git a/src/resources/objects/harvester/HarvesterMessageBuilder.java b/src/resources/objects/harvester/HarvesterMessageBuilder.java index 3b6c4602..98daa62a 100644 --- a/src/resources/objects/harvester/HarvesterMessageBuilder.java +++ b/src/resources/objects/harvester/HarvesterMessageBuilder.java @@ -21,6 +21,807 @@ ******************************************************************************/ package resources.objects.harvester; -public class HarvesterMessageBuilder { +import java.nio.ByteOrder; +import java.util.Vector; +import org.apache.mina.core.buffer.IoBuffer; + +import engine.resources.objects.SWGObject; + +import resources.objects.ObjectMessageBuilder; +import resources.objects.building.BuildingObject; +import resources.objects.creature.CreatureObject; +import resources.objects.resource.GalacticResource; +import resources.objects.resource.ResourceContainerObject; + +/** + * @author Charon + */ +public class HarvesterMessageBuilder extends ObjectMessageBuilder{ + + public HarvesterMessageBuilder(HarvesterObject harvesterObject) { + setObject(harvesterObject); + } + + public IoBuffer buildBaseline3() { + + HarvesterObject building = (HarvesterObject) object; + IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + + buffer.putShort((short) 0x0D); + buffer.putFloat(building.getComplexity()); + buffer.put(getAsciiString(building.getStfFilename())); + buffer.putInt(0); + buffer.put(getAsciiString(building.getStfName())); + buffer.putInt(0); + buffer.putInt(0xFF); + //buffer.putInt(0x64); + buffer.putInt(0); + buffer.putInt(0); + buffer.putShort((short) 0); + + buffer.putInt(0); + buffer.putInt(0); + // buffer.putInt(16777216); + buffer.putInt(0x100); + buffer.putInt(0); + buffer.putInt(64); + buffer.putInt(0x201C); + buffer.put((byte) 1); + + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + + buffer.flip(); + buffer = createBaseline("BUIO", (byte) 3, buffer, size); + + return buffer; + + } + + public IoBuffer buildHINO3Delta(HarvesterObject harvester,byte state) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)3); + buffer.putInt(0xB); + buffer.putShort((short)2); + buffer.putShort((short)8); + buffer.put((byte)1); + buffer.putShort((short)1); + buffer.put((byte)0); + buffer.putShort((short)0xD); + buffer.put(state); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } +// 0000: 05 00 53 21 86 12 33 01 0E BE 41 00 00 00 4F 4E ..S!..3...A...ON +// 0010: 49 48 03 0B 00 00 00 02 00 08 00 01 01 00 00 0D IH.............. +// 0020: 00 01 + + + public IoBuffer buildHINO3Delta2(HarvesterObject harvester,byte state) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)3); + buffer.putInt(0xB); + buffer.putShort((short)2); + buffer.putShort((short)8); + buffer.put((byte)0); + buffer.putShort((short)1); + buffer.put((byte)0); + buffer.putShort((short)0xD); + buffer.put(state); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildBaseline6() { + + HarvesterObject building = (HarvesterObject) object; + IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + + buffer.putShort((short) 8); + buffer.putInt(0x43); + + buffer.put(getAsciiString(building.getDetailFilename())); + buffer.putInt(0); + buffer.put(getAsciiString(building.getDetailName())); + buffer.putInt(0); + buffer.put((byte) 0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + + buffer.flip(); + buffer = createBaseline("BUIO", (byte) 6, buffer, size); + + return buffer; + + } + + + public IoBuffer buildHINO7Delta(HarvesterObject harvester,byte state) { + + Vector outputHopperContent = harvester.getOutputHopperContent(); + int hopperContentSize = outputHopperContent.size(); + int iHopperList = 1; + if (hopperContentSize==0) { + iHopperList = 0; + } + //int sizeP = 30 + 15*hopperContentSize; + int sizeP = 30-2-4-4; + //System.out.println("sizeP " + sizeP); + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + buffer.putInt(sizeP); + // dOut.writeInt(0x2D); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put(state); + buffer.putShort((short)9); + buffer.putFloat(harvester.getActualExtractionRate()); + buffer.putShort((short)0x0C); + buffer.put(harvester.getUpdateCount()); +// buffer.putShort((short)0x0D); +// buffer.putInt(iHopperList); +// buffer.putInt(harvester.getResourceUpdateCount()); + int sumOfHopper = 0; + int i = 0; + sumOfHopper = 0; + Vector outputHopper = harvester.getOutputHopperContent(); + for (ResourceContainerObject cont : outputHopper){ + sumOfHopper += cont.getStackCount(); + i++; + } + + buffer.putShort((short)0x0A); + buffer.putInt(sumOfHopper); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildHINO7Delta2(HarvesterObject harvester,byte state) { + + Vector outputHopperContent = harvester.getOutputHopperContent(); + int hopperContentSize = outputHopperContent.size(); + int iHopperList = 1; + if (hopperContentSize==0) { + iHopperList = 0; + } + int sizeP = 30 + 15*hopperContentSize; + //System.out.println("sizeP " + sizeP); + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + buffer.putInt(sizeP); + // dOut.writeInt(0x2D); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put(state); + buffer.putShort((short)9); + buffer.putFloat(harvester.getActualExtractionRate()); + buffer.putShort((short)0x0C); + buffer.put(harvester.getUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(iHopperList); + buffer.putInt(harvester.getResourceUpdateCount()); + int sumOfHopper = 0; + + byte i = 0; + for (ResourceContainerObject container : outputHopperContent){ + buffer.putShort((short)harvester.getResourceUpdateCount()); + buffer.put(i); + buffer.putLong(container.getReferenceID()); + buffer.putInt(container.getStackCount()); + sumOfHopper += container.getStackCount(); + i++; + } + + buffer.putShort((short)0x0A); + buffer.putInt(sumOfHopper); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + // 2 + 2 + 1 + 2 + 4 + 2 + 1 + 2 + 4 + 4 + (hoppersize* 2+1+8+4=15) + 2 + 4 + +// 0000: 05 00 53 21 86 12 33 01 0E BE 41 00 00 00 4F 4E ..S!..3...A...ON +// 0010: 49 48 07 2D 00 00 00 05 00 06 00 01 09 00 3F AE IH.-..........?. +// 0020: 2D 42 0C 00 02 0D 00 01 00 00 00 01 00 00 00 02 -B.............. +// 0030: 00 00 5E C8 62 AB 41 00 00 00 CC F1 0A 40 0A 00 ..^.b.A......@.. +// 0040: CC F1 0A 40 ...@ + + public IoBuffer buildHINO7EmptyHopperDelta(HarvesterObject harvester) { + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + buffer.putInt(21); + buffer.putShort((short)3); + buffer.putShort((short)0x0C); + buffer.put((byte)harvester.getResourceUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(0); + buffer.putInt(harvester.getResourceUpdateCount()); + buffer.putShort((short)0x0A); + buffer.putFloat(harvester.getOutputHopperContent().size()); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildHINO7ExperimentalDelta(HarvesterObject harvester) { + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + buffer.putInt(0x18); + buffer.putShort((short)3); + buffer.putShort((short)0x0C); + buffer.put((byte)harvester.getResourceUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(1); + buffer.putInt(0x1E); + buffer.put((byte)0); + buffer.putShort((short)0); + buffer.putInt(harvester.getResourceUpdateCount()); + buffer.putShort((short)0x0A); + buffer.putFloat(0); // since it's 0 outputhoppercontent + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + +// 0000: 05 00 53 21 86 12 53 D0 AC 41 3F 00 00 00 4F 4E ..S!..S..A?...ON +// 0010: 49 48 07 18 00 00 00 03 00 0C 00 25 0D 00 01 00 IH.........%.... +// 0020: 00 00 1E 00 00 00 00 00 00 0A 00 00 00 00 00 ............... + + + public IoBuffer buildHINO7ExperimentalDelta2(HarvesterObject harvester) { + + int iHopperList = 0; + if (harvester.getOutputHopperContent().size() >= 1) { + iHopperList = 1; + } + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(36); + buffer.putShort((short)3); + buffer.putShort((short)0x0C); + buffer.put(harvester.getUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(iHopperList); + buffer.putInt(harvester.getResourceUpdateCount()); + int i = 0; + int totalStackCount = 0; + Vector outputHopper = harvester.getOutputHopperContent(); + for (ResourceContainerObject cont : outputHopper){ + totalStackCount += cont.getStackCount(); + if (cont.getReferenceID() == harvester.getSelectedHarvestResource().getId()) { + buffer.put((byte)2); + buffer.putShort((short) i); + buffer.putLong(cont.getReferenceID()); + buffer.putFloat((float)cont.getStackCount()); + //System.out.println("TOTAL STACKCOUNT " + (float)cont.getStackCount()); + } + i++; + } + + buffer.putShort((short)0x0A); + buffer.putFloat((float)totalStackCount); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildHINO7ActivateDelta(HarvesterObject harvester) { + + int iHopperList = 0; + if (harvester.getOutputHopperContent().size() >= 1) { + iHopperList = 1; + } + int factor = 0; + Vector outputHopper = harvester.getOutputHopperContent(); + for (ResourceContainerObject cont : outputHopper){ + if (cont.getReferenceID() == harvester.getSelectedHarvestResource().getId()) { + factor = 1; + } + } + + byte iHopperUpdateCounter = harvester.getResourceUpdateCount(); + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + buffer.putInt(5+19+(15*factor)); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put((byte)1); + // 2 + 4 + 4 + 2 + 4 + (15*h) = 16 + 2 + 1 = 19 + buffer.putShort((short)0x0C); + buffer.put(harvester.getUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(iHopperList); + buffer.putInt(iHopperUpdateCounter); + int totalStackCount = 0; + + int i = 0; + + for (ResourceContainerObject cont : outputHopper){ + totalStackCount += cont.getStackCount(); + if (cont.getReferenceID() == harvester.getSelectedHarvestResource().getId()) { + buffer.put((byte)2); + buffer.putShort((short) i); + buffer.putLong(cont.getReferenceID()); + buffer.putFloat((float)cont.getStackCount()); + } + i++; + } + + buffer.putShort((short)0x0A); + buffer.putFloat((float)totalStackCount); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildHINO7ActivateDelta2(HarvesterObject harvester) { + + int iHopperList = 0; + if (harvester.getOutputHopperContent().size() >= 1) { + iHopperList = 1; + } + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(11); + buffer.putShort((short)2); + buffer.putShort((short)6); + buffer.put((byte)1); + buffer.putShort((short)9); + buffer.putFloat(harvester.getActualExtractionRate()); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } +// +// 02 00 06 00 01 09 00 43 94 IH............C. +// 0020: 59 42 YB + + public IoBuffer buildHINO7ActivateDelta2old(HarvesterObject harvester) { + + int iHopperList = 0; + if (harvester.getOutputHopperContent().size() >= 1) { + iHopperList = 1; + } + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(5); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put((byte)1); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildHINO7DeactivateDelta(HarvesterObject harvester) { + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(14); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put((byte)0); + buffer.putShort((short)9); + buffer.putFloat(0); + buffer.putShort((short)0xC); + buffer.put((byte)5); + + // new +// buffer.putShort((short)6); +// buffer.put((byte)0); +// buffer.putShort((short)9); +// buffer.put((byte)0); +// buffer.putShort((short)0xC); +// buffer.put((byte)5); + + // + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildHINO7DeactivateDeltaold(HarvesterObject harvester) { + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(5); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put((byte)0); + + // new + buffer.putShort((short)6); + buffer.put((byte)0); + buffer.putShort((short)9); + buffer.put((byte)0); + buffer.putShort((short)0xC); + buffer.put((byte)5); + + // + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildHINO7ClearDelta(HarvesterObject harvester) { + + int iHopperList = 0; + if (harvester.getOutputHopperContent().size() >= 1) { + iHopperList = 1; + } + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(36); + buffer.putShort((short)3); + buffer.putShort((short)0x0C); + buffer.put(harvester.getUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(iHopperList); + buffer.putInt(harvester.getResourceUpdateCount()); + buffer.put((byte)4); + buffer.putShort((short)0x0A); + buffer.putFloat((float)0.0F); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildDiscardResourceResponse(HarvesterObject harvester, byte actionMode, byte actionCounter,CreatureObject owner) { + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x80CE5E46); + buffer.putInt(0x0B); + buffer.putInt(0xEE); + buffer.putLong(owner.getObjectID()); + buffer.putInt(0); + buffer.putInt(0xED); + buffer.put((byte)1); + buffer.put(actionCounter); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + +//0000: 05 00 46 5E CE 80 0B 00 00 00 EE 00 00 00 62 5F ..F^..........b_ +//0010: 02 15 00 00 01 00 00 00 00 00 ED 00 00 00 01 01 ................ +// ^^ weird but works, should be zero allowed too + + public IoBuffer buildBaseline8() { + IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 0); + int size = buffer.position(); + buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("TANO", (byte) 8, buffer, size); + + return buffer; + } + + public IoBuffer buildBaseline9() { + IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 0); + int size = buffer.position(); + buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("TANO", (byte) 9, buffer, size); + + return buffer; + } + + + public IoBuffer buildHINOBaseline7(HarvesterObject harvester,Vector vSRD) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int sizeP = 74; + + buffer.putShort((short)5); + buffer.putInt(0x68A75F0C); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x4F4E4948); + buffer.put((byte)7); + + int iResourceCount = vSRD.size(); + Vector outputHopperContent = harvester.getOutputHopperContent(); + int hopperContentSize = outputHopperContent.size(); + float outputHopperCount = 0; + + //y = a + 4x + 16x + 12z = a + 20x + 12z + sizeP += (iResourceCount * 4); + sizeP += (iResourceCount * 16); + + sizeP += (hopperContentSize * 12); + + for (int i = 0; i < iResourceCount; i++) { + sizeP += vSRD.get(i).getName().length(); + sizeP += vSRD.get(i).getFileName().length(); + } + + buffer.putInt(sizeP); + + for (ResourceContainerObject container : outputHopperContent){ + outputHopperCount += container.getStackCount(); + } + + buffer.putShort((short)0x0F); + buffer.put((byte)1); + buffer.putInt(iResourceCount); + buffer.putInt(iResourceCount); + + for (int i = 0; i < iResourceCount; i++) { + buffer.putLong(vSRD.get(i).getId()); + } + buffer.putInt(iResourceCount); + + buffer.putInt(iResourceCount); + + for (int i = 0; i < iResourceCount; i++) { + buffer.putLong(vSRD.get(i).getId()); + } + + buffer.putInt(iResourceCount); + + buffer.putInt(iResourceCount); + + for (int i = 0; i < iResourceCount; i++) { + buffer.put(getAsciiString(vSRD.get(i).getName())); + } + + buffer.putInt(iResourceCount); + buffer.putInt(iResourceCount); + for (int i = 0; i < iResourceCount; i++) { + buffer.put(getAsciiString(vSRD.get(i).getFileName())); + + } + + if (harvester.getSelectedHarvestResource() != null) { + buffer.putLong(harvester.getSelectedHarvestResource().getId()); + } else { + buffer.putLong(0); + } + + buffer.put(harvester.isActivated() ? (byte)1 : (byte)0); + + buffer.putInt(harvester.getSpecRate()); // SPEC RATE buffer.putInt(harvester.getBER()); + + buffer.putFloat(harvester.getBER()); + + buffer.putFloat(harvester.getActualExtractionRate()); + buffer.putFloat(outputHopperCount); + buffer.putInt(harvester.getOutputHopperCapacity()); + buffer.put(harvester.getUpdateCount()); + buffer.putInt(hopperContentSize); + buffer.putInt(0); + for (ResourceContainerObject container : outputHopperContent){ + buffer.putLong(container.getReferenceID()); + buffer.putFloat(container.getStackCount()); + } + buffer.put(harvester.getStructuralCondition()); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildCustomNameDelta(HarvesterObject harvester, String customName) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int sizeP = 8; + sizeP += 2*customName.length(); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x54414E4F); + buffer.put((byte)3); + buffer.putInt(sizeP); + buffer.putShort((short)1); + buffer.putShort((short)2); + buffer.put(getUnicodeString(customName)); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildPermissionListCreate(HarvesterObject harvester, Vector permissionList, String listName) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int listSize = permissionList.size(); + buffer.putShort((short)4); + buffer.putInt(0x52F364B8); + buffer.putInt(listSize); + for (String name : permissionList){ + buffer.put(getUnicodeString(name)); + } + //buffer.putInt(0x61); + buffer.putInt(0); + //buffer.putShort((short)0); + buffer.put(getUnicodeString(listName)); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + /* + 0000: 04 00 B8 64 F3 52 01 00 00 00 06 00 00 00 63 00 ...d.R........c. + 0010: 68 00 61 00 72 00 6F 00 6E 00 00 00 00 00 05 00 h.a.r.o.n....... + 0020: 00 00 41 00 44 00 4D 00 49 00 4E 00 ..A.D.M.I.N. + */ + + // Send this in response to the Radial Menu to manage harvesters, + // it is necessary to send this *before* the 07 Baseline! + //ResourceHarvesterActivatePageMessage (BD18C679) + public IoBuffer buildResourceHarvesterActivatePageMessage(HarvesterObject harvester) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)2); + buffer.putInt(0xBD18C679); + buffer.putLong(harvester.getObjectID()); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildHarvesterGetResourceData(HarvesterObject harvester,SWGObject owner,Vector planetResources) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x80CE5E46); + buffer.putInt(0x0B); + buffer.putInt(0x000000EA); + buffer.putLong(owner.getObjectID()); + buffer.putInt(0); + buffer.putLong(harvester.getObjectID()); + if (planetResources == null || planetResources.isEmpty()) { + buffer.putInt(0); + } else { + buffer.putInt(planetResources.size()); + for (int i = 0; i < planetResources.size(); i++) { + float localConcentration = planetResources.get(i).deliverConcentrationForSurvey(owner.getPlanetId(), owner.getPosition().x, owner.getPosition().z); + buffer.putLong(planetResources.get(i).getId()); + buffer.put(getAsciiString(planetResources.get(i).getName())); + buffer.put(getAsciiString(planetResources.get(i).getFileName())); + buffer.put((byte)localConcentration); + } + } + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + // TODO Auto-generated method stub + + } + + @Override + public void sendBaselines() { + + } } diff --git a/src/resources/objects/harvester/HarvesterObject.java b/src/resources/objects/harvester/HarvesterObject.java index b31b40cf..5626ce35 100644 --- a/src/resources/objects/harvester/HarvesterObject.java +++ b/src/resources/objects/harvester/HarvesterObject.java @@ -21,11 +21,501 @@ ******************************************************************************/ package resources.objects.harvester; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Vector; + +import main.NGECore; +import protocol.swg.SceneCreateObjectByCrc; +import protocol.swg.SceneDestroyObject; +import protocol.swg.SceneEndBaselines; +import protocol.swg.UpdatePVPStatusMessage; + import com.sleepycat.persist.model.Persistent; +import services.chat.WaypointAttachment; +import engine.clients.Client; +import engine.resources.common.CRC; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import resources.objects.creature.CreatureObject; +import resources.objects.installation.InstallationMessageBuilder; import resources.objects.installation.InstallationObject; +import resources.objects.player.PlayerObject; +import resources.objects.resource.GalacticResource; +import resources.objects.resource.ResourceContainerObject; +import resources.objects.waypoint.WaypointObject; +import services.chat.Mail; + + +/** + * @author Charon + */ @Persistent(version=0) public class HarvesterObject extends InstallationObject { + + private HarvesterMessageBuilder messageBuilder; + private InstallationMessageBuilder installationMessageBuilder; + + public final static byte HARVESTER_TYPE_MINERAL = 0; + public final static byte HARVESTER_TYPE_CHEMICAL = 1; + public final static byte HARVESTER_TYPE_FLORA = 2; + public final static byte HARVESTER_TYPE_GAS = 3; + public final static byte HARVESTER_TYPE_WATER = 4; + public final static byte HARVESTER_TYPE_SOLAR = 5; + public final static byte HARVESTER_TYPE_WIND = 6; + public final static byte HARVESTER_TYPE_FUSION = 7; + public final static byte HARVESTER_TYPE_GEO = 8; + + public String[] mineral_type_iff = new String[]{"object/installation/mining_ore/shared_mining_ore_harvester_style_1.iff", + "object/installation/mining_ore/shared_mining_ore_harvester_style_2.iff", + "object/installation/mining_ore/shared_mining_ore_harvester_heavy.iff", + "object/installation/mining_ore/shared_mining_ore_harvester_elite.iff"}; + + public String[] chemical_type_iff = new String[]{"object/installation/mining_liquid/shared_mining_liquid_harvester_style_1.iff", + "object/installation/mining_liquid/shared_mining_liquid_harvester_style_2.iff", + "object/installation/mining_liquid/shared_mining_liquid_harvester_style_3.iff", + "object/installation/mining_liquid/shared_mining_liquid_harvester_style_4.iff"}; + + public String[] flora_type_iff = new String[]{"object/installation/mining_organic/shared_mining_organic_flora_farm.iff", + "object/installation/mining_organic/shared_mining_organic_flora_farm_medium.iff", + "object/installation/mining_organic/shared_mining_organic_flora_farm_heavy.iff", + "object/installation/mining_organic/shared_mining_organic_flora_farm_elite.iff"}; + + public String[] water_type_iff = new String[]{"object/installation/mining_liquid/shared_mining_liquid_moisture_harvester.iff", + "object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_medium.iff", + "object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_heavy.iff", + "object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_elite.iff"}; + + public String[] gas_type_iff = new String[]{"object/installation/mining_gas/shared_mining_gas_harvester_style_1.iff", + "object/installation/mining_gas/shared_mining_gas_harvester_style_2.iff", + "object/installation/mining_gas/shared_mining_gas_harvester_style_3.iff", + "object/installation/mining_gas/shared_mining_gas_harvester_style_4.iff"}; + + public String[] wind_type_iff = new String[]{"object/installation/generators/shared_power_generator_wind_style_1.iff"}; + + public String[] solar_type_iff = new String[]{"object/installation/generators/shared_power_generator_solar_style_1.iff"}; + + public String[] fusion_type_iff = new String[]{"object/installation/generators/shared_power_generator_fusion_style_1.iff"}; + + public String[] geo_type_iff = new String[]{"object/installation/generators/shared_power_generator_geothermal_style_1.iff"}; + //for nothing "object/installation/generators/shared_power_generator_photo_bio_style_1.iff" + + + public byte harvester_type = 0; + public byte harvester_size = 0; + private Vector outputHopperContent = new Vector(); + private int outputHopperCapacity = 0; + private int BER = 0; + private float maintenanceAmount = 0; + private float powerLevel = 0; + private int powerCost = 0; + private int maintenanceCost = 0; + private byte structuralCondition = 100; + private boolean activated = false; + private boolean generator = false; + private GalacticResource selectedHarvestResource; + private float selectedResourceConcentration; + private byte updateCount; + private byte resourceUpdateCount; + private Vector adminList = new Vector(); + private Vector hopperList = new Vector(); + private SWGObject owner; + private float currentHarvestedCountFloat=0.0F; + private String deedTemplate; + + private int specRate; + + + public HarvesterObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ + super(objectID, planet, template, position, orientation); + this.setConditionDamage(100); + messageBuilder = new HarvesterMessageBuilder(this); + installationMessageBuilder = new InstallationMessageBuilder((InstallationObject)this); + } + + public int getBER() { + return BER; + } + + + public void setBER(int baseExtractionRate) { + this.BER = baseExtractionRate; + } + + + public float getActualExtractionRate() { + //float resourceDraw = (getBER() * getSelectedResourceConcentration()) / 400; // /100 + float resourceDraw = 1.5F*(getBER() * getSelectedResourceConcentration()) / 100; + // BER * concentration * publish 27 bonus * profession buffs = AER + // 14* 0.83 * 1.5 * 1.05 = 18.3015 AER + return resourceDraw; + } + + public int getSpecRate() { + return specRate; + } + + public void setSpecRate(int specRate) { + this.specRate = specRate; + } + + + public GalacticResource getSelectedHarvestResource() { + return selectedHarvestResource; + } + + + public void setSelectedHarvestResource(GalacticResource selectedHarvestResource,CreatureObject owner) { + this.selectedHarvestResource = selectedHarvestResource; + setSelectedResourceConcentration(selectedHarvestResource.deliverConcentrationForSurvey(this.getPlanetId(), this.getPosition().x, this.getPosition().z)); + + owner.getClient().getSession().write(installationMessageBuilder.constructINSO7Var1((InstallationObject) this,selectedHarvestResource.getObjectId())); + owner.getClient().getSession().write(installationMessageBuilder.constructINSO7Var2((InstallationObject) this,selectedHarvestResource.getObjectId())); + } + + + public float getSelectedResourceConcentration() { + return selectedResourceConcentration; + } + + + private void setSelectedResourceConcentration(float selectedResourceConcentration) { + this.selectedResourceConcentration = selectedResourceConcentration; + } + + + public void activateHarvester(CreatureObject owner){ + activated = true; + this.setOwner(owner); + owner.getClient().getSession().write(messageBuilder.buildHINO3Delta(this,(byte)1)); + owner.getClient().getSession().write(messageBuilder.buildHINO7ActivateDelta2(this)); + } + + + public void deactivateHarvester(CreatureObject owner){ + activated = false; + owner.getClient().getSession().write(messageBuilder.buildHINO3Delta2(this,(byte)0)); + owner.getClient().getSession().write(messageBuilder.buildHINO7DeactivateDelta(this)); + } + + + public boolean isActivated(){ + return this.activated; + } + + + public byte getHarvester_type() { + return harvester_type; + } + + + public void setHarvester_type(byte harvester_type) { + this.harvester_type = harvester_type; + } + + + public Vector getOutputHopperContent() { + return outputHopperContent; + } + + + public void setOutputHopperContent(Vector outputHopperContent) { + this.outputHopperContent = outputHopperContent; + } + + + public byte getStructuralCondition() { + return structuralCondition; + } + + + public void setStructuralCondition(byte structuralCondition) { + this.structuralCondition = structuralCondition; + } + + + public int getOutputHopperCapacity() { + return outputHopperCapacity; + } + + + public void setOutputHopperCapacity(int outputHopperCapacity) { + this.outputHopperCapacity = outputHopperCapacity; + } + + + public byte getUpdateCount() { + if (updateCount>254) updateCount = 0; + return updateCount++; + } + + public byte getResourceUpdateCount() { + if (resourceUpdateCount>254) resourceUpdateCount = 0; + return resourceUpdateCount++; + } + + + public void setUpdateCount(byte updateCount) { + this.updateCount = updateCount; + } + + + public Vector getAdminList() { + return adminList; + } + + + public void setAdminList(Vector adminList) { + this.adminList = adminList; + } + + + public Vector getHopperList() { + return hopperList; + } + + + public void setHopperList(Vector hopperList) { + this.hopperList = hopperList; + } + + + public float getPowerLevel() { + return powerLevel; + } + + + public void setPowerLevel(float energyLevel) { + this.powerLevel = energyLevel; + } + + + public float getMaintenanceAmount() { + return maintenanceAmount; + } + + + public void setMaintenanceAmount(float maintenanceAmount) { + this.maintenanceAmount = maintenanceAmount; + } + + public int getPowerCost() { + return powerCost; + } + + + public void setPowerCost(int powerCost) { + this.powerCost = powerCost; + } + + + public int getMaintenanceCost() { + return maintenanceCost; + } + + + public void setMaintenanceCost(int maintenanceCost) { + this.maintenanceCost = maintenanceCost; + } + + + public float getCurrentHarvestedCountFloat() { + return currentHarvestedCountFloat; + } + + + public void setCurrentHarvestedCountFloat(float currentHarvestedCountFloat) { + this.currentHarvestedCountFloat = currentHarvestedCountFloat; + } + + + public SWGObject getOwner() { + return owner; + } + + + public void setOwner(SWGObject owner) { + this.owner = owner; + } + + public void setDeedTemplate(String deedTemplate){ + this.deedTemplate = deedTemplate; + } + + public String getDeedTemplate(){ + return this.deedTemplate; + } + + + public boolean isGenerator() { + return generator; + } + + public void setGenerator(boolean generator) { + this.generator = generator; + } + + + public void setHarvesterName(String name,CreatureObject owner){ + owner.getClient().getSession().write(messageBuilder.buildCustomNameDelta(this,name)); + this.setCustomName(name); + ((CreatureObject)owner).sendSystemMessage("Structure renamed.", (byte) 0); + } + + public void setPermissionAdmin(String name,CreatureObject owner){ + Vector permissionList = this.getAdminList(); + owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(this, permissionList, name)); + } + + public void setPermissionHopper(String name,CreatureObject owner){ + Vector permissionList = this.getAdminList(); + owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(this, permissionList, name)); + } + + public void operateMachinery(CreatureObject owner){ + owner.getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this)); + // Assemble resources at that spot + // For later, it might be needed to also pass the template to differentiate liquid resources + Vector planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type()); + owner.getClient().getSession().write(messageBuilder.buildHarvesterGetResourceData(this, owner, planetResourcesVector)); + owner.getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector)); + } + + public void deActivate(){ + owner.getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this)); + } + + public void placeHarvester(){ + owner.getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this)); + } + + public static void createAndPlaceHarvester(SWGObject object){ + CreatureObject actor = (CreatureObject) object.getAttachment("Owner"); + + String structureTemplate = (String)object.getAttachment("Deed_StructureTemplate"); + HarvesterObject harvester = (HarvesterObject) NGECore.getInstance().objectService.createObject(structureTemplate, actor.getPlanet()); + long objectId = harvester.getObjectID(); + + Vector adminList = harvester.getAdminList(); + String[] fullName = ((CreatureObject)actor).getCustomName().split(" "); + adminList.add(fullName[0]); + harvester.setAdminList(adminList); + // Set BER and outputhopper capacity here, take it from deed + harvester.setBER((int)object.getAttachment("Deed_BER")); + harvester.setSpecRate((int)(1.5F*(int)object.getAttachment("Deed_BER"))); + harvester.setOutputHopperCapacity((int)object.getAttachment("Deed_Capacity")); + harvester.setDeedTemplate((String)object.getAttachment("Deed_DeedTemplate")); + if ((int)object.getAttachment("Deed_SurplusMaintenance")>0){ + harvester.setMaintenanceAmount((int)object.getAttachment("Deed_SurplusMaintenance")); + } + if ((int)object.getAttachment("Deed_SurplusPower")>0){ + harvester.setPowerLevel((int)object.getAttachment("Deed_SurplusPower")); + } + + + // build harvester + int resCRC = CRC.StringtoCRC(structureTemplate); + float positionY = NGECore.getInstance().terrainService.getHeight(actor.getPlanetId(), object.getPosition().x, object.getPosition().z); + SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(objectId, object.getOrientation().x, object.getOrientation().y, object.getOrientation().z, object.getOrientation().w, object.getPosition().x, positionY, object.getPosition().z, resCRC, (byte) 0); + actor.getClient().getSession().write(createObjectMsg.serialize()); + tools.CharonPacketUtils.printAnalysis(createObjectMsg.serialize()); + + harvester.setPosition(new Point3D(object.getPosition().x,positionY, object.getPosition().z)); + + resources.objects.installation.InstallationMessageBuilder messenger = new resources.objects.installation.InstallationMessageBuilder((InstallationObject)harvester); + actor.getClient().getSession().write(messenger.buildBaseline3((InstallationObject)harvester)); + SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(harvester.getObjectID()); + actor.getClient().getSession().write(sceneEndBaselinesMsg.serialize()); + tools.CharonPacketUtils.printAnalysis(sceneEndBaselinesMsg.serialize()); + + PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); + WaypointObject constructionWaypoint = (WaypointObject)NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", actor.getPlanet(), harvester.getPosition().x, 0 ,harvester.getPosition().z); + String displayname = "@installation_n:"+harvester.getStfName(); + constructionWaypoint.setName(displayname); + constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); + constructionWaypoint.setPosition(new Point3D(object.getPosition().x,0, object.getPosition().z)); + player.waypointAdd(constructionWaypoint); + constructionWaypoint.setPosition(new Point3D(object.getPosition().x,0, object.getPosition().z)); + constructionWaypoint.setActive(true); + constructionWaypoint.setColor((byte)1); + constructionWaypoint.setStringAttribute("", ""); + player.waypointAdd(constructionWaypoint); + constructionWaypoint.setName(displayname); + constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); + player.setLastSurveyWaypoint(constructionWaypoint); + + List attachments = new ArrayList(); + WaypointAttachment attachment = new WaypointAttachment(); + attachment.active = true; + attachment.cellID = constructionWaypoint.getCellId(); + attachment.color = (byte)1; + attachment.name = displayname; + attachment.planetCRC = engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName()); + attachment.positionX = object.getPosition().x; + attachment.positionY = 0; + attachment.positionZ = object.getPosition().z; + attachments.add(attachment); + + // remove constructor + NGECore.getInstance().objectService.destroyObject(object); + SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(object.getObjectID()); + actor.getClient().getSession().write(destroyObjectMsg.serialize()); + + // ToDo: waypoint attachment fix + Date date = new Date(); + Mail constructionNotificationMail = new Mail(); + constructionNotificationMail.setSenderName("Structure Service"); + constructionNotificationMail.setSubject("Your structure"); + constructionNotificationMail.setRecieverId(actor.getObjectID()); + constructionNotificationMail.setTimeStamp((int) (date.getTime() / 1000)); + constructionNotificationMail.setMailId(NGECore.getInstance().chatService.generateMailId()); + String message = "Your construction is ready"; + constructionNotificationMail.setMessage(message); + constructionNotificationMail.setStatus(Mail.NEW); + constructionNotificationMail.setAttachments(attachments); + //NGECore.getInstance().chatService.sendPersistentMessage(actor.getClient(), constructionNotificationMail); + NGECore.getInstance().chatService.storePersistentMessage(constructionNotificationMail); + NGECore.getInstance().chatService.sendPersistentMessageHeader(actor.getClient(), constructionNotificationMail); + + } + + public void createNewHopperContainer(){ + Vector planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type()); + ((CreatureObject)this.getOwner()).getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector)); + ((CreatureObject)this.getOwner()).getClient().getSession().write(messageBuilder.buildHINO7Delta(this,(byte)1)); + } + + public void continueHopperContainer(){ + Vector planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type()); + ((CreatureObject)this.getOwner()).getClient().getSession().write(messageBuilder.buildHarvesterGetResourceData(this, owner, planetResourcesVector)); + ((CreatureObject)this.getOwner()).getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector)); + } + + @Override + public void sendBaselines(Client destination) { + + + if(destination == null || destination.getSession() == null) { + System.out.println("NULL destination"); + return; + } + + destination.getSession().write(messageBuilder.buildBaseline3()); + destination.getSession().write(messageBuilder.buildBaseline6()); + destination.getSession().write(messageBuilder.buildBaseline8()); + destination.getSession().write(messageBuilder.buildBaseline9()); + + if(getPvPBitmask() != 0) { + UpdatePVPStatusMessage upvpm = new UpdatePVPStatusMessage(getObjectID()); + upvpm.setFaction(UpdatePVPStatusMessage.factionCRC.Neutral); + upvpm.setStatus(getPvPBitmask()); + destination.getSession().write(upvpm.serialize()); + } + } } diff --git a/src/resources/objects/installation/InstallationMessageBuilder.java b/src/resources/objects/installation/InstallationMessageBuilder.java index f7902d4e..f9fe356d 100644 --- a/src/resources/objects/installation/InstallationMessageBuilder.java +++ b/src/resources/objects/installation/InstallationMessageBuilder.java @@ -21,6 +21,205 @@ ******************************************************************************/ package resources.objects.installation; -public class InstallationMessageBuilder { +import java.nio.ByteOrder; +import org.apache.mina.core.buffer.IoBuffer; +import resources.objects.ObjectMessageBuilder; +import resources.objects.harvester.HarvesterObject; +/** + * @author Charon + */ + +public class InstallationMessageBuilder extends ObjectMessageBuilder{ + + public InstallationMessageBuilder(InstallationObject installationObject) { + setObject(installationObject); + } + + public IoBuffer buildBaseline3(InstallationObject installationObject) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int packSize = 66; + packSize += installationObject.getStfName().length(); + packSize += installationObject.getStfFilename().length(); + + buffer.putShort((short)5); + buffer.putInt(0x68A75F0C); + buffer.putLong(installationObject.getObjectID()); + buffer.putInt(0x494E534F); + buffer.put((byte)3); + buffer.putInt(packSize); + buffer.putShort((short) 0x05); + buffer.putFloat(installationObject.getComplexity()); + buffer.put(getAsciiString(installationObject.getStfFilename())); // installation_n + buffer.putInt(0); + buffer.put(getAsciiString(installationObject.getStfName())); + buffer.put(getUnicodeString(""));//buffer.put(getUnicodeString(installationObject.getCustomName())); + buffer.putInt(1);// int 1 // oper 3 + buffer.putShort((short)0); + + buffer.putInt(0); + buffer.putInt(0); + buffer.putLong(0); + + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.put((byte)1); + buffer.put((byte)0); + buffer.putFloat(0.0F); + buffer.putFloat(0.0F); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + +// 0000: 05 00 0C 5F A7 68 82 EC 7D 16 00 00 02 00 4F 53 ..._.h..}.....OS +// 0010: 4E 49 06 0E 00 00 00 05 00 76 00 00 00 00 00 00 NI.......v...... +// 0020: 00 01 00 00 00 ..... + + public IoBuffer buildBaseline6(InstallationObject installationObject) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int packSize = 14; + buffer.putShort((short)5); + buffer.putInt(0x68A75F0C); + buffer.putLong(installationObject.getObjectID()); + buffer.putInt(0x494E534F); + buffer.put((byte)6); + buffer.putInt(packSize); + buffer.putShort((short)5); + buffer.putInt(0x76); + buffer.putInt(0); + buffer.putInt(1); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildBaseline7() { + IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 0); + int size = buffer.position(); + buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("INSO", (byte) 7, buffer, size); + + return buffer; + } + + public IoBuffer buildBaseline8() { + IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 0); + int size = buffer.position(); + buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("INSO", (byte) 8, buffer, size); + + return buffer; + } + + public IoBuffer buildBaseline9() { + IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 0); + int size = buffer.position(); + buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("INSO", (byte) 9, buffer, size); + + return buffer; + } + + public IoBuffer buildDelta3(InstallationObject installationObject,IoBuffer packet,int packSize) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(installationObject.getObjectID()); + buffer.putInt(0x494E534F); + buffer.put((byte)3); + buffer.putInt(packSize); + buffer.put(packet); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildDelta7(InstallationObject installationObject,IoBuffer packet,int packSize) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(installationObject.getObjectID()); + buffer.putInt(0x494E534F); + buffer.put((byte)7); + buffer.putInt(packSize); + buffer.put(packet); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer constructINSO7Var1(InstallationObject installationObject,long selectedResource) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + int hopperContentsSize = ((HarvesterObject)installationObject).getOutputHopperContent().size()+1; + byte updateCounter = ((HarvesterObject)installationObject).getUpdateCount(); + + buffer.setAutoExpand(true); + buffer.putShort((short)2); // buffer.putShort((short)updateCounter); + buffer.putShort((short)0xC); + buffer.put((byte)1); + buffer.putShort((short)0xD); + + buffer.putInt(1);//buffer.putInt(hopperContentsSize); // works once with 1! HopperContentsSize->Number of resources in hopper + buffer.putInt(2); // UpdateCounter works once with 2! + buffer.put((byte)1); // subtype : ADD + buffer.putShort((short)0); // index was 0 buffer.putShort((short)(hopperContentsSize-1)); + buffer.putLong(selectedResource); + buffer.putFloat(0); + int size = buffer.position(); + buffer.flip(); + return buildDelta7(installationObject,IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(),size); + } + +// 0000: 05 00 53 21 86 12 82 EC 7D 16 00 00 02 00 4F 53 ..S!....}.....OS +// 0010: 4E 49 07 1E 00 00 00 02 00 0C 00 01 0D 00 01 00 NI.............. +// 0020: 00 00 02 00 00 00 01 00 00 8A D3 79 16 00 00 0F ...........y.... +// 0030: 00 00 00 00 00 ..... + + public IoBuffer constructINSO7Var2(InstallationObject installationObject,long selectedResource) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)2); + buffer.putShort((short)0x9); + buffer.putFloat(0); + buffer.putShort((short)0x5); + buffer.putLong(selectedResource); + int size = buffer.position(); + buffer.flip(); + return buildDelta7(installationObject,IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(),size); + } + +// 0000: 05 00 53 21 86 12 82 EC 7D 16 00 00 02 00 4F 53 ..S!....}.....OS +// 0010: 4E 49 07 12 00 00 00 02 00 09 00 00 00 00 00 05 NI.............. +// 0020: 00 8A D3 79 16 00 00 0F 00 ...y..... + + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + // TODO Auto-generated method stub + + } + + @Override + public void sendBaselines() { + + } } diff --git a/src/resources/objects/installation/InstallationObject.java b/src/resources/objects/installation/InstallationObject.java index 728de4a9..5a3870e7 100644 --- a/src/resources/objects/installation/InstallationObject.java +++ b/src/resources/objects/installation/InstallationObject.java @@ -23,9 +23,16 @@ package resources.objects.installation; import com.sleepycat.persist.model.Persistent; +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; + import resources.objects.tangible.TangibleObject; @Persistent(version=0) public class InstallationObject extends TangibleObject { - -} + + public InstallationObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ + super(objectID, planet, template, position, orientation); + } +} \ No newline at end of file diff --git a/src/resources/objects/resource/ResourceContainerObject.java b/src/resources/objects/resource/ResourceContainerObject.java index b2a0eada..c5b84a9f 100644 --- a/src/resources/objects/resource/ResourceContainerObject.java +++ b/src/resources/objects/resource/ResourceContainerObject.java @@ -47,7 +47,7 @@ public class ResourceContainerObject extends TangibleObject { private CreatureObject proprietor; private String resourceType; - private String resourceClass; + private String resourceClass=""; private String resourceName; private byte generalType; private long referenceID; @@ -148,7 +148,7 @@ public class ResourceContainerObject extends TangibleObject { public void initializeStats(GalacticResource resource){ this.setResourceName(resource.getName()); - this.setResourceClass(resource.getResourceClass()); + this.setResourceClass(resource.getCategory()); this.setColdResistance(resource.getResourceStats()[0]); this.setConductivity(resource.getResourceStats()[1]); this.setDecayResistance(resource.getResourceStats()[2]); diff --git a/src/services/DevService.java b/src/services/DevService.java index ef265f41..b5f0e2d3 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -38,6 +38,7 @@ import resources.common.Opcodes; import resources.common.SpawnPoint; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; +import resources.objects.deed.Harvester_Deed; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.tool.SurveyTool; @@ -84,6 +85,7 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 21, "Weapons"); suiOptions.put((long) 22, "Misc Items"); suiOptions.put((long) 23, "Jedi Items"); + suiOptions.put((long) 26, "Installations"); suiOptions.put((long) 110, "Survey Devices"); if(creature.getClient().isGM()) suiOptions.put((long) 120, "House Deeds"); break; @@ -122,6 +124,10 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 91, "(Dark) Jedi Robe"); suiOptions.put((long) 92, "Belt of Master Bodo Baas"); break; + case 10: // [Items] Jedi Items + suiOptions.put((long) 111, "Harvesters"); + suiOptions.put((long) 112, "Energy resources"); + break; } @@ -187,6 +193,9 @@ public class DevService implements INetworkDispatch { case 25: // Tools sendCharacterBuilderSUI(player, 15); return; + case 26: // Installations + sendCharacterBuilderSUI(player, 10); + return; // [Items] Weapons case 30: // Jedi Weapons @@ -992,7 +1001,196 @@ public class DevService implements INetworkDispatch { solarSurveyTool.setCustomName("Solar Survey Device"); inventory.add(solarSurveyTool); return; + case 111: + // Minerals + String templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_s1_deed.iff"; + Harvester_Deed deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(5); + deed1.setAttributes(); + inventory.add(deed1); + templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_s2_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(11); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_heavy_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(135400); + deed1.setBER(14); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_deed_elite.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(44); + deed1.setAttributes(); + inventory.add(deed1); + + + // Chemicals + templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(5); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed_medium.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(11); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed_heavy.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(135400); + deed1.setBER(14); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed_elite.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(44); + deed1.setAttributes(); + inventory.add(deed1); + + + // Flora + templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(5); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed_medium.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(11); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed_heavy.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(135400); + deed1.setBER(14); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed_elite.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(44); + deed1.setAttributes(); + inventory.add(deed1); + + + // Gas + templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(5); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed_medium.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(11); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed_heavy.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(135400); + deed1.setBER(14); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed_elite.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(44); + deed1.setAttributes(); + inventory.add(deed1); + + + // Water + templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(5); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed_medium.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(11); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed_heavy.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(135400); + deed1.setBER(14); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed_elite.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(44); + deed1.setAttributes(); + inventory.add(deed1); + + + // Generators + templateString="object/tangible/deed/generator_deed/shared_generator_fusion_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(19); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/generator_deed/shared_generator_wind_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(10); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/generator_deed/shared_generator_solar_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(15); + deed1.setAttributes(); + inventory.add(deed1); + +// templateString="object/tangible/deed/generator_deed/shared_generator_photo_bio_deed.iff"; +// deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); +// deed1.setOutputHopperCapacity(250000); +// deed1.setBER(19); +// inventory.add(deed1); + + templateString="object/tangible/deed/generator_deed/shared_generator_geothermal_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(15); + deed1.setAttributes(); + inventory.add(deed1); + + break; + case 112: + core.resourceService.spawnSpecificResourceContainer("Radioactive", player, 100000); + break; case 120: SWGObject houseDeed = core.objectService.createObject("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", planet); inventory.add(houseDeed); diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 34e02ecf..82345d06 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -48,6 +48,7 @@ import protocol.swg.objectControllerObjects.CommandEnqueueRemove; import protocol.swg.objectControllerObjects.ShowFlyText; import protocol.swg.objectControllerObjects.StartTask; import resources.objects.creature.CreatureObject; +import resources.objects.harvester.HarvesterObject; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; @@ -137,7 +138,7 @@ public class CommandService implements INetworkDispatch { target = actor; } - if (target != actor) { + if (target != actor && target instanceof CreatureObject) { return false; } @@ -521,6 +522,45 @@ public class CommandService implements INetworkDispatch { } }); + + objControllerOpcodes.put(ObjControllerOpcodes.RESOURCE_EMPTY_HOPPER, new INetworkRemoteEvent() { + + @Override + public void handlePacket(IoSession session, IoBuffer data) throws Exception { + data.order(ByteOrder.LITTLE_ENDIAN); + Client client = core.getClient(session); + CommandEnqueue commandEnqueue = new CommandEnqueue(); + +// StringBuilder sb = new StringBuilder(); +// for (byte b : data.array()) { +// sb.append(String.format("%02X ", b)); +// } +// System.out.println(sb.toString()); + + /* + 05 00 46 5E CE 80 83 00 00 00 ED 00 00 00 3E 45 + 04 00 00 00 00 00 00 00 00 00 3E 45 04 00 00 00 + 00 00 90 52 05 00 00 00 00 00 D7 35 05 00 00 00 + 00 00 01 00 00 00 00 07 + */ + + long playerId = data.getLong(); // 3E 45 04 00 00 00 00 00 + data.getInt(); // 00 00 00 00 + data.getLong(); // 3E 45 04 00 00 00 00 00 + long harvesterId = data.getLong(); // 1E 55 05 00 00 00 00 00 + //long containerId = data.getLong(); // 1E 55 05 00 00 00 00 00 Resources ID + long resourceId = data.getLong(); // 1E 55 05 00 00 00 00 00 Resources ID + int stackCount = data.getInt(); // Stack count + byte actionMode = data.get(); // 0 for retrieving, 1 for discarding + byte updateCount = data.get(); // updateCount + + CreatureObject actor = (CreatureObject) client.getParent(); + SWGObject target = core.objectService.getObject(harvesterId); + + core.harvesterService.handleEmptyHopper(actor,target,harvesterId,resourceId,stackCount,actionMode,updateCount); + } + }); + } diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 816d910b..80fea282 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -95,8 +95,11 @@ import resources.objects.Delta; import resources.objects.building.BuildingObject; import resources.objects.cell.CellObject; import resources.objects.creature.CreatureObject; +import resources.objects.deed.Harvester_Deed; import resources.objects.group.GroupObject; import resources.objects.guild.GuildObject; +import resources.objects.harvester.HarvesterObject; +import resources.objects.installation.InstallationObject; import resources.objects.intangible.IntangibleObject; import resources.objects.mission.MissionObject; import resources.objects.player.PlayerObject; @@ -313,7 +316,11 @@ public class ObjectService implements INetworkDispatch { object = new SurveyTool(objectID, planet, Template, position, orientation); - }else if(Template.startsWith("object/tangible")) { + } else if(Template.startsWith("object/tangible/deed/harvester_deed") || Template.startsWith("object/tangible/deed/generator_deed")) { + + object = new Harvester_Deed(objectID, planet, Template, position, orientation); + + } else if(Template.startsWith("object/tangible")) { object = new TangibleObject(objectID, planet, Template, position, orientation); @@ -369,7 +376,22 @@ public class ObjectService implements INetworkDispatch { object = new ResourceContainerObject(objectID, planet, Template, position, orientation); - }else { + } else if(Template.startsWith("object/installation/mining_ore/construction")) { + + float positionY = core.terrainService.getHeight(planet.getID(), position.x, position.z)-1f; + Point3D newpoint = new Point3D(position.x,positionY,position.z); + object = new InstallationObject(objectID, planet, Template, newpoint, orientation); + + } else if(Template.startsWith("object/installation/mining_ore") || Template.startsWith("object/installation/mining_liquid") || + Template.startsWith("object/installation/mining_gas") || Template.startsWith("object/installation/mining_organic") || + Template.startsWith("object/installation/generators")) { + + float positionY = core.terrainService.getHeight(planet.getID(), position.x, position.z)-1f; + Point3D newpoint = new Point3D(position.x,positionY,position.z); + object = new HarvesterObject(objectID, planet, Template, newpoint, orientation); + core.harvesterService.addHarvester(object); + + } else { return null; } diff --git a/src/services/resources/HarvesterService.java b/src/services/resources/HarvesterService.java new file mode 100644 index 00000000..11c17dfe --- /dev/null +++ b/src/services/resources/HarvesterService.java @@ -0,0 +1,1070 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.resources; + +import java.util.Collections; +import java.util.Comparator; +import java.util.Map; +import java.util.Random; +import java.util.Vector; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import protocol.swg.EnterStructurePlacementModeMessage; +import protocol.swg.SceneCreateObjectByCrc; +import protocol.swg.SceneDestroyObject; +import protocol.swg.SceneEndBaselines; +import main.NGECore; +import engine.resources.common.CRC; +import engine.resources.container.Traverser; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; +import resources.objects.creature.CreatureObject; +import resources.objects.deed.Harvester_Deed; +import resources.objects.harvester.HarvesterMessageBuilder; +import resources.objects.harvester.HarvesterObject; +import resources.objects.installation.InstallationObject; +import resources.objects.player.PlayerObject; +import resources.objects.resource.GalacticResource; +import resources.objects.resource.ResourceContainerObject; +import resources.objects.resource.ResourceRoot; +import resources.objects.tangible.TangibleObject; +import resources.objects.waypoint.WaypointObject; +import services.sui.SUIWindow; +import services.sui.SUIWindow.SUICallback; +import services.sui.SUIWindow.Trigger; + +/** + * @author Charon + */ + +public class HarvesterService implements INetworkDispatch { + + private NGECore core; + private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + + private Vector allHarvesters = new Vector(); + private Vector allConstructors = new Vector(); + + public HarvesterService(NGECore core) { + this.core = core; + //core.commandService.registerCommand("permissionlistmodify"); + //core.commandService.registerCommand("harvesterselectresource"); + //core.commandService.registerCommand("harvesteractivate"); + //core.commandService.registerCommand("harvesterdeactivate"); + //core.commandService.registerCommand("harvesterdiscardhopper"); + //core.commandService.registerCommand("harvestergetresourcedata"); + //core.commandService.registerCommand("resourceemptyhopper"); + //core.commandService.registerCommand("placestructure"); + //generateNoBuildData(); + scheduleHarvesterService(); + } + + @Override + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + + + } + + + public void scheduleHarvesterService(){ + + final ScheduledFuture task = scheduler.scheduleAtFixedRate(new Runnable() { + + @Override + public void run() { + ServiceProcessing(); + } + + }, 10, 5000, TimeUnit.MILLISECONDS); + + } + + public void ServiceProcessing(){ + synchronized(allHarvesters){ + for (HarvesterObject harvester : allHarvesters){ + updateHarvester(harvester); + } + } + synchronized(allConstructors){ + Vector removeConstructors = new Vector(); + for (InstallationObject constructor : allConstructors){ + boolean readyToBuild = checkBuildTime(constructor); + if (readyToBuild) + removeConstructors.add(constructor); + } + allConstructors.removeAll(removeConstructors); + } + } + + + public void addHarvester(SWGObject harvester){ + synchronized(allHarvesters){ + allHarvesters.add((HarvesterObject)harvester); + } + } + + public void removeHarvester(SWGObject harvester){ + synchronized(allHarvesters){ + allHarvesters.remove((HarvesterObject)harvester); + } + } + + public boolean checkBuildTime(InstallationObject installation){ + boolean value = false; + long startTime = (long) installation.getAttachment("ConstructionStart"); + if (startTime+50000){ + String[] helper = ownerName.split(" "); + ownerName = helper[0]; + } + + String maintenancePool_string = ""+(int)harvester.getMaintenanceAmount(); + int hourlyMaintenance = harvester.getMaintenanceCost(); + float totalNumberOfHours = (float)harvester.getMaintenanceAmount()/hourlyMaintenance; + float minuteFraction = ((totalNumberOfHours * 100) % 100) / 100; + int nDays = (int)totalNumberOfHours / 24; + float difference = totalNumberOfHours % 24; + int nHours = (int)difference; + int nMinutes = (int)(minuteFraction *60); + maintenancePool_string += " (" + nDays + " days, " + nHours + " hours, " + nMinutes + " minutes)"; + // Power reserves calculation + String powerReserves_string = ""+(int)harvester.getPowerLevel(); + int hourlyPower = harvester.getPowerCost(); + totalNumberOfHours = (float)harvester.getPowerLevel()/hourlyPower; + minuteFraction = ((totalNumberOfHours * 100) % 100) / 100; + nDays = (int)totalNumberOfHours / 24; + difference = totalNumberOfHours % 24; + nHours = (int)difference; + nMinutes = (int)(minuteFraction *60); + powerReserves_string += " (" + nDays + " days, " + nHours + " hours, " + nMinutes + " minutes)"; + + window.addListBoxMenuItem("@player_structure:owner_prompt" + " " + ownerName, 0); + window.addListBoxMenuItem("@player_structure:structure_public", 1); + window.addListBoxMenuItem("@player_structure:condition_prompt" + " " + target.getConditionDamage(), 2); + window.addListBoxMenuItem("@player_structure:maintenance_pool_prompt " + maintenancePool_string, 3); + window.addListBoxMenuItem("@player_structure:maintenance_rate_prompt " + harvester.getMaintenanceCost() + " cr/h", 4); // @player_structure:credits_per_hour + window.addListBoxMenuItem("@player_structure:maintenance_mods_prompt", 5); + window.addListBoxMenuItem("@player_structure:power_reserve_prompt " + powerReserves_string, 6); + window.addListBoxMenuItem("@player_structure:power_consumption_prompt " + harvester.getPowerCost() + " @player_structure:units_per_hour", 7); + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + Vector returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void createPayMaintenanceSUIPage(SWGObject owner, TangibleObject target) { + CreatureObject creature = (CreatureObject) owner; + final HarvesterObject harvester = (HarvesterObject)target; + final SUIWindow window = core.suiService.createSUIWindow("Script.transfer", owner, target, 10); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:select_amount"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:select_maint_amount" + + "\n \n @player_structure:current_maint_pool : " + (int)harvester.getMaintenanceAmount()); + + window.setProperty("msgPayMaintenance", "transaction.txtInputFrom"); + + window.setProperty("transaction.lblFrom:Text", "@player_structure:total_funds"); + window.setProperty("transaction.lblTo:Text", "@player_structure:to_pay"); + window.setProperty("transaction.lblFrom", "@player_structure:total_funds"); + window.setProperty("transaction.lblTo", "@player_structure:to_pay"); + + window.setProperty("transaction.lblStartingFrom:Text", ""+creature.getCashCredits()); + window.setProperty("transaction.lblStartingTo:Text", "0"); + + window.setProperty("transaction:InputFrom", "555555"); + window.setProperty("transaction:InputTo", "666666"); + + window.setProperty("transaction:txtInputFrom", ""+creature.getCashCredits()); + window.setProperty("transaction:txtInputTo", "1"); + window.setProperty("transaction.txtInputFrom:Text", ""+creature.getCashCredits()); + window.setProperty("transaction.txtInputTo:Text", "" + "0"); + + window.setProperty("transaction.ConversionRatioFrom", "1"); + window.setProperty("transaction.ConversionRatioTo", "0"); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + + Vector returnList = new Vector(); + returnList.add("transaction.txtInputFrom:Text"); + returnList.add("transaction.txtInputTo:Text"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + crafter.setCashCredits(crafter.getCashCredits() - Integer.parseInt(returnList.get(1))); + harvester.setMaintenanceAmount(harvester.getMaintenanceAmount()+Float.parseFloat(returnList.get(1))); + //String displayname = "@installation_n:"+harvester.getStfName(); + String displayname = "the structure"; + if (harvester.getCustomName()!=null) + displayname = harvester.getCustomName(); + crafter.sendSystemMessage("You successfully make a payment of " + Integer.parseInt(returnList.get(1)) + " credits to " + displayname + ".", (byte) 0); + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void createRenameSUIPage(SWGObject owner, TangibleObject target) { + //updateHarvester(owner, target); + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + final TangibleObject outerSurveyTool = target; + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.harvesterService.handleSetName((CreatureObject)owner, (TangibleObject)outerSurveyTool,returnList.get(0)); + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + + public void createDestroySUIPage(final SWGObject owner, final TangibleObject target) { + + // "\\#32CD32 @player_structure:confirm_destruction_d3b \#" + + final HarvesterObject harvester = (HarvesterObject)target; + // harvester.getStfFilename(); installation_n .getTemplate(); + String displayname = "@installation_n:"+harvester.getStfName(); + if (harvester.getCustomName()!=null) + displayname = harvester.getCustomName(); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", displayname); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:confirm_destruction_d1 " + + "@player_structure:confirm_destruction_d2 " + + "\n \n @player_structure:confirm_destruction_d3a " + + "\\#32CD32 @player_structure:confirm_destruction_d3b \\#FFFFFF " + + "@player_structure:confirm_destruction_d4 "); + if (harvester.getConditionDamage()<20 && harvester.getMaintenanceAmount()<3000){ + window.addListBoxMenuItem("@player_structure:redeed_confirmation \\#BB0000 @player_structure:can_redeed_no_suffix \\#FFFFFF ",1 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_confirmation \\#32CD32 @player_structure:can_redeed_yes_suffix \\#FFFFFF ",1 ); + } + if (harvester.getConditionDamage()<20){ + window.addListBoxMenuItem("@player_structure:redeed_condition \\#BB0000 " + harvester.getConditionDamage() + " \\#FFFFFF ",1 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_condition \\#32CD32 " + harvester.getConditionDamage() + " \\#FFFFFF ",1 ); + } + if (harvester.getMaintenanceAmount()<0){ + window.addListBoxMenuItem("@player_structure:redeed_maintenance \\#BB0000 " + (int)harvester.getMaintenanceAmount() + " \\#FFFFFF ",2 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_maintenance \\#32CD32 " + (int)harvester.getMaintenanceAmount() + " \\#FFFFFF ",2 ); + } + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + createCodeWindow(owner, target); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void createCodeWindow(SWGObject owner, TangibleObject target) { + + // "\\#32CD32 @player_structure:confirm_destruction_d3b \#" + + final HarvesterObject harvester = (HarvesterObject)target; + // harvester.getStfFilename(); installation_n .getTemplate(); + Random rnd = new Random(); + final int confirmCode = 100000 + rnd.nextInt(900000); + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:confirm_destruction_t"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:your_structure_prefix " + + "\\#32CD32 @player_structure:will_redeed_confirm \\#FFFFFF "+ + "@player_structure:will_redeed_suffix " + + "\n \n Code: " + confirmCode); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + core.suiService.closeSUIWindow(owner, 0); + if (returnList.get(0).equals(""+confirmCode)){ + // handle creation of correct deed in player inventory + PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost"); + String deedTemplate = harvester.getDeedTemplate(); + Harvester_Deed deed = (Harvester_Deed)core.objectService.createObject(deedTemplate, owner.getPlanet()); + if(player.getLotsRemaining()+deed.getLotRequirement()>10){ + // Something went wrong or hacking attempt + crafter.sendSystemMessage("Structure can't be redeeded. Maximum lot count exceeded.",(byte)1); + return; + } + + deed.setStructureTemplate(harvester.getTemplate()); + deed.setOutputHopperCapacity(harvester.getOutputHopperCapacity()); + deed.setBER(harvester.getBER()); + deed.setSurplusMaintenance((int)harvester.getMaintenanceAmount()); + deed.setSurplusPower((int)harvester.getPowerLevel()); + deed.setAttributes(); + + SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(harvester.getObjectID()); + owner.getClient().getSession().write(destroyObjectMsg.serialize()); + core.objectService.destroyObject(harvester.getObjectID()); + + SWGObject crafterInventory = owner.getSlottedObject("inventory"); + crafterInventory.add(deed); + + if(player.getLotsRemaining()+deed.getLotRequirement()<=10) + player.setLotsRemaining(player.getLotsRemaining()+deed.getLotRequirement()); + + crafter.sendSystemMessage("@player_structure:processing_destruction",(byte)1); + crafter.sendSystemMessage("@player_structure:deed_reclaimed",(byte)1); + + } else { + crafter.sendSystemMessage("@player_structure:incorrect_destroy_code",(byte)1); + } + + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void handleOperateMachinery(CreatureObject owner, TangibleObject target) { + + HarvesterObject harvester = (HarvesterObject) target; + harvester.operateMachinery(owner); + } + + public void handleDestroy(SWGObject owner, TangibleObject target) { + + HarvesterObject harvester = (HarvesterObject) target; + // Assemble resources at that spot + // For later, it might be needed to also pass the template to differentiate liquid resources + Vector planetVector = core.resourceService.getSpawnedResourcesByPlanetAndHarvesterType(target.getPlanetId(),harvester.getHarvester_type()); + HarvesterMessageBuilder messenger = new HarvesterMessageBuilder((HarvesterObject)target); + owner.getClient().getSession().write(messenger.buildHINOBaseline7((HarvesterObject)target, planetVector)); + } + + public void handleSetName(CreatureObject owner, TangibleObject target,String name) { + + ((HarvesterObject) target).setHarvesterName(name,owner); + } + + public void handleDepositPower(SWGObject owner, TangibleObject target) { + + CreatureObject creature = (CreatureObject) owner; + final HarvesterObject harvester = (HarvesterObject) target; + int playerEnergyLevel = 0; + playerEnergyLevel = calculateTotalPlayerEnergy(creature); + + final SUIWindow window = core.suiService.createSUIWindow("Script.transfer", owner, target, 10); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:add_power"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:select_power_amount"+ + "\n \n @player_structure:current_power_value " + (int)harvester.getPowerLevel()); + window.setProperty("transaction.txtInputFrom:Text", "" + playerEnergyLevel); + window.setProperty("transaction.txtInputTo:Text", "" + "0"); + window.setProperty("transaction.lblFrom:Text", "@player_structure:total_energy"); + window.setProperty("transaction.lblTo:Text", "@player_structure:to_deposit"); + window.setProperty("transaction:InputFrom", "5555"); + window.setProperty("transaction:InputTo", "6666"); + window.setProperty("transaction.lblStartingFrom:Text", ""+playerEnergyLevel); + window.setProperty("transaction.lblStartingTo:Text", "0"); + window.setProperty("transaction.ConversionRatioFrom", "0"); + window.setProperty("transaction.ConversionRatioTo", "1"); + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + + Vector returnList = new Vector(); + returnList.add("transaction.txtInputFrom:Text"); + returnList.add("transaction.txtInputTo:Text"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + harvester.setPowerLevel(harvester.getPowerLevel()+Integer.parseInt(returnList.get(1))); + updateEnergyInventoryContainers(crafter,Integer.parseInt(returnList.get(1))); + crafter.sendSystemMessage("You successfully deposit " + Integer.parseInt(returnList.get(1)) + " units of energy.", (byte) 0); + crafter.sendSystemMessage("Energy reserves now at " + (int)harvester.getPowerLevel() + " units.", (byte) 0); + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public int calculateTotalPlayerEnergy(CreatureObject owner){ + // final int energy = 0; Doesn't work with generic types + int energy = 0; + final Vector energyVector = new Vector(); + TangibleObject playerInventory = (TangibleObject) owner.getSlottedObject("inventory"); + playerInventory.viewChildren(owner, false, false, new Traverser() { + @Override + public void process(SWGObject obj) { + + if (obj instanceof ResourceContainerObject){ + ResourceContainerObject container = (ResourceContainerObject) obj; + if (container.getResourceClass()==null)System.out.println("container.getResourceClass()==null " + container.getTemplate()); + if (container.getResourceClass().equals("Radioactive") || + container.getResourceClass().equals("Wind Renewable Energy") || + container.getResourceClass().equals("Solar Renewable Energy") || + container.getResourceClass().equals("Geothermal Renewable Energy") || + container.getResourceClass().equals("Tidal Renewable Energy") || + container.getResourceClass().equals("Hydron-3 Renewable Energy")) { + energyVector.add(container.getStackCount()); + } + } + } + /* + public void process(SWGObject a1) { + if(!(a1 instanceof PlayerObject) && a1 != null) { + if(a1.getClient() != null && a1 != a.this$0) { + a1.makeAware(a.this$0); + } + a.this$0.makeAware(a1); + } + } + } + */ + }); + + for (Integer value : energyVector){ + energy += value; + } + return energy; + } + + /* + * This is deducting the deposited power from the inventory + */ + public void updateEnergyInventoryContainers(SWGObject owner, int deductedEnergy){ + + final Vector containerVector = new Vector(); + TangibleObject playerInventory = (TangibleObject) owner.getSlottedObject("inventory"); + playerInventory.viewChildren(owner, false, false, new Traverser() { + @Override + public void process(SWGObject obj) { + // is energy resource? + if (obj instanceof ResourceContainerObject){ + ResourceContainerObject container = (ResourceContainerObject) obj; + if (container.getResourceClass().equals("Radioactive") || + container.getResourceClass().equals("Wind Renewable Energy") || + container.getResourceClass().equals("Solar Renewable Energy") || + container.getResourceClass().equals("Geothermal Renewable Energy") || + container.getResourceClass().equals("Tidal Renewable Energy") || + container.getResourceClass().equals("Hydron-3 Renewable Energy")) { + containerVector.add(container); + } + } + } + }); + + Comparator comp = new ResourceContainerObjectComparator(); + Collections.sort(containerVector, comp); + + for (int i=containerVector.size()-1;i >= 0; i--){ + int containerEnergy = containerVector.get(i).getStackCount(); + if (containerEnergy <= deductedEnergy){ + deductedEnergy -= containerEnergy; + playerInventory._remove(containerVector.get(i)); + SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(containerVector.get(i).getObjectID()); + owner.getClient().getSession().write(destroyObjectMsg.serialize()); + } else { + containerEnergy -= deductedEnergy; + containerVector.get(i).setStackCount(containerEnergy,(CreatureObject)owner); + playerInventory._remove(containerVector.get(i)); + playerInventory._add(containerVector.get(i)); + +// ResourceMessenger messenger = new ResourceMessenger(IoBuffer.allocate(1)); +// owner.getClient().getSession().write(messenger.serialize_buildRCNO3Delta(containerVector.get(i).getObjectID(),containerEnergy)); + } + } + } + + public class ResourceContainerObjectComparator implements Comparator { + + @Override + public int compare(ResourceContainerObject b1, ResourceContainerObject b2) { + if (b1.getStackCount() == b2.getStackCount()) { + return 0; + } + if (b1.getStackCount() > b2.getStackCount()) { + return 1; + } + if (b1.getStackCount() < b2.getStackCount()) { + return -1; + } + return 0; + } + } + + public void handlePermissionAdmin(CreatureObject owner, TangibleObject target) { + + String listName = "ADMIN"; + ((HarvesterObject) target).setPermissionAdmin(listName,owner); + } + + public void handlePermissionHopper(CreatureObject owner, TangibleObject target) { + + String listName = "HOPPER"; + ((HarvesterObject) target).setPermissionHopper(listName,owner); + } + + public void handlePermissionListModify(CreatureObject crafter, SWGObject target, String commandArgs){ + + String[] commandSplit = commandArgs.split(" "); + if (commandSplit.length==3){ + if (core.characterService.playerExists(commandSplit[2])){ + if (commandSplit[2].equals("ADMIN")){ + Vector adminList = ((HarvesterObject)target).getAdminList(); + if (commandSplit[0].equals("add") && (!adminList.contains(commandSplit[2]))){ + crafter.sendSystemMessage(commandSplit[2] + " added as administrator", (byte) 0); + adminList.add(commandSplit[2]); + ((HarvesterObject)target).setAdminList(adminList); + } + if (commandSplit[0].equals("remove") && (adminList.contains(commandSplit[2]))){ + crafter.sendSystemMessage(commandSplit[2] + " removed as administrator", (byte) 0); + adminList.remove(commandSplit[2]); + ((HarvesterObject)target).setAdminList(adminList); + } + } + if (commandSplit[2].equals("HOPPER")){ + Vector hopperList = ((HarvesterObject)target).getHopperList(); + if (commandSplit[0].equals("add") && (!hopperList.contains(commandSplit[2]))){ + crafter.sendSystemMessage(commandSplit[2] + " added as administrator", (byte) 0); + hopperList.add(commandSplit[2]); + ((HarvesterObject)target).setHopperList(hopperList); + } + if (commandSplit[0].equals("remove") && (hopperList.contains(commandSplit[2]))){ + crafter.sendSystemMessage(commandSplit[2] + " removed as administrator", (byte) 0); + hopperList.remove(commandSplit[2]); + ((HarvesterObject)target).setHopperList(hopperList); + } + } + } else { + crafter.sendSystemMessage(commandSplit[2]+ " is an invalid player name", (byte) 0); + } + } + if (commandSplit.length==2){ + crafter.sendSystemMessage("No name was entered", (byte) 0); + } + + } + + public void handleHarvesterSelectResourceCommand(CreatureObject owner, SWGObject target, String commandArgs){ + + long selectedResourceId = Long.parseLong(commandArgs); + GalacticResource resource = core.resourceService.findResourceById(selectedResourceId); + ((HarvesterObject) target).setSelectedHarvestResource(resource,owner); + } + + public void handleHarvesterActivateCommand(CreatureObject owner, SWGObject target, String commandArgs){ + + + if (((HarvesterObject)target).getPowerLevel()<=0 && !((HarvesterObject)target).isGenerator()){ + ((CreatureObject)owner).sendSystemMessage("The installation is lacking power.", (byte) 0); + return; + } + if (((HarvesterObject)target).getMaintenanceAmount()<=0){ + ((CreatureObject)owner).sendSystemMessage("The installation is lacking maintenance.", (byte) 0); + return; + } + + + ((HarvesterObject)target).activateHarvester(owner); + } + + public void handleHarvesterDeactivateCommand(CreatureObject owner, SWGObject target, String commandArgs){ + + ((HarvesterObject)target).deactivateHarvester(owner); + } + + public void handleEmptyHopper(CreatureObject owner,SWGObject target,long harvesterId, long resourceId, int stackcount, byte actionMode, byte updateCount){ + + HarvesterMessageBuilder messenger = new HarvesterMessageBuilder((HarvesterObject)target); + //DiscardResourceResponse + owner.getClient().getSession().write(messenger.buildDiscardResourceResponse((HarvesterObject)target, actionMode, updateCount,owner)); + + + ResourceContainerObject foundContainer = null; + Vector hopperContent = ((HarvesterObject) target).getOutputHopperContent(); + for (ResourceContainerObject cont : hopperContent){ + if (cont.getReferenceID()==resourceId){ + foundContainer = cont; + } + } + if (foundContainer==null) + return; // something went wrong + + if (foundContainer.getStackCount()==stackcount){ + ((HarvesterObject) target).setCurrentHarvestedCountFloat(1); + foundContainer.setStackCount(0, owner); + } else { + ((HarvesterObject) target).setCurrentHarvestedCountFloat(foundContainer.getStackCount()-stackcount); + foundContainer.setStackCount(foundContainer.getStackCount()-stackcount,owner); + } + ((HarvesterObject) target).setOutputHopperContent(hopperContent); + + // <<< + Vector planetResourcesVector = core.resourceService.getSpawnedResourcesByPlanetAndHarvesterType(target.getPlanetId(),((HarvesterObject)target).getHarvester_type()); + owner.getClient().getSession().write(messenger.buildHINOBaseline7((HarvesterObject)target, planetResourcesVector)); + owner.getClient().getSession().write(messenger.buildHINO7ExperimentalDelta2((HarvesterObject)target)); + // >> + + hopperContent = ((HarvesterObject) target).getOutputHopperContent(); + for (ResourceContainerObject cont : hopperContent){ + if (cont.getReferenceID()==resourceId){ + foundContainer = cont; + } + } + + // create retrieved resource container + GalacticResource sampleResource = core.resourceService.findResourceById(resourceId); + String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[sampleResource.getResourceRoot().getContainerType()]; + ResourceContainerObject containerObject = (ResourceContainerObject) core.objectService.createObject(resourceContainerIFF, owner.getPlanet()); + containerObject.initializeStats(sampleResource); + containerObject.setProprietor(owner); + containerObject.setStackCount(stackcount,owner); + containerObject.setIffFileName(resourceContainerIFF); + SWGObject crafterInventory = owner.getSlottedObject("inventory"); +// containerObject.sendBaselines(owner.getClient()); +// SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(containerObject.getObjectID()); +// owner.getClient().getSession().write(sceneEndBaselinesMsg.serialize()); +// tools.CharonPacketUtils.printAnalysis(sceneEndBaselinesMsg.serialize()); + crafterInventory.add(containerObject); + } + + + public void handleEmptyHarvester(CreatureObject owner, SWGObject target, String commandArgs){ + + HarvesterMessageBuilder messenger = new HarvesterMessageBuilder((HarvesterObject)target); + Vector hopperContent = ((HarvesterObject) target).getOutputHopperContent(); + Vector deleteContent = new Vector(); + + for (ResourceContainerObject cont : hopperContent){ + ResourceContainerObject foundContainer = cont; + + if (foundContainer==null) + return; // something went wrong + + long resourceId = foundContainer.getReferenceID(); + int stackcount = foundContainer.getStackCount(); + + SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(resourceId); + owner.getClient().getSession().write(destroyObjectMsg.serialize()); + + // create retrieved resource container + GalacticResource sampleResource = core.resourceService.findResourceById(resourceId); + String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[sampleResource.getResourceRoot().getContainerType()]; + ResourceContainerObject containerObject = (ResourceContainerObject) core.objectService.createObject(resourceContainerIFF, owner.getPlanet()); + containerObject.initializeStats(sampleResource); + containerObject.setProprietor(owner); + containerObject.setStackCount(stackcount,owner); + int resCRC = CRC.StringtoCRC(resourceContainerIFF); + containerObject.setIffFileName(resourceContainerIFF); + + long objectId = containerObject.getObjectID(); + SWGObject crafterInventory = owner.getSlottedObject("inventory"); + +// SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(objectId, owner.getOrientation().x, owner.getOrientation().y, owner.getOrientation().z, owner.getOrientation().w, owner.getPosition().x, owner.getPosition().y, owner.getPosition().z, resCRC, (byte) 0); +// owner.getClient().getSession().write(createObjectMsg.serialize()); +// tools.CharonPacketUtils.printAnalysis(createObjectMsg.serialize()); +// +// containerObject.sendBaselines(owner.getClient()); +// +// SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(containerObject.getObjectID()); +// owner.getClient().getSession().write(sceneEndBaselinesMsg.serialize()); +// tools.CharonPacketUtils.printAnalysis(sceneEndBaselinesMsg.serialize()); + + crafterInventory.add(containerObject); + + if (cont.getReferenceID()!=((HarvesterObject) target).getSelectedHarvestResource().getId()){ + deleteContent.add(cont); + } else { + ((HarvesterObject) target).setCurrentHarvestedCountFloat(0); + foundContainer.setStackCount(0,owner); + } + } + hopperContent.removeAll(deleteContent); + + ((HarvesterObject) target).setOutputHopperContent(hopperContent); + + Vector planetResourcesVector = core.resourceService.getSpawnedResourcesByPlanetAndHarvesterType(target.getPlanetId(),((HarvesterObject)target).getHarvester_type()); + owner.getClient().getSession().write(messenger.buildHINOBaseline7((HarvesterObject)target, planetResourcesVector)); + owner.getClient().getSession().write(messenger.buildHINO7ExperimentalDelta2((HarvesterObject)target)); + } + + public void updateHarvester(HarvesterObject harvester){ + + + if(harvester.isActivated()) + { + // Check maintenance and power + if (harvester.getMaintenanceAmount()<=0){ + CreatureObject owner = (CreatureObject)harvester.getOwner(); + owner.sendSystemMessage("The installation is lacking maintenance.", (byte) 0); + // ToDo: Send mail + harvester.deactivateHarvester(owner); + return; + } + + if (harvester.getPowerLevel()<=0 && !harvester.isGenerator()){ + CreatureObject owner = (CreatureObject)harvester.getOwner(); + owner.sendSystemMessage("The installation is lacking power.", (byte) 0); + // ToDo: Send mail + harvester.deactivateHarvester(owner); + return; + } + + harvester.setMaintenanceAmount(harvester.getMaintenanceAmount()-(harvester.getMaintenanceCost()/3600.0F)); + harvester.setPowerLevel(harvester.getPowerLevel()-(harvester.getPowerCost()/3600.0F)); + + Vector outputHopperContent = harvester.getOutputHopperContent(); + GalacticResource currentResource = harvester.getSelectedHarvestResource(); + ResourceContainerObject hopperContainer = hopperHasContainer(currentResource, outputHopperContent); + // check if output hopper contains already a container with the selected harvest resource + if(hopperContainer==null) + { + + //ResourceContainerObject container = new ResourceContainerObject(); + String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[currentResource.getResourceRoot().getContainerType()]; + ResourceContainerObject container = (ResourceContainerObject) core.objectService.createObject(resourceContainerIFF, harvester.getPlanet()); + container.initializeStats(harvester.getSelectedHarvestResource()); + container.setStackCount(0,false); + harvester.setCurrentHarvestedCountFloat(0.0F); + outputHopperContent.add(container); + harvester.setOutputHopperContent(outputHopperContent); + harvester.createNewHopperContainer(); + + } else { + + harvester.continueHopperContainer(); + + // add harvested amount + int BER = harvester.getBER(); + //BER = 15; + float minuteRate = harvester.getActualExtractionRate(); + float updateRate = minuteRate / 60; + harvester.setCurrentHarvestedCountFloat(harvester.getCurrentHarvestedCountFloat()+updateRate); + + int oldStackCount = hopperContainer.getStackCount(); + int newStackCount = (int) (harvester.getCurrentHarvestedCountFloat()); + CreatureObject owner = (CreatureObject)harvester.getOwner(); + if (newStackCount>oldStackCount){ + for (ResourceContainerObject iterContainer : outputHopperContent){ + if (iterContainer.getReferenceID()==hopperContainer.getReferenceID()){ + iterContainer.setStackCount(newStackCount,owner); // updates collection + } + } + harvester.setOutputHopperContent(outputHopperContent); + //((CreatureObject)harvester.getOwner()).getClient().getSession().write(messenger.buildHINO7ExperimentalDelta2(harvester)); + } + harvester.setCurrentHarvestedCountFloat(harvester.getCurrentHarvestedCountFloat()+updateRate); + } + } + } + + private ResourceContainerObject hopperHasContainer(GalacticResource resource, Vector outputHopperContent){ + ResourceContainerObject container = null; + for (ResourceContainerObject iterContainer : outputHopperContent){ + if (iterContainer.getReferenceID()==resource.getId()){ + return iterContainer; + } + } + return container; + } + + + public void constructionSite(CreatureObject actor,SWGObject target, long objectId, float posX, float posZ, float dir){ + + SWGObject usedDeed = (SWGObject)actor.getAttachment("LastUsedDeed"); + String constructorTemplate = ((Harvester_Deed)usedDeed).getConstructorTemplate(); + //String structureTemplate = "object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff"; + + float positionY = core.terrainService.getHeight(actor.getPlanetId(), posX, posZ) + 2f; + Quaternion quaternion = new Quaternion(1, 0, 0, 0); + quaternion = resources.common.MathUtilities.rotateQuaternion(quaternion, (float)((Math.PI/2) * dir), new Point3D(0, 1, 0)); + InstallationObject installation = (InstallationObject) core.objectService.createObject(constructorTemplate, 0, actor.getPlanet(), new Point3D(posX, positionY, posZ), quaternion); + + + installation.setAttachment("ConstructionStart", System.currentTimeMillis()); + installation.setAttachment("Owner", actor); + installation.setAttachment("Deed_StructureTemplate", ((Harvester_Deed)usedDeed).getStructureTemplate()); + installation.setAttachment("Deed_DeedTemplate", ((Harvester_Deed)usedDeed).getTemplate()); + installation.setAttachment("Deed_BER", ((Harvester_Deed)usedDeed).getBER()); + installation.setAttachment("Deed_Capacity", ((Harvester_Deed)usedDeed).getOutputHopperCapacity()); + installation.setAttachment("Deed_DeedLots", ((Harvester_Deed)usedDeed).getLotRequirement()); + installation.setAttachment("Deed_SurplusMaintenance", ((Harvester_Deed)usedDeed).getSurplusMaintenance()); + installation.setAttachment("Deed_SurplusPower", ((Harvester_Deed)usedDeed).getSurplusPower()); + + // destroy deed + TangibleObject playerInventory = (TangibleObject) actor.getSlottedObject("inventory"); + playerInventory._remove(usedDeed); + SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(usedDeed.getObjectID()); + actor.getClient().getSession().write(destroyObjectMsg.serialize()); + + int resCRC = CRC.StringtoCRC(constructorTemplate); + SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(installation.getObjectID(), quaternion.x, quaternion.y, quaternion.z, quaternion.w, posX, positionY, posZ, resCRC, (byte) 0); + actor.getClient().getSession().write(createObjectMsg.serialize()); + tools.CharonPacketUtils.printAnalysis(createObjectMsg.serialize()); + SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(installation.getObjectID()); + actor.getClient().getSession().write(sceneEndBaselinesMsg.serialize()); + tools.CharonPacketUtils.printAnalysis(sceneEndBaselinesMsg.serialize()); + + PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); + player.setLotsRemaining(player.getLotsRemaining()-(int)((Harvester_Deed)usedDeed).getLotRequirement()); + synchronized(allConstructors){ + allConstructors.add(installation); + } + } + + public void placeHarvester(SWGObject object){ + HarvesterObject.createAndPlaceHarvester(object); + } + + + public void enterStructurePlacementMode(SWGObject object, CreatureObject actor){ + + if (!core.terrainService.canBuildAtPosition(actor,actor.getPosition().x,actor.getPosition().z)){ + actor.sendSystemMessage("@player_structure:not_permitted", (byte) 0); + return; + } + + PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); + if (((Harvester_Deed)object).getLotRequirement()>player.getLotsRemaining()){ + actor.sendSystemMessage("@player_structure:not_enough_lots", (byte) 0); + return; + } + + actor.setAttachment("LastUsedDeed", object); + String structureTemplate = ((Harvester_Deed)object).getStructureTemplate(); + //String temp = "object/installation/mining_ore/shared_mining_ore_harvester_style_1.iff"; + EnterStructurePlacementModeMessage placementMsg = new EnterStructurePlacementModeMessage(actor,structureTemplate); + actor.getClient().getSession().write(placementMsg.serialize()); + } + + + public void handlePlaceStructureCommand(CreatureObject crafter, SWGObject target, String commandArgs){ + + // 511379 3516.08 -4804.08 0 + // Split Args by Delimiter + long objectId = crafter.getObjectID(); + float posX = crafter.getPosition().x; + float posZ = crafter.getPosition().z; + float dir = 0; + String[] splitter = commandArgs.split(" "); + if (splitter.length==4){ //QA + objectId = Long.parseLong(splitter[0]); + posX = Float.parseFloat(splitter[1]); + posZ = Float.parseFloat(splitter[2]); + dir = Float.parseFloat(splitter[3]); + } + + constructionSite(crafter, target, objectId, posX, posZ, dir); + } + + + // helper method to simulate a harvester deed in the player inventory + // that contains BER,cap,template info about the harvester + public void createExampleDeed(CreatureObject actor){ + + String templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_s1_deed.iff"; + Harvester_Deed deed = (Harvester_Deed)core.objectService.createObject(templateString, actor.getPlanet()); + deed.setName("Example Harvester Deed"); + deed.setStructureTemplate("object/installation/mining_ore/shared_mining_ore_harvester_style_1.iff"); + deed.setOutputHopperCapacity(27344); + deed.setBER(15); + + TangibleObject playerInventory = (TangibleObject) actor.getSlottedObject("inventory"); + playerInventory.add(deed); + + deed.setParent(playerInventory); + + core.resourceService.spawnSpecificResourceContainer("Radioactive", actor, 50); + core.resourceService.spawnSpecificResourceContainer("Radioactive", actor, 501); + core.resourceService.spawnSpecificResourceContainer("Radioactive", actor, 3); + core.resourceService.spawnSpecificResourceContainer("Radioactive", actor, 66); +// core.resourceService.spawnSpecificResourceContainer("Steel", actor, 50); +// core.resourceService.spawnSpecificResourceContainer("Fiberplast", actor, 50); + + } + + + // Stress Test (Server) for many harvesters running in the service + // 200 are running fine, 400 also + public void moduleTestManyHarvesters(CreatureObject actor){ + // assuming an average number of 200 harvesters per planet + for (int i=0;i<400;i++){ + createSingleTestHarvester(actor,i); + } + } + + public void createSingleTestHarvester(CreatureObject actor,int counter){ + // determine random position + String structureTemplate = "object/installation/mining_ore/shared_mining_ore_harvester_style_1.iff"; + HarvesterObject harvester = (HarvesterObject) core.objectService.createObject(structureTemplate, actor.getPlanet()); + long objectId = harvester.getObjectID(); + Vector adminList = harvester.getAdminList(); + String[] fullName = ((CreatureObject)actor).getCustomName().split(" "); + adminList.add(fullName[0]); + harvester.setAdminList(adminList); + // Set BER and outputhopper capacity here, take it from deed + harvester.setBER(8); + harvester.setOutputHopperCapacity(27344); + harvester.setMaintenanceAmount(2993); + harvester.setMaintenanceCost(30); + harvester.setPowerLevel(14714); + harvester.setPowerCost(25); + + Random generator = new Random(); + generator = new Random(); // Exclude mountains at the edge of the maps + int spawnCoordsX = generator.nextInt(15000) - 7500; + int spawnCoordsZ = generator.nextInt(15000) - 7500; + + // build harvester + int resCRC = CRC.StringtoCRC(structureTemplate); + Quaternion quaternion = new Quaternion(1, 0, 0, 0); + quaternion = resources.common.MathUtilities.rotateQuaternion(quaternion, (float)((Math.PI/2) * 1), new Point3D(0, 1, 0)); + float positionY = core.terrainService.getHeight(actor.getPlanetId(), spawnCoordsX, spawnCoordsZ)+ 2f; + SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(objectId,quaternion.x,quaternion.y, quaternion.z, quaternion.w, spawnCoordsX, positionY, spawnCoordsZ, resCRC, (byte) 0); + actor.getClient().getSession().write(createObjectMsg.serialize()); + tools.CharonPacketUtils.printAnalysis(createObjectMsg.serialize()); + + resources.objects.installation.InstallationMessageBuilder messenger = new resources.objects.installation.InstallationMessageBuilder((InstallationObject)harvester); + actor.getClient().getSession().write(messenger.buildBaseline3((InstallationObject)harvester)); + SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(harvester.getObjectID()); + actor.getClient().getSession().write(sceneEndBaselinesMsg.serialize()); + tools.CharonPacketUtils.printAnalysis(sceneEndBaselinesMsg.serialize()); + + // select resource + long selectedResourceId = core.resourceService.getAllSpawnedResources().get(51).getId(); + GalacticResource resource = core.resourceService.findResourceById(selectedResourceId); + harvester.setSelectedHarvestResource(resource,actor); + + + // activate harvester + harvester.activateHarvester(actor); + HarvesterMessageBuilder messenger2 = new HarvesterMessageBuilder(harvester); + actor.getClient().getSession().write(messenger2.buildHINO3Delta(harvester,(byte)1)); + actor.getClient().getSession().write(messenger2.buildHINO7ActivateDelta2(harvester)); + + + //create waypoint + if (counter<200){ + PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); + WaypointObject constructionWaypoint = (WaypointObject)core.objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", actor.getPlanet(), harvester.getPosition().x, 0 ,harvester.getPosition().z); + String displayname = "@installation_n:"+harvester.getStfName() + " " + counter; + constructionWaypoint.setName(displayname); + constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); + constructionWaypoint.setPosition(new Point3D(spawnCoordsX,0, spawnCoordsZ)); + player.waypointAdd(constructionWaypoint); + constructionWaypoint.setPosition(new Point3D(spawnCoordsX,0, spawnCoordsZ)); + constructionWaypoint.setActive(true); + constructionWaypoint.setColor((byte)1); + constructionWaypoint.setStringAttribute("", ""); + player.waypointAdd(constructionWaypoint); + constructionWaypoint.setName(displayname); + constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); + player.setLastSurveyWaypoint(constructionWaypoint); + } + + allHarvesters.add(harvester); + } + + @Override + public void shutdown() { + // TODO Auto-generated method stub + + } +} \ No newline at end of file diff --git a/src/services/resources/ResourceService.java b/src/services/resources/ResourceService.java index efc62fe1..4ebaa89d 100644 --- a/src/services/resources/ResourceService.java +++ b/src/services/resources/ResourceService.java @@ -28,13 +28,16 @@ import java.util.Random; import java.util.Vector; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; + import com.sleepycat.persist.EntityCursor; + import main.NGECore; import engine.resources.common.CRC; import engine.resources.objects.SWGObject; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.objects.creature.CreatureObject; +import resources.objects.harvester.HarvesterObject; import resources.objects.resource.GalacticResource; import resources.objects.resource.ResourceContainerObject; import resources.objects.resource.ResourceRoot; @@ -11306,6 +11309,36 @@ public class ResourceService implements INetworkDispatch { return resource; } + public Vector getSpawnedResourcesByPlanetAndHarvesterType(int planetId, byte harvesterType) { + Vector planetResourceList = new Vector(); + byte searchtype = harvesterType; + if (harvesterType==7) searchtype = (byte) 0; + for (GalacticResource gal : allSpawnedResources){ + if (gal.isSpawnedOn(planetId) && gal.getGeneralType()==searchtype) + if (harvesterType!=HarvesterObject.HARVESTER_TYPE_FUSION) + planetResourceList.add(gal); + else if (harvesterType==HarvesterObject.HARVESTER_TYPE_FUSION) { + System.err.println("gal.getContainerType() " + gal.getContainerType()); + if (gal.getResourceRoot().getContainerType()==ResourceRoot.CONTAINER_TYPE_ENERGY_RADIOACTIVE) + planetResourceList.add(gal); + } else if (harvesterType==HarvesterObject.HARVESTER_TYPE_GEO) { + System.err.println("gal.getContainerType() " + gal.getContainerType()); + if (gal.getGeneralType()==GalacticResource.GENERAL_GEOTHERM) + planetResourceList.add(gal); + } + } + return planetResourceList; + } + + public GalacticResource findResourceById(long id){ + GalacticResource resource = new GalacticResource(); + for (GalacticResource sampleResource : allSpawnedResources){ + if (sampleResource.getId()==id) + return sampleResource; + } + return resource; + } + // ToDo: Improve public GalacticResource grabMeatForCreature(CreatureObject corpse){ GalacticResource resource = null; diff --git a/src/services/sui/SUIService.java b/src/services/sui/SUIService.java index eb853838..b49cf67f 100644 --- a/src/services/sui/SUIService.java +++ b/src/services/sui/SUIService.java @@ -46,6 +46,7 @@ import resources.common.FileUtilities; import resources.common.ObjControllerOpcodes; import resources.common.Opcodes; import resources.common.RadialOptions; +import resources.objects.harvester.HarvesterObject; import services.sui.SUIWindow.SUICallback; import services.sui.SUIWindow.Trigger; import engine.clients.Client; @@ -81,6 +82,26 @@ public class SUIService implements INetworkDispatch { if(target == null || owner == null) return; + if (target instanceof HarvesterObject){ + HarvesterObject harvester = (HarvesterObject) target; + Vector admins = harvester.getAdminList(); + Vector hoppers = harvester.getHopperList(); + + if (harvester.getOwner()==owner && !admins.contains(owner.getCustomName())){ + admins.add(owner.getCustomName()); + } + + if (! admins.contains(owner.getCustomName()) && ! hoppers.contains(owner.getCustomName())){ + return; // Completely unauthorized + } + + if (! admins.contains(owner.getCustomName()) && hoppers.contains(owner.getCustomName())){ + // authorized for hopper + // change radialOptions to hopper access + harvester.setAttachment("radial_filename", "harvesterHopper"); + } + } + if(target.getGrandparent() != null && target.getGrandparent().getAttachment("structureAdmins") != null) { if(core.housingService.getPermissions(owner, target.getContainer())) From 3ccbfcc3c935145e763a96b8212917a0b83e4fa5 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Thu, 10 Apr 2014 20:03:48 -0400 Subject: [PATCH 67/68] Added SWG, Server, and other parent channels --- src/services/SimulationService.java | 4 +++- src/services/TerrainService.java | 1 + src/services/chat/ChatService.java | 33 ++++++++++++++------------ src/services/object/ObjectService.java | 1 - 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 22b30882..9e8096e6 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -809,7 +809,9 @@ public class SimulationService implements INetworkDispatch { PlayerObject ghost = (PlayerObject) object.getSlottedObject("ghost"); core.weatherService.sendWeather(object); - + + //core.chatService.joinChatRoom(object.getCustomName().toLowerCase(), "SWG." + core.getGalaxyName() + "." + object.getPlanet().getName()); + if (!object.hasSkill(ghost.getProfessionWheelPosition())) { object.showFlyText("cbt_spam", "skill_up", (float) 2.5, new RGB(154, 205, 50), 0); object.playEffectObject("clienteffect/skill_granted.cef", ""); diff --git a/src/services/TerrainService.java b/src/services/TerrainService.java index 497477db..ddc66042 100644 --- a/src/services/TerrainService.java +++ b/src/services/TerrainService.java @@ -176,6 +176,7 @@ public class TerrainService { noBuildAreas.put(planet, new ArrayList()); loadClientRegions(planet); + core.chatService.createChatRoom("", name, "system", true); core.chatService.createChatRoom("public chat for this planet, cannot create rooms here", name + ".Planet", "SYSTEM", true); core.chatService.createChatRoom("system messages for this planet, cannot create rooms here", name + ".system", "SYSTEM", true); diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index 4175d886..dbaea263 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -738,8 +738,11 @@ public class ChatService implements INetworkDispatch { * TODO: Research other channel address formats */ - ChatRoom system = createChatRoom("", "system", "system", true); - System.out.println("Created chat room " + system.getRoomAddress()); + createChatRoom("", "SWG", "system", true); + createChatRoom("", "SWG." + core.getGalaxyName(), "system", true); + + createChatRoom("", "system", "system", true); // galaxy system messages + createChatRoom("", "Auction", "system", true); //createChatRoom("Bounty Hunter chat for this galaxy", "BountyHunter", "SYSTEM", true); //createChatRoom("Commando chat for this galaxy", "Commando", "SYSTEM", true); @@ -751,23 +754,23 @@ public class ChatService implements INetworkDispatch { cursor.close(); } - public ChatRoom createChatRoom(String roomName, String address, String creator, boolean showInList) { - return createChatRoom(roomName, address, creator, showInList, false); + public ChatRoom createChatRoom(String roomName, String address, String creator, boolean isPublic) { + return createChatRoom(roomName, address, creator, isPublic, false); } - public ChatRoom createChatRoom(String roomName, String address, String creator, boolean showInList, boolean store) { + public ChatRoom createChatRoom(String roomName, String address, String creator, boolean isPublic, boolean store) { if (creator.contains(" ")) creator = creator.split(" ")[0]; ChatRoom room = new ChatRoom(); room.setDescription(roomName); - if (!address.startsWith("SWG.")) + if (!address.startsWith("SWG")) room.setRoomAddress("SWG." + core.getGalaxyName() + "." + address); else room.setRoomAddress(address); room.setCreator(creator.toLowerCase()); room.setOwner(creator.toLowerCase()); - room.setVisible(showInList); + room.setVisible(isPublic); room.setRoomId(generateChatRoomId()); chatRooms.put(room.getRoomId(), room); @@ -784,13 +787,13 @@ public class ChatService implements INetworkDispatch { public boolean joinChatRoom(String user, String roomAddress) { chatRooms.forEach((k, v) -> { if (v.getRoomAddress().equals(roomAddress)) { - joinChatRoom(user, k); + joinChatRoom(user, k, true); return; } }); return false; } - public boolean joinChatRoom(String user, int roomId) { + public boolean joinChatRoom(String user, int roomId, boolean resendList) { if (user.contains(" ")) user = user.split(" ")[0]; @@ -802,7 +805,7 @@ public class ChatService implements INetworkDispatch { if (!room.hasUser(user.toLowerCase())) { room.addUser(user.toLowerCase()); - if (!room.isVisible()) { + if (!room.isVisible() || resendList) { CreatureObject creo = (CreatureObject) getObjectByFirstName(user); if (creo != null) { ChatRoomList listMessage = new ChatRoomList(room); @@ -810,16 +813,16 @@ public class ChatService implements INetworkDispatch { } } ChatOnEnteredRoom enterRoom = new ChatOnEnteredRoom(user, 0, roomId, true); - - room.getUserList().stream().forEach(str -> { - SWGObject userObj = getObjectByFirstName(str); - userObj.getClient().getSession().write(enterRoom.serialize()); - }); + getObjectByFirstName(user).getClient().getSession().write(enterRoom.serialize()); + //System.out.println("Sent message for room " + room.getRoomAddress()); return true; } return false; } + public boolean joinChatRoom(String user, int roomId) { + return joinChatRoom(user, roomId, false); + } public void leaveChatRoom(CreatureObject player, int roomId) { String playerName = player.getCustomName().toLowerCase(); diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 61aba9b9..e193e791 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -833,7 +833,6 @@ public class ObjectService implements INetworkDispatch { if(!core.getConfig().getString("MOTD").equals("")) creature.sendSystemMessage(core.getConfig().getString("MOTD"), (byte) 2); - core.chatService.joinChatRoom(creature.getCustomName().toLowerCase(), "SWG." + core.getGalaxyName() + "." + creature.getPlanet().getName() + ".Planet"); core.playerService.postZoneIn(creature); } From 3ebf1dbf94baaad00e92c311a219b93e318c41de Mon Sep 17 00:00:00 2001 From: Seefo Date: Fri, 11 Apr 2014 09:20:21 -0400 Subject: [PATCH 68/68] Fixed an issue where people who did not get the winning kill... see ext. Fixed an issue where people who did not get the winning kill of a creature or were not grouped with the killer of a creature could loot the corpse of said creature. --- src/services/LootService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/LootService.java b/src/services/LootService.java index 4084d8fd..815490e4 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -73,7 +73,9 @@ public class LootService implements INetworkDispatch { public void handleLootRequest(CreatureObject requester, TangibleObject lootedObject) { - if (lootedObject.isLooted() || lootedObject.isLootLock()) + GroupObject group = (GroupObject) core.objectService.getObject(requester.getGroupId()); + + if (lootedObject.isLooted() || lootedObject.isLootLock() || (group == null && !lootedObject.getKiller().equals(requester)) || (group != null && !group.getMemberList().contains(lootedObject.getKiller()))) return; lootedObject.setLootLock(true);