Xtra 31 Share Posted June 7, 2020 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 Link to comment Share on other sites More sharing options...
Stoned 52 Share Posted June 7, 2020 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 More sharing options...
wettofu 109 Share Posted June 7, 2020 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 Link to comment Share on other sites More sharing options...
Xtra 31 Author Share Posted June 7, 2020 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 More sharing options...
RetroBot 35 Share Posted June 7, 2020 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 More sharing options...
Xtra 31 Author Share Posted June 7, 2020 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 More sharing options...
NovaGTX 106 Share Posted June 9, 2020 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.