Skip to content

Spawn Mobs On Event

Featured Replies

Hello i made an event and i try once the player go there and transform after this the mobs spawn or npc's whatever

and i use this code:

public List<L2Spawn> _MonsterSpawn = new FastList<L2Spawn>();
private int[] mobs={ 21162, 21253, 21184, 21205, 21163, 21254, 21206, 21185, 21255, 21207, 21165, 21186 };
public static L2Spawn _mobsSpawn;

.
.
.
.
.
.
.

private void spawnGuards(final EventPlayer player)
	{

		L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
		
		try
		{
			_mobsSpawn = new L2Spawn(tmpl);
			 
			_mobsSpawn.setLocx(player.getX() + Rnd.get(650) - Rnd.get(350) + Rnd.get(150)); // loc x
			_mobsSpawn.setLocy(player.getY() + Rnd.get(650) - Rnd.get(250) + Rnd.get(140)); // loc y
			_mobsSpawn.setLocz(player.getZ()); // loc z			
			 
			_mobsSpawn.setAmount(1);
			_mobsSpawn.setHeading(0);
			_mobsSpawn.setRespawnDelay(150000);
			_mobsSpawn.setLocation(0);
			_mobsSpawn.setInstanceId(player.getInstanceId());
			 
			_MonsterSpawn.add(_mobsSpawn);
			_mobsSpawn = null;
		
		
		}
		catch (Exception e)
		{
		System.out.println("Error in event");
		}

	}
	
	private void transformPlayer(final EventPlayer player)
	{
		player.setNameColor(255, 0, 0);
		player.transform(303);
		player.setStatus(1);
		untransformMutant();
		player.broadcastUserInfo();
		mutant = player;
		spawnGuards(player);
		
	}
 

So player transform but mobs no spawn... 

I though maybe is because inside the event engine where  player.teleToEventArea(); 

is instance and yes it was so i used 

_mobsSpawn.setInstanceId(player.getInstanceId());

 

to be in same instance with player

but still i cant see them or i dont see if they spawn... (ps no errors in GS)

Edited by VideoCopilot

I don't know how the instances works, probably you too... but what exactly you trying to do with that?

private void spawnGuards(final EventPlayer player)
	{
 
		L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
		
		try
		{
			_mobsSpawn = new L2Spawn(tmpl);
			 
			_mobsSpawn.setLocx(player.getX() + Rnd.get(650) - Rnd.get(350) + Rnd.get(150)); // loc x
			_mobsSpawn.setLocy(player.getY() + Rnd.get(650) - Rnd.get(250) + Rnd.get(140)); // loc y
			_mobsSpawn.setLocz(player.getZ()); // loc z			
			 
			_mobsSpawn.setAmount(1);
			_mobsSpawn.setHeading(0);
			_mobsSpawn.setRespawnDelay(150000);
			_mobsSpawn.setLocation(0);
			_mobsSpawn.setInstanceId(player.getInstanceId());
			 
			_MonsterSpawn.add(_mobsSpawn);
			_mobsSpawn = null;
		
		
		}
		catch (Exception e)
		{
		System.out.println("Error in event");
		}
 
	}

Edited by Tessa

Hello,
I don't know much about spawning yet,so I can't help you there,but if I am correct,if it throws error,you can't see it,because you have System.out.println,you should use _log.log(Level.WARNING,"Error in event"); but first create: protected static Logger _log = Logger.getLogger(YourClassName.class.getName());
EDIT:Tessa,I believe he is trying to spawn mob near player position.

Edited by StealthyS4m

Hello,

I don't know much about spawning yet,so I can't help you there,but if I am correct,if it throws error,you can't see it,because you have System.out.println,you should use _log.log(Level.WARNING,"Error in event"); but first create: protected static Logger _log = Logger.getLogger(YourClassName.class.getName());

EDIT:Tessa,I believe he is trying to spawn mob near player position.

According to this code, he tries to do nothing...

  • Author

Hello,

I don't know much about spawning yet,so I can't help you there,but if I am correct,if it throws error,you can't see it,because you have System.out.println,you should use _log.log(Level.WARNING,"Error in event"); but first create: protected static Logger _log = Logger.getLogger(YourClassName.class.getName());

EDIT:Tessa,I believe he is trying to spawn mob near player position.

ye you are right about error message too i forgot to add it

Tessa i just try spawn mob  at the position of the player isnt that code right?

Take a look at the already existing instances and you will find everything you need.

  • Author

Take a look at the already existing instances and you will find everything you need.

can you add me on skype a bit i wanna share you screen to show you the code about instance to see that its the same -.- still no work im not idiot

can you add me on skype a bit i wanna share you screen to show you the code about instance to see that its the same -.- still no work im not idiot

Ok, tell me which instance you take as a example and I will take a look! :)

  • Author

Ok, tell me which instance you take as a example and I will take a look! :)

i send you as private the whole code >.>  thx

I am not sure,but I think it should have something like that at the end of the method:
SpawnTable.getInstance().addNewSpawn(_mobSpawn, false);
_mobSpawn.init();

Edited by StealthyS4m

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.