From 8a727e13651e5f4705f4274c3bedc9824681f950 Mon Sep 17 00:00:00 2001 From: CoderTim Date: Mon, 4 Aug 2014 01:02:05 -0400 Subject: [PATCH 1/2] Smarter Sneaky Assassins AI --- .../games/sneakyassassins/npc/NpcManager.java | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java index 24d020347..620a9d369 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java @@ -8,6 +8,7 @@ import nautilus.game.arcade.game.*; import nautilus.game.arcade.game.games.sneakyassassins.*; import nautilus.game.arcade.world.*; import org.bukkit.*; +import org.bukkit.block.*; import org.bukkit.entity.*; import org.bukkit.event.*; import org.bukkit.event.entity.*; @@ -91,11 +92,35 @@ public class NpcManager implements Listener { if (getRandom().nextInt(40) == 0) { - Location loc = npc.getLocation().add(getRandom().nextDouble() * 32 - 16, 0, getRandom().nextDouble() * 32 - 16); + List nearby = new ArrayList<>(); - if (loc.getWorld().getHighestBlockYAt(loc) > 0) + for (Location location : getGame().GetTeamList().get(0).GetSpawns()) { - UtilEnt.CreatureMove(npc, loc, 0.8f); + if (Math.abs(npc.getLocation().getX() - location.getX()) <= 16 && Math.abs(npc.getLocation().getZ() - location.getZ()) <= 16) + nearby.add(location); + } + + if (!nearby.isEmpty()) + { + Location location = UtilAlg.Random(nearby); + + for (int i = 0; i < 5; i++) + { + int dx = getRandom().nextInt(5) - 2; + int dz = getRandom().nextInt(5) - 2; + + Location candidate = location.clone().add(dx, 0, dz); + Block block = candidate.getBlock(); + + if (block.isEmpty() && block.getRelative(BlockFace.UP).isEmpty()) + { + location = candidate; + + break; + } + } + + UtilEnt.CreatureMove(npc, location, 0.8f); } } } From e7d3cf9e02a6161a3c21c1d55899516b054c1f66 Mon Sep 17 00:00:00 2001 From: CoderTim Date: Mon, 4 Aug 2014 01:06:11 -0400 Subject: [PATCH 2/2] Sneaky Assassins previous commit bug fix --- .../arcade/game/games/sneakyassassins/npc/NpcManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java index 620a9d369..12c20e22f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java @@ -112,7 +112,10 @@ public class NpcManager implements Listener Location candidate = location.clone().add(dx, 0, dz); Block block = candidate.getBlock(); - if (block.isEmpty() && block.getRelative(BlockFace.UP).isEmpty()) + if (!block.getRelative(BlockFace.DOWN).isEmpty() && + !block.getRelative(BlockFace.DOWN).isLiquid() && + block.isEmpty() && + block.getRelative(BlockFace.UP).isEmpty()) { location = candidate;