예제 #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
 }
예제 #2
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
 }
예제 #3
0
 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;
 }
예제 #4
0
 public static bool atGodwars(Location l)
 {
     return l.inArea(2820, 5245, 2964, 5380);
 }
예제 #5
0
 public static bool atBarrows(Location l)
 {
     return l.inArea(3521, 9663, 3582, 9727);
 }
예제 #6
0
 public static bool atAgilityArena(Location l)
 {
     return l.inArea(2757, 9542, 2809, 9594);
 }
예제 #7
0
파일: Follow.cs 프로젝트: Rut0/RSPS-CSharp
        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(Misc.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);
            }
        }
예제 #8
0
 public static bool onWaterbirthIsle(Location l)
 {
     return l.inArea(2494, 3710, 2564, 3786);
 }
예제 #9
0
 public static bool inTzHaar(Location l)
 {
     return l.inArea(2370, 5120, 2541, 5185);
 }
예제 #10
0
 public static bool inFightPits(Location l)
 {
     return(l.inArea(2376, 5127, 2422, 5168));
 }
예제 #11
0
 public static bool atAgilityArena(Location l)
 {
     return(l.inArea(2757, 9542, 2809, 9594));
 }
예제 #12
0
 public static bool atGodwars(Location l)
 {
     return(l.inArea(2820, 5245, 2964, 5380));
 }
예제 #13
0
 public static bool atBarrows(Location l)
 {
     return(l.inArea(3521, 9663, 3582, 9727));
 }
예제 #14
0
 public static bool inWilderness(Location l)
 {
     return(l.inArea(2945, 3524, 3391, 3975));
 }
예제 #15
0
파일: Follow.cs 프로젝트: ramatronics/rsps
        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(Misc.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);
            }
        }
예제 #16
0
 public static bool inFightPits(Location l)
 {
     return l.inArea(2376, 5127, 2422, 5168);
 }
예제 #17
0
 public static bool inFightPitsWaitingArea(Location l)
 {
     return l.inArea(2394, 5169, 2404, 5175);
 }
예제 #18
0
 public static bool inFightPitsWaitingArea(Location l)
 {
     return(l.inArea(2394, 5169, 2404, 5175));
 }
예제 #19
0
 public static bool inWilderness(Location l)
 {
     return l.inArea(2945, 3524, 3391, 3975);
 }
예제 #20
0
 public static bool inTzHaar(Location l)
 {
     return(l.inArea(2370, 5120, 2541, 5185));
 }
예제 #21
0
 public static bool onWaterbirthIsle(Location l)
 {
     return(l.inArea(2494, 3710, 2564, 3786));
 }
예제 #22
0
파일: Farming.cs 프로젝트: ramatronics/rsps
 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;
 }