L2Playable actor = getActor();
if(actor == null)
{
return;
}
L2Character attack_target = getAttackTarget();
if(_skill.getSkillType() == SkillType.CRAFT || _skill.isToggle())
{
if(_skill.checkCondition(actor, attack_target, _forceUse, _dontMove, true))
{
actor.doCast(_skill, attack_target, _forceUse);
}
return;
}
if(attack_target == null || attack_target.isDead() != _skill.getCorpse() && !_skill.isNotTargetAoE())
{
setIntention(AI_INTENTION_ACTIVE);
actor.sendActionFailed();
return;
}
if(!checkRange)
{
// Если скилл имеет следующее действие, назначим это действие после окончания действия скилла
if(_skill.getNextAction() == NextAction.ATTACK && !actor.equals(attack_target))
{
setNextAction(nextAction.ATTACK, attack_target, null, _forceUse, false);
}
else
{
clearNextAction();
}
clientStopMoving();
if(_skill.checkCondition(actor, attack_target, _forceUse, _dontMove, true))
{
actor.doCast(_skill, attack_target, _forceUse);
}
else
{
setNextIntention();
if(getIntention() == CtrlIntention.AI_INTENTION_ATTACK)
{
thinkAttack(true);
}
}
return;
}
int range = actor.getMagicalAttackRange(_skill);
if(range < 10)
{
range = 10;
}
boolean canSee = _skill.getSkillType() == SkillType.TAKECASTLE || _skill.getSkillType() == SkillType.TAKEFORTRESS || GeoEngine.canSeeTarget(actor, attack_target, actor.isFlying());
boolean noRangeSkill = _skill.getCastRange() == 32767;
if(!noRangeSkill && !canSee && (range > 200 || Math.abs(actor.getZ() - attack_target.getZ()) > 200))
{
actor.sendPacket(Msg.CANNOT_SEE_TARGET);
setIntention(AI_INTENTION_ACTIVE);
actor.sendActionFailed();
return;