Advertisement
Guest User

Nik

a guest
Sep 23rd, 2009
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.90 KB | None | 0 0
  1. Index: src/main/java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java
  2. ===================================================================
  3. --- src/main/java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java   (revision 345)
  4. +++ src/main/java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java   (working copy)
  5. @@ -17,6 +17,7 @@
  6.   */
  7.  package net.sf.l2j.gameserver.network.clientpackets;
  8.  
  9. +import java.util.Map;
  10.  import java.util.logging.Logger;
  11.  
  12.  import net.sf.l2j.Config;
  13. @@ -188,17 +189,17 @@
  14.  
  15.          if (item.getItem().getType2() == L2Item.TYPE2_WEAPON)
  16.          {
  17. -           chance = Config.ENCHANT_CHANCE_WEAPON;
  18. +           chance = getListChance(Config.ENCHANT_CHANCE_WEAPON_LIST,Config.ENCHANT_CHANCE_WEAPON,item);
  19.             maxEnchantLevel = Config.ENCHANT_MAX_WEAPON;
  20.          }
  21.          else if (item.getItem().getType2() == L2Item.TYPE2_SHIELD_ARMOR)
  22.          {
  23. -           chance = Config.ENCHANT_CHANCE_ARMOR;
  24. +           chance = getListChance(Config.ENCHANT_CHANCE_ARMOR_LIST,Config.ENCHANT_CHANCE_ARMOR,item);
  25.             maxEnchantLevel = Config.ENCHANT_MAX_ARMOR;
  26.          }
  27.          else if (item.getItem().getType2() == L2Item.TYPE2_ACCESSORY)
  28.          {
  29. -           chance = Config.ENCHANT_CHANCE_JEWELRY;
  30. +           chance = getListChance(Config.ENCHANT_CHANCE_JEWELRY_LIST,Config.ENCHANT_CHANCE_JEWELRY,item);
  31.             maxEnchantLevel = Config.ENCHANT_MAX_JEWELRY;
  32.          }
  33.  
  34. @@ -342,6 +343,24 @@
  35.          activeChar.sendPacket(new ItemList(activeChar, false)); //TODO update only the enchanted item
  36.          activeChar.broadcastUserInfo();
  37.      }
  38. +      
  39. +   public static boolean isInRestrictionList(L2ItemInstance item)
  40. +   {
  41. +       if (Config.LIST_ENCHANT_CHANCE_LISTS_RESTRICTION.contains(0)) return true;
  42. +       return Config.LIST_ENCHANT_CHANCE_LISTS_RESTRICTION.contains(item.getItemId());    
  43. +   }
  44. +   public static int getListChance(Map<Integer, Integer> ConfigEnchantChanceList, Integer ConfigEnchantChance, L2ItemInstance item)
  45. +   {
  46. +       int chance = 0;
  47. +       if (!ConfigEnchantChanceList.isEmpty() && isInRestrictionList(item))
  48. +       {
  49. +           if (ConfigEnchantChanceList.containsKey(item.getEnchantLevel()+1))
  50. +           chance = ConfigEnchantChanceList.get(item.getEnchantLevel()+1);
  51. +           else chance = ConfigEnchantChance;
  52. +       }
  53. +       else chance = ConfigEnchantChance; 
  54. +       return chance;
  55. +   }    
  56.      
  57.      /* (non-Javadoc)
  58.       * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
  59. Index: src/main/java/net/sf/l2j/Config.java
  60. ===================================================================
  61. --- src/main/java/net/sf/l2j/Config.java    (revision 345)
  62. +++ src/main/java/net/sf/l2j/Config.java    (working copy)
  63. @@ -23,10 +23,12 @@
  64.  import java.io.InputStream;
  65.  import java.math.BigInteger;
  66.  import java.util.List;
  67. +import java.util.Map;
  68.  import java.util.Properties;
  69.  import java.util.logging.Logger;
  70.  
  71.  import javolution.util.FastList;
  72. +import javolution.util.FastMap;
  73.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  74.  
  75.  /**
  76. @@ -921,6 +923,11 @@
  77.      public static int ENCHANT_CHANCE_WEAPON;
  78.      public static int ENCHANT_CHANCE_ARMOR;
  79.      public static int ENCHANT_CHANCE_JEWELRY;
  80. +   public static Map<Integer, Integer> ENCHANT_CHANCE_WEAPON_LIST;
  81. +   public static Map<Integer, Integer> ENCHANT_CHANCE_ARMOR_LIST;
  82. +   public static Map<Integer, Integer> ENCHANT_CHANCE_JEWELRY_LIST;
  83. +   public static String        ENCHANT_CHANCE_LISTS_RESTRICTION;
  84. +   public static List<Integer> LIST_ENCHANT_CHANCE_LISTS_RESTRICTION = new FastList<Integer>();
  85.      /** Maximum level of enchantment */
  86.      public static int ENCHANT_MAX_WEAPON;
  87.      public static int ENCHANT_MAX_ARMOR;
  88. @@ -1430,6 +1437,60 @@
  89.                  ENCHANT_CHANCE_WEAPON  = Integer.parseInt(otherSettings.getProperty("EnchantChanceWeapon", "68"));
  90.                  ENCHANT_CHANCE_ARMOR  = Integer.parseInt(otherSettings.getProperty("EnchantChanceArmor", "52"));
  91.                  ENCHANT_CHANCE_JEWELRY  = Integer.parseInt(otherSettings.getProperty("EnchantChanceJewelry", "54"));
  92. +                       String[] propertySplitWeapon = otherSettings.getProperty("EnchantChanceWeaponList", "").split(";");
  93. +                       String[] propertySplitArmor = otherSettings.getProperty("EnchantChanceArmorList", "").split(";");
  94. +                       String[] propertySplitJewelry = otherSettings.getProperty("EnchantChanceJewelryList", "").split(";");
  95. +                       ENCHANT_CHANCE_WEAPON_LIST = new FastMap<Integer, Integer>(propertySplitWeapon.length);
  96. +                       ENCHANT_CHANCE_ARMOR_LIST = new FastMap<Integer, Integer>(propertySplitArmor.length);
  97. +                       ENCHANT_CHANCE_JEWELRY_LIST = new FastMap<Integer, Integer>(propertySplitJewelry.length);
  98. +                   if (propertySplitWeapon.length > 1)
  99. +                   {
  100. +                       for (String enchant : propertySplitWeapon)
  101. +                       {
  102. +                           String[] enchantSplit = enchant.split(",");
  103. +                           if (enchantSplit.length != 2)System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");
  104. +                           else
  105. +                           {
  106. +                               try{ENCHANT_CHANCE_WEAPON_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
  107. +                               catch (NumberFormatException nfe){
  108. +                               if (!enchant.isEmpty())System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");}
  109. +                           }
  110. +                       }
  111. +                   }
  112. +                   if (propertySplitArmor.length > 1)
  113. +                   {
  114. +                       for (String enchant : propertySplitArmor)
  115. +                       {
  116. +                           String[] enchantSplit = enchant.split(",");
  117. +                           if (enchantSplit.length != 2)System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");
  118. +                           else
  119. +                           {
  120. +                               try{ENCHANT_CHANCE_ARMOR_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
  121. +                               catch (NumberFormatException nfe){
  122. +                               if (!enchant.isEmpty())System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");}
  123. +                           }
  124. +                       }
  125. +                   }
  126. +                   if (propertySplitJewelry.length > 1)
  127. +                   {
  128. +                       for (String enchant : propertySplitJewelry)
  129. +                       {
  130. +                           String[] enchantSplit = enchant.split(",");
  131. +                           if (enchantSplit.length != 2)System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");
  132. +                           else
  133. +                           {
  134. +                               try{ENCHANT_CHANCE_JEWELRY_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
  135. +                               catch (NumberFormatException nfe){
  136. +                               if (!enchant.isEmpty())System.out.println("[CustomEnchantSystem]: invalid config property -> EnchantList ");}
  137. +                           }
  138. +                       }
  139. +                   }
  140. +                   ENCHANT_CHANCE_LISTS_RESTRICTION = otherSettings.getProperty("EnchantChanceListsRestriction", "0");
  141. +                   LIST_ENCHANT_CHANCE_LISTS_RESTRICTION = new FastList<Integer>();
  142. +                   for (String id : ENCHANT_CHANCE_LISTS_RESTRICTION.split(","))
  143. +                   {
  144. +                       LIST_ENCHANT_CHANCE_LISTS_RESTRICTION.add(Integer.parseInt(id));
  145. +                   }
  146.                  /* limit on enchant */
  147.                  ENCHANT_MAX_WEAPON = Integer.parseInt(otherSettings.getProperty("EnchantMaxWeapon", "255"));
  148.                  ENCHANT_MAX_ARMOR = Integer.parseInt(otherSettings.getProperty("EnchantMaxArmor", "255"));
  149. Index: config/Other.properties
  150. ===================================================================
  151. --- config/Other.properties (revision 345)
  152. +++ config/Other.properties (working copy)
  153. @@ -44,6 +44,35 @@
  154.  EnchantChanceWeapon = 68
  155.  EnchantChanceArmor = 52
  156.  EnchantChanceJewelry = 54
  157. +
  158. +# This is a list where you define different enchant chance on different enchant levels
  159. +# Format: enchantLevel1,enchantChance1;enchantLevel2,enchantChance2...
  160. +# Example:
  161. +#  The "\"indicates new line, and is only set for formating purposes.
  162. +#  EnchantChanceWeaponList = 4,90;5,80;6,75;7,70;8,65;\
  163. +#  9,60;10,50;11,20;12,10;13,50;14,25;15,20
  164. +#  No ";" or ";\" at the end
  165. +# So, if the enchant chance for +15 is set to 30%, the enchanter will have 30%
  166. +# chance to enchant the weapon from +14 to +15
  167. +# If a specific enchant level isnt described in the list, or the list is empty,
  168. +# the chance will be the one set at default configs
  169. +# (ex. EnchantChanceWeapon = ?? / EnchantChanceArmor = ?? / EnchantChanceJewelry = ??)
  170. +# So if you miss in the list for example, +15 for weapon, the chance will be
  171. +# the one set at EnchantChanceWeapon (BlessedEnchantChanceWeapon for blessed)
  172. +EnchantChanceWeaponList =
  173. +EnchantChanceArmorList =
  174. +EnchantChanceJewelryList =
  175. +
  176. +# List of item id that will be affected by EnchantChance lists
  177. +# (separated by "," like 77,78,79).
  178. +# Notes:
  179. +#  *Make sure the lists do NOT CONTAIN trailing spaces or spaces between the numbers!
  180. +#  *Items on this list will be affected by normal enchant restrictions aswell.
  181. +#     For example, even if you add a hero weapon here, you wont be able to enchant it.
  182. +#   *Default is 0, that means all items will be affected, and if there is 0 somewhere
  183. +#     in the list, it will still affect all items! Be aware of that!
  184. +EnchantChanceListsRestriction = 0
  185. +
  186. # Enchant limit [default = 0 (unlimited)]
  187. EnchantMaxWeapon = 0
  188. EnchantMaxArmor = 0
  189.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement