if(!target.isCharacter())
{
activeChar.sendMessage("target is not a character");
return false;
}
L2CharacterAI ai = target.getAI();
if(ai == null)
{
activeChar.sendMessage("ai == null");
return false;
}
L2Character actor = ai.getActor();
if(actor == null)
{
activeChar.sendMessage("actor == null");
return false;
}
activeChar.sendMessage("actor: " + actor);
break;
case admin_find_broken_ai:
for(L2NpcInstance npc : L2ObjectsStorage.getAllNpcsForIterate())
{
if(npc.getAI().getActor() != npc)
{
activeChar.sendMessage("type 1");
activeChar.teleToLocation(npc.getLoc());
return true;
}
else if(!npc.isVisible())
{
L2WorldRegion region = L2World.getRegion(npc);
if(region != null && region.getNpcsList(new GArray<L2NpcInstance>(region.getObjectsSize()), 0, npc.getReflection().getId()).contains(npc))
{
activeChar.sendMessage("type 2");
activeChar.teleToLocation(npc.getLoc());
return true;
}
L2WorldRegion currentRegion = npc.getCurrentRegion();
if(currentRegion != null)
{
activeChar.sendMessage("type 3");
activeChar.teleToLocation(npc.getLoc());
return true;
}
}
else if(npc.isDead())
{
for(AggroInfo aggro : npc.getAggroMap().values())
{
if(aggro.damage > 0 && aggro.hate == 0 && aggro.attacker != null && !aggro.attacker.isDead())
{
activeChar.sendMessage("type 4");
activeChar.teleToLocation(npc.getLoc());
return true;
}
}
}
}
break;
case admin_setvar:
if(wordList.length != 3)
{
activeChar.sendMessage("Incorrect argument count!!!");
return false;
}
ServerVariables.set(wordList[1], wordList[2]);
activeChar.sendMessage("Value changed.");
break;
case admin_set_ai_interval:
if(wordList.length != 2)
{
activeChar.sendMessage("Incorrect argument count!!!");
return false;
}
int interval = Integer.parseInt(wordList[1]);
int count = 0;
int count2 = 0;
for(final L2NpcInstance npc : L2ObjectsStorage.getAllNpcsForIterate())
{
if(npc == null || npc instanceof L2RaidBossInstance)
{
continue;
}
final L2CharacterAI char_ai = npc.getAI();
if(char_ai instanceof DefaultAI)
{
try
{
final java.lang.reflect.Field field = l2p.gameserver.ai.DefaultAI.class.getDeclaredField("AI_TASK_DELAY");
field.setAccessible(true);
field.set(char_ai, interval);
if(char_ai.isActive())
{
char_ai.stopAITask();
char_ai.teleportHome(true);
count++;
L2WorldRegion region = npc.getCurrentRegion();
if(region != null && !region.areNeighborsEmpty())
{
char_ai.startAITask();
count2++;
}
}
}
catch(Exception e)