imancity Posted May 10, 2016 Share Posted May 10, 2016 So I followed some Java tutorials and explored a bit more and managed to get my script from earlier to run. Now my problem is that when the player talks to the NPC, he keeps on clicking the NPC (after the random sleep i set) and also keeps clicking the first dialogue button. Is there a way to have him complete on BUY before starting over? First time coding and scripting, I appreciate any help! case BUY: state = "Walking To Karim"; getWalking().walk(kebabstore); npcs.closest("Karim").interact("Talk-to"); sleep(random(300,400)); if (dialogues.isPendingContinuation()) { dialogues.clickContinue();} sleep(random(300,400)); if (dialogues.isPendingOption()) { dialogues.selectOption("Yes please.");} sleep(random(300,400)); break; Quote Link to comment Share on other sites More sharing options...
Explv Posted May 10, 2016 Share Posted May 10, 2016 (edited) So I followed some Java tutorials and explored a bit more and managed to get my script from earlier to run. Now my problem is that when the player talks to the NPC, he keeps on clicking the NPC (after the random sleep i set) and also keeps clicking the first dialogue button. Is there a way to have him complete on BUY before starting over? First time coding and scripting, I appreciate any help! case BUY: state = "Walking To Karim"; getWalking().webWalk(kebabstore); npcs.closest("Karim").interact("Talk-to"); sleep(random(300,400)); if (dialogues.isPendingContinuation()) { dialogues.clickContinue();} sleep(random(300,400)); if (dialogues.isPendingOption()) { dialogues.selectOption("Yes please.");} sleep(random(300,400)); break; case BUY: if(!kebabstore.contains(myPosition()){ getWalking().walk(kebabstore); } else if(!getDialogues().inDialogue()){ npcs.closest("Karim").interact("Talk-to"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getDialogues().inDialogue(); } }.sleep(); } else if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); sleep(random(700, 1000)); } else if (dialogues.isPendingOption()) { dialogues.selectOption("Yes please."); sleep(random(700, 1000)); } break; You only need to perform these actions when certain criteria are satisfied. E.g. you only want to walk to the kebab store if you aren't already there. You only want to talk to Karim if you aren't already in a dialogue etc. Edited May 10, 2016 by Explv 2 Quote Link to comment Share on other sites More sharing options...
imancity Posted May 10, 2016 Author Share Posted May 10, 2016 case BUY: if(!kebabstore.contains(myPosition()){ getWalking().walk(kebabstore); } else if(!getDialogues().inDialogue()){ npcs.closest("Karim").interact("Talk-to"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getDialogues().inDialogue(); } }.sleep(); } else if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); sleep(random(700, 1000)); } else if (dialogues.isPendingOption()) { dialogues.selectOption("Yes please."); sleep(random(700, 1000)); } break; Thanks!! I was thinking to do something like that but didn't know how to word it. Appreciate it. For some reason my code is making the contains red, do I need to import something in the beginning in relation to it? Quote Link to comment Share on other sites More sharing options...
Explv Posted May 10, 2016 Share Posted May 10, 2016 (edited) Thanks!! I was thinking to do something like that but didn't know how to word it. Appreciate it. For some reason my code is making the contains red, do I need to import something in the beginning in relation to it? Sorry I assumed kebabstore was an Area. If you are using a Position, I recommend you change it to this: private final Area kebabstore = new Area(3271, 3179, 3275, 3183); Also change getWalking().walk(kebabstore); To getWalking().webWalk(kebabstore); Edited May 10, 2016 by Explv 1 Quote Link to comment Share on other sites More sharing options...
imancity Posted May 10, 2016 Author Share Posted May 10, 2016 Sorry I assumed kebabstore was an Area. If you are using a Position, I recommend you change it to this: private final Area kebabstore = new Area(3271, 3179, 3275, 3183); Also change getWalking().walk(kebabstore); To getWalking().webWalk(kebabstore); Ohh! I see, that makes sense. So for webWalking do i need Areas? I wanted to use webWalking but couldn't figure it out too well. Quote Link to comment Share on other sites More sharing options...
Explv Posted May 10, 2016 Share Posted May 10, 2016 Ohh! I see, that makes sense. So for webWalking do i need Areas? I wanted to use webWalking but couldn't figure it out too well. No you can use Positions. I only suggested that you use an Area so that you can determine if your player is in the kebab store. That Area consists of all the positions in the kebab store, so by calling the contains method with the player's position, you are effectively saying. "If my player is in the kebab store" 3 Quote Link to comment Share on other sites More sharing options...
GaetanoH Posted May 10, 2016 Share Posted May 10, 2016 No you can use Positions. I only suggested that you use an Area so that you can determine if your player is in the kebab store. That Area consists of all the positions in the kebab store, so by calling the contains method with the player's position, you are effectively saying. "If my player is in the kebab store" The way you explain things really intrigues me, you should teach no joke. 4 Quote Link to comment Share on other sites More sharing options...
Explv Posted May 11, 2016 Share Posted May 11, 2016 The way you explain things really intrigues me, you should teach no joke. Thanks boss, I will make some tutorials in the near future 2 Quote Link to comment Share on other sites More sharing options...
GaetanoH Posted May 11, 2016 Share Posted May 11, 2016 Thanks boss, I will make some tutorials in the near future Ayyy! Quote Link to comment Share on other sites More sharing options...
Chris Posted May 11, 2016 Share Posted May 11, 2016 Thanks boss, I will make some tutorials in the near future if you dont get stuck on transit m8 Quote Link to comment Share on other sites More sharing options...
Glaciation96 Posted October 8, 2018 Share Posted October 8, 2018 (edited) On 5/11/2016 at 11:41 AM, Explv said: Thanks boss, I will make some tutorials in the near future Any plans on making an in-depth dialogue tutorial? Or have you already got one... Also, from what you have shown, would that method also work for getting through dialogue which includes going through multiple dialogue choices? For example, I am trying to get from karamja to port sarim and vice versa, so would the following work? I'm asking as it seems like a list like this is very prone to breaking if something was to happen to just one of the options? ...else if (dialogues.isPendingOption()) { dialogues.selectOption("I have nothing to hide."); sleep(random(700, 1000)); } else if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); sleep(random(700, 1000)); } else if (dialogues.isPendingOption()) { dialogues.selectOption("Second selection in order to board boat."); sleep(random(700, 1000)); } else if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); sleep(random(700, 1000)); } else if (dialogues.isPendingOption()) { dialogues.selectOption("n selection to board boat."); sleep(random(700, 1000)); } else if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); sleep(random(700, 1000)); } break; For context, I'm trying to avoid webwalk just to learn java a little better. Also, is there a way to conditional sleep in between the dialogue options? If so, what would you return? For the next pending continuation as the condition? Thanks! Edited October 8, 2018 by Glaciation96 Quote Link to comment Share on other sites More sharing options...
Ragnar Lothbrok Posted October 8, 2018 Share Posted October 8, 2018 6 hours ago, Glaciation96 said: Any plans on making an in-depth dialogue tutorial? Or have you already got one... Also, from what you have shown, would that method also work for getting through dialogue which includes going through multiple dialogue choices? For example, I am trying to get from karamja to port sarim and vice versa, so would the following work? I'm asking as it seems like a list like this is very prone to breaking if something was to happen to just one of the options? ...else if (dialogues.isPendingOption()) { dialogues.selectOption("I have nothing to hide."); sleep(random(700, 1000)); } else if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); sleep(random(700, 1000)); } else if (dialogues.isPendingOption()) { dialogues.selectOption("Second selection in order to board boat."); sleep(random(700, 1000)); } else if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); sleep(random(700, 1000)); } else if (dialogues.isPendingOption()) { dialogues.selectOption("n selection to board boat."); sleep(random(700, 1000)); } else if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); sleep(random(700, 1000)); } break; For context, I'm trying to avoid webwalk just to learn java a little better. Also, is there a way to conditional sleep in between the dialogue options? If so, what would you return? For the next pending continuation as the condition? Thanks! You can use the completeDialog() method. if (!dialogues.inDialog()) { // Talk to npc } else { if (dialogues.completeDialog("answer 1", "answer2")) { // sleep !dialogues.inDialog() } } I just wrote this up quickly so there may be some typos but you should get the general idea. 2 Quote Link to comment Share on other sites More sharing options...
Glaciation96 Posted October 9, 2018 Share Posted October 9, 2018 17 hours ago, Ragnar Lothbrok said: You can use the completeDialog() method. if (!dialogues.inDialog()) { // Talk to npc } else { if (dialogues.completeDialog("answer 1", "answer2")) { // sleep !dialogues.inDialog() } } I just wrote this up quickly so there may be some typos but you should get the general idea. Thanks for the response. I tried to implement this but not sure if it's well off the mark or not. Regardless, any chance of someone giving feedback on how well this would work? I'd really appreciate it! Spoiler public void talkToSeamen() throws InterruptedException { Entity sailor = npcs.closest("Seaman Thresnor", "Seaman Lorris", "Captain Tobias"); if (sailor != null && !dialogues.inDialogue()) { if (sailor.interact("Talk to")) { new ConditionalSleep(9000, (int) (Math.random() * 436 + 247)) { @Override public boolean condition() throws InterruptedException { return getDialogues().inDialogue(); } }.sleep(); } } else { if (dialogues.completeDialogue("SeamenOption")) { new ConditionalSleep(9000, (int) (Math.random() * 436 + 247)) { @Override public boolean condition() throws InterruptedException { return !getDialogues().inDialogue(); } }.sleep(); } } new ConditionalSleep(9000, (int) (Math.random() * 436 + 247)) { @Override public boolean condition() throws InterruptedException { return boatAtKaramja.contains(myPosition()) && gangplank !=null; } }.sleep(); sleep(random(1500,2500)); //Is this needed? Boat anim could play over character who's already at gangplank! if(boatAtKaramja.contains(myPosition()) && gangplank !=null) { gangplank.interact("Cross"); new ConditionalSleep(9000, (int) (Math.random() * 436 + 247)) { @Override public boolean condition() throws InterruptedException { return !myPlayer().isAnimating() && KaramHarbour.contains(myPosition()); } }.sleep(); } } Thanks! Quote Link to comment Share on other sites More sharing options...
Ragnar Lothbrok Posted October 9, 2018 Share Posted October 9, 2018 if (dialogues.completeDialogue("SeamenOption")) { new ConditionalSleep(9000, (int) (Math.random() * 436 + 247)) { @Override public boolean condition() throws InterruptedException { return !getDialogues().inDialogue(); } }.sleep(); } This wont work as I assume the option from the dialog isn't "SeamenOption" - this needs to match the String they offer exactly. You know WebWalking takes care of this all for you? Area karamjaDocks = new Area(2943, 3149, 2947, 3145); if (!karamjaDocks.contains(myPosition)) { getWalking.webWalk(karamjaDocks); } else { // We are on Karamja } Quote Link to comment Share on other sites More sharing options...