Skip to content

[Help]monster attack the monster. how?

Featured Replies

How to do that: a monster attack the monster on spawn

Java

well here is, im using it on my serv and works perfectlly, try to rework for your core,

 

add this onSPawn
npc.broadcastPacket(new AutoAttackStart(npc.getObjectId()));
ThreadPoolManager.getInstance().scheduleAi(new AttackTask(npc, TARGET_ON_WHICH_YOUR_NPC ATTACKS), Rnd.get(10, 1000));



private static final class AttackTask implements Runnable
{
	private final L2Npc _attacker;
	private final L2Npc _target;
	public AttackTask(L2Npc attacker, L2Npc target)
	{
		_attacker = attacker;
		_target = target;
	}
	@Override
	public void run()
	{
		Broadcast.toPlayer(new Attack(_attacker, _target, false, 0, true), _attacker.getInstanceId());
		ThreadPoolManager.getInstance().scheduleAi(new AttackTask(_attacker, _target), 1500);
	}
}	

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.