Jump to content

itemSelected() method snippet


KMJT

Recommended Posts

Probably not the most efficient but better than nothing. It is pretty straight forward. Whatever item you want to add this method to put the item in the very first inventory slot to debug the points (3 x and 3 y coordinate values). If you debug your coordinate values from any spot other than the very first inventory slot, the method will not work. The coordinate points that you are debugging will be of the white outline (when an item is selected). Make sure that these colors match exactly the rgb values (255,255,255) which is the white outline around the item. When choosing your confirm points try to spread the points out and choose points that you think are unique (for example if there is a point that is bent inwards into the item, that would be a good point to choose since it is unlikely that any other item in the game shares that distinct feature). I put in 3 confirm points but you can easily edit the method to add more/less confirm points. The more confirm points there are, the more accurate the method will be. Although imo anything over 3 confirm points is overkill if you are choosing points that are spread apart and unique.

 

public int onLoop() throws InterruptedException
{ 
    //test example
 
    if(itemSelected(568,221,  580,237,  590,227))
        log("ROPE UPTEXT");
 
    else if(itemSelected(571,235,  573,242,  585,223))
        log("KNIFE UPTEXT");
 
    else
        log("no uptext");
 
    return 50;
}
 
 
 
boolean itemSelected(int highlightedX1, int highlightedY1, int highlightedX2, int highlightedY2, int highlightedX3, int highlightedY3)
{
    Color highlightColor = new Color(255,255,255);
 
    for(int rows=0, y1=highlightedY1, y2=highlightedY2, y3=highlightedY3; rows<7; rows++)
    {
        for(int columns=0, x1=highlightedX1, x2=highlightedX2, x3=highlightedX3; columns<4; columns++)
        {
            if(client.getColorPicker().isColorAt(x1,y1,highlightColor) && client.getColorPicker().isColorAt(x2,y2,highlightColor) && client.getColorPicker().isColorAt(x3,y3,highlightColor))
                return true;
 
            x1+=42;
            x2+=42;
            x3+=42;
        }
 
        y1+=36;
        y2+=36;
        y3+=36;
    }
 
    return false;
}
Edited by KMJT
Link to comment
Share on other sites

Its not efficient, guys just use hook its few seconds to find those fields.

 

 

I may be wrong but from what I was told using your method although more efficient doesn't it eventually have to be updated? Personally I would rather sacrifice a bit of CPU then have to worry about updating something in the future tongue.png Which is why they should just hook it in the API >.<

Can't you just check if your first Option contains "use"?

 

 

How? The client.getMenu() or w/e the code is does not verify true uptext. It is hover uptext which does not guarantee that an item is selected.

 

If you mean grabbing colours from the actual up text area, you can, although you would have to have a colour range since the up text colour is not constant. By that I mean if you are grabbing the rgb values of a direct point on the world "Use", a few seconds later that rgb value could be slightly off, i'm guessing because of background change. I haven't really tested the rgb value range in the uptext so for all I know it is more efficient. I'll test the rgb range later tonight.

Edited by KMJT
Link to comment
Share on other sites

  • 3 weeks later...

I may be wrong but from what I was told using your method although more efficient doesn't it eventually have to be updated? Personally I would rather sacrifice a bit of CPU then have to worry about updating something in the future tongue.png Which is why they should just hook it in the API >.<

 

 

U will get it faster than osbot update lel. Even by hand

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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