Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question Arrays/Lists with GameObjects

Joined
Dec 4, 2020
Messages
5
Hey folks. I'm new around here and trying my hand at putting together some bots. Not entirely new to scripting but this is getting me.

Basically, I am trying to get all reachable iron ores from a position (there should be 3), and add them into an array/list. Here is currently what the section looks like:

Code:
public void execute() {
        OreMuncher.rocks = GameObjects.newQuery().reachableFrom(OreMuncher.getOreLocation()).ids(11365).actions("Mine").results().asList();
        if(OreMuncher.rocks.size() > 0) logText("Rocks found");
        if(OreMuncher.rocks.size() > 0 && OreMuncher.getPlayer() != null && Distance.between(OreMuncher.getOreLocation(), OreMuncher.getPlayer()) < 1){
            logText("Mining iron");
            switch(OreMuncher.getRockSelect()){
                case 0: {
                    OreMuncher.rockSelect++;
                    OreMuncher.rocks.get(OreMuncher.rockSelect).interact("Mine");
                }
                case 1: {
                    OreMuncher.rockSelect++;
                    OreMuncher.rocks.get(OreMuncher.rockSelect).interact("Mine");
                }
                case 2: {
                    OreMuncher.rockSelect = 0;
                    OreMuncher.rocks.get(OreMuncher.rockSelect).interact("Mine");
                }
            }
            Execution.delayUntil(()->OreMuncher.getPlayer().getAnimationId() != -1, 5000);
        }
        else if(OreMuncher.getPlayer() != null && Distance.between(OreMuncher.getOreLocation(), OreMuncher.getPlayer()) > 1) {
                logText("Moving to mining location");
                Path p = RegionPath.buildTo(OreMuncher.getOreLocation());
                if(p != null)
                    p.step();
        }
        else if(OreMuncher.rocks.size() == 3 && !OreMuncher.rocks.get(OreMuncher.rockSelect).isVisible())
            Camera.turnTo(OreMuncher.rocks.get(OreMuncher.rockSelect));
        else logText("No rocks found.");
    }

I am using rockSelect to keep track of which rock the player is currently mining. OreMuncher.rocks is the list I created in the main class with
Code:
public static List<GameObject> rocks = new ArrayList<>();

When in-game, absolutely nothing happens. All other parts of my script work; world switching, retrieving the pickaxe, dropping, I'm just struggling with getting these stupid rocks into a list.

Thanks heaps folks! Let me know if you need anything more from me :)
 
Joined
Feb 24, 2020
Messages
33
i quite don't get why do you need to overcomplicate things at start, scripts naturally get overcomplicated as time passes begin as simple as you can

why exactly do you need to know which rock your mining?

why do you need check for reachability? is there some unreachable rock from position OreMuncher.getOreLocation()?

do you need to control exactly which rock out of the 3 your mining? or cannot you just return the .nearest one to OreMuncher.getOreLocation()?

what kind of reasons have led you to believe that using simple rock decision by color substitution is not enough for this task?
 
Joined
Dec 4, 2020
Messages
5
i quite don't get why do you need to overcomplicate things at start, scripts naturally get overcomplicated as time passes begin as simple as you can

why exactly do you need to know which rock your mining?

why do you need check for reachability? is there some unreachable rock from position OreMuncher.getOreLocation()?

do you need to control exactly which rock out of the 3 your mining? or cannot you just return the .nearest one to OreMuncher.getOreLocation()?

what kind of reasons have led you to believe that using simple rock decision by color substitution is not enough for this task?
The idea is that I wanted to keep track of which rock I am mining so that I can hover over the next one, for example, and allow me to keep mining in a pattern instead of randomizing it. I am trying to create a powermining bot in which I stand in one location between three ore deposits, so using reachability seemed like the easiest method to gather the three rocks Objects. Just getting the nearest one would not work either as it would just be grabbing one rock consistently, am I wrong?
 
Joined
Feb 24, 2020
Messages
33
The idea is that I wanted to keep track of which rock I am mining so that I can hover over the next one, for example, and allow me to keep mining in a pattern instead of randomizing it. I am trying to create a powermining bot in which I stand in one location between three ore deposits, so using reachability seemed like the easiest method to gather the three rocks Objects. Just getting the nearest one would not work either as it would just be grabbing one rock consistently, am I wrong?

Well the rock has certain states like depleted not depleted upon the change of the state the color of rock changes. Therefore if the rock is depleted color substitution disqualifies this rock from the query for gameObject.

quite frankly, if there is no need for rock selection pattern or order in which rocks are mined, then just handle them 1 by 1
if your mining iron why this doesn't suffice?

Code:
GameObject ironRocks = GameObjects.newQuery().colorSubstitutions(new Color(48,48,48), newColor(32,17,14)).results().nearestTo(OreMuncher.getOreLocation());
 
Joined
Dec 4, 2020
Messages
5
Well the rock has certain states like depleted not depleted upon the change of the state the color of rock changes. Therefore if the rock is depleted color substitution disqualifies this rock from the query for gameObject.

quite frankly, if there is no need for rock selection pattern or order in which rocks are mined, then just handle them 1 by 1
if your mining iron why this doesn't suffice?

Code:
GameObject ironRocks = GameObjects.newQuery().colorSubstitutions(new Color(48,48,48), newColor(32,17,14)).results().nearestTo(OreMuncher.getOreLocation());

That sounds like it could be a solution - I was just struggling to figure out how to make it target the three rocks closest to one point without running across the quarry, I thought an array with reachable objects would be an easy solution but your solution seems much better.

Thank you my friend, I'll give it a go!
 
Joined
Feb 24, 2020
Messages
33
runemate development is very confusing, and you seem to fail to appreciate the subtle devilry between something being reachable/pathable/navigable these things are all different!
  • also i would switch to TreeBot implementation
  • the null check for player works only if your not relogging then it may still return null once relogged refreshment of getLocal player may be needed
  • the local pathing will often return null not very reliable
 
Joined
Dec 4, 2020
Messages
5
runemate development is very confusing, and you seem to fail to appreciate the subtle devilry between something being reachable/pathable/navigable these things are all different!
  • also i would switch to TreeBot implementation
  • the null check for player works only if your not relogging then it may still return null once relogged refreshment of getLocal player may be needed
  • the local pathing will often return null not very reliable
I have seen a lot of information saying that WebPath is broken, but then at the same time I see some people that sound like they may have used it and have it work. Does WebPath work better then local pathing still at this point? If so, I'll have to go that a go tomorrow.

Really appreciate the information, thank you!
 
Joined
Feb 24, 2020
Messages
33
the situation is far more messy then that....

yes web is broken to most places
local pathing sometimes works, but even if it does it still performs sluggish, there's some weird micro delay on each step taken

so the only rescue so far seem to be

Custom Web Maker
 
cuppa.drink(java);
Joined
Mar 13, 2018
Messages
7,097
@Shwoopy I just got home from a long day so my brain isn't working at full capacity, but one quick thing I noticed is that you should really avoid using static variables of any kind in your bots (unless they're constants, I guess). By my understanding, static variables have a weird interaction if more than one bot is being run on the same runemate instance; If more than one bot of the same kind is being run on runemate, with static variables, I think the static variables are shared/interact in a non-deterministic way since both bots are trying to access the same variable.

Besides that it seems like Bia already covered most of the feedback: you can simplify a lot of the logic using a more precise query, you should nullcheck more stuff (especially Players.getLocal(), but a lot of things queried from runemate can return null unexpectedly, like Inventory.getItems(), object queries etc. I just assume all queries may be null and nullcheck/cache them as needed), colorSubs is helpful for mining. Also if you want to find the rocks directly adjacent to the player, what I personally do is have a function that takes in the player's current position and returns a "cross" area that derived from the current player area, and use this "cross" area in the GameObject query.

And of course if this is empty then search for 3 rocks nearby and have your pathing logic to get there (for such a small area, bresenhampath or regionpath should be fine, but custom webs are an option for more complex pathing).
 
Joined
Dec 4, 2020
Messages
5
@Shwoopy I just got home from a long day so my brain isn't working at full capacity, but one quick thing I noticed is that you should really avoid using static variables of any kind in your bots (unless they're constants, I guess). By my understanding, static variables have a weird interaction if more than one bot is being run on the same runemate instance; If more than one bot of the same kind is being run on runemate, with static variables, I think the static variables are shared/interact in a non-deterministic way since both bots are trying to access the same variable.

Besides that it seems like Bia already covered most of the feedback: you can simplify a lot of the logic using a more precise query, you should nullcheck more stuff (especially Players.getLocal(), but a lot of things queried from runemate can return null unexpectedly, like Inventory.getItems(), object queries etc. I just assume all queries may be null and nullcheck/cache them as needed), colorSubs is helpful for mining. Also if you want to find the rocks directly adjacent to the player, what I personally do is have a function that takes in the player's current position and returns a "cross" area that derived from the current player area, and use this "cross" area in the GameObject query.

And of course if this is empty then search for 3 rocks nearby and have your pathing logic to get there (for such a small area, bresenhampath or regionpath should be fine, but custom webs are an option for more complex pathing).
Thank you so much for the reply, Cuppa >:) Ironically, your AIO miner was partially what inspired me to give this a shot myself.
I have found out the hard way about everything returning null; I've gone through and added many null checks and learned how to combat that thankfully.

Really though, lots of great information here - thank you everybody! Learning lots today already; proud of my progress.
Going to go and read up on static variables and work on getting them out of my script.

Also will be working on converting over to a TreeBot instead of TaskBot.
Thanks guys!
 
Wanted to say I really appreciate your guys' support. You really inspired me to continue and I am extremely proud of the progress I have made and what I have learned when it comes to RuneMate's API in the last few days, and especially you, Cuppa, seeing how well your AIO miner works. Me being the poor sod I am, I wanted to go ahead and try making my own. I'm getting there.

I've become familiar with JavaFX and Scene Builder and created beautiful embedded UI. I've got the custom web pathing working (also if there is anybody else out there looking for an extremely handy world map that generates coordinates and areas: bless). I've also converted to TreeBot and I agree, it is much more pleasant to work with.

Hopefully I'll be able to actually get some bots on the store soon. Rome wasn't built in a day!
;)

Thanks dudes.

Side node, the 2 account 15 minute limit thing: very annoying when I'm constantly in and out testing :p
My fault for closing improperly I think but dang

IIad46A.png


Super pumped and excited to see where my journey takes me.
 
Last edited:
Top