Ejemplo n.º 1
0
        private void handleExamineObject(Player player, Packet packet)
        {
            ushort id = (ushort)packet.readLEShortA();

            if (player.getTemporaryAttribute("unmovable") != null)
            {
                return;
            }

            SkillHandler.resetAllSkills(player);
            player.getPackets().closeInterfaces();
            player.getPackets().sendMessage("[Id: " + id + "] " + ObjectData.forId(id).getExamine());
        }
Ejemplo n.º 2
0
 private void handleFirstClickNPC(Player player, Packet packet)
 {
     int npcIndex = packet.readLEShortA();
     if (npcIndex < 0 || npcIndex > Constants.MAX_NPCS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return;
     }
     SkillHandler.resetAllSkills(player);
     Npc npc = Server.getNpcList()[npcIndex];
     if (npc == null || npc.isDestroyed())
     {
         return;
     }
     Combat.newAttack(player, npc);
 }
Ejemplo n.º 3
0
 private void handleMagicOnNPC(Player player, Packet packet)
 {
     int childId = packet.readLEShort();
     int interfaceId = packet.readLEShort();
     int junk = packet.readShortA();
     int npcIndex = packet.readLEShortA();
     if (npcIndex < 0 || npcIndex > Constants.MAX_NPCS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return;
     }
     Npc npc = Server.getNpcList()[npcIndex];
     if (npc == null || npc.isDestroyed())
     {
         return;
     }
     SkillHandler.resetAllSkills(player);
     player.setTarget(npc);
     MagicCombat.newMagicAttack(player, npc, childId, interfaceId == 193);
     Console.WriteLine(childId);
 }
Ejemplo n.º 4
0
 private void handleItemOnNPC(Player player, Packet packet)
 {
     int interfaceId = packet.readInt();
     int slot = packet.readLEShort();
     int npcIndex = packet.readLEShort();
     int item = packet.readLEShortA();
     if (npcIndex < 0 || npcIndex > Constants.MAX_NPCS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return;
     }
     Npc npc = Server.getNpcList()[npcIndex];
     if (npc == null || npc.isDestroyed())
     {
         return;
     }
     SkillHandler.resetAllSkills(player);
     player.getPackets().closeInterfaces();
     Console.WriteLine("Item on NPC " + npc.getId());
     if (player.getInventory().getItemInSlot(slot) == item)
     {
         switch (npc.getId())
         {
             case 519: // Bob
                 BrokenBarrows.talkToBob(player, npc, player.getInventory().getItemInSlot(slot), 0);
                 break;
         }
     }
 }
Ejemplo n.º 5
0
 private void handleThirdClickObject(Player player, Packet packet)
 {
     short id = packet.readLEShortA();
     int y = packet.readLEShortA();
     int x = packet.readLEShort();
     if (player.getTemporaryAttribute("unmovable") != null)
     {
         return;
     }
     if (x < 1000 || id < 0 || y < 1000 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return;
     }
     SkillHandler.resetAllSkills(player);
     player.getPackets().closeInterfaces();
     player.setFaceLocation(new Location(x, y, player.getLocation().getZ()));
     Console.WriteLine("Third object click = " + id + " " + x + " " + y);
     if (LaddersAndStairs.useObject(player, id, new Location(x, y, player.getLocation().getZ()), 3))
     {
         return;
     }
     switch (id)
     {
         case 28089: // GE desk
             Server.getGrandExchange().clickDesk(player, x, y, 3);
             break;
     }
 }
Ejemplo n.º 6
0
        private void handleSecondClickObject(Player player, Packet packet)
        {
            int objectY = packet.readLEShortA();
            int objectX = packet.readLEShort();
            ushort objectId = packet.readUShort();
            Console.WriteLine("Second object click = " + objectId + " " + objectX + " " + objectY);
            if (player.getTemporaryAttribute("unmovable") != null)
            {
                return;
            }
            if (objectX < 1000 || objectY < 1000 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
            {
                return;
            }
            SkillHandler.resetAllSkills(player);
            player.getPackets().closeInterfaces();
            player.setFaceLocation(new Location(objectX, objectY, player.getLocation().getZ()));
            if (Thieving.wantToThieveStall(player, objectId, objectX, objectY))
            {
                return;
            }
            else if (Farming.interactWithPatch(player, objectId, objectX, objectY, -1))
            {
                return;
            }
            else if (LaddersAndStairs.useObject(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 2))
            {
                return;
            }
            switch (objectId)
            {
                case 28089: // GE desk
                    Server.getGrandExchange().clickDesk(player, objectX, objectY, 2);
                    break;

                case 25824: // Spinning wheel (Seers)
                case 36970: // Spinning wheel (Lumbridge
                    Spinning.displaySpinningInterface(player);
                    break;

                case 6: // Dwarf multicannon
                    DwarfCannon cannon = player.getCannon();
                    Location l = new Location(objectX, objectY, player.getLocation().getZ());
                    if (cannon == null || (cannon != null & !l.Equals(cannon.getLocation())))
                    {
                        player.getPackets().sendMessage("This isn't your cannon!");
                        break;
                    }
                    cannon.pickupCannon();
                    break;

                case 11666: // Falador furnace
                case 36956: // Lumbridge furnace
                    Smelting.displaySmeltOptions(player);
                    break;

                case 11959: // Tin rocks
                case 11958:
                case 11957:
                case 11933:
                case 11934:
                case 11935:
                case 31077:
                case 31078:
                case 31079:
                    Mining.prospectRock(player, objectX, objectY, "tin");
                    break;

                case 11960: // Copper rocks
                case 11961:
                case 11962:
                case 11936:
                case 11937:
                case 11938:
                case 31080:
                case 31081:
                case 31082:
                    Mining.prospectRock(player, objectX, objectY, "copper");
                    break;

                case 15504: // Clay rocks
                case 15503:
                case 15505:
                case 11189:
                case 11190:
                case 11191:
                case 31062:
                case 31063:
                case 31064:
                case 32429:
                case 32430:
                case 32431:
                    Mining.prospectRock(player, objectX, objectY, "clay");
                    break;

                case 11948: // Silver rocks
                case 11949:
                case 11950:
                case 11165:
                case 11186:
                case 11187:
                case 11188:
                case 31074:
                case 31075:
                case 31076:
                case 32444:
                case 32445:
                case 32446:
                case 15579:
                case 15580:
                case 15581:
                    Mining.prospectRock(player, objectX, objectY, "silver");
                    break;

                case 11930: // Coal rocks
                case 11931:
                case 11932:
                case 14850:
                case 14851:
                case 14852:
                case 31068:
                case 31069:
                case 31070:
                case 32426:
                case 32427:
                case 32428:
                    Mining.prospectRock(player, objectX, objectY, "coal");
                    break;

                case 11945: // Mithril rocks
                case 11946:
                case 11947:
                case 11942:
                case 11943:
                case 11944:
                case 14853:
                case 14854:
                case 14855:
                case 31086:
                case 31087:
                case 31088:
                case 32438:
                case 32439:
                case 32440:
                    Mining.prospectRock(player, objectX, objectY, "mithril");
                    break;

                case 11954: // Iron rocks
                case 11955:
                case 11956:
                case 14856:
                case 14857:
                case 14858:
                case 31071:
                case 31072:
                case 31073:
                case 32441:
                case 32442:
                case 32443:
                    Mining.prospectRock(player, objectX, objectY, "iron");
                    break;

                case 14859: // Rune rocks
                case 14860:
                case 14861:
                    Mining.prospectRock(player, objectX, objectY, "runite");
                    break;

                case 11951: // Gold rocks
                case 11952:
                case 11953:
                case 11183:
                case 11184:
                case 11185:
                case 31065:
                case 31066:
                case 31067:
                case 32432:
                case 32433:
                case 32434:
                case 15576:
                case 15577:
                case 15578:
                    Mining.prospectRock(player, objectX, objectY, "gold");
                    break;

                case 11963: // Adamant rocks
                case 11964:
                case 11965:
                case 11939:
                case 11940:
                case 11941:
                case 14862:
                case 14863:
                case 14864:
                case 31083:
                case 31084:
                case 31085:
                case 32435:
                case 32436:
                case 32437:
                    Mining.prospectRock(player, objectX, objectY, "adamantite");
                    break;

                case 11552: // Empty rocks
                case 11553:
                case 11554:
                case 11555:
                case 11556:
                case 31059:
                case 31060:
                case 31061:
                case 14832:
                case 14833:
                case 14834:
                case 33400:
                case 33401:
                case 33402:
                case 15582:
                case 15583:
                case 15584:
                    Mining.displayEmptyRockMessage(player, new Location(objectX, objectY, player.getLocation().getZ()));
                    break;

                case 2491: // Rune essence
                    Mining.prospectRock(player, objectX, objectY, "Rune essence");
                    break;

                case 27663: // Duel arena bank chest.
                case 2213:  // Catherby bank booth.
                case 11402: // Varrock bank booth.
                case 11758: // Falador bank booth.
                case 36786: // Lumbridge bank booth.
                case 35647: // Al-Kharid bank booth.
                case 25808: // Seers bank booth.
                case 34752: // Ardougne bank booth.
                case 26972: // Edgeville bank booth.
                case 29085: // Ooglog bank booth.
                    player.getBank().openBank(false, objectX, objectY);
                    break;
            }
        }
Ejemplo n.º 7
0
 private void handleRightClickOne(Player player, Packet packet)
 {
     int childId = packet.readLEShort();
     int interfaceId = packet.readLEShort();
     int item = packet.readLEShortA();
     int slot = packet.readLEShortA();
     if (slot > 28 || slot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return;
     }
     SkillHandler.resetAllSkills(player);
     if (player.getInventory().getItemInSlot(slot) == item)
     {
         player.getPackets().closeInterfaces();
         if (interfaceId == 149 && childId == 0)
         {
             if (Herblore.emptyPotion(player, player.getInventory().getItemInSlot(slot), slot))
             {
                 return;
             }
             else if (JewelleryTeleport.useJewellery(player, player.getInventory().getItemInSlot(slot), slot, false))
             {
                 return;
             }
         }
     }
 }
Ejemplo n.º 8
0
 private void handleItemOnItem(Player player, Packet packet)
 {
     int itemSlot = packet.readUShort();
     int unused = packet.readInt();
     int withSlot = packet.readLEShort();
     int unused2 = packet.readInt();
     int itemUsed = packet.readLEShortA();
     int usedWith = packet.readLEShortA();
     if (itemSlot > 28 || itemSlot < 0 || withSlot > 28 || withSlot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return;
     }
     SkillHandler.resetAllSkills(player);
     player.getPackets().closeInterfaces();
     if (player.getInventory().getSlot(itemSlot).getItemId() == itemUsed && player.getInventory().getSlot(withSlot).getItemId() == usedWith)
     {
         if (Fletching.isFletching(player, itemUsed, usedWith))
         {
             return;
         }
         else if (Herblore.doingHerblore(player, itemUsed, usedWith))
         {
             return;
         }
         else if (Herblore.mixDoses(player, itemUsed, usedWith, itemSlot, withSlot))
         {
             return;
         }
         else if (Crafting.wantsToCraft(player, itemUsed, usedWith))
         {
             return;
         }
         else if (Firemaking.isFiremaking(player, itemUsed, usedWith, itemSlot, withSlot))
         {
             return;
         }
         else if (Farming.plantSapling(player, itemUsed, usedWith))
         {
             return;
         }
         else
         {
             player.getPackets().sendMessage("Nothing interesting happens.");
         }
     }
 }
Ejemplo n.º 9
0
 private void handlePickupItem(Player player, Packet packet)
 {
     int x = packet.readLEShort();
     int id = packet.readUShort();
     int y = packet.readLEShortA();
     Location l = new Location(x, y, player.getLocation().getZ());
     SkillHandler.resetAllSkills(player);
     if (x < 1000 || y < 1000 | id < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return;
     }
     player.getPackets().closeInterfaces();
     if (player.getLocation().Equals(l))
     {
         Server.getGroundItems().pickupItem(player, id, player.getLocation());
         return;
     }
     CoordinateEvent pickupItemCoordinateEvent = new CoordinateEvent(player, l);
     pickupItemCoordinateEvent.setAction(() =>
     {
         Server.getGroundItems().pickupItem(player, id, player.getLocation());
     });
     Server.registerCoordinateEvent(pickupItemCoordinateEvent);
 }
Ejemplo n.º 10
0
        private void handleInvenClickItem(Player player, Packet packet)
        {
            int slot = packet.readLEShortA();
            int item = packet.readShortA();
            int childId = packet.readLEShort();
            int interfaceId = packet.readLEShort();
            if (slot > 28 || slot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
            {
                return;
            }
            SkillHandler.resetAllSkills(player);
            if (player.getInventory().getItemInSlot(slot) == item)
            {
                player.getPackets().closeInterfaces();
                if (Consumables.isEating(player, player.getInventory().getItemInSlot(slot), slot))
                    return;
                else if (Herblore.idHerb(player, player.getInventory().getItemInSlot(slot)))
                    return;
                else if (RuneCraft.fillPouch(player, (RuneCraftData.POUCHES)player.getInventory().getItemInSlot(slot)))
                    return;
                else if (Prayer.wantToBury(player, player.getInventory().getItemInSlot(slot), slot))
                    return;
                else if (Teleport.useTeletab(player, player.getInventory().getItemInSlot(slot), slot))
                    return;
                else if (FarmingAmulet.showOptions(player, player.getInventory().getItemInSlot(slot)))
                    return;

                switch (item)
                {
                    case 4155: // Slayer gem
                        Slayer.doDialogue(player, 1051);
                        break;

                    case 6: // Dwarf multicannon
                        if (player.getCannon() != null)
                        {
                            player.getPackets().sendMessage("You already have a cannon set up!");
                            break;
                        }
                        player.setCannon(new DwarfCannon(player));
                        break;

                    case 5073: // Nest with seeds.
                    case 5074: // Nest with jewellery.
                        Woodcutting.randomNestItem(player, item);
                        break;

                    case 952: // Spade
                        player.setLastAnimation(new Animation(830));
                        if (Barrows.enterCrypt(player))
                        {
                            player.getPackets().sendMessage("You've broken into a crypt!");
                            break;
                        }
                        player.getPackets().sendMessage("You find nothing.");
                        break;
                }
            }
        }
Ejemplo n.º 11
0
        private void handleItemOnGroundItem(Player player, Packet packet)
        {
            int objectX = packet.readLEShortA();
            int itemSlot = packet.readLEShort();
            int itemIdInInventory = packet.readLEShort();
            int itemIdOnGround = packet.readLEShort();
            int objectY = packet.readLEShortA();
            int interfaceId = packet.readLEShort();
            int child = packet.readUShort();

            if (itemSlot > 28 || itemSlot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
                return;

            if (Firemaking.isFiremaking(player, itemIdInInventory, itemIdOnGround, itemSlot, -1))
                return;
            else
                player.getPackets().sendMessage("Nothing interesting happens.");
        }
Ejemplo n.º 12
0
 private void handleExamineItem(Player player, Packet packet)
 {
     int item = packet.readLEShortA();
     if (item < 0 || item > Constants.MAX_ITEMS)
     {
         return;
     }
     string examine = ItemData.forId(item).getExamine();
     player.getPackets().sendMessage(examine);
 }
Ejemplo n.º 13
0
        private void handleAttackPlayer(Player player, Packet packet)
        {
            int index = packet.readLEShortA();
            if (index < 0 || index >= Constants.MAX_PLAYERS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
            {
                return;
            }
            SkillHandler.resetAllSkills(player);
            Player p2 = Server.getPlayerList()[index];
            if (p2 == null)
                return;

            player.setFaceLocation(p2.getLocation());
            player.getPackets().closeInterfaces();
            if (Location.atDuelArena(player.getLocation()))
            {
                if (player.getDuel() != null)
                {
                    if (player.getDuel().getStatus() < 4)
                    {
                        player.getDuel().declineDuel();
                        return;
                    }
                    else if (player.getDuel().getStatus() == 5 && player.getDuel().getPlayer2().Equals(p2))
                    {
                        player.getPackets().sendMessage("The duel has not yet started!");
                        return;
                    }
                    else if ((player.getDuel().getStatus() == 5 || player.getDuel().getStatus() == 6) && !player.getDuel().getPlayer2().Equals(p2))
                    {
                        return;
                    }
                    else if (player.getDuel().getStatus() == 6)
                    {
                        Combat.newAttack(player, p2);
                        return;
                    }
                }
                if (!player.getLocation().withinDistance(p2.getLocation(), 1))
                {
                    int x = p2.getLocation().getX();
                    int y = p2.getLocation().getY();
                    AreaEvent attackAreaEvent = new AreaEvent(player, x - 1, y - 1, x + 1, y + 1);
                    attackAreaEvent.setAction(() =>
                    {
                        player.getWalkingQueue().resetWalkingQueue();
                        player.getPackets().clearMapFlag();
                        if (p2.getGESession() != null || (p2.getDuel() != null && !p2.getDuel().getPlayer2().Equals(player)) || p2.getTrade() != null || p2.getShopSession() != null || p2.getBank().isBanking())
                        {
                            player.getPackets().sendMessage("That player is busy at the moment.");
                            return;
                        }
                        if (p2.wantsToDuel(player))
                        {
                            p2.setFaceLocation(player.getLocation());
                            player.getPackets().closeInterfaces();
                            p2.getPackets().closeInterfaces();
                            player.setDuelSession(new DuelSession(player, p2));
                            p2.setDuelSession(new DuelSession(p2, player));
                            return;
                        }
                        player.setFaceLocation(p2.getLocation());
                        p2.getPackets().sendMessage(player.getLoginDetails().getUsername() + ":duelstake:");
                        player.getPackets().sendMessage("Sending duel request...");
                        player.newDuelRequest(p2);
                    });
                    Server.registerCoordinateEvent(attackAreaEvent);
                    return;
                }
                if (p2.getGESession() != null || (p2.getDuel() != null && !p2.getDuel().getPlayer2().Equals(player)) || p2.getTrade() != null || p2.getShopSession() != null || p2.getBank().isBanking())
                {
                    player.getPackets().sendMessage("That player is busy at the moment.");
                    return;
                }
                if (p2.wantsToDuel(player))
                {
                    player.getPackets().closeInterfaces();
                    p2.getPackets().closeInterfaces();
                    p2.setFaceLocation(player.getLocation());
                    player.setDuelSession(new DuelSession(player, p2));
                    p2.setDuelSession(new DuelSession(p2, player));
                    return;
                }
                player.newDuelRequest(p2);
                p2.getPackets().sendMessage(player.getLoginDetails().getUsername() + ":duelstake:");
                player.getPackets().sendMessage("Sending duel request...");
                return;
            }
            Combat.newAttack(player, p2);
        }
Ejemplo n.º 14
0
 private void handleTradePlayer(Player player, Packet packet)
 {
     int index = packet.readLEShortA();
     if (index < 0 || index >= Constants.MAX_PLAYERS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return;
     }
     SkillHandler.resetAllSkills(player);
     Player p2 = Server.getPlayerList()[index];
     if (p2 == null)
     {
         return;
     }
     player.setFaceLocation(p2.getLocation());
     if (player.getTrade() != null)
     {
         player.getTrade().decline();
         return;
     }
     player.getPackets().closeInterfaces();
     if (!player.getLocation().withinDistance(p2.getLocation(), 1))
     {
         int x = p2.getLocation().getX();
         int y = p2.getLocation().getY();
         AreaEvent tradePlayerAreaEvent = new AreaEvent(player, x - 1, y - 1, x + 1, y + 1);
         tradePlayerAreaEvent.setAction(() =>
         {
             player.getWalkingQueue().resetWalkingQueue();
             player.getPackets().clearMapFlag();
             if (p2.getGESession() != null || p2.getTrade() != null || p2.getDuel() != null || p2.getShopSession() != null || p2.getBank().isBanking())
             {
                 player.getPackets().sendMessage("That player is busy at the moment.");
                 return;
             }
             if (p2.wantsToTrade(player))
             {
                 player.getPackets().closeInterfaces();
                 p2.getPackets().closeInterfaces();
                 p2.setFaceLocation(player.getLocation());
                 player.setTrade(new TradeSession(player, p2));
                 p2.setTrade(new TradeSession(p2, player));
                 return;
             }
             player.setFaceLocation(p2.getLocation());
             p2.getPackets().sendMessage(player.getLoginDetails().getUsername() + ":tradereq:");
             player.getPackets().sendMessage("Sending trade offer...");
             player.newTradeRequest(p2);
         });
         Server.registerCoordinateEvent(tradePlayerAreaEvent);
         return;
     }
     if (p2.getGESession() != null || p2.getTrade() != null || p2.getDuel() != null || p2.getShopSession() != null || p2.getBank().isBanking())
     {
         player.getPackets().sendMessage("That player is busy at the moment.");
         return;
     }
     if (p2.wantsToTrade(player))
     {
         player.getPackets().closeInterfaces();
         p2.getPackets().closeInterfaces();
         p2.setFaceLocation(player.getLocation());
         player.setTrade(new TradeSession(player, p2));
         p2.setTrade(new TradeSession(p2, player));
         return;
     }
     player.newTradeRequest(p2);
     p2.getPackets().sendMessage(player.getLoginDetails().getUsername() + ":tradereq:");
     player.getPackets().sendMessage("Sending trade offer...");
 }
Ejemplo n.º 15
0
 private void handleMagicOnPlayer(Player player, Packet packet)
 {
     int junk = packet.readShortA();
     int id = packet.readLEShort();
     int interfaceId = packet.readLEShort();
     int index = packet.readLEShortA();
     if (index < 0 || index >= Constants.MAX_PLAYERS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return;
     }
     SkillHandler.resetAllSkills(player);
     Player p2 = Server.getPlayerList()[index];
     if (p2 == null)
     {
         return;
     }
     player.getPackets().closeInterfaces();
     player.setTarget(p2);
     MagicCombat.newMagicAttack(player, p2, id, interfaceId == 193);
 }
Ejemplo n.º 16
0
 private void handleFollowPlayer(Player player, Packet packet)
 {
     int index = packet.readLEShortA();
     if (index < 0 || index >= Constants.MAX_PLAYERS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return;
     }
     SkillHandler.resetAllSkills(player);
     Player p2 = Server.getPlayerList()[index];
     if (p2 == null)
     {
         return;
     }
     player.getFollow().setFollowing(p2);
 }