{
_isAttacked = false;
if(npc.getNpcId() == GORDON)
{
npc.setWalking();
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(X, Y, Z, 0));
}
}
else if(event.equalsIgnoreCase("check_ai"))
{
cancelQuestTimer("check_ai", null, null);
if(!_isSpawned)
{
L2NpcInstance gordon_ai = findTemplate(GORDON);
if(gordon_ai != null)
{
_isSpawned = true;
startQuestTimer("Start", 1000, gordon_ai, null,true);
return super.onAdvEvent(event, npc, player);
}
}
}
else if(event.equalsIgnoreCase("Start"))
{
//startQuestTimer("Start", 1000, npc, null);
if(npc != null && _isSpawned)
{
// check if player have Cursed Weapon and in radius
if(npc.getNpcId() == GORDON)
{
Collection<L2PcInstance> chars = npc.getKnownList().getKnownPlayers().values();
if(chars != null && chars.size() > 0)
{
for(L2PcInstance pc : chars)
{
if(pc.isCursedWeaponEquipped() && pc.isInsideRadius(npc, 5000, false, false))
{
npc.setRunning();
((L2Attackable) npc).addDamageHate(pc, 0, 9999);
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, pc);
_isAttacked = true;
cancelQuestTimer("time_isAttacked", null, null);
startQuestTimer("time_isAttacked", 180000, npc, null);
return super.onAdvEvent(event, npc, player);
}
}
}
}
// end check
if(_isAttacked)
return super.onAdvEvent(event, npc, player);
if(npc.getNpcId() == GORDON && npc.getX() - 50 <= X && npc.getX() + 50 >= X && npc.getY() - 50 <= Y && npc.getY() + 50 >= Y)
{
_isWalkTo++;
if(_isWalkTo > 55)
{
_isWalkTo = 1;
}
X = WALKS[_isWalkTo - 1][0];
Y = WALKS[_isWalkTo - 1][1];
Z = WALKS[_isWalkTo - 1][2];
npc.setWalking();
//TODO: find better way to prevent teleporting to the home location
npc.getSpawn().setLocx(X);
npc.getSpawn().setLocy(Y);
npc.getSpawn().setLocz(Z);
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(X, Y, Z, 0));
}
// Test for unblock Npc
if(npc.getX() != _npcMoveX && npc.getY() != _npcMoveY)
{
_npcMoveX = npc.getX();
_npcMoveY = npc.getY();
_npcBlock = 0;
}
else if(npc.getNpcId() == GORDON)
{
_npcBlock++;
if(_npcBlock > 2)
{
npc.teleToLocation(X, Y, Z);
return super.onAdvEvent(event, npc, player);
}
if(_npcBlock > 0)
{
//TODO: find better way to prevent teleporting to the home location
npc.getSpawn().setLocx(X);
npc.getSpawn().setLocy(Y);
npc.getSpawn().setLocz(Z);
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(X, Y, Z, 0));
}
}
// End Test unblock Npc
}
}