Jump to content
  • 0

Limit amount of loot on the ground L2j - H5


Kyboi

Question

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
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
Edit ItemsAutoDestroy#addItem method, simply enforce whatever timer you want.

L2J already handles your case, eg. herbs naturally dissapear after a while.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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

    • Totally understood. You are right. I am not denying the time and the effort that you guys have poured in learning and developing yourselves as able devs. If I am not a learner then I would have bought a ready solution like korean client worked-out (not sure if there is. I have never tried to look for) Frankly, I have never bought any packs or some stuffs but just been working on a pure pack from l2j by myself. Actually I am not asking you guys to do everything for me. I just looked for a clue to solve my problem. (I am a korean and there is no korean community for l2j developing) I searched this forum for related articles and found some but all the instructions were just from normal users, not devs. They just shared their thoughts or opinions not apt informations. Namely, I could not get any clue for my problem.   Anyways, I already gave up to mod client due to lack of informations and knowleges. Have a good day brother.
    • Hi, I have seen in l2gold.in that there is an item that when clicked spawns a mob/raid_boss ramdom, this is edited from the ai or you have to create a mod in extender?, I am using the Dandiarena datapack.   I have seen the skill to spawn a pet with an item (dragon flaute) and I have seen the s_skill to spawn the unicorns (elemental summoner), I tried to create a s_summon of a raid boss but it threw error, for this reason I decided to come here to ask, this can help many people.   --------------------------------------------------------------------------------------------------------------------------------   SPAWN CAT: skill_begin    skill_name=[s_summon_blackcat1]    /* [쀜뀼 삣 끔 삣] */    skill_id=1111    level=1    operate_type=A1    magic_level=20    effect={{i_summon;[cat_the_cat_a];70;[crystal_d];0}}    operate_cond={{can_summon}}    is_magic=1    mp_consume1=8    mp_consume2=31    item_consume={[crystal_d];3}    cast_range=-1    effective_range=-1    skill_hit_time=15    skill_cool_time=0    skill_hit_cancel_time=0.5    reuse_delay=21600    attribute=attr_none    effect_point=0    target_type=self    affect_scope=single    affect_limit={0;0}    next_action=none    ride_state={@ride_none;@ride_wind;@ride_star;@ride_twilight}    skill_end   SPAWN ITEM (DB +10): skill_begin    skill_name=[s_en_draconic_bow_focus_10_box]    /* [Box with Draconic Bow Focus + 10] */    skill_id=10043    level=1    operate_type=A1    magic_level=1    effect={{i_add_enchanted_item;7577;10}}    is_magic=0    mp_consume2=0    item_consume={[en_draconic_bow_focus_10_box];1}    cast_range=-1    effective_range=-1    skill_hit_time=0.2    skill_cool_time=0    skill_hit_cancel_time=0    reuse_delay=0    attribute=attr_none    effect_point=0    target_type=self    affect_scope=single    affect_limit={0;0}    next_action=none    ride_state={@ride_none;@ride_wind;@ride_star;@ride_twilight}    skill_end   DRAGON FLAUTE: skill_begin    skill_name=[s_wolf_collar]    /* [Modified 15 May 2009 18:44] */    skill_id=2046    level=1    operate_type=A1    magic_level=1    effect={{i_summon_pet}}    operate_cond={{can_summon_pet};{op_not_territory;{{51341;218103;-3252;-2932};{53341;218103;-3252;-2932};{53341;220103;-3252;-2932};{51341;220103;-3252;-2932}}}}    is_magic=0    mp_consume2=0    cast_range=-1    effective_range=-1    skill_hit_time=5    skill_cool_time=0    skill_hit_cancel_time=0.5    reuse_delay=0    attribute=attr_none    effect_point=0    target_type=self    affect_scope=single    affect_limit={0;0}    next_action=none    ride_state={@ride_none}    skill_end     ITEM WITH RAMDOM DROP (GIFT/BOX): skill_begin    skill_name=[s_ingredient_box_1]    /* [샜쁽쁘 상삐] */    skill_id=2175    level=1    operate_type=A1    magic_level=1    effect={{i_restoration_random;{{{{[blood_root];2}};20};{{{[sulfur];2}};20};{{{[infernium_ore];1}};35};{{{[demons_blood];2}};25}}}}    is_magic=2    mp_consume2=0    item_consume={[ingredient_box];1}    cast_range=-1    effective_range=-1    skill_hit_time=0    skill_cool_time=0    skill_hit_cancel_time=0    reuse_delay=0    attribute=attr_none    effect_point=0    target_type=self    affect_scope=single    affect_limit={0;0}    next_action=none    ride_state={@ride_none;@ride_wind;@ride_star;@ride_twilight}    skill_end   --------------------------------------------------------------------------------------------------------------------------------   SPAWN RAID BOSS/MOB W/ ITEM: ??? HELP!     --------------------------------------------------------------------------------------------------------------------------------   I am learning how to create an OFF server, but I have many doubts, I would like you to guide me, I would appreciate it very much!    
    • Hello, is possible any effect spawn raid boss/mobs?
    • wts 100kk adena set mj light unsealed set nightmare sealed set tallum heavy unsealed set jewels tts unsealed! soul bow ITEMS C GRADE  l2reborn origins x1
    • WTB AQ Reborn Origins x1  Only middleman.  discord: Mr.Saran#1369
  • 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