Jump to content

Recommended Posts

Posted

Hello everyone, here's a simple and useful idea for any type of server.

 

This code applies a discount when a player makes a purchase inside a clan’s castle or clan hall, offering a benefit to clan members who own a castle or clan hall.

Important: Merchant transactions must be handled through multisell, not buylist. The discount is directly applied within the multisell, so the price shown is already reduced.

 

"For example, if a scroll costs 1000 Adena and you set a 20% discount in the config, the final price when purchasing inside a castle or clan hall will be 800 Adena."

 

This code is developed on the public aCis 401 revision.

 

public static int CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT;
CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT = clans.getProperty("ClanBaseOwnershipMechantDiscount", 20);

# If clan owns a clan hall or castle, all members have a discount of X% at merchant transactions (multisell).
# Discount applies only inside the base (castle or clan hall).
ClanBaseOwnershipMechantDiscount = 20

 

/**
diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/data/xml/MultisellData.java b/aCis_gameserver/java/net/sf/l2j/gameserver/data/xml/MultisellData.java
index 556e111..bbf8e69 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/data/xml/MultisellData.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/data/xml/MultisellData.java
@@ -101,7 +101,7 @@
 		do
 		{
 			// send list at least once even if size = 0
-			player.sendPacket(new MultiSellList(list, index));
+			player.sendPacket(new MultiSellList(list, index, player));
 			index += PAGE_SIZE;
 		}
 		while (index < list.getEntries().size());
diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/MultiSellChoose.java b/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/MultiSellChoose.java
index 7c82c5b..1654abc 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/MultiSellChoose.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/MultiSellChoose.java
@@ -6,6 +6,7 @@
 import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.enums.FloodProtector;
 import net.sf.l2j.gameserver.enums.StatusType;
+import net.sf.l2j.gameserver.enums.ZoneId;
 import net.sf.l2j.gameserver.enums.items.CrystalType;
 import net.sf.l2j.gameserver.model.Augmentation;
 import net.sf.l2j.gameserver.model.actor.Player;
@@ -225,6 +226,20 @@
 					return;
 				}
 				
+				if (player.isInsideZone(ZoneId.CLAN_HALL) && player.getClan() != null && player.getClan().hasClanHall())
+				{
+					e.setItemCount(e.getItemCount() * (100 - Config.CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT) / 100);
+					if (e.getItemCount() == 0)
+						e.setItemCount(1);
+				}
+				
+				if (player.isInsideZone(ZoneId.CASTLE) && player.getClan() != null && player.getClan().hasCastle())
+				{
+					e.setItemCount(e.getItemCount() * (100 - Config.CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT) / 100);
+					if (e.getItemCount() == 0)
+						e.setItemCount(1);
+				}
+				
 				if (Config.BLACKSMITH_USE_RECIPES || !e.getMaintainIngredient())
 				{
 					// if it's a stackable item, just reduce the amount from the first (only) instance that is found in the inventory
diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/MultiSellList.java b/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/MultiSellList.java
index 9269b06..c6102a0 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/MultiSellList.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/MultiSellList.java
@@ -2,6 +2,9 @@
 
 import static net.sf.l2j.gameserver.data.xml.MultisellData.PAGE_SIZE;
 
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.enums.ZoneId;
+import net.sf.l2j.gameserver.model.actor.Player;
 import net.sf.l2j.gameserver.model.multisell.Entry;
 import net.sf.l2j.gameserver.model.multisell.Ingredient;
 import net.sf.l2j.gameserver.model.multisell.ListContainer;
@@ -15,7 +18,9 @@
 	
 	private boolean _finished;
 	
-	public MultiSellList(ListContainer list, int index)
+	private Player _player;
+	
+	public MultiSellList(ListContainer list, int index, Player player)
 	{
 		_list = list;
 		_index = index;
@@ -28,6 +33,8 @@
 		}
 		else
 			_finished = true;
+		
+		_player = player;
 	}
 	
 	@Override
@@ -74,7 +81,14 @@
 			{
 				writeH(ing.getItemId());
 				writeH(ing.getTemplate() != null ? ing.getTemplate().getType2() : 65535);
-				writeD(ing.getItemCount());
+				
+				if (_player.isInsideZone(ZoneId.CLAN_HALL) && _player.getClan() != null && _player.getClan().hasClanHall())
+					writeD((ing.getItemCount() * (100 - Config.CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT) / 100) < 1 ? 1 : ing.getItemCount() * 80 / 100);
+				else if (_player.isInsideZone(ZoneId.CASTLE) && _player.getClan() != null && _player.getClan().hasCastle())
+					writeD((ing.getItemCount() * (100 - Config.CLAN_BASE_OWNERSHIP_MERCHANT_DISCOUNT) / 100) < 1 ? 1 : ing.getItemCount() * 80 / 100);
+				else
+					writeD(ing.getItemCount());
+				
 				writeH(ing.getEnchantLevel());
 				writeD(0x00); // TODO: i.getAugmentId()
 				writeD(0x00); // TODO: i.getManaLeft()

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • 👑 [FOR SALE] Lineage 2 Premium UCP – Modern Web Panel with Progression & Reward Systems. Looking for the ultimate edge to make your server boom and boost revenue? Introducing the L2 Premium UCP—the most comprehensive and modern User Control Panel on the market. Developed with a total focus on player experience (UX) and administrative automation. Say goodbye to outdated, buggy panels. Give your server the look and feel of an official game!  
    • Here I agree with you, because I get tired of clients like you and I don’t see any problems. Since you act in such a strange way, I’ll mirror it back to you, little brother.   Alice will even post a correspondence with you where you've been asking the same stupid questions (about prices or products) for three years and let everyone look and draw two personal conclusions about you (you're a little child)     If anyone wants to add you as a buyer to their group, let them take you hand and foot. I'll even help you pack you into an iron box.   Let's look at your last reply where you wish me luck in sales but then immediately run off to complain on the forum  yes, that's what people like you do and yes, I don't want to see people like you in my group or anywhere near it.   We're freelancing here, and yes, at first I check for loyalty and patience with clients, but when year after year they only ask me about prices - you know, if someone needs this, it's definitely not me.   Go with God, little brother, and find happiness in your life and stop making kindergarten on forums.😂   I don't need clients like that for free - who can't even look at payment methods and immediately become aggressive - and you always use free goods, just like your favorites from the Brazilian forum, you apparently have a fever about this - I have nothing against it - we had a nice conversation, everything is fine.            
    • Looking to release interface source from newer clients, if you got a client message me on discord: ilikebeer.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..