Skip to content

Commit

Permalink
Fix attack getting confused about arguments if put in wrong order.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Dec 5, 2013
1 parent 6a8f57e commit 77397ae
Showing 1 changed file with 8 additions and 7 deletions.
Expand Up @@ -30,20 +30,21 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {

if (!scriptEntry.hasObject("cancel")
&& arg.matches("cancel, stop")) {
&& arg.matches("cancel, stop")) {

scriptEntry.addObject("cancel", "");
}

else if (!scriptEntry.hasObject("target")
&& arg.matchesArgumentType(dEntity.class)
&& arg.matchesPrefix("target")) {
&& arg.matchesPrefix("target, t")) {
// Single entity arg
scriptEntry.addObject("target", arg.asType(dEntity.class));
}

else if (!scriptEntry.hasObject("entities")
&& arg.matchesArgumentList(dEntity.class)) {
&& arg.matchesArgumentList(dEntity.class)
&& !arg.matchesPrefix("target, t")) {
// Entity dList arg
scriptEntry.addObject("entities", ((dList) arg.asType(dList.class)).filter(dEntity.class));
}
Expand Down Expand Up @@ -78,8 +79,8 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept

// Report to dB
dB.report(scriptEntry, getName(), (cancel == true ? aH.debugObj("cancel", cancel) : "") +
aH.debugObj("entities", entities.toString()) +
(target != null ? aH.debugObj("target", target) : ""));
aH.debugObj("entities", entities.toString()) +
(target != null ? aH.debugObj("target", target) : ""));

// Go through all the entities and make them either attack
// the target or stop attacking
Expand All @@ -94,8 +95,8 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
else {
// Only cancel navigation if the NPC is attacking something
if (nav.isNavigating()
&& nav.getTargetType().equals(TargetType.ENTITY)
&& nav.getEntityTarget().isAggressive()) {
&& nav.getTargetType().equals(TargetType.ENTITY)
&& nav.getEntityTarget().isAggressive()) {

nav.cancelNavigation();
}
Expand Down

0 comments on commit 77397ae

Please sign in to comment.