Jump to content
  • 0

Monster Set Target


Akatalilh

Question

Hello, i want make an event that when monsters spawn somewhere (i set), they automatical start walking and attack something (a target)

So the idea is to spawn something like Flag and monsters once they spawn they try to attack flag and kill it (players try defend flag)

 

So my question is how i set mobs or something to Attack something that is far away? example the mob walk outside giran castle -> inside giran castle

or point to point ?

 

Thanks in advance

  • Downvote 1
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

By Pa'agrio, my eyes are bleeding.

 

Avoid to create so much methods until they are used in another location. It becomes unreadable.

 

I guess "npc" is the NPC to attack (let's called him "victim") ? He must walk and reach a position, meanwhile mobs are spawning and must kill it ?

 

If you want an hint try to make steps...

 

Step 1 : spawn your victim and make it walk.

Step 2 : spawn monsters at interval X. We don't care about anything else.

Step 3 : monsters must run and follow a path. Probably you have to create that path, until monsters spawn around the NPC, which is far easier to handle (no need to care about a lot of thing, you just have to reuse current victim position and spawn monsters).

Step 4 : monsters must attack the NPC.

 

Do your stuff in that order and don't go on another step until you reached previous step.

 

A generic, one time spawn is handled by following :

NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
if (template != null)
{
	if (randomOffset)
	{
		x += Rnd.get(-100, 100);
		y += Rnd.get(-100, 100);
	}
				
	L2Spawn spawn = new L2Spawn(template);
	spawn.setHeading(heading);
	spawn.setLocx(x);
	spawn.setLocy(y);
	spawn.setLocz(z + 20);
	spawn.stopRespawn();
	L2Npc result = spawn.doSpawn(isSummonSpawn);
				
	if (despawnDelay > 0)
		result.scheduleDespawn(despawnDelay);

        // Affect the newly spawned NPC "result" here
        result.doSomething();
}

Where parameters are following :

 

* @param npcId : the NPC template to spawn.
* @param x
* @param y
* @param z
* @param heading
* @param randomOffset : if true, set a random position
* @param despawnDelay : despawn delay, if any (0 means permanent).
* @param isSummonSpawn : if true, spawn with animation (if any exists).
 
If you want to affect the newly spawned npc, then affect "result", like :
result.setWalking();

PS : methods names are perhaps different on your pack, I checked on my own pack, aCis.

 

The above code should be put in a method, and can be reused on your event. Or simply see addSpawn from Quest.java.

Edited by Tryskell
Link to comment
Share on other sites

  • 0

The walk ? Check npcwalkers_routes :)

 

 

Like spawn mob -> go from point a to b -> if inside range -> attack

Link to comment
Share on other sites

  • 0

Tryskell i did this

 

 

public void spawnMonstersEvent(final L2Npc npc)

{
 
 
SpawnMonster1();
SpawnMonster01();
waitSecs(2);
 
npc.setWalking();
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(82238, 147903, -3471, 0));
 
 
 
 
for (L2Spawn spawn : getMonsterIds())
if (spawn != null)
{
spawn.init();
}
}

 

i was not sure... but again it give error and mobs does not spawn with these extra lines

 

npc.setWalking();
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(82238, 147903, -3471, 0));
Link to comment
Share on other sites

  • 0

By Pa'agrio, my eyes are bleeding.

 

Avoid to create so much methods until they are used in another location. It becomes unreadable.

 

I guess "npc" is the NPC to attack (let's called him "victim") ? He must walk and reach a position, meanwhile mobs are spawning and must kill it ?

 

If you want an hint try to make steps...

 

Step 1 : spawn your victim and make it walk.

Step 2 : spawn monsters at interval X. We don't care about anything else.

Step 3 : monsters must run and follow a path. Probably you have to create that path, until monsters spawn around the NPC, which is far easier to handle (no need to care about a lot of thing, you just have to reuse current victim position and spawn monsters).

Step 4 : monsters must attack the NPC.

 

Do your stuff in that order and don't go on another step until you reached previous step.

 

A generic, one time spawn is handled by following :

NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
if (template != null)
{
	if (randomOffset)
	{
		x += Rnd.get(-100, 100);
		y += Rnd.get(-100, 100);
	}
				
	L2Spawn spawn = new L2Spawn(template);
	spawn.setHeading(heading);
	spawn.setLocx(x);
	spawn.setLocy(y);
	spawn.setLocz(z + 20);
	spawn.stopRespawn();
	L2Npc result = spawn.doSpawn(isSummonSpawn);
				
	if (despawnDelay > 0)
		result.scheduleDespawn(despawnDelay);

        // Affect the newly spawned NPC "result" here
        result.doSomething();
}

Where parameters are following :

 

* @param npcId : the NPC template to spawn.
* @param x
* @param y
* @param z
* @param heading
* @param randomOffset : if true, set a random position
* @param despawnDelay : despawn delay, if any (0 means permanent).
* @param isSummonSpawn : if true, spawn with animation (if any exists).
 
If you want to affect the newly spawned npc, then affect "result", like :
result.setWalking();

PS : methods names are perhaps different on your pack, I checked on my own pack, aCis.

 

The above code should be put in a method, and can be reused on your event. Or simply see addSpawn from Quest.java.

Thank u so much Tryskell

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...