Пример #1
0
 public static bool atDuelArena(Location l)
 {
     return(l.inArea(3318, 3247, 3327, 3247) ||
            l.inArea(3324, 3247, 3328, 3264) ||
            l.inArea(3327, 3262, 3342, 3270) ||
            l.inArea(3342, 3262, 3387, 3280) ||
            l.inArea(3387, 3262, 3394, 3271) ||
            l.inArea(3313, 3224, 3325, 3247) ||
            l.inArea(3326, 3200, 3398, 3267)); // Entire arena
 }
	    public static bool useWildernessObelisk(Player p, int id, Location loc) {
		    for(int i = 0; i < OBELISK_ID.Length; i++) {
			    if (id == OBELISK_ID[i]) {
				    if (loc.inArea(OBELISK_LOCATIONS[i][0] - 2, OBELISK_LOCATIONS[i][1] - 2, OBELISK_LOCATIONS[i][0] + 2, OBELISK_LOCATIONS[i][1] + 2)) {
                        AreaEvent useWildernessObeliskAreaEvent = new AreaEvent(p, loc.getX() - 1, loc.getY() - 1, loc.getX() + 1, loc.getY() + 1);
                        useWildernessObeliskAreaEvent.setAction(() => {
							    activateObelisk(i);				
					    });
                        Server.registerCoordinateEvent(useWildernessObeliskAreaEvent);
				    }
				    return true;
			    }
		    }
		    return false;
	    }
Пример #3
0
 public static bool atBarrows(Location l)
 {
     return(l.inArea(3521, 9663, 3582, 9727));
 }
Пример #4
0
 public static bool inWilderness(Location l)
 {
     return(l.inArea(2945, 3524, 3391, 3975));
 }
Пример #5
0
 private static int getPatchIndex(Location patchLocation, int i)
 {
     if (patchLocation.inArea((int)PATCHES[i][2], (int)PATCHES[i][3], (int)PATCHES[i][4], (int)PATCHES[i][5]))
     {
         return i;
     }
     return -1;
 }
Пример #6
0
 public static bool inWilderness(Location l)
 {
     return l.inArea(2945, 3524, 3391, 3975);
 }
Пример #7
0
 public static bool inTzHaar(Location l)
 {
     return(l.inArea(2370, 5120, 2541, 5185));
 }
Пример #8
0
 public static bool inFightPits(Location l)
 {
     return(l.inArea(2376, 5127, 2422, 5168));
 }
Пример #9
0
 public static bool inTzHaar(Location l)
 {
     return l.inArea(2370, 5120, 2541, 5185);
 }
Пример #10
0
 public static bool inFightPitsWaitingArea(Location l)
 {
     return l.inArea(2394, 5169, 2404, 5175);
 }
Пример #11
0
 public static bool inFightPits(Location l)
 {
     return l.inArea(2376, 5127, 2422, 5168);
 }
Пример #12
0
 public static bool atAgilityArena(Location l)
 {
     return l.inArea(2757, 9542, 2809, 9594);
 }
Пример #13
0
 public static bool atGodwars(Location l)
 {
     return l.inArea(2820, 5245, 2964, 5380);
 }
Пример #14
0
 public static bool atBarrows(Location l)
 {
     return l.inArea(3521, 9663, 3582, 9727);
 }
Пример #15
0
 public static bool atDuelArena(Location l)
 {
     return l.inArea(3318, 3247, 3327, 3247) ||
     l.inArea(3324, 3247, 3328, 3264) ||
     l.inArea(3327, 3262, 3342, 3270) ||
     l.inArea(3342, 3262, 3387, 3280) ||
     l.inArea(3387, 3262, 3394, 3271) ||
     l.inArea(3313, 3224, 3325, 3247) ||
     l.inArea(3326, 3200, 3398, 3267); // Entire arena
 }
Пример #16
0
 public static bool atGodwars(Location l)
 {
     return(l.inArea(2820, 5245, 2964, 5380));
 }
Пример #17
0
 public static bool atAgilityArena(Location l)
 {
     return(l.inArea(2757, 9542, 2809, 9594));
 }
Пример #18
0
 public static bool onWaterbirthIsle(Location l)
 {
     return l.inArea(2494, 3710, 2564, 3786);
 }
Пример #19
0
 public static bool inFightPitsWaitingArea(Location l)
 {
     return(l.inArea(2394, 5169, 2404, 5175));
 }
Пример #20
0
        public void followEntity() {
		    if (follower == null || entity.isDead() || follower.isDead() || follower.isDestroyed()) {
			    follower = null;
			    return;
		    }

		    if (follower.getLocation().withinDistance(entity.getLocation(), 1))
			    return;

		    if (follower is Player) {
			    if (follower.getEntityFocus() == -1 || follower.getEntityFocus() != entity.getClientIndex()) {
				    entity.setEntityFocus(follower.getClientIndex());
			    }
			    if (!follower.getLocation().withinDistance(entity.getLocation(), 15)) {
				    setFollowing(null);
				    return;
			    }
		    }

            //TODO: Starting from here organize all this crap properly.

		    bool sameCoords = false;
            int x = entity.getLocation().getX();
            int y = entity.getLocation().getY();
		    int targetX = follower.getLocation().getX();
		    int targetY = follower.getLocation().getY();
		    int newX = x;
		    int newY = y;
		    if (x == targetX && y == targetY) {
			    sameCoordWait++;
			    if (sameCoordWait < 2) {
				    return;
			    }
			    if (sameCoordWait == 2) {
				    if (misc.random(3) == 0) {
					    newY--;
				    } else if (misc.random(3) == 1) {
					    newY++;
				    } else if (misc.random(3) == 2) {
					    newX--;
				    } else if (misc.random(3) == 3) {
					    newX++;
				    }
				    sameCoords = true;
				    sameCoordWait = 0;
			    }
		    }

		    if (!sameCoords) {
			    if (targetX > x && targetY == y) {
				    newX++;
			    } else
			    if (targetX < x && targetY == y) {
				    newX--;
			    }else
			    if (targetX == x && targetY > y) {
				    newY++;
			    }else
			    if (targetX == x && targetY < y) {
				    newY--;
			    }else
			    if (targetX > x && targetY > y) {
				    newX++;
				    newY++;
			    }else
			    if (targetX < x && targetY < y) {
				    newX--;
				    newY--;
			    }else
			    if (targetX > x && targetY < y) {
				    newX++;
				    newY--;
			    }else
			    if (targetX < x && targetY > y) {
				    newX--;
				    newY++;
			    }
		    }
		    //if (entity.getLocation().withinDistance(follower.getLocation(),  Combat.npcUsesRange((Npc)entity) ? 30 : Combat.getNPCSize(entity, follower))) {
		    //	return;
		    //}
		    if (entity is Npc) {
			    Location newLoc =  new Location(newX, newY, entity.getLocation().getZ());
                if (!newLoc.inArea(((Npc)entity).getMinimumCoords().getX(), ((Npc)entity).getMinimumCoords().getY(), ((Npc)entity).getMaximumCoords().getX(), ((Npc)entity).getMaximumCoords().getY()))
                {
				    follower = null;
				    return;
			    }
			    if (!sameCoords && newX == targetX && newY == targetY) {
				    return;
			    }
		    }
		    if (follower.getEntityFocus() == -1 || follower.getEntityFocus() != entity.getClientIndex()) {
			    entity.setEntityFocus(follower.getClientIndex());
		    }
            /*
		    if (!entity.getLocation().withinDistance(follower.getLocation())) {
			    if (((Player)follower).getSummonedNPC() == npc) {
				    npc.setLastAnimation(new Animation(8298);
				    npc.setLastGraphics(new Graphics(NPCSizes.getNpcSize(npc.getId()) > 0 ? 1315 : 1314);
				    npc.setLocation(new Location(targetX, targetY, following.getLocation().getZ()));
				    npc.setEntityFocus(following.getClientIndex());
				    return;
				
			    }
		    }*/
		    if (entity is Npc) { //npc following a player.
		        ((Npc)entity).getSprites().setSprites(WalkingQueue.direction(x, y, newX, newY), -1);
			    if (((Npc)entity).getSprites().getPrimarySprite() != -1) {
				    int sprite = ((Npc)entity).getSprites().getPrimarySprite() >> 1;
				    ((Npc)entity).getSprites().setSprites(sprite, -1);
				    ((Npc)entity).setLocation(new Location(newX, newY, ((Npc)entity).getLocation().getZ()));
			    }
		    } else { //player following a player
                int diffX = targetX - x;
                int diffY = targetY - y;

                //if(Math.Max(Math.Abs(diffX), Math.Abs(diffY)) <= 1) return; //1 step away or on top of player, no need to follow

                //Try to fix this up to make it look more natural. Because just using the else statement looks ugly.
                //TODO: Must add sprite direction detection for it to know which way the person is standing so it would be behind him.
                if (diffX == 0 && diffY == -2)  { //go down
                    diffY = -1;
                } else  if (diffX == 0 && diffY == 2) { //go up
                    diffY = 1;
                } else if (diffX == -2 && diffY == 0) { //go left
                    diffX = -1;
                } else if (diffX == 2 && diffY == 0) { //go right
                    diffX = 1;
                } else  if ( (diffX == 2 && diffY == -2) || (diffX == 2 && diffY == -1) || (diffX == 1 && diffY == -2)) { //left down, down 1 left 2 or down 2 right 1
                    diffX = 1;
                    diffY = -1;
                } else if ((diffX == -2 && diffY == 2) || (diffX == -2 && diffY == 1) || (diffX == -1 && diffY == 2)) { //left up, up 1 left 2 or up 2 left 1
                    diffX = -1;
                    diffY = 1;
                } else if ((diffX == 2 && diffY == 2) || (diffX == 2 && diffY == 1) || (diffX == 1 && diffY == 2)){ //up right, up 1 right 2, up 2 right 1
                    diffX = 1;
                    diffY = 1;
                } else if ((diffX == -2 && diffY == -2) ||(diffX == -1 && diffY == -2) || (diffX == -2 && diffY == -1)) { //down left, down 2 left 1 or down 1 right 2
                    diffX = -1;
                    diffY = -1;
                } else {
	                if (diffX < 0)
                        diffX++;
                    else if (diffX > 0)
                        diffX--;
                    if (diffY < 0)
                        diffY++;
                    else if (diffY > 0)
                        diffY--;
	            }

                ((Player)entity).getWalkingQueue().forceWalk(diffX, diffY);
		    }
	    }
Пример #21
0
 public static bool onWaterbirthIsle(Location l)
 {
     return(l.inArea(2494, 3710, 2564, 3786));
 }
Пример #22
0
        public void followEntity()
        {
            if (follower == null || entity.isDead() || follower.isDead() || follower.isDestroyed())
            {
                follower = null;
                return;
            }

            if (follower.getLocation().withinDistance(entity.getLocation(), 1))
            {
                return;
            }

            if (follower is Player)
            {
                if (follower.getEntityFocus() == -1 || follower.getEntityFocus() != entity.getClientIndex())
                {
                    entity.setEntityFocus(follower.getClientIndex());
                }
                if (!follower.getLocation().withinDistance(entity.getLocation(), 15))
                {
                    setFollowing(null);
                    return;
                }
            }

            //TODO: Starting from here organize all this crap properly.

            bool sameCoords = false;
            int  x          = entity.getLocation().getX();
            int  y          = entity.getLocation().getY();
            int  targetX    = follower.getLocation().getX();
            int  targetY    = follower.getLocation().getY();
            int  newX       = x;
            int  newY       = y;

            if (x == targetX && y == targetY)
            {
                sameCoordWait++;
                if (sameCoordWait < 2)
                {
                    return;
                }
                if (sameCoordWait == 2)
                {
                    if (misc.random(3) == 0)
                    {
                        newY--;
                    }
                    else if (misc.random(3) == 1)
                    {
                        newY++;
                    }
                    else if (misc.random(3) == 2)
                    {
                        newX--;
                    }
                    else if (misc.random(3) == 3)
                    {
                        newX++;
                    }
                    sameCoords    = true;
                    sameCoordWait = 0;
                }
            }

            if (!sameCoords)
            {
                if (targetX > x && targetY == y)
                {
                    newX++;
                }
                else
                if (targetX < x && targetY == y)
                {
                    newX--;
                }
                else
                if (targetX == x && targetY > y)
                {
                    newY++;
                }
                else
                if (targetX == x && targetY < y)
                {
                    newY--;
                }
                else
                if (targetX > x && targetY > y)
                {
                    newX++;
                    newY++;
                }
                else
                if (targetX < x && targetY < y)
                {
                    newX--;
                    newY--;
                }
                else
                if (targetX > x && targetY < y)
                {
                    newX++;
                    newY--;
                }
                else
                if (targetX < x && targetY > y)
                {
                    newX--;
                    newY++;
                }
            }
            //if (entity.getLocation().withinDistance(follower.getLocation(),  Combat.npcUsesRange((Npc)entity) ? 30 : Combat.getNPCSize(entity, follower))) {
            //	return;
            //}
            if (entity is Npc)
            {
                Location newLoc = new Location(newX, newY, entity.getLocation().getZ());
                if (!newLoc.inArea(((Npc)entity).getMinimumCoords().getX(), ((Npc)entity).getMinimumCoords().getY(), ((Npc)entity).getMaximumCoords().getX(), ((Npc)entity).getMaximumCoords().getY()))
                {
                    follower = null;
                    return;
                }
                if (!sameCoords && newX == targetX && newY == targetY)
                {
                    return;
                }
            }
            if (follower.getEntityFocus() == -1 || follower.getEntityFocus() != entity.getClientIndex())
            {
                entity.setEntityFocus(follower.getClientIndex());
            }

            /*
             *      if (!entity.getLocation().withinDistance(follower.getLocation())) {
             *              if (((Player)follower).getSummonedNPC() == npc) {
             *                      npc.setLastAnimation(new Animation(8298);
             *                      npc.setLastGraphics(new Graphics(NPCSizes.getNpcSize(npc.getId()) > 0 ? 1315 : 1314);
             *                      npc.setLocation(new Location(targetX, targetY, following.getLocation().getZ()));
             *                      npc.setEntityFocus(following.getClientIndex());
             *                      return;
             *
             *              }
             *      }*/
            if (entity is Npc)           //npc following a player.
            {
                ((Npc)entity).getSprites().setSprites(WalkingQueue.direction(x, y, newX, newY), -1);
                if (((Npc)entity).getSprites().getPrimarySprite() != -1)
                {
                    int sprite = ((Npc)entity).getSprites().getPrimarySprite() >> 1;
                    ((Npc)entity).getSprites().setSprites(sprite, -1);
                    ((Npc)entity).setLocation(new Location(newX, newY, ((Npc)entity).getLocation().getZ()));
                }
            }
            else             //player following a player
            {
                int diffX = targetX - x;
                int diffY = targetY - y;

                //if(Math.Max(Math.Abs(diffX), Math.Abs(diffY)) <= 1) return; //1 step away or on top of player, no need to follow

                //Try to fix this up to make it look more natural. Because just using the else statement looks ugly.
                //TODO: Must add sprite direction detection for it to know which way the person is standing so it would be behind him.
                if (diffX == 0 && diffY == -2)    //go down
                {
                    diffY = -1;
                }
                else if (diffX == 0 && diffY == 2)      //go up
                {
                    diffY = 1;
                }
                else if (diffX == -2 && diffY == 0)     //go left
                {
                    diffX = -1;
                }
                else if (diffX == 2 && diffY == 0)     //go right
                {
                    diffX = 1;
                }
                else if ((diffX == 2 && diffY == -2) || (diffX == 2 && diffY == -1) || (diffX == 1 && diffY == -2))       //left down, down 1 left 2 or down 2 right 1
                {
                    diffX = 1;
                    diffY = -1;
                }
                else if ((diffX == -2 && diffY == 2) || (diffX == -2 && diffY == 1) || (diffX == -1 && diffY == 2))     //left up, up 1 left 2 or up 2 left 1
                {
                    diffX = -1;
                    diffY = 1;
                }
                else if ((diffX == 2 && diffY == 2) || (diffX == 2 && diffY == 1) || (diffX == 1 && diffY == 2))    //up right, up 1 right 2, up 2 right 1
                {
                    diffX = 1;
                    diffY = 1;
                }
                else if ((diffX == -2 && diffY == -2) || (diffX == -1 && diffY == -2) || (diffX == -2 && diffY == -1))    //down left, down 2 left 1 or down 1 right 2
                {
                    diffX = -1;
                    diffY = -1;
                }
                else
                {
                    if (diffX < 0)
                    {
                        diffX++;
                    }
                    else if (diffX > 0)
                    {
                        diffX--;
                    }
                    if (diffY < 0)
                    {
                        diffY++;
                    }
                    else if (diffY > 0)
                    {
                        diffY--;
                    }
                }

                ((Player)entity).getWalkingQueue().forceWalk(diffX, diffY);
            }
        }