* @param checkRange boolean
*/
protected void thinkCast(boolean checkRange)
{
Playable actor = getActor();
Creature target = getAttackTarget();
if ((_skill.getSkillType() == SkillType.CRAFT) || _skill.isToggle())
{
if (_skill.checkCondition(actor, target, _forceUse, _dontMove, true))
{
actor.doCast(_skill, target, _forceUse);
}
return;
}
if ((target == null) || ((target.isDead() != _skill.getCorpse()) && !_skill.isNotTargetAoE()))
{
setIntention(AI_INTENTION_ACTIVE);
actor.sendActionFailed();
return;
}
if (!checkRange)
{
if ((_skill.getNextAction() == NextAction.ATTACK) && !actor.equals(target))
{
setNextAction(nextAction.ATTACK, target, null, _forceUse, false);
}
else
{
clearNextAction();
}
clientStopMoving();
if (_skill.checkCondition(actor, target, _forceUse, _dontMove, true))
{
actor.doCast(_skill, 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, target, actor.isFlying());
boolean noRangeSkill = _skill.getCastRange() == 32767;
if (!noRangeSkill && !canSee && ((range > 200) || (Math.abs(actor.getZ() - target.getZ()) > 200)))
{
actor.sendPacket(SystemMsg.CANNOT_SEE_TARGET);
setIntention(AI_INTENTION_ACTIVE);
actor.sendActionFailed();
return;