package l2p.gameserver.clientpackets;
import l2p.gameserver.model.L2Character;
import l2p.gameserver.model.L2Player;
import l2p.gameserver.model.L2Skill;
import l2p.gameserver.tables.SkillTable;
public class RequestMagicSkillUse extends L2GameClientPacket
{
private Integer _magicId;
private boolean _ctrlPressed;
private boolean _shiftPressed;
@Override
public void readImpl()
{
_magicId = readD();
_ctrlPressed = readD() != 0;
_shiftPressed = readC() != 0;
}
@Override
public void runImpl()
{
L2Player activeChar = getClient().getActiveChar();
if(activeChar == null)
{
return;
}
if(activeChar.isOutOfControl())
{
activeChar.sendActionFailed();
return;
}
L2Skill skill = SkillTable.getInstance().getInfo(_magicId, activeChar.getSkillLevel(_magicId));
if(skill != null)
{
if(!(skill.isActive() || skill.isToggle()))
{
return;
}
// В режиме трансформации доступны только скилы трансформы
if(activeChar.getTransformation() != 0 && !activeChar.getAllSkills().contains(skill))
{
return;
}
if(skill.isToggle())
{
if(activeChar.getEffectList().getEffectsBySkill(skill) != null)
{
activeChar.getEffectList().stopEffect(skill.getId());
activeChar.sendActionFailed();
return;
}
}
L2Character target = skill.getAimingTarget(activeChar, activeChar.getTarget());
activeChar.setGroundSkillLoc(null);
activeChar.getAI().Cast(skill, target, _ctrlPressed, _shiftPressed);
}
else
{
activeChar.sendActionFailed();
}
}
}