Jump to content
  • 0

Question

Posted

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

8 answers to this question

Recommended Posts

  • 0
Posted (edited)

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
  • 0
Posted

The walk ? Check npcwalkers_routes :)

 

 

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

  • 0
Posted

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));
  • 0
Posted

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

Guest
This topic is now closed to further replies.


  • Posts

    • NEW HIDDENSTASH KEY SYSTEM INTRODUCED TO THE SITE   **Earn While You Spend - Introducing HS Cashback!**   Every purchase on our site now rewards you with **HS Keys cashback**   EVERY ONE WHO REGISTERS IN SITE UNTILL 15TH OF MAY GETS 2000 HS KEYS IN HES BALANE   Here's how it works:       **1 USD = 1000 HS Keys**   **Get 3% cashback** on every purchase   **Use your HS Keys to **save on your next order**   ---   ### ⚡ Why this is awesome   * Every order gives you value back   * Stack it with promos & HS usage   * Turn your spending into future discounts   ---   ### Example   Spend **$10** → Get **300 HS Keys** back   Spend **$50** → Get **1500 HS Keys** back   ---   ### Smart system (built for fairness)   * Cashback is rounded to keep things balanced   * Prevents abuse from tiny orders   * Rewards real buyers   ---   ### Start earning now   Every purchase = progress toward your next discount   Shop now and build your HS balance!   #cashback #gamingdeals #d2r #rewards #loyalty   Stay safe out there, heroes - and happy hunting! www.d2rhiddenstash.com     We just launched our new Affiliate Program — and it’s the easiest way to earn HS Keys.   Invite your friends using your personal link.   Example: If your friend spends $10 → you get 300 HS Keys No limits. No effort. Just share your link.   Get your referral link here: www.d2rhiddenstash.com/profile     Start earning today
    • https://jumpshare.com/share/L45ApA5PVrGN2O5Ua5pQ   Skill synchronization with the server: Launching and synchronizing animations, launching and synchronizing effects. All of this is tied to the server's timing  
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..