/**
* Calculates quantity of items for specific drop acording to current situation
*
* @param drop The L2DropData count is being calculated for
* @param lastAttacker The L2PcInstance that has killed the L2Attackable
* @param deepBlueDrop Factor to divide the drop chance
* @param levelModifier level modifier in %'s (will be subtracted from drop chance)
*/
private int calculateDropCount(L2DropData drop, L2PcInstance lastAttacker, int levelModifier)
{
// Roll the dice.. between 0 and MAX_CHANCE (=1000000)
int roll = Rnd.get(1, L2DropData.MAX_CHANCE);
float rate = (drop.isSweep()? Config.RATE_DROP_SPOIL:Config.RATE_DROP_ITEMS);
// Get default drop chance
float dropChance = drop.getChance() * rate;
int deepBlueDrop = 1;
if (Config.DEEPBLUE_DROP_RULES)
{
if (levelModifier > 0)
{
// 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
deepBlueDrop = 3;
if (drop.getItemId() == 57) deepBlueDrop *= (int)Config.RATE_DROP_ITEMS;
}
}
// 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)) * rate / deepBlueDrop);
// Round drop chance
dropChance = Math.round(dropChance);
// Set our limits for chance of drop
if (dropChance < 1) dropChance = 1;
if (drop.getItemId() == 57 && dropChance > L2DropData.MAX_CHANCE) dropChance = L2DropData.MAX_CHANCE; // If item is adena, dont drop multiple time
int itemCount = 0;
// Check if the Item must be dropped
while (roll < dropChance)
{
// Get min and max Item quantity that can be dropped in one time
int min = drop.getMinDrop();
int max = drop.getMaxDrop();
// Get the item quantity dropped
if (min < max)
itemCount += Rnd.get(min, max);
else if (min == max)
itemCount += min;
else
itemCount++;
// Calculate the Adena reward with the RATE_DROP_ADENA
if (drop.getItemId() == 57) itemCount *= Config.RATE_DROP_ADENA;
// Prepare for next iteration if dropChance > L2DropData.MAX_CHANCE
dropChance -= L2DropData.MAX_CHANCE;
}
if (itemCount == 0 && Config.DEBUG) _log.fine("Roll produced 0 items to drop...");
return itemCount;
}
/**
* Calculates the level modifier for drop
*
* @param lastAttacker The L2PcInstance that has killed the L2Attackable
*/
private int calculateLevelModifierForDrop(L2PcInstance lastAttacker)
{
if (Config.DEEPBLUE_DROP_RULES)
{
int highestLevel = lastAttacker.getLevel();
// Check to prevent very high level player to nearly kill mob and let low level player do the last hit.
if (getAttackByList() != null && getAttackByList().size() > 0)
{
for (L2Character atkChar: getAttackByList())
if (atkChar != null && atkChar.getLevel() > highestLevel) highestLevel = atkChar.getLevel();
}
// According to official data (Prima), deep blue mobs are 9 or more levels below players
if (highestLevel - 9 >= getLevel()) return ((highestLevel - (getLevel() + 8)) * 9);
}
return 0;
}
private void dropItem(L2PcInstance player, int itemId, int itemCount)
{
L2ItemInstance dropit;
int z;
for (int i = 1; i <= itemCount; i++)
{
dropit = ItemTable.getInstance().createItem(itemId);
// Set the Item quantity dropped if L2ItemInstance is stackable
if (dropit.isStackable())
{
i = itemCount; // Set so loop won't happent again
dropit.setCount(itemCount); // Set item count
}
if (Config.DEBUG) _log.fine("Item id to drop: " + itemId + " 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(itemId);
broadcastPacket(sm);
}
// Check if the autoLoot mode is active
if (Config.AUTO_LOOT)
player.doAutoLoot(dropit); // Give this or these Item(s) to the L2PcInstance that has killed the L2Attackable
else
{
// Get the current Z position of the L2Character that has killed the L2Attackable
z = getZ();
if (player.getZ() > z) z = player.getZ();
// 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 + 200);
// Add drop to auto destroy item task
if (Config.AUTODESTROY_ITEM_AFTER > 0) ItemsAutoDestroy.getInstance().addItem(dropit);
}
}
}
/**
* Manage Sweep drops of L2Attackable.
*
* Actions :
*