-JRGames-

Enchant Items Newbie

Mar 8th, 2021 (edited)
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.56 KB | None | 0 0
  1.  - Parte da config
  2. +# Enchant level (+) for starter items of characters on creation?
  3. +# Default = 0
  4. +NewCharEnchantItems = 6
  5.  
  6.  
  7. diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
  8. index ba3ddff..389d92a 100644
  9. --- a/java/net/sf/l2j/Config.java
  10. +++ b/java/net/sf/l2j/Config.java
  11. @@ -568,7 +575,15 @@
  12.     public static int CHAR_CREATE_LVL;
  13.     public static int NEW_CHAR_ENCHANT_LEVEL;
  14.    
  15.         CHAR_CREATE_LVL = Integer.parseInt(newChar.getProperty("CharLvl", "80"));
  16. +       NEW_CHAR_ENCHANT_LEVEL = newChar.getProperty("NewCharEnchantItems", 0);
  17. +               if (NEW_CHAR_ENCHANT_LEVEL < 0)
  18. +                   NEW_CHAR_ENCHANT_LEVEL = 0;        
  19.  
  20. Index: java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java
  21. ===================================================================
  22. --- java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java   (revision 190)
  23. +++ java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java   (working copy)
  24. @@ -152,6 +164,8 @@
  25.                 if (item.isEquipable() && holder.isEquipped())
  26.                                 player.getInventory().equipItemAndRecord(item);
  27.  
  28. +               if (Config.NEW_CHAR_ENCHANT_LEVEL != 0 && item.isEnchantable())
  29. +                   item.setEnchantLevel(Config.NEW_CHAR_ENCHANT_LEVEL);
  30.  
  31.  
  32. Index: java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java
  33. ===================================================================
  34. --- java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java    (revision 190)
  35. +++ java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java    (working copy)
  36. @@ -43,8 +43,10 @@
  37. +import net.sf.l2j.gameserver.model.item.type.CrystalType;
  38. +import net.sf.l2j.gameserver.model.item.type.WeaponType;
  39.  
  40. @@ -470,6 +472,16 @@
  41.     }
  42.     public final int getCrystalCount()
  43.     {
  44.         return _item.getCrystalCount(_enchantLevel);
  45.     }
  46.  
  47. +   /**
  48. +    * Returns the reference grade of the item.
  49. +    *
  50. +    * @return int
  51. +    */
  52. +   public final CrystalType getItemGrade()
  53. +   {
  54. +       return _item.getCrystalType();
  55. +   }
  56. +  
  57. +   /**
  58.      * @return the reference price of the item.
  59.      */
  60.     public int getReferencePrice()
  61. @@ -1260,4 +1272,17 @@
  62.     public void unChargeAllShots()
  63.     {
  64.         _shotsMask = 0;
  65.     }
  66. +
  67. +   /**
  68. +    * @return true if item can be enchanted.
  69. +    */
  70. +   public boolean isEnchantable()
  71. +   {
  72. +       if (isHeroItem() || isShadowItem() || isEtcItem() || (getItemType() == WeaponType.FISHINGROD) || (getItemGrade() == CrystalType.NONE))
  73. +           return false;
  74. +      
  75. +       // only equipped items or in inventory can be enchanted
  76. +       return ((getLocation() == ItemLocation.INVENTORY) || (getLocation() == ItemLocation.PAPERDOLL));
  77. +   }
  78. +  
  79.  }
  80.  
Add Comment
Please, Sign In to add comment