Jump to content

How to handle trees that grab you?


Recommended Posts

Posted (edited)

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
Posted

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

Posted (edited)

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
Posted

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);
        }
    };
Posted

 

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

Posted

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. 

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
  • Recently Browsing   0 members

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