From e05a5b4bf548015996b79ea6f52adb55d9cb3bdd Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Sat, 5 Apr 2014 23:59:42 +0200 Subject: [PATCH 01/38] 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 31f20c7ac0ab5bdcdea75155d9ff5e6236f9cf3d Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Mon, 7 Apr 2014 01:56:46 +0200 Subject: [PATCH 02/38] 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 1f981fa388a2ec77e6a7b93ff0618a9977a12a66 Mon Sep 17 00:00:00 2001 From: Bronco69 Date: Mon, 7 Apr 2014 03:18:46 +0200 Subject: [PATCH 03/38] 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 97dfb85bd7807a417f6ec50f683dcf8ebcbbf17d Mon Sep 17 00:00:00 2001 From: Bronco69 Date: Mon, 7 Apr 2014 04:25:56 +0200 Subject: [PATCH 04/38] 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 580daaa8eb1aed320dc97712cfb786a102c6d69b Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:02:52 +0100 Subject: [PATCH 05/38] 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 2fcc4dd24b91db32fa147154b892a9d8c35afeaf Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:15:53 +0100 Subject: [PATCH 06/38] 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 7558d65f3a7053c9e0659c4b687b5b4f60c32a39 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:21:32 +0100 Subject: [PATCH 07/38] 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 0bc71493eedbb3ab2f9eb3b6b8d43f4464522522 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:27:42 +0100 Subject: [PATCH 08/38] 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 53c54b983e1e378f537c883e12e6fade8e2a61e8 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:32:03 +0100 Subject: [PATCH 09/38] 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 3e46e6e7d5acca3f253557e47dba2ae0cead5caa Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:38:03 +0100 Subject: [PATCH 10/38] 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 948f4db778ba3784e13924472589795082e808a9 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:45:59 +0100 Subject: [PATCH 11/38] 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 497f290e54e20f90f7aa0c475b32ce5ee6162bed Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 04:53:38 +0100 Subject: [PATCH 12/38] 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 92b262d8280a34277fa6f3ca7a92fc2b58818839 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 05:02:39 +0100 Subject: [PATCH 13/38] 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 b89190fd97347c6a71e81685f2df9031b3287e18 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 05:12:43 +0100 Subject: [PATCH 14/38] 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 44c4d8632cbde5d9415cb8fc210f460de61fb223 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 05:22:44 +0100 Subject: [PATCH 15/38] 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 7008b1fd9e641604c048cda67570a4f41a0d8e84 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 05:54:20 +0100 Subject: [PATCH 16/38] 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 3eeb1bb7d579afd7826738320dcee0069a66196b Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 06:06:39 +0100 Subject: [PATCH 17/38] 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 577bbdb23b98a0880b5426040380d86f2a1ba8c0 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 06:41:32 +0100 Subject: [PATCH 18/38] 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 d7b51621a15cc0a5b69d18b2583716bd3228827e Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 07:19:31 +0100 Subject: [PATCH 19/38] 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 b6045f85dc817c37502a974acab880f90aa76be6 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 09:29:19 +0100 Subject: [PATCH 20/38] 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 f221f02b593205dba73652e26e2c11ac3bfec373 Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Mon, 7 Apr 2014 10:33:12 +0200 Subject: [PATCH 21/38] 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 c8aeff3d1d5989d274324e0a962b881d0c92bb6d Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 09:46:12 +0100 Subject: [PATCH 22/38] 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 75df58038cbc10aeb5d88b8dafe6a3b47e6c2e2a Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Mon, 7 Apr 2014 10:48:33 +0200 Subject: [PATCH 23/38] 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 e4d676f43d5f4c2a23fc164b1fd1469ef8ca2adf Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 10:08:41 +0100 Subject: [PATCH 24/38] 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 c1486c27fe54d10ad51b7d56029b4764a9cee451 Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Mon, 7 Apr 2014 11:29:19 +0200 Subject: [PATCH 25/38] 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 2a9988847fd41a45f3f1874c967c1ba4f709031e Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 10:37:11 +0100 Subject: [PATCH 26/38] 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 7216987f13a4af12bd1a3d5b46ea427a66f705bf Mon Sep 17 00:00:00 2001 From: Levarrishawk Date: Mon, 7 Apr 2014 05:50:25 -0400 Subject: [PATCH 27/38] 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 615a998384634beba61e7db5b91cb7940da4133c Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 14:47:56 +0100 Subject: [PATCH 28/38] 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 f3e2498e627dba2c63406ec28f3bd61311f57f01 Mon Sep 17 00:00:00 2001 From: Seefo Date: Mon, 7 Apr 2014 10:32:25 -0400 Subject: [PATCH 29/38] 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 0bbf98e20909c415cc3cdc53634dbd7335764281 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 16:31:23 +0100 Subject: [PATCH 30/38] 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 5dbabe69820b8e2c2ee6564bf9a437ef5ef0ef52 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 16:42:19 +0100 Subject: [PATCH 31/38] 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 69da7a4abd3d444a4530035a541fe984dcc8b221 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 18:31:13 +0100 Subject: [PATCH 32/38] Commands now account for different cmdTable struct --- src/services/command/BaseSWGCommand.java | 162 +++++++++++++---------- 1 file changed, 91 insertions(+), 71 deletions(-) diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index 7ded241d..a00dee0a 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 = null; + private String characterAbility; private int target; private int targetType; private boolean callOnTarget = false; @@ -60,9 +60,11 @@ public class BaseSWGCommand implements Cloneable { 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", "command_table_atmospheric_flight" }; + "command_table", "command_table_ground", "command_table_space" }; for (int n = 0; n < tableArray.length; n++) { List invalidStates = new ArrayList(); @@ -73,87 +75,105 @@ public class BaseSWGCommand implements Cloneable { 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); - 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, 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 (!((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); + 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 (characterAbility != null) { + if (foundCommand) { break; } } From 3928d5844801352ab8a77f1d7b9f9a6fca36e8ec Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 18:43:31 +0100 Subject: [PATCH 33/38] cmdSvc now accounts for different cmdTable struct --- src/services/command/CommandService.java | 34 +++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index c6b5fab0..2b7a6877 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -258,7 +258,7 @@ public class CommandService implements INetworkDispatch { try { 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" }; + "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); @@ -268,8 +268,19 @@ public class CommandService implements INetworkDispatch { 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); + 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 = (Boolean) visitor.getObject(i, 82-sub); if (hasCharacterAbility || isCombatCommand) { CombatCommand command = new CombatCommand(name.toLowerCase()); @@ -305,7 +316,7 @@ public class CommandService implements INetworkDispatch { try { 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" }; + "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); @@ -315,8 +326,19 @@ public class CommandService implements INetworkDispatch { 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); + 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 = (Boolean) visitor.getObject(i, 82-sub); if (hasCharacterAbility || isCombatCommand) { CombatCommand command = new CombatCommand(commandName); From ac39628b294fbb700cabbdb1aa2cbdcfcd034e6c Mon Sep 17 00:00:00 2001 From: Light2 Date: Mon, 7 Apr 2014 19:57:21 +0200 Subject: [PATCH 34/38] fixed command crash --- src/services/command/CommandService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 2b7a6877..8ab54593 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -338,7 +338,10 @@ public class CommandService implements INetworkDispatch { sub += 5; } - boolean isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); + 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); From f2d42d750a7960f31186e81bfe1760e650270e18 Mon Sep 17 00:00:00 2001 From: Light2 Date: Mon, 7 Apr 2014 20:08:04 +0200 Subject: [PATCH 35/38] fixed another command crash --- 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 a00dee0a..0448a8ea 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -94,7 +94,7 @@ public class BaseSWGCommand implements Cloneable { 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_")) { + if (tableArray[n].startsWith("client_") || tableArray[n].startsWith("command_table_")) { sub += 1; } From ff8c22df7b0ba3cdb25962e6afd19e7867626457 Mon Sep 17 00:00:00 2001 From: Light2 Date: Mon, 7 Apr 2014 20:44:20 +0200 Subject: [PATCH 36/38] command class cast fix --- src/services/command/CommandService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 8ab54593..8e9bcf44 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -280,7 +280,10 @@ public class CommandService implements INetworkDispatch { sub += 5; } - boolean isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); + 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()); From d5c9d226e3c7ed85c47aab279e0a37ffa7fd55ac Mon Sep 17 00:00:00 2001 From: Waverunner Date: Mon, 7 Apr 2014 16:22:36 -0400 Subject: [PATCH 37/38] Fixed #255: Evasion not exiting combat --- scripts/buffs/me_evasion_1.py | 2 ++ src/services/SimulationService.java | 3 +-- src/services/combat/CombatService.java | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/buffs/me_evasion_1.py b/scripts/buffs/me_evasion_1.py index 81ea7c1d..723b5ad5 100644 --- a/scripts/buffs/me_evasion_1.py +++ b/scripts/buffs/me_evasion_1.py @@ -7,6 +7,8 @@ def add(core, actor, buff): core.skillModService.addSkillMod(actor, 'expertise_dodge', 35) core.skillModService.addSkillMod(actor, 'display_only_evasion', 5000) core.skillModService.addSkillMod(actor, 'combat_evasion_value', 50) + + core.combatService.endCombat(actor) return def remove(core, actor, buff): diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 051f1690..bf7cc26e 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -775,8 +775,7 @@ public class SimulationService implements INetworkDispatch { core.removeClient(session); object.setAttachment("disconnectTask", disconnectTask); - for(TangibleObject obj : new Vector(object.getDefendersList())) - object.removeDefender(obj); // temp fix for being stuck in combat + core.combatService.endCombat(object); // temp fix for ending combat on disconnect } diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 6115344a..08a6cee5 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -1381,6 +1381,13 @@ public class CombatService implements INetworkDispatch { } + public void endCombat(CreatureObject defender) { + Vector defenderList = new Vector(defender.getDefendersList()); + if (defenderList.size() > 0) { + defenderList.stream().forEach(attacker -> defender.removeDefender(attacker)); + } + } + public enum HitType{; public static final byte MISS = 0; From ce183ad337a8c59007590c1418a13032687d9a2e Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Mon, 7 Apr 2014 23:59:42 +0200 Subject: [PATCH 38/38] 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) { } + +}