Esempio n. 1
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;
                }
            }
        }
Esempio n. 2
0
        private void handleThirdClickNPC(Player player, Packet packet)
        {
            int npcIndex = packet.readShortA();

            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;
            }
            Console.WriteLine("Third click NPC " + npc.getId());
            SkillHandler.resetAllSkills(player);
            if (Thieving.wantToThieveNpc(player, npc))
            {
                return;
            }
            else if (Fishing.wantToFish(player, npc, true))
            {
                return;
            }
            else if (AgilityArena.dialogue(player, npc, true))
            {
                return;
            }
            else if (TzHaar.interactTzhaarNPC(player, npc, 2))
            {
                return;
            }
            else if (WarriorGuild.talkToWarriorGuildNPC(player, npc, 2))
            {
                return;
            }
            switch (npc.getId())
            {
            case 553:     // Aubury
                HomeArea.interactWithAubury(player, npc, 2);
                break;

            case 519:     // Bob
                BrokenBarrows.talkToBob(player, npc, -1, 2);
                break;
            }
        }
Esempio n. 3
0
 public static void doDialogue(Player p, int status)
 {
     if (status > 0 && status < 76)
     {
         AgilityArena.doDialogue(p, status);
     }
     else if (status > 76 && status < 100)
     {
         WarriorGuild.talkToKamfreena(p, status);
     }
     else if (status > 100 && status < 125)
     {
         BrokenBarrows.showBobDialogue(p, status);
     }
     else if (status > 155 && status < 200)
     {
         HomeArea.showAliDialogue(p, status);
     }
     else if (status > 200 && status < 235)
     {
         AlKharid.showAliDialogue(p, status);
     }
     else if (status > 239 && status < 270)
     {
         BoatOptions.showBentleyDialogue(p, status);
     }
     else if (status > 279 && status < 300)
     {
         BoatOptions.showCanifisSailorDialogue(p, status);
     }
     else if (status > 299 && status < 330)
     {
         BoatOptions.showJarvaldDialogue(p, status);
     }
     else if (status > 339 && status < 360)
     {
         BoatOptions.showSquireDialogue(p, status);
     }
     else if (status > 370 && status < 400)
     {
         BoatOptions.showArnorDialogue(p, status);
     }
     else if (status > 410 && status < 430)
     {
         BoatOptions.showCaptainBarnabyDialogue(p, status);
     }
 }
Esempio n. 4
0
        public override void dropLoot()
        {
            Entity whoKiller = this.getKiller();

            /*
             * Replaced if killer is [Npc] to [this] (this player).
             * Also I couldn't do it in 1 line of coding because
             * this.getKiller() may change while being casted to Player
             * even if it was Npc (then it would be based on luck timing).
             */
            Player killer = whoKiller is Npc ? this : (Player)(whoKiller);

            int amountToKeep = isSkulled() ? 0 : 3;

            if (prayers.isProtectItem())
            {
                amountToKeep = isSkulled() ? 1 : 4;
            }

            int[]  protectedItems = new int[amountToKeep];
            bool[] saved          = new bool[amountToKeep];
            if (protectedItems.Length > 0)
            {
                protectedItems[0] = ProtectedItems.getProtectedItem1(this)[0];
            }
            if (protectedItems.Length > 1)
            {
                protectedItems[1] = ProtectedItems.getProtectedItem2(this)[0];
            }
            if (protectedItems.Length > 2)
            {
                protectedItems[2] = ProtectedItems.getProtectedItem3(this)[0];
            }
            if (protectedItems.Length > 3)
            {
                protectedItems[3] = ProtectedItems.getProtectedItem4(this)[0];
            }
            bool save = false;

            foreach (Item item in getInventory().getItems())
            {
                save = false;

                if (item.getItemId() > 0)
                {
                    for (int j = 0; j < protectedItems.Length; j++)
                    {
                        if (amountToKeep > 0 && protectedItems[j] > 0)
                        {
                            if (!saved[j] && !save)
                            {
                                if (item.getItemId() == protectedItems[j] && item.getItemAmount() == 1)
                                {
                                    saved[j] = true;
                                    save     = true;
                                }
                                if (item.getItemId() == protectedItems[j] && item.getItemAmount() > 1)
                                {
                                    item.setItemAmount(item.getItemAmount() - 1);
                                    saved[j] = true;
                                    save     = true;
                                }
                            }
                        }
                    }
                    if (!save)
                    {
                        int itemId = item.getItemId();
                        //If inventory items have to break on dropped death, this is where they go
                        if (itemId >= 4708 && itemId <= 4759)
                        {
                            itemId = BrokenBarrows.getBrokenId(itemId);
                        }
                        Server.getGroundItems().newEntityDrop(new GroundItem(itemId, item.getItemAmount(), this.getLocation(), item.getDefinition().isPlayerBound() ? this : killer));
                    }
                }
            }
            inventory.clearAll();
            saved = new bool[amountToKeep];
            foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP)))
            {
                if (equip == ItemData.EQUIP.NOTHING)
                {
                    continue;
                }
                save = false;
                Item item = this.getEquipment().getSlot(equip);
                if (item.getItemId() > 0)
                {
                    for (int j = 0; j < protectedItems.Length; j++)
                    {
                        if (amountToKeep > 0 && protectedItems[j] > -1)
                        {
                            if (!saved[j] && !save)
                            {
                                if (item.getItemId() == protectedItems[j] && item.getItemAmount() == 1)
                                {
                                    saved[j] = true;
                                    save     = true;
                                }
                                if (item.getItemId() == protectedItems[j] && item.getItemAmount() > 1)
                                {
                                    item.setItemAmount(item.getItemAmount() - 1);
                                    saved[j] = true;
                                    save     = true;
                                }
                            }
                        }
                    }
                    if (!save)
                    {
                        //If equipped items have to break on dropped death, this is where they go
                        int itemId = item.getItemId();
                        if (itemId >= 4708 && itemId <= 4759)
                        {
                            itemId = BrokenBarrows.getBrokenId(itemId);
                        }
                        Server.getGroundItems().newEntityDrop(new GroundItem(itemId, item.getItemAmount(), this.getLocation(), item.getDefinition().isPlayerBound() ? this : killer));
                    }
                }
            }
            equipment.clearAll();
            GroundItem bones = new GroundItem(526, 1, this.getLocation(), killer);

            Server.getGroundItems().newEntityDrop(bones);
            inventory.setProtectedItems(protectedItems);
        }
Esempio n. 5
0
        private void handleSecondClickNPC(Player player, Packet packet)
        {
            int npcIndex = packet.readLEShort();

            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;
            }
            Console.WriteLine("Second click NPC " + npc.getId());
            SkillHandler.resetAllSkills(player);
            if (Fishing.wantToFish(player, npc, false))
            {
                return;
            }
            else if (Slayer.talkToMaster(player, npc))
            {
                return;
            }
            else if (AgilityArena.dialogue(player, npc, false))
            {
                return;
            }
            else if (TzHaar.interactTzhaarNPC(player, npc, 1))
            {
                return;
            }
            else if (WarriorGuild.talkToWarriorGuildNPC(player, npc, 1))
            {
                return;
            }
            else if (BoatOptions.interactWithBoatNPC(player, npc))
            {
                return;
            }
            switch (npc.getId())
            {
            case 519:     // Bob
                BrokenBarrows.talkToBob(player, npc, -1, 1);
                break;

            case 553:     // Aubury
                HomeArea.interactWithAubury(player, npc, 1);
                break;

            case 1862: // Ali morisanne
                if (npc.getLocation().inArea(2319, 3177, 2321, 3182))
                {      // Home Ali
                    HomeArea.interactWithAliMorissaae(player, npc);
                    break;
                }
                else if (npc.getLocation().inArea(3311, 3198, 3316, 3199))
                {     // Al Kharid Ali
                    AlKharid.interactWithAliMorissaae(player, npc);
                    break;
                }
                break;
            }
        }
Esempio n. 6
0
        public override void dropLoot()
        {
            Entity killer = this.getKiller();
            Player klr    = killer is Npc ? null : (Player)killer;

            if (klr == null)
            {
                klr = this;
            }
            int amountToKeep = isSkulled() ? 0 : 3;

            if (prayers.isProtectItem())
            {
                amountToKeep = isSkulled() ? 1 : 4;
            }

            /*
             * Meh wanted to make a much more effient system.
             * //price of item, [item, object[]=(inventory/euqipment)]
             * //Inventory Items
             * SortedDictionary<int, object[]> valueSortedItems = new SortedDictionary<int, object[]>();
             * Item item;
             * int price = 0;
             * for(int i = 0; i < Inventory.MAX_INVENTORY_SLOTS; i++) {
             *  item = inventory.getSlot(i);
             *  if(item.getItemId() != -1 && item.getItemAmount() > 0) { //is real item.
             *      //price of item stacked
             *      price = item.getItemAmount() * item.getDefinition().getPrice().getMaximumPrice();
             *      valueSortedItems.Add(price, new object[] {item, 0});
             *  }
             * }
             * //Equipment Items
             * for(int i = 0; i < 14; i++) {
             *  item = equipment.getSlot(i);
             *  if(item.getItemId() != -1 && item.getItemAmount() > 0) { //is real item.
             *      //price of item stacked
             *      price = item.getItemAmount() * item.getDefinition().getPrice().getMaximumPrice();
             *      valueSortedItems.Add(price, new object[] {item, 1});
             *  }
             * }*/

            int[]  protectedItems = new int[amountToKeep];
            bool[] saved          = new bool[amountToKeep];
            if (protectedItems.Length > 0)
            {
                protectedItems[0] = ProtectedItems.getProtectedItem1(this)[0];
            }
            if (protectedItems.Length > 1)
            {
                protectedItems[1] = ProtectedItems.getProtectedItem2(this)[0];
            }
            if (protectedItems.Length > 2)
            {
                protectedItems[2] = ProtectedItems.getProtectedItem3(this)[0];
            }
            if (protectedItems.Length > 3)
            {
                protectedItems[3] = ProtectedItems.getProtectedItem4(this)[0];
            }
            bool save = false;

            for (int i = 0; i < 28; i++)
            {
                save = false;
                Item item = inventory.getSlot(i);
                if (item.getItemId() > 0)
                {
                    for (int j = 0; j < protectedItems.Length; j++)
                    {
                        if (amountToKeep > 0 && protectedItems[j] > 0)
                        {
                            if (!saved[j] && !save)
                            {
                                if (item.getItemId() == protectedItems[j] && item.getItemAmount() == 1)
                                {
                                    saved[j] = true;
                                    save     = true;
                                }
                                if (item.getItemId() == protectedItems[j] && item.getItemAmount() > 1)
                                {
                                    item.setItemAmount(item.getItemAmount() - 1);
                                    saved[j] = true;
                                    save     = true;
                                }
                            }
                        }
                    }
                    if (!save)
                    {
                        int itemId = item.getItemId();
                        if (itemId >= 4708 && itemId <= 4759)
                        {
                            itemId = BrokenBarrows.getBrokenId(itemId);
                        }
                        GroundItem gi = new GroundItem(itemId, item.getItemAmount(), this.getLocation(), item.getDefinition().isPlayerBound() ? this : klr);
                        Server.getGroundItems().newEntityDrop(gi);
                    }
                }
            }
            inventory.clearAll();
            saved = new bool[amountToKeep];
            foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP)))
            {
                if (equip == ItemData.EQUIP.NOTHING)
                {
                    continue;
                }
                save = false;
                Item item = this.getEquipment().getSlot(equip);
                if (item.getItemId() > 0)
                {
                    for (int j = 0; j < protectedItems.Length; j++)
                    {
                        if (amountToKeep > 0 && protectedItems[j] > -1)
                        {
                            if (!saved[j] && !save)
                            {
                                if (item.getItemId() == protectedItems[j] && item.getItemAmount() == 1)
                                {
                                    saved[j] = true;
                                    save     = true;
                                }
                                if (item.getItemId() == protectedItems[j] && item.getItemAmount() > 1)
                                {
                                    item.setItemAmount(item.getItemAmount() - 1);
                                    saved[j] = true;
                                    save     = true;
                                }
                            }
                        }
                    }
                    if (!save)
                    {
                        int itemId = item.getItemId();
                        if (itemId >= 4708 && itemId <= 4759)
                        {
                            itemId = BrokenBarrows.getBrokenId(itemId);
                        }
                        GroundItem gi = new GroundItem(itemId, item.getItemAmount(), this.getLocation(), item.getDefinition().isPlayerBound() ? this : klr);
                        Server.getGroundItems().newEntityDrop(gi);
                    }
                }
            }
            equipment.clearAll();
            GroundItem bones = new GroundItem(526, 1, this.getLocation(), klr);

            Server.getGroundItems().newEntityDrop(bones);
            inventory.setProtectedItems(protectedItems);
        }