Jump to content
  • 0

[Help] New Enchant Scrolls


Question

Posted

Feliz, Navidad, Merry Christmas.

 

This is my abstractEnchantPacket.java

 

:poker face:

 

package net.sf.l2j.gameserver.network.clientpackets;

 

import gnu.trove.map.hash.TIntObjectHashMap;

 

import net.sf.l2j.Config;

import net.sf.l2j.gameserver.model.L2ItemInstance;

import net.sf.l2j.gameserver.templates.item.L2Item;

import net.sf.l2j.gameserver.templates.item.L2Weapon;

import net.sf.l2j.gameserver.templates.item.L2WeaponType;

 

public abstract class AbstractEnchantPacket extends L2GameClientPacket

{

  public static final TIntObjectHashMap<EnchantScroll> _scrolls = new TIntObjectHashMap<>();

 

  public static final class EnchantScroll

  {

      protected final boolean _isWeapon;

      protected final int _grade;

      private final boolean _isBlessed;

      private final boolean _isCrystal;

     

      public EnchantScroll(boolean wep, boolean bless, boolean crystal, int type)

      {

        _isWeapon = wep;

        _grade = type;

        _isBlessed = bless;

        _isCrystal = crystal;

      }

     

      /**

      * @param enchantItem : The item to enchant.

      * @return true if support item can be used for this item

      */

      public final boolean isValid(L2ItemInstance enchantItem)

      {

        if (enchantItem == null)

            return false;

       

        // checking scroll type and configured maximum enchant level

        switch (enchantItem.getItem().getType2())

        {

            case L2Item.TYPE2_WEAPON:

              if (!_isWeapon || (Config.ENCHANT_MAX_WEAPON > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_WEAPON))

                  return false;

              break;

           

            case L2Item.TYPE2_SHIELD_ARMOR:

            case L2Item.TYPE2_ACCESSORY:

              if (_isWeapon || (Config.ENCHANT_MAX_ARMOR > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_ARMOR))

                  return false;

              break;

           

            default:

              return false;

        }

       

        // check for crystal type

        if (_grade != enchantItem.getItem().getCrystalType())

            return false;

       

        return true;

      }

     

      /**

      * @return true if item is a blessed scroll.

      */

      public final boolean isBlessed()

      {

        return _isBlessed;

      }

     

      /**

      * @return true if item is a crystal scroll.

      */

      public final boolean isCrystal()

      {

        return _isCrystal;

      }

     

      /**

      * Regarding enchant system :

 

      *

 

      * Weapons

      * <ul>

      * <li>magic weapons has chance of 40% until +15 and 20% from +15 and higher. There is no upper limit, there is no dependance on current enchant level.</li>

      * <li>non magic weapons has chance of 70% until +15 and 35% from +15 and higher. There is no upper limit, there is no dependance on current enchant level.</li>

      * </ul>

      * Armors

      * <ul>

      * <li>non fullbody armors (jewelry, upper armor, lower armor, boots, gloves, helmets and shirts) has chance of 2/3 for +4, 1/3 for +5, 1/4 for +6, ...., 1/18 +20. If you've made a +20 armor, chance to make it +21 will be equal to zero (0%).</li>

      * <li>full body armors has a chance of 1/1 for +4, 2/3 for +5, 1/3 for +6, ..., 1/17 for +20. If you've made a +20 armor, chance to make it +21 will be equal to zero (0%).</li>

      * </ul>

      * @param enchantItem : The item to enchant.

      * @return the enchant chance under double format (0.7 / 0.35 / 0.44324...).

      */

      public final double getChance(L2ItemInstance enchantItem)

      {

        if (!isValid(enchantItem))

            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 1;

       

        double chance = 0;

       

        // Armor formula : 0.66^(current-2), chance is lower and lower for each enchant.

        if (enchantItem.isArmor())

            chance = Math.pow(Config.ENCHANT_CHANCE_ARMOR, (enchantItem.getEnchantLevel() - 2));

        // Weapon formula is 70% for fighter weapon, 40% for mage weapon. Special rates after +14.

        else if (enchantItem.isWeapon())

        {

            if (((L2Weapon) enchantItem.getItem()).isMagical())

              chance = (enchantItem.getEnchantLevel() > 14) ? Config.ENCHANT_CHANCE_WEAPON_MAGIC_15PLUS : Config.ENCHANT_CHANCE_WEAPON_MAGIC;

            else

              chance = (enchantItem.getEnchantLevel() > 14) ? Config.ENCHANT_CHANCE_WEAPON_NONMAGIC_15PLUS : Config.ENCHANT_CHANCE_WEAPON_NONMAGIC;

        }

       

        return chance;

      }

  }

 

  /**

    * Format : itemId, (isWeapon, isBlessed, isCrystal, grade)

 

    * Allowed items IDs must be sorted by ascending order.

    */

  static

  {

      // Scrolls: Enchant Weapon

      _scrolls.put(729, new EnchantScroll(true, false, false, L2Item.CRYSTAL_A));

      _scrolls.put(947, new EnchantScroll(true, false, false, L2Item.CRYSTAL_B));

      _scrolls.put(951, new EnchantScroll(true, false, false, L2Item.CRYSTAL_C));

      _scrolls.put(955, new EnchantScroll(true, false, false, L2Item.CRYSTAL_D));

      _scrolls.put(959, new EnchantScroll(true, false, false, L2Item.CRYSTAL_S));

     

      // Scrolls: Enchant Armor

      _scrolls.put(730, new EnchantScroll(false, false, false, L2Item.CRYSTAL_A));

      _scrolls.put(948, new EnchantScroll(false, false, false, L2Item.CRYSTAL_B));

      _scrolls.put(952, new EnchantScroll(false, false, false, L2Item.CRYSTAL_C));

      _scrolls.put(956, new EnchantScroll(false, false, false, L2Item.CRYSTAL_D));

      _scrolls.put(960, new EnchantScroll(false, false, false, L2Item.CRYSTAL_S));

     

      // Blessed Scrolls: Enchant Weapon

      _scrolls.put(6569, new EnchantScroll(true, true, false, L2Item.CRYSTAL_A));

      _scrolls.put(6571, new EnchantScroll(true, true, false, L2Item.CRYSTAL_B));

      _scrolls.put(6573, new EnchantScroll(true, true, false, L2Item.CRYSTAL_C));

      _scrolls.put(6575, new EnchantScroll(true, true, false, L2Item.CRYSTAL_D));

      _scrolls.put(6577, new EnchantScroll(true, true, false, L2Item.CRYSTAL_S));

     

      // Blessed Scrolls: Enchant Armor

      _scrolls.put(6570, new EnchantScroll(false, true, false, L2Item.CRYSTAL_A));

      _scrolls.put(6572, new EnchantScroll(false, true, false, L2Item.CRYSTAL_B));

      _scrolls.put(6574, new EnchantScroll(false, true, false, L2Item.CRYSTAL_C));

      _scrolls.put(6576, new EnchantScroll(false, true, false, L2Item.CRYSTAL_D));

      _scrolls.put(6578, new EnchantScroll(false, true, false, L2Item.CRYSTAL_S));

     

      // Crystal Scrolls: Enchant Weapon

      _scrolls.put(731, new EnchantScroll(true, false, true, L2Item.CRYSTAL_A));

      _scrolls.put(949, new EnchantScroll(true, false, true, L2Item.CRYSTAL_B));

      _scrolls.put(953, new EnchantScroll(true, false, true, L2Item.CRYSTAL_C));

      _scrolls.put(957, new EnchantScroll(true, false, true, L2Item.CRYSTAL_D));

      _scrolls.put(961, new EnchantScroll(true, false, true, L2Item.CRYSTAL_S));

     

      // Crystal Scrolls: Enchant Armor

      _scrolls.put(732, new EnchantScroll(false, false, true, L2Item.CRYSTAL_A));

      _scrolls.put(950, new EnchantScroll(false, false, true, L2Item.CRYSTAL_B));

      _scrolls.put(954, new EnchantScroll(false, false, true, L2Item.CRYSTAL_C));

      _scrolls.put(958, new EnchantScroll(false, false, true, L2Item.CRYSTAL_D));

      _scrolls.put(962, new EnchantScroll(false, false, true, L2Item.CRYSTAL_S));

     

      // Special scrolls(event): Enchant Weapon

      _scrolls.put(12269, new EnchantScroll(true, true, false, L2Item.CRYSTAL_A));

      _scrolls.put(12271, new EnchantScroll(true, true, false, L2Item.CRYSTAL_B));

      _scrolls.put(12273, new EnchantScroll(true, true, false, L2Item.CRYSTAL_C));

      _scrolls.put(12275, new EnchantScroll(true, true, false, L2Item.CRYSTAL_D));

      _scrolls.put(12277, new EnchantScroll(true, true, false, L2Item.CRYSTAL_S));

     

      // Special scrolls(event): Enchant Armor

      _scrolls.put(12270, new EnchantScroll(false, true, false, L2Item.CRYSTAL_A));

      _scrolls.put(12272, new EnchantScroll(false, true, false, L2Item.CRYSTAL_B));

      _scrolls.put(12274, new EnchantScroll(false, true, false, L2Item.CRYSTAL_C));

      _scrolls.put(12276, new EnchantScroll(false, true, false, L2Item.CRYSTAL_D));

      _scrolls.put(12278, new EnchantScroll(false, true, false, L2Item.CRYSTAL_S));

  }

 

  /**

    * @param scroll The instance of item to make checks on.

    * @return enchant template for scroll.

    */

  protected static final EnchantScroll getEnchantScroll(L2ItemInstance scroll)

  {

      return _scrolls.get(scroll.getItemId());

  }

 

  /**

    * @param item The instance of item to make checks on.

    * @return true if item can be enchanted.

    */

  protected static final boolean isEnchantable(L2ItemInstance item)

  {

      if (item.isHeroItem() || item.isShadowItem() || item.isEtcItem() || item.getItem().getItemType() == L2WeaponType.FISHINGROD)

        return false;

     

      // only equipped items or in inventory can be enchanted

      if (item.getLocation() != L2ItemInstance.ItemLocation.INVENTORY && item.getLocation() != L2ItemInstance.ItemLocation.PAPERDOLL)

        return false;

     

      return true;

  }

}

 

I want to register new scrolls correctly and give them a 100% enchant rate.

Anyone can help me?

Is there an easy way? I am aCis user.

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • We are taking new orders. Kindly DM us on Telegram!
    • Hello everyone!  I’d like to share an experience that might serve as a lesson for anyone planning to work with third-party protection services—specifically, Active Anticheat. I know this might sound like a strange job request, but  our player base mostly consists of veteran of Lineage 2 players who are used to using bots as part of their gameplay experience. As server administrators, we decided to adapt to our users. That’s why we approached Active Anticheat with a proposal: Allow bot usage under certain conditions. We explained everything in detail, and they agreed.   📌 February – A Promising Start On February 16th, we contacted Active Anticheat to request a custom antibot system. The idea was to kick players using bots during specific times (like sieges), but allow them to log back in without bots afterward. After a few discussions, both sides agreed on the following solution: Bots allowed during regular days. During siege events, anyone using a bot would be automatically kicked. Kicked players could log back in without using bots. The deal was priced at $5,000, which we already paid on March 31st, 2025. Active Anticheat promised delivery by the end of April, or at the latest, by May. Screenshot:  Deal 1 Deal 2   🕐 May – The Delays Begin We followed up multiple times in May, only to finally hear back on May 26th: “It won’t be ready this month. But we’re working on a big update coming in June.” That update? Still nowhere to be seen, even as I’m writing this post. Screenshot:  Delayed   🔁 Plan B – L2Walker Rejected, Adrenaline Offered With our server launch schedule getting tighter, we needed an alternative. At the end of June, we asked Active Anticheat: “Can you at least allow L2Walker access to the server?” Their response on June 28th: “L2Walker can’t be allowed. But we can allow Adrenaline (free & paid version) and L2Helper for $2,000 + $300 (for a new license).” We agreed, hoping it would be a temporary fix while waiting for the promised “big update” (which we had already paid $5,000 for, remember?). Screenshot:  New Offer 1 New Offer 2 New Offer 3   ❌ AA Failed Their setup took about a week. We ran 2–3 rounds of testing using clean clients. The result? Adrenaline (both free and paid) couldn’t connect to our server. It couldn’t detect the Lineage 2 client, because the custom Active Anticheat protection was blocking it. We reached out to Active Anticheat for support, and their response? “You should contact Adrenaline support to enable free Adrenaline for your server. Adrenaline blocks it by default when Active Anticheat is detected.” Then we tested Premium Adrenaline. And it still didn’t work. Active Anticheat stood firm: “It’s not our fault. Adrenaline blocked us—not the other way around.” Screenshot: Failed 1 Failed 2   💸 The Bitter Reality Today, we’re still waiting for answers. No reply. No fix. No update. No refund. We’ve spent a total of $7,300 and received nothing functional in return. And this, despite their full agreement with our initial plan.  
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock