Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

EasyAsPieee

Stop anything on attack?

16 posts in this topic

Hey there guys. I started scripting recently, and I'm working on some scripts for deadman mode. The problem that came up for me is that if I die while doing something, the bot should go to top lummy bank, withdraw a tablet and teleport back where needed, but it just starts running elsewhere. The problem that causes this I believe is that, for example, I call:

PathFinding.aStarWalk(bank.getRandomTile());

It finds the path, sets it, and just does step by step, and if killed, the step doesn't kick off and is just attempted to do further? If so, would there be any way to like... Stop ANYTHING that the bot was doing if in combat/dead? Thank you!

Share this post


Link to post
Share on other sites

DPathNavigator allows you to set a stopping condition i.e. if health < a certain number then it will stop, however DPathNavigator can only be used to navigate currently loaded areas. I'm not sure if any of the other API walking methods support stopping conditions.

Share this post


Link to post
Share on other sites
2 minutes ago, FALSkills said:

DPathNavigator allows you to set a stopping condition i.e. if health < a certain number then it will stop, however DPathNavigator can only be used to navigate currently loaded areas. I'm not sure if any of the other API walking methods support stopping conditions.


What is considered a currently loaded area? The block that doesnt require "Loading... Please wait" box? If so, what size is it?

Share this post


Link to post
Share on other sites
3 minutes ago, EasyAsPieee said:


What is considered a currently loaded area? The block that doesnt require "Loading... Please wait" box? If so, what size is it?

I'm not sure of the exact radius, but like 25-30 tiles or so.

Share this post


Link to post
Share on other sites

WebWalking is not perfect. It doesn't work everywhere and paths are not always the best.
Also, every script walks in the same web, so yes, it's quite easy to detect.

There is an AdvancedWalking on development which might be a major improvement from WebWalking:

Meanwhile, you could implement your own walking method.

 

Share this post


Link to post
Share on other sites

Is the path you're working with predictable? (e.g. going from bank to trees)

You could create an array of RSTiles with a few tiles which your script would walk through.

Randomize it a little on every walk:
https://tribot.org/doc/org/tribot/api2007/Walking.html#randomizePath-org.tribot.api.interfaces.Positionable:A-int-int-

and then use this to walk through the path. Also has the ability to stop if a specified condition is true (e.g. hp lower than x, death, etc)
https://tribot.org/doc/org/tribot/api2007/Walking.html#walkPath-org.tribot.api.interfaces.Positionable:A-org.tribot.api.types.generic.Condition-long-


 

 

 

Share this post


Link to post
Share on other sites

I use WebWalking in one of my scripts that i currently farm and accounts last over a month. IMO other classes are much more detectable than webWalking, so I'd reccommend using WebWalking with stopping condition, just because it will be  a lot easier for you.

Here is how the stopping condition should look like.

WebWalking.walkTo(LOCATION_RSTile, new Condition() {
				@Override
				public boolean active() {
					if (Stopping_condition)// set a stopping condition here. for instance, if leaves RSArea, return true and stop webwalking.
						return true;
					} else {
						return false;
					}
				}
			}, 200);

 

Share this post


Link to post
Share on other sites
21 minutes ago, Xpointerset said:

if (Stopping_condition) { // set a stopping condition here. for instance, if leaves RSArea, return true and stop webwalking.
    return true;
} else {
   return false;
}

That's as bad a programmer can do. Simply return your if condition:  return Stopping_condition;

Edited by Beg

Share this post


Link to post
Share on other sites
12 minutes ago, Beg said:

That's as bad a programmer can do. Simply return your if condition:  return Stopping_condition;

First off thank you for correcting me.

So if I simply use "return Stopping_condition;" the stopping condition itself will act as a boolean and pass true/false values to active(). Am I correct?

Share this post


Link to post
Share on other sites
46 minutes ago, Xpointerset said:

First off thank you for correcting me.

So if I simply use "return Stopping_condition;" the stopping condition itself will act as a boolean and pass true/false values to active(). Am I correct?

Since you use it as a boolean for the if statement you can rightfully use it as a boolean for return statement :P

E: Could I find something somewhere about writing conditions? All the @override stuff etc etc feels so new to me, would like to read about it a little :?

Edited by EasyAsPieee

Share this post


Link to post
Share on other sites
1 hour ago, EasyAsPieee said:

E: Could I find something somewhere about writing conditions? All the @override stuff etc etc feels so new to me, would like to read about it a little :?

@Override is just a notation to remind you you're overriding an existing method. It doesn't even need to be there but it's good practice to do so and it's always helpful to know if you're overriding or declaring a new method.
In this case, you're overriding the definition of active() method (which is abstract) and implementing your own.

The condition is no more than an abstract class with an abstract method, boolean active().
You're defining a new anonymous inner class of type Condition and implementing your own active() method.

https://tribot.org/doc/org/tribot/api/types/generic/Condition.html

// This is the whole API Condition Class
public abstract class Condition() {

    public abstract boolean active();

}

Edited by Beg

Share this post


Link to post
Share on other sites
7 minutes ago, Beg said:

@Override is just a notation to remind you you're overriding an existing method. It doesn't even need to be there but it's good practice to do so and it's always helpful to know if you're overriding or declaring a new method.
In this case, you're overriding the definition of active() method (which is abstract) and implementing your own.

The condition is no more than an abstract class with an abstract method, boolean active().
You're making a new object of class Condition and implementing your own active() method.

https://tribot.org/doc/org/tribot/api/types/generic/Condition.html

// This is the whole API Condition Class
public abstract class Condition() {

    public abstract boolean active();

}

That makes sense, thanks! :) And as I have taken an override from another script once, the abstract classes create new files, right? Because my script is now divided into 2 files, *.class and *$1.class ?

Share this post


Link to post
Share on other sites

$1.class has nothing to do with abstract classes.  $#.class files is where anonymous inner classes are stored, such as new Condition() { ... }.
If you do 10 different new Condition() { ... } on your code, then *$1.class, *$2.class, *$3.class ..., *$10.class files are created.

Edited by Beg

Share this post


Link to post
Share on other sites

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.