{
// already knows the skill with this level
return;
}
L2Skill skill = SkillTable.getInstance().getInfo(_id, _level);
int counts = 0;
int _requiredSp = 10000000;
if (_skillType == 0)
{
L2SkillLearn[] skills = SkillTreeTable.getInstance()
.getAvailableSkills(player, player.getSkillLearningClassId());
for (L2SkillLearn s : skills)
{
L2Skill sk = SkillTable.getInstance().getInfo(s.getId(),
s.getLevel());
if (sk == null || sk != skill
|| !sk.getCanLearn(player.getSkillLearningClassId())
|| !sk.canTeachBy(npcid))
continue;
counts++;
_requiredSp = SkillTreeTable.getInstance().getSkillCost(player,
skill);
}
if (counts == 0 && !Config.ALT_GAME_SKILL_LEARN)
{
player
.sendMessage("You are trying to learn skill that u can't..");
Util.handleIllegalPlayerAction(player, "Player "
+ player.getName()
+ " tried to learn skill that he can't!!!",
IllegalPlayerAction.PUNISH_KICK);
return;
}
if (player.getSp() >= _requiredSp)
{
if (Config.SP_BOOK_NEEDED)
{
int spbId = SkillSpellbookTable.getInstance()
.getBookForSkill(skill);
if (skill.getLevel() == 1 && spbId > -1)
{
L2ItemInstance spb = player.getInventory()
.getItemByItemId(spbId);
if (spb == null)
{
// Haven't spellbook
player.sendPacket(new SystemMessage(
SystemMessageId.ITEM_MISSING_TO_LEARN_SKILL));
return;
}
// ok
player.destroyItem("Consume", spb, trainer, true);
}
}
} else
{
SystemMessage sm = new SystemMessage(
SystemMessageId.NOT_ENOUGH_SP_TO_LEARN_SKILL);
player.sendPacket(sm);
sm = null;
return;
}
} else if (_skillType == 1)
{
int costid = 0;
int costcount = 0;
// Skill Learn bug Fix
L2SkillLearn[] skillsc = SkillTreeTable.getInstance()
.getAvailableSkills(player);
for (L2SkillLearn s : skillsc)
{
L2Skill sk = SkillTable.getInstance().getInfo(s.getId(),
s.getLevel());
if (sk == null || sk != skill)
continue;
counts++;
costid = s.getIdCost();
costcount = s.getCostCount();
_requiredSp = s.getSpCost();
}
if (counts == 0)
{
player
.sendMessage("You are trying to learn skill that u can't..");
Util.handleIllegalPlayerAction(player, "Player "
+ player.getName()
+ " tried to learn skill that he can't!!!",
IllegalPlayerAction.PUNISH_KICK);
return;
}
if (player.getSp() >= _requiredSp)
{
if (!player.destroyItemByItemId("Consume", costid, costcount,
trainer, false))
{
// Haven't spellbook
player.sendPacket(new SystemMessage(
SystemMessageId.ITEM_MISSING_TO_LEARN_SKILL));
return;
}
SystemMessage sm = new SystemMessage(
SystemMessageId.DISSAPEARED_ITEM);
sm.addNumber(costcount);
sm.addItemName(costid);
sendPacket(sm);
sm = null;
} else
{
SystemMessage sm = new SystemMessage(
SystemMessageId.NOT_ENOUGH_SP_TO_LEARN_SKILL);
player.sendPacket(sm);
sm = null;
return;
}
}
else if (_skillType == 2) //pledgeskills TODO: Find appropriate system messages.
{
if (!player.isClanLeader())
{
// TODO: Find and add system msg
player.sendMessage("This feature is available only for the clan leader");
return;
}
int itemId = 0;
int repCost = 100000000;
// Skill Learn bug Fix
L2PledgeSkillLearn[] skills = SkillTreeTable.getInstance().getAvailablePledgeSkills(player);
for (L2PledgeSkillLearn s : skills)
{
L2Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel());
if (sk == null || sk != skill)
continue;
counts++;