Commands check LOS & distance if correct type

This commit is contained in:
Treeku
2014-04-07 07:19:31 +01:00
parent 577bbdb23b
commit d7b51621a1
+17 -4
View File
@@ -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;