Skip to content
Permalink
Browse files

fix guarding pathing

  • Loading branch information...
mcmonkey4eva committed Mar 17, 2019
1 parent a702759 commit ac02ffb91781a062ba7cca4cd04d0be97eadf5db
@@ -1100,7 +1100,11 @@ else if (chasing == null) {
npc.getNavigator().getDefaultParameters().distanceMargin(SentinelPlugin.instance.guardDistanceMargin);
npc.getNavigator().getDefaultParameters().range(100);
npc.getNavigator().getDefaultParameters().stuckAction(TeleportStuckAction.INSTANCE);
npc.getNavigator().setTarget(SentinelUtilities.pickNear(player.getLocation(), guardSelectionRange));
Location picked = SentinelUtilities.pickNear(player.getLocation(), guardSelectionRange);
if (SentinelPlugin.debugMe) {
debug("Guard movement chosen to go to " + picked.toVector().toBlockVector().toString());
}
npc.getNavigator().setTarget(picked);
npc.getNavigator().getLocalParameters().speedModifier((float) speed);
chased = true;
}
@@ -1131,7 +1135,7 @@ else if (chasing == null) {
chased = false;
}
else {
if (pathingTo == null && npc.getNavigator().isNavigating()) {
if (pathingTo == null && npc.getNavigator().isNavigating() && getGuarding() == null) {
npc.getNavigator().cancelNavigation();
needsSafeReturn = false;
}
@@ -1142,7 +1146,7 @@ else if (chasing == null) {
}
}
}
else if (chasing == null && pathingTo == null && npc.getNavigator().isNavigating() && needsSafeReturn) {
else if (chasing == null && getGuarding() == null && pathingTo == null && npc.getNavigator().isNavigating() && needsSafeReturn) {
npc.getNavigator().cancelNavigation();
needsSafeReturn = false;
}
@@ -73,7 +73,7 @@ public static Location rayTrace(Location start, Location end) {
*/
public static Location pickNear(Location start, double range) {
Location hit = rayTrace(start.clone().add(0, 1.5, 0), start.clone().add(
SentinelUtilities.randomDecimal(-range, range), 1.5, SentinelUtilities.randomDecimal(range, range)));
SentinelUtilities.randomDecimal(-range, range), 1.5, SentinelUtilities.randomDecimal(-range, range)));
if (hit.subtract(0, 1, 0).getBlock().getType().isSolid()) {
return hit;
}
@@ -47,7 +47,7 @@ public void info(CommandContext args, CommandSender sender, SentinelTrait sentin

@Command(aliases = {"sentinel"}, usage = "stats",
desc = "Shows statistics about the current NPC.",
modifiers = {"stats"}, permission = "sentinel.info", min = 2, max = 2)
modifiers = {"stats"}, permission = "sentinel.info", min = 1, max = 1)
@Requirements(livingEntity = true, ownership = true, traits = {SentinelTrait.class})
public void stats(CommandContext args, CommandSender sender, SentinelTrait sentinel) {
sender.sendMessage(SentinelCommand.prefixGood + ChatColor.RESET + sentinel.getNPC().getFullName() + SentinelCommand.ColorBasic

0 comments on commit ac02ffb

Please sign in to comment.
You can’t perform that action at this time.