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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • GoldRush launches tomorrow! July 18 16:00 GMT+3 Europe / International Register your account in the website, connect wallet and be ready to dominate!
    • 🏰 L2EXALTA LEGACY — Interlude x45 📅 Grand Opening: 31/07/2026 — 21:30 (GMT+3) 🌐 Website: https://l2exalta.org/ 💬 Discord: https://discord.gg/zNTCZD4AcT 📌 Wiki: https://l2exalta.org/en/wiki.html#progression   ⚙️ MAIN INFO Chronicle : Interlude Rates : x45 Adena : x50 Spoil : x1 Drop : x5 Safe Enchant : +3 Files : L2OFF   💰 ECONOMY EX Coin : dynamic market currency, mined from monsters, Raid Bosses and Grand Bosses value fluctuates over time Exalta Vouchers : premium currency used for store, donations and EX Coin exchange Exchange : convert EX Coin into Exalta Vouchers Investment options : choose safer or riskier market strategies with EX Coin   ⚔️ PROGRESSION & GEAR Exalta Armors : signature top-tier gear line Forge System : upgrade weapons, armor and jewels with risk/reward mechanics Raid Boss progression tied to materials and prestige   🤖 AUTOFARM Access : Auto Hunting button, bottom-right UI Duration : controlled via tickets or in-game currency Route Mode : record custom farm routes Support Mode : healer/support builds auto-follow, heal and assist party Smart targeting logic with class-specific behavior (mage/archer/melee/support) Captcha designed not to interrupt legitimate AutoFarm sessions   🧪 BUFFER Exalta Buffer NPC/interface Scheme Buffer : save multiple buff loadouts Class presets for mage, fighter, support, PvP   🛠️ SMART GADGETS / QOL Autoloot filter Drop value tracker Boss timer tools Farm stats tracker Auto-consume system In-game server assistant   🗺️ DUNGEON FINDER / PVE Party matching with roles (Tank / Healer / DPS) Ready-check before teleport Monastery of Silence custom PvE zone Party-based reward structure   🎟️ DAILY PROGRESS / EXALTA PASS Daily and weekly tasks (farm, PvP, boss, check-in) Premium Pass track with extra rewards Monastery Daily Quest Reward boards for claiming progress   🏠 HOUSING & EXPEDITIONS Player residences with service NPCs Exalta Spirit Expeditions to themed territories Rewards vary by territory Owner-only access   🏆 PVP / TOURNAMENT Scheduled Tournament system Ranking points from wins/participation Spectator Mode for watching live matches PvP Statues for top-ranked players Anti-feed protections   🛡️ CLAN CONTENT Clan Civil War battlefield event Clan Dungeon Raid content DPS Meter for contribution tracking Support Credit system Classic siege/clan politics preserved   🏪 AUCTION / SHOPS Auction House with seller fee Black Market Dealer (limited-time special offers) Custom shops and multisells Confirmation prompts on purchases/sales   💳 DONATIONS / VIP Donation rewards linked to Exalta Vouchers VIP tiers with comfort/cosmetic bonuses Premium store Gift/promo codes for events   🎥 STREAMER / COMMUNITY Streamer Panel with visible stream links Viewer rewards system Streamer Points for cosmetics/vouchers In-game voice chat (global/party/clan/alliance/command)   🔒 FAIR PLAY Strong Anti-Bot protection Reward protection tied to valid client state Captcha on suspicious activity Staff investigation tools No bots, packet tools or modified clients allowed   👑 GRANDBOSS SPAWNS Orfen : 1 day + 1h random Core : 1 day + 1h random Queen Ant : 1 day 6h + 1h random Zaken : 2 days 12h + 1h random Baium : 5 days + 1h random Antharas : 8 days + 1h random Valakas : 11 days + 1h random   🏅 OLYMPIAD Runs Thursday, Friday, Saturday Heroes change monthly Balanced and fair matchmaking
    • yup basically another one just in case https://drive.google.com/file/d/1UtccbD9e50x3WEnQBab2PTZnBHwpcGYM/view?usp=sharing LineageWarrior.FMagic (CollideActors = True; > False) LineageWarrior.FOrc (CollideActors = True; > False) LineageWarrior.FShaman (CollideActors = True; > False) LineageWarrior.MDarkElf (CollideActors = True; > False) LineageWarrior.MDwarf (CollideActors = True; > False) LineageWarrior.MElf (CollideActors = True; > False) LineageWarrior.MFighter (CollideActors = True; > False) LineageWarrior.MMagic (CollideActors = True; > False) LineageWarrior.MOrc (CollideActors = True; > False) LineageWarrior.MShaman (CollideActors = True; > False) LineageWarrior.FDwarf (CollideActors = True; > False) LineageWarrior.FElf (CollideActors = True; > False) LineageWarrior.FFighter (CollideActors = True; > False)
    • @l2naylondev Requiring a player to log in just for the sake of logging  seems exploitable. Someone could log in only to claim the reward and immediately leave, or repeatedly change their ip. So i guess  are there are additional protections in place ? such as locking the reward by account, character , and ip. It would also be useful to add a playtime requirement. For example, after logging in, the player would need to remain active for at least x playtime  before getting the reward or other parameters configurable by the xml.  I suggest improving the system before selling it. 
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..