Jump to content

Recommended Posts

Posted (edited)

This share is gold for those who know how to use it, it basically unhard-codes all enchant scrolls and gives you the ability to create any scroll with a simple //reload items.

Tested on L2AEPvP (Beta), more details:

 

 

sample XML (very basic)

	<item id="45000" type="EnchantScroll" name="Scroll: Enchant Weapon">
		<set name="default_action" val="skill_reduce" />
		<set name="etcitem_type" val="scrl_enchant_wp" />
		<set name="is_oly_restricted" val="true" />
		<set name="is_stackable" val="true" />
		<set name="handler" val="EnchantScrolls" />
		
		<set name="scroll_binds" val="WEAPON" />
		
		<rates rate="0">
			<tiertarget tier="ANY" rate="0" disprate="80">
				<enchtarget enchants="0-3" rate="100" /> <!-- SAFE -->
				<enchtarget enchants="4-8" rate="80" />
				<enchtarget enchants="9-11" rate="75" />
				<enchtarget enchants="12-15" rate="70" />
				<enchtarget enchants="15" rate="45" disprate="60"/>
				<enchtarget enchants="16,17" rate="60" />
				<enchtarget enchants="18" rate="40" />
				<enchtarget enchants="19" rate="20" />
			</tiertarget>
			<tiertarget tier="COMMON" rate="90" maxench="25" >
				<enchtarget enchants="0,1,2,3,4" rate="100" maxench="25" /> <!-- SAFE -->
			</tiertarget>
		</rates>
		
		<fails penalty="CRYSTALLIZE" >
			<tiertarget tier="UNCOMMON" penalty="NONE" basevalue="0" >
				<enchtarget enchants="7,8,9,10,11,12" penalty="NONE" value="4"/>
				<enchtarget enchants="13,14,15" penalty="DEC" value="1"/>
			</tiertarget>
		</fails>
	</item>

 

Features:

    The possibilities are hundreds, you can create enchant scrolls that can enchant a very specific tier, enchant scrolls that have their own max enchant and so on

    You can calculate the enchant rates and inform the player before the enchant

    Item Grades are obviously ignored

 

Things you have to do to get this working:

1) Create TIERS (enum) and assign it to items

2) Create EnchantFailed (enum) and implement the penalty code

3) Create ScrollBinds (enum) and assign it to each paperdoll

 

Additional things you will need

 

	public static <V extends Enum<V>> EnumSet<V> toEnumSet(String enumStr, Class<V> enumClass)
	{
		if (enumStr == null)
			return EnumSet.noneOf(enumClass);
		final String[] enumStrings = enumStr.replace(" ", "").split(",");
		final EnumSet<V> enums = EnumSet.noneOf(enumClass);
		for (String e : enumStrings)
			enums.add(Enum.valueOf(enumClass, e));
		return enums;
	}

 

	public static int[] toIntArrayEx(String[] strArray)
	{
		final ArrayList<Integer> intList = new ArrayList<>(strArray.length);
		
		for (int i=0;i<strArray.length;i++)
		{	try
			{	
				final String strNum = strArray[i];
				if (strNum.contains("-"))
				{
					final String[] explode = strNum.split("-");
					final int min = Integer.parseInt(explode[0]);
					final int max = Integer.parseInt(explode[1]);
					if (min < max) for (int j = min; j <= max; j++)
						intList.add(j);
				}
				else
					intList.add(Integer.parseInt(strNum));
			}
			catch (Exception e)
			{	e.printStackTrace();
			}
		}
		
		return intList.stream().mapToInt(i->i).toArray();
	}

 

Good luck

Edited by xxdem
  • Like 1
  • Thanks 4
  • Upvote 1
  • 3 weeks later...

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
Reply to this topic...

×   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.

×
×
  • Create New...