Welcome!

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

Sign up now!

Bug Using GE API

Joined
Aug 23, 2015
Messages
1,970
Jdocs:
  • GrandExchange.close() is missing - Cloud said it doesn't exist
  • getWealthTransferred() - a description saying what this does would be helpful, though I assume its the money spent or received relating to an offer
  • toString() - probably shouldn't be exposed
  • getItemQuantity() - consider making this getTotalOfferQuantity() for clarity

Method usage:
  • GrandExchange.open() doesn't work
  • Setting offer quantity to '0' literally enters 0 infinitely... since you can't enter 0. It should enter in the number in your inv, or a playersensed, very high value - EDIT this may be since setting quantity doesn't work at all, see below
  • Sell offers never get past the entering quantity stage, even with a real number
  • Buy offers never get past the entering quantity stage

Will update further when the GE api is usable...

Here is the shitty code I used
Code:
package com.regalbots.testingGE;

import com.RegalAPI.fletching.Fletching;
import com.runemate.game.api.hybrid.entities.LocatableEntity;
import com.runemate.game.api.hybrid.entities.definitions.ItemDefinition;
import com.runemate.game.api.hybrid.local.Camera;
import com.runemate.game.api.hybrid.local.hud.interfaces.Bank;
import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
import com.runemate.game.api.hybrid.local.hud.interfaces.SpriteItem;
import com.runemate.game.api.hybrid.region.Banks;
import com.runemate.game.api.script.framework.LoopingBot;
import com.runemate.game.api.hybrid.net.GrandExchange;

public class GrandExchangeBot extends LoopingBot {

    private Fletching bow = Fletching.MAPLE_LONGBOW_U;
    private SpriteItem materialOne, materialTwo, finishedProduct;
    private ItemDefinition matOneDefinition, matTwoDefinition, productDefinition;
    private int matOnePrice, matTwoPrice, productPrice;
    private int matOneID, matTwoID, finishedProductID;
    private GrandExchange.Item matOneLookup, matTwoLookup, productLookup;
    private int toWithdraw;


    @Override
    public void onStart(String... strings) {
        setLoopDelay(2000, 3000);
    }

    @Override
    public void onLoop() {
        getLogger().info("Looping");
        productPrice = 0;
        matOnePrice = 0;
        matTwoPrice = 0;
        if(true || (materialOne = Inventory.newQuery().names(bow.getMaterialOne()).results().first()) != null){
            //matOneDefinition = materialOne.getDefinition();
            if(true || matOneDefinition != null){
                //matOneID = matOneDefinition.getId();
                matOneID = 1517;
                matOneLookup = GrandExchange.lookup(matOneID);
                if(matOneLookup != null){
                    matOnePrice = (int) (matOneLookup.getPrice() * 1.1);
                    getLogger().info("Found material one price");
                }
            }
        }
        if(true || (materialTwo = Inventory.newQuery().names(bow.getMaterialTwo()).results().first()) != null){
            //matTwoDefinition = materialTwo.getDefinition();
            if(true || matTwoDefinition != null){
                //matTwoID = matTwoDefinition.getId();
                matTwoID = 946;
                matTwoLookup = GrandExchange.lookup(matTwoID);
                if(matTwoLookup != null){
                    matTwoPrice = (int) (matTwoLookup.getPrice() * 1.1);
                    getLogger().info("Found material two price");
                }
            }
        }
        if(true || (finishedProduct = Inventory.newQuery().names(bow.getProduct()).results().first()) != null){
            //productDefinition = finishedProduct.getDefinition();
            if(true || productDefinition != null){
                //finishedProductID = productDefinition.getId();
                finishedProductID = 62;
                productLookup = GrandExchange.lookup(finishedProductID);
                if(productLookup != null) {
                    productPrice = (int) (productLookup.getPrice() * .85);
                    getLogger().info("Found product price");
                }
            }
        }
        if(Inventory.contains(bow.getProduct()) || Inventory.getQuantity("Coins") > 10000) {
            getLogger().info("We have product or coins");
            if (GrandExchange.isOpen()) {
                getLogger().info("GE is open");
                if (Inventory.containsAllOf(bow.getMaterialOne(), bow.getMaterialTwo())) {
                    getLogger().warn("Pretend GE is being closed");
                } else if (Inventory.contains(bow.getProduct()) && productPrice != 0){
                    getLogger().info("Buying product");
                    GrandExchange.placeSellOffer(bow.getProduct(), 2314, productPrice);
                } else if (!GrandExchange.newQuery().sellOffers().itemNames(bow.getProduct()).completed().results().isEmpty()){
                    getLogger().info("Product purchased");
                    GrandExchange.collectToInventory();
                } else if (!Inventory.contains(bow.getMaterialOne()) && GrandExchange.newQuery().buyOffers().itemNames(bow.getMaterialOne()).results().isEmpty()){
                    getLogger().info("Buying "+bow.getMaterialOne());
                    GrandExchange.placeBuyOffer(bow.getMaterialOne(), 1000, matOnePrice);
                } else if (!GrandExchange.newQuery().buyOffers().itemNames(bow.getMaterialOne()).completed().results().isEmpty()){
                    getLogger().info(bow.getMaterialOne()+" purchased");
                    GrandExchange.collectToInventory();
                } else if (!Inventory.contains(bow.getMaterialTwo()) && GrandExchange.newQuery().buyOffers().itemNames(bow.getMaterialTwo()).results().isEmpty()){
                    getLogger().info("Buying "+bow.getMaterialTwo());
                    GrandExchange.placeBuyOffer(bow.getMaterialTwo(), 1, matTwoPrice);
                } else if (!GrandExchange.newQuery().buyOffers().itemNames(bow.getMaterialTwo()).completed().results().isEmpty()){
                    getLogger().info(bow.getMaterialTwo()+" purchased");
                    GrandExchange.collectToInventory();
                }
            } else {
                if(Bank.isOpen()){
                    getLogger().info("Closing bank to use GE");
                    Bank.close();
                } else {
                    getLogger().info("Opening GE");
                    GrandExchange.open();
                }
            }
        } else {
            getLogger().info("Looking for "+bow.getProduct()+" to sell and Coins in the bank.");
            if(Bank.isOpen()){
                if(Bank.getWithdrawMode().equals(Bank.WithdrawMode.NOTE)){
                    if(Bank.contains(bow.getProduct())){
                        getLogger().info("Withdrawing product");
                        Bank.withdraw(bow.getProduct(), 0);
                    } else if (Bank.contains("Coins")){
                        getLogger().info("Withdrawing coins");
                        toWithdraw = (int) (Bank.getQuantity("Coins") * .75);
                        Bank.withdraw("Coins", toWithdraw);
                    } else if (Inventory.contains(bow.getProduct()) || (Inventory.getQuantity("Coins") > Bank.getQuantity("Coins"))) {
                        getLogger().info("Closing bank");
                        Bank.close();
                    } else {
                        getLogger().severe("We couldn't find "+bow.getProduct()+"s.  Stopping bot.");
                        stop();
                    }
                } else {
                    Bank.setWithdrawMode(Bank.WithdrawMode.NOTE);
                }
            } else {
                LocatableEntity banker = Banks.newQuery().results().nearest();
                if(banker != null && banker.isVisible()){
                    getLogger().info("Opening bank");
                    Bank.open();
                } else {
                    if(banker != null){
                        Camera.turnTo(banker);
                    }
                }
            }
        }
    }
}

@Party
 
@Party
This code is way too expansive for the amt of time I have tonight, and it's very hard to follow. I'm going to post the issues I find here with what I think will fix it, or hints.

This is only for OSRS. If you would like me to check RS3, PM me on slack or RM.

Code:
   private static boolean configureValuesAndConfirm(int quantity, int price) {
                if (quantityButton == null || !quantityButton.interact("Enter quantity") || !Execution.delayUntil(EnterAmountDialog::isOpen, 1200)) {
                    return false;
                }

Problem: EnterAmountDialog is never open, since the code doesn't encompass the grand exchange "Enter price" interface
Solution: Change EnterAmountDialog as follows. This will allow it to "see" that it's ready to enter a price per item.

Code:
    private static InterfaceComponent getTextEntryComponent() {
        return Interfaces.newQuery().texts("Enter amount:", "How many do you wish to buy?", "How many do you wish to sell?", "Set a price for each item:").types(InterfaceComponent.Type.LABEL)
                .containers(Environment.isRS3() ? RS3_WIDGET : OSRS_WIDGET).results().first();
    }

I didn't test it, but here is an example of getting the # entered out of this interface
Imgur: The most awesome images on the Internet

Code:
    public static boolean open() {
        return open(Npcs.newQuery().names("Grand Exchange clerk").actions("Exchange").visible().results().nearest(), "Exchange");
    }

    public static boolean open(String action) {
        return open(Npcs.newQuery().names("Grand Exchange clerk").actions("Exchange").visible().results().nearest(), action);
    }

Problem: NPC Query doesn't work
Solution: Change names() to names("Grand Exchange Clerk")

IDK what code to write to fix this, but I'm can describe what I think is happening.

The query
final InterfaceComponent priceComponent = Interfaces.newQuery().containers(GE_CONTAINER).types(InterfaceComponent.Type.LABEL).texts(PRICE_TERM).heights(20).results().first();
is throwing false positives. When the false positive throws (It finds that text somewhere else, in hidden parts of the GE interface), it thinks the price is correct. I tested this by using a price of 6, which caused it to place an offer as intended, and then a price of 999, which caused it to click the "Set price" button infinitely. When using OIE, a query using the .contains(6) returns multiple results in the GE container, while using .contains(999) only returns the actual price.

Pretty sure it's a problem with the comma in the number
 
Joined
Aug 23, 2015
Messages
1,970
@Party correct price still not recognized, quantities over 999 still not recognized
 
To clarify, problems 1 and 2 are solved. Problems 3 and 4 remain.
 
UPDATE 7/2/17
still doesn't recognize quantities over 999
never recognizes the correct price, regardless of quantity of item
 
@Party
 
@Party The issues listed in OP and on july 2nd are resolved.


There is one remaining issue where it will regularly type the item's name incorrectly by typing the beginning, deleting it, and typing the rest. Fortunately, it always recovers if the item isn't shown, although it usually shows up anyways.
 
Top