コード例 #1
0
ファイル: ProtectedItems.cs プロジェクト: Krill156/SharpEMU
 public static int[] getProtectedItem1(Player p)
 {
     int[] protectedItem = new int[2];
     protectedItem[0] = -1;
     for (int i = 0; i < 28; i++) {
         if(p.getInventory().getSlot(i).itemId == -1) continue;
         int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice();
         if ((price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice()))
         {
             protectedItem[0] = p.getInventory().getSlot(i).getItemId();
             protectedItem[1] = INVENTORY;
         }
     }
     foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) {
         if (equip == ItemData.EQUIP.NOTHING) continue;
         if (p.getEquipment().getSlot(equip).itemId == -1) continue;
         int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice();
         if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
         {
             protectedItem[0] = p.getEquipment().getSlot(equip).getItemId();
             protectedItem[1] = EQUIPMENT;
         }
     }
     return protectedItem;
 }
コード例 #2
0
ファイル: ProtectedItems.cs プロジェクト: Krill156/SharpEMU
 public static int[] getProtectedItem2(Player p)
 {
     int[] protectedItem = new int[2];
     protectedItem[0] = -1;
     int[] protectedItem1 = getProtectedItem1(p);
     bool save;
     for (int i = 0; i < 28; i++) {
         if (p.getInventory().getSlot(i).itemId == -1) continue;
         int amt = p.getInventory().getItemAmount(p.getInventory().getItemInSlot(i));
         int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice();
         if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
         {
             save = true;
             if (protectedItem1[1] == INVENTORY) {
                 if (protectedItem1[0] == p.getInventory().getItemInSlot(i)) {
                     if (amt < 2) {
                         save = false;
                     }
                 }
             }
             if (save) {
                 protectedItem[0] = p.getInventory().getSlot(i).getItemId();
                 protectedItem[1] = INVENTORY;
             }
         }
     }
        foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) {
        if (equip == ItemData.EQUIP.NOTHING) continue;
        if (p.getEquipment().getSlot(equip).itemId == -1) continue;
        int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice();
        int amt = p.getEquipment().getAmountInSlot(equip);
         if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
         {
             save = true;
             if (protectedItem1[1] == EQUIPMENT) {
                 if (protectedItem1[0] == p.getEquipment().getItemInSlot(equip))
                 {
                     if (amt < 2) {
                         save = false;
                     }
                 }
             }
             if (save) {
                 protectedItem[0] = p.getEquipment().getSlot(equip).getItemId();
                 protectedItem[1] = EQUIPMENT;
             }
         }
     }
     return protectedItem;
 }
コード例 #3
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
 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;
             }
         }
     }
 }
コード例 #4
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
        private void handleItemOnObject(Player player, Packet packet)
        {
            int objectX = packet.readShortA();
            int item = packet.readUShort();
            int objectY = packet.readLEShort();
            int slot = packet.readUShort();
            int interfaceId = packet.readLEShort();
            int child = packet.readUShort();
            int objectId = packet.readShortA();
            if (slot > 28 || slot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
                return;
            }
            Console.WriteLine("Item on object = " + objectId + " " + objectX + " " + objectY);
            SkillHandler.resetAllSkills(player);
            player.getPackets().closeInterfaces();
            player.setFaceLocation(new Location(objectX, objectY, player.getLocation().getZ()));
            if (player.getInventory().getItemInSlot(slot) == item) {
                if (Crafting.wantsToCraftOnObject(player, player.getInventory().getItemInSlot(slot), objectId)) {
                    return;
                } else if (Farming.interactWithPatch(player, objectId, objectX, objectY, player.getInventory().getItemInSlot(slot))) {
                    return;
                } else if (WarriorGuild.useAnimator(player, player.getInventory().getItemInSlot(slot), objectId, objectX, objectY)) {
                    return;
                }
                if (player.getInventory().getItemInSlot(slot) == 7936) {
                    if (RuneCraft.wantToRunecraft(player, objectId, objectX, objectY)) {
                        return;
                    }
                    if (RuneCraft.useTalisman(player, objectId, objectX, objectY)) {
                        return;
                    }
                }
                switch(objectId) {
                    case 6: // Cannon:
                        DwarfCannon cannon = player.getCannon();
                        Location l = new Location(objectX, objectY, player.getLocation().getZ());
                        if (cannon == null || (cannon != null & !l.withinDistance(cannon.getLocation(), 2))) {
                            player.getPackets().sendMessage("This isn't your cannon!");
                            break;
                        }
                        cannon.loadCannon();
                        break;

                    case 36781: // Lumbridge fountain.
                    case 24214:	// Fountain in east Varrock.
                    case 24265:	// Varrock main fountain.
                    case 11661:	// Falador waterpump.
                    case 11759:	// Falador south fountain.
                    case 879:	// Camelot fountains.
                    case 29529:	// Sink.
                    case 874:	// Sink.
                        if (FillVial.fillingVial(player, new Location(objectX, objectY, player.getLocation().getZ())) && player.getInventory().getItemInSlot(slot) == 229) {
                            break;
                        }
                        break;

                    case 2728: // Range in Catherby
                        if (Cooking.isCooking(player, player.getInventory().getItemInSlot(slot), false, -1, -1)) {
                            break;
                        }
                        break;

                    case 2732: // Fire
                        if (Cooking.isCooking(player, player.getInventory().getItemInSlot(slot), true, objectX, objectY)) {
                            break;
                        }
                        break;

                    case 36956: // Lumbridge furnace
                    case 11666: // Falador furnace
                        if (Smelting.wantToSmelt(player, player.getInventory().getItemInSlot(slot))) {
                            break;
                        } else if (Crafting.wantsToCraftOnObject(player, player.getInventory().getItemInSlot(slot), objectId)) {
                            break;
                        }
                        break;

                    case 2783: // Anvil
                        if (Smithing.wantToSmithOnAnvil(player, player.getInventory().getItemInSlot(slot), new Location(objectX, objectY, player.getLocation().getZ()))) {
                            break;
                        }
                        break;

                    default:
                        player.getPackets().sendMessage("Nothing interesting happens.");
                        break;
                }
            }
        }
コード例 #5
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
 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.");
         }
     }
 }
コード例 #6
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
        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;
                }
            }
        }
コード例 #7
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
 private void handleEquipItem(Player player, Packet packet)
 {
     int item = packet.readLEShort();
     int slot = packet.readShortA();
     int interfaceId = packet.readInt();
     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 (RuneCraft.emptyPouch(player, (RuneCraftData.POUCHES)player.getInventory().getItemInSlot(slot))) {
             return;
         }
         player.getEquipment().equipItem(player.getInventory().getItemInSlot(slot), slot);
     }
 }
コード例 #8
0
ファイル: LoginHandler.cs プロジェクト: Krill156/SharpEMU
        public bool savePlayer(Player p)
        {
            if (p == null) return false;
            try
            {
                string username = p.getLoginDetails().getUsername().ToLower();

                /* Character saving code goes here */
                XmlTextWriter writer = new XmlTextWriter(misc.getServerPath() + @"\accounts\" + username + ".xml", null);
                writer.Formatting = Formatting.Indented;
                writer.WriteStartElement("Player");
                    writer.WriteStartElement("Login");
                        writer.WriteElementString("Password", p.getLoginDetails().getPassword());
                        writer.WriteElementString("Rights", p.getRights().ToString());
                        writer.WriteElementString("BankPin", p.getBank().getBankPin());
                    writer.WriteEndElement();

                    writer.WriteStartElement("Position");
                        writer.WriteElementString("X", p.getLocation().getX().ToString());
                        writer.WriteElementString("Y", p.getLocation().getY().ToString());
                        writer.WriteElementString("Z", p.getLocation().getZ().ToString());
                    writer.WriteEndElement();

                    writer.WriteStartElement("Settings");
                        writer.WriteElementString("RunEnergy", p.getRunEnergy().ToString());
                        writer.WriteStartElement("PrivacySettings");
                            writer.WriteElementString("Public", p.getFriends().getPrivacyOption(0).ToString());
                            writer.WriteElementString("Private", p.getFriends().getPrivacyOption(1).ToString());
                            writer.WriteElementString("Trade", p.getFriends().getPrivacyOption(2).ToString());
                        writer.WriteEndElement();
                    writer.WriteEndElement();

                    writer.WriteStartElement("Friends");
                        foreach(long friend in p.getFriends().getFriendsList())
                            writer.WriteElementString("Friend", friend.ToString());
                    writer.WriteEndElement();

                    writer.WriteStartElement("Ignores");
                        foreach (long ignore in p.getFriends().getIgnoresList())
                            writer.WriteElementString("Ignore", ignore.ToString());
                    writer.WriteEndElement();

                    writer.WriteStartElement("Stats");
                        foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL))) {
                             writer.WriteStartElement(skill.ToString()); //skill name.
                                writer.WriteElementString("CurrentLevel", p.getSkills().getCurLevel(skill).ToString());
                                writer.WriteElementString("XP", p.getSkills().getXp(skill).ToString());
                            writer.WriteEndElement();
                        }
                    writer.WriteEndElement();

                    Item item;
                    writer.WriteStartElement("EquipmentItems");
                    foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) {
                        if (equip == ItemData.EQUIP.NOTHING) continue;
                        item = p.getEquipment().getSlot(equip);
                        if (item.getItemId() == -1) continue; //empty slot.

                        writer.WriteStartElement(equip.ToString());
                            writer.WriteElementString("Id", item.getItemId().ToString());
                            writer.WriteElementString("Amount", item.getItemAmount().ToString());
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();

                    writer.WriteStartElement("InventoryItems");
                        for (int i = 0; i < Inventory.MAX_INVENTORY_SLOTS; i++) {
                            item = p.getInventory().getSlot(i);
                            if (item.getItemId() == -1) continue; //empty slot.

                            writer.WriteStartElement("Item");
                                writer.WriteElementString("Slot", i.ToString());
                                writer.WriteElementString("Id", item.getItemId().ToString());
                                writer.WriteElementString("Amount", item.getItemAmount().ToString());
                            writer.WriteEndElement();
                        }
                    writer.WriteEndElement();

                    writer.WriteStartElement("BankItems");
                    for (int i = 0; i < Bank.MAX_BANK_SLOTS; i++)
                    {
                        item = p.getBank().getSlot(i);
                        if (item.getItemId() == -1) continue; //empty slot.

                        writer.WriteStartElement("Item");
                            writer.WriteElementString("Slot", i.ToString());
                            writer.WriteElementString("Id", item.getItemId().ToString());
                            writer.WriteElementString("Amount", item.getItemAmount().ToString());
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                writer.WriteEndElement();
                //Write the XML to file and close the writer
                writer.Close();
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
コード例 #9
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
        private void handleSwapSlot2(Player player, Packet packet)
        {
            int interfaceId = packet.readLEShort();
            int child = packet.readUShort();
            int newSlot = packet.readLEShort();
            int interface2 = packet.readUShort();
            int child2 = packet.readUShort();
            int oldSlot = packet.readLEShort();
            int oldItem = player.getInventory().getItemInSlot(oldSlot);
            int oldAmount = player.getInventory().getAmountInSlot(oldSlot);
            int newItem = player.getInventory().getItemInSlot(newSlot);
            int newAmount = player.getInventory().getAmountInSlot(newSlot);
            if (oldSlot > 28 || oldSlot < 0 || newSlot > 28 || oldSlot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
                return;
            }
            switch (interfaceId) {
                case 621: // Shop.
                case 763: // Bank.
                case 336: // Duel
                    player.getInventory().getSlot(oldSlot).setItemId(newItem);
                    player.getInventory().getSlot(oldSlot).setItemAmount(newAmount);
                    player.getInventory().getSlot(newSlot).setItemId(oldItem);
                    player.getInventory().getSlot(newSlot).setItemAmount(oldAmount);
                    break;

                default:
                    misc.WriteError("UNHANDLED ITEM SWAP 2 : interface = " + interfaceId);
                    break;
            }
            //No need to update the screen since the client does it for us!
            player.getPackets().refreshInventory();
        }
コード例 #10
0
ファイル: Barrows.cs プロジェクト: Krill156/SharpEMU
 protected static void getBarrowReward(Player p)
 {
     int barrowChance = misc.random(BARROWS_CHANCE);
     int killCount = p.getBarrowKillCount();
     if (barrowChance == 0) {
         int reward = BARROW_REWARDS[misc.random(BARROW_REWARDS.Length - 1)];
         p.getInventory().addItemOrGround(reward);
     }
     if (misc.random(20) == 0) {
         p.getInventory().addItemOrGround(1149); // Dragon med helm.
     } else if (misc.random(15) == 0) {
         int halfKey = misc.random(1) == 0 ? 985 : 987;
         p.getInventory().addItemOrGround(halfKey); // Half key.
     }
     if (misc.random(3) == 0 || p.getBarrowTunnel() == KARIL) { // Bolt racks.
         int amount = getAmountOfReward(4740, killCount);
         p.getInventory().addItemOrGround(4740, amount);
     }
     if (misc.random(3) == 0) { // Blood runes
         int amount = getAmountOfReward(565, killCount);
         p.getInventory().addItemOrGround(565, amount);
     }
     if (misc.random(2) == 0) { // Death runes
         int amount = getAmountOfReward(560, killCount);
         p.getInventory().addItemOrGround(560, amount);
     }
     if (misc.random(1) == 0) { // Chaos runes
         int amount = getAmountOfReward(562, killCount);
         p.getInventory().addItemOrGround(562, amount);
     }
     if (misc.random(1) == 0) { // Coins
         int amount = getAmountOfReward(995, killCount);
         p.getInventory().addItemOrGround(995, amount);
     }
     if (misc.random(1) == 0) {
         int amount = getAmountOfReward(558, killCount); // Mind runes.
         p.getInventory().addItemOrGround(558, amount);
     }
 }
コード例 #11
0
ファイル: BrokenBarrows.cs プロジェクト: Krill156/SharpEMU
        public static void showBobDialogue(Player p, int status)
        {
            p.getPackets().softCloseInterfaces();
            int index = -1;
            int newStatus = -1;
            if (p.getTemporaryAttribute("bobsAxesBarrowItem") != null) {
                int item = (int)p.getTemporaryAttribute("bobsAxesBarrowItem");
                index = getIndex(item);
                if (index == -1) {
                    return;
                } else if (item == (int)DATA[index][0]) {
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("That item isn't broken..", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    return;
                } else if (item != (int)DATA[index][1]) {
                    return;
                }
            }
            switch(status) {
                case 101:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("That'll cost you " + ((int)DATA[index][2]).ToString("#,##0") + " gold coins to fix, are you sure?", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 102;
                    break;

                case 102:
                    p.getPackets().modifyText("Yes, I'm sure!", 557, 2);
                    p.getPackets().modifyText("On second thoughts, no thanks.", 557, 3);
                    p.getPackets().sendChatboxInterface2(557);
                    newStatus = 103;
                    break;

                case 103:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Yes, I'm sure!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 104;
                    break;

                case 104:
                    if (!p.getInventory().hasItemAmount(995, (int)DATA[index][2])) {
                        p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                        p.getPackets().modifyText("Bob", 241, 3);
                        p.getPackets().modifyText("You don't have enough money to pay for the repair!", 241, 4);
                        p.getPackets().animateInterface(9827, 241, 2);
                        p.getPackets().sendChatboxInterface2(241);
                        break;
                    } else {
                        if (!p.getInventory().hasItem((int)DATA[index][1])) {
                            p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                            p.getPackets().modifyText("Bob", 241, 3);
                            p.getPackets().modifyText("The item seems to have gone from your inventory.", 241, 4);
                            p.getPackets().animateInterface(9827, 241, 2);
                            p.getPackets().sendChatboxInterface2(241);
                            break;
                        } else if (p.getInventory().deleteItem(995, (int)DATA[index][2])) {
                            p.getInventory().replaceSingleItem((int)DATA[index][1], (int)DATA[index][0]);
                            p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                            p.getPackets().modifyText("Bob", 241, 3);
                            p.getPackets().modifyText("There you go, happy doing business with you!", 241, 4);
                            p.getPackets().animateInterface(9827, 241, 2);
                            p.getPackets().sendChatboxInterface2(241);
                            p.getPackets().sendMessage("You pay Bob his fee and he repairs your " + (string)DATA[index][3] + ".");
                            break;
                        }
                    }
                    break;

                case 105:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("On second thoughts, no thanks.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 106;
                    break;

                case 106:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("Ok, but don't expect my prices to change anytime soon!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 107:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("Hello there " + p.getLoginDetails().getUsername() + ", what can i do for you?", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 108;
                    break;

                case 108:
                    p.getPackets().modifyText("Could you please repair my Barrow item?", 230, 2);
                    p.getPackets().modifyText("I'm interested in buying an axe.", 230, 3);
                    p.getPackets().modifyText("Nevermind.", 230, 4);
                    p.getPackets().sendChatboxInterface2(230);
                    newStatus = 109;
                    break;

                case 109:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Could you please repair my Barrow item?", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 110;
                    break;

                case 110:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("Certainly! Show me the item and i'll see what i can do.", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 111:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("I'm interested in buying an axe.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 112;
                    break;

                case 112:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("What a coincidence! Axes are my speciality!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 113;
                    break;

                case 113:
                    //TODO open bob's shop
                    break;

                case 114:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Nevermind.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    break;
            }
            if (newStatus != -1) {
                p.setTemporaryAttribute("dialogue", newStatus);
            }
        }
コード例 #12
0
        public bool equipItem(int itemID, int slot)
        {
            ItemData.EQUIP equipType = ItemData.getItemType(itemID);
            int            amount    = player.getInventory().getAmountInSlot(slot);
            bool           stackable = ItemData.forId(itemID).isStackable();
            bool           twoHanded = ItemData.isTwoHanded(itemID);

            if (equipType == ItemData.EQUIP.NOTHING)
            {
                player.getPackets().sendMessage("Unable to find an item slot for item : " + itemID + " , please report this to a staff member.");
                return(false);
            }
            if (duelRuleActive(equipType))
            {
                return(true);
            }
            if (twoHanded)
            {
                if (player.getInventory().getTotalFreeSlots() < getNeeded2HSlots())
                {
                    player.getPackets().sendMessage("Not enough space in your inventory.");
                    return(false);
                }
            }
            if (!player.getInventory().deleteItem(itemID, slot, amount))
            {
                return(false);
            }
            if (twoHanded && getItemInSlot(ItemData.EQUIP.SHIELD) != -1)
            {
                if (!unequipItem(ItemData.EQUIP.SHIELD))
                {
                    return(false);
                }
            }
            if (equipType == ItemData.EQUIP.SHIELD)
            {
                if (getItemInSlot(ItemData.EQUIP.WEAPON) != -1)
                {
                    if (ItemData.isTwoHanded(slots[3].getItemId()))
                    {
                        if (!unequipItem(ItemData.EQUIP.WEAPON))
                        {
                            return(false);
                        }
                    }
                }
            }
            int equipSlot = Convert.ToInt32(equipType);

            if (slots[equipSlot].getItemId() != itemID && slots[equipSlot].getItemId() > 0)
            {
                if (!player.getInventory().addItem(slots[equipSlot].getItemId(), slots[equipSlot].getItemAmount(), slot))
                {
                    return(false);
                }
                if (equipType == ItemData.EQUIP.HAT)
                {
                    RuneCraft.toggleRuin(player, slots[equipSlot].getItemId(), false);
                    if (RuneCraft.getTiaraIndex(itemID) != -1)                   // switching from tiara to tiara.
                    {
                        RuneCraft.toggleRuin(player, itemID, true);
                    }
                }
            }
            else if (stackable && slots[equipSlot].getItemId() == itemID)
            {
                amount = slots[equipSlot].getItemAmount() + amount;
            }
            else if (slots[equipSlot].getItemId() != -1)
            {
                player.getInventory().addItem(slots[equipSlot].getItemId(), slots[equipSlot].getItemAmount(), slot);
            }
            slots[equipSlot].setItemId(itemID);
            slots[equipSlot].setItemAmount(amount);
            player.getPackets().refreshEquipment();
            player.getUpdateFlags().setAppearanceUpdateRequired(true);
            if (equipType == ItemData.EQUIP.HAT)
            {
                RuneCraft.toggleRuin(player, itemID, RuneCraft.wearingTiara(player));
            }
            if (equipType == ItemData.EQUIP.WEAPON)
            {
                setWeapon();
                MagicData.cancelAutoCast(player, true);
            }
            refreshBonuses();
            player.setEntityFocus(65535);
            return(true);
        }
コード例 #13
0
 public void newSellOffer(byte slot)
 {
     this.slot = slot;
     p.getPackets().sendConfig(1109, -1);
     p.getPackets().sendConfig(1110, 0);
     p.getPackets().sendConfig(1111, 0);
     p.getPackets().sendConfig(1112, slot);
     p.getPackets().sendConfig(1113, 1);
     p.getPackets().sendConfig(1114, 0);
     p.getPackets().sendConfig(1115, 0);
     p.getPackets().sendConfig(1116, 0);
     p.getPackets().displayInventoryInterface(107);
     p.getPackets().setRightClickOptions(1026, 107 * 65536 + 18, 0, 27);
     object[] opts = new object[] { "", "", "", "", "Offer", -1, 0, 7, 4, 93, 7012370 };
     p.getPackets().sendClientScript(149, opts, "IviiiIsssss");
     p.getPackets().sendItems(-1, 65535, 93, p.getInventory().getItems());
 }
コード例 #14
0
ファイル: MagicData.cs プロジェクト: Krill156/SharpEMU
 public static bool hasRunes(Player p, int[] runes, int[] amount)
 {
     for (int i = 0; i < runes.Length; i++)
     {
         if (checkForStaffs(p, runes[i]) != -1)
         {
             if (!p.getInventory().hasItemAmount(runes[i], amount[i]))
             {
                 return false;
             }
         }
     }
     return true;
 }
コード例 #15
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
        private void handleRightClickTwo(Player player, Packet packet)
        {
            int childId = packet.readLEShort();
            int interfaceId = packet.readLEShort();
            int slot = packet.readLEShort();
            int item = packet.readLEShort();
            if (slot < 0 || slot > 28 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
                return;
            }
            SkillHandler.resetAllSkills(player);
            if (player.getInventory().getItemInSlot(slot) == item) {
                player.getPackets().closeInterfaces();
                switch(player.getInventory().getItemInSlot(slot)) {
                    case 5509: // Small pouch.
                        player.getPackets().sendMessage("There is " + player.getSmallPouchAmount() + " Pure essence in your small pouch. (holds 3).");
                        break;

                    case 5510: // Medium pouch.
                        player.getPackets().sendMessage("There is " + player.getMediumPouchAmount() + " Pure essence in your medium pouch. (holds 6).");
                            break;

                        case 5512: // Large pouch.
                            player.getPackets().sendMessage("There is " + player.getLargePouchAmount() + " Pure essence in your large pouch. (holds 9).");
                            break;

                        case 5514: // Giant pouch.
                            player.getPackets().sendMessage("There is " + player.getGiantPouchAmount() + " Pure essence in your giant pouch. (holds 12).");
                            break;
                }
            }
        }
コード例 #16
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
        private void handleSwapSlot(Player player, Packet packet)
        {
            int oldSlot = packet.readUShort();
            int childId = packet.readLEShort();
            int interfaceId = packet.readLEShort();
            int newSlot = packet.readShortA();
            int swapType = packet.readByteS();
            int oldItem = player.getInventory().getItemInSlot(oldSlot);
            int oldAmount = player.getInventory().getAmountInSlot(oldSlot);
            int newItem = player.getInventory().getItemInSlot(newSlot);
            int newAmount = player.getInventory().getAmountInSlot(newSlot);
            if (oldSlot > 28 || oldSlot < 0 || newSlot > 28 || oldSlot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
                return;
            }
            switch (interfaceId) {
                case 149:
                    if (swapType == 0 && childId == 0) {
                        player.getInventory().getSlot(oldSlot).setItemId(newItem);
                        player.getInventory().getSlot(oldSlot).setItemAmount(newAmount);
                        player.getInventory().getSlot(newSlot).setItemId(oldItem);
                        player.getInventory().getSlot(newSlot).setItemAmount(oldAmount);
                    }
                    break;

                default:
                    misc.WriteError("UNHANDLED ITEM SWAP 1 : interface = " + interfaceId);
                    break;
            }
            //No need to update the screen since the client does it for us!
        }
コード例 #17
0
ファイル: NPCInteract.cs プロジェクト: Krill156/SharpEMU
 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;
         }
     }
 }
コード例 #18
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
 private void handleDropItem(Player player, Packet packet)
 {
     int item = packet.readShortA();
     int slot = packet.readShortA();
     int interfaceId = packet.readLEShort();
     int childId = packet.readUShort();
     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 (ItemData.isPlayerBound(player.getInventory().getItemInSlot(slot))) {
             Item[] items = {new Item(player.getInventory().getItemInSlot(slot), 1)};
             //player.getPackets().sendItems(94, 0, 93, items);
             player.getPackets().modifyText("Are you sure you want to destroy this item?", 94, 3); // Title
             //player.getPackets().modifyText("Yes", 94, 4); // Yes
             //player.getPackets().modifyText("No", 94, 5); // No
             player.getPackets().modifyText("", 94, 10); // Line 1
             player.getPackets().modifyText("If you wish to get another Fire cape, you must", 94, 11); // Line 2
             player.getPackets().modifyText("complete the Fight cave minigame again.", 94, 12); // Line 3
             player.getPackets().modifyText("Fire Cape", 94, 13); // Item name
             player.getPackets().sendChatboxInterface(94);
             return;
         }
         int id = player.getInventory().getItemInSlot(slot);
         int amt = player.getInventory().getAmountInSlot(slot);
         GroundItem i = new GroundItem(id, amt, new Location(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()), player);
         if (player.getInventory().deleteItem(id, slot, amt)) {
             if (!Server.getGroundItems().addToStack(id, amt, player.getLocation(), player)) {
                 Server.getGroundItems().newEntityDrop(i);
             }
         }
     }
 }
コード例 #19
0
ファイル: LoginHandler.cs プロジェクト: Krill156/SharpEMU
        public ReturnCode loadPlayer(Connection connection)
        {
            if (connection == null)
                return ReturnCode.COULD_NOT_COMPLETE;
            LoginDetails loginDetails = connection.getLoginDetails();
            if (loginDetails == null || loginDetails.getUsername() == "" || loginDetails.getLongName() == 0)
                return ReturnCode.INVALID_PASSWORD;//ReturnCode.INVALID_PASSWORD;

            foreach (char c in loginDetails.getUsername().ToCharArray())
            {
                if (!char.IsLetterOrDigit(c) && !char.IsWhiteSpace(c))
                    return ReturnCode.INVALID_PASSWORD;
            }
            Player createdPlayer = new Player(connection);
            connection.setPlayer(createdPlayer); //player finally created.
            createdPlayer.setLoginDetails(loginDetails);

            if (!File.Exists(misc.getServerPath() + @"\accounts\" +  loginDetails.getUsername() + ".xml")) {

                createdPlayer.setRights(2); //all new users admins atm (change later).
                createdPlayer.setLocation(new Location(2323, 3174, 0));
                return ReturnCode.LOGIN_OK; //new user.
            }
            //Yeah reading XML files is a bit h**o.
            try
            {
                int temp;
                long lTemp;
                string username = createdPlayer.getLoginDetails().getUsername().ToLower();
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(misc.getServerPath() + @"\accounts\" + username + ".xml");

                XmlNode xmlNode = xmlDocument.SelectSingleNode("/Player/Login/Password");
                if (xmlNode == null) return ReturnCode.INVALID_PASSWORD; //no password node.
                if (createdPlayer.getLoginDetails().getPassword() != xmlNode.InnerText)
                    return ReturnCode.INVALID_PASSWORD;

                XmlNode loginElement = xmlDocument.SelectSingleNode("/Player/Login");
                if(loginElement != null && loginElement.HasChildNodes) {
                    XmlNodeList childs = loginElement.ChildNodes;

                    foreach (XmlElement element in childs)
                    {
                        switch (element.Name)
                        {
                            case "Rights":
                                if (!int.TryParse(element.InnerText, out temp))
                                    temp = 0;
                                createdPlayer.setRights(temp);
                                break;
                            case "BankPin":
                                if (element.InnerText == "") continue;
                                createdPlayer.getBank().setBankPin(element.InnerText);
                                break;
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Position");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes;
                    Location location = new Location();
                    foreach (XmlElement element in childs)
                    {
                        switch (element.Name)
                        {
                            case "X":
                                if (!int.TryParse(element.InnerText, out temp)) {
                                    createdPlayer.setLocation(Constants.HOME_SPAWN_LOCATION);
                                    break;
                                }
                                location.setX(temp);
                                break;
                            case "Y":
                                if (!int.TryParse(element.InnerText, out temp)) {
                                   createdPlayer.setLocation(Constants.HOME_SPAWN_LOCATION);
                                    break;
                                }
                                location.setY(temp);
                                break;
                            case "Z":
                                if (!int.TryParse(element.InnerText, out temp))
                                    temp = 0;
                                location.setZ(temp);
                                break;
                        }
                    }
                    createdPlayer.setLocation(location);
                    if (Location.atDuelArena(createdPlayer.getLocation()))
                        DuelSession.teleportDuelArenaHome(createdPlayer);
                }

                xmlNode = xmlDocument.SelectSingleNode("/Player/Settings/RunEnergy");
                if (xmlNode == null)
                {
                    temp = 100;
                } else {
                    if (!int.TryParse(xmlNode.InnerText, out temp))
                        temp = 100;
                }
                createdPlayer.setRunEnergyLoad(temp);

                loginElement = xmlDocument.SelectSingleNode("/Player/Settings/PrivacySettings");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes;
                    Friends.STATUS publicStatus = Friends.STATUS.ON, privateStatus = Friends.STATUS.ON, tradeStatus = Friends.STATUS.ON;

                    foreach (XmlElement element in childs)
                    {
                        switch (element.Name)
                        {
                            case "Public":
                                publicStatus = (Friends.STATUS)Enum.Parse(typeof(Friends.STATUS), element.InnerText, true);
                                break;
                            case "Private":
                                privateStatus = (Friends.STATUS)Enum.Parse(typeof(Friends.STATUS), element.InnerText, true);
                                break;
                            case "Trade":
                                tradeStatus = (Friends.STATUS) Enum.Parse(typeof(Friends.STATUS), element.InnerText, true);
                                break;
                        }
                    }
                    createdPlayer.getFriends().setPrivacyOptions(publicStatus, privateStatus, tradeStatus);
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Friends");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes; //number of Friends

                    foreach (XmlElement element in childs)
                    {
                        if(element.Name == "Friend") {
                            if(long.TryParse(element.InnerText, out lTemp))
                                createdPlayer.getFriends().getFriendsList().Add(lTemp);
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Ignores");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNodeList childs = loginElement.ChildNodes; //number of Friends

                    foreach (XmlElement element in childs)
                    {
                        if (element.Name == "Ignore") {
                            if (long.TryParse(element.InnerText, out lTemp))
                                createdPlayer.getFriends().getIgnoresList().Add(lTemp);
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/Stats");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNode skillNode;
                    foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL)))
                    {
                        skillNode = loginElement.SelectSingleNode("/Player/Stats/" + skill.ToString());

                        foreach (XmlElement element in skillNode.ChildNodes)
                        { //CurrentLevel/XP
                            switch (element.Name)
                            {
                                case "CurrentLevel":
                                    if (!int.TryParse(element.InnerText, out temp))
                                    {
                                        if (skill != Skills.SKILL.HITPOINTS)
                                            createdPlayer.getSkills().setCurLevel(skill, 1);
                                        else
                                            createdPlayer.getSkills().setCurLevel(skill, 10);
                                        break;
                                    }
                                    createdPlayer.getSkills().setCurLevel(skill, temp);
                                    break;
                                case "XP":
                                    if (!int.TryParse(element.InnerText, out temp))
                                    {
                                        if (skill != Skills.SKILL.HITPOINTS)
                                            createdPlayer.getSkills().setXp(skill, 0);
                                        else
                                            createdPlayer.getSkills().setXp(skill, 1184);
                                        break;
                                    }
                                    createdPlayer.getSkills().setXp(skill, temp);
                                    break;
                            }
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/EquipmentItems");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    XmlNode skillNode;

                    foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) {
                        if (equip == ItemData.EQUIP.NOTHING) continue;
                        skillNode = loginElement.SelectSingleNode("/Player/EquipmentItems/" + equip.ToString());
                        if (skillNode == null) continue;
                        int id = -1, amount = 0;
                        foreach (XmlElement element in skillNode.ChildNodes)
                        {
                            switch (element.Name)
                            {
                                case "Id":
                                    if (!int.TryParse(element.InnerText, out id))
                                        id = -1;
                                    break;
                                case "Amount":
                                    if (!int.TryParse(element.InnerText, out amount))
                                        amount = 0;
                                    break;
                            }
                        }
                        if (id != -1) {
                            createdPlayer.getEquipment().getEquipment()[(int)equip].setItemId(id);
                            createdPlayer.getEquipment().getEquipment()[(int)equip].setItemAmount(amount);
                        }
                    }
                }

                loginElement = xmlDocument.SelectSingleNode("/Player/InventoryItems");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    int slot = -1, id = 0, amount = 0;
                    foreach (XmlElement itemElement in loginElement.ChildNodes) //each item.
                    {
                        foreach (XmlElement itemDef in itemElement.ChildNodes) //each item.
                        {
                            switch (itemDef.Name)
                            {
                                case "Slot":
                                    if (!int.TryParse(itemDef.InnerText, out slot))
                                        slot = -1;
                                    if (slot < 0 || slot > Inventory.MAX_INVENTORY_SLOTS) slot = -1;
                                    break;
                                case "Id":
                                    if (!int.TryParse(itemDef.InnerText, out id))
                                        slot = -1;
                                    break;
                                case "Amount":
                                    if (!int.TryParse(itemDef.InnerText, out amount))
                                        slot = -1;
                                    break;
                            }
                        }
                        if (slot != -1) {
                            createdPlayer.getInventory().getItems()[slot].setItemId(id);
                            createdPlayer.getInventory().getItems()[slot].setItemAmount(amount);
                        }
                    }

                }

                loginElement = xmlDocument.SelectSingleNode("/Player/BankItems");
                if (loginElement != null && loginElement.HasChildNodes)
                {
                    int slot = -1, id = 0, amount = 0;
                    foreach (XmlElement itemElement in loginElement.ChildNodes) //each item.
                    {
                        foreach (XmlElement itemDef in itemElement.ChildNodes) //each item.
                        {
                            switch (itemDef.Name)
                            {
                                case "Slot":
                                    if (!int.TryParse(itemDef.InnerText, out slot))
                                        slot = -1;
                                    if (slot < 0 || slot > Inventory.MAX_INVENTORY_SLOTS) slot = -1;
                                    break;
                                case "Id":
                                    if (!int.TryParse(itemDef.InnerText, out id))
                                        slot = -1;
                                    break;
                                case "Amount":
                                    if (!int.TryParse(itemDef.InnerText, out amount))
                                        slot = -1;
                                    break;
                            }
                        }
                        if (slot != -1)
                        {
                            createdPlayer.getBank().getBank()[slot].setItemId(id);
                            createdPlayer.getBank().getBank()[slot].setItemAmount(amount);
                        }
                    }
                }

                return ReturnCode.LOGIN_OK; //new user.
            }
            catch (Exception e)
            {
                misc.WriteError(e.Message);
                return ReturnCode.COULD_NOT_COMPLETE;
            }
        }