if(!_def_think)
{
return true;
}
assert currentTask != null;
L2Character temp_attack_target = L2ObjectsStorage.getAsCharacter(currentTask.targetStoreId);
if(actor.isAttackingNow() || actor.isCastingNow())
{
return false;
}
switch(currentTask.type)
{
// Задание "прибежать в заданные координаты"
case MOVE:
{
if(actor.isMovementDisabled() || !getIsMobile())
{
return true;
}
if(actor.isInRange(currentTask.loc, 100))
{
return maybeNextTask(currentTask);
}
if(actor.isMoving)
{
return false;
}
if(!actor.moveToLocation(currentTask.loc, 0, currentTask.pathfind))
{
clientStopMoving();
_pathfind_fails = 0;
actor.teleToLocation(currentTask.loc);
//actor.broadcastPacketToOthers(new MagicSkillUse(actor, actor, 2036, 1, 500, 600000));
//ThreadPoolManager.getInstance().scheduleAi(new Teleport(currentTask.loc), 500, false);
return maybeNextTask(currentTask);
}
}
break;
// Задание "добежать - ударить"
case ATTACK:
{
if(checkTarget(temp_attack_target, false, 2000))
{
return true;
}
setAttackTarget(temp_attack_target);
if(actor.isMoving)
{
return Rnd.chance(25);
}
if(actor.getRealDistance(temp_attack_target) <= actor.getPhysicalAttackRange() + 40 && GeoEngine.canSeeTarget(actor, temp_attack_target, false))
{
clientStopMoving();
_pathfind_fails = 0;
actor.setAttackTimeout(getMaxAttackTimeout() + System.currentTimeMillis());
actor.doAttack(temp_attack_target);
return maybeNextTask(currentTask);
}
if(actor.isMovementDisabled() || !getIsMobile())
{
return true;
}
tryMoveToTarget(temp_attack_target);
}
break;
// Задание "добежать - атаковать скиллом"
case CAST:
{
if(actor.isMuted(currentTask.skill) || actor.isSkillDisabled(currentTask.skill.getId()))
{
return true;
}
boolean isAoE = currentTask.skill.getTargetType() == L2Skill.SkillTargetType.TARGET_AURA;
if(checkTarget(temp_attack_target, false, 3000))
{
return true;
}
setAttackTarget(temp_attack_target);
int castRange = currentTask.skill.getAOECastRange();
if(actor.getRealDistance(temp_attack_target) <= castRange + 60 && GeoEngine.canSeeTarget(actor, temp_attack_target, false))
{
clientStopMoving();
_pathfind_fails = 0;
actor.setAttackTimeout(getMaxAttackTimeout() + System.currentTimeMillis());
actor.doCast(currentTask.skill, isAoE ? actor : temp_attack_target, !temp_attack_target.isPlayable());
return maybeNextTask(currentTask);
}
if(actor.isMoving)
{
return Rnd.chance(10);
}
if(actor.isMovementDisabled() || !getIsMobile())
{
return true;
}
tryMoveToTarget(temp_attack_target, castRange);
}
break;
// Задание "добежать - применить скилл"
case BUFF:
{
if(actor.isMuted(currentTask.skill) || actor.isSkillDisabled(currentTask.skill.getId()))
{
return true;
}
if(temp_attack_target == null || temp_attack_target.isAlikeDead() || !actor.isInRange(temp_attack_target, 2000))
{
return true;
}
boolean isAoE = currentTask.skill.getTargetType() == L2Skill.SkillTargetType.TARGET_AURA;
int castRange = currentTask.skill.getAOECastRange();
if(actor.isMoving)
{
return Rnd.chance(10);
}
if(actor.getRealDistance(temp_attack_target) <= castRange + 60 && GeoEngine.canSeeTarget(actor, temp_attack_target, false))
{
clientStopMoving();
_pathfind_fails = 0;
actor.doCast(currentTask.skill, isAoE ? actor : temp_attack_target, !temp_attack_target.isPlayable());
return maybeNextTask(currentTask);
}
if(actor.isMovementDisabled() || !getIsMobile())
{
return true;