Walking Mobs on a Route

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
pewpew122
Posts: 8
Joined: Wed Nov 09, 2011 3:08 am

Walking Mobs on a Route

Post by pewpew122 »

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.
User avatar
VlLight
L2j Veteran
L2j Veteran
Posts: 577
Joined: Fri Dec 14, 2007 11:58 am
Location: Russia

Re: Walking Mobs on a Route

Post by VlLight »

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:

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");    }}
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:

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;} 
So, you can start moving only for selected mobs and by own route:

Code: Select all

if (getRoute(npc) > 0)        WalkingManager.getInstance().startMoving(npc, getRoute(npc)); 
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)
User avatar
lucan
Posts: 590
Joined: Wed Mar 16, 2011 10:39 pm
Location: Brazil

Re: Walking Mobs on a Route

Post by lucan »

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!
User avatar
corbin12
Posts: 325
Joined: Sun May 29, 2011 8:27 pm
Location: Seed of Hellfire

Re: Walking Mobs on a Route

Post by corbin12 »

VlLight, can you please explain further about getRoute?
"Playing Lineage II is not a privilege, but a right."
User avatar
VlLight
L2j Veteran
L2j Veteran
Posts: 577
Joined: Fri Dec 14, 2007 11:58 am
Location: Russia

Re: Walking Mobs on a Route

Post by VlLight »

corbin12 wrote:VlLight, can you please explain further about getRoute?
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)
User avatar
corbin12
Posts: 325
Joined: Sun May 29, 2011 8:27 pm
Location: Seed of Hellfire

Re: Walking Mobs on a Route

Post by corbin12 »

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?
"Playing Lineage II is not a privilege, but a right."
lion
L2j Veteran
L2j Veteran
Posts: 967
Joined: Sun Mar 11, 2007 7:49 pm
Location: Ukraine

Re: Walking Mobs on a Route

Post by lion »

2,5,12 route id in Route.xml, yes x and y
User avatar
corbin12
Posts: 325
Joined: Sun May 29, 2011 8:27 pm
Location: Seed of Hellfire

Re: Walking Mobs on a Route

Post by corbin12 »

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."
lion
L2j Veteran
L2j Veteran
Posts: 967
Joined: Sun Mar 11, 2007 7:49 pm
Location: Ukraine

Re: Walking Mobs on a Route

Post by lion »

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
User avatar
corbin12
Posts: 325
Joined: Sun May 29, 2011 8:27 pm
Location: Seed of Hellfire

Re: Walking Mobs on a Route

Post by corbin12 »

Thank you. I made a script but only one of 2 mobs run
"Playing Lineage II is not a privilege, but a right."
Post Reply