L2EnchantSkillLearn sl = SkillTreeTable.getSkillEnchant(_skillId, oldSkillLevel);
if(sl == null)
{
return;
}
L2Skill newSkill;
if(_skillLvl % 100 == 0)
{
_skillLvl = sl.getBaseLevel();
newSkill = SkillTable.getInstance().getInfo(_skillId, _skillLvl);
}
else
{
newSkill = SkillTable.getInstance().getInfo(_skillId, SkillTreeTable.convertEnchantLevel(sl.getBaseLevel(), _skillLvl, sl.getMaxLevel()));
}
if(newSkill == null)
{
return;
}
if(Functions.getItemCount(activeChar, SkillTreeTable.UNTRAIN_ENCHANT_BOOK) == 0)
{
activeChar.sendPacket(Msg.ITEMS_REQUIRED_FOR_SKILL_ENCHANT_ARE_INSUFFICIENT);
return;
}
Functions.removeItem(activeChar, SkillTreeTable.UNTRAIN_ENCHANT_BOOK, 1);
activeChar.addExpAndSp(0, sl.getCost()[1] * sl.getCostMult(), false, false);
activeChar.addSkill(newSkill, true);
if(_skillLvl > 100)
{
SystemMessage sm = new SystemMessage(SystemMessage.Untrain_of_enchant_skill_was_successful_Current_level_of_enchant_skill_S1_has_been_decreased_by_1);
sm.addSkillName(_skillId, _skillLvl);
activeChar.sendPacket(sm);
}
else
{
SystemMessage sm = new SystemMessage(SystemMessage.Untrain_of_enchant_skill_was_successful_Current_level_of_enchant_skill_S1_became_0_and_enchant_skill_will_be_initialized);
sm.addSkillName(_skillId, _skillLvl);
activeChar.sendPacket(sm);
}
Log.add(activeChar.getName() + "|Successfully untranes|" + _skillId + "|to+" + _skillLvl + "|---", "enchant_skills");
activeChar.sendPacket(new ExEnchantSkillInfo(_skillId, newSkill.getDisplayLevel()), new ExEnchantSkillResult(1), new SkillList(activeChar));
updateSkillShortcuts(activeChar);
}