Jump to content

Open source F2P quester


thatguycalledrob

Recommended Posts

55 minutes ago, thatguycalledrob said:

Ah the man himself! Okay okay, I admit that the real reason that I didn't use it was because it didn't work as expected the first time (wouldn't return true when a quest was completed). However, since this whole script is config-based it did make some logical sense to use a different implementation! I guess the API focuses on robustness over most else.

Thanks for looking through the code though, it means a lot to have one of the main devs check it!

 

I still want to log which one is causing an error when I have Verbose mode, but you're right in that each if statement calls the function, even if VERBOSE = False.
I think I will wrap the whole thing in an if(Verbose){} statement, as to only call them the second time if I am actually wanting an output. Good catch on this, I wouldn't have seen this if I had been looking!

 

Valid, I was worried about this yesterday.
I'm fairly new to OSbot & java coding here, so could you, or someone else please help me with a best practice example?
I am unsure how often ID's change, and the best implementation for options.

are we talking about:
https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html ?
 

if so - would you replace my stream:
RS2Object Coffin = getObjects().getAll().stream().filter(n -> n.getName().equals("Coffin") && (n.getId() == 15061 || n.getId() == 2145))
With something like:
RS2Object Coffin = Optional.ofNullable(getObjects().getAll()).filter(n -> n.getName().equals("Coffin")).orElse("Some default")?

Examples would be appreciated!
Looks like tomorrows session is just going to be a lot of code cleaning 

 

Optional<RS2Object> optional = getObjects().getAll().stream().filter(n -> n.getName().equals("Coffin")).findFirst();
if(optional.isPresent()) { //do things }

This is the more "proper" way, however your solution would work.

The only static ids which are normally accepted is item ids and config ids. Although config ids have changed in the past they are considered very stable. Definitely replace entity ids with other identifiers, the entity hover debug tool should give you some ideas. As for using configs for checking if a quest is complete or not, that's definitely fine because you know the exact values for your individual quests.

You said specifically you are new to Java coding, are you familiar with other languages?
 

 

Link to comment
Share on other sites

12 hours ago, Alek said:

Optional<RS2Object> optional = getObjects().getAll().stream().filter(n -> n.getName().equals("Coffin")).findFirst();
if(optional.isPresent()) { //do things }

This is the more "proper" way, however your solution would work.

1

Okay I see, I think this will actually make it easier to solve a bug in the R&J script I found yesterday.
Thanks for the example!

Out of interest, any idea how to order a stream with multiple values, based on a set of conditions? 
I was writing a fishing script and I noticed that all bots all move at the same time to the same next spot when one vanishes (probably due to using the . closest API command).
I tried to better with a stream it but now it seems to go to the Object with the lowest x+y (coords).
Both seem to be easily detectable with some basic pattern recognition on Jagex's side.

I wanted to order the stream, and then remove the top n elements of the stream based on a distribution, such that it picks the closes spot with probability p(1), the second with p(2), etc
My issue is that I couldn't find a way to do this trivially, either ordering or discarding. I could put the stream (after filtering) into an array, then order, remove, check, etc... but these seem like things that you should be able to do with the inbuilt functionality of Java.

 

12 hours ago, Alek said:

You said specifically you are new to Java coding, are you familiar with other languages?

 

Yessir, I did a placement year last year (might be called a year in industry in the USA) where I basically ended up scripting in VBA 40 hours a week, and I have done a load of C, Maple, R and Matlab over the first half of my degree, although I'm nowhere near as good as I am with VBA.

Link to comment
Share on other sites

  • 1 month later...
  • 2 years later...
  • 1 year later...

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