if(!actor.isInCombat())
{
_lastMinionsTarget = 0;
return;
}
MinionList ml = ((L2ReflectionBossInstance) actor).getMinionList();
if(ml == null || !ml.hasMinions())
{
_lastMinionsTarget = 0;
return;
}
long now = System.currentTimeMillis();
if(_nextOrderTime > now && _lastMinionsTarget > 0)
{
L2Player old_target = L2ObjectsStorage.getAsPlayer(_lastMinionsTarget);
if(old_target != null && !old_target.isAlikeDead())
{
for(L2MinionInstance m : ml.getSpawnedMinions())
{
if(m.getAI().getAttackTarget() != old_target)
{
m.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, old_target, 10000000);
m.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, old_target);
}
}
return;
}
}
_nextOrderTime = now + 30000;
GArray<L2Player> pl = L2World.getAroundPlayers(actor);
if(pl.isEmpty())
{
_lastMinionsTarget = 0;
return;
}
GArray<L2Player> alive = new GArray<L2Player>(6);
for(L2Player p : pl)
{
if(!p.isAlikeDead())
{
alive.add(p);
}
}
if(alive.isEmpty())
{
_lastMinionsTarget = 0;
return;
}
L2Player target = alive.get(Rnd.get(alive.size()));
_lastMinionsTarget = target.getStoredId();
Functions.npcSayCustomMessage(actor, "Kama56Boss.attack", target.getName());
for(L2MinionInstance m : ml.getSpawnedMinions())
{
m.clearAggroList(false);
m.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 10000000);
m.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
}