Jump to content
  • 0

Any Item like Adena


BloodRav3N

Question

Hello MxC,

I have a question. How can I make any etcitem to be dropped like Adena? So if I'm in a party the amount will be shared with all party members like Adena.

 

Edit: Could anyone give me the idea where to search? Or is it really hard to do? I'm using L2jFrozen btw.

Edited by BloodRav3N
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0
On 4/2/2018 at 6:55 PM, BloodRav3N said:

Could anyone give me the idea where to search? Or is it really hard to do? I'm using L2jFrozen btw.

have a look how it works on l2party.java, then copy and add with the item id

Link to comment
Share on other sites

  • 0

Your file is Party.java

Search/try what you want in there.. Ofc will not work if you simple change/add some ids. But, there is your file.

Link to comment
Share on other sites

  • 0

If anyone wants to do it here is what I did:

 

PcInventory.java

	public static final int ADENA_ID = 57;
	+public static final int COIN_ID = 9404;
	public static final int ANCIENT_ADENA_ID = 5575;
	
	private final L2PcInstance _owner;
	private L2ItemInstance _adena;
	+private L2ItemInstance _coin;
	private L2ItemInstance _ancientAdena;

--------------------------------------------

	public L2ItemInstance getAdenaInstance()
	{
		return _adena;
	}
	
	+public L2ItemInstance getCoinInstance()
	+{
	+	return _coin;
	+}
	
	@Override
	public int getAdena()
	{
		return _adena != null ? _adena.getCount() : 0;
	}
	
	+public int getCoin()
	+{
	+	return _coin != null ? _coin.getCount() : 0;
	+}

---------------------------------------------

	public void addAdena(final String process, final int count, final L2PcInstance actor, final L2Object reference)
	{
		if (count > 0)
		{
			addItem(process, ADENA_ID, count, actor, reference);
		}
	}
	
	+public void addCoin(final String process, final int count, final L2PcInstance actor, final L2Object reference)
	+{
	+	if (count > 0)
	+	{
	+		addItem(process, COIN_ID, count, actor, reference);
	+	}
	+}

-----------------------------------------------------

	public L2ItemInstance addItem(final String process, L2ItemInstance item, final L2PcInstance actor, final L2Object reference)
	{
		item = super.addItem(process, item, actor, reference);
		
		if (item != null && item.getItemId() == ADENA_ID && !item.equals(_adena))
		{
			_adena = item;
		}
		
		+if (item != null && item.getItemId() == COIN_ID && !item.equals(_coin))
		+{
		+	_coin = item;
		+}

--------------------------------------------------------

	public L2ItemInstance transferItem(final String process, final int objectId, final int count, final ItemContainer target, final L2PcInstance actor, final L2Object reference)
	{
		final L2ItemInstance item = super.transferItem(process, objectId, count, target, actor, reference);
		
		if (_adena != null && (_adena.getCount() <= 0 || _adena.getOwnerId() != getOwnerId()))
		{
			_adena = null;
		}
		
		+if (_coin != null && (_coin.getCount() <= 0 || _coin.getOwnerId() != getOwnerId()))
		+{
		+	_coin = null;
		+}

------------------------------------------------------

	public L2ItemInstance dropItem(final String process, L2ItemInstance item, final L2PcInstance actor, final L2Object reference)
	{
		item = super.dropItem(process, item, actor, reference);
		
		if (_adena != null && (_adena.getCount() <= 0 || _adena.getOwnerId() != getOwnerId()))
		{
			_adena = null;
		}
		
		+if (_coin != null && (_coin.getCount() <= 0 || _coin.getOwnerId() != getOwnerId()))
		+{
		+	_coin = null;
		+}

----------------------------------------------------

	public L2ItemInstance dropItem(final String process, final int objectId, final int count, final L2PcInstance actor, final L2Object reference)
	{
		final L2ItemInstance item = super.dropItem(process, objectId, count, actor, reference);
		
		if (_adena != null && (_adena.getCount() <= 0 || _adena.getOwnerId() != getOwnerId()))
		{
			_adena = null;
		}

		+if (_coin != null && (_coin.getCount() <= 0 || _coin.getOwnerId() != getOwnerId()))
		+{
		+	_coin = null;
		+}

--------------------------------------------------------------

	protected void removeItem(final L2ItemInstance item)
	{
		// Removes any reference to the item from Shortcut bar
		getOwner().removeItemFromShortCut(item.getObjectId());
		
		// Removes active Enchant Scroll
		if (item.equals(getOwner().getActiveEnchantItem()))
		{
			getOwner().setActiveEnchantItem(null);
		}
		
		if (item.getItemId() == ADENA_ID)
		{
			_adena = null;
		}
		+else if (item.getItemId() == COIN_ID)
		+{
		+	_coin = null;
		+}

----------------------------------------------------------

	public void restore()
	{
		super.restore();
		_adena = getItemByItemId(ADENA_ID);
	+	_coin = getItemByItemId(COIN_ID);
		_ancientAdena = getItemByItemId(ANCIENT_ADENA_ID);
	}

----------------------------------------------------------

 

L2PcInstance.java

	public int getAdena()
	{
		return _inventory.getAdena();
	}
	+public int getCoin()
	+{
	+	return _inventory.getCoin();
	+}

--------------------------------------------------------
  
  	+public void addCoin(final String process, int count, final L2Object reference, final boolean sendMessage)
	+{
	+	if (count > 0)
	+	{
	+		if (_inventory.getCoin() == Integer.MAX_VALUE)
	+		{
	+			return;
	+		}
	+		else if (_inventory.getCoin() >= Integer.MAX_VALUE - count)
	+		{
	+			count = Integer.MAX_VALUE - _inventory.getCoin();
	+			_inventory.addCoin(process, count, this, reference);
	+		}
	+		else if (_inventory.getCoin() < Integer.MAX_VALUE - count)
	+		{
	+			_inventory.addCoin(process, count, this, reference);
	+		}
	+		if (sendMessage)
	+		{
	+			SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
	+			sm.addItemName(PcInventory.COIN_ID);
	+			sm.addNumber(count);
	+			sendPacket(sm);
	+			sm = null;
	+		}
	+		
	+		// Send update packet
	+		if (!Config.FORCE_INVENTORY_UPDATE)
	+		{
	+			InventoryUpdate iu = new InventoryUpdate();
	+			iu.addItem(_inventory.getAdenaInstance());
	+			sendPacket(iu);
	+			iu = null;
	+		}
	+		else
	+		{
	+			sendPacket(new ItemList(this, false));
	+		}
	+	}
	+}

----------------------------------------------------------------------------
  
  		else if (item.getItemId() == 57)
		{
			addAdena("AutoLoot", item.getCount(), target, true);
		}
		+else if (item.getItemId() == 9404)
		+{
		+	addCoin("AutoLoot", item.getCount(), target, true);
		+}

----------------------------------------------------------------------------
  
  			else if (target.getItemId() == 57 && getInventory().getAdenaInstance() != null)
			{
				addAdena("Pickup", target.getCount(), null, true);
				ItemTable.getInstance().destroyItem("Pickup", target, this, null);
			}
		+	else if (target.getItemId() == 9404 && getInventory().getCoinInstance() != null)
		+	{
		+		addCoin("Pickup", target.getCount(), null, true);
		+		ItemTable.getInstance().destroyItem("Pickup", target, this, null);
		+	}


  

 

L2Party.java

	public void distributeItem(final L2PcInstance player, final L2ItemInstance item)
	{
		if (item.getItemId() == 57)
		{
			distributeAdena(player, item.getCount(), player);
			ItemTable.getInstance().destroyItem("Party", item, player, null);
			return;
		}
		+if (item.getItemId() == 9404)
		+{
		+	distributeCoin(player, item.getCount(), player);
		+	ItemTable.getInstance().destroyItem("Party", item, player, null);
		+	return;
		+}

-------------------------------------------------------------------

	public void distributeItem(final L2PcInstance player, final L2Attackable.RewardItem item, final boolean spoil, final L2Attackable target)
	{
		if (item == null)
			return;
		
		if (item.getItemId() == 57)
		{
			distributeAdena(player, item.getCount(), target);
			return;
		}
		
		+if (item.getItemId() == 9404)
		+{
		+	distributeCoin(player, item.getCount(), target);
		+	return;
		+}

------------------------------------------------------------------------
  Search for public void distributeAdena and paste this under:

+	public void distributeCoin(final L2PcInstance player, final int coin, final L2Character target)
+	{
+		// Get all the party members
+		final List<L2PcInstance> membersList = getPartyMembers();
+		
+		// Check the number of party members that must be rewarded
+		// (The party member must be in range to receive its reward)
+		final List<L2PcInstance> ToReward = FastList.newInstance();
+		
+		for (final L2PcInstance member : membersList)
+		{
+			if (!Util.checkIfInRange(Config.ALT_PARTY_RANGE2, target, member, true))
+			{
+				continue;
+			}
+			ToReward.add(member);
+		}
+		
+		// Avoid null exceptions, if any
+		if (ToReward.isEmpty())
+			return;
+		
+		// Now we can actually distribute the adena reward
+		// (Total adena split by the number of party members that are in range and must be rewarded)
+		final int count = coin / ToReward.size();
+		
+		for (final L2PcInstance member : ToReward)
+		{
+			member.addCoin("Party", count, player, true);
+		}
+		FastList.recycle((FastList<?>) ToReward);
+	}

Thanks again for the replies (even if it took 1 months for a reply :P ) you can lock this topic :)

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.
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.



×
×
  • Create New...