Commands checked if they are combat cmds

This commit is contained in:
Treeku
2014-04-10 15:54:49 +01:00
parent e91362a12f
commit 97df8d8f5f
+20 -4
View File
@@ -97,14 +97,14 @@ public class CommandService implements INetworkDispatch {
return false;
}
// The two below statements need testing before use
for (long state : command.getInvalidStates()) {
if ((actor.getStateBitmask() & state) == state) {
//return false;
}
}
// This SHOULD be invalid locomotions but we don't track these currently.
// Postures are the best we can do.
for (byte posture : command.getInvalidPostures()) {
if (actor.getPosture() == posture) {
//return false;
@@ -259,7 +259,7 @@ public class CommandService implements INetworkDispatch {
sub += 5;
}
if (hasCharacterAbility) {
if (hasCharacterAbility || isCombatCommand(name)) {
CombatCommand command = new CombatCommand(name.toLowerCase());
commandLookup.add(command);
return command;
@@ -315,7 +315,7 @@ public class CommandService implements INetworkDispatch {
sub += 5;
}
if (hasCharacterAbility) {
if (hasCharacterAbility || isCombatCommand(commandName)) {
CombatCommand command = new CombatCommand(commandName);
commandLookup.add(command);
return command;
@@ -335,6 +335,22 @@ public class CommandService implements INetworkDispatch {
return null;
}
public boolean isCombatCommand(String commandName) {
try {
DatatableVisitor visitor = ClientFileManager.loadFile("datatables/combat/combat_data.iff", DatatableVisitor.class);
for (int i = 0; i < visitor.getRowCount(); i++) {
if (visitor.getObject(i, 0) != null && ((String) (visitor.getObject(i, 0))).equalsIgnoreCase(commandName)) {
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) {
actor.addCooldown(command.getCooldownGroup(), command.getCooldown());