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

    • 🛡 GoldRush — High Five x20   A fresh High Five server focused on active progression, fair competition, and a healthy player-driven economy.   GoldRush is built for players who want a fresh spin on our beloved game that is connected to today's world via Web3 marketplace.   🌍 Server Info   Chronicle: High Five Type: Mid Rate / PvP Craft Community: International Location: Europe Time Zone: GMT+3   ⚙️ Rates   EXP: x20 SP: x20 Adena: x10 Drop: x8 Spoil: x12 Raid Boss: x3 Quest Items: x5 Quest EXP / SP: x10 Quest Adena: x5   👑 Class Progression   1st Class: Free 2nd Class: Free 3rd Class: 5,000,000 Adena   1st and 2nd class transfers reward Shadow Weapons.   ✨ Main Features   No P2W as there is no donation currency in the game Web3 Marketplace Events with real rewards Rotating accessories shop Weekly Olympiad Clean and active mid-rate progression   🧩 Community Board Features   Buffer GM Shop Gatekeeper Drop Search Rankings   🔨 Enchant Info   Max Weapon Enchant: +16 Max Armor Enchant: +12 Olympiad Max Enchant: +6   Safe Enchant: Weapons / Armor: safe to +3 Full Body Armor: safe to +4   Enchant Chance: +4 to +6: 66% +7 to +9: 60% +10 to +12: 54% +13 to +14: 48% +15 to +16: 42%   🏪 GM Shop / Gear Progression   C-grade through Dynasty gear is available through the GM Shop.   Moirai+ progression is farm, craft and raid based.   There is no admin-created endgame gear selling.   🥇 Gold Rush Economy   GoldRush includes a server-wide Adena sink system.   Players contribute Adena to the Gold Rush Collector. When the server goal is reached, limited Gold Bar stock unlocks through the Gold Merchant.   Daily Gold Rush missions also allow active players to earn Gold Bars through gameplay.   🌐 Website Player-to-Player Marketplace   GoldRush includes a website-based Web3 marketplace where players can list and trade items with each other.   Items come from real players.   The marketplace is player-to-player only.   🏛 Olympiad   Weekly Olympiad cycle. Olympiad starts at 18:00 GMT+3. Olympiad max enchant: +6.   🏰 Sieges   Castle sieges take place on Sundays at 16:00 and 20:00 GMT+3.   The first siege will happen 2 weeks after launch.   🐉 Grand Boss Respawn   Queen Ant: 24h + 2h random Core: 30h + 2h random Orfen: 48h + 2h random Baium: 120h + 3h random Antharas: 120h + 24h random Valakas: 120h + 24h random Beleth: 120h + 24h random   🎉 Events   Manual GM events with real token or gold bar rewards.   ⚔️ Fair Play   Bots are strictly forbidden and will result in a ban without warning.   Dualbox is limited to 1 box.   GoldRush is built around a healthy player-to-player economy.   🚀 What to Expect   Active farming Meaningful PvP Meaningul Farming Player-driven economy No donation currency     🔗 Join Us   Website: www.goldrushpvp.xyz Discord: https://discord.gg/kg9WXxcAY   🏁 Expected Launch: July 18 2026     If you are looking for a fresh High Five x20 server with clean structure and strong long-term potential, GoldRush is almost ready.   See you in game.
    • Collisions is from client are no way to bypass from server. Can be done from client modification need to be moded a .dll I can do the work you can contact me by DM  P.D: I already have this job done on the past
    • I believe this can be achieved with a client mod actually. What client are you using?  
  • 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..