Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Goblin Diplomacy Dialog Option Choosing Help


    Xtra
     Share

    Recommended Posts

    Hey,

    Firstly I'd like to say that I began scripting a few days ago, and finding it really rewarding and enjoyable. As a university student studying computer science, this really helps me learn and keeps my interest. 

    Anyways this unfortunately means at times my script code can be less useful than a white crayon on white paper :).

    My problem is that I'm trying to make a script that, at this stage, solves the Goblin Diplomacy dialogues. I've tried doing this all day, different methods, widgets, lamdba statements, and I can't (and don't know) the appropriate methods/api to use.

    I can solve linear dialogue fairly easy, but when it comes to randomised dialogue, I'm not sure how to go about this. This is because the Goblin Diplomacy has 2 sets of options to go through, seemingly at random. One has a set of 3 options (same as in quest guide), another has only 2. 

    I'm also well aware that the below code wont work, but I'm asking for your guidance on how to fix it. Thanks!

                    if (!getQuests().isFinished(FreeQuest.GOBLIN_DIPLOMACY)) {
                        state = "Doing Goblin Diplomacy";
    
                        if (hasGoblinDiplomacyItems()) {
                            dyeGoblinMail();
                        }
                        if (getInventory().contains(286) && getInventory().contains(287) && getInventory().contains(288)) {
    
                            walkToGoblinHall();
                            if (getNpcs().closest("General Bentnoze") != null && getNpcs().closest("General Bentnoze").hasAction("Talk-to")) {
    
                                sleepUntil(() -> getNpcs().closest("General Bentnoze").interact("Talk-to"), 8000);
                                if (sleepUntil(() -> getDialogues().inDialogue(), 8000)) {
    
                                    while (getDialogues().inDialogue() && getDialogues().canContinue()) {
    
                                        sleepUntil(() -> getDialogues().continueDialogue(), 8000);
                                    } if(getDialogues().inDialogue() && !getDialogues().canContinue()) {
    
                                        getDialogues().chooseOption("Do you want me to pick an armour colour for you?");
                                        getDialogues().chooseOption("No he doesn't look fat");
                                    }
                                }
                            }
                        }
                    }


    Edit: I have studied DreamBot's API docs for hours, looked up threads etc, simply ran out of options

    Edited by Xtra
    Link to comment
    Share on other sites

    You could do something like this, not tested at all but might give you an idea:

       if (getNpcs().closest("General Bentnoze") != null && getNpcs().closest("General Bentnoze").hasAction("Talk-to")) {
    
                                sleepUntil(() -> getNpcs().closest("General Bentnoze").interact("Talk-to"), 8000);
                                if (sleepUntil(() -> getDialogues().inDialogue(), 8000)) {
    
                                    if(getDialogues().canContinue()) {
    
                                        sleepUntil(() -> getDialogues().continueDialogue(), 8000);
                                    } 
    								if(!getDialogues().canContinue()) {
    									
                                        getDialogues().chooseOption("Do you want me to pick an armour colour for you?");
    									sleep(200,400);
                                        getDialogues().chooseOption("No he doesn't look fat");
                                    }
                                }
                            }
                        }
                    }

    I'd bin off that while loop and just select the option via a string when !getDialogues.canContinue()

    Link to comment
    Share on other sites

    You could just simply put 

    if (getDialogues().inDialogue()){
                    getDialogues().spaceToContinue();
    		getDialogues().chooseOption("Whatever");
    		getDialogues().chooseOption("Eat my ass");
                } else {
    		generalDude.interact("Talk-to");
    }

    i dunno if people like it that way or whether its messy but i just do it like that :)

    Edited by wettofu
    Link to comment
    Share on other sites

    Thanks for both of your suggestions!  Both were eye-opening and I really appreciate you taking the time to help.

    Due to being confused about how the dialogue is random, I think the error was in my logic and if statements, and the order of them. It would break the case with the current code if not using a while loop.

    @wettofu that code worked really well, and was just what I was looking for. No complicated expressions, just simple elegant code.
     

    Link to comment
    Share on other sites

    if (script.getDialogues().inDialogue()) {
                if (script.getDialogues().canContinue()) {
                    Main.state = "Space to continue";
                    if(script.getDialogues().spaceToContinue()) {
                        script.sleep(Calculations.random(1500,2000));
                    }
                } else {
                    if (!script.getDialogues().canContinue() && script.getDialogues().getOptions().length > 0) {
                        for (String x : chatOptions) {
                            if (script.getDialogues().chooseOption(x)) {
                                Main.state = "Selecting dialogue " + x;
                                script.sleep(700, 800);
                            }
                        }
                    }
                }
            }

     

    I just use a String array with all options i'll need for dialogue on each part of a quest and have it loop through each option until it finds it in the correct dialogue.

    Link to comment
    Share on other sites

    1 hour ago, RetroBot said:
    if (script.getDialogues().inDialogue()) {
                if (script.getDialogues().canContinue()) {
                    Main.state = "Space to continue";
                    if(script.getDialogues().spaceToContinue()) {
                        script.sleep(Calculations.random(1500,2000));
                    }
                } else {
                    if (!script.getDialogues().canContinue() && script.getDialogues().getOptions().length > 0) {
                        for (String x : chatOptions) {
                            if (script.getDialogues().chooseOption(x)) {
                                Main.state = "Selecting dialogue " + x;
                                script.sleep(700, 800);
                            }
                        }
                    }
                }
            }

     

    I just use a String array with all options i'll need for dialogue on each part of a quest and have it loop through each option until it finds it in the correct dialogue.

    Thanks! This is great :)

    Link to comment
    Share on other sites

    I suggest looking into a script structure rather than a bunch of nested if statements. getDialogue() is always useful.
    Here's a link to a post I've referenced for people new to scripting.

     

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.