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)


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).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...