Hello,
I wanted to change enchant stats of items and for example give +1% of some stat per each enchant. This can help in daggers, so that you can add crit. dmg for each enchant, since +0 and +16 dagger does the same damage with skills.
Since I couldn't do it changing the <enchant> values of the weapons, I modified the core and I can now add custom skills to items. You specify the skill id, and the max skill level. Starting from +1, it gives the player this skill with the level.
On xmls for items and armors, you specify these:
<set name="extra_enchant_skill" val="1045"/>
<set name="extra_enchant_skill_lv" val="6"/>
For example, this adds Bless the Body skill to the item. +0 item has no skill, +1 item has Bless the Body lv1, +2 item has Bless the Body lv2, +6 item has Bless the Body lv6 and everything else sticks to lv6, since there is no lv 7. For example, +16 item has Bless the Body lv6. You can create passive skills and modify anything you want.
This is the diff patch:
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Weapon.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Weapon.java
index 994d4a8..b775ee1 100644
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Weapon.java
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Weapon.java
@@ -55,6 +55,8 @@
private final int _shieldDef;
private final double _shieldDefRate;
private final int _atkSpeed;
+ private final int _extraEnchantSkill;
+ private final int _extraEnchantSkillLevel;
private final int _atkReuse;
private final int _mpConsume;
private final int _mDam;
@@ -93,6 +95,8 @@
_shieldDef = set.getInt("shield_def", 0);
_shieldDefRate = set.getDouble("shield_def_rate", 0);
_atkSpeed = set.getInt("atk_speed", 0);
+ _extraEnchantSkill = set.getInt("extra_enchant_skill", 0);
+ _extraEnchantSkillLevel = set.getInt("extra_enchant_skill_lv", 0);
_atkReuse = set.getInt("atk_reuse", type == WeaponType.BOW ? 1500 : 0);
_mpConsume = set.getInt("mp_consume", 0);
_mDam = set.getInt("m_dam", 0);
@@ -288,6 +292,24 @@
}
/**
+ * Returns skill that player get when has equipped weapon +
+ * @return
+ */
+ public int getExtraEnchantSkill()
+ {
+ return _extraEnchantSkill;
+ }
+
+ /**
+ * Returns max skill level of skill
+ * @return
+ */
+ public int getExtraEnchantSkillLevel()
+ {
+ return _extraEnchantSkillLevel;
+ }
+
+ /**
* Returns array of Func objects containing the list of functions used by the weapon
* @param instance : ItemInstance pointing out the weapon
* @param creature : Creature pointing out the player
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Armor.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Armor.java
index dc7f30e..58ebe25 100644
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Armor.java
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Armor.java
@@ -40,6 +40,8 @@
private final int _mDef;
private final int _mpBonus;
private final int _hpBonus;
+ private final int _extraEnchantSkill;
+ private final int _extraEnchantSkillLevel;
private Skill _itemSkill = null; // for passive skill
/**
@@ -60,6 +62,8 @@
_mDef = set.getInt("m_def", 0);
_mpBonus = set.getInt("mp_bonus", 0);
_hpBonus = set.getInt("hp_bonus", 0);
+ _extraEnchantSkill = set.getInt("extra_enchant_skill", 0);
+ _extraEnchantSkillLevel = set.getInt("extra_enchant_skill_lv", 0);
final int sId = set.getInt("item_skill_id", 0);
final int sLv = set.getInt("item_skill_lvl", 0);
@@ -144,6 +148,24 @@
}
/**
+ * Returns skill that player get when has equipped armor +
+ * @return
+ */
+ public int getExtraEnchantSkill()
+ {
+ return _extraEnchantSkill;
+ }
+
+ /**
+ * Returns max skill level of skill
+ * @return
+ */
+ public int getExtraEnchantSkillLevel()
+ {
+ return _extraEnchantSkillLevel;
+ }
+
+ /**
* Returns array of Func objects containing the list of functions used by the armor
* @param instance : ItemInstance pointing out the armor
* @param creature : Creature pointing out the player
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Inventory.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Inventory.java
index b6419b3..4effb61 100644
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Inventory.java
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Inventory.java
@@ -287,16 +287,23 @@
Skill passiveSkill = null;
Skill enchant4Skill = null;
+ int extraEnchantSkill = 0;
+ int extraEnchantSkillLevel = 0;
final Item it = item.getItem();
if (it instanceof Weapon)
{
passiveSkill = ((Weapon) it).getSkill();
enchant4Skill = ((Weapon) it).getEnchant4Skill();
+ extraEnchantSkill = ((Weapon) it).getExtraEnchantSkill();
+ extraEnchantSkillLevel = ((Weapon) it).getExtraEnchantSkillLevel();
+
}
else if (it instanceof Armor)
{
passiveSkill = ((Armor) it).getSkill();
+ extraEnchantSkill = ((Armor) it).getExtraEnchantSkill();
+ extraEnchantSkillLevel = ((Armor) it).getExtraEnchantSkillLevel();
}
if (!player.isItemEquippedByItemId(item.getItemId()))
@@ -312,6 +319,21 @@
player.removeSkill(enchant4Skill, false);
player.sendSkillList();
}
+
+ if ((extraEnchantSkill > 0) && (item.getEnchantLevel() > 0) && (extraEnchantSkill > 0))
+ {
+ Skill extraSkill = null;
+ if (item.getEnchantLevel() > extraEnchantSkillLevel)
+ {
+ extraSkill = SkillTable.getInstance().getInfo(extraEnchantSkill, extraEnchantSkillLevel);
+ }
+ else
+ {
+ extraSkill = SkillTable.getInstance().getInfo(extraEnchantSkill, item.getEnchantLevel());
+ }
+ player.removeSkill(extraSkill);
+ player.sendSkillList();
+ }
}
}
@@ -330,6 +352,8 @@
Skill passiveSkill = null;
Skill enchant4Skill = null;
+ int extraEnchantSkill = 0;
+ int extraEnchantSkillLevel = 0;
final Item it = item.getItem();
if (it instanceof Weapon)
@@ -348,6 +372,12 @@
{
enchant4Skill = ((Weapon) it).getEnchant4Skill();
}
+
+ if (item.getEnchantLevel() > 0)
+ {
+ extraEnchantSkill = ((Weapon) it).getExtraEnchantSkill();
+ extraEnchantSkillLevel = ((Weapon) it).getExtraEnchantSkillLevel();
+ }
}
else if (it instanceof Armor)
{
@@ -356,6 +386,12 @@
player.refreshMasteryPenality();
// Passive skills from Armor
passiveSkill = ((Armor) it).getSkill();
+
+ if (item.getEnchantLevel() > 0)
+ {
+ extraEnchantSkill = ((Armor) it).getExtraEnchantSkill();
+ extraEnchantSkillLevel = ((Armor) it).getExtraEnchantSkillLevel();
+ }
}
if ((passiveSkill != null) && (!passiveSkill.isSingleEffect() || (player.getInventory().checkHowManyEquipped(item.getItemId()) == 1)))
@@ -369,6 +405,21 @@
player.addSkill(enchant4Skill, false);
player.sendSkillList();
}
+
+ if ((extraEnchantSkill > 0) && (extraEnchantSkillLevel > 0))
+ {
+ Skill extraSkill = null;
+ if (item.getEnchantLevel() > extraEnchantSkillLevel)
+ {
+ extraSkill = SkillTable.getInstance().getInfo(extraEnchantSkill, extraEnchantSkillLevel);
+ }
+ else
+ {
+ extraSkill = SkillTable.getInstance().getInfo(extraEnchantSkill, item.getEnchantLevel());
+ }
+ player.addSkill(extraSkill, false);
+ player.sendSkillList();
+ }
}
}