Jump to content
  • 0

Help On Enchants


Question

9 answers to this question

Recommended Posts

  • 0
Posted

Explain to us what's your problem..

The enchant system is based on uniqueness of the item

and after that the rates are modified on uniqueness of the item

 

i tried to but i get wrong when i enchant because the rates are w/e for example: 

+ 0 50% +1 75% +2 45% etc etc 

also when breaks goes to -1 and not the starting base

also if item +19 enchant is %100 and if breks goes to +17 

 

the reason i needed a guy that already worked on this pack

  • 0
Posted

Give a try inside of Clientpackets/AbstractEnchantPacket.java

 

I don't know the base of this project, but maybe will be there.

package net.sf.l2j.gameserver.network.clientpackets;
import java.util.Arrays;
import java.util.Map;

import javolution.util.FastMap;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.templates.item.L2ArmorType;
import net.sf.l2j.gameserver.templates.item.L2Item;
import net.sf.l2j.gameserver.templates.item.L2WeaponType;

public abstract class AbstractEnchantPacket extends L2GameClientPacket
{
public static final Map<Integer, EnchantScroll> _scrolls = new FastMap<Integer, EnchantScroll>();
public static final Map<Integer, EnchantItem> _supports = new FastMap<Integer, EnchantItem>();

public static final int ITEM_DESTROYED = 0;
public static final int ENCHANT_TO_4_OR_0 = 1;
public static final int ENCHANT_MINUS_ONE_OR_NEXT_LEVEL = 2;
public static final int REMAIN_SAME_ENCHANT = 3;
public static final int ENCHANT_TO_10_OR_6_OR_3_OR_0 = 4;
public static final int RETURNS_TO_0 = 5;
public static final int ENCHANT_TO_7_OR_3_OR_0 = 6;

public static class EnchantItem
{
protected final boolean _isWeapon;
protected final int _grade;
protected int _maxEnchantLevel = 20;
protected final int _chanceAdd;
protected final int[] _itemIds;

public EnchantItem(boolean wep, int type, int level, int chanceAdd, int[] items)
{
	_isWeapon = wep;
	_grade = type;
	_maxEnchantLevel = level;
	_chanceAdd = chanceAdd;
	_itemIds = items;
}

/*
 * Return true if support item can be used for this item
 */
public final boolean isValid(L2ItemInstance targetItem)
{
	if (targetItem == null)
		return false;
	
	final int type2 = targetItem.getItem().getType2();
	
	// checking scroll type and configured maximum enchant level
	switch (type2)
	{
	// weapon scrolls can enchant only weapons
	case L2Item.TYPE2_WEAPON:
		if (!_isWeapon /*|| (Config.ENCHANT_MAX_WEAPON > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_WEAPON)*/)
			return false;
		break;
		// armor scrolls can enchant only accessory and armors
	case L2Item.TYPE2_SHIELD_ARMOR:
		if (targetItem.getItemType() == L2ArmorType.SIGIL)
		{
			if (!_isWeapon)
				return false;
		}
		else if (_isWeapon /*|| (Config.ENCHANT_MAX_ARMOR > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_ARMOR)*/)
			return false;
		break;
	case L2Item.TYPE2_ACCESSORY:
		if (_isWeapon /*|| (Config.ENCHANT_MAX_JEWELRY > 0 && enchantItem.getEnchantLevel() >= Config.ENCHANT_MAX_JEWELRY)*/)
			return false;
		break;
	default:
		return false;
	}
	
	// check for crystal types
	if (_grade != targetItem.getItem().getItemGradeSPlus())
		return false;
	
	if (targetItem.isTimeLimitedItem())
	{
		int max = 99;
		
		switch ((int)targetItem.getItem().getUniqueness())
		{
		case 0:
			break;
		case 1:
			max = 11;
			break;
		case 2:
			max = 8;
			break;
		case 3:
			max = 4;
			break;
		default:
			max = 0;
		}
		
		if (targetItem.getEnchantLevel() >= max)
			return false;
	}
	
	if (targetItem.isStarterItem())
	{
		int max = 15;
		
		switch ((int)targetItem.getItem().getUniqueness())
		{
		case 0:
			break;
		case 1:
			max = 14;
			break;
		case 2:
			max = 12;
			break;
		case 3:
			max = 11;
			break;
		case 4:
			if (targetItem.getItem().getUniqueness() == 4.5)
				max = 3;
			else
				max = 8;
			break;
		case 5:
			max = 0;
			break;
		}
		
		if (targetItem.getEnchantLevel() >= max)
		{
			targetItem.getActingPlayer().sendMessage("Your item is a starter item, and thus have reached its enchant limit");
			return false;
		}
	}
	
	// check for maximum enchant level
	if (_maxEnchantLevel != 0 && targetItem.getEnchantLevel() >= _maxEnchantLevel)
		return false;
	
	if(_itemIds != null && Arrays.binarySearch(_itemIds, targetItem.getItemId()) < 0)
		return false;
	
	return true;
}

public final int getChanceAdd()
{
	return _chanceAdd;
}
}

public static final class EnchantScroll extends EnchantItem
{
private final boolean _isForbidden;
private final boolean _isLegendary;
private final boolean _isBlessed;
private final boolean _isCrystal;
private final boolean _isSafe;
private final int _scrollLvl;

public EnchantScroll(boolean wep, boolean bless, boolean crystal, boolean safe, int type, int level, int chance, int[] items)
{
	super(wep, type, level, chance, items);
	
	_isBlessed = bless;
	_isCrystal = crystal;
	_isSafe = safe;
	_isForbidden = false;
	_isLegendary = false;
	
	if (_isForbidden)
		_scrollLvl = 4;
	else if (_isLegendary)
		_scrollLvl = 3;
	else if (_isBlessed)
		_scrollLvl = 2;
	else if (_isCrystal)
		_scrollLvl = 1;
	else
		_scrollLvl = 0;
}

public EnchantScroll(boolean wep, boolean bless, boolean crystal, boolean safe, boolean forbidden, boolean legendary, int type, int level, int chance, int[] items)
{
	super(wep, type, level, chance, items);
	
	_isBlessed = bless;
	_isCrystal = crystal;
	_isSafe = safe;
	_isForbidden = forbidden;
	_isLegendary = legendary;
	
	if (_isForbidden)
		_scrollLvl = 4;
	else if (_isLegendary)
		_scrollLvl = 3;
	else if (_isBlessed)
		_scrollLvl = 2;
	else if (_isCrystal)
		_scrollLvl = 1;
	else
		_scrollLvl = 0;
}

public final boolean isForbidden()
{
	return _isForbidden;
}

public final boolean isLegendary()
{
	return _isLegendary;
}

public final boolean isBlessed()
{
	return _isBlessed;
}

public final boolean isCrystal()
{
	return _isCrystal;
}

/*
 * Return true for safe-enchant scrolls (enchant level will remain on failure)
 */
public final boolean isSafe()
{
	return _isSafe;
}

public final int getMaxEnchantLevel(final L2ItemInstance enchantItem)
{
	return _maxEnchantLevel;
}

public final boolean isValid(L2ItemInstance enchantItem, EnchantItem supportItem)
{
	// blessed scrolls can't use support items
	if (supportItem != null && (!supportItem.isValid(enchantItem) || isBlessed()))
		return false;
	
	return isValid(enchantItem);
}

public final int getChance(final L2ItemInstance enchantItem, final EnchantItem supportItem)
{
	if (isBlessed() || isForbidden() || isLegendary())
	{
		if (supportItem != null)// blessed scrolls does not use support items
			return -200;
	}
	
	if (!isValid(enchantItem, supportItem))
		return -200;
	
	if (!enchantItem.isStandardShopItem() && enchantItem.isWeapon())
	{
		if (!enchantItem.isRaidbossItem()) //rares, epics
		{
			int chance = 40;
			
			switch (_scrollLvl)
			{
			case 0: //normal scrolls
				break;
			case 1: //crystal scrolls
				chance = 54;
				break;
			case 2: //blessed scrolls
				chance = 70;
				break;
			case 3: //legendary scrolls
				chance = 75;
				break;
			case 4: //forbidden
				chance = 80;
				break;
			default:
				System.out.println("LOL WTF get enchant chance has a 'default' scroll wtf lol");
				return -1;
			}
			
			switch (enchantItem.getEnchantLevel())
			{
			case 10:
				chance -= 3;
				break;
			case 11:
				chance -= 7;
				break;
			case 12:
				chance -= 10;
				break;
			case 13:
				chance -= 14;
				break;
			case 14:
				chance -= 17;
				break;
			case 15:
				chance -= 21;
				break;
			case 16:
				chance -= 25;
				break;
			case 17:
				chance -= 29;
				break;
			case 18:
				chance -= 34;
				break;
			case 19:
				chance -= 40;
				break;
			case 20:
				chance -= 50;
				break;
			}
			
			if (enchantItem.isAtOrOverMustBreakEnchantLevel())
			{
				chance -= 7;
				chance /= 2.5;
			}
			
			return chance;
		}
	}
	
	int chance = 0;
	
	switch (enchantItem.getEnchantLevel())
	{
	case 0:
	case 1:
	case 2:
		chance = 100;
		break;
	case 3:
		chance = 95;
		break;
	case 4:
		chance = 90;
		break;
	case 5:
		chance = 85;
		break;
	case 6:
		chance = 80;
		break;
	case 7:
		chance = 75;
		break;
	case 8:
		chance = 70;
		break;
	case 9:
		chance = 65;
		break;
	case 10:
		chance = 60;
		break;
	case 11:
		chance = 55;
		break;
	case 12:
		chance = 50;
		break;
	case 13:
		chance = 45;
		break;
	case 14:
		chance = 40;
		break;
	case 15:
		chance = 35;
		break;
	case 16:
		chance = 30;
		break;
	case 17:
		chance = 25;
		break;
	case 18:
		chance = 20;
		break;
	case 19:
		chance = 15;
		break;
	default:
		chance = 10;
	}
	
	if (enchantItem.getEnchantLevel() < 10 && enchantItem.getUniqueness() <= 4)
	{
		chance += 15;
	}
	else if (enchantItem.getEnchantLevel() < 12 && enchantItem.getUniqueness() <= 3) //vesper boost
	{
		chance += 10;
	}
	else if (enchantItem.getUniqueness() >= 4.5)
	{
		if (enchantItem.isStandardShopItem())
		{
			if (enchantItem.getEnchantLevel() >= 10)
				chance -= (enchantItem.getEnchantLevel()-9)*5;
		}
		else
		{
			if (enchantItem.getEnchantLevel() >= 10)
				chance -= (enchantItem.getEnchantLevel()-9)*5;
		}
	}
	else if (enchantItem.getUniqueness() >= 4)
	{
		if (enchantItem.isStandardShopItem())
		{
			if (enchantItem.getEnchantLevel() >= 11)
				chance -= 5;
		}
		else
		{
			if (enchantItem.getEnchantLevel() >= 10)
				chance -= 5;
		}
	}
	else if (enchantItem.getUniqueness() >= 3.5)
	{
		if (enchantItem.isStandardShopItem())
		{
			if (enchantItem.getEnchantLevel() >= 14)
				chance -= 5;
		}
		else
		{
			if (enchantItem.getEnchantLevel() >= 15)
				chance -= 10;
			else if (enchantItem.getEnchantLevel() >= 14)
				chance -= 5;
		}
	}
	else if (enchantItem.getUniqueness() >= 3)
	{
		if (enchantItem.isStandardShopItem())
		{
			if (enchantItem.getEnchantLevel() >= 18)
				chance -= 5;
		}
		else
		{
			if (enchantItem.getEnchantLevel() >= 16)
				chance -= 5;
		}
	}
	
	chance += _chanceAdd;
	
	if (supportItem != null)
		chance += supportItem.getChanceAdd();
	
	chance += enchantItem.getItem().getWeight();
	
	switch (_scrollLvl)
	{
	case 0: //normal scrolls
		chance += 10;
		if (enchantItem.getItem().getUniqueness() >= 3.5)
			chance -= 5;
		break;
	case 1: //crystal scrolls
		if (((enchantItem.getItem().getUniqueness() >= 3 && enchantItem.getEnchantLevel() >= 10) || enchantItem.getItem().getUniqueness() >= 4) && !enchantItem.isStandardShopItem())
			chance -= 5;
		break;
	case 2: //blessed scrolls
		chance += 30;
		break;
	case 3: //legendary scrolls
		chance += 40;
		if (enchantItem.isAtOrOverMustBreakEnchantLevel())
			chance -= 5;
		else if (enchantItem.getItem().getUniqueness() >= 4)
			chance += 5;
		break;
	case 4: //forbidden
		chance += 50;
		if (enchantItem.isAtOrOverMustBreakEnchantLevel())
			chance -= 5;
		else if (enchantItem.getItem().getUniqueness() >= 4)
			chance += 5;
		break;
	default :
		System.out.println("LOL WTF get enchant chance has a 'default' scroll wtf lol");
		return -1;
	}
	
	if (enchantItem.isAtOrOverMustBreakEnchantLevel())
	{
		chance -= 3;
		chance /= 2;
	}
	return chance;
}

/**
 * @param enchantItem - item to be enchanted
 * @return
 * 3 = item and enchant stay the same
 * 2 = enchant is subtracted by 1
 * 1 = enchant is set to 0
 * 0 = item is destroyed
 */
public final byte determineFateOfItemIfFail(final L2ItemInstance enchantItem)
{
	if (_isForbidden)
		return REMAIN_SAME_ENCHANT;
	
	/*	if (_isSafe)
		return REMAIN_SAME_ENCHANT;*/
	
	final float uniqueness = enchantItem.getItem().getUniqueness();
	
	if (_isLegendary)
	{
		switch ((int)uniqueness)
		{
		case 0:
			return REMAIN_SAME_ENCHANT;
		case 1:
			return REMAIN_SAME_ENCHANT;
		case 2:
			return REMAIN_SAME_ENCHANT;
		case 3:
			return REMAIN_SAME_ENCHANT;
		case 4:
			if (!enchantItem.isStandardShopItem())
				return ENCHANT_TO_10_OR_6_OR_3_OR_0;
			return ENCHANT_MINUS_ONE_OR_NEXT_LEVEL;
		case 5:
			if (!enchantItem.isStandardShopItem())
				return ENCHANT_TO_10_OR_6_OR_3_OR_0;
			return ENCHANT_MINUS_ONE_OR_NEXT_LEVEL;
		}
	}
	else if (_isBlessed)
	{
		if (!enchantItem.isStandardShopItem())
		{
			switch ((int)uniqueness)
			{
			case 5:
			case 4:
				if (enchantItem.getEnchantLevel() >= 6)
					return ITEM_DESTROYED;
				break;
			case 3:
				if (enchantItem.isRaidbossItem() && enchantItem.getEnchantLevel() >= 13)
					return ITEM_DESTROYED;
				else if (enchantItem.getEnchantLevel() >= 16)
					return ITEM_DESTROYED;
				break;
			default:
				if (enchantItem.getEnchantLevel() >= 15)
					return ITEM_DESTROYED;
			}
		}
		
		switch ((int)uniqueness)
		{
		case 0:
			return REMAIN_SAME_ENCHANT;
		case 1:
			return REMAIN_SAME_ENCHANT;
		case 2:
			return ENCHANT_MINUS_ONE_OR_NEXT_LEVEL;
		case 3:
			return ENCHANT_TO_10_OR_6_OR_3_OR_0;
		case 4:
			if (uniqueness > 4 && enchantItem.getEnchantLevel() >= 11)
				return ITEM_DESTROYED;
			else if (uniqueness >= 4 && enchantItem.getEnchantLevel() >= 13)
				return ITEM_DESTROYED;
			else if (uniqueness == 4)
				return ENCHANT_TO_7_OR_3_OR_0;
			else
				return ENCHANT_TO_4_OR_0;
		case 5:
			return RETURNS_TO_0;
		}
	}
	else if (_isCrystal)
	{
		if (!enchantItem.isStandardShopItem())
		{
			if (uniqueness >= 4)
			{
				if (enchantItem.getEnchantLevel() >= 3)
					return ITEM_DESTROYED;
			}
			else if (enchantItem.getEnchantLevel() >= 9)
				return ITEM_DESTROYED;
		}
		
		switch ((int)uniqueness)
		{
		case 0:
			return ENCHANT_MINUS_ONE_OR_NEXT_LEVEL;
		case 1:
			return ENCHANT_MINUS_ONE_OR_NEXT_LEVEL;
		case 2:
			if (enchantItem.getEnchantLevel() >= enchantItem.getItem().getClutchEnchantLevel())
				return ITEM_DESTROYED;
			else
				return ENCHANT_TO_10_OR_6_OR_3_OR_0;
		case 3:
			if (enchantItem.getEnchantLevel() >= enchantItem.getItem().getClutchEnchantLevel()-1)
				return ITEM_DESTROYED;
			else
				return ENCHANT_TO_4_OR_0;
		case 4:
			if (uniqueness > 4 && enchantItem.getEnchantLevel() >= 6)
				return ITEM_DESTROYED;
			else if (uniqueness >= 4 && enchantItem.getEnchantLevel() >= 12)
				return ITEM_DESTROYED;
			else
				return RETURNS_TO_0;
		case 5:
			return ITEM_DESTROYED;
		}
	}
	else //normal scrolls
	{
		if (!enchantItem.isStandardShopItem())
			return ITEM_DESTROYED;
		
		switch ((int)uniqueness)
		{
		case 0:
			return ENCHANT_TO_10_OR_6_OR_3_OR_0;
		case 1:
			return ENCHANT_TO_4_OR_0;
		case 2:
			return ITEM_DESTROYED;
		case 3:
			return ITEM_DESTROYED;
		case 4:
			return ITEM_DESTROYED;
		case 5:
			return ITEM_DESTROYED;
		}
	}
	
	return ITEM_DESTROYED;
}
}

static
{
	// itemId, (isWeapon, isBlessed, isCrystal, isSafe, grade, max enchant level, chance increase, allowed item IDs)
	// allowed items list must be sorted by ascending order
	
	// Titanium enchant scrolls
	_scrolls.put(99950, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_S, 11, 100, new int[]{90018,90019,90020,90021,90022,90023,90024,90025,90026,90027,90028,90029,90030,90031,90032,90033,90034}));
	_scrolls.put(99951, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_S, 11, 100, new int[]{13140,13141,13142,13435,13436,13437,13448,13449,13450,13451,13452,13453,13454,13455,13456,74000,74001
			,74002,74003,74004,74010,74011,74012,74013,74014,74020,74021,74022,74023,74024,90035}));
	
	_scrolls.put(99952, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_S, 14, 100, new int[]{90018,90019,90020,90021,90022,90023,90024,90025,90026,90027,90028,90029,90030,90031,90032,90033,90034}));
	_scrolls.put(99953, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_S, 14, 100, new int[]{13140,13141,13142,13435,13436,13437,13448,13449,13450,13451,13452,13453,13454,13455,13456,74000,74001
			,74002,74003,74004,74010,74011,74012,74013,74014,74020,74021,74022,74023,74024,90035}));
	
	// Dread enchant scrolls
	_scrolls.put(99954, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_S, 10, 100, new int[]{90000,90001,90002,90003,90004,90005,90006,90007,90008,90009,90010,90011,90012,90013,90014,90015,90016,90017}));
	_scrolls.put(99955, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_S, 10, 100, new int[]{71000,71001,71002,71003,71004,71010,71011,71012,71013,71014,71020,71021,71022,71023,71024,
			72000,72001,72002,72003,72004,72010,72011,72012,72013,72014,72020,72021,72022,72023,72024}));
	
	_scrolls.put(729, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_A, 20, 0, null));
	_scrolls.put(730, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_A, 20, 0, null));
	_scrolls.put(731, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_A, 20, 0, null));
	_scrolls.put(732, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_A, 20, 0, null));
	_scrolls.put(947, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_B, 20, 0, null));
	_scrolls.put(948, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_B, 20, 0, null));
	_scrolls.put(949, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_B, 20, 0, null));
	_scrolls.put(950, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_B, 20, 0, null));
	_scrolls.put(951, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_C, 20, 0, null));
	_scrolls.put(952, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_C, 20, 0, null));
	_scrolls.put(953, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_C, 20, 0, null));
	_scrolls.put(954, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_C, 20, 0, null));
	_scrolls.put(955, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_D, 20, 0, null));
	_scrolls.put(956, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_D, 20, 0, null));
	_scrolls.put(957, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_D, 20, 0, null));
	_scrolls.put(958, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_D, 20, 0, null));
	
	_scrolls.put(959, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_S, 20, 0, null));
	_scrolls.put(960, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_S, 20, 0, null));
	_scrolls.put(961, new EnchantScroll(true, false, true, false, L2Item.CRYSTAL_S, 20, 0, null));
	_scrolls.put(962, new EnchantScroll(false, false, true, false, L2Item.CRYSTAL_S, 20, 0, null));
	
	_scrolls.put(6569, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_A, 20, 0, null));
	_scrolls.put(6570, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_A, 20, 0, null));
	_scrolls.put(6571, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_B, 20, 0, null));
	_scrolls.put(6572, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_B, 20, 0, null));
	_scrolls.put(6573, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_C, 20, 0, null));
	_scrolls.put(6574, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_C, 20, 0, null));
	_scrolls.put(6575, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_D, 20, 0, null));
	_scrolls.put(6576, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_D, 20, 0, null));
	
	_scrolls.put(6577, new EnchantScroll(true, true, false, false, L2Item.CRYSTAL_S, 20, 0, null));
	_scrolls.put(6578, new EnchantScroll(false, true, false, false, L2Item.CRYSTAL_S, 20, 0, null));
	
	_scrolls.put(22006, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_D, 20, 0, null));
	_scrolls.put(22007, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_C, 20, 0, null));
	_scrolls.put(22008, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_B, 20, 0, null));
	_scrolls.put(22009, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_A, 20, 0, null));
	_scrolls.put(22010, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_D, 20, 0, null));
	_scrolls.put(22011, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_C, 20, 0, null));
	_scrolls.put(22012, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_B, 20, 0, null));
	_scrolls.put(22013, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_A, 20, 0, null));
	_scrolls.put(22014, new EnchantScroll(true, false, false, false, false, true, L2Item.CRYSTAL_S, 25, 0, null));
	_scrolls.put(22015, new EnchantScroll(true, false, false, true, L2Item.CRYSTAL_A, 20, 0, null));
	_scrolls.put(22016, new EnchantScroll(false, false, false, false, false, true, L2Item.CRYSTAL_S, 25, 0, null));
	_scrolls.put(22017, new EnchantScroll(false, false, false, true, L2Item.CRYSTAL_A, 20, 0, null));
	_scrolls.put(22018, new EnchantScroll(true, false, false, false, true, false, L2Item.CRYSTAL_S, 25, 0, null));
	_scrolls.put(22019, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_A, 20, 0, null));
	_scrolls.put(22020, new EnchantScroll(false, false, false, false, true, false, L2Item.CRYSTAL_S, 25, 0, null));
	_scrolls.put(22021, new EnchantScroll(false, false, false, false, L2Item.CRYSTAL_A, 20, 0, null));
	
	// Master Yogi's Scroll Enchant Weapon (event)
	_scrolls.put(13540, new EnchantScroll(true, false, false, false, L2Item.CRYSTAL_NONE, 0, 0, new int[]{ 13539 }));
	
	// itemId, (isWeapon, grade, max enchant level, chance increase)
	_supports.put(12362, new EnchantItem(true, L2Item.CRYSTAL_D, 15, 20, null));
	_supports.put(12363, new EnchantItem(true, L2Item.CRYSTAL_C, 15, 18, null));
	_supports.put(12364, new EnchantItem(true, L2Item.CRYSTAL_B, 15, 15, null));
	_supports.put(12365, new EnchantItem(true, L2Item.CRYSTAL_A, 15, 12, null));
	_supports.put(12366, new EnchantItem(true, L2Item.CRYSTAL_S, 15, 10, null));
	_supports.put(12367, new EnchantItem(false, L2Item.CRYSTAL_D, 15, 35, null));
	_supports.put(12368, new EnchantItem(false, L2Item.CRYSTAL_C, 15, 27, null));
	_supports.put(12369, new EnchantItem(false, L2Item.CRYSTAL_B, 15, 23, null));
	_supports.put(12370, new EnchantItem(false, L2Item.CRYSTAL_A, 15, 18, null));
	_supports.put(12371, new EnchantItem(false, L2Item.CRYSTAL_S, 15, 15, null));
	_supports.put(14702, new EnchantItem(true, L2Item.CRYSTAL_D, 15, 20, null));
	_supports.put(14703, new EnchantItem(true, L2Item.CRYSTAL_C, 15, 18, null));
	_supports.put(14704, new EnchantItem(true, L2Item.CRYSTAL_B, 15, 15, null));
	_supports.put(14705, new EnchantItem(true, L2Item.CRYSTAL_A, 15, 12, null));
	_supports.put(14706, new EnchantItem(true, L2Item.CRYSTAL_S, 15, 10, null));
	_supports.put(14707, new EnchantItem(false, L2Item.CRYSTAL_D, 15, 35, null));
	_supports.put(14708, new EnchantItem(false, L2Item.CRYSTAL_C, 15, 27, null));
	_supports.put(14709, new EnchantItem(false, L2Item.CRYSTAL_B, 15, 23, null));
	_supports.put(14710, new EnchantItem(false, L2Item.CRYSTAL_A, 15, 18, null));
	_supports.put(14711, new EnchantItem(false, L2Item.CRYSTAL_S, 15, 15, null));
}

/**
 * Return enchant template for scroll
 */
protected static final EnchantScroll getEnchantScroll(L2ItemInstance scroll)
{
	return _scrolls.get(scroll.getItemId());
}

/**
 * Return enchant template for support item
 */
protected static final EnchantItem getSupportItem(L2ItemInstance item)
{
	return _supports.get(item.getItemId());
}

/**
 * Return true if item can be enchanted
 */
protected static final boolean isEnchantable(L2ItemInstance item)
{
	if (item.isHeroItem())
		return false;
	if (item.isShadowItem())
		return false;
	if (item.isCommonItem())
		return false;
	if (item.isEtcItem())
		return false;
	/*		if (item.isTimeLimitedItem())
			return false;*/
	if (item.isWear())
		return false;
	// rods
	if (item.getItem().getItemType() == L2WeaponType.ROD)
		return false;
	// apprentice and travelers weapons
	if (item.getItemId() >= 7816 && item.getItemId() <= 7831)
		return false;
	// bracelets
	if (item.getItem().getBodyPart() == L2Item.SLOT_L_BRACELET)
		return false;
	if (item.getItem().getBodyPart() == L2Item.SLOT_R_BRACELET)
		return false;
	if (item.getItem().getBodyPart() == L2Item.SLOT_BACK)
		return false;
	// only items in inventory and equipped can be enchanted
	if (item.getLocation() != L2ItemInstance.ItemLocation.INVENTORY && item.getLocation() != L2ItemInstance.ItemLocation.PAPERDOLL)
		return false;
	
	return true;
}
}

where getUniquness is the weapon grade* ,

public int getPermChance()
{
	return _permChance;
}

public float getUniqueness()
{
	return _uniqueness;
}

public int getClutchEnchantLevel()
{
	if (getUniqueness() == 0)  
	{
		return 21;
	}
	else if (getUniqueness() == 1)
	{
		return 21;
	}
	else if (getUniqueness() == 1.5)  
	{
		return 20;
	}
	else if (getUniqueness() == 2) 
	{
		return 20;
	}
	else if (getUniqueness() == 2.5) 
	{
		return 19;
	}
	else if (isRaidbossItem()) 
	{
		return 14;
	}
	else if (getUniqueness() == 3) 
	{
		if (getName().contains("Dynasty"))
			return 17;
		if (getItemId() != 14163 && getItemId() != 14164 && getItemId() != 14165)
			return 16;
		return 14;
	}
	else if (getUniqueness() == 3.5) 
	{
		return 14;
	}
	else if (getUniqueness() == 4)  
	{
		if (isStandardShopItem())
			return 12;
		else
			return 11;
	}
	else if (getUniqueness() == 4.5) 
	{
		return 8;
	}
	else if (getUniqueness() == 5) 
	{
		return 4;
	}
	
	return 65535;
} 
  • 0
Posted (edited)

l2pride enchant system is hardcoded and completly complex for no reason, you won't be able to make notable modifications on it with minimal coding knowledge

Edited by xxdem

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

    • --- Interlude GvE PvP new season start at 2026-06-27 21:00 GMT+3 ---   Gameplay: Chronicle: Interlude Type: Faction/GvE (Angels vs Nature vs Demons) GM Shop: B-S grade Buff slots: 20+4 Starting level: 74 + rebirth system   New Features: Client: Modern interface based on Essence Balance: New class skills for better balance Achievement Rewards: Daily, Weekly, One-time TOP rankings: PvP, Event PvP, Map PvP, Clan PvP, Event MvP, Map MvP Zones: 70 different PvP zones,  18 different events (8 map events | 10 main events) 12 Grand/raid bosses. Castle siege Olympiad Clan Hall challenge Custom Enchant System: Dynamic success chance (greater enchant level or item grade less enchanting success chance) Enchant rate: Blessed scrolls dynamic from 100% to 25%. Crystal Scrolls: 100%; Max enchant weapon +12 Max enchant armor +8 Safe point enchant system Extra Features: PvP items with level upgrade Weapon/Armor upgrade (from B grade to S) system Attributes system   Website: https://l2cygnus.com Community: Discord Facebook: https://www.facebook.com/l2cygnus Youtube: 
    • 🚀 L2JOne Website System — Features & Security Overview 📌 Overview The L2JOne Website System is a complete platform designed for Lineage 2 servers, providing account management, donation processing, game integration, automation tools, and advanced security protections.   Built with a focus on: Security Performance Automation Scalability Easy Administration 🎮 Player Features ✔ Account Registration Direct account creation from the website Game database integration Data validation Optional email verification Google reCAPTCHA protection ✔ Secure Login System Protected user sessions Automatic Session ID regeneration Session Fixation protection Secure logout ✔ Player Control Panel Ticket balance management Purchase history Transfer history Character selection Automatic item delivery ✔ Account Recovery Email-based recovery Temporary recovery tokens Automatic token expiration 💰 Donation System Supported Payment Gateways Mercado Pago PIX Credit Card Debit Card Stripe International credit cards PayPal Worldwide payments Binance Pay Cryptocurrency payments ⚡ Automated Credit Delivery Once a payment is confirmed: Gateway validates the transaction. Webhook signature is verified. Order is marked as completed. Credits are added to the player's balance. Player transfers credits to a character. Items are automatically delivered in-game. No manual intervention required. 🎁 Coupon System Percentage discounts Fixed value discounts Usage limits Expiration dates Minimum purchase requirements 🎟 Ticket System Internal virtual currency Item conversion system Administrative adjustments Full transaction history Balance management 📊 Administrative Dashboard Real-Time Statistics Total revenue Daily revenue New registrations Total purchases Pending payments Approved payments Reports Sales reports Financial reports Player activity reports Transfer history Interactive Charts Revenue growth Daily earnings Monthly earnings Visitors by country Payment distribution 🌍 Analytics System Visitor countries Browser statistics Operating systems Device tracking Access history 📰 News Management System Unlimited news posts Featured images HTML editor support Homepage highlights 🎥 Video & Streaming System Supports: YouTube Twitch Kick Custom stream embeds ⏳ Countdown System Launch countdown timer Configurable date and time Timezone support Homepage integration 📥 Download Center Fully configurable: Game Client Official Patch Mirror Downloads Torrent Downloads External Download Links 📱 Social Media Integration Discord Facebook Instagram Telegram YouTube 🔒 Security Layer CSRF Protection All forms include: Unique security tokens Mandatory validation Automatic expiration Protects against: Cross-Site Request Forgery (CSRF) Google reCAPTCHA Protection Integrated Google reCAPTCHA v3 Protects against: Bots Automated registrations Brute-force attacks Session Security Session ID regeneration HttpOnly cookies SameSite cookie protection Secure cookie support Protects against: Session hijacking Session fixation attacks Upload Protection Sensitive file types are blocked: .sql .sqlite .log .pem .key Directory Protection Direct access denied to: config/ private/ storage/ cli/ database/ Unauthorized access is blocked. Anti-Replay Protection Financial callbacks include: Signed timestamps Expiration windows One-time validation Protects against: Payment replay attacks Duplicate transaction processing Webhook Security HMAC signature validation Shared secret verification Mandatory request authentication Protects against: Fake payment notifications Fraudulent credit generation Duplicate Payment Prevention Built-in: Idempotency control Transaction reference validation Payment status verification Prevents: Double credits Repeated processing SQL Injection Protection Secure database layer using: PDO Prepared Statements Parameter Binding No unsafe SQL concatenation. XSS Protection Output sanitization through: HTML escaping Input filtering Protects against: Cross-Site Scripting (XSS) Session theft Licensing Protection Centralized licensing system with: Unique license key Unique secret key Remote validation Domain verification Heartbeat monitoring Anti-Cloning Protection Licenses are linked to: Authorized domain Unique credentials Central validation server Unauthorized domain usage can be automatically blocked. ⚙ Administrative Tools User Management Create accounts Edit accounts Suspend users Adjust balances Financial Management Approve transactions Cancel orders Financial reports Content Management News management Download management Video management Social media management Global Settings Rates configuration Countdown management Payment gateway settings License management 🚀 Technology Stack PHP 8+ MySQL 9+ / MariaDB 11+ Bootstrap 5.3.8 AdminLTE 4..0.2 Mercado Pago SDK Stripe SDK PayPal API Binance Pay API Google reCAPTCHA v3 PDO Secure Database Layer 🛡 Final Result The L2JOne Website System delivers a professional-grade solution for Lineage 2 servers, combining: ✅ Modern Administrative Dashboard ✅ Advanced Donation System ✅ Automatic In-Game Delivery ✅ Real-Time Statistics ✅ Centralized Licensing Platform ✅ Financial Fraud Protection ✅ SQL Injection Protection ✅ XSS Protection ✅ CSRF Protection ✅ Anti-Replay Security ✅ Anti-Cloning Protection A complete, secure, and scalable platform built for professional Lineage 2 server operations DEMO SITE: "My Site" - Lineage II I am currently studying programming in Trybe | Cursos de Inteligência Artificial e Tecnologia Price: 150 USDT Payment methods: Crypto using the Tron network or PayPal (you pay an administrative fee). You can choose to pay a monthly fee to get new features or stick with your current version with security updates! The maintenance fee is only 30 USDT per month. Customers currently using my website: http://www.l2shadowwars.com/                                                                                                        Panel Admin:            Database WebSIte     PANEL PLAYER     StartPack    
    • Fixed a lot of null crashes, damn vanganth 🤣 Added engine that you can create your custom quests Extender dungeon systen so u can create as many dungeons as you like       Possibility to create a server from scratch its possible just is the work + the license/month , many ask for the creation.. i can do everything u like, i can even implement UFOs to fly over gym so.. whatever your dream is i can be as close as possible!
    • Hello, it is someone here to help me to make multiskill on helios pack? ( Not stacksub ) i want. On Hi5 i have this config .   # When enabled, the following will be true: # All classes can learn all skills. # Skills of another class costs x2 SP to learn. # Skills of another race costs x2 SP to learn. # Skills of fighters/mages costs x3 SP to learn. # Default: False AltGameSkillLearn = True
  • 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..