}
}
break;
case ATTACK:
{
Creature target = currentTask.target.get();
if (!checkTarget(target, MAX_PURSUE_RANGE))
{
return true;
}
setAttackTarget(target);
if (actor.isMoving)
{
return Rnd.chance(25);
}
if ((actor.getRealDistance3D(target) <= (actor.getPhysicalAttackRange() + 40)) && GeoEngine.canSeeTarget(actor, target, false))
{
clientStopMoving();
_pathfindFails = 0;
setAttackTimeout(getMaxAttackTimeout() + System.currentTimeMillis());
actor.doAttack(target);
return maybeNextTask(currentTask);
}
if (actor.isMovementDisabled() || !getIsMobile())
{
return true;
}
tryMoveToTarget(target);
}
break;
case CAST:
{
Creature target = currentTask.target.get();
if (actor.isMuted(currentTask.skill) || actor.isSkillDisabled(currentTask.skill) || actor.isUnActiveSkill(currentTask.skill.getId()))
{
return true;
}
boolean isAoE = currentTask.skill.getTargetType() == Skill.SkillTargetType.TARGET_AURA;
int castRange = currentTask.skill.getAOECastRange();
if (!checkTarget(target, MAX_PURSUE_RANGE + castRange))
{
return true;
}
setAttackTarget(target);
if ((actor.getRealDistance3D(target) <= (castRange + 60)) && GeoEngine.canSeeTarget(actor, target, false))
{
clientStopMoving();
_pathfindFails = 0;
setAttackTimeout(getMaxAttackTimeout() + System.currentTimeMillis());
actor.doCast(currentTask.skill, isAoE ? actor : target, !target.isPlayable());
return maybeNextTask(currentTask);
}
if (actor.isMoving)
{
return Rnd.chance(10);
}
if (actor.isMovementDisabled() || !getIsMobile())
{
return true;
}
tryMoveToTarget(target, castRange);
}
break;
case BUFF:
{
Creature target = currentTask.target.get();
if (actor.isMuted(currentTask.skill) || actor.isSkillDisabled(currentTask.skill) || actor.isUnActiveSkill(currentTask.skill.getId()))
{
return true;
}
if ((target == null) || target.isAlikeDead() || !actor.isInRange(target, 2000))
{
return true;
}
boolean isAoE = currentTask.skill.getTargetType() == Skill.SkillTargetType.TARGET_AURA;
int castRange = currentTask.skill.getAOECastRange();
if (actor.isMoving)
{
return Rnd.chance(10);
}
if ((actor.getRealDistance3D(target) <= (castRange + 60)) && GeoEngine.canSeeTarget(actor, target, false))
{
clientStopMoving();
_pathfindFails = 0;
actor.doCast(currentTask.skill, isAoE ? actor : target, !target.isPlayable());
return maybeNextTask(currentTask);
}
if (actor.isMovementDisabled() || !getIsMobile())
{
return true;