L2JMobius

CT0 Stackable item drop

dramaa · 1 · 1108

Online dramaa

  • Elder
  • ****
    • Posts: 161
so currently i wanted to change drop logic, i wanted life stones to be dropped separately when it's stackable, i did it but now, min and max drop are kind a fked we can say, when i have min 2 and max 5, it's dropping more then 5, so if anyone can help me about it, i would appreciate  ::) :-\


org.l2jmobius.gameserver.model.actor.Npc.java
Code: [Select]
/**
* Drops an item.
* @param creature the last attacker or main damage dealer
* @param itemId the item ID
* @param itemCount the item count
* @return the dropped item
*/
// Define a list of item IDs that should always be dropped separately
private static final Set<Integer> INDIVIDUAL_DROP_ITEMS = Set.of(8732, 8742, 8752, 8762, 8731, 8741, 8751, 8761 // item IDs
);

public Item dropItem(Creature creature, int itemId, int itemCount)
{
Item item = null;

// Check if the item is in the INDIVIDUAL_DROP_ITEMS set
boolean dropIndividually = INDIVIDUAL_DROP_ITEMS.contains(itemId);

// If not dropping individually and the item is stackable, drop the total count at once
if (!dropIndividually && ItemData.getInstance().getTemplate(itemId).isStackable())
{
item = ItemData.getInstance().createItem("Loot", itemId, itemCount, creature, this);
if (item == null)
{
return null;
}

if (creature != null)
{
item.getDropProtection().protect(creature);
}

// Randomize drop position.
final int newX = (getX() + Rnd.get((RANDOM_ITEM_DROP_LIMIT * 2) + 1)) - RANDOM_ITEM_DROP_LIMIT;
final int newY = (getY() + Rnd.get((RANDOM_ITEM_DROP_LIMIT * 2) + 1)) - RANDOM_ITEM_DROP_LIMIT;
final int newZ = getZ() + 20;

item.dropMe(this, newX, newY, newZ);

// Add drop to auto destroy item task.
if (!Config.LIST_PROTECTED_ITEMS.contains(itemId) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getTemplate().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getTemplate().hasExImmediateEffect())))
{
ItemsAutoDestroyTaskManager.getInstance().addItem(item);
}
item.setProtected(false);

return item;
}