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.



  • Posts

    • Top Up the Way You Like — PayPal is Back with Us! We're excited to announce that we now accept PayPal again! That means even more ways to fund your balance in our store Available Payment Methods: ➡ Cryptocurrency (USDT, BTC, ETH, LTC, and more) ➡ Crypto Bot in Telegram ➡ Telegram Stars ➡ Bank Cards ➡ Lolz Balance ➡ Binance Pay ➡ Crystal Pay — crystalpay.io ➡ Wata (Bank Cards) ➡ Payeer ➡ AliPay ➡ PayPal (Friends & Family only) Also Available on the Website: ➡ Binance Gift Cards ➡ Google Pay/Apple Pay Promo Code: PAYPAL5 (5% Discount) How to Buy: ➡ Online Store: Click ➡ Telegram Bot: Click Other Services: ➡ SMM Panel: Click Returning customers enjoy extra discounts and promo codes! Support: ➡ Telegram: https://t.me/solomon_bog ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ ✉ Email: solomonbog@socnet.store You can also use these contacts to: — Get consultation on wholesale purchases — Establish a partnership (Current partners: https://socnet.bgng.io/partners) — Become our supplier SocNet — Your Store for Digital Goods & Premium Subscriptions
    • Top Up the Way You Like — PayPal is Back with Us! We're excited to announce that we now accept PayPal again! That means even more ways to fund your balance in our store Available Payment Methods: ➡ Cryptocurrency (USDT, BTC, ETH, LTC, and more) ➡ Crypto Bot in Telegram ➡ Telegram Stars ➡ Bank Cards ➡ Lolz Balance ➡ Binance Pay ➡ Crystal Pay — crystalpay.io ➡ Wata (Bank Cards) ➡ Payeer ➡ AliPay ➡ PayPal (Friends & Family only) Also Available on the Website: ➡ Binance Gift Cards ➡ Google Pay/Apple Pay Promo Code: PAYPAL5 (5% Discount) How to Buy: ➡ Online Store: Click ➡ Telegram Bot: Click Other Services: ➡ SMM Panel: Click Returning customers enjoy extra discounts and promo codes! Support: ➡ Telegram: https://t.me/solomon_bog ➡ Telegram Channel: https://t.me/accsforyou_shop ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ ✉ Email: solomonbog@socnet.store You can also use these contacts to: — Get consultation on wholesale purchases — Establish a partnership (Current partners: https://socnet.bgng.io/partners) — Become our supplier SocNet — Your Store for Digital Goods & Premium Subscriptions
    • We are taking new orders. Kindly DM us on Telegram!
    • Dear friends, Just a reminder - our Open Beta Test begins today at 18:00! Join us to explore the world together, test the update, and help us make it even better. See you in game!    The Chronicle 4 client is now available for download.
    • I tried mate with a fresh Freya, H5, H5 part 5, and always the same issue. I can't enter inside the Game, as it appears black. I. Can hear sound and so on from the starting location and quest, but I can't see a thing I installed the chinese language on windows, and still does not work , I always get black screen when i try to enter into the game after selecting the characters. I hear sounds, environment and so on, but i can see anything Also tried with a fresh freya client as well, i can see the english words and so on, but i cant enter inside the game...i dont understand whats going wrong
  • Topics

×
×
  • 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