Jump to content
  • 0

Walker Mob Like Hi5


Question

Posted (edited)

hello all i have make a code for walker same mobs but i dont know why is not running
and in console show me error can any tell me where is the problem ?

	public void DoWalkerMonster()
	{
		if (npc == null || npc.getSpawn() == null)
		{	
			if (npc.getTemplate().getNpcId() != walkerNpc)
			{
				_isWalkTo++;
				if (_isWalkTo < 55)
				{
					_isWalkTo = 1;
				}
				X = WALKS[_isWalkTo - 1][0];
				Y = WALKS[_isWalkTo - 1][1];
				Z = WALKS[_isWalkTo - 1][2];
				// TODO: find better way to prevent teleporting to the home location
				npc.getSpawn().setLocx(X);
				npc.getSpawn().setLocy(Y);
				npc.getSpawn().setLocz(Z);
				npc.setRunning();
				npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(X, Y, Z, 0));
			}
			return;
		}
		LOGGER.info("walker mob working!"); // only for check work or not.
	}
Edited by tazerman2

13 answers to this question

Recommended Posts

  • 0
Posted (edited)

What the heck is that..

    if (npc == null || npc.getSpawn() == null)
        {    
            if (npc.getTemplate().getNpcId() != walkerNpc)

The code lack of logic, a bit :D

 

What's the error?

Edited by SweeTs
  • 0
Posted (edited)

i need make this
antharas_lair.jpg

is in antharas lair. like 30 mobs same ID walker in a my location. I tried to make this

Edited by tazerman2
  • 0
Posted (edited)


public class WalkerMonster implements Runnable

{

    public static L2NpcInstance npc;

    protected FastList<L2NpcInstance> _allMobs = new FastList<>();

    protected static final Logger LOGGER = Logger.getLogger(Quest.class);

    private static int _isWalkTo = 0;

    private static int X = 0;

    private static int Y = 0;

    private static int Z = 0;

    private static int walkerNpc = 90;

    

    private static final int[][] WALKS =

        {

            {

                141569,

                -45908,

                -2387

            },

            {

                142494,

                -45456,

                -2397

            },

            {

                141569,

                -45908,

                -2387

            },

            {

                142494,

                -45456,

                -2397

            },

            {

                141569,

                -45908,

                -2387

            },

            {

                142494,

                -45456,

                -2397

            }

        };

        

    public void DoWalkerMonster()

    {

        if (npc == null || npc.getSpawn() == null)

        {    

            if (npc.getTemplate().getNpcId() != walkerNpc)

            {

                _isWalkTo++;

                if (_isWalkTo < 55)

                {

                    _isWalkTo = 1;

                }

                X = WALKS[_isWalkTo - 1][0];

                Y = WALKS[_isWalkTo - 1][1];

                Z = WALKS[_isWalkTo - 1][2];

                // TODO: find better way to prevent teleporting to the home location

                npc.getSpawn().setLocx(X);

                npc.getSpawn().setLocy(Y);

                npc.getSpawn().setLocz(Z);

                npc.setRunning();

                npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(X, Y, Z, 0));

            }

        }

        LOGGER.info("walker mob working!"); // only for check is work or not

    }

 

    @Override

    public void run()

    {

        DoWalkerMonster();

    }

}

 

Edited by tazerman2
  • 0
Posted (edited)

The whole script got no logic, from the npcId checked (90), to the .run() method, to the reverted null checks, to the "indexes" (55 checks, while you got only 6 locations), to the miss of a loop.

 

Review your copy entirely, see Gordon script (whom nodes and index logics inherit from).

 

It can't work.

Edited by Tryskell
  • 0
Posted

I think this more correct.

	for (L2NpcInstance npc : _allMobs)
	{
	      if (npc != null && npc.getSpawn() != null)
	        {    
	            if (npc.getTemplate().getNpcId() != walkerNpc)
	            {
	                _isWalkTo++;
	                if (_isWalkTo < 55)
	                {
	                    _isWalkTo = 1;
	                }
	                X = WALKS[_isWalkTo - 1][0];
	                Y = WALKS[_isWalkTo - 1][1];
	                Z = WALKS[_isWalkTo - 1][2];
	                // TODO: find better way to prevent teleporting to the home location
	                npc.getSpawn().setLocx(X);
	                npc.getSpawn().setLocy(Y);
	                npc.getSpawn().setLocz(Z);
	                npc.setRunning();
	                npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(X, Y, Z, 0));
	            }
	        }
	}
  • 0
Posted

Those checks (notably npcId) are often pointless, on script because you generally only impact a single npcId, and on instance because the whole template inherits directly the core behavior.

 

getSpawn() != null is also tricky, if you manually spawn it or use regular spawnlist, you're screwed. You have to script side spawn it.

 

Anyway script shared is not even 50% of complete script, if you want to make it works correctly (without counting it's not even a script at first sight).

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock