1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Bug Using GE API

Discussion in 'Developer Support' started by Snufalufugus, Jun 16, 2017.

  1. Snufalufugus

    Joined:
    Aug 23, 2015
    Messages:
    1,961
    Likes Received:
    757
    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 (Text):
    1. package com.regalbots.testingGE;
    2.  
    3. import com.RegalAPI.fletching.Fletching;
    4. import com.runemate.game.api.hybrid.entities.LocatableEntity;
    5. import com.runemate.game.api.hybrid.entities.definitions.ItemDefinition;
    6. import com.runemate.game.api.hybrid.local.Camera;
    7. import com.runemate.game.api.hybrid.local.hud.interfaces.Bank;
    8. import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
    9. import com.runemate.game.api.hybrid.local.hud.interfaces.SpriteItem;
    10. import com.runemate.game.api.hybrid.region.Banks;
    11. import com.runemate.game.api.script.framework.LoopingBot;
    12. import com.runemate.game.api.hybrid.net.GrandExchange;
    13.  
    14. public class GrandExchangeBot extends LoopingBot {
    15.  
    16.     private Fletching bow = Fletching.MAPLE_LONGBOW_U;
    17.     private SpriteItem materialOne, materialTwo, finishedProduct;
    18.     private ItemDefinition matOneDefinition, matTwoDefinition, productDefinition;
    19.     private int matOnePrice, matTwoPrice, productPrice;
    20.     private int matOneID, matTwoID, finishedProductID;
    21.     private GrandExchange.Item matOneLookup, matTwoLookup, productLookup;
    22.     private int toWithdraw;
    23.  
    24.  
    25.     @Override
    26.     public void onStart(String... strings) {
    27.         setLoopDelay(2000, 3000);
    28.     }
    29.  
    30.     @Override
    31.     public void onLoop() {
    32.         getLogger().info("Looping");
    33.         productPrice = 0;
    34.         matOnePrice = 0;
    35.         matTwoPrice = 0;
    36.         if(true || (materialOne = Inventory.newQuery().names(bow.getMaterialOne()).results().first()) != null){
    37.             //matOneDefinition = materialOne.getDefinition();
    38.             if(true || matOneDefinition != null){
    39.                 //matOneID = matOneDefinition.getId();
    40.                 matOneID = 1517;
    41.                 matOneLookup = GrandExchange.lookup(matOneID);
    42.                 if(matOneLookup != null){
    43.                     matOnePrice = (int) (matOneLookup.getPrice() * 1.1);
    44.                     getLogger().info("Found material one price");
    45.                 }
    46.             }
    47.         }
    48.         if(true || (materialTwo = Inventory.newQuery().names(bow.getMaterialTwo()).results().first()) != null){
    49.             //matTwoDefinition = materialTwo.getDefinition();
    50.             if(true || matTwoDefinition != null){
    51.                 //matTwoID = matTwoDefinition.getId();
    52.                 matTwoID = 946;
    53.                 matTwoLookup = GrandExchange.lookup(matTwoID);
    54.                 if(matTwoLookup != null){
    55.                     matTwoPrice = (int) (matTwoLookup.getPrice() * 1.1);
    56.                     getLogger().info("Found material two price");
    57.                 }
    58.             }
    59.         }
    60.         if(true || (finishedProduct = Inventory.newQuery().names(bow.getProduct()).results().first()) != null){
    61.             //productDefinition = finishedProduct.getDefinition();
    62.             if(true || productDefinition != null){
    63.                 //finishedProductID = productDefinition.getId();
    64.                 finishedProductID = 62;
    65.                 productLookup = GrandExchange.lookup(finishedProductID);
    66.                 if(productLookup != null) {
    67.                     productPrice = (int) (productLookup.getPrice() * .85);
    68.                     getLogger().info("Found product price");
    69.                 }
    70.             }
    71.         }
    72.         if(Inventory.contains(bow.getProduct()) || Inventory.getQuantity("Coins") > 10000) {
    73.             getLogger().info("We have product or coins");
    74.             if (GrandExchange.isOpen()) {
    75.                 getLogger().info("GE is open");
    76.                 if (Inventory.containsAllOf(bow.getMaterialOne(), bow.getMaterialTwo())) {
    77.                     getLogger().warn("Pretend GE is being closed");
    78.                 } else if (Inventory.contains(bow.getProduct()) && productPrice != 0){
    79.                     getLogger().info("Buying product");
    80.                     GrandExchange.placeSellOffer(bow.getProduct(), 2314, productPrice);
    81.                 } else if (!GrandExchange.newQuery().sellOffers().itemNames(bow.getProduct()).completed().results().isEmpty()){
    82.                     getLogger().info("Product purchased");
    83.                     GrandExchange.collectToInventory();
    84.                 } else if (!Inventory.contains(bow.getMaterialOne()) && GrandExchange.newQuery().buyOffers().itemNames(bow.getMaterialOne()).results().isEmpty()){
    85.                     getLogger().info("Buying "+bow.getMaterialOne());
    86.                     GrandExchange.placeBuyOffer(bow.getMaterialOne(), 1000, matOnePrice);
    87.                 } else if (!GrandExchange.newQuery().buyOffers().itemNames(bow.getMaterialOne()).completed().results().isEmpty()){
    88.                     getLogger().info(bow.getMaterialOne()+" purchased");
    89.                     GrandExchange.collectToInventory();
    90.                 } else if (!Inventory.contains(bow.getMaterialTwo()) && GrandExchange.newQuery().buyOffers().itemNames(bow.getMaterialTwo()).results().isEmpty()){
    91.                     getLogger().info("Buying "+bow.getMaterialTwo());
    92.                     GrandExchange.placeBuyOffer(bow.getMaterialTwo(), 1, matTwoPrice);
    93.                 } else if (!GrandExchange.newQuery().buyOffers().itemNames(bow.getMaterialTwo()).completed().results().isEmpty()){
    94.                     getLogger().info(bow.getMaterialTwo()+" purchased");
    95.                     GrandExchange.collectToInventory();
    96.                 }
    97.             } else {
    98.                 if(Bank.isOpen()){
    99.                     getLogger().info("Closing bank to use GE");
    100.                     Bank.close();
    101.                 } else {
    102.                     getLogger().info("Opening GE");
    103.                     GrandExchange.open();
    104.                 }
    105.             }
    106.         } else {
    107.             getLogger().info("Looking for "+bow.getProduct()+" to sell and Coins in the bank.");
    108.             if(Bank.isOpen()){
    109.                 if(Bank.getWithdrawMode().equals(Bank.WithdrawMode.NOTE)){
    110.                     if(Bank.contains(bow.getProduct())){
    111.                         getLogger().info("Withdrawing product");
    112.                         Bank.withdraw(bow.getProduct(), 0);
    113.                     } else if (Bank.contains("Coins")){
    114.                         getLogger().info("Withdrawing coins");
    115.                         toWithdraw = (int) (Bank.getQuantity("Coins") * .75);
    116.                         Bank.withdraw("Coins", toWithdraw);
    117.                     } else if (Inventory.contains(bow.getProduct()) || (Inventory.getQuantity("Coins") > Bank.getQuantity("Coins"))) {
    118.                         getLogger().info("Closing bank");
    119.                         Bank.close();
    120.                     } else {
    121.                         getLogger().severe("We couldn't find "+bow.getProduct()+"s.  Stopping bot.");
    122.                         stop();
    123.                     }
    124.                 } else {
    125.                     Bank.setWithdrawMode(Bank.WithdrawMode.NOTE);
    126.                 }
    127.             } else {
    128.                 LocatableEntity banker = Banks.newQuery().results().nearest();
    129.                 if(banker != null && banker.isVisible()){
    130.                     getLogger().info("Opening bank");
    131.                     Bank.open();
    132.                 } else {
    133.                     if(banker != null){
    134.                         Camera.turnTo(banker);
    135.                     }
    136.                 }
    137.             }
    138.         }
    139.     }
    140. }
    141.  
    @Party
    --- Double Post Merged, Jun 16, 2017, Original Post Date: Jun 14, 2017 ---
    @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 (Text):
    1.    private static boolean configureValuesAndConfirm(int quantity, int price) {
    2.                 if (quantityButton == null || !quantityButton.interact("Enter quantity") || !Execution.delayUntil(EnterAmountDialog::isOpen, 1200)) {
    3.                     return false;
    4.                 }
    5.  
    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 (Text):
    1.     private static InterfaceComponent getTextEntryComponent() {
    2.         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)
    3.                 .containers(Environment.isRS3() ? RS3_WIDGET : OSRS_WIDGET).results().first();
    4.     }
    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 (Text):
    1.     public static boolean open() {
    2.         return open(Npcs.newQuery().names("Grand Exchange clerk").actions("Exchange").visible().results().nearest(), "Exchange");
    3.     }
    4.  
    5.     public static boolean open(String action) {
    6.         return open(Npcs.newQuery().names("Grand Exchange clerk").actions("Exchange").visible().results().nearest(), action);
    7.     }
    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
     
    Boot likes this.
  2. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
  3. Snufalufugus

    Joined:
    Aug 23, 2015
    Messages:
    1,961
    Likes Received:
    757
    @Party correct price still not recognized, quantities over 999 still not recognized
    --- Double Post Merged, Jun 24, 2017, Original Post Date: Jun 24, 2017 ---
    To clarify, problems 1 and 2 are solved. Problems 3 and 4 remain.
    --- Double Post Merged, Jul 2, 2017 ---
    UPDATE 7/2/17
    still doesn't recognize quantities over 999
    never recognizes the correct price, regardless of quantity of item
    --- Double Post Merged, Jul 2, 2017 ---
    @Party
    --- Double Post Merged, Jul 13, 2017 ---
    @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.
     

Share This Page

Loading...