Jump to content
  • 0

[Help] Max Skill Echant


Question

8 answers to this question

Recommended Posts

  • 0
Posted
# Created by Zoey76
# Version 0.2
# Added check to avoid skill overenchanting.
# Based on Starter's idea/work to cutoff skill enchanting.
# Based on Lineage's Work to avoid skill overenchanting.
# Thanks SolidSnake for time and tips.
#P L2_GameServer
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(revision 4422)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -14970,6 +14970,65 @@
		for (int id : _skills.keySet())
		{
			int level = getSkillLevel(id);
+			
+			if (Config.ENABLE_SKILL_MAX_ENCHANT_LIMIT)
+			{
+				L2Skill fixedSkill = null;
+				int oldLevel = level;
+				if (Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL > 0)
+				{
+					if ((level > (100 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL)) && (level < 131))
+					{
+						level = (100 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL);
+						fixedSkill = SkillTable.getInstance().getInfo(id, level);
+					}
+					else if ((level > (200 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL)) && (level < 231))
+					{
+						level = (200 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL);
+						fixedSkill = SkillTable.getInstance().getInfo(id, level);
+					}
+					else if ((level > (300 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL)) && (level < 331))
+					{
+						level = (300 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL);
+						fixedSkill = SkillTable.getInstance().getInfo(id, level);
+					}
+					else if ((level > (400 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL)) && (level < 431))
+					{
+						level = (400 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL);
+						fixedSkill = SkillTable.getInstance().getInfo(id, level);
+					}
+					else if ((level > (500 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL)) && (level < 531))
+					{
+						level = (500 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL);
+						fixedSkill = SkillTable.getInstance().getInfo(id, level);
+					}
+					else if ((level > (600 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL)) && (level < 631))
+					{
+						level = (600 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL);
+						fixedSkill = SkillTable.getInstance().getInfo(id, level);
+					}
+					else if ((level > (700 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL)) && (level < 731))
+					{
+						level = (700 + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL);
+						fixedSkill = SkillTable.getInstance().getInfo(id, level);
+					}
+				}
+				else if (Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL == 0)
+				{
+					level = SkillTable.getInstance().getMaxLevel(id);
+					fixedSkill = SkillTable.getInstance().getInfo(id, level);
+				}
+				//Setting the new level enchat for the skill.
+				if (fixedSkill != null)
+				{
+					oldLevel = oldLevel % 100;
+					level = level % 100;
+					_log.info("Decreasing skill enchantment from " + oldLevel + " to " + level + " on skill " + id + " from Player: " + getName() + "!");
+					addSkill(fixedSkill, true);
+					level = getSkillLevel(id);//updating skill level for next checks
+				}
+			}
+			
			if (level >= 100) // enchanted skill
				level = SkillTable.getInstance().getMaxLevel(id);
			L2SkillLearn learn = SkillTreeTable.getInstance().getSkillLearnBySkillIdLevel(getClassId(), id, level);
Index: java/com/l2jserver/gameserver/network/clientpackets/RequestExEnchantSkill.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/RequestExEnchantSkill.java	(revision 4420)
+++ java/com/l2jserver/gameserver/network/clientpackets/RequestExEnchantSkill.java	(working copy)
@@ -73,6 +73,20 @@
		if (player == null)
			return;

+		if (Config.ENABLE_SKILL_ENCHANT)
+		{
+			if ((_skillLvl % 100) >= Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL)
+			{
+				player.sendMessage("You have reached max skill enchant level. Allowed on this server up to " + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL + ".");
+				return;
+			}
+		}
+		else
+		{
+			player.sendMessage("You cannot use the skill enchanting function, it's currently turned off.");
+			return;
+		}
+		
		if (player.getClassId().level() < 3) // requires to have 3rd class quest completed
		{
			player.sendPacket(SystemMessageId.YOU_CANNOT_USE_SKILL_ENCHANT_IN_THIS_CLASS);
Index: java/com/l2jserver/gameserver/network/clientpackets/RequestExEnchantSkillSafe.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/RequestExEnchantSkillSafe.java	(revision 4420)
+++ java/com/l2jserver/gameserver/network/clientpackets/RequestExEnchantSkillSafe.java	(working copy)
@@ -71,6 +71,23 @@
		if (player == null)
			return;

+		if (Config.ENABLE_SKILL_ENCHANT)
+		{
+			if (Config.ENABLE_SKILL_MAX_ENCHANT_LIMIT)
+			{
+				if ((_skillLvl % 100) >= Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL)
+				{
+					player.sendMessage("You have reached max skill enchant level. Allowed on this server up to " + Config.SKILL_MAX_ENCHANT_LIMIT_LEVEL + ".");
+					return;
+				}
+			}
+		}
+		else
+		{
+			player.sendMessage("You cannot use the skill enchanting function, it's currently turned off.");
+			return;
+		}
+		
		if (player.getClassId().level() < 3) // requires to have 3rd class quest completed
		{
			player.sendPacket(SystemMessageId.YOU_CANNOT_USE_SKILL_ENCHANT_IN_THIS_CLASS);
Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java	(revision 4422)
+++ java/com/l2jserver/Config.java	(working copy)
@@ -216,6 +216,9 @@
	public static boolean STORE_RECIPE_SHOPLIST;
	public static boolean STORE_UI_SETTINGS;
	public static String[] FORBIDDEN_NAMES;
+	public static boolean ENABLE_SKILL_ENCHANT;
+	public static boolean ENABLE_SKILL_MAX_ENCHANT_LIMIT;
+	public static int SKILL_MAX_ENCHANT_LIMIT_LEVEL;

	//--------------------------------------------------
	// ClanHall Settings
@@ -1645,6 +1648,9 @@
					STORE_RECIPE_SHOPLIST = Boolean.parseBoolean(Character.getProperty("StoreRecipeShopList", "False"));
					STORE_UI_SETTINGS = Boolean.parseBoolean(Character.getProperty("StoreCharUiSettings", "False"));
					FORBIDDEN_NAMES = Character.getProperty("ForbiddenNames", "").split(",");
+					ENABLE_SKILL_ENCHANT = Boolean.parseBoolean(Character.getProperty("EnableSkillEnchant", "True"));
+					ENABLE_SKILL_MAX_ENCHANT_LIMIT = Boolean.parseBoolean(Character.getProperty("EnableSkillMaxEnchantLimit", "False"));
+					SKILL_MAX_ENCHANT_LIMIT_LEVEL = Integer.parseInt(Character.getProperty("SkillMaxEnchantLimitLevel", "30"));
				}
				catch (Exception e)
				{
Index: java/config/Character.properties
===================================================================
--- java/config/Character.properties	(revision 4422)
+++ java/config/Character.properties	(working copy)
@@ -88,7 +88,18 @@
# Default: False
AutoLearnSkills = False

+# Turn this off to avoid skill enchanting.
+# Default: True
+EnableSkillEnchant = True
+# When this is enabled it will read the "SkillMaxEnchantLimitLevel" option.
# Default: False
+EnableSkillMaxEnchantLimit = False
+# When this is over 0, it will cutoff the skill enchant level to it's value.
+# When it's 0 it will removed the current skill enchant.
+# Default: 30
+SkillMaxEnchantLimitLevel = 30
+
+# Default: False
AutoLootHerbs = False

# Maximum number of buffs and songs/dances.

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.



×
×
  • Create New...