Jump to content
  • 0

Limit amount of loot on the ground L2j - H5


Question

Posted (edited)

Hello, I'm having a problem with my drop rates, due to the high amount of loot that Champions give I made it so that non-stackable items drop on the ground (since going over 500 items in the inventory disables a character), the problem is that in the long run sometimes Champions dropped hundreds or thousands of non-stackable items on the ground, causing massive lag, lowering the drop rate/chance isn't a possibility since that would mean massively decreasing the chance of item to be dropped from a regular mob, to solve this I just set the MultipleItemDrop config to False, with that only 1 item is created if the item is non-stackable

 

HOWEVER the problem is that now whenever I'm doing a quest and the NPC gives 2 or more items of the same ID (like the Spirit of Mirrors quest in the Human Village) I get only 1 instead, making the quest impossible to complete, I went into the core and noticed 2 variables affected by the MultipleItemDrop config: dropItem and addItem, I thought that maybe creating a new config and separating both would solve the problem, and it did, but after that if someone logged out while having equipped any item other than NG then the character would be unable to enter again, and a massive error appears on the console when someone tries to login said character, the error was basically StackOverflowError which with my really lacking knowledge of java it means that something is on an infinite loop

 

With that situation happening I think that now my safest option is to just limit the amount of items dropped on the ground, how can I do this? here's the code for the item drop:

 

public L2ItemInstance dropItem(L2PcInstance player, int itemId, long itemCount)
	{
		L2ItemInstance item = null;
		for (int i = 0; i < itemCount; i++)
		{
			// 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;
			
			if (ItemTable.getInstance().getTemplate(itemId) == null)
			{
				LOG.error("Item doesn't exist so cannot be dropped. Item ID: {} Quest: {}", itemId, getName());
				return null;
			}
			
			item = ItemTable.getInstance().createItem("Loot", itemId, itemCount, player, this);
			if (item == null)
			{
				return null;
			}
			
			if (player != null)
			{
				item.getDropProtection().protect(player);
			}
			
			item.dropMe(this, newX, newY, newZ);
			
			// Add drop to auto destroy item task.
			if (!Config.LIST_PROTECTED_ITEMS.contains(itemId))
			{
				if (((Config.AUTODESTROY_ITEM_AFTER > 0) && !item.getItem().hasExImmediateEffect()) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && item.getItem().hasExImmediateEffect()))
				{
					ItemsAutoDestroy.getInstance().addItem(item);
				}
			}
			item.setProtected(false);
			
			// If stackable, end loop as entire count is included in 1 instance of item.
			if (item.isStackable() || !Config.MULTIPLE_ITEM_DROP)
			{
				break;
			}
		}
		return item;
	}


And the code for the itemdrop on L2Attackable.java:

 

public void doItemDrop(L2NpcTemplate npcTemplate, L2Character mainDamageDealer)
	{
		if (mainDamageDealer == null)
		{
			return;
		}
		
		L2PcInstance player = mainDamageDealer.getActingPlayer();
		
		// Don't drop anything if the last attacker or owner isn't L2PcInstance
		if (player == null)
		{
			return;
		}
		
		CursedWeaponsManager.getInstance().checkDrop(this, player);
		
		if (isSpoiled())
		{
			_sweepItems.set(npcTemplate.calculateDrops(DropListScope.CORPSE, this, player));
		}
		
		Collection<ItemHolder> deathItems = npcTemplate.calculateDrops(DropListScope.DEATH, this, player);
		if (deathItems != null)
		{
			for (ItemHolder drop : deathItems)
			{
				L2Item item = ItemTable.getInstance().getTemplate(drop.getId());
				// Check if the autoLoot mode is active
				if (isFlying() || ((!item.hasExImmediateEffect() && ((!isRaid() && Config.AUTO_LOOT) && (item.isStackable() || (isRaid() && Config.AUTO_LOOT_RAIDS)))) || (item.hasExImmediateEffect() && Config.AUTO_LOOT_HERBS)))
				{
					player.doAutoLoot(this, drop); // Give the item(s) to the L2PcInstance that has killed the L2Attackable
				}
				else
				{
					dropItem(player, drop); // drop the item on the ground
				}
				
				// Broadcast message if RaidBoss was defeated
				if (isRaid() && !isRaidMinion() && (drop.getCount() > 0))
				{
					final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DIED_DROPPED_S3_S2);
					sm.addCharName(this);
					sm.addItemName(item);
					sm.addLong(drop.getCount());
					broadcastPacket(sm);
				}
			}
		}
    }

 

Thanks in advance

Edited by Kyboi

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • What kind of explanation are you expecting from the admin? You're very funny.. You're not the owner of those files. This is exactly why people dont trust you. You know which files am talking about the ones from Fotis, from Greece. Yes, that source code. As far as I remember, you were banned multiple times and i still dont know why you are even here. Later, you came back under a different name. But now, everyone knows who you really are. Stop sharing servers that already exist. Do you really think people are blind or stupid?  
    • The server will be offline for 1-2 months Till I prepare the big update.  Adding completely new features, improving the user experience. We are coming soon.
    • https://media1.tenor.com/m/VqFdrGGsXOwAAAAd/bj-blowjob.gif
    • Mod: Saudação Real para Dono de Castelo Sistema inspirado no comportamento do Lineage II Classic (Kamael), que adiciona imersão e respeito ao líder do clã que controla um castelo.   🔍 Descrição Esse mod cria uma animação automática de reverência (/socialbow) para todos os jogadores próximos ao líder do clã dono de um castelo, quando ele estiver presente na vila. Além disso, mensagens de saudação personalizadas são exibidas no chat e na tela para todos os jogadores ao redor. Ideal para servidores que querem adicionar um toque de imersão realista e respeito ao poder dos clãs.   💡 Funcionalidades Leitura de dados por XML (GreetingData.xml) Configuração por castelo, zona, animação, mensagem e tempo Reação automática de jogadores próximos ao líder Cooldown configurável para evitar spam Totalmente compatível com aCis 409 / DreamV2 Suporte a expansão futura com mais zonas ou ações   <?xml version="1.0" encoding="UTF-8"?> <!--   Configuração do sistema de Saudação Real (Reverência ao Líder de Castelo)   Quando o líder do clã que possui um castelo estiver presente na vila correspondente, jogadores próximos   automaticamente fazem uma reverência (social ID definido) e recebem uma mensagem de saudação na tela.   -----------------------------------------   Atributos de <greeting>:   • castleId  → ID do castelo (ex: 1 = Gludio, 2 = Dion)   • zone      → "TOWN" (apenas dentro da vila atualmente)   • actionId  → ID da animação (7 = reverência)   • msg       → Mensagem exibida na tela e chat   • time      → Tempo mínimo em segundos entre cada saudação --> <list>     <greeting castleId="1" zone="TOWN" actionId="7" msg="Salve o Rei de Gludio!" time="60" />     <greeting castleId="2" zone="TOWN" actionId="7" msg="Honrem o Senhor de Dion!" time="30" /> </list> 📌 Observações Técnicas A checagem ocorre a cada 10 segundo via GreetingManager. Gatilho: líder do castelo está na zona de paz da vila. Jogadores próximos (em raio configurável) executam a animação e recebem mensagem. 🧠 Requisitos Servidor aCis ou derivado compatível (testado no DreamV2 e aCis 409) Path DreamV2: AQUI Path aCis 409: AQUI PasteBin: AQUI
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock