浏览代码

BETA: Enchant system rework max enchant and enchant rate are moved from configs to DP (dist/game/data/enchantData.xml)
More info http://www.l2jserver.com/forum/viewtopic.php?f=69&t=23983

Rumen Nikiforov 13 年之前
父节点
当前提交
3103b40593

+ 0 - 17
L2J_Server_BETA/dist/game/config/Character.properties

@@ -368,28 +368,11 @@ NpcTalkBlockingTime = 3
 # This controls the chance an item has to break if it is enchanted.
 # This chance is in %, so if you set this to 100%, enchants will always succeed.
 # DEFAULT NEEDS TO BE VERIFIED, MUST BE CHANGED HERE AND IN CONFIG.JAVA IF NOT CORRECT
-# Default: 66,66,66
-EnchantChanceWeapon = 66
-EnchantChanceArmor = 66
-EnchantChanceJewelry = 66
 EnchantChanceElementStone = 50
 EnchantChanceElementCrystal = 30
 EnchantChanceElementJewel = 20
 EnchantChanceElementEnergy = 10
 
-# DEFAULT NEEDS TO BE VERIFIED, MUST BE CHANGED HERE AND IN CONFIG.JAVA IF NOT CORRECT
-# Default: 66,66,66
-BlessedEnchantChanceWeapon = 66
-BlessedEnchantChanceArmor = 66
-BlessedEnchantChanceJewelry = 66
-
-# 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
-EnchantMaxWeapon = 0
-EnchantMaxArmor = 0
-EnchantMaxJewelry = 0
-
 # This is the maximum safe enchant.
 # Notes:
 #	If EnchantSafeMax is set to for 8 the item will be safely enchanted to 8 regardless of the max enchant value set above.

+ 8 - 32
L2J_Server_BETA/java/com/l2jserver/Config.java

@@ -1003,19 +1003,10 @@ public final class Config
 	}
 	public static ObjectMapType MAP_TYPE;
 	public static ObjectSetType SET_TYPE;
-	public static int ENCHANT_CHANCE_WEAPON;
-	public static int ENCHANT_CHANCE_ARMOR;
-	public static int ENCHANT_CHANCE_JEWELRY;
-	public static int ENCHANT_CHANCE_ELEMENT_STONE;
-	public static int ENCHANT_CHANCE_ELEMENT_CRYSTAL;
-	public static int ENCHANT_CHANCE_ELEMENT_JEWEL;
-	public static int ENCHANT_CHANCE_ELEMENT_ENERGY;
-	public static int BLESSED_ENCHANT_CHANCE_WEAPON;
-	public static int BLESSED_ENCHANT_CHANCE_ARMOR;
-	public static int BLESSED_ENCHANT_CHANCE_JEWELRY;
-	public static int ENCHANT_MAX_WEAPON;
-	public static int ENCHANT_MAX_ARMOR;
-	public static int ENCHANT_MAX_JEWELRY;
+	public static double ENCHANT_CHANCE_ELEMENT_STONE;
+	public static double ENCHANT_CHANCE_ELEMENT_CRYSTAL;
+	public static double ENCHANT_CHANCE_ELEMENT_JEWEL;
+	public static double ENCHANT_CHANCE_ELEMENT_ENERGY;
 	public static int ENCHANT_SAFE_MAX;
 	public static int ENCHANT_SAFE_MAX_FULL;
 	public static int[] ENCHANT_BLACKLIST;
@@ -1640,19 +1631,10 @@ public final class Config
 					WAREHOUSE_SLOTS_CLAN = Integer.parseInt(Character.getProperty("MaximumWarehouseSlotsForClan", "150"));
 					ALT_FREIGHT_SLOTS = Integer.parseInt(Character.getProperty("MaximumFreightSlots", "200"));
 					ALT_FREIGHT_PRIECE = Integer.parseInt(Character.getProperty("FreightPriece", "1000"));
-					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"));
-					ENCHANT_CHANCE_ELEMENT_STONE = Integer.parseInt(Character.getProperty("EnchantChanceElementStone", "50"));
-					ENCHANT_CHANCE_ELEMENT_CRYSTAL = Integer.parseInt(Character.getProperty("EnchantChanceElementCrystal", "30"));
-					ENCHANT_CHANCE_ELEMENT_JEWEL = Integer.parseInt(Character.getProperty("EnchantChanceElementJewel", "20"));
-					ENCHANT_CHANCE_ELEMENT_ENERGY = Integer.parseInt(Character.getProperty("EnchantChanceElementEnergy", "10"));
-					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"));
-					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"));
+					ENCHANT_CHANCE_ELEMENT_STONE = Double.parseDouble(Character.getProperty("EnchantChanceElementStone", "50"));
+					ENCHANT_CHANCE_ELEMENT_CRYSTAL = Double.parseDouble(Character.getProperty("EnchantChanceElementCrystal", "30"));
+					ENCHANT_CHANCE_ELEMENT_JEWEL = Double.parseDouble(Character.getProperty("EnchantChanceElementJewel", "20"));
+					ENCHANT_CHANCE_ELEMENT_ENERGY = Double.parseDouble(Character.getProperty("EnchantChanceElementEnergy", "10"));
 					ENCHANT_SAFE_MAX = Integer.parseInt(Character.getProperty("EnchantSafeMax", "3"));
 					ENCHANT_SAFE_MAX_FULL = Integer.parseInt(Character.getProperty("EnchantSafeMaxFull", "4"));
 					String[] notenchantable = Character.getProperty("EnchantBlackList","7816,7817,7818,7819,7820,7821,7822,7823,7824,7825,7826,7827,7828,7829,7830,7831,13293,13294,13296").split(",");
@@ -3250,16 +3232,10 @@ public final class Config
 		else if (pName.equalsIgnoreCase("MaximumWarehouseSlotsForDwarf")) WAREHOUSE_SLOTS_DWARF = Integer.parseInt(pValue);
 		else if (pName.equalsIgnoreCase("MaximumWarehouseSlotsForClan")) WAREHOUSE_SLOTS_CLAN = Integer.parseInt(pValue);
 		
-		else if (pName.equalsIgnoreCase("EnchantChanceWeapon")) ENCHANT_CHANCE_WEAPON = Integer.parseInt(pValue);
-		else if (pName.equalsIgnoreCase("EnchantChanceArmor")) ENCHANT_CHANCE_ARMOR = Integer.parseInt(pValue);
-		else if (pName.equalsIgnoreCase("EnchantChanceJewelry")) ENCHANT_CHANCE_JEWELRY = Integer.parseInt(pValue);
 		else if (pName.equalsIgnoreCase("EnchantChanceElementStone")) ENCHANT_CHANCE_ELEMENT_STONE = Integer.parseInt(pValue);
 		else if (pName.equalsIgnoreCase("EnchantChanceElementCrystal")) ENCHANT_CHANCE_ELEMENT_CRYSTAL = Integer.parseInt(pValue);
 		else if (pName.equalsIgnoreCase("EnchantChanceElementJewel")) ENCHANT_CHANCE_ELEMENT_JEWEL = Integer.parseInt(pValue);
 		else if (pName.equalsIgnoreCase("EnchantChanceElementEnergy")) ENCHANT_CHANCE_ELEMENT_ENERGY = Integer.parseInt(pValue);
-		else if (pName.equalsIgnoreCase("EnchantMaxWeapon")) ENCHANT_MAX_WEAPON = Integer.parseInt(pValue);
-		else if (pName.equalsIgnoreCase("EnchantMaxArmor")) ENCHANT_MAX_ARMOR = Integer.parseInt(pValue);
-		else if (pName.equalsIgnoreCase("EnchantMaxJewelry")) ENCHANT_MAX_JEWELRY = Integer.parseInt(pValue);
 		else if (pName.equalsIgnoreCase("EnchantSafeMax")) ENCHANT_SAFE_MAX = Integer.parseInt(pValue);
 		else if (pName.equalsIgnoreCase("EnchantSafeMaxFull")) ENCHANT_SAFE_MAX_FULL = Integer.parseInt(pValue);
 		

+ 2 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/GameServer.java

@@ -46,6 +46,7 @@ import com.l2jserver.gameserver.datatables.ClanTable;
 import com.l2jserver.gameserver.datatables.DoorTable;
 import com.l2jserver.gameserver.datatables.EnchantGroupsTable;
 import com.l2jserver.gameserver.datatables.EnchantHPBonusData;
+import com.l2jserver.gameserver.datatables.EnchantItemTable;
 import com.l2jserver.gameserver.datatables.EventDroplist;
 import com.l2jserver.gameserver.datatables.ExperienceTable;
 import com.l2jserver.gameserver.datatables.FishTable;
@@ -225,6 +226,7 @@ public class GameServer
 		
 		printSection("Items");
 		ItemTable.getInstance();
+		EnchantItemTable.getInstance();
 		SummonItemsData.getInstance();
 		EnchantHPBonusData.getInstance();
 		MerchantPriceConfigTable.getInstance().loadInstances();

+ 289 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/EnchantItemTable.java

@@ -0,0 +1,289 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.datatables;
+
+import gnu.trove.map.hash.TIntObjectHashMap;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.model.EnchantItem;
+import com.l2jserver.gameserver.model.EnchantScroll;
+import com.l2jserver.gameserver.model.item.L2Item;
+import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
+
+
+/**
+ * @author UnAfraid
+ *
+ */
+public class EnchantItemTable
+{
+	private static final Logger _log = Logger.getLogger(EnchantItemTable.class.getName());
+	
+	public final TIntObjectHashMap<EnchantScroll> _scrolls;
+	public final TIntObjectHashMap<EnchantItem> _supports;
+	
+	public EnchantItemTable()
+	{
+		_scrolls = new TIntObjectHashMap<EnchantScroll>();
+		_supports = new TIntObjectHashMap<EnchantItem>();
+		
+		load();
+	}
+	
+	public void load()
+	{
+		try
+		{
+			_scrolls.clear();
+			_supports.clear();
+			
+			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+			factory.setValidating(false);
+			factory.setIgnoringComments(true);
+			
+			File file = new File(Config.DATAPACK_ROOT + "/data/enchantData.xml");
+			if (!file.exists())
+			{
+				_log.log(Level.WARNING, "[" + getClass().getSimpleName() + "] File is missing " + Config.DATAPACK_ROOT + "/data/enchantData.xml !");
+				return;
+			}
+			
+			Document doc = factory.newDocumentBuilder().parse(file);
+			Node first = doc.getFirstChild();
+			if (first != null && "list".equalsIgnoreCase(first.getNodeName()))
+			{
+				for (Node n = first.getFirstChild(); n != null; n = n.getNextSibling())
+				{
+					if ("enchant".equalsIgnoreCase(n.getNodeName()))
+					{
+						int scrollId = 0;
+						boolean isWeapon = true;
+						boolean isBlessed = false;
+						boolean isCrystal = false;
+						boolean isSafe = false;
+						int type = L2Item.CRYSTAL_NONE;
+						int maxEnchant = 0;
+						double chance = 66.66;
+						int[] items = null;
+						
+						NamedNodeMap attrs = n.getAttributes();
+						Node att = attrs.getNamedItem("id");
+						
+						if (att == null)
+						{
+							_log.log(Level.WARNING, "[" + getClass().getSimpleName() + "] Missing Enchant id, skipping");
+							continue;
+						}
+						scrollId = Integer.parseInt(att.getNodeValue());
+						
+						att = attrs.getNamedItem("isWeapon");
+						if (att != null)
+						{
+							isWeapon = Boolean.parseBoolean(att.getNodeValue());
+						}
+						
+						att = attrs.getNamedItem("isBlessed");
+						if (att != null)
+						{
+							isBlessed = Boolean.parseBoolean(att.getNodeValue());
+						}
+						
+						att = attrs.getNamedItem("isCrystal");
+						if (att != null)
+						{
+							isCrystal = Boolean.parseBoolean(att.getNodeValue());
+						}
+						
+						att = attrs.getNamedItem("isSafe");
+						if (att != null)
+						{
+							isSafe = Boolean.parseBoolean(att.getNodeValue());
+						}
+						
+						att = attrs.getNamedItem("targetGrade");
+						if (att != null)
+						{
+							type = ItemTable._crystalTypes.get(att.getNodeValue());
+						}
+						
+						att = attrs.getNamedItem("maxEnchant");
+						if (att != null)
+						{
+							maxEnchant = Integer.parseInt(att.getNodeValue());
+						}
+						
+						att = attrs.getNamedItem("successRate");
+						if (att != null)
+						{
+							chance = Double.parseDouble(att.getNodeValue());
+							chance = Math.max(chance, 1.0); // Enchant bonus cannot be below 1.0
+						}
+						
+						List<Integer> itemz = new ArrayList<Integer>();
+						
+						for (Node cd = n.getFirstChild(); cd != null; cd = cd.getNextSibling())
+						{
+							if ("item".equalsIgnoreCase(cd.getNodeName()))
+							{
+								att = cd.getAttributes().getNamedItem("id");
+								if (itemz != null)
+									itemz.add(Integer.parseInt(att.getNodeValue()));
+								else
+								{
+									_log.log(Level.WARNING, "[" + getClass().getSimpleName() + "] Missing Item id, skipping");
+									continue;
+								}
+							}
+						}
+						
+						if (itemz.size() > 0)
+						{
+							items = new int[itemz.size()];
+							int i = 0;
+							for (Integer id : itemz)
+							{
+								items[i++] = id;
+							}
+							Arrays.sort(items);
+						}
+						
+						_scrolls.put(scrollId, new EnchantScroll(isWeapon, isBlessed, isCrystal, isSafe, type, maxEnchant, chance, items));
+					}
+					else if ("support".equalsIgnoreCase(n.getNodeName()))
+					{
+						int scrollId = 0;
+						boolean isWeapon = true;
+						int type = L2Item.CRYSTAL_NONE;
+						int maxEnchant = 0;
+						double chance = 1.0;
+						int[] items = null;
+						NamedNodeMap attrs = n.getAttributes();
+						Node att = attrs.getNamedItem("id");
+						
+						if (att == null)
+						{
+							_log.log(Level.WARNING, "[" + getClass().getSimpleName() + "] Missing Support id, skipping");
+							continue;
+						}
+						scrollId = Integer.parseInt(att.getNodeValue());
+						
+						att = attrs.getNamedItem("isWeapon");
+						if (att != null)
+						{
+							isWeapon = Boolean.parseBoolean(att.getNodeValue());
+						}
+						
+						att = attrs.getNamedItem("targetGrade");
+						if (att != null)
+						{
+							type = ItemTable._crystalTypes.get(att.getNodeValue());
+						}
+						
+						att = attrs.getNamedItem("maxEnchant");
+						if (att != null)
+						{
+							maxEnchant = Integer.parseInt(att.getNodeValue());
+						}
+						
+						att = attrs.getNamedItem("successBonus");
+						if (att != null)
+						{
+							chance = Double.parseDouble(att.getNodeValue());
+							chance = Math.max(chance, 1.0); // Enchant bonus cannot be below 1.0
+						}
+						
+						List<Integer> itemz = new ArrayList<Integer>();
+						
+						for (Node cd = n.getFirstChild(); cd != null; cd = cd.getNextSibling())
+						{
+							if ("item".equalsIgnoreCase(cd.getNodeName()))
+							{
+								att = cd.getAttributes().getNamedItem("id");
+								if (itemz != null)
+									itemz.add(Integer.parseInt(att.getNodeValue()));
+								else
+								{
+									_log.log(Level.WARNING, "[" + getClass().getSimpleName() + "] Missing Item id, skipping");
+									continue;
+								}
+							}
+						}
+						
+						if (itemz.size() > 0)
+						{
+							items = new int[itemz.size()];
+							int i = 0;
+							for (Integer id : itemz)
+							{
+								items[i++] = id;
+							}
+							Arrays.sort(items);
+						}
+						_supports.put(scrollId, new EnchantItem(isWeapon, type, maxEnchant, chance, items));
+					}
+				}
+			}
+		}
+		catch (Exception e)
+		{
+			_log.log(Level.WARNING, "[" + getClass().getSimpleName() + "] Failed to parse xml: " + e.getMessage(), e);
+		}
+		
+		_log.info(getClass().getSimpleName() + ": Loaded " + _scrolls.size() + " Enchant Scrolls");
+		_log.info(getClass().getSimpleName() + ": Loaded " + _supports.size() + " Support Items");
+	}
+	
+	/**
+	 * @param scroll 
+	 * @return enchant template for scroll
+	 */
+	public final EnchantScroll getEnchantScroll(L2ItemInstance scroll)
+	{
+		return _scrolls.get(scroll.getItemId());
+	}
+	
+	/**
+	 * @param item 
+	 * @return enchant template for support item
+	 */
+	public final EnchantItem getSupportItem(L2ItemInstance item)
+	{
+		return _supports.get(item.getItemId());
+	}
+	
+	public static final EnchantItemTable getInstance()
+	{
+		return SingletonHolder._instance;
+	}
+	
+	@SuppressWarnings("synthetic-access")
+	private static class SingletonHolder
+	{
+		protected static final EnchantItemTable _instance = new EnchantItemTable();
+	}
+}

+ 95 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/EnchantItem.java

@@ -0,0 +1,95 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.model;
+
+import java.util.Arrays;
+
+import com.l2jserver.gameserver.model.item.L2Item;
+import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
+
+/**
+ * @author UnAfraid
+ */
+public class EnchantItem
+{
+	protected final boolean _isWeapon;
+	protected final int _grade;
+	protected final int _maxEnchantLevel;
+	protected final double _chanceAdd;
+	protected final int[] _itemIds;
+	
+	/**
+	 * @param wep
+	 * @param type
+	 * @param level
+	 * @param chance
+	 * @param items
+	 */
+	public EnchantItem(boolean wep, int type, int level, double chance, int[] items)
+	{
+		_isWeapon = wep;
+		_grade = type;
+		_maxEnchantLevel = level;
+		_chanceAdd = chance;
+		_itemIds = items;
+	}
+	
+	/**
+	 * @param enchantItem
+	 * @return true if support item can be used for this item
+	 */
+	public final boolean isValid(L2ItemInstance enchantItem)
+	{
+		if (enchantItem == null)
+			return false;
+		
+		else if (enchantItem.isEnchantable() == 0)
+			return false;
+		
+		else if (!isValidItemType(enchantItem.getItem().getType2()))
+			return false;
+
+		else if (_maxEnchantLevel != 0 && enchantItem.getEnchantLevel() >= _maxEnchantLevel)
+			return false;
+		
+		else if (_grade != enchantItem.getItem().getItemGradeSPlus())
+			return false;
+		
+		else if ((enchantItem.isEnchantable() > 1 && (_itemIds == null || Arrays.binarySearch(_itemIds, enchantItem.getItemId()) < 0)) || _itemIds != null && Arrays.binarySearch(_itemIds, enchantItem.getItemId()) < 0)
+			return false;
+				
+		return true;
+	}
+	
+	private boolean isValidItemType(int type2)
+	{
+		if (type2 == L2Item.TYPE2_WEAPON)
+		{
+			return _isWeapon;
+		}
+		else if (type2 == L2Item.TYPE2_SHIELD_ARMOR || type2 == L2Item.TYPE2_ACCESSORY)
+		{
+			return !_isWeapon;
+		}
+		return false;
+	}
+	/**
+	 * @return chance increase
+	 */
+	public final double getChanceAdd()
+	{
+		return _chanceAdd;
+	}
+}

+ 111 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/EnchantScroll.java

@@ -0,0 +1,111 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.model;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.model.item.L2Item;
+import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
+
+
+/**
+ * @author UnAfraid
+ *
+ */
+public class EnchantScroll extends EnchantItem
+{
+	private final boolean _isBlessed;
+	private final boolean _isCrystal;
+	private final boolean _isSafe;
+	
+	/**
+	 * @param wep
+	 * @param bless
+	 * @param crystal
+	 * @param safe
+	 * @param type
+	 * @param level
+	 * @param chance
+	 * @param items
+	 */
+	public EnchantScroll(boolean wep, boolean bless, boolean crystal, boolean safe, int type, int level, double chance, int[] items)
+	{
+		super(wep, type, level, chance, items);
+		
+		_isBlessed = bless;
+		_isCrystal = crystal;
+		_isSafe = safe;
+	}
+	
+	/**
+	 * @return true for blessed scrolls
+	 */
+	public final boolean isBlessed()
+	{
+		return _isBlessed;
+	}
+	
+	/**
+	 * @return true for crystal scrolls
+	 */
+	public final boolean isCrystal()
+	{
+		return _isCrystal;
+	}
+	
+	/**
+	 * @return true for safe-enchant scrolls (enchant level will remain on failure)
+	 */
+	public final boolean isSafe()
+	{
+		return _isSafe;
+	}
+	
+	/**
+	 * @param enchantItem
+	 * @param supportItem
+	 * @return
+	 */
+	public final boolean isValid(L2ItemInstance enchantItem, EnchantItem supportItem)
+	{
+		// blessed scrolls can't use support items
+		if (supportItem != null && (!supportItem.isValid(enchantItem) || isBlessed()))
+			return false;
+		
+		return super.isValid(enchantItem);
+	}
+	
+	/**
+	 * @param enchantItem
+	 * @param supportItem
+	 * @return
+	 */
+	public final double getChance(L2ItemInstance enchantItem, EnchantItem supportItem)
+	{
+		if (!isValid(enchantItem, supportItem))
+			return -1;
+		
+		boolean fullBody = enchantItem.getItem().getBodyPart() == L2Item.SLOT_FULL_ARMOR;
+		if (enchantItem.getEnchantLevel() < Config.ENCHANT_SAFE_MAX
+				|| (fullBody && enchantItem.getEnchantLevel() < Config.ENCHANT_SAFE_MAX_FULL))
+			return 100;
+		
+		double chance = _chanceAdd;
+		
+		if (supportItem != null && !_isBlessed)
+			chance *= supportItem.getChanceAdd();
+		
+		return chance;
+	}
+}

+ 4 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/model/item/L2Item.java

@@ -180,7 +180,7 @@ public abstract class L2Item
 	private final boolean _destroyable;
 	private final boolean _tradeable;
 	private final boolean _depositable;
-	private final boolean _enchantable;
+	private final int _enchantable;
 	private final boolean _elementable;
 	private final boolean _questItem;
 	private final boolean _freightable;
@@ -232,7 +232,7 @@ public abstract class L2Item
 		_tradeable = set.getBool("is_tradable", true);
 		_depositable = set.getBool("is_depositable", true);
 		_elementable = set.getBool("element_enabled", false);
-		_enchantable = set.getBool("enchant_enabled", false);
+		_enchantable = set.getInteger("enchant_enabled", 0);
 		_questItem = set.getBool("is_questitem", false);
 		_freightable = set.getBool("is_freightable", false);
 		_is_oly_restricted = set.getBool("is_oly_restricted", false);
@@ -629,9 +629,9 @@ public abstract class L2Item
 	 * This method also check the enchant blacklist.
 	 * @return {@code true} if the item can be enchanted, {@code false} otherwise.
 	 */
-	public final boolean isEnchantable()
+	public final int isEnchantable()
 	{
-		return _enchantable && Arrays.binarySearch(Config.ENCHANT_BLACKLIST, getItemId()) < 0;
+		return Arrays.binarySearch(Config.ENCHANT_BLACKLIST, getItemId()) < 0 ?  _enchantable : 0;
 	}
 	
 	/**

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/model/item/instance/L2ItemInstance.java

@@ -491,11 +491,11 @@ public final class L2ItemInstance extends L2Object
 	 * Return true if item can be enchanted
 	 * @return boolean
 	 */
-	public boolean isEnchantable()
+	public int isEnchantable()
 	{
 		if (getLocation() == ItemLocation.INVENTORY || getLocation() == ItemLocation.PAPERDOLL)
 			return getItem().isEnchantable();
-		return false;
+		return 0;
 	}
 	
 	/**

+ 0 - 364
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/AbstractEnchantPacket.java

@@ -1,364 +0,0 @@
-/*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- * 
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.network.clientpackets;
-
-import gnu.trove.map.hash.TIntObjectHashMap;
-
-import java.util.Arrays;
-
-import com.l2jserver.Config;
-import com.l2jserver.gameserver.model.item.L2Item;
-import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
-
-
-public abstract class AbstractEnchantPacket extends L2GameClientPacket
-{
-	
-	public static final TIntObjectHashMap<EnchantScroll> _scrolls = new TIntObjectHashMap<EnchantScroll>();
-	public static final TIntObjectHashMap<EnchantItem> _supports = new TIntObjectHashMap<EnchantItem>();
-	
-	public static class EnchantItem
-	{
-		protected final boolean _isWeapon;
-		protected final int _grade;
-		protected final int _maxEnchantLevel;
-		protected final int _chanceAdd;
-		protected final int[] _itemIds;
-		
-		/**
-		 * @param wep
-		 * @param type
-		 * @param level
-		 * @param chance
-		 * @param items
-		 */
-		public EnchantItem(boolean wep, int type, int level, int chance, int[] items)
-		{
-			_isWeapon = wep;
-			_grade = type;
-			_maxEnchantLevel = level;
-			_chanceAdd = chance;
-			_itemIds = items;
-		}
-		
-		/**
-		 * @param enchantItem
-		 * @return true if support item can be used for this item
-		 */
-		public final boolean isValid(L2ItemInstance enchantItem)
-		{
-			if (enchantItem == null)
-				return false;
-			
-			int type2 = enchantItem.getItem().getType2();
-			
-			// checking scroll type and configured maximum enchant level
-			switch (type2)
-			{
-				// weapon scrolls can enchant only weapons
-				case L2Item.TYPE2_WEAPON:
-					if (!_isWeapon
-							|| (Config.ENCHANT_MAX_WEAPON > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_WEAPON))
-						return false;
-					break;
-					// armor scrolls can enchant only accessory and armors
-				case L2Item.TYPE2_SHIELD_ARMOR:
-					if (_isWeapon
-							|| (Config.ENCHANT_MAX_ARMOR > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_ARMOR))
-						return false;
-					break;
-				case L2Item.TYPE2_ACCESSORY:
-					if (_isWeapon
-							|| (Config.ENCHANT_MAX_JEWELRY > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_JEWELRY))
-						return false;
-					break;
-				default:
-					return false;
-			}
-			
-			// check for crystal types
-			if (_grade != enchantItem.getItem().getItemGradeSPlus())
-				return false;
-			
-			// check for maximum enchant level
-			if (_maxEnchantLevel != 0 && enchantItem.getEnchantLevel() >= _maxEnchantLevel)
-				return false;
-			
-			if(_itemIds != null && Arrays.binarySearch(_itemIds, enchantItem.getItemId()) < 0)
-				return false;
-			
-			return true;
-		}
-		
-		/**
-		 * @return chance increase
-		 */
-		public final int getChanceAdd()
-		{
-			return _chanceAdd;
-		}
-	}
-	
-	public static final class EnchantScroll extends EnchantItem
-	{
-		private final boolean _isBlessed;
-		private final boolean _isCrystal;
-		private final boolean _isSafe;
-		
-		/**
-		 * @param wep
-		 * @param bless
-		 * @param crystal
-		 * @param safe
-		 * @param type
-		 * @param level
-		 * @param chance
-		 * @param items
-		 */
-		public EnchantScroll(boolean wep, boolean bless, boolean crystal, boolean safe, int type, int level, int chance, int[] items)
-		{
-			super(wep, type, level, chance, items);
-			
-			_isBlessed = bless;
-			_isCrystal = crystal;
-			_isSafe = safe;
-		}
-		
-		/**
-		 * @return true for blessed scrolls
-		 */
-		public final boolean isBlessed()
-		{
-			return _isBlessed;
-		}
-		
-		/**
-		 * @return true for crystal scrolls
-		 */
-		public final boolean isCrystal()
-		{
-			return _isCrystal;
-		}
-		
-		/**
-		 * @return true for safe-enchant scrolls (enchant level will remain on failure)
-		 */
-		public final boolean isSafe()
-		{
-			return _isSafe;
-		}
-		
-		/**
-		 * @param enchantItem
-		 * @param supportItem
-		 * @return
-		 */
-		public final boolean isValid(L2ItemInstance enchantItem, EnchantItem supportItem)
-		{
-			// blessed scrolls can't use support items
-			if (supportItem != null && (!supportItem.isValid(enchantItem) || isBlessed()))
-				return false;
-			
-			return isValid(enchantItem);
-		}
-		
-		/**
-		 * @param enchantItem
-		 * @param supportItem
-		 * @return
-		 */
-		public final int getChance(L2ItemInstance enchantItem, EnchantItem supportItem)
-		{
-			if (!isValid(enchantItem, supportItem))
-				return -1;
-			
-			boolean fullBody = enchantItem.getItem().getBodyPart() == L2Item.SLOT_FULL_ARMOR;
-			if (enchantItem.getEnchantLevel() < Config.ENCHANT_SAFE_MAX
-					|| (fullBody && enchantItem.getEnchantLevel() < Config.ENCHANT_SAFE_MAX_FULL))
-				return 100;
-			
-			boolean isAccessory = enchantItem.getItem().getType2() == L2Item.TYPE2_ACCESSORY;
-			int chance = 0;
-			
-			if (_isBlessed)
-			{
-				// blessed scrolls does not use support items
-				if (supportItem != null)
-					return -1;
-				
-				if (_isWeapon)
-					chance = Config.BLESSED_ENCHANT_CHANCE_WEAPON;
-				else if (isAccessory)
-					chance = Config.BLESSED_ENCHANT_CHANCE_JEWELRY;
-				else
-					chance = Config.BLESSED_ENCHANT_CHANCE_ARMOR;
-			}
-			else
-			{
-				if (_isWeapon)
-					chance = Config.ENCHANT_CHANCE_WEAPON;
-				else if (isAccessory)
-					chance = Config.ENCHANT_CHANCE_JEWELRY;
-				else
-					chance = Config.ENCHANT_CHANCE_ARMOR;
-			}
-			
-			chance += _chanceAdd;
-			
-			if (supportItem != null)
-				chance += supportItem.getChanceAdd();
-			
-			return chance;
-		}
-	}
-	
-	static
-	{
-		// itemId, (isWeapon, isBlessed, isCrystal, isSafe, grade, max enchant level, chance increase, allowed item IDs)
-		// allowed items IDs must be sorted by ascending order
-		// Scrolls: Enchant Weapon
-		_scrolls.put(729, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_A, 0, 0, null));
-		_scrolls.put(947, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_B, 0, 0, null));
-		_scrolls.put(951, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_C, 0, 0, null));
-		_scrolls.put(955, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_D, 0, 0, null));
-		_scrolls.put(959, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_S, 0, 0, null));
-		// Scrolls: Enchant Armor
-		_scrolls.put(730, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_A, 0, 0, null));
-		_scrolls.put(948, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_B, 0, 0, null));
-		_scrolls.put(952, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_C, 0, 0, null));
-		_scrolls.put(956, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_D, 0, 0, null));
-		_scrolls.put(960, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_S, 0, 0, null));
-		
-		// Blessed Scrolls: Enchant Weapon
-		_scrolls.put(6569, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_A, 0, 0, null));
-		_scrolls.put(6571, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_B, 0, 0, null));
-		_scrolls.put(6573, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_C, 0, 0, null));
-		_scrolls.put(6575, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_D, 0, 0, null));
-		_scrolls.put(6577, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_S, 0, 0, null));
-		// Blessed Scrolls: Enchant Armor
-		_scrolls.put(6570, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_A, 0, 0, null));
-		_scrolls.put(6572, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_B, 0, 0, null));
-		_scrolls.put(6574, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_C, 0, 0, null));
-		_scrolls.put(6576, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_D, 0, 0, null));
-		_scrolls.put(6578, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_S, 0, 0, null));
-		
-		// Crystal Scrolls: Enchant Weapon
-		_scrolls.put(731, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_A, 0, 0, null));
-		_scrolls.put(949, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_B, 0, 0, null));
-		_scrolls.put(953, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_C, 0, 0, null));
-		_scrolls.put(957, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_D, 0, 0, null));
-		_scrolls.put(961, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_S, 0, 0, null));
-		// Crystal Scrolls: Enchant Armor
-		_scrolls.put(732, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_A, 0, 0, null));
-		_scrolls.put(950, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_B, 0, 0, null));
-		_scrolls.put(954, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_C, 0, 0, null));
-		_scrolls.put(958, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_D, 0, 0, null));
-		_scrolls.put(962, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_S, 0, 0, null));
-
-		// Weapon Enchant Scrolls
-		_scrolls.put(20517, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_S, 0, 10, null));
-		_scrolls.put(22006, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_D, 0, 10, null));
-		_scrolls.put(22007, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_C, 0, 10, null));
-		_scrolls.put(22008, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_B, 0, 10, null));
-		_scrolls.put(22009, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_A, 0, 10, null));
-		// Armor Enchant Scrolls
-		_scrolls.put(20518, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_S, 0, 10, null));
-		_scrolls.put(22010, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_D, 0, 10, null));
-		_scrolls.put(22011, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_C, 0, 10, null));
-		_scrolls.put(22012, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_B, 0, 10, null));
-		_scrolls.put(22013, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_A, 0, 10, null));
-		
-		// Ancient Weapon Enchant Crystal
-		_scrolls.put(20519, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_S, 16, 10, null));
-		_scrolls.put(22014, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_B, 16, 10, null));
-		_scrolls.put(22015, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_A, 16, 10, null));
-		// Ancient Armor Enchant Crystal
-		_scrolls.put(20520, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_S, 16, 10, null));
-		_scrolls.put(22016, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_B, 16, 10, null));
-		_scrolls.put(22017, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_A, 16, 10, null));
-
-		// Divine Weapon Enchant Crystal
-		_scrolls.put(20521, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_S, 0, 100, null));
-		_scrolls.put(22018, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_B, 0, 100, null));
-		_scrolls.put(22019, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_A, 0, 100, null));
-		// Divine Armor Enchant Crystal
-		_scrolls.put(20522, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_S, 0, 100, null));
-		_scrolls.put(22020, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_B, 0, 100, null));
-		_scrolls.put(22021, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_A, 0, 100, null));
-		
-		// Destruction Weapon
-		_scrolls.put(22229, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_D, 16, 0, null));
-		_scrolls.put(22227, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_C, 16, 0, null));
-		_scrolls.put(22225, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_B, 16, 0, null));
-		_scrolls.put(22223, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_A, 16, 0, null));
-		_scrolls.put(22221, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_S, 16, 0, null));
-		// Destruction Armor
-		_scrolls.put(22230, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_D, 16, 0, null));
-		_scrolls.put(22228, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_C, 16, 0, null));
-		_scrolls.put(22226, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_B, 16, 0, null));
-		_scrolls.put(22224, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_A, 16, 0, null));
-		_scrolls.put(22222, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_S, 16, 0, null));
-
-		// PC Bang Enchants
-		_scrolls.put(15346, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_S, 0, 0, new int[]{ 15313, 15314, 15315, 15316, 15317, 15318, 15319, 15320, 15321, 15322, 15323, 15324, 15325, 15326 }));
-		_scrolls.put(15347, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_A, 0, 0, new int[]{ 13210, 13211, 13212, 13213, 13214, 13215, 13216, 13217, 13218, 13219, 13220, 13221, 13222, 13223, 13224 }));
-		_scrolls.put(15348, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_B, 0, 0, new int[]{ 13194, 13195, 13196, 13197, 13198, 13199, 13200, 13201, 13202, 13203, 13204, 13205, 13206, 13207, 13208, 13209, }));
-		_scrolls.put(15349, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_C, 0, 0, new int[]{ 13178, 13179, 13180, 13181, 13182, 13183, 13184, 13185, 13186, 13187, 13188, 13189, 13190, 13191, 13192, 13193 }));
-		_scrolls.put(15350, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_D, 0, 0, new int[]{ 13163, 13164, 13165, 13166, 13167, 13168, 13169, 13170, 13171, 13172, 13173, 13174, 13175, 13176, 13177 }));
-		
-		// Master Yogi's Scroll Enchant Weapon (event)
-		_scrolls.put(13540, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_NONE, 0, 0, new int[]{ 13539 }));
-		
-		// itemId, (isWeapon, grade, max enchant level, chance increase)
-		_supports.put(12362, new EnchantItem(true, L2Item.CRYSTAL_D, 9, 20, null));
-		_supports.put(12363, new EnchantItem(true, L2Item.CRYSTAL_C, 9, 18, null));
-		_supports.put(12364, new EnchantItem(true, L2Item.CRYSTAL_B, 9, 15, null));
-		_supports.put(12365, new EnchantItem(true, L2Item.CRYSTAL_A, 9, 12, null));
-		_supports.put(12366, new EnchantItem(true, L2Item.CRYSTAL_S, 9, 10, null));
-		_supports.put(12367, new EnchantItem(false, L2Item.CRYSTAL_D, 9, 35, null));
-		_supports.put(12368, new EnchantItem(false, L2Item.CRYSTAL_C, 9, 27, null));
-		_supports.put(12369, new EnchantItem(false, L2Item.CRYSTAL_B, 9, 23, null));
-		_supports.put(12370, new EnchantItem(false, L2Item.CRYSTAL_A, 9, 18, null));
-		_supports.put(12371, new EnchantItem(false, L2Item.CRYSTAL_S, 9, 15, null));
-		_supports.put(14702, new EnchantItem(true, L2Item.CRYSTAL_D, 9, 20, null));
-		_supports.put(14703, new EnchantItem(true, L2Item.CRYSTAL_C, 9, 18, null));
-		_supports.put(14704, new EnchantItem(true, L2Item.CRYSTAL_B, 9, 15, null));
-		_supports.put(14705, new EnchantItem(true, L2Item.CRYSTAL_A, 9, 12, null));
-		_supports.put(14706, new EnchantItem(true, L2Item.CRYSTAL_S, 9, 10, null));
-		_supports.put(14707, new EnchantItem(false, L2Item.CRYSTAL_D, 9, 35, null));
-		_supports.put(14708, new EnchantItem(false, L2Item.CRYSTAL_C, 9, 27, null));
-		_supports.put(14709, new EnchantItem(false, L2Item.CRYSTAL_B, 9, 23, null));
-		_supports.put(14710, new EnchantItem(false, L2Item.CRYSTAL_A, 9, 18, null));
-		_supports.put(14711, new EnchantItem(false, L2Item.CRYSTAL_S, 9, 15, null));
-	}
-	
-	/**
-	 * @param scroll 
-	 * @return enchant template for scroll
-	 */
-	protected static final EnchantScroll getEnchantScroll(L2ItemInstance scroll)
-	{
-		return _scrolls.get(scroll.getItemId());
-	}
-	
-	/**
-	 * @param item 
-	 * @return enchant template for support item
-	 */
-	protected static final EnchantItem getSupportItem(L2ItemInstance item)
-	{
-		return _supports.get(item.getItemId());
-	}
-}

+ 36 - 20
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestEnchantItem.java

@@ -19,7 +19,10 @@ import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 
 import com.l2jserver.Config;
+import com.l2jserver.gameserver.datatables.EnchantItemTable;
 import com.l2jserver.gameserver.datatables.SkillTable;
+import com.l2jserver.gameserver.model.EnchantItem;
+import com.l2jserver.gameserver.model.EnchantScroll;
 import com.l2jserver.gameserver.model.L2Skill;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -36,7 +39,7 @@ import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.gameserver.util.Util;
 import com.l2jserver.util.Rnd;
 
-public final class RequestEnchantItem extends AbstractEnchantPacket
+public final class RequestEnchantItem extends L2GameClientPacket
 {
 	protected static final Logger _log = Logger.getLogger(RequestEnchantItem.class.getName());
 	protected static final Logger _logEnchant = Logger.getLogger("enchant");
@@ -69,7 +72,7 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 		
 		if (activeChar.isProcessingTransaction() || activeChar.isInStoreMode())
 		{
-			activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_ENCHANT_WHILE_STORE));
+			activeChar.sendPacket(SystemMessageId.CANNOT_ENCHANT_WHILE_STORE);
 			activeChar.setActiveEnchantItem(null);
 			return;
 		}
@@ -85,7 +88,7 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 		}
 		
 		// template for scroll
-		EnchantScroll scrollTemplate = getEnchantScroll(scroll);
+		EnchantScroll scrollTemplate = EnchantItemTable.getInstance().getEnchantScroll(scroll);
 		
 		// scroll not found in list
 		if (scrollTemplate == null)
@@ -100,13 +103,13 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 				activeChar.setActiveEnchantItem(null);
 				return;
 			}
-			supportTemplate = getSupportItem(support);
+			supportTemplate = EnchantItemTable.getInstance().getSupportItem(support);
 		}
 		
 		// first validation check
-		if (!scrollTemplate.isValid(item, supportTemplate) || !item.isEnchantable())
+		if (!scrollTemplate.isValid(item, supportTemplate))
 		{
-			activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION));
+			activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION);
 			activeChar.setActiveEnchantItem(null);
 			activeChar.sendPacket(new EnchantResult(2, 0, 0));
 			return;
@@ -125,7 +128,7 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 		scroll = activeChar.getInventory().destroyItem("Enchant", scroll.getObjectId(), 1, activeChar, item);
 		if (scroll == null)
 		{
-			activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
+			activeChar.sendPacket(SystemMessageId.NOT_ENOUGH_ITEMS);
 			Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to enchant with a scroll he doesn't have", Config.DEFAULT_PUNISH);
 			activeChar.setActiveEnchantItem(null);
 			activeChar.sendPacket(new EnchantResult(2, 0, 0));
@@ -138,7 +141,7 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 			support = activeChar.getInventory().destroyItem("Enchant", support.getObjectId(), 1, activeChar, item);
 			if (support == null)
 			{
-				activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
+				activeChar.sendPacket(SystemMessageId.NOT_ENOUGH_ITEMS);
 				Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " tried to enchant with a support item he doesn't have", Config.DEFAULT_PUNISH);
 				activeChar.setActiveEnchantItem(null);
 				activeChar.sendPacket(new EnchantResult(2, 0, 0));
@@ -148,17 +151,15 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 		
 		synchronized (item)
 		{
-			int chance = scrollTemplate.getChance(item, supportTemplate);
+			double chance = scrollTemplate.getChance(item, supportTemplate);
 			
 			L2Skill enchant4Skill = null;
 			L2Item it = item.getItem();
 			
 			// last validation check
-			if (item.getOwnerId() != activeChar.getObjectId()
-					|| !item.isEnchantable()
-					|| chance < 0)
+			if (item.getOwnerId() != activeChar.getObjectId() || item.isEnchantable() == 0 || chance < 0)
 			{
-				activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION));
+				activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION);
 				activeChar.setActiveEnchantItem(null);
 				activeChar.sendPacket(new EnchantResult(2, 0, 0));
 				return;
@@ -174,7 +175,10 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 				if (Config.LOG_ITEM_ENCHANTS)
 				{
 					LogRecord record = new LogRecord(Level.INFO, "Success");
-					record.setParameters(new Object[]{activeChar, item, scroll, support, chance});
+					record.setParameters(new Object[]
+					{
+						activeChar, item, scroll, support, chance
+					});
 					record.setLoggerName("item");
 					_logEnchant.log(record);
 				}
@@ -197,7 +201,7 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 				
 				if (it instanceof L2Armor && item.getEnchantLevel() == 4 && activeChar.getInventory().getItemByObjectId(item.getObjectId()).isEquipped())
 				{
-					enchant4Skill = ((L2Armor)it).getEnchant4Skill();
+					enchant4Skill = ((L2Armor) it).getEnchant4Skill();
 					if (enchant4Skill != null)
 					{
 						// add skills bestowed from +4 armor
@@ -217,7 +221,10 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 					if (Config.LOG_ITEM_ENCHANTS)
 					{
 						LogRecord record = new LogRecord(Level.INFO, "Safe Fail");
-						record.setParameters(new Object[]{activeChar, item, scroll, support, chance});
+						record.setParameters(new Object[]
+						{
+							activeChar, item, scroll, support, chance
+						});
 						record.setLoggerName("item");
 						_logEnchant.log(record);
 					}
@@ -253,7 +260,7 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 					if (scrollTemplate.isBlessed())
 					{
 						// blessed enchant - clear enchant value
-						activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.BLESSED_ENCHANT_FAILED));
+						activeChar.sendPacket(SystemMessageId.BLESSED_ENCHANT_FAILED);
 						
 						item.setEnchantLevel(0);
 						item.updateDatabase();
@@ -262,7 +269,10 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 						if (Config.LOG_ITEM_ENCHANTS)
 						{
 							LogRecord record = new LogRecord(Level.INFO, "Blessed Fail");
-							record.setParameters(new Object[]{activeChar, item, scroll, support, chance});
+							record.setParameters(new Object[]
+							{
+								activeChar, item, scroll, support, chance
+							});
 							record.setLoggerName("item");
 							_logEnchant.log(record);
 						}
@@ -286,7 +296,10 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 							if (Config.LOG_ITEM_ENCHANTS)
 							{
 								LogRecord record = new LogRecord(Level.INFO, "Unable to destroy");
-								record.setParameters(new Object[]{activeChar, item, scroll, support, chance});
+								record.setParameters(new Object[]
+								{
+									activeChar, item, scroll, support, chance
+								});
 								record.setLoggerName("item");
 								_logEnchant.log(record);
 							}
@@ -330,7 +343,10 @@ public final class RequestEnchantItem extends AbstractEnchantPacket
 						if (Config.LOG_ITEM_ENCHANTS)
 						{
 							LogRecord record = new LogRecord(Level.INFO, "Fail");
-							record.setParameters(new Object[]{activeChar, item, scroll, support, chance});
+							record.setParameters(new Object[]
+							{
+								activeChar, item, scroll, support, chance
+							});
 							record.setLoggerName("item");
 							_logEnchant.log(record);
 						}

+ 4 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestExTryToPutEnchantSupportItem.java

@@ -14,6 +14,8 @@
  */
 package com.l2jserver.gameserver.network.clientpackets;
 
+import com.l2jserver.gameserver.datatables.EnchantItemTable;
+import com.l2jserver.gameserver.model.EnchantItem;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
 import com.l2jserver.gameserver.network.SystemMessageId;
@@ -23,7 +25,7 @@ import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 /**
  * @author  KenM
  */
-public class RequestExTryToPutEnchantSupportItem extends AbstractEnchantPacket
+public class RequestExTryToPutEnchantSupportItem extends L2GameClientPacket
 {
 	private static final String _C__D0_4D_REQUESTEXTRYTOPUTENCHANTSUPPORTITEM = "[C] D0:4D RequestExTryToPutEnchantSupportItem";
 	
@@ -51,7 +53,7 @@ public class RequestExTryToPutEnchantSupportItem extends AbstractEnchantPacket
 				if (item == null || support == null)
 					return;
 				
-				EnchantItem supportTemplate = getSupportItem(support);
+				EnchantItem supportTemplate = EnchantItemTable.getInstance().getSupportItem(support);
 				
 				if (supportTemplate == null || !supportTemplate.isValid(item))
 				{

+ 26 - 27
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestExTryToPutEnchantTargetItem.java

@@ -14,16 +14,17 @@
  */
 package com.l2jserver.gameserver.network.clientpackets;
 
+import com.l2jserver.gameserver.datatables.EnchantItemTable;
+import com.l2jserver.gameserver.model.EnchantScroll;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.item.instance.L2ItemInstance;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.serverpackets.ExPutEnchantTargetItemResult;
-import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 
 /**
- * @author  KenM
+ * @author KenM
  */
-public class RequestExTryToPutEnchantTargetItem extends AbstractEnchantPacket
+public class RequestExTryToPutEnchantTargetItem extends L2GameClientPacket
 {
 	private static final String _C__D0_4C_REQUESTEXTRYTOPUTENCHANTTARGETITEM = "[C] D0:4C RequestExTryToPutEnchantTargetItem";
 	
@@ -40,34 +41,32 @@ public class RequestExTryToPutEnchantTargetItem extends AbstractEnchantPacket
 	{
 		L2PcInstance activeChar = getClient().getActiveChar();
 		
-		if (_objectId == 0)
+		if (_objectId == 0 || activeChar == null)
 			return;
 		
-		if (activeChar != null)
+		if (activeChar.isEnchanting())
+			return;
+		
+		L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
+		L2ItemInstance scroll = activeChar.getActiveEnchantItem();
+		
+		if (item == null || scroll == null)
+			return;
+		
+		// template for scroll
+		EnchantScroll scrollTemplate = EnchantItemTable.getInstance().getEnchantScroll(scroll);
+		
+		if (!scrollTemplate.isValid(item))
 		{
-			if (activeChar.isEnchanting())
-				return;
-			
-			L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
-			L2ItemInstance scroll = activeChar.getActiveEnchantItem();
-			
-			if (item == null || scroll == null)
-				return;
-			
-			// template for scroll
-			EnchantScroll scrollTemplate = getEnchantScroll(scroll);
-			
-			if (!scrollTemplate.isValid(item) || !item.isEnchantable())
-			{
-				activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.DOES_NOT_FIT_SCROLL_CONDITIONS));
-				activeChar.setActiveEnchantItem(null);
-				activeChar.sendPacket(new ExPutEnchantTargetItemResult(0));
-				return;
-			}
-			activeChar.setIsEnchanting(true);
-			activeChar.setActiveEnchantTimestamp(System.currentTimeMillis());
-			activeChar.sendPacket(new ExPutEnchantTargetItemResult(_objectId));
+			activeChar.sendPacket(SystemMessageId.DOES_NOT_FIT_SCROLL_CONDITIONS);
+			activeChar.setActiveEnchantItem(null);
+			activeChar.sendPacket(new ExPutEnchantTargetItemResult(0));
+			return;
 		}
+		activeChar.setIsEnchanting(true);
+		activeChar.setActiveEnchantTimestamp(System.currentTimeMillis());
+		activeChar.sendPacket(new ExPutEnchantTargetItemResult(_objectId));
+		
 	}
 	
 	@Override