Jump to content

[Share][Updated] Advanced Enchant Chance System v1.3


Recommended Posts

Posted

I got the basic idea for this system, when i saw TheEnd's Custom Enchant System -> http://www.maxcheaters.com/forum/index.php?topic=80457.0

Since it was quite limited, i've made this system, allowing you to set different chance for different enchant level...

 

The code is done on L2J Server - Gracia Final , but there is a high possibility to work on others too

 

So simply, this system allows you to create ur own list which you define the chance for some enchant level...

For example, if you set the chance for +14 to be 50%, the enchanter will have 50% chance to enchant his item from +13 to +14. Read the config for more info

Not 100% tested, but it worked on the test. So if you find any bugs, report 'em

 

Index: java/config/Character.properties
===================================================================
--- java/config/Character.properties	(revision 3492)
+++ java/config/Character.properties	(working copy)
@@ -270,6 +270,38 @@
BlessedEnchantChanceArmor = 66
BlessedEnchantChanceJewelry = 66

+# This is a list where you define different enchant chance on different enchant levels
+# Format: enchantLevel1,enchantChance1;enchantLevel2,enchantChance2...
+# Example: 
+#	The "\"indicates new line, and is only set for formating purposes.
+#	EnchantChanceWeaponList = 4,90;5,80;6,75;7,70;8,65;\
+#	9,60;10,50;11,20;12,10;13,50;14,25;15,20
+#	No ";" or ";\" at the end
+# So, if the enchant chance for +15 is set to 30%, the enchanter will have 30%
+# chance to enchant the weapon from +14 to +15
+# If a specific enchant level isnt described in the list, or the list is empty,
+# the chance will be the one set at default configs
+# (ex. EnchantChanceWeapon = ?? / EnchantChanceArmor = ?? / EnchantChanceJewelry = ??)
+# So if you miss in the list for example, +15 for weapon, the chance will be
+# the one set at EnchantChanceWeapon (BlessedEnchantChanceWeapon for blessed)
+EnchantChanceWeaponList =
+EnchantChanceArmorList =
+EnchantChanceJewelryList =
+
+BlessedEnchantChanceWeaponList = 
+BlessedEnchantChanceArmorList = 
+BlessedEnchantChanceJewelryList = 
+
+# List of item id that will be affected by EnchantChance lists
+# (separated by "," like 77,78,79).
+# Notes:
+#	*Make sure the lists do NOT CONTAIN trailing spaces or spaces between the numbers!
+#	*Items on this list will be affected by normal enchant restrictions aswell.
+#     For example, even if you add a hero weapon here, you wont be able to enchant it.
+#   *Default is 0, that means all items will be affected, and if there is 0 somewhere
+#     in the list, it will still affect all items! Be aware of that!
+EnchantChanceListsRestriction = 0
+
# This is the enchant limit, if set to 0, there will be no limit.
# Example: If this is set to 10, the maximum enchant will be 10.
# Default: 0, 0, 0
Index: java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java	(revision 3492)
+++ java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java	(working copy)
@@ -18,6 +18,7 @@
import java.util.Map;

import javolution.util.FastMap;
+import gnu.trove.TIntIntHashMap; 

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.L2ItemInstance;
@@ -172,20 +173,20 @@
					return -1;

				if (_isWeapon)
-					chance = Config.BLESSED_ENCHANT_CHANCE_WEAPON;
+					chance = getListChance(Config.BLESSED_ENCHANT_CHANCE_WEAPON_LIST,Config.BLESSED_ENCHANT_CHANCE_WEAPON,enchantItem);		
				else if (isAccessory)
-					chance = Config.BLESSED_ENCHANT_CHANCE_JEWELRY;
+					chance = getListChance(Config.BLESSED_ENCHANT_CHANCE_JEWELRY_LIST,Config.BLESSED_ENCHANT_CHANCE_JEWELRY,enchantItem);
				else
-					chance = Config.BLESSED_ENCHANT_CHANCE_ARMOR;
+					chance = getListChance(Config.BLESSED_ENCHANT_CHANCE_ARMOR_LIST,Config.BLESSED_ENCHANT_CHANCE_ARMOR,enchantItem);
			}
			else
			{
				if (_isWeapon)
-					chance = Config.ENCHANT_CHANCE_WEAPON;
+					chance = getListChance(Config.ENCHANT_CHANCE_WEAPON_LIST,Config.ENCHANT_CHANCE_WEAPON,enchantItem);		
				else if (isAccessory)
-					chance = Config.ENCHANT_CHANCE_JEWELRY;
+					chance = getListChance(Config.ENCHANT_CHANCE_JEWELRY_LIST,Config.ENCHANT_CHANCE_JEWELRY,enchantItem);	
				else
-					chance = Config.ENCHANT_CHANCE_ARMOR;
+					chance = getListChance(Config.ENCHANT_CHANCE_ARMOR_LIST,Config.ENCHANT_CHANCE_ARMOR,enchantItem);
			}

			chance += _chanceAdd;
@@ -196,6 +197,24 @@
			return chance;
		}
	}
+	
+	public static boolean isInRestrictionList(L2ItemInstance item)
+	{
+		if (Config.LIST_ENCHANT_CHANCE_LISTS_RESTRICTION.contains(0)) return true;
+		return Config.LIST_ENCHANT_CHANCE_LISTS_RESTRICTION.contains(item.getItemId());		
+	}
+	public static int getListChance(TIntIntHashMap ConfigEnchantChanceList, Integer ConfigEnchantChance, L2ItemInstance item)
+	{
+		int chance = 0;
+		if (!ConfigEnchantChanceList.isEmpty() && isInRestrictionList(item))
+		{
+			if (ConfigEnchantChanceList.containsKey(item.getEnchantLevel()+1))
+			chance = ConfigEnchantChanceList.get(item.getEnchantLevel()+1);
+			else chance = ConfigEnchantChance;
+		}
+		else chance = ConfigEnchantChance;	
+		return chance;
+	}

	static
	{
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java	(revision 3492)
+++ java/net/sf/l2j/Config.java	(working copy)
@@ -29,6 +29,7 @@

import javolution.util.FastList;
import javolution.util.FastMap;
+import gnu.trove.TIntIntHashMap; 
import net.sf.l2j.gameserver.util.FloodProtectorConfig;
import net.sf.l2j.gameserver.util.StringUtil;

@@ -38,7 +39,6 @@

	//--------------------------------------------------
	// L2J Property File Definitions
-	//--------------------------------------------------
	public static final String CHARACTER_CONFIG_FILE = "./config/Character.properties";
	public static final String EXTENSIONS_CONFIG_FILE = "./config/extensions.properties";
	public static final String FEATURE_CONFIG_FILE = "./config/Feature.properties";
@@ -800,9 +800,17 @@
	public static int ENCHANT_CHANCE_WEAPON;
	public static int ENCHANT_CHANCE_ARMOR;
	public static int ENCHANT_CHANCE_JEWELRY;
+	public static TIntIntHashMap ENCHANT_CHANCE_WEAPON_LIST;
+	public static TIntIntHashMap ENCHANT_CHANCE_ARMOR_LIST;
+	public static TIntIntHashMap ENCHANT_CHANCE_JEWELRY_LIST;
	public static int BLESSED_ENCHANT_CHANCE_WEAPON;
	public static int BLESSED_ENCHANT_CHANCE_ARMOR;
	public static int BLESSED_ENCHANT_CHANCE_JEWELRY;
+	public static TIntIntHashMap BLESSED_ENCHANT_CHANCE_WEAPON_LIST;
+	public static TIntIntHashMap BLESSED_ENCHANT_CHANCE_ARMOR_LIST;
+	public static TIntIntHashMap BLESSED_ENCHANT_CHANCE_JEWELRY_LIST;
+	public static String ENCHANT_CHANCE_LISTS_RESTRICTION;
+	public static List<Integer> LIST_ENCHANT_CHANCE_LISTS_RESTRICTION = new FastList<Integer>();
	public static int ENCHANT_MAX_WEAPON;
	public static int ENCHANT_MAX_ARMOR;
	public static int ENCHANT_MAX_JEWELRY;
@@ -1221,9 +1229,93 @@
					ENCHANT_CHANCE_WEAPON = Integer.parseInt(Character.getProperty("EnchantChanceWeapon", "66"));
					ENCHANT_CHANCE_ARMOR = Integer.parseInt(Character.getProperty("EnchantChanceArmor", "66"));
					ENCHANT_CHANCE_JEWELRY = Integer.parseInt(Character.getProperty("EnchantChanceJewelry", "66"));
+						String[] propertySplitWeapon = Character.getProperty("EnchantChanceWeaponList", "").split(";");
+						String[] propertySplitArmor = Character.getProperty("EnchantChanceArmorList", "").split(";");
+						String[] propertySplitJewelry = Character.getProperty("EnchantChanceJewelryList", "").split(";");
+						String[] propertySplitBlessedWeapon = Character.getProperty("BlessedEnchantChanceWeaponList", "").split(";");
+						String[] propertySplitBlessedArmor = Character.getProperty("BlessedEnchantChanceArmorList", "").split(";");
+						String[] propertySplitBlessedJewelry = Character.getProperty("BlessedEnchantChanceJewelryList", "").split(";");
+						ENCHANT_CHANCE_WEAPON_LIST = new TIntIntHashMap(propertySplitWeapon.length);
+						ENCHANT_CHANCE_ARMOR_LIST = new TIntIntHashMap(propertySplitArmor.length);
+						ENCHANT_CHANCE_JEWELRY_LIST = new TIntIntHashMap(propertySplitJewelry.length);
+						BLESSED_ENCHANT_CHANCE_WEAPON_LIST = new TIntIntHashMap(propertySplitBlessedWeapon.length);
+						BLESSED_ENCHANT_CHANCE_ARMOR_LIST = new TIntIntHashMap(propertySplitBlessedArmor.length);
+						BLESSED_ENCHANT_CHANCE_JEWELRY_LIST = new TIntIntHashMap(propertySplitBlessedJewelry.length);
+						for (String enchant : propertySplitWeapon)
+						{
+							String[] enchantSplit = enchant.split(",");
+							if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+							else
+							{
+								try{ENCHANT_CHANCE_WEAPON_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+								catch (NumberFormatException nfe){
+								if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+							}
+						}
+						for (String enchant : propertySplitArmor)
+						{
+							String[] enchantSplit = enchant.split(",");
+							if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+							else
+							{
+								try{ENCHANT_CHANCE_ARMOR_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+								catch (NumberFormatException nfe){
+								if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+							}
+						}
+						for (String enchant : propertySplitJewelry)
+						{
+							String[] enchantSplit = enchant.split(",");
+							if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+							else
+							{
+								try{ENCHANT_CHANCE_JEWELRY_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+								catch (NumberFormatException nfe){
+								if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+							}
+						}
					BLESSED_ENCHANT_CHANCE_WEAPON = Integer.parseInt(Character.getProperty("BlessedEnchantChanceWeapon", "66"));
					BLESSED_ENCHANT_CHANCE_ARMOR = Integer.parseInt(Character.getProperty("BlessedEnchantChanceArmor", "66"));
					BLESSED_ENCHANT_CHANCE_JEWELRY = Integer.parseInt(Character.getProperty("BlessedEnchantChanceJewelry", "66"));
+					for (String enchant : propertySplitBlessedWeapon)
+					{
+						String[] enchantSplit = enchant.split(",");
+						if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+						else
+						{
+							try{BLESSED_ENCHANT_CHANCE_WEAPON_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+							catch (NumberFormatException nfe){
+							if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+						}
+					}
+					for (String enchant : propertySplitBlessedArmor)
+					{
+						String[] enchantSplit = enchant.split(",");
+						if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+						else
+						{
+							try{BLESSED_ENCHANT_CHANCE_ARMOR_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+							catch (NumberFormatException nfe){
+							if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+						}
+					}
+					for (String enchant : propertySplitBlessedJewelry)
+					{
+						String[] enchantSplit = enchant.split(",");
+						if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+						else
+						{
+							try{BLESSED_ENCHANT_CHANCE_JEWELRY_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+							catch (NumberFormatException nfe){
+							if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+						}
+					}
+					ENCHANT_CHANCE_LISTS_RESTRICTION = Character.getProperty("EnchantChanceListsRestriction", "0");
+					LIST_ENCHANT_CHANCE_LISTS_RESTRICTION = new FastList<Integer>();
+					for (String id : ENCHANT_CHANCE_LISTS_RESTRICTION.split(","))
+					{
+						LIST_ENCHANT_CHANCE_LISTS_RESTRICTION.add(Integer.parseInt(id));
+					}
					ENCHANT_MAX_WEAPON = Integer.parseInt(Character.getProperty("EnchantMaxWeapon", "0"));
					ENCHANT_MAX_ARMOR = Integer.parseInt(Character.getProperty("EnchantMaxArmor", "0"));
					ENCHANT_MAX_JEWELRY = Integer.parseInt(Character.getProperty("EnchantMaxJewelry", "0"));

 

Interlude(L2-Equal) - http://pastebin.com/f4382d81c[1.1]

Interlude(L2J-Archid) - http://pastebin.com/f5bd04576[1.3]

Interlude(L2JHardCode) - http://pastebin.com/f1173273a[1.3]

 

 

Changelog:

NOTE: When i was editing  the system to v1.3, i saw that i changed only the interlude patch to 1.1, the g.final patch was still 1.0, when i though it was 1.1... so 1.2 was based on 1.0, that wasnt working properly... so for gracia final patch, 1.3 is working properly.

 

1.1:

At 1.0 the code wasnt tested and it wasnt working correctly, now its tested & fixed

 

1.2:

Added a list, where you can define which items to be affected by this list (as fxb0t requested)

 

1.3: (NOT TESTED, please test)

Changed Map/FastMap to TIntIntHashMap(It works a bit different than FastMap, so i had to guess how it works... i hope i got it right and didnt messed smth)

Instead of using the same logarithm for every enchant, i created a method that contains this logarithm, so this method can be called with different values. In short, same function, but a lot less code.

Posted

here you go... sorry that i cant post it in the first post... it exceeds 20000 chars -.-

Index: java/com/equal/Config.java
===================================================================
--- java/com/equal/Config.java	(revision 341)
+++ java/com/equal/Config.java	(working copy)
@@ -25,10 +25,12 @@
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;

import javolution.util.FastList;
+import javolution.util.FastMap;

import com.equal.gameserver.model.actor.instance.L2PcInstance;
import com.equal.gameserver.util.FloodProtectorConfig;
@@ -660,6 +662,12 @@
	public static int     ENCHANT_CHANCE_WEAPON_BLESSED; /** Chance that a Blessed Scroll will have to enchant over safe limit */
	public static int     ENCHANT_CHANCE_ARMOR_BLESSED; /** Chance that a Blessed Scroll will have to enchant over safe limit */
	public static int     ENCHANT_CHANCE_JEWELRY_BLESSED; /** Chance that a Blessed Scroll will have to enchant over safe limit */
+ 	public static Map<Integer, Integer> ENCHANT_CHANCE_WEAPON_LIST;
+ 	public static Map<Integer, Integer> ENCHANT_CHANCE_ARMOR_LIST;
+ 	public static Map<Integer, Integer> ENCHANT_CHANCE_JEWELRY_LIST;
+ 	public static Map<Integer, Integer> BLESSED_ENCHANT_CHANCE_WEAPON_LIST;
+ 	public static Map<Integer, Integer> BLESSED_ENCHANT_CHANCE_ARMOR_LIST;
+ 	public static Map<Integer, Integer> BLESSED_ENCHANT_CHANCE_JEWELRY_LIST;
	public static int     ENCHANT_MAX_ALLOWED_WEAPON; /** Max possible enchant by player */
	public static int     ENCHANT_MAX_ALLOWED_ARMOR; /** Max possible enchant by player */
	public static int     ENCHANT_MAX_ALLOWED_JEWELRY; /** Max possible enchant by player */
@@ -1615,6 +1623,84 @@
				ENCHANT_CHANCE_WEAPON_BLESSED = Integer.parseInt(otherSettings.getProperty("EnchantChanceWeaponBlessed", "55"));
				ENCHANT_CHANCE_ARMOR_BLESSED = Integer.parseInt(otherSettings.getProperty("EnchantChanceArmorBlessed", "55"));
				ENCHANT_CHANCE_JEWELRY_BLESSED = Integer.parseInt(otherSettings.getProperty("EnchantChanceJewelryBlessed", "55"));
+						String[] propertySplitWeapon = otherSettings.getProperty("EnchantChanceWeaponList", "").split(";");
+						String[] propertySplitArmor = otherSettings.getProperty("EnchantChanceArmorList", "").split(";");
+						String[] propertySplitJewelry = otherSettings.getProperty("EnchantChanceJewelryList", "").split(";");
+						String[] propertySplitBlessedWeapon = otherSettings.getProperty("BlessedEnchantChanceWeaponList", "").split(";");
+						String[] propertySplitBlessedArmor = otherSettings.getProperty("BlessedEnchantChanceArmorList", "").split(";");
+						String[] propertySplitBlessedJewelry = otherSettings.getProperty("BlessedEnchantChanceJewelryList", "").split(";");
+						ENCHANT_CHANCE_WEAPON_LIST = new FastMap<Integer, Integer>(propertySplitWeapon.length);
+						ENCHANT_CHANCE_ARMOR_LIST = new FastMap<Integer, Integer>(propertySplitArmor.length);
+						ENCHANT_CHANCE_JEWELRY_LIST = new FastMap<Integer, Integer>(propertySplitJewelry.length);
+						BLESSED_ENCHANT_CHANCE_WEAPON_LIST = new FastMap<Integer, Integer>(propertySplitBlessedWeapon.length);
+						BLESSED_ENCHANT_CHANCE_ARMOR_LIST = new FastMap<Integer, Integer>(propertySplitBlessedArmor.length);
+						BLESSED_ENCHANT_CHANCE_JEWELRY_LIST = new FastMap<Integer, Integer>(propertySplitBlessedJewelry.length);
+						for (String enchant : propertySplitWeapon)
+						{
+							String[] enchantSplit = enchant.split(",");
+							if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+							else
+							{
+								try{ENCHANT_CHANCE_WEAPON_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+								catch (NumberFormatException nfe){
+								if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+							}
+						}
+						for (String enchant : propertySplitArmor)
+						{
+							String[] enchantSplit = enchant.split(",");
+							if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+							else
+							{
+								try{ENCHANT_CHANCE_ARMOR_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+								catch (NumberFormatException nfe){
+								if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+							}
+						}
+						for (String enchant : propertySplitJewelry)
+						{
+							String[] enchantSplit = enchant.split(",");
+							if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+							else
+							{
+								try{ENCHANT_CHANCE_JEWELRY_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+								catch (NumberFormatException nfe){
+								if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+							}
+						}
+					for (String enchant : propertySplitBlessedWeapon)
+					{
+						String[] enchantSplit = enchant.split(",");
+						if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+						else
+						{
+							try{BLESSED_ENCHANT_CHANCE_WEAPON_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+							catch (NumberFormatException nfe){
+							if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+						}
+					}
+					for (String enchant : propertySplitBlessedArmor)
+					{
+						String[] enchantSplit = enchant.split(",");
+						if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+						else
+						{
+							try{BLESSED_ENCHANT_CHANCE_ARMOR_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+							catch (NumberFormatException nfe){
+							if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+						}
+					}
+					for (String enchant : propertySplitBlessedJewelry)
+					{
+						String[] enchantSplit = enchant.split(",");
+						if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
+						else
+						{
+							try{BLESSED_ENCHANT_CHANCE_JEWELRY_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
+							catch (NumberFormatException nfe){
+							if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
+						}
+					}
				ENCHANT_MAX_ALLOWED_WEAPON = Integer.parseInt(otherSettings.getProperty("EnchantMaxAllowedWeapon", "255"));
				ENCHANT_MAX_ALLOWED_ARMOR = Integer.parseInt(otherSettings.getProperty("EnchantMaxAllowedArmor", "255"));
				ENCHANT_MAX_ALLOWED_JEWELRY = Integer.parseInt(otherSettings.getProperty("EnchantMaxAllowedJewelry", "255"));
Index: java/com/equal/gameserver/network/clientpackets/RequestEnchantItem.java
===================================================================
--- java/com/equal/gameserver/network/clientpackets/RequestEnchantItem.java	(revision 341)
+++ java/com/equal/gameserver/network/clientpackets/RequestEnchantItem.java	(working copy)
@@ -206,7 +206,14 @@
			{
				if (scroll.getItemId() == scrollId)
				{
-					chance = Config.ENCHANT_CHANCE_WEAPON;
+					if (!Config.ENCHANT_CHANCE_WEAPON_LIST.isEmpty())
+					{for (Integer listChance : Config.ENCHANT_CHANCE_WEAPON_LIST.values())
+						{if (Config.ENCHANT_CHANCE_WEAPON_LIST.containsKey(item.getEnchantLevel()+1))
+							{ chance = listChance;}
+							else chance = Config.ENCHANT_CHANCE_WEAPON;
+						}
+					}
+					else chance = Config.ENCHANT_CHANCE_WEAPON;		
					break;
				}
			}
@@ -223,7 +230,14 @@
			{
				if (scroll.getItemId() == scrollId)
				{
-					chance = Config.ENCHANT_CHANCE_WEAPON_BLESSED;
+					if (!Config.BLESSED_ENCHANT_CHANCE_WEAPON_LIST.isEmpty())
+					{for (Integer listChance : Config.BLESSED_ENCHANT_CHANCE_WEAPON_LIST.values())
+						{if (Config.BLESSED_ENCHANT_CHANCE_WEAPON_LIST.containsKey(item.getEnchantLevel()+1))
+							{ chance = listChance;}
+							else chance = Config.ENCHANT_CHANCE_WEAPON_BLESSED;
+						}
+					}
+					else chance = Config.ENCHANT_CHANCE_WEAPON_BLESSED;		
					break;
				}
			}
@@ -235,7 +249,14 @@
			{
				if (scroll.getItemId() == scrollId)
				{
-					chance = Config.ENCHANT_CHANCE_ARMOR;
+					if (!Config.ENCHANT_CHANCE_ARMOR_LIST.isEmpty())
+					{for (Integer listChance : Config.ENCHANT_CHANCE_ARMOR_LIST.values())
+						{if (Config.ENCHANT_CHANCE_ARMOR_LIST.containsKey(item.getEnchantLevel()+1))
+							{ chance = listChance;}
+							else chance = Config.ENCHANT_CHANCE_ARMOR;
+						}
+					}
+					else chance = Config.ENCHANT_CHANCE_ARMOR;
					break;
				}
			}
@@ -251,7 +272,14 @@
			{
				if (scroll.getItemId() == scrollId)
				{
-					chance = Config.ENCHANT_CHANCE_ARMOR_BLESSED;
+					if (!Config.BLESSED_ENCHANT_CHANCE_ARMOR_LIST.isEmpty())
+					{for (Integer listChance : Config.BLESSED_ENCHANT_CHANCE_ARMOR_LIST.values())
+						{if (Config.BLESSED_ENCHANT_CHANCE_ARMOR_LIST.containsKey(item.getEnchantLevel()+1))
+							{ chance = listChance;}
+							else chance = Config.ENCHANT_CHANCE_ARMOR_BLESSED;
+						}
+					}
+					else chance = Config.ENCHANT_CHANCE_ARMOR_BLESSED;
					break;
				}
			}
@@ -262,7 +290,14 @@
			{
				if (scroll.getItemId() == scrollId)
				{
-					chance = Config.ENCHANT_CHANCE_JEWELRY;
+					if (!Config.ENCHANT_CHANCE_JEWELRY_LIST.isEmpty())
+					{for (Integer listChance : Config.ENCHANT_CHANCE_JEWELRY_LIST.values())
+						{if (Config.ENCHANT_CHANCE_JEWELRY_LIST.containsKey(item.getEnchantLevel()+1))
+							{ chance = listChance;}
+							else chance = Config.ENCHANT_CHANCE_JEWELRY;
+						}
+					}
+					else chance = Config.ENCHANT_CHANCE_JEWELRY;	
					break;
				}
			}
@@ -278,7 +313,14 @@
			{
				if (scroll.getItemId() == scrollId)
				{
-					chance = Config.ENCHANT_CHANCE_JEWELRY_BLESSED;
+					if (!Config.BLESSED_ENCHANT_CHANCE_JEWELRY_LIST.isEmpty())
+					{for (Integer listChance : Config.BLESSED_ENCHANT_CHANCE_JEWELRY_LIST.values())
+						{if (Config.BLESSED_ENCHANT_CHANCE_JEWELRY_LIST.containsKey(item.getEnchantLevel()+1))
+							{ chance = listChance;}
+							else chance = Config.ENCHANT_CHANCE_JEWELRY_BLESSED;
+						}
+					}
+					else chance = Config.ENCHANT_CHANCE_JEWELRY_BLESSED;	
					break;
				}
			}
Index: config/other.properties
===================================================================
--- config/other.properties	(revision 341)
+++ config/other.properties	(working copy)
@@ -61,7 +61,30 @@
EnchantChanceArmorBlessed = 100
EnchantChanceJewelryBlessed = 100

+# This is a list where you define different enchant chance on different enchant levels
+# Format: enchantLevel1,enchantChance1;enchantLevel2,enchantChance2...
+# Example: 
+#	The "\"indicates new line, and is only set for formating purposes.
+#	EnchantChanceWeaponList = 4,90;5,80;6,75;7,70;8,65;\
+#	9,60;10,50;11,20;12,10;13,50;14,25;15,20
+#	No ";" or ";\" at the end
+# So, if the enchant chance for +15 is set to 30%, the enchanter will have 30%
+# chance to enchant the weapon from +14 to +15
+# If a specific enchant level isnt described in the list, or the list is empty,
+# the chance will be the one set at default configs
+# (ex. EnchantChanceWeapon = ?? / EnchantChanceArmor = ?? / EnchantChanceJewelry = ??)
+# So if you miss in the list for example, +15 for weapon, the chance will be
+# the one set at EnchantChanceWeapon (BlessedEnchantChanceWeapon for blessed)
+EnchantChanceWeaponList =
+EnchantChanceArmorList =
+EnchantChanceJewelryList =

+BlessedEnchantChanceWeaponList = 
+BlessedEnchantChanceArmorList = 
+BlessedEnchantChanceJewelryList = 
+
+
+
# Enchant limit [default = 0 (unlimited)]
# EnchantMaxAllowe is if any player has bigger enchant gets banned. EnchantMax is what max value can be put by scrols.
EnchantMaxAllowedWeapon = 65535

Posted

I do such codes when im bored, and i make em with the point to learn more and more about codding...

The only thing motivating me to share my work with you is that you appreciate it ^^

Im open for more ideas to improve this system

Guest
This topic is now closed to further replies.


  • Posts

    • Our sales are ongoing. Bump. 08 July 2025 Telegram: ContactDiscordAccS
    • Hi there, I am interested. How can I contact you?
    • Server Hardware Configuration:   Recommended Configuration: CPU i7 with 3.0GHz frequency, 6 cores or more, solid-state drive, 16GB RAM or more. Recommended to use Experience Mode for gaming with no less than 1000 FakePlayers on the server. For optimal gaming experience, FakePlayer levels in Immersive Mode need to be higher than the script requirements. Siege War: Clan members must be level 40 or above to run siege war scripts. Olympics: Must be level 76 or above to run Olympics scripts.   Game Mode Introduction:   Immersive Mode: FakePlayers start from level 1, simulating real player growth paths, suitable for nostalgic and new players. Experience Mode: FakePlayers are randomly assigned levels 1-85, with fixed levels, suitable for quick game experience or veteran players revisiting classics. Mode Switching Guide: Default setting is Experience Mode. To switch to Immersive Mode, edit the GameMode item in \gameserver\config\jf_config.properties file, changing the value from True to False.   Clan System Features:   FakePlayers automatically create and manage clans, supporting player declarations of war against them. Automatically identifies enemy clans and organizes teams for battle. Players can easily manage clan members through custom commands, including teaming, summoning, resting, and other functions.   Classes and Custom Commands:   Considering the single-player environment, some classes have been merged and optimized, such as Bard, Support, and Dwarf classes. FakePlayers automatically utilize fashion, vehicles, transformation, and bracelet systems to enhance game diversity. Provides rich custom commands such as .RandomTeam, .SummonTeammate, etc., enhancing interaction between players and FakePlayers.   Activity Participation:   FakePlayers can automatically join TVT battles, GVG competitions, CtF capture the flag, and other exciting activities, providing players with rich gaming experiences.   Siege War Instructions: In the GM menu, you can apply, withdraw, and teleport to castle-related maps.When it's not siege event time, you can manually start siege wars.   FakePlayer siege behavior is controlled by scripts. During sieges, you can form regular teams and alliance teams, but cannot form clan teams or use clan summoning commands.   Siege Time Settings:   Siege application deadline modified to 5 minutes before registration closes. Siege duration changed from 2 hours to 30 minutes. Next siege time after siege ends adjusted to once per week. After FakePlayers obtain castle ownership, they automatically announce the next siege time as the nearest Sunday around 8 PM. When real players obtain castles, they need to manually set the next siege time or use default time.   Siege War Process: FakePlayers automatically apply for sieges, automatically conduct siege activities every Sunday and obtain castle ownership.   When castle is initially owned by NPCs: When there's only 1 attacking clan, obtaining the castle seal ends the siege war. When there are 2 or more attacking parties, in the first attack, attacking clans automatically form temporary alliances, players won't be selected and won't attack alliance members. After one party successfully seals, enters castle ownership alternation phase. Temporary alliance dissolves, battlefield transforms to full attack state where both attackers and defenders can attack each other. When castle is initially owned by FakePlayer clans or real players: After obtaining castle seal, enters castle ownership alternation phase.   Olympics Competition Instructions: Default activity time is daily from 18:00 to 00:00 the next day. Can be activated through GM console outside time periods.Non-time period activation method: GM console > Olympics > Start Olympics   Players must be nobles in main class state to participate in Olympics. FakePlayers automatically obtain noble status when participating in Olympics. Recommended to enable script control, this setting allows FakePlayers to automatically register for Olympics to generate real FakePlayer Olympics data. Setting activation: jf_config.properties --> lines 314, 321, 328. After players register for classless, individual class, and unlimited team competitions, FakePlayers and FakePlayer teams will automatically be generated for companionship. Scoring rules are consistent with official servers. Olympics runs monthly cycles, with settlement days on the 1st and 15th of each month. At cycle end, FakePlayers automatically apply to become heroes, players need to manually perform hero certification to become heroes.   Update Notes:   Optimized team system, fixed abnormal teammate name issues. GM console element enhancement menu fully localized, more convenient operation. Game mode switching simplified, one-click switching between Immersive and Experience modes. Reduced FakePlayer server-wide chat frequency, creating a more harmonious gaming environment. FakePlayer AI logic fully upgraded, reducing lag phenomena and improving game fluidity. FakePlayer clan joining events optimized, manual clan invitation function fixed. Introduced FakePlayer 1V1 duel system, enhancing combat fun. Integrated simple auto-assist system, optimizing game experience. Activated automatic potion supply function, reducing player operation burden. Implemented alliance and federation construction between real players and FakePlayers. FakePlayers automatically join team waiting queues, enhancing social interaction. Added FakePlayer private shops, enriching the trading system. Bulletin board built-in auction house upgrade, FakePlayers sell high-level items, players can also list items, FakePlayers randomly purchase. Opened some advanced dungeons accessible to FakePlayers, including Purgatory Abyss series, Immortal/Destruction/Annihilation Seed dungeons and multiple classic maps. Added normal boss respawn time settings Fixed new character Chinese title garbled text Fixed character shop setup not leveling Fixed TVT activity score anomalies In Experience Mode, teaming with FakePlayers modified to: FakePlayers normally gain experience and level up Fixed bug where FakePlayer accessories couldn't be completely replaced in Immersive Mode Fixed some issues with wild FakePlayers not fighting back Fixed bug where FakePlayers could still attack normally when under fear or loss of control debuff states Added Divine Knight FakePlayer class summoning small undead bird skill Optimized Knight class third job skill usage Optimized FakePlayer Wizard class combat logic in Olympics events Fixed Hero "one sentence" function Fixed bug where units couldn't be assigned when inviting FakePlayers to join clan Fixed bug of attacking wild BOSS followers while AFK Fixed bug of FakePlayers attacking wild BOSS followers when not AFK Fixed VIP member system Optimized Knight team combat logic Corrected boss teleport point confusion FakePlayers can enter "4 Cups" dungeon without restrictions "4 Cups" series quest localization corrections FakePlayers can enter Small Baium dungeon without restrictions Fixed alliance channel teammate auto-leaving bug Fixed alliance channel summon attacking teammates bug Fixed alliance channel code recursive infinite loop bug under certain probability Added alliance channel FakePlayer death resurrection script Fixed bug where FakePlayers could only equip S80 equipment at maximum Added custom FakePlayer crafting workshop and private shop (MS system) - see detailed instructions Added FakePlayer generation speed and initial level settings for Experience and Immersive modes Optimized database connections, breaking through 3000 player limit Fixed bug of wild same-clan FakePlayers fighting each other Siege War (test) real player difficulty appropriately increased Added Arrogance, Forge, Monastery, Imperial Tomb, Dragon Valley, various tombs, temples and other FakePlayer leveling maps, thanks to: TaoXiaoSan Quest testing and htm localization corrections, thanks to: Floating Cloud To reduce server burden, temporarily disabled FakePlayer item pickup function (won't update data but still has pickup actions) Modified auction house listing item logic (whether to close this service?) Fixed TVT, GVG, Ctf, LastHero, team events conflicting with siege events and Olympics bugs Added robot chat interface (private chat only) Added Dwarf race summoning robot Golem (non-siege) Reconstructed FakePlayer resurrection logic Restored in-game item shop When team hunting BOSS, Priest classes only provide healing services, debuff usage probability increased Opened FakePlayer equipment enhancement custom permissions Added server FakePlayer clan quantity settings   Download   Note: This LineageII l2jserver is not fully English!!!  
    • Server Hardware Configuration:   Recommended Configuration: CPU i7 with 3.0GHz frequency, 6 cores or more, solid-state drive, 16GB RAM or more. Recommended to use Experience Mode for gaming with no less than 1000 FakePlayers on the server. For optimal gaming experience, FakePlayer levels in Immersive Mode need to be higher than the script requirements. Siege War: Clan members must be level 40 or above to run siege war scripts. Olympics: Must be level 76 or above to run Olympics scripts.   Game Mode Introduction:   Immersive Mode: FakePlayers start from level 1, simulating real player growth paths, suitable for nostalgic and new players. Experience Mode: FakePlayers are randomly assigned levels 1-85, with fixed levels, suitable for quick game experience or veteran players revisiting classics. Mode Switching Guide: Default setting is Experience Mode. To switch to Immersive Mode, edit the GameMode item in \gameserver\config\jf_config.properties file, changing the value from True to False.   Clan System Features:   FakePlayers automatically create and manage clans, supporting player declarations of war against them. Automatically identifies enemy clans and organizes teams for battle. Players can easily manage clan members through custom commands, including teaming, summoning, resting, and other functions.   Classes and Custom Commands:   Considering the single-player environment, some classes have been merged and optimized, such as Bard, Support, and Dwarf classes. FakePlayers automatically utilize fashion, vehicles, transformation, and bracelet systems to enhance game diversity. Provides rich custom commands such as .RandomTeam, .SummonTeammate, etc., enhancing interaction between players and FakePlayers.   Activity Participation:   FakePlayers can automatically join TVT battles, GVG competitions, CtF capture the flag, and other exciting activities, providing players with rich gaming experiences.   Siege War Instructions: In the GM menu, you can apply, withdraw, and teleport to castle-related maps.When it's not siege event time, you can manually start siege wars.   FakePlayer siege behavior is controlled by scripts. During sieges, you can form regular teams and alliance teams, but cannot form clan teams or use clan summoning commands.   Siege Time Settings:   Siege application deadline modified to 5 minutes before registration closes. Siege duration changed from 2 hours to 30 minutes. Next siege time after siege ends adjusted to once per week. After FakePlayers obtain castle ownership, they automatically announce the next siege time as the nearest Sunday around 8 PM. When real players obtain castles, they need to manually set the next siege time or use default time.   Siege War Process: FakePlayers automatically apply for sieges, automatically conduct siege activities every Sunday and obtain castle ownership.   When castle is initially owned by NPCs: When there's only 1 attacking clan, obtaining the castle seal ends the siege war. When there are 2 or more attacking parties, in the first attack, attacking clans automatically form temporary alliances, players won't be selected and won't attack alliance members. After one party successfully seals, enters castle ownership alternation phase. Temporary alliance dissolves, battlefield transforms to full attack state where both attackers and defenders can attack each other. When castle is initially owned by FakePlayer clans or real players: After obtaining castle seal, enters castle ownership alternation phase.   Olympics Competition Instructions: Default activity time is daily from 18:00 to 00:00 the next day. Can be activated through GM console outside time periods.Non-time period activation method: GM console > Olympics > Start Olympics   Players must be nobles in main class state to participate in Olympics. FakePlayers automatically obtain noble status when participating in Olympics. Recommended to enable script control, this setting allows FakePlayers to automatically register for Olympics to generate real FakePlayer Olympics data. Setting activation: jf_config.properties --> lines 314, 321, 328. After players register for classless, individual class, and unlimited team competitions, FakePlayers and FakePlayer teams will automatically be generated for companionship. Scoring rules are consistent with official servers. Olympics runs monthly cycles, with settlement days on the 1st and 15th of each month. At cycle end, FakePlayers automatically apply to become heroes, players need to manually perform hero certification to become heroes.   Update Notes:   Optimized team system, fixed abnormal teammate name issues. GM console element enhancement menu fully localized, more convenient operation. Game mode switching simplified, one-click switching between Immersive and Experience modes. Reduced FakePlayer server-wide chat frequency, creating a more harmonious gaming environment. FakePlayer AI logic fully upgraded, reducing lag phenomena and improving game fluidity. FakePlayer clan joining events optimized, manual clan invitation function fixed. Introduced FakePlayer 1V1 duel system, enhancing combat fun. Integrated simple auto-assist system, optimizing game experience. Activated automatic potion supply function, reducing player operation burden. Implemented alliance and federation construction between real players and FakePlayers. FakePlayers automatically join team waiting queues, enhancing social interaction. Added FakePlayer private shops, enriching the trading system. Bulletin board built-in auction house upgrade, FakePlayers sell high-level items, players can also list items, FakePlayers randomly purchase. Opened some advanced dungeons accessible to FakePlayers, including Purgatory Abyss series, Immortal/Destruction/Annihilation Seed dungeons and multiple classic maps. Added normal boss respawn time settings Fixed new character Chinese title garbled text Fixed character shop setup not leveling Fixed TVT activity score anomalies In Experience Mode, teaming with FakePlayers modified to: FakePlayers normally gain experience and level up Fixed bug where FakePlayer accessories couldn't be completely replaced in Immersive Mode Fixed some issues with wild FakePlayers not fighting back Fixed bug where FakePlayers could still attack normally when under fear or loss of control debuff states Added Divine Knight FakePlayer class summoning small undead bird skill Optimized Knight class third job skill usage Optimized FakePlayer Wizard class combat logic in Olympics events Fixed Hero "one sentence" function Fixed bug where units couldn't be assigned when inviting FakePlayers to join clan Fixed bug of attacking wild BOSS followers while AFK Fixed bug of FakePlayers attacking wild BOSS followers when not AFK Fixed VIP member system Optimized Knight team combat logic Corrected boss teleport point confusion FakePlayers can enter "4 Cups" dungeon without restrictions "4 Cups" series quest localization corrections FakePlayers can enter Small Baium dungeon without restrictions Fixed alliance channel teammate auto-leaving bug Fixed alliance channel summon attacking teammates bug Fixed alliance channel code recursive infinite loop bug under certain probability Added alliance channel FakePlayer death resurrection script Fixed bug where FakePlayers could only equip S80 equipment at maximum Added custom FakePlayer crafting workshop and private shop (MS system) - see detailed instructions Added FakePlayer generation speed and initial level settings for Experience and Immersive modes Optimized database connections, breaking through 3000 player limit Fixed bug of wild same-clan FakePlayers fighting each other Siege War (test) real player difficulty appropriately increased Added Arrogance, Forge, Monastery, Imperial Tomb, Dragon Valley, various tombs, temples and other FakePlayer leveling maps, thanks to: TaoXiaoSan Quest testing and htm localization corrections, thanks to: Floating Cloud To reduce server burden, temporarily disabled FakePlayer item pickup function (won't update data but still has pickup actions) Modified auction house listing item logic (whether to close this service?) Fixed TVT, GVG, Ctf, LastHero, team events conflicting with siege events and Olympics bugs Added robot chat interface (private chat only) Added Dwarf race summoning robot Golem (non-siege) Reconstructed FakePlayer resurrection logic Restored in-game item shop When team hunting BOSS, Priest classes only provide healing services, debuff usage probability increased Opened FakePlayer equipment enhancement custom permissions Added server FakePlayer clan quantity settings   Download   Note: This LineageII l2jserver is not fully English!!!
    • if you are sending him clients i have no words mate that means you know him.
  • 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