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
  • Quest dialogue


    JagexPlease

    Recommended Posts

    Okay, so I've figured out how to do this. But it's really hacky and pretty inefficient, so I was wondering if someone else has a better suggestion on how to go through dialogue

     

    Basically I have a array with all the possible dialogue options with that character, then it clicks through the dialogue if it can space/click to continue then while options are available a while loop just cycles through and checks if anything in the array matches the dialogue options.

     

    Avert your gaze if you are faint of heart

    int i = 0;
    String[] possibleChoices = {"DIALOGUE TEXT", "MORE DIALOGUE TEXT"};
    
    
    if (!getDialogues().canContinue() && getDialogues().inDialogue()) {
                log("!getDialogues = true");
                while (i < possibleChoices.length) {
                    getDialogues().chooseOption(possibleChoices[i]);
                    log("i = " + i);
                    i++;
                }
                if(i >= possibleChoices.length - 1){
                    i = 0;
                }
            }
    

    I guess I could just hard code it so it just follows a set path of dialogue, but that seems a bit lame.

     

    Any help appreciated, thanks!

     

    EDIT : 

     

    Also is there a way to maybe tell what the bot has selected, so that when a certain option is set I can change a variable to something else

     

    basically

    If(textChosen == "example answer"){
         state = 2;
    }
    
    Link to comment
    Share on other sites

     

    Okay, so I've figured out how to do this. But it's really hacky and pretty inefficient, so I was wondering if someone else has a better suggestion on how to go through dialogue

     

    Basically I have a array with all the possible dialogue options with that character, then it clicks through the dialogue if it can space/click to continue then while options are available a while loop just cycles through and checks if anything in the array matches the dialogue options.

     

    Avert your gaze if you are faint of heart

    int i = 0;
    String[] possibleChoices = {"DIALOGUE TEXT", "MORE DIALOGUE TEXT"};
    
    
    if (!getDialogues().canContinue() && getDialogues().inDialogue()) {
                log("!getDialogues = true");
                while (i < possibleChoices.length) {
                    getDialogues().chooseOption(possibleChoices[i]);
                    log("i = " + i);
                    i++;
                }
                if(i >= possibleChoices.length - 1){
                    i = 0;
                }
            }
    

    I guess I could just hard code it so it just follows a set path of dialogue, but that seems a bit lame.

     

    Any help appreciated, thanks!

     

    EDIT : 

     

    Also is there a way to maybe tell what the bot has selected, so that when a certain option is set I can change a variable to something else

     

    basically

    If(textChosen == "example answer"){
         state = 2;
    }
    

    Ermm you would you want to use .equals() for comparing strings btw. 

     

    Then you would also want to check to make sure that option is available. 

     

    By either converting getDialogues().getOptions() to String and seeing if it contains it, looping through the options, or what I prefer to do is just check if the option index contains a String like so: getDialogues().getOptionIndex(aDialogue) > 0.

     

    Also to check if you can choose an option I would use getDialogues().getOptions() != null instead of using !getDialogues().canContinue().

     

    Furthermore, you can use a break to stop the loop once it chooses the correct option and for readability sake, I would also recommend a for loop over a while loop (doesn't really make much of a difference though).

     

    Then if you're using this for more than one dialogue you can also make a method out of it then just have it either return an int (to sleep) or just have it set as a void. 

    private void dialogueThingy (String[] dialogue){

        //Continue dialogue if should continue

        //Choose option if it should choose an option

    }

     

    Then you can just put a different array when you're talking to a different person or something. 

     

    Now just wait for another scripter to point out a better method*

    Link to comment
    Share on other sites

    I use something like this myself.

    final String[] OPTIONS = {"Hey, you look worried.", "How can I help?", "Yes."};
    
    if (getDialogues().inDialogue() && !getDialogues().continueDialogue()) {
      for(String option : OPTIONS) {
        if (getDialogues().chooseOption(option)) {
          break;
        }
      }
    }
    
    Link to comment
    Share on other sites

    Best achievable with a recursive solution:
     

    public boolean solveDialogue(String... options) {
            if (!getDialogues().inDialogue())
                return true;
            if (getDialogues().canContinue()) {
                return getDialogues().spaceToContinue() && solveDialogue(options);
            }
            for (String option : options) {
                for (String chatOption : getDialogues().getOptions()) {
                    if (option.equals(chatOption)) {
                        return getDialogues().clickOption(option) && solveDialogue(options);
                    }
                }
            }
            return solveDialogue(options);
        }
    

    Use:

    solveDialogue("hey there", "Nah");
    

    This will press enter for regular dialogue and pick the dialogues you left in the parameters when its supposed to do so.

    Should probably put in some sleeping in there though.

    Link to comment
    Share on other sites

    Best achievable with a recursive solution:

     

    public boolean solveDialogue(String... options) {
            if (!getDialogues().inDialogue() || getDialogues().canContinue())
                return true;
            if (getDialogues().canContinue()) {
                return getDialogues().spaceToContinue() && solveDialogue(options);
            }
            for (String option : options) {
                for (String chatOption : getDialogues().getOptions()) {
                    if (option.equals(chatOption)) {
                        return getDialogues().clickOption(option) && solveDialogue(options);
                    }
                }
            }
            return solveDialogue(options);
        }
    

    Use:

    solveDialogue("hey there", "Nah");
    

    This will press enter for regular dialogue and pick the dialogues you left in the parameters when its supposed to do so.

    Should probably put in some sleeping in there though.

    Why not make use of the API's boolean return types (see my post above). No need to loop through the available options and compare if they're the ones you need to click.

    Link to comment
    Share on other sites

    Why not make use of the API's boolean return types (see my post above). No need to loop through the available options and compare if they're the ones you need to click.

     

    It assumes the possibility that he may type a certain option wrong, but you're definitely right xd

    Link to comment
    Share on other sites

    Should probably do a check for isDialogueContinuing(), unfortunately theres no method in dreambot for this.

     

    This also does 1 action per loop, which is how i prefer to do it, but you could put this method in a loop in another method if you want to handle dialogue in 1 call.  You would probably want to change the return values though.  

     

    usage: 

    if(getDialogue.inDialogue()){
       doDialogue(CHOOSE_OPTIONS)
    }
    
        public boolean doDialogue(String ... chooseOptions){
            if(getDialogues().canContinue()){
                getDialogues().continueDialogue();
                return true;
            }
    
            String options[] = getDialogues().getOptions();
    
            if(options == null){
                return false;
            }
    
            for (int i = 0; i < options.length; i++) {
                for (String chooseOption : chooseOptions) {
                    if(options[i].contains(chooseOption)){
                        getDialogues().chooseOption(i+1);
                        return true;
                    }
                }
            }
    
            return false;
        }
    
    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • 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.