Page 1 of 1
[SOLVED] How to set enchant to +6 when they are +20
Posted: Wed Mar 19, 2014 6:53 am
by HappyLDE
If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision
6377:
L2JDP Revision
10159:
Hello,
I'm using one of the unstable revisions (
just before all NPCs moved to xml!)
The question: I want to set internally the items to be as +6 even if they are +20 or even +100 so that skills don't get unbalanced. In what direction to go and can we do this by changing only one core file.
Like the file that is reading the enchant level of an item and set it? What file it is?
Thank you

Re: How to set enchant to +6 when they are +20
Posted: Wed Mar 19, 2014 1:34 pm
by UnAfraid
check L2ItemInstance there is a config for olympiad max enchant level use it as example.
Re: How to set enchant to +6 when they are +20
Posted: Wed Mar 19, 2014 8:16 pm
by HappyLDE
Thank you! In L2ItemInstance i changed the
getEnchantLevel() function. In the insertIntoDb, restoreFromDb and updateInDb functions i used
_enchantLevel instead of
getEnchantLevel().
So items from +1 to +25 are calculated into +1 to +8
Code: Select all
public int getEnchantLevel() { // Any items enchanted higher than 25 (eg GM weapons) return the true enchantment if (_enchantLevel > 25) { return _enchantLevel; } float percentEnchant25 = (_enchantLevel * 100) / 25; // Bring +1 to +25 items to +1 to +8 // 8 / 100 = 0.08 int newEnchantValue = (int) (0.08 * percentEnchant25); return newEnchantValue; }
Edit: Well that doesn't seem to get the wanted result. If i enchant to +25 i get the item as +8... but i want it to be +25 and it's power as +8 :s
Re: How to set enchant to +6 when they are +20
Posted: Wed Mar 19, 2014 11:16 pm
by Zoey76
Of course it wouldn't work as you wish because that is the value returned to send to the clients to display "enchant glow".
Go to L2ItemInstace#getEnchantLevel() and right click it and select "Open Call Hierarchy" and it will bring up a window with about 35 calls, ignore all that related to system messages and packets (like trade and user info) follow those that go into the part of code related to HP and attack calculations and you could call getNerfedEnchantLevel() method that is your method and have your own formula.

Re: How to set enchant to +6 when they are +20
Posted: Thu Mar 20, 2014 7:25 am
by HappyLDE
Right so i restored
getEnchantLevel() to original and added
getNerfedEnchantLevel() with the formula.
I only added the getNerfedEnchantLevel() to 2 files:
Code: Select all
-L2ItemInstance#getOlyEnchantLevel() @Override-FuncEnchant#calc
And now it works! Since getNerfedEnchantLevel() return +8 if item is +25 and +26 if item is +26 the difference in damage, patk, pdef, skill and hp is huge as if applies correctly. And visually it looks +25 even if power +8 now.
Thank you!

Re: How to set enchant to +6 when they are +20
Posted: Tue Mar 25, 2014 5:54 pm
by JMD
HappyLDE wrote:Right so i restored
getEnchantLevel() to original and added
getNerfedEnchantLevel() with the formula.
I only added the getNerfedEnchantLevel() to 2 files:
Code: Select all
-L2ItemInstance#getOlyEnchantLevel() @Override-FuncEnchant#calc
And now it works! Since getNerfedEnchantLevel() return +8 if item is +25 and +26 if item is +26 the difference in damage, patk, pdef, skill and hp is huge as if applies correctly. And visually it looks +25 even if power +8 now.
Thank you!

Can you share a patch for this?
Re: [SOLVED] How to set enchant to +6 when they are +20
Posted: Fri Mar 28, 2014 3:44 pm
by HappyLDE
Sure:
Code: Select all
### Eclipse Workspace Patch 1.0#P L2J_Server_BETAIndex: java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java===================================================================--- java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java (revision 6377)+++ java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java (working copy)@@ -886,6 +886,23 @@ return _enchantLevel; } + public int getNerfedEnchantLevel()+ {+ // Any items enchanted higher than 25 (eg GM weapons) return the true enchantment+ if (_enchantLevel > 25)+ {+ return _enchantLevel;+ }+ + float percentEnchant25 = (_enchantLevel * 100) / 25;+ + // Bring +1 - +25 items to +1 - +8+ // 8 / 100 = 0.08+ int newEnchantValue = (int) (0.08 * percentEnchant25);+ + return newEnchantValue;+ }+ /** * @param enchantLevel the enchant value to set */@@ -1648,7 +1665,7 @@ ps.setLong(2, getCount()); ps.setString(3, _loc.name()); ps.setInt(4, _locData);- ps.setInt(5, getEnchantLevel());+ ps.setInt(5, _enchantLevel); ps.setInt(6, getCustomType1()); ps.setInt(7, getCustomType2()); ps.setInt(8, getMana());@@ -1684,7 +1701,7 @@ ps.setLong(3, getCount()); ps.setString(4, _loc.name()); ps.setInt(5, _locData);- ps.setInt(6, getEnchantLevel());+ ps.setInt(6, _enchantLevel); ps.setInt(7, getObjectId()); ps.setInt(8, _type1); ps.setInt(9, _type2);@@ -2030,7 +2047,7 @@ public int getOlyEnchantLevel() { L2PcInstance player = getActingPlayer();- int enchant = getEnchantLevel();+ int enchant = getNerfedEnchantLevel(); if (player == null) { Index: java/com/l2jserver/gameserver/model/skills/funcs/FuncEnchant.java===================================================================--- java/com/l2jserver/gameserver/model/skills/funcs/FuncEnchant.java (revision 6377)+++ java/com/l2jserver/gameserver/model/skills/funcs/FuncEnchant.java (working copy)@@ -42,7 +42,7 @@ } L2ItemInstance item = (L2ItemInstance) funcOwner; - int enchant = item.getEnchantLevel();+ int enchant = item.getNerfedEnchantLevel(); if (enchant <= 0) {
Re: [SOLVED] How to set enchant to +6 when they are +20
Posted: Fri Mar 28, 2014 5:41 pm
by JMD
HappyLDE wrote:Sure:
Code: Select all
### Eclipse Workspace Patch 1.0#P L2J_Server_BETAIndex: java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java===================================================================--- java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java (revision 6377)+++ java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java (working copy)@@ -886,6 +886,23 @@ return _enchantLevel; } + public int getNerfedEnchantLevel()+ {+ // Any items enchanted higher than 25 (eg GM weapons) return the true enchantment+ if (_enchantLevel > 25)+ {+ return _enchantLevel;+ }+ + float percentEnchant25 = (_enchantLevel * 100) / 25;+ + // Bring +1 - +25 items to +1 - +8+ // 8 / 100 = 0.08+ int newEnchantValue = (int) (0.08 * percentEnchant25);+ + return newEnchantValue;+ }+ /** * @param enchantLevel the enchant value to set */@@ -1648,7 +1665,7 @@ ps.setLong(2, getCount()); ps.setString(3, _loc.name()); ps.setInt(4, _locData);- ps.setInt(5, getEnchantLevel());+ ps.setInt(5, _enchantLevel); ps.setInt(6, getCustomType1()); ps.setInt(7, getCustomType2()); ps.setInt(8, getMana());@@ -1684,7 +1701,7 @@ ps.setLong(3, getCount()); ps.setString(4, _loc.name()); ps.setInt(5, _locData);- ps.setInt(6, getEnchantLevel());+ ps.setInt(6, _enchantLevel); ps.setInt(7, getObjectId()); ps.setInt(8, _type1); ps.setInt(9, _type2);@@ -2030,7 +2047,7 @@ public int getOlyEnchantLevel() { L2PcInstance player = getActingPlayer();- int enchant = getEnchantLevel();+ int enchant = getNerfedEnchantLevel(); if (player == null) { Index: java/com/l2jserver/gameserver/model/skills/funcs/FuncEnchant.java===================================================================--- java/com/l2jserver/gameserver/model/skills/funcs/FuncEnchant.java (revision 6377)+++ java/com/l2jserver/gameserver/model/skills/funcs/FuncEnchant.java (working copy)@@ -42,7 +42,7 @@ } L2ItemInstance item = (L2ItemInstance) funcOwner; - int enchant = item.getEnchantLevel();+ int enchant = item.getNerfedEnchantLevel(); if (enchant <= 0) {
Thank you.