Beispiel #1
0
 public bool useDoor(Player p, int doorId, int doorX, int doorY, int doorHeight)
 {
     Location doorLocation = new Location(doorX, doorY, doorHeight);
     foreach (Door door in doors)
     {
         int id = door.isDoorOpen() ? door.getOpenDoorId() : door.getClosedDoorId();
         if (id == doorId)
         {
             if (door.getDoorLocation().Equals(doorLocation))
             {
                 if (door.isDoorOpen() && (Environment.TickCount - door.getLastChangeTime() <= PLAYER_CHANGE_DELAY))
                 {
                     // door was opened in the last PLAYER_CHANGE_DELAY ms..cant be instantly closed
                     return true;
                 }
                 else if (!door.isClosable() && door.isDoorOpen())
                 {
                     // door cannot be closed by a player
                     return true;
                 }
                 Door d = door;
                 AreaEvent useDoorAreaEvent = new AreaEvent(p, doorLocation.getX() - 1, doorLocation.getY() - 1, doorLocation.getX() + 1, doorLocation.getY() + 1);
                 useDoorAreaEvent.setAction(() =>
                 {
                     changeDoor(p, d);
                 });
                 Server.registerCoordinateEvent(useDoorAreaEvent);
                 return true;
             }
         }
     }
     return false;
 }
Beispiel #2
0
 public static void displayEmptyRockMessage(Player player, Location rockLocation)
 {
     AreaEvent displayEmptyRockMessageAreaEvent = new AreaEvent(player, rockLocation.getX() - 1, rockLocation.getY() - 1, rockLocation.getX() + 1, rockLocation.getY() + 1);
     displayEmptyRockMessageAreaEvent.setAction(() =>
     {
         player.getPackets().sendMessage("There is currently no ore available from this rock.");
     });
 }
Beispiel #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;
 }
Beispiel #4
0
 public DwarfCannon(Player player)
 {
     p = player;
     cannonLocation = p.getLocation();
     fakeCannonLocation = new Location(cannonLocation.getX() + 1, cannonLocation.getY() + 1, cannonLocation.getY());
     firing = false;
     cannonballs = 0;
     constructionStage = 0;
     direction = 0;
     setNpcsInArea();
     newCannon();
 }
Beispiel #5
0
 public static void tryCutTree(Player p, ushort treeId, Location treeLocation, int i, bool newCut)
 {
     int index = getTreeIndex(treeId);
     if (index == -1)
     {
         return;
     }
     int s = TREE_SIZE[index];
     int dis = s;
     AreaEvent tryCutTreeAreaEvent = new AreaEvent(p, treeLocation.getX() - s, treeLocation.getY() - s, treeLocation.getX() + s, treeLocation.getY() + s);
     tryCutTreeAreaEvent.setAction(() =>
     {
         cutTree(p, treeId, treeLocation, i, newCut, dis);
     });
     Server.registerCoordinateEvent(tryCutTreeAreaEvent);
 }
Beispiel #6
0
 public static void slashWeb(Player p, ushort webId, Location webLocation)
 {
     AreaEvent slashWebAreaEvent = new AreaEvent(p, webLocation.getX() - 1, webLocation.getY() - 1, webLocation.getX() + 1, webLocation.getY() + 1);
     slashWebAreaEvent.setAction(() =>
     {
         long lastSlash = 0;
         p.setFaceLocation(webLocation);
         if (p.getTemporaryAttribute("lastWebSlash") != null)
         {
             lastSlash = (int)p.getTemporaryAttribute("lastWebSlash");
         }
         if (Environment.TickCount - lastSlash <= 800)
         {
             return;
         }
         if (Server.getGlobalObjects().originalObjectExists(webId, webLocation))
         {
             p.setLastAnimation(new Animation(p.getAttackAnimation()));
             p.setTemporaryAttribute("lastWebSlash", Environment.TickCount);
             Event attemptCutWebEvent = new Event(500);
             attemptCutWebEvent.setAction(() =>
             {
                 attemptCutWebEvent.stop();
                 bool webExists = Server.getGlobalObjects().originalObjectExists(webId, webLocation);
                 Server.getGlobalObjects().lowerHealth(webId, webLocation);
                 if (Server.getGlobalObjects().originalObjectExists(webId, webLocation))
                 {
                     p.getPackets().sendMessage("You fail to cut through the web.");
                 }
                 else
                 {
                     if (webExists)
                     { // This means we slashed it, if !webExists, someone else slashed it in the last 500ms
                         p.getPackets().sendMessage("You slash through the web!");
                     }
                 }
             });
             Server.registerEvent(attemptCutWebEvent);
         }
     });
     Server.registerCoordinateEvent(slashWebAreaEvent);
 }
Beispiel #7
0
 public int distanceToPoint(Location l)
 {
     return (int)Math.Sqrt(Math.Pow(x - l.getX(), 2) + Math.Pow(y - l.getY(), 2));
 }
Beispiel #8
0
 public static bool inFightCave(Location l)
 {
     return l.getX() >= 19000;
 }
Beispiel #9
0
 public int distanceToPoint(Location l)
 {
     return((int)Math.Sqrt(Math.Pow(x - l.getX(), 2) + Math.Pow(y - l.getY(), 2)));
 }
Beispiel #10
0
 public static bool inFightCave(Location l)
 {
     return(l.getX() >= 19000);
 }
Beispiel #11
0
 public static void tryMineRock(Player p, ushort rockId, Location rockLocation, int i, bool newMine)
 {
     if (rockId != 2491)
     {
         AreaEvent mineRockAreaEvent = new AreaEvent(p, rockLocation.getX() - 1, rockLocation.getY() - 1, rockLocation.getX() + 1, rockLocation.getY() + 1);
         mineRockAreaEvent.setAction(() =>
         {
             mineRock(p, rockId, rockLocation, i, newMine);
         });
         Server.registerCoordinateEvent(mineRockAreaEvent);
     }
     else
     {
         AreaEvent mineRuneEssenceAreaEvent = new AreaEvent(p, rockLocation.getX() - 1, rockLocation.getY() - 1, rockLocation.getX() + 5, rockLocation.getY() + 5);
         mineRuneEssenceAreaEvent.setAction(() =>
         {
             mineRock(p, rockId, rockLocation, i, newMine);
         });
         Server.registerCoordinateEvent(mineRuneEssenceAreaEvent);
     }
 }
Beispiel #12
0
 public static bool wantToSmithOnAnvil(Player p, int item, Location anvilLoc)
 {
     for (int i = 0; i < BARS.Length; i++)
     {
         if (item == BARS[i])
         {
             AreaEvent displaySmithOptionsAreaEvent = new AreaEvent(p, anvilLoc.getX() - 1, anvilLoc.getY() - 1, anvilLoc.getX() + 1, anvilLoc.getY() + 1);
             displaySmithOptionsAreaEvent.setAction(() =>
             {
                 displaySmithOptions(p, i);
             });
             Server.registerCoordinateEvent(displaySmithOptionsAreaEvent);
             return true;
         }
     }
     return false;
 }
Beispiel #13
0
 public void sendProjectileCoords(Location location)
 {
     int regionX = player.getUpdateFlags().getLastRegion().getRegionX();
     int regionY = player.getUpdateFlags().getLastRegion().getRegionY();
     connection.SendPacket(new PacketBuilder().setId(26)
         .addByteC((byte)(location.getX() - ((regionX - 6) * 8) - 3))
         .addByte((byte)(location.getY() - ((regionY - 6) * 8) - 2)).toPacket());
 }
Beispiel #14
0
 public static void leaveEssMine(Player p, Location loc)
 {
     AreaEvent leaveEssMineAreaEvent = new AreaEvent(p, loc.getX() - 1, loc.getY() - 1, loc.getX() + 1, loc.getY() + 1);
     leaveEssMineAreaEvent.setAction(() =>
     {
         p.teleport(new Location(2340 + Misc.random(1), 3155 + Misc.random(1), 0));
     });
     Server.registerCoordinateEvent(leaveEssMineAreaEvent);
 }
Beispiel #15
0
 public void sendProjectile(Location source, Location dest, int startSpeed, int gfx, int angle, int startHeight, int endHeight, int speed, Entity lockon)
 {
     sendProjectileCoords(source);
     connection.SendPacket(new PacketBuilder().setId(16)
          .addByte((byte)((byte)angle))
          .addByte((byte)((byte)(source.getX() - dest.getX()) * -1))
          .addByte((byte)((byte)(source.getY() - dest.getY()) * -1))
          .addUShort(lockon is Player ? (-lockon.getClientIndex() - 1) : lockon.getClientIndex() + 1)
          .addUShort(gfx)
          .addByte((byte)startHeight)
          .addByte((byte)endHeight)
          .addUShort(startSpeed)
          .addUShort(speed)
          .addByte((byte)((byte)gfx == 53 ? 0 : 16))//arch..0 if cannon
          .addByte((byte)64).toPacket());
 }
Beispiel #16
0
 public void removeObject(Location loc, int face, int type)
 {
     sendCoords(new Location(loc.getX(), loc.getY(), player.getLocation().getZ()));
     connection.SendPacket(new PacketBuilder().setId(195)
         .addByteC((byte)((type << 2) + (face & 3)))
         .addByte((byte)0).toPacket());
 }
Beispiel #17
0
 public void newStillGraphics(Location loc, Graphics graphics, byte tilesAway = 0)
 {
     sendCoords(new Location(loc.getX(), loc.getY(), player.getLocation().getZ()));
     connection.SendPacket(new PacketBuilder().setId(17)
         .addByte(tilesAway) //tiles away  (X >> 4 + Y & 7)
         .addUShort(graphics.getId()) // graphic id
         .addByte((byte)graphics.getHeight()) //height of the spell above it's basic place, i think it's written in pixels 100 pixels higher
         .addUShort(graphics.getDelay()).toPacket()); ;//Time before casting the graphic
 }
Beispiel #18
0
 public void newObjectAnimation(Location loc, int anim)
 {
     sendCoords(new Location(loc.getX(), loc.getY(), player.getLocation().getZ()));
     int type = 10;
     int x = loc.getX();
     int face = 0;
     if (anim == 497)
     { // Agility ropeswing
         face = x == 2551 ? 4 : x == 3005 ? 2 : 0;
     }
     connection.SendPacket(new PacketBuilder().setId(20)
         .addByteS(0)
         .addByteS((byte)((type << 2) + (face & 3)))
         .addLEShort(anim).toPacket());
 }
Beispiel #19
0
 public void createObject(int objectId, Location loc, int face, int type)
 {
     sendCoords(new Location(loc.getX(), loc.getY(), player.getLocation().getZ()));
     connection.SendPacket(new PacketBuilder().setId(179)
         .addByteA((byte)((type << 2) + (face & 3)))
         .addByte((byte)0)
         .addShortA(objectId).toPacket());
 }