Walking Mobs on a Route
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
-
- Posts: 8
- Joined: Wed Nov 09, 2011 3:08 am
Walking Mobs on a Route
If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision 5034:
L2JDP Revision 8482:
I'm trying to add a patrolling mob on a field (example Cruma Marshlands) that walks on a set path and attacks any players that's very close to it. I noticed that NPCs can be turned into Walker NPCs but those are only passive NPCs for towns. Then I found a Routes.xml file that has some coordinates and a cycle pattern that lets me change it to however I want it.
However, I'm confused on how to use it since I do not know how to add a NPC ID to it so it does that specific route to an specific mob npc. In what part do I need to add the NPCID so I can add a walkingroute on the Routes.xml so my Mob uses it.
» Find Revision
L2J Revision 5034:
L2JDP Revision 8482:
I'm trying to add a patrolling mob on a field (example Cruma Marshlands) that walks on a set path and attacks any players that's very close to it. I noticed that NPCs can be turned into Walker NPCs but those are only passive NPCs for towns. Then I found a Routes.xml file that has some coordinates and a cycle pattern that lets me change it to however I want it.
However, I'm confused on how to use it since I do not know how to add a NPC ID to it so it does that specific route to an specific mob npc. In what part do I need to add the NPCID so I can add a walkingroute on the Routes.xml so my Mob uses it.
- VlLight
- L2j Veteran
- Posts: 577
- Joined: Fri Dec 14, 2007 11:58 am
- Location: Russia
Re: Walking Mobs on a Route
Not sure, if it wasn't changed, but looks like wasn't. You should create individual script for it.
Simplified example can looks like this:
This simplified code, of course, is suitable, if ONLY ONE mob with used ID spawns (actually, if there is no other mobs with this ID in radius 3000 from starting point of route (you can change range in class)), else all of them will march by this route.
So, if you wish to make marching only some mobs, or if you wish to make mobs with same ID marching by different routes, you should define correspondence between mob and route.
It can be done like this, by spawn coordinates of monsters:
So, you can start moving only for selected mobs and by own route:
P.S> Note, if you spawn mobs by spawntable, not by script, you shoud call onSpawn() for mobs at script start (at least, it was so in Freya)
Simplified example can looks like this:
Code: Select all
public class SimplifiedExample extends Quest{ public SimplifiedExample(int questId, String name, String descr) { super(questId, name, descr); addSpawnId(EXAMPLE_MOB); } @Override public final String onSpawn(L2Npc npc) { WalkingManager.getInstance().startMoving(npc, route_ID_from_Routes_XML); return super.onSpawn(npc); } public static void main(String[] args) { new SimplifiedExample(-1, "SimplifiedExample", "custom"); }}
So, if you wish to make marching only some mobs, or if you wish to make mobs with same ID marching by different routes, you should define correspondence between mob and route.
It can be done like this, by spawn coordinates of monsters:
Code: Select all
private static final Map<Integer, int[]> ROUTE_DATA = new HashMap<Integer, int[]>();static{ ROUTE_DATA.put(1, new int[] { 14840, 251949 }); ROUTE_DATA.put(2, new int[] { 16082, 251790 }); ROUTE_DATA.put(5, new int[] { 16524, 255244 }); ROUTE_DATA.put(12, new int[] { 17670, 252256 });} private static int getRoute(L2Npc npc){ for (int key : ROUTE_DATA.keySet()) { int coord[] = ROUTE_DATA.get(key); if (coord[0] == npc.getSpawn().getLocx() && coord[1] == npc.getSpawn().getLocy()) return key; } return -1;}
Code: Select all
if (getRoute(npc) > 0) WalkingManager.getInstance().startMoving(npc, getRoute(npc));
- lucan
- Posts: 590
- Joined: Wed Mar 16, 2011 10:39 pm
- Location: Brazil
Re: Walking Mobs on a Route
For a single custom Mob I can use the script gordon.java? Just changing the ID of the NPC, path coordinates, new name to file and load it in scripts.java?
EDITED...
Yes, the AI gordon.java can be used for this function, only changes few informations like NPC id, names GORDON and Gordon to own name, coordinates of walks and in the line if (_isWalkTo > 55) change the number 55 to be equal to the amount of routes that you have in WALKS and the name of file.
Put the file loading in scripts.cfg and works! I tested and works perfect!
EDITED...
Yes, the AI gordon.java can be used for this function, only changes few informations like NPC id, names GORDON and Gordon to own name, coordinates of walks and in the line if (_isWalkTo > 55) change the number 55 to be equal to the amount of routes that you have in WALKS and the name of file.
Put the file loading in scripts.cfg and works! I tested and works perfect!
- corbin12
- Posts: 325
- Joined: Sun May 29, 2011 8:27 pm
- Location: Seed of Hellfire
Re: Walking Mobs on a Route
VlLight, can you please explain further about getRoute?
"Playing Lineage II is not a privilege, but a right."
- VlLight
- L2j Veteran
- Posts: 577
- Joined: Fri Dec 14, 2007 11:58 am
- Location: Russia
Re: Walking Mobs on a Route
What exactly is unclear? For monsters with same ID it needs to identify them between each other, for attach individual route to each of them. One from alternatives is spawn point (if monsters have different) - you should pair spawn coordinates and route (For example, map with route number as key)corbin12 wrote:VlLight, can you please explain further about getRoute?
- corbin12
- Posts: 325
- Joined: Sun May 29, 2011 8:27 pm
- Location: Seed of Hellfire
Re: Walking Mobs on a Route
This thing is unclear:
ROUTE_DATA.put(1, new int[] { 14840, 251949 });
ROUTE_DATA.put(2, new int[] { 16082, 251790 });
ROUTE_DATA.put(5, new int[] { 16524, 255244 });
ROUTE_DATA.put(12, new int[] { 17670, 252256 });
What does 2,5,12 mean?? and 14840, 251949 and the other down from them. Are these X or Y?
ROUTE_DATA.put(1, new int[] { 14840, 251949 });
ROUTE_DATA.put(2, new int[] { 16082, 251790 });
ROUTE_DATA.put(5, new int[] { 16524, 255244 });
ROUTE_DATA.put(12, new int[] { 17670, 252256 });
What does 2,5,12 mean?? and 14840, 251949 and the other down from them. Are these X or Y?
"Playing Lineage II is not a privilege, but a right."
-
- L2j Veteran
- Posts: 967
- Joined: Sun Mar 11, 2007 7:49 pm
- Location: Ukraine
Re: Walking Mobs on a Route
2,5,12 route id in Route.xml, yes x and y
- corbin12
- Posts: 325
- Joined: Sun May 29, 2011 8:27 pm
- Location: Seed of Hellfire
Re: Walking Mobs on a Route
ty. And in x (for example I have 5 mobs) every mob who is in x will run(all of them)?
"Playing Lineage II is not a privilege, but a right."
-
- L2j Veteran
- Posts: 967
- Joined: Sun Mar 11, 2007 7:49 pm
- Location: Ukraine
Re: Walking Mobs on a Route
in this example you have check x and y, if this not enough you can add heading check for example, then npc name and other
- corbin12
- Posts: 325
- Joined: Sun May 29, 2011 8:27 pm
- Location: Seed of Hellfire
Re: Walking Mobs on a Route
Thank you. I made a script but only one of 2 mobs run
"Playing Lineage II is not a privilege, but a right."