Skip to content

Commit

Permalink
fix guarding pathing
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 17, 2019
1 parent a702759 commit ac02ffb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/main/java/org/mcmonkey/sentinel/SentinelTrait.java
Expand Up @@ -1100,7 +1100,11 @@ else if (chasing == null) {
npc.getNavigator().getDefaultParameters().distanceMargin(SentinelPlugin.instance.guardDistanceMargin); npc.getNavigator().getDefaultParameters().distanceMargin(SentinelPlugin.instance.guardDistanceMargin);
npc.getNavigator().getDefaultParameters().range(100); npc.getNavigator().getDefaultParameters().range(100);
npc.getNavigator().getDefaultParameters().stuckAction(TeleportStuckAction.INSTANCE); 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); npc.getNavigator().getLocalParameters().speedModifier((float) speed);
chased = true; chased = true;
} }
Expand Down Expand Up @@ -1131,7 +1135,7 @@ else if (chasing == null) {
chased = false; chased = false;
} }
else { else {
if (pathingTo == null && npc.getNavigator().isNavigating()) { if (pathingTo == null && npc.getNavigator().isNavigating() && getGuarding() == null) {
npc.getNavigator().cancelNavigation(); npc.getNavigator().cancelNavigation();
needsSafeReturn = false; needsSafeReturn = false;
} }
Expand All @@ -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(); npc.getNavigator().cancelNavigation();
needsSafeReturn = false; needsSafeReturn = false;
} }
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/mcmonkey/sentinel/SentinelUtilities.java
Expand Up @@ -73,7 +73,7 @@ public static Location rayTrace(Location start, Location end) {
*/ */
public static Location pickNear(Location start, double range) { public static Location pickNear(Location start, double range) {
Location hit = rayTrace(start.clone().add(0, 1.5, 0), start.clone().add( 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()) { if (hit.subtract(0, 1, 0).getBlock().getType().isSolid()) {
return hit; return hit;
} }
Expand Down
Expand Up @@ -47,7 +47,7 @@ public void info(CommandContext args, CommandSender sender, SentinelTrait sentin


@Command(aliases = {"sentinel"}, usage = "stats", @Command(aliases = {"sentinel"}, usage = "stats",
desc = "Shows statistics about the current NPC.", 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}) @Requirements(livingEntity = true, ownership = true, traits = {SentinelTrait.class})
public void stats(CommandContext args, CommandSender sender, SentinelTrait sentinel) { public void stats(CommandContext args, CommandSender sender, SentinelTrait sentinel) {
sender.sendMessage(SentinelCommand.prefixGood + ChatColor.RESET + sentinel.getNPC().getFullName() + SentinelCommand.ColorBasic sender.sendMessage(SentinelCommand.prefixGood + ChatColor.RESET + sentinel.getNPC().getFullName() + SentinelCommand.ColorBasic
Expand Down

0 comments on commit ac02ffb

Please sign in to comment.