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); }
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); }