public void runImpl()
{
L2Player activeChar = getClient().getActiveChar();
if(activeChar == null || activeChar.getTransformation() != 0)
return;
if (_level < 1 || _level > 1000 || _id < 1 || _id > 32000)
{
_log.warning("Recived Wrong Packet Data in Aquired Skill - id:" + _id + " level:" + _level);
return;
}
L2NpcInstance trainer = activeChar.getLastNpc();
if((trainer == null || activeChar.getDistance(trainer.getX(), trainer.getY()) > L2Character.INTERACTION_DISTANCE) && !activeChar.isGM())
return;
if(SkillTable.SubclassSkills.isSubclassSkill(_id))
{
Functions.callScripts("services.SubSkills", "learnSkill", new Object[] {
activeChar,
new Integer(_id) }, null);
return;
}
activeChar.setSkillLearningClassId(activeChar.getClassId());
final L2Skill skill = SkillTable.getInstance().getInfo(_id, _level);
if(activeChar.getSkillLevel(_id) >= _level)
return; // already knows the skill with this level
if(_level > 1 && activeChar.getSkillLevel(_id) != _level - 1)
{
Util.handleIllegalPlayerAction(activeChar, "RequestAquireSkill[58]", "tried to increase skill " + _id + " level to " + _level + " while having it's level " + activeChar.getSkillLevel(_id), 2);
return;
}
if(!(skill.isCommon() || SkillTreeTable.getInstance().isSkillPossible(activeChar, _id, _level)))
{
Util.handleIllegalPlayerAction(activeChar, "RequestAquireSkill[64]", "tried to learn skill " + _id + " while on class " + activeChar.getActiveClass(), 2);
return;
}
L2SkillLearn SkillLearn = SkillTreeTable.getInstance().getSkillLearn(_id, _level, activeChar.getClassId(), _skillType == AcquireSkillList.CLAN ? activeChar.getClan() : null);
if(_skillType == AcquireSkillList.CLAN)
learnClanSkill(skill, activeChar.getClan());
else
{
int _requiredSp = SkillTreeTable.getInstance().getSkillCost(activeChar, skill);
if(activeChar.getSp() >= _requiredSp || SkillLearn.common || SkillLearn.transformation)
{
Short spb_id = SkillSpellbookTable._skillSpellbooks.get(SkillSpellbookTable.hashCode(new int[] {
skill.getId(),
skill.getLevel() }));
if(spb_id != null)
{
L2ItemInstance spb = activeChar.getInventory().findItemByItemId(spb_id.intValue());
if(spb == null || spb.getIntegerLimitedCount() < SkillLearn.itemCount)
{
activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_DO_NOT_HAVE_ENOUGH_ITEMS_TO_LEARN_SKILLS));
return;
}
L2ItemInstance ri = activeChar.getInventory().destroyItem(spb, SkillLearn.itemCount, true);
if(ri.getItemId() != 57)
activeChar.sendPacket(new SystemMessage(SystemMessage.S1_HAS_DISAPPEARED).addItemName(ri.getItemId()));
else
activeChar.sendPacket(new SystemMessage(SystemMessage.S1_ADENA_DISAPPEARED).addNumber(SkillLearn.itemCount
));
if(ri.getLastChange() == L2ItemInstance.REMOVED)
L2World.removeObject(ri);
}
activeChar.addSkill(skill, true);
if(!SkillLearn.common && !SkillLearn.transformation)
activeChar.setSp(activeChar.getSp() - _requiredSp);
activeChar.updateStats();
activeChar.sendUserInfo(true);
// update all the shortcuts to this skill
if(_level > 1)
for(L2ShortCut sc : activeChar.getAllShortCuts())
if(sc.id == _id && sc.type == L2ShortCut.TYPE_SKILL)
{
L2ShortCut newsc = new L2ShortCut(sc.slot, sc.page, sc.type, sc.id, _level);
activeChar.sendPacket(new ShortCutRegister(newsc));
activeChar.registerShortCut(newsc);
}
}
else
{
activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_DO_NOT_HAVE_ENOUGH_SP_TO_LEARN_SKILLS));
return;
}
}
if(SkillLearn.common)
activeChar.sendPacket(new ExStorageMaxCount(activeChar));
activeChar.sendPacket(new SkillList(activeChar));
if(trainer != null)
if(_skillType == AcquireSkillList.USUAL)
trainer.showSkillList(activeChar);
else if(_skillType == AcquireSkillList.FISHING)
trainer.showFishingSkillList(activeChar);
else if(_skillType == AcquireSkillList.CLAN)
trainer.showClanSkillList(activeChar);
else if(_skillType == AcquireSkillList.TRANSFORMATION)
trainer.showTransformationSkillList(activeChar);
}