Advertisement
Guest User

Nik

a guest
Sep 23rd, 2009
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.58 KB | None | 0 0
  1. Index: config/main/rates.properties
  2. ===================================================================
  3. --- config/main/rates.properties    (revision 980)
  4. +++ config/main/rates.properties    (working copy)
  5. @@ -80,6 +80,38 @@
  6.  EnchantChanceCrystal = 88
  7.  EnchantChanceArmor = 66
  8.  EnchantChanceJewelry = 66
  9. +# This is a list where you define different enchant chance on different enchant levels
  10. +# Format: enchantLevel1,enchantChance1;enchantLevel2,enchantChance2...
  11. +# Example:
  12. +#  The "\"indicates new line, and is only set for formating purposes.
  13. +#  EnchantChanceWeaponList = 4,90;5,80;6,75;7,70;8,65;\
  14. +#  9,60;10,50;11,20;12,10;13,50;14,25;15,20
  15. +#  No ";" or ";\" at the end
  16. +# So, if the enchant chance for +15 is set to 30%, the enchanter will have 30%
  17. +# chance to enchant the weapon from +14 to +15
  18. +# If a specific enchant level isnt described in the list, or the list is empty,
  19. +# the chance will be the one set at default configs
  20. +# (ex. EnchantChanceWeapon = ?? / EnchantChanceArmor = ?? / EnchantChanceJewelry = ??)
  21. +# So if you miss in the list for example, +15 for weapon, the chance will be
  22. +# the one set at EnchantChanceWeapon (BlessedEnchantChanceWeapon for blessed)
  23. +EnchantChanceWeaponList =
  24. +EnchantChanceArmorList =
  25. +EnchantChanceJewelryList =
  26. +
  27. +BlessedEnchantChanceWeaponList =
  28. +BlessedEnchantChanceArmorList =
  29. +BlessedEnchantChanceJewelryList =
  30. +
  31. +# List of item id that will be affected by EnchantChance lists
  32. +# (separated by "," like 77,78,79).
  33. +# Notes:
  34. +#  *Make sure the lists do NOT CONTAIN trailing spaces or spaces between the numbers!
  35. +#  *Items on this list will be affected by normal enchant restrictions aswell.
  36. +#     For example, even if you add a hero weapon here, you wont be able to enchant it.
  37. +#   *Default is 0, that means all items will be affected, and if there is 0 somewhere
  38. +#     in the list, it will still affect all items! Be aware of that!
  39. +EnchantChanceListsRestriction = 0
  40. +
  41. # Enchant limit [default = 0 (unlimited)]
  42. EnchantMaxWeapon = 0
  43. EnchantMaxArmor = 0
  44. Index: src/main/java/com/l2jarchid/gameserver/network/clientpackets/RequestEnchantItem.java
  45. ===================================================================
  46. --- src/main/java/com/l2jarchid/gameserver/network/clientpackets/RequestEnchantItem.java    (revision 980)
  47. +++ src/main/java/com/l2jarchid/gameserver/network/clientpackets/RequestEnchantItem.java    (working copy)
  48. @@ -17,6 +17,7 @@
  49.  */
  50. package com.l2jarchid.gameserver.network.clientpackets;
  51.  
  52. +import java.util.Map;
  53. import java.util.logging.Logger;
  54.  
  55. import com.l2jarchid.L2Config;
  56. @@ -200,13 +201,13 @@
  57.             for (int normalweaponscroll : NORMAL_WEAPON_SCROLLS)
  58.                 if (scroll.getItemId() == normalweaponscroll)  
  59.                 {
  60. -                   chance = L2Config.ENCHANT_CHANCE_WEAPON;
  61. +                   chance = getListChance(L2Config.ENCHANT_CHANCE_WEAPON_LIST,L2Config.ENCHANT_CHANCE_WEAPON,item);
  62.                     maxEnchantLevel = L2Config.ENCHANT_MAX_WEAPON;
  63.                 }  
  64.             for (int blessedweaponscroll : BLESSED_WEAPON_SCROLLS)
  65.                 if (scroll.getItemId() == blessedweaponscroll)
  66.                 {
  67. -                   chance = L2Config.ENCHANT_CHANCE_BLESSED;
  68. +                   chance = getListChance(L2Config.BLESSED_ENCHANT_CHANCE_WEAPON_LIST,L2Config.ENCHANT_CHANCE_BLESSED,item);
  69.                     maxEnchantLevel = L2Config.ENCHANT_MAX_WEAPON;
  70.                 }  
  71.             for (int crystalweaponscroll : CRYSTAL_WEAPON_SCROLLS)
  72. @@ -219,13 +220,13 @@
  73.             for (int normalarmorscroll : NORMAL_ARMOR_SCROLLS)
  74.                 if (scroll.getItemId() == normalarmorscroll)
  75.                 {
  76. -                   chance = L2Config.ENCHANT_CHANCE_ARMOR;
  77. +                   chance = getListChance(L2Config.ENCHANT_CHANCE_ARMOR_LIST,L2Config.ENCHANT_CHANCE_ARMOR,item);
  78.                     maxEnchantLevel = L2Config.ENCHANT_MAX_ARMOR;
  79.                 }
  80.             for (int blessedarmorscroll : BLESSED_ARMOR_SCROLLS)
  81.                 if (scroll.getItemId() == blessedarmorscroll)
  82.                 {
  83. -                   chance = L2Config.ENCHANT_CHANCE_BLESSED;
  84. +                   chance = getListChance(L2Config.BLESSED_ENCHANT_CHANCE_ARMOR_LIST,L2Config.ENCHANT_CHANCE_BLESSED,item);
  85.                     maxEnchantLevel = L2Config.ENCHANT_MAX_ARMOR;
  86.                 }
  87.             for (int crystalarmorscroll : CRYSTAL_ARMOR_SCROLLS)
  88. @@ -238,13 +239,13 @@
  89.             for (int normaljewelscroll : NORMAL_ARMOR_SCROLLS)
  90.                 if (scroll.getItemId() == normaljewelscroll)
  91.                 {
  92. -                   chance = L2Config.ENCHANT_CHANCE_JEWELRY;
  93. +                   chance = getListChance(L2Config.ENCHANT_CHANCE_JEWELRY_LIST,L2Config.ENCHANT_CHANCE_JEWELRY,item);
  94.                     maxEnchantLevel = L2Config.ENCHANT_MAX_JEWELRY;
  95.                 }
  96.             for (int blessedjewelscroll : BLESSED_ARMOR_SCROLLS)
  97.                 if (scroll.getItemId() == blessedjewelscroll)
  98.                 {
  99. -                   chance = L2Config.ENCHANT_CHANCE_BLESSED;
  100. +                   chance = getListChance(L2Config.BLESSED_ENCHANT_CHANCE_JEWELRY_LIST,L2Config.ENCHANT_CHANCE_BLESSED,item);
  101.                     maxEnchantLevel = L2Config.ENCHANT_MAX_JEWELRY;
  102.                 }
  103.             for (int crystaljewelscroll : CRYSTAL_ARMOR_SCROLLS)
  104. @@ -395,6 +396,25 @@
  105.         activeChar.broadcastUserInfo();
  106.     }
  107.    
  108. +  
  109. +   public static boolean isInRestrictionList(L2ItemInstance item)
  110. +   {
  111. +       if (L2Config.LIST_ENCHANT_CHANCE_LISTS_RESTRICTION.contains(0)) return true;
  112. +       return L2Config.LIST_ENCHANT_CHANCE_LISTS_RESTRICTION.contains(item.getItemId());      
  113. +   }
  114. +   public static int getListChance(Map<Integer, Integer> ConfigEnchantChanceList, Integer ConfigEnchantChance, L2ItemInstance item)
  115. +   {
  116. +       int chance = 0;
  117. +       if (!ConfigEnchantChanceList.isEmpty() && isInRestrictionList(item))
  118. +       {
  119. +           if (ConfigEnchantChanceList.containsKey(item.getEnchantLevel()+1))
  120. +           chance = ConfigEnchantChanceList.get(item.getEnchantLevel()+1);
  121. +           else chance = ConfigEnchantChance;
  122. +       }
  123. +       else chance = ConfigEnchantChance; 
  124. +       return chance;
  125. +   }
  126. +    
  127.     /* (non-Javadoc)
  128.      * @see com.l2jarchid.gameserver.clientpackets.ClientBasePacket#getType()
  129.      */
  130. Index: src/main/java/com/l2jarchid/L2Config.java
  131. ===================================================================
  132. --- src/main/java/com/l2jarchid/L2Config.java   (revision 980)
  133. +++ src/main/java/com/l2jarchid/L2Config.java   (working copy)
  134. @@ -785,6 +785,14 @@
  135.     public static int           ENCHANT_CHANCE_CRYSTAL;
  136.     public static int           ENCHANT_CHANCE_ARMOR;
  137.     public static int           ENCHANT_CHANCE_JEWELRY;
  138. +   public static Map<Integer, Integer> ENCHANT_CHANCE_WEAPON_LIST;
  139. +   public static Map<Integer, Integer> ENCHANT_CHANCE_ARMOR_LIST;
  140. +   public static Map<Integer, Integer> ENCHANT_CHANCE_JEWELRY_LIST;
  141. +   public static Map<Integer, Integer> BLESSED_ENCHANT_CHANCE_WEAPON_LIST;
  142. +   public static Map<Integer, Integer> BLESSED_ENCHANT_CHANCE_ARMOR_LIST;
  143. +   public static Map<Integer, Integer> BLESSED_ENCHANT_CHANCE_JEWELRY_LIST;
  144. +   public static String        ENCHANT_CHANCE_LISTS_RESTRICTION;
  145. +   public static List<Integer> LIST_ENCHANT_CHANCE_LISTS_RESTRICTION = new FastList<Integer>();
  146.     public static int           ENCHANT_MAX_WEAPON;
  147.     public static int           ENCHANT_MAX_ARMOR;
  148.     public static int           ENCHANT_MAX_JEWELRY;
  149. @@ -840,6 +848,108 @@
  150.             ENCHANT_CHANCE_CRYSTAL          = Integer.parseInt(ratesSettings.getProperty("EnchantChanceCrystal", "100"));
  151.             ENCHANT_CHANCE_ARMOR            = Integer.parseInt(ratesSettings.getProperty("EnchantChanceArmor", "52"));
  152.             ENCHANT_CHANCE_JEWELRY          = Integer.parseInt(ratesSettings.getProperty("EnchantChanceJewelry", "54"));
  153. +                       String[] propertySplitWeapon = ratesSettings.getProperty("EnchantChanceWeaponList", "").split(";");
  154. +                       String[] propertySplitArmor = ratesSettings.getProperty("EnchantChanceArmorList", "").split(";");
  155. +                       String[] propertySplitJewelry = ratesSettings.getProperty("EnchantChanceJewelryList", "").split(";");
  156. +                       String[] propertySplitBlessedWeapon = ratesSettings.getProperty("BlessedEnchantChanceWeaponList", "").split(";");
  157. +                       String[] propertySplitBlessedArmor = ratesSettings.getProperty("BlessedEnchantChanceArmorList", "").split(";");
  158. +                       String[] propertySplitBlessedJewelry = ratesSettings.getProperty("BlessedEnchantChanceJewelryList", "").split(";");
  159. +                       ENCHANT_CHANCE_WEAPON_LIST = new FastMap<Integer, Integer>(propertySplitWeapon.length);
  160. +                       ENCHANT_CHANCE_ARMOR_LIST = new FastMap<Integer, Integer>(propertySplitArmor.length);
  161. +                       ENCHANT_CHANCE_JEWELRY_LIST = new FastMap<Integer, Integer>(propertySplitJewelry.length);
  162. +                       BLESSED_ENCHANT_CHANCE_WEAPON_LIST = new FastMap<Integer, Integer>(propertySplitBlessedWeapon.length);
  163. +                       BLESSED_ENCHANT_CHANCE_ARMOR_LIST = new FastMap<Integer, Integer>(propertySplitBlessedArmor.length);
  164. +                       BLESSED_ENCHANT_CHANCE_JEWELRY_LIST = new FastMap<Integer, Integer>(propertySplitBlessedJewelry.length);
  165. +                   if (propertySplitWeapon.length > 1)
  166. +                   {
  167. +                       for (String enchant : propertySplitWeapon)
  168. +                       {
  169. +                           String[] enchantSplit = enchant.split(",");
  170. +                           if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
  171. +                           else
  172. +                           {
  173. +                               try{ENCHANT_CHANCE_WEAPON_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
  174. +                               catch (NumberFormatException nfe){
  175. +                               if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
  176. +                           }
  177. +                       }
  178. +                   }
  179. +                   if (propertySplitArmor.length > 1)
  180. +                   {
  181. +                       for (String enchant : propertySplitArmor)
  182. +                       {
  183. +                           String[] enchantSplit = enchant.split(",");
  184. +                           if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
  185. +                           else
  186. +                           {
  187. +                               try{ENCHANT_CHANCE_ARMOR_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
  188. +                               catch (NumberFormatException nfe){
  189. +                               if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
  190. +                           }
  191. +                       }
  192. +                   }
  193. +                   if (propertySplitJewelry.length > 1)
  194. +                   {
  195. +                       for (String enchant : propertySplitJewelry)
  196. +                       {
  197. +                           String[] enchantSplit = enchant.split(",");
  198. +                           if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
  199. +                           else
  200. +                           {
  201. +                               try{ENCHANT_CHANCE_JEWELRY_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
  202. +                               catch (NumberFormatException nfe){
  203. +                               if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
  204. +                           }
  205. +                       }
  206. +                   }
  207. +                   if (propertySplitBlessedWeapon.length > 1)
  208. +                   {
  209. +                       for (String enchant : propertySplitBlessedWeapon)
  210. +                       {
  211. +                           String[] enchantSplit = enchant.split(",");
  212. +                           if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
  213. +                           else
  214. +                           {
  215. +                               try{BLESSED_ENCHANT_CHANCE_WEAPON_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
  216. +                               catch (NumberFormatException nfe){
  217. +                               if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
  218. +                           }
  219. +                       }
  220. +                   }
  221. +                   if (propertySplitBlessedArmor.length > 1)
  222. +                   {
  223. +                       for (String enchant : propertySplitBlessedArmor)
  224. +                       {
  225. +                           String[] enchantSplit = enchant.split(",");
  226. +                           if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
  227. +                           else
  228. +                           {
  229. +                               try{BLESSED_ENCHANT_CHANCE_ARMOR_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
  230. +                               catch (NumberFormatException nfe){
  231. +                               if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
  232. +                           }
  233. +                       }
  234. +                   }
  235. +                   if (propertySplitBlessedJewelry.length > 1)
  236. +                   {
  237. +                       for (String enchant : propertySplitBlessedJewelry)
  238. +                       {
  239. +                           String[] enchantSplit = enchant.split(",");
  240. +                           if (enchantSplit.length != 2)_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchant, "\""));
  241. +                           else
  242. +                           {
  243. +                               try{BLESSED_ENCHANT_CHANCE_JEWELRY_LIST.put(Integer.valueOf(enchantSplit[0]), Integer.valueOf(enchantSplit[1]));}
  244. +                               catch (NumberFormatException nfe){
  245. +                               if (!enchant.isEmpty())_log.warning(StringUtil.concat("[CustomEnchantSystem]: invalid config property -> EnchantList \"", enchantSplit[0], "\"", enchantSplit[1]));}
  246. +                           }
  247. +                       }
  248. +                   }
  249. +                   ENCHANT_CHANCE_LISTS_RESTRICTION = ratesSettings.getProperty("EnchantChanceListsRestriction", "0");
  250. +                   LIST_ENCHANT_CHANCE_LISTS_RESTRICTION = new FastList<Integer>();
  251. +                   for (String id : ENCHANT_CHANCE_LISTS_RESTRICTION.split(","))
  252. +                   {
  253. +                       LIST_ENCHANT_CHANCE_LISTS_RESTRICTION.add(Integer.parseInt(id));
  254. +                   }
  255.              /* limit on enchant */
  256.              ENCHANT_MAX_WEAPON              = Integer.parseInt(ratesSettings.getProperty("EnchantMaxWeapon", "255"));
  257.              ENCHANT_MAX_ARMOR               = Integer.parseInt(ratesSettings.getProperty("EnchantMaxArmor", "255"));
  258.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement