Merge remote-tracking branch 'origin/master'

This commit is contained in:
Shaun Bennett 2014-08-04 00:31:56 -05:00
commit 1c5b3919e1
1 changed files with 31 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import nautilus.game.arcade.game.*;
import nautilus.game.arcade.game.games.sneakyassassins.*; import nautilus.game.arcade.game.games.sneakyassassins.*;
import nautilus.game.arcade.world.*; import nautilus.game.arcade.world.*;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.*; import org.bukkit.event.*;
import org.bukkit.event.entity.*; import org.bukkit.event.entity.*;
@ -91,11 +92,38 @@ public class NpcManager implements Listener
{ {
if (getRandom().nextInt(40) == 0) if (getRandom().nextInt(40) == 0)
{ {
Location loc = npc.getLocation().add(getRandom().nextDouble() * 32 - 16, 0, getRandom().nextDouble() * 32 - 16); List<Location> 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.getRelative(BlockFace.DOWN).isEmpty() &&
!block.getRelative(BlockFace.DOWN).isLiquid() &&
block.isEmpty() &&
block.getRelative(BlockFace.UP).isEmpty())
{
location = candidate;
break;
}
}
UtilEnt.CreatureMove(npc, location, 0.8f);
} }
} }
} }