*/
@Override
protected boolean createNewTask()
{
clearTasks();
Creature target = prepareTarget();
if (target == null)
{
return false;
}
final NpcInstance actor = getActor();
if (actor.isDead())
{
return false;
}
final double distance = actor.getDistance(target);
final double chp = actor.getCurrentHpPercents();
if (_hpStage == 0)
{
actor.altOnMagicUseTimer(actor, getSkill(4691, 1));
_hpStage = 1;
}
else if ((chp < 80) && (_hpStage == 1))
{
actor.altOnMagicUseTimer(actor, getSkill(4691, 2));
defenceDownTimer = System.currentTimeMillis();
_hpStage = 2;
}
else if ((chp < 50) && (_hpStage == 2))
{
actor.altOnMagicUseTimer(actor, getSkill(4691, 3));
_hpStage = 3;
}
else if ((chp < 30) && (_hpStage == 3))
{
actor.altOnMagicUseTimer(actor, getSkill(4691, 4));
_hpStage = 4;
}
else if ((chp < 10) && (_hpStage == 4))
{
actor.altOnMagicUseTimer(actor, getSkill(4691, 5));
_hpStage = 5;
}
if ((getAliveMinionsCount() < 100) && Rnd.chance(5))
{
final NpcInstance minion = Functions.spawn(Location.findPointToStay(actor.getLoc(), 400, 700, actor.getGeoIndex()), 29029);
minions.add(minion);
ValakasManager.addValakasMinion(minion);
}
if (_counterAttackIndex > 2000)
{
ValakasManager.broadcastScreenMessage(NpcString.VALAKAS_HEIGHTENED_BY_COUNTERATTACKS);
_counterAttackIndex = 0;
return chooseTaskAndTargets(s_berserk, actor, 0);
}
else if (_rangedAttacksIndex > 2000)
{
if (Rnd.chance(60))
{
final Creature randomHated = actor.getAggroList().getRandomHated();
if (randomHated != null)
{
setAttackTarget(randomHated);
actor.startConfused();
ThreadPoolManager.getInstance().schedule(new RunnableImpl()