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

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

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

    • Good luck my friend! 😃
    • try this one instead. The one he shared affects every single NPC/player character in the game, the one I posted only affects player characters  https://drive.google.com/file/d/1UtccbD9e50x3WEnQBab2PTZnBHwpcGYM/view?usp=sharing or perhaps i misunderstood; if you could please post a full explanation of the problem you're having with the files, unfortunately i think whatever you're using to translate to english is a bit bad nevermind, i got what you mean, here's the fix   https://drive.google.com/file/d/1av7OHaGSdnVQtcBgb9MhtiIkxVXy3P2y/view?usp=sharing   CanIngnoreCollision=True CanBeIngnoredCollision=True  
    • <dailyReward days="28" autoOpen="true" minimumOnlineTimeSeconds="30" oneRewardPerIP="true" resetIfMissDay="true">   For now, I have these settings in the XML—this is the V1 version I created, though I plan to make further improvements over time. Of course, I’ll also add more protections—MAC, HWID, and perhaps others like account-based restrictions—to make it more secure. We can also implement non-tradable items to further enhance the system's security. I’ll keep posting updates and refining both the system and the interface. I might make a video tomorrow; if you look at the top, you'll see the "auto-open" feature can be toggled on or off, allowing users to rely solely on the `.daily` command. Cheers! Note: If I sell it in this state, I’ll provide support and roll out updates to users. I’m not forcing anyone to buy anything; I’d even provide the patch files so that anyone with the necessary skills can add features, modify it, or improve it further.
    • If the problem is that the target is lost, the action of aiming at another character, upon losing collision, does not allow aiming.   This one works as it should, allowing you to target characters
  • 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..