Jump to content

How to handle trees that grab you?


dmmslaver

Recommended Posts

I have made something for the exact same problem,

 

Because setBreakCondition isn't triggered often enough, I have a seperate thread that does the following:

 

Find all trees near me within 1 tile away,

If tree found, interrupt() the main thread

 

The interrupt interrupts the web walker, so my code falls back into the main onLoop()

 

There I have some logic that checks for the trees again, if one is found it walks around it or else continues webWalking smile.png

Edited by Abuse
Link to comment
Share on other sites

I have made something for the exact same problem,

 

Because setBreakCondition isn't triggered often enough, I have a seperate thread that does the following:

 

Find all trees near me within 1 tile away,

If tree found, interrupt() the main thread

 

The interrupt interrupts the web walker, so my code falls back into the main onLoop()

 

There I have some logic that checks for the trees again, if one is found it walks around it or else continues webWalking smile.png

Thank you yes that is a workaround however seems really haxxy :D

Link to comment
Share on other sites

There is no better responsive way atm.

This isn't the only npc that halts your movement. Like the guy in the chair in falador castle, and others. It would be nice to see the web walking realize that it is not actually walking, and then evaluate()

The thread polling solution is rather cumbersome for such a simple task.

Edited by dmm_slaver
Link to comment
Share on other sites

Solution:

 

    Thread shitTree = new Thread() {

        {
            setDaemon(true);
            setPriority(Thread.MIN_PRIORITY);
            setName("Shit tree handler 0");
        }

        @[member=Override]
        public void run() {
            do {
                Player i = myPlayer();
                if (i != null) {
                    if (i.isHitBarVisible()) {
                        interrupt = true;
                        NPC tree = npcs.closest(4418);
                        if (tree != null) {
                            log("under attack tree");
                            if (tree.getY() > myPlayer().getY() && am.dist(tree, myPlayer()) < 2) {
                                Position p = myPosition().translate(am.gauss(3), 0);
                                p.interact(bot, "Walk here");
                                am.delay(am.gaussp(1200, 600));
                                continue;
                            }
                        }

                    } else {
                        interrupt = false;
                    }
                }
                am.delay(50);

            } while (running);
        }
    };
Link to comment
Share on other sites

 

Solution:

 

    Thread shitTree = new Thread() {

        {
            setDaemon(true);
            setPriority(Thread.MIN_PRIORITY);
            setName("Shit tree handler 0");
        }

        @[member='Override']
        public void run() {
            do {
                Player i = myPlayer();
                if (i != null) {
                    if (i.isHitBarVisible()) {
                        interrupt = true;
                        NPC tree = npcs.closest(4418);
                        if (tree != null) {
                            log("under attack tree");
                            if (tree.getY() > myPlayer().getY() && am.dist(tree, myPlayer()) < 2) {
                                Position p = myPosition().translate(am.gauss(3), 0);
                                p.interact(bot, "Walk here");
                                am.delay(am.gaussp(1200, 600));
                                continue;
                            }
                        }

                    } else {
                        interrupt = false;
                    }
                }
                am.delay(50);

            } while (running);
        }
    };

 

It'd be cool if they added support for this so people weren't creating a separate thread just to check for tree npc's

Link to comment
Share on other sites

It'd be cool if they added support for this so people weren't creating a separate thread just to check for tree npc's

All they need is to be able to set a maximum wait time before running evaluate() 

Also note, my solution only works if you're walking from south to north always. However it would be easy to modify it to work for other directions. 

Link to comment
Share on other sites

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
Reply to this topic...

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...