Esempio n. 1
0
 public static boolean isInArea(Position position, Area area) {
   return position.getZ() == area.getSouthWestCorner().getZ()
       && position.getX() > area.getSouthWestCorner().getX()
       && position.getY() > area.getSouthWestCorner().getY()
       && position.getX() < area.getNorthEastCorner().getX()
       && position.getY() < area.getNorthEastCorner().getY();
 }
Esempio n. 2
0
 public Area enlarge(int distance) {
   this.southWestCorner =
       new Position(
           southWestCorner.getX() - distance,
           southWestCorner.getY() - distance,
           southWestCorner.getZ());
   this.northEastCorner =
       new Position(
           northEastCorner.getX() + distance,
           northEastCorner.getY() + distance,
           northEastCorner.getZ());
   return this;
 }
Esempio n. 3
0
 /** Makes walkable npcs walk, then updates it's position. */
 public void sendNpcWalk() {
   if (walkType == WalkType.WALK && Misc.randomNumber(10) == 0) {
     int yModifier = 0, xModifier = 0, direction = 0;
     int[][] coordinateModifiers = {
       {-1, 1}, {0, 1}, {1, 1}, {-1, 0}, {1, 0}, {-1, -1}, {0, -1}, {1, -1}
     };
     direction = Misc.randomNumber(8);
     xModifier = coordinateModifiers[direction][0];
     yModifier = coordinateModifiers[direction][1];
     if (minWalk.getX() <= (currentX + xModifier)
         && minWalk.getY() <= (currentY + yModifier)
         && maxWalk.getX() >= (currentX + xModifier)
         && maxWalk.getY() >= (currentY + yModifier)) {
       primaryDirection = direction;
       appendNpcPosition(xModifier, yModifier);
       getUpdateFlags().faceEntity(65535);
     }
   }
 }
Esempio n. 4
0
 public static Position randomPosition(Area area) {
   Position finalPosition =
       new Position(
           area.getSouthWestCorner().getX()
               + Misc.random(area.getNorthEastCorner().getX() - area.getSouthWestCorner().getX()),
           area.getSouthWestCorner().getY()
               + Misc.random(area.getNorthEastCorner().getY() - area.getSouthWestCorner().getY()),
           area.getSouthWestCorner().getZ());
   while (Region.getClipping(finalPosition.getX(), finalPosition.getY(), finalPosition.getZ())
       != 0)
     finalPosition =
         new Position(
             area.getSouthWestCorner().getX()
                 + Misc.random(
                     area.getNorthEastCorner().getX() - area.getSouthWestCorner().getX()),
             area.getSouthWestCorner().getY()
                 + Misc.random(
                     area.getNorthEastCorner().getY() - area.getSouthWestCorner().getY()),
             area.getSouthWestCorner().getZ());
   return finalPosition;
 }