Page 1 of 1

Making characters not follow a teleported npc

Posted: Mon Oct 05, 2009 2:47 pm
by Probe
I'm building a script that relocates a certain npc, to a place still in range for the players attacking it.
I've written the following code to make sure both npc and players stop attacking, but it's not working.

Code: Select all

for (L2Character pc : npc.getAttackByList()) // Make sure players don't auto-attack beleth once he ports			{				if (pc != null && !(pc.isDead()))				{					pc.abortCast();					pc.abortAttack();					pc.setTarget(null);					pc.stopMove(null);					pc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);					pc.sendPacket(new StopMove(pc.getObjectId(), pc.getX(), pc.getY(), pc.getZ(), pc.getHeading()));				}			}

Code: Select all

npc.setTarget(null);			npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);			npc.teleToLocation(spawnPoint.getLocx(),spawnPoint.getLocy(),spawnPoint.getLocz());	
I looked into the javas and saw that teleToLocation already clears target and aborts casting\attacking, so didn't add it again

what else can be done? :|