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); }
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); } } } }
public static void createGroundArrow(Entity killer, Entity target, int arrow) { if (misc.random(1) == 1) { return; } GroundItem i = new GroundItem(arrow, 1, target.getLocation(), ((Player)killer)); if (Server.getGroundItems().addToStack(arrow, 1, target.getLocation(), ((Player)killer))) { return; } else { Server.getGroundItems().newEntityDrop(i); } }