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

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


  • Posts

    • Can't find you on discord ,can you share your discord profile here?
    • Hello lovely community, When you talk, about trust first of all I want you to stay and think for a second. - If was not a trusted person why I would even share this information? (seriously not a single reason) - I did not share any information about how this happened, and which company had the vulnurability (the issue has been fixed from their side and they was very helpful and took quick action + our dev as expert took that quick action) I also want warmly thank abusix.com for providing detailed information (not going to share the whole email for obivious reasons) Mentioning  - So lets clarify now what to except from the project. We have different different protocols and 2 engines. But first we are going to start with Interlude Mastered which is going to be a modern engine but a familiar one. Secondary project will be with the latest engine UE however this one needs allot of work is not that easy it takes time(so we will have it soon as is ready) I got to agree with Seamless, Good project are developed quietly. Also we have already clarified that the servers that we are working are under development how is possible guys to give you detailed information about something that is not finished yet? The topic opened on General Discussion Instead of  Private Servers for a reason. Some of you already have serves in this topic please and none of you have approach they way i do and be open for your own servers unless you have it ready until now so please.... atleast I'm taking a step and I'm pretty much open to share information with everyone. Once everything is ready Server information and everything will be shared in the topic: Private servers. Thanks in advance.  
    • Boost your connection speed and secure your privacy today!  Official Website: https://novproxy.com?kwd=tt-max
    • Good projects are developed quietly and launched only when they are ready to maintain a consistent online presence and build a community. The formula is simple, yet people keep making the same mistakes.   Start with an alpha phase and keep access limited. Since the author claims to already have an inner circle, use that group for early testing. Then open a closed beta through invitation keys or a similar system. Later, announce an open beta.   During these early stages, do not accept donations, partnerships, or other forms of support. Focus entirely on improving the project. Once it is stable, announce it and continue maintaining it regardless of the maximum number of users on
    • in best case this project will open with 100 ppl
  • 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..