public void doItemDrop(L2Character lastAttacker) { // Manage drop of Special Events created by GM for a defined period doEventDrop(lastAttacker); // Create a table containing all possible drops of this L2Attackable from L2NpcTemplate List drops = new FastList(); drops.addAll(getTemplate().getDropData()); if (Config.DEBUG) _log.finer("this npc has "+drops.size()+" drops defined"); // Add Quest drops to the table containing all possible drops of this L2Attackable if (lastAttacker instanceof L2PcInstance) { L2PcInstance player = (L2PcInstance)lastAttacker; player.fillQuestDrops(this, drops); } // If DeepBlue Drop Rule is enabled, calculate the drop modifiers int deepBlueDropAdena = 1; // Factor to divide the drop chance for Adenas drops int deepBlueDropOther = 1; // Factor to divide the drop chance for Others drops int levelModifier = 0; // level modifier in %'s (will be subtracted from drop chance) if (Config.DEEPBLUE_DROP_RULES) { if (lastAttacker instanceof L2PcInstance) { L2PcInstance player = (L2PcInstance)lastAttacker; // According to official data (Prima), // deep blue mobs are 9 or more levels below players if ((player.getLevel() - 9) >= getLevel()) { // We should multiply by the server's drop rate, // so we always get a low chance of drop for deep blue mobs. // NOTE: This is valid only for adena drops! Others drops will still obey server's rate deepBlueDropAdena = (3 * (int)Config.RATE_DROP_ITEMS); deepBlueDropOther = 3; levelModifier = ((player.getLevel() - (getLevel()+8)) * 9); } } } // Go Throw all possible drops (base + quests) of this L2Attackable for (L2DropData drop : drops) { // If it's a sweep drop, it will not appear on the ground if (drop.isSweep()) continue; // Roll the dice.. between 0 and MAX_CHANCE (=1000000) int roll = L2Character.getRnd().nextInt(L2DropData.MAX_CHANCE); // Get default drop chance float dropChance = drop.getChance()*Config.RATE_DROP_ITEMS; // Check our rates... Is it an Adena drop or is it any other drop?... int deepBlueDrop = 1; if (drop.getItemId() == 57) { deepBlueDrop = deepBlueDropAdena; } else { deepBlueDrop = deepBlueDropOther; } // Check if we should apply our maths so deep blue mobs will not drop that easy if (Config.DEEPBLUE_DROP_RULES) { dropChance = ((drop.getChance() - ((drop.getChance() * levelModifier)/100)) * (Config.RATE_DROP_ITEMS) / deepBlueDrop); } // Round drop chance dropChance = Math.round(dropChance); // Set our limits for chance of drop if (dropChance < 1) dropChance = 1; if (dropChance > L2DropData.MAX_CHANCE) dropChance = L2DropData.MAX_CHANCE; // Check if the Item must be dropped if (roll < dropChance) { // Create the L2ItemInstance corresponding to the Item Identifier and add it to _allObjects of L2world L2ItemInstance dropit = ItemTable.getInstance().createItem(drop.getItemId()); // Get min and max Item quantity that can be dropped in one time int min = drop.getMinDrop(); int max = drop.getMaxDrop(); int itemCount = 0; // Get the item quantity dropped if (min < max) { // getRnd().nextInt(n) requires n > 0 // Get RND between 0 and (max-min) then add min to get range between min and max... itemCount = L2Character.getRnd().nextInt(max - min) + min; } else { itemCount = 1; } // Calculate the Adena reward with the RATE_DROP_ADENA if (dropit.getItemId() == 57) { itemCount *= Config.RATE_DROP_ADENA; } if (itemCount != 0) { // Set the Item quantity dropped dropit.setCount(itemCount); if (Config.DEBUG) _log.fine("Item id to drop: "+drop.getItemId()+" amount: "+dropit.getCount()); if(this instanceof L2RaidBossInstance) { SystemMessage sm = new SystemMessage(SystemMessage.S1_DIED_DROPPED_S3_S2); sm.addString(getName()); sm.addNumber(dropit.getCount()); sm.addItemName(drop.getItemId()); broadcastPacket(sm); } // Check if the autoLoot mode is actif if (Config.AUTO_LOOT && lastAttacker instanceof L2PcInstance) { // Give this or these Item(s) to the L2PcInstance that has killed the L2Attackable ((L2PcInstance)lastAttacker).doAutoLoot(dropit); } else if (drop.isQuestDrop()) { // Give this or these Quest Item(s) to the L2PcInstance that has killed the L2Attackable ((L2PcInstance)lastAttacker).doAutoLoot(dropit); } else { // Get the current Z position of the L2Character that has killed the L2Attackable int z = getZ(); if (lastAttacker.getZ()>z) z=lastAttacker.getZ(); z = z + 200; // Init the dropped L2ItemInstance and add it in the world as a visible object at the position where mob was last dropit.dropMe(this, getX(), getY(), z); if (Config.AUTODESTROY_ITEM_AFTER > 0) ItemsAutoDestroy.getInstance().addItem(dropit); } } else { _log.fine("Roll produced 0 items to drop... Cancelling"); } } } }