if ((activeChar.getLevel() < 76) || (activeChar.getClassLevel() < 4))
{
activeChar.sendMessage("You must have 3rd class change quest completed.");
return;
}
EnchantSkillLearn sl = SkillTreeTable.getSkillEnchant(_skillId, _skillLvl);
if (sl == null)
{
return;
}
int slevel = activeChar.getSkillDisplayLevel(_skillId);
if (slevel == -1)
{
return;
}
if ((slevel <= sl.getBaseLevel()) || ((slevel % 100) != (_skillLvl % 100)))
{
return;
}
int[] cost = sl.getCost();
int requiredSp = (cost[1] * sl.getCostMult()) / SkillTreeTable.SAFE_ENCHANT_COST_MULTIPLIER;
int requiredAdena = (cost[0] * sl.getCostMult()) / SkillTreeTable.SAFE_ENCHANT_COST_MULTIPLIER;
if (activeChar.getSp() < requiredSp)
{
sendPacket(Msg.SP_REQUIRED_FOR_SKILL_ENCHANT_IS_INSUFFICIENT);
return;
}
if (activeChar.getAdena() < requiredAdena)
{
sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
return;
}
if (_skillId < 10000)
{
if (Functions.getItemCount(activeChar, SkillTreeTable.CHANGE_ENCHANT_BOOK) == 0)
{
activeChar.sendPacket(Msg.ITEMS_REQUIRED_FOR_SKILL_ENCHANT_ARE_INSUFFICIENT);
return;
}
Functions.removeItem(activeChar, SkillTreeTable.CHANGE_ENCHANT_BOOK, 1);
}
else if (_skillId >= 10000)
{
if (Functions.getItemCount(activeChar, SkillTreeTable.NEW_CHANGE_ENCHANT_BOOK) == 0)
{
activeChar.sendPacket(Msg.ITEMS_REQUIRED_FOR_SKILL_ENCHANT_ARE_INSUFFICIENT);
return;
}
Functions.removeItem(activeChar, SkillTreeTable.NEW_CHANGE_ENCHANT_BOOK, 1);
}
Functions.removeItem(activeChar, 57, requiredAdena);
activeChar.addExpAndSp(0, -1 * requiredSp);
int levelPenalty = Rnd.get(Math.min(4, _skillLvl % 100));
_skillLvl -= levelPenalty;
if ((_skillLvl % 100) == 0)
{
_skillLvl = sl.getBaseLevel();
}
Skill skill = SkillTable.getInstance().getInfo(_skillId, SkillTreeTable.convertEnchantLevel(sl.getBaseLevel(), _skillLvl, sl.getMaxLevel()));
if (skill != null)
{
activeChar.addSkill(skill, true);
}
if (levelPenalty == 0)