Jump to content
  • 0

[Help]Enchant System Acis


Question

Posted

I get this code : http://www.maxcheaters.com/forum/index.php?topic=125525.0

but i cant add on acis because its different

 

Index: /Server/GameServer/java/net/sf/l2j/gameserver/clientpackets/RequestEnchantItem.java
===================================================================
--- /Server/GameServer/java/net/sf/l2j/gameserver/clientpackets/RequestEnchantItem.java (revision 2)
+++ /Server/GameServer/java/net/sf/l2j/gameserver/clientpackets/RequestEnchantItem.java (revision 10)
@@ -41,6 +41,9 @@
     protected static final Logger _log = Logger.getLogger(Inventory.class.getName());
     private static final String _C__58_REQUESTENCHANTITEM = "[C] 58 RequestEnchantItem";
-    private static final int[] CRYSTAL_SCROLLS = { 731, 732, 949, 950, 953, 954, 957, 958, 961, 962 };
-
+	private static final int[] ENCHANT_SCROLLS = { 729, 730, 947, 948, 951, 952, 955, 956, 959, 960 };
+	private static final int[] CRYSTAL_SCROLLS = { 731, 732, 949, 950, 953, 954, 957, 958, 961, 962 };
+	private static final int[] BLESSED_SCROLLS = { 6569, 6570, 6571, 6572, 6573, 6574, 6575, 6576, 6577, 6578 };
+
+    
     private int _objectId;

@@ -57,4 +60,12 @@
         if (activeChar == null || _objectId == 0) return;

+        		if (activeChar.isProcessingTransaction())
+        			{
+        				activeChar.sendPacket(new SystemMessage(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION));
+        				activeChar.setActiveEnchantItem(null);
+        				return;
+        			}
+
+        
         L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
         L2ItemInstance scroll = activeChar.getActiveEnchantItem();
@@ -179,27 +190,93 @@
         }

-        // SystemMessage sm = new SystemMessage(SystemMessageId.ENCHANT_SCROLL_CANCELLED);
-        // activeChar.sendPacket(sm);
-
-        SystemMessage sm;
-
-        int chance = 0;
-        int maxEnchantLevel = 0;
-
-        if (item.getItem().getType2() == L2Item.TYPE2_WEAPON)
-        {
-	        chance = Config.ENCHANT_CHANCE_WEAPON;
-	        maxEnchantLevel = Config.ENCHANT_MAX_WEAPON;
-        }
-        else if (item.getItem().getType2() == L2Item.TYPE2_SHIELD_ARMOR)
-        {
-	        chance = Config.ENCHANT_CHANCE_ARMOR;
-	        maxEnchantLevel = Config.ENCHANT_MAX_ARMOR;
-        }
-        else if (item.getItem().getType2() == L2Item.TYPE2_ACCESSORY)
-        {
-        	chance = Config.ENCHANT_CHANCE_JEWELRY;
-        	maxEnchantLevel = Config.ENCHANT_MAX_JEWELRY;
-        }
+		// SystemMessage sm = new
+		// SystemMessage(SystemMessageId.ENCHANT_SCROLL_CANCELLED);
+		// activeChar.sendPacket(sm);
+		SystemMessage sm;
+		int chance = 0;
+		int maxEnchantLevel = 0;
+		if (item.getItem().getType2() == L2Item.TYPE2_WEAPON)
+		{
+			maxEnchantLevel = Config.ENCHANT_MAX_WEAPON;
+			for (int scrollId : ENCHANT_SCROLLS)
+			{
+				if (scroll.getItemId() == scrollId)
+				{
+					chance = Config.ENCHANT_CHANCE_WEAPON;
+					break;
+				}
+			}
+			for (int scrollId : CRYSTAL_SCROLLS)
+			{
+				if (scroll.getItemId() == scrollId)
+				{
+					chance = Config.ENCHANT_CHANCE_WEAPON_CRYSTAL;
+					;
+					break;
+				}
+			}
+			for (int scrollId : BLESSED_SCROLLS)
+			{
+				if (scroll.getItemId() == scrollId)
+				{
+					chance = Config.ENCHANT_CHANCE_WEAPON_BLESSED;
+					break;
+				}
+			}
+		} else if (item.getItem().getType2() == L2Item.TYPE2_SHIELD_ARMOR)
+		{
+			maxEnchantLevel = Config.ENCHANT_MAX_ARMOR;
+			for (int scrollId : ENCHANT_SCROLLS)
+			{
+				if (scroll.getItemId() == scrollId)
+				{
+					chance = Config.ENCHANT_CHANCE_ARMOR;
+					break;
+				}
+			}
+			for (int scrollId : CRYSTAL_SCROLLS)
+			{
+				if (scroll.getItemId() == scrollId)
+				{
+					chance = Config.ENCHANT_CHANCE_ARMOR_CRYSTAL;
+					break;
+				}
+			}
+			for (int scrollId : BLESSED_SCROLLS)
+			{
+				if (scroll.getItemId() == scrollId)
+				{
+					chance = Config.ENCHANT_CHANCE_ARMOR_BLESSED;
+					break;
+				}
+			}
+		} else if (item.getItem().getType2() == L2Item.TYPE2_ACCESSORY)
+		{
+			maxEnchantLevel = Config.ENCHANT_MAX_JEWELRY;
+			for (int scrollId : ENCHANT_SCROLLS)
+			{
+				if (scroll.getItemId() == scrollId)
+				{
+					chance = Config.ENCHANT_CHANCE_JEWELRY;
+					break;
+				}
+			}
+			for (int scrollId : CRYSTAL_SCROLLS)
+			{
+				if (scroll.getItemId() == scrollId)
+				{
+					chance = Config.ENCHANT_CHANCE_JEWELRY_CRYSTAL;
+					break;
+				}
+			}
+			for (int scrollId : BLESSED_SCROLLS)
+			{
+				if (scroll.getItemId() == scrollId)
+				{
+					chance = Config.ENCHANT_CHANCE_JEWELRY_BLESSED;
+					break;
+				}
+			}
+		}

         if (item.getEnchantLevel() < Config.ENCHANT_SAFE_MAX

15 answers to this question

Recommended Posts

  • 0
Posted

i cannot add the request enchant item.java because its different :/ and i got complicated

 

Use standard code and make it the same way, just if(isBlessed) or so. It's not hard :)

 

Edit: Bah, it's for each enchant, so it's goin to be a bit different. Anyway, on aCis custom section it's already shared :)

  • 0
Posted

Use standard code and make it the same way, just if(isBlessed) or so. It's not hard :)

 

Edit: Bah, it's for each enchant, so it's goin to be a bit different. Anyway, on aCis custom section it's already shared :)

i am newbie and i dont understand so well what u tell me.

 

  • 0
Posted

/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
* 
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
* 
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.network.clientpackets;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.EnchantResult;
import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
import net.sf.l2j.gameserver.network.serverpackets.ItemList;
import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.util.Util;
import net.sf.l2j.util.Rnd;

public final class RequestEnchantItem extends AbstractEnchantPacket
{
private int _objectId = 0;

@Override
protected void readImpl()
{
	_objectId = readD();
}

@Override
protected void runImpl()
{
	final L2PcInstance activeChar = getClient().getActiveChar();
	if (activeChar == null || _objectId == 0)
		return;

	if (!activeChar.isOnline() || getClient().isDetached())
	{
		activeChar.setActiveEnchantItem(null);
		return;
	}

	if (activeChar.isProcessingTransaction() || activeChar.isInStoreMode())
	{
		activeChar.sendPacket(SystemMessageId.CANNOT_ENCHANT_WHILE_STORE);
		activeChar.setActiveEnchantItem(null);
		activeChar.sendPacket(EnchantResult.CANCELLED);
		return;
	}

	L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
	L2ItemInstance scroll = activeChar.getActiveEnchantItem();

	if (item == null || scroll == null)
	{
		activeChar.setActiveEnchantItem(null);
		activeChar.sendPacket(SystemMessageId.ENCHANT_SCROLL_CANCELLED);
		activeChar.sendPacket(EnchantResult.CANCELLED);
		return;
	}

	// template for scroll
	EnchantScroll scrollTemplate = getEnchantScroll(scroll);
	if (scrollTemplate == null)
		return;

	// first validation check
	if (!scrollTemplate.isValid(item) || !isEnchantable(item))
	{
		activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION);
		activeChar.setActiveEnchantItem(null);
		activeChar.sendPacket(EnchantResult.CANCELLED);
		return;
	}

	// attempting to destroy scroll
	scroll = activeChar.getInventory().destroyItem("Enchant", scroll.getObjectId(), 1, activeChar, item);
	if (scroll == null)
	{
		activeChar.sendPacket(SystemMessageId.NOT_ENOUGH_ITEMS);
		Util.handleIllegalPlayerAction(activeChar, activeChar.getName() + " tried to enchant without scroll.", Config.DEFAULT_PUNISH);
		activeChar.setActiveEnchantItem(null);
		activeChar.sendPacket(EnchantResult.CANCELLED);
		return;
	}

	if (activeChar.getActiveTradeList() != null)
	{
		activeChar.cancelActiveTrade();
		activeChar.sendPacket(SystemMessageId.TRADE_ATTEMPT_FAILED);
		return;
	}

	synchronized (item)
	{
		double chance = scrollTemplate.getChance(item);

		// last validation check
		if (item.getOwnerId() != activeChar.getObjectId() || !isEnchantable(item) || chance < 0)
		{
			activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION);
			activeChar.setActiveEnchantItem(null);
			activeChar.sendPacket(EnchantResult.CANCELLED);
			return;
		}

		// success
		if (Rnd.get() < chance)
		{
			// announce the success
			SystemMessage sm;

			if (item.getEnchantLevel() == 0)
			{
				sm = SystemMessage.getSystemMessage(SystemMessageId.S1_SUCCESSFULLY_ENCHANTED);
				sm.addItemName(item.getItemId());
				activeChar.sendPacket(sm);
			}
			else
			{
				sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_SUCCESSFULLY_ENCHANTED);
				sm.addNumber(item.getEnchantLevel());
				sm.addItemName(item.getItemId());
				activeChar.sendPacket(sm);
			}

			item.setEnchantLevel(item.getEnchantLevel() + 1);
			item.updateDatabase();
			activeChar.sendPacket(EnchantResult.SUCCESS);
		}
		else
		{
			// unequip item on enchant failure to avoid item skills stack
			if (item.isEquipped())
			{
				if (item.getEnchantLevel() > 0)
				{
					SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED);
					sm.addNumber(item.getEnchantLevel());
					sm.addItemName(item.getItemId());
					activeChar.sendPacket(sm);
				}
				else
				{
					SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISARMED);
					sm.addItemName(item.getItemId());
					activeChar.sendPacket(sm);
				}

				L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
				InventoryUpdate iu = new InventoryUpdate();
				for (L2ItemInstance itm : unequiped)
					iu.addModifiedItem(itm);

				activeChar.sendPacket(iu);
				activeChar.broadcastUserInfo();
			}

			if (scrollTemplate.isBlessed())
			{
				// blessed enchant - clear enchant value
				activeChar.sendPacket(SystemMessageId.BLESSED_ENCHANT_FAILED);

				item.setEnchantLevel(0);
				item.updateDatabase();
				activeChar.sendPacket(EnchantResult.UNSUCCESS);
			}
			else
			{
				// enchant failed, destroy item
				int crystalId = item.getItem().getCrystalItemId();
				int count = item.getCrystalCount() - (item.getItem().getCrystalCount() + 1) / 2;
				if (count < 1)
					count = 1;

				L2ItemInstance destroyItem = activeChar.getInventory().destroyItem("Enchant", item, activeChar, null);
				if (destroyItem == null)
				{
					// unable to destroy item, cheater ?
					Util.handleIllegalPlayerAction(activeChar, "Unable to delete item on enchant failure from player " + activeChar.getName() + ", possible cheater !", Config.DEFAULT_PUNISH);
					activeChar.setActiveEnchantItem(null);
					activeChar.sendPacket(EnchantResult.CANCELLED);
					return;
				}

				L2ItemInstance crystals = null;
				if (crystalId != 0)
				{
					crystals = activeChar.getInventory().addItem("Enchant", crystalId, count, activeChar, destroyItem);

					SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
					sm.addItemName(crystals.getItemId());
					sm.addItemNumber(count);
					activeChar.sendPacket(sm);
				}

				if (!Config.FORCE_INVENTORY_UPDATE)
				{
					InventoryUpdate iu = new InventoryUpdate();
					if (destroyItem.getCount() == 0)
						iu.addRemovedItem(destroyItem);
					else
						iu.addModifiedItem(destroyItem);

					if (crystals != null)
						iu.addItem(crystals);

					activeChar.sendPacket(iu);
				}
				else
					activeChar.sendPacket(new ItemList(activeChar, true));

				L2World world = L2World.getInstance();
				world.removeObject(destroyItem);
				if (crystalId == 0)
					activeChar.sendPacket(EnchantResult.UNK_RESULT_4);
				else
					activeChar.sendPacket(EnchantResult.UNK_RESULT_1);
			}
		}

		StatusUpdate su = new StatusUpdate(activeChar);
		su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
		activeChar.sendPacket(su);

		activeChar.sendPacket(new ItemList(activeChar, false));
		activeChar.broadcastUserInfo();
		activeChar.setActiveEnchantItem(null);
	}
}
}

here is the original

  • 0
Posted

my friend i am asking for help if i could do this myself i will . thats the reason i am asking help here

if u want somebody to do it for u, make topic in marketplace and if u dont have money for such things just read guides and tell us in which part u are stuck, what errors u have got.

  • 0
Posted

if u want somebody to do it for u, make topic in marketplace and if u dont have money for such things just read guides and tell us in which part u are stuck, what errors u have got.

i dont understand how to do it cause its differnt. example :

+	private static final int[] ENCHANT_SCROLLS = { 729, 730, 947, 948, 951, 952, 955, 956, 959, 960 };
+	private static final int[] CRYSTAL_SCROLLS = { 731, 732, 949, 950, 953, 954, 957, 958, 961, 962 };
+	private static final int[] BLESSED_SCROLLS = { 6569, 6570, 6571, 6572, 6573, 6574, 6575, 6576, 6577, 6578 };
+
+   

where i have to add this there isnt anywhere this line : private static final String _C__58_REQUESTENCHANTITEM = "[C] 58 RequestEnchantItem";

  • 0
Posted

add it at the start of the class

for example your class can look like this:

package blablabla;
import blablabla

public class RequestEnchantItem
{//class starts here
//Its Place where class starts, so its the best place to add variables like ENCHANT_SCROLLS etc. Those variables will be visible in whole class.

public void getEnchant(int bla)
{//Method starts here
//Its the method, if u add variable here, it will be visible only inside this method
}//Method ends here
}//class ends here

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

    • So dont plat that waste time&money server.   GM promises pie in the sky, but does nothing. It's all about money, money, money. And wipe.   SCAM server!
    • I'm looking for someone to remove GameGuard from a game that uses XTRAP. The game no longer uses XTRAP. I have a game server. But the client is kicked from the game after a few minutes of logging in. If I try to remove XTRAP (just by deleting it), the game opens and closes quickly.   Send me a PM. The game is Audition, a dance game.
    • 🎉 L2Dead StuckSub - GRAND OPENING 14 February 2026🎉 After beta, testing, mistakes, laughs and a lot of PvP, the moment has finally come. L2Dead StuckSub is officially opening its gates on 14 February 2026.   ⚔️What to expect: ✦Main Class +6 Stuck Sub system ✦Balanced PvP & custom party farm areas ✦Custom events, bosses and strong rewards ✦Competitive clan scene with castle rewards   📌Until the opening: ✦Create your clans and register them in the Clan-Register channel ✦Invite your friends / old parties / CPs ✦Stay tuned for more information (rates, events, siege times, etc.)   Get your setups ready, prepare your macros and your Discord/voice. On 14 February 2026 20:00 GMT+2, we write the first chapter of L2Dead together. 🔥 https://www.l2dead.com/ https://discord.gg/TGnATuZmdt
    • Here’s the **clean, L2jAcis-style way** to make **Auto Loot work ONLY for Premium players** on **Interlude**.   I’ll give you **two options** — pick what fits your server philosophy.   ---   ## ✅ OPTION 1 (BEST PRACTICE): Premium-Only Auto Loot (Code-based)   ### 🔹 Step 1: Add config option   **`config/Premium.properties`**   ```properties # Enable auto loot only for premium players PremiumAutoLoot = True ```   ---   ### 🔹 Step 2: Read config   **`Config.java`**   ```java public static boolean PREMIUM_AUTO_LOOT; ```   Load it:   ```java PREMIUM_AUTO_LOOT = Premium.getProperty("PremiumAutoLoot", false); ```   ---   ### 🔹 Step 3: Modify drop handling   **File:**   ``` net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance ```   Find **dropItems()** or **doItemDrop()** Replace / modify logic like this:   ```java if (player != null && player.isPremium() && Config.PREMIUM_AUTO_LOOT) {     for (ItemInstance item : items)         player.getInventory().addItem("AutoLoot", item, player, this); } else {     for (ItemInstance item : items)         dropItem(player, item); } ```   ✅ Result:   * **Premium players** → instant loot * **Normal players** → loot on ground   ---   ## ✅ OPTION 2: Auto Loot via Character Variable (More Flexible)   Useful if you want **GM control** per character.   ### 🔹 Premium activation   When premium is added:   ```java player.setVar("AUTO_LOOT", "1"); ```   ### 🔹 Drop check   ```java if (player != null && player.getVarB("AUTO_LOOT")) {     player.addItem("AutoLoot", item, player, true); } else {     dropItem(player, item); } ```   ---   ## 🎯 BONUS (Recommended Add-Ons)   ### 🔸 Adena always auto-loot (even non-premium)   ```java if (item.getItemId() == 57) {     player.addAdena("Loot", item.getCount(), this, true);     continue; } ```   ### 🔸 Party check (premium leader only)   ```java player.isInParty() && player.getParty().getLeader().isPremium() ```   ---   ## ⚠️ Notes (Interlude Safe)   ✔ Compatible with **L2jAcis Interlude** ✔ No client-side changes ✔ No exploit risk ✔ Retail-like behavior   ---      
  • 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..