Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: src/main/java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java
- ===================================================================
- --- src/main/java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java (revision 345)
- +++ src/main/java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java (working copy)
- @@ -17,6 +17,7 @@
- */
- package net.sf.l2j.gameserver.network.clientpackets;
- +import java.util.Map;
- import java.util.logging.Logger;
- import net.sf.l2j.Config;
- @@ -188,17 +189,17 @@
- if (item.getItem().getType2() == L2Item.TYPE2_WEAPON)
- {
- - chance = Config.ENCHANT_CHANCE_WEAPON;
- + chance = getListChance(Config.ENCHANT_CHANCE_WEAPON_LIST,Config.ENCHANT_CHANCE_WEAPON,item);
- maxEnchantLevel = Config.ENCHANT_MAX_WEAPON;
- }
- else if (item.getItem().getType2() == L2Item.TYPE2_SHIELD_ARMOR)
- {
- - chance = Config.ENCHANT_CHANCE_ARMOR;
- + chance = getListChance(Config.ENCHANT_CHANCE_ARMOR_LIST,Config.ENCHANT_CHANCE_ARMOR,item);
- maxEnchantLevel = Config.ENCHANT_MAX_ARMOR;
- }
- else if (item.getItem().getType2() == L2Item.TYPE2_ACCESSORY)
- {
- - chance = Config.ENCHANT_CHANCE_JEWELRY;
- + chance = getListChance(Config.ENCHANT_CHANCE_JEWELRY_LIST,Config.ENCHANT_CHANCE_JEWELRY,item);
- maxEnchantLevel = Config.ENCHANT_MAX_JEWELRY;
- }
- @@ -342,6 +343,24 @@
- activeChar.sendPacket(new ItemList(activeChar, false)); //TODO update only the enchanted item
- activeChar.broadcastUserInfo();
- }
- +
- + 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(Map<Integer, Integer> 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;
- + }
- /* (non-Javadoc)
- * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
- Index: src/main/java/net/sf/l2j/Config.java
- ===================================================================
- --- src/main/java/net/sf/l2j/Config.java (revision 345)
- +++ src/main/java/net/sf/l2j/Config.java (working copy)
- @@ -23,10 +23,12 @@
- import java.io.InputStream;
- import java.math.BigInteger;
- 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 net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- /**
- @@ -921,6 +923,11 @@
- public static int ENCHANT_CHANCE_WEAPON;
- public static int ENCHANT_CHANCE_ARMOR;
- public static int ENCHANT_CHANCE_JEWELRY;
- + 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 String ENCHANT_CHANCE_LISTS_RESTRICTION;
- + public static List<Integer> LIST_ENCHANT_CHANCE_LISTS_RESTRICTION = new FastList<Integer>();
- /** Maximum level of enchantment */
- public static int ENCHANT_MAX_WEAPON;
- public static int ENCHANT_MAX_ARMOR;
- @@ -1430,6 +1437,60 @@
- ENCHANT_CHANCE_WEAPON = Integer.parseInt(otherSettings.getProperty("EnchantChanceWeapon", "68"));
- ENCHANT_CHANCE_ARMOR = Integer.parseInt(otherSettings.getProperty("EnchantChanceArmor", "52"));
- ENCHANT_CHANCE_JEWELRY = Integer.parseInt(otherSettings.getProperty("EnchantChanceJewelry", "54"));
- + String[] propertySplitWeapon = otherSettings.getProperty("EnchantChanceWeaponList", "").split(";");
- + String[] propertySplitArmor = otherSettings.getProperty("EnchantChanceArmorList", "").split(";");
- + String[] propertySplitJewelry = otherSettings.getProperty("EnchantChanceJewelryList", "").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);
- + if (propertySplitWeapon.length > 1)
- + {
- + for (String enchant : propertySplitWeapon)
- + {
- + String[] enchantSplit = enchant.split(",");
- + if (enchantSplit.length != 2)System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");
- + else
- + {
- + try{ENCHANT_CHANCE_WEAPON_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
- + catch (NumberFormatException nfe){
- + if (!enchant.isEmpty())System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");}
- + }
- + }
- + }
- + if (propertySplitArmor.length > 1)
- + {
- + for (String enchant : propertySplitArmor)
- + {
- + String[] enchantSplit = enchant.split(",");
- + if (enchantSplit.length != 2)System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");
- + else
- + {
- + try{ENCHANT_CHANCE_ARMOR_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
- + catch (NumberFormatException nfe){
- + if (!enchant.isEmpty())System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");}
- + }
- + }
- + }
- + if (propertySplitJewelry.length > 1)
- + {
- + for (String enchant : propertySplitJewelry)
- + {
- + String[] enchantSplit = enchant.split(",");
- + if (enchantSplit.length != 2)System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");
- + else
- + {
- + try{ENCHANT_CHANCE_JEWELRY_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
- + catch (NumberFormatException nfe){
- + if (!enchant.isEmpty())System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");}
- + }
- + }
- + }
- + ENCHANT_CHANCE_LISTS_RESTRICTION = otherSettings.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));
- + }
- /* limit on enchant */
- ENCHANT_MAX_WEAPON = Integer.parseInt(otherSettings.getProperty("EnchantMaxWeapon", "255"));
- ENCHANT_MAX_ARMOR = Integer.parseInt(otherSettings.getProperty("EnchantMaxArmor", "255"));
- Index: config/Other.properties
- ===================================================================
- --- config/Other.properties (revision 345)
- +++ config/Other.properties (working copy)
- @@ -44,6 +44,35 @@
- EnchantChanceWeapon = 68
- EnchantChanceArmor = 52
- EnchantChanceJewelry = 54
- +
- +# 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 =
- +
- +# 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
- +
- # Enchant limit [default = 0 (unlimited)]
- EnchantMaxWeapon = 0
- EnchantMaxArmor = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement