Jump to content

Dialogue help?


igetbanned

Recommended Posts

Trying to make a Range Guild script, but the dialogue seems to be messing up on me. Here's what I have:

                NPC judge = npcs.closestThatContains("Competition Judge");
                if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow"))
                    judge.interact("Talk-to");
                    getDialogues().clickContinue();
                    sleep(1500);
                    getDialogues().selectOption("Sure, I'll give it a go.");
                    sleep(1500);
                    getDialogues().clickContinue();
                    sleep(1000);

It just loops back to "Talk-to" and clicks continue once, then restarts again and talks to the judge. A never ending cycle. I tried removing the if statement and even adding another but it didn't work. Can't test the latter part of my script because I can't even get passed the dialogue portion, lol. Help?

Link to comment
Share on other sites

Trying to make a Range Guild script, but the dialogue seems to be messing up on me. Here's what I have:

                NPC judge = npcs.closestThatContains("Competition Judge");
                if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow"))
                    judge.interact("Talk-to");
                    getDialogues().clickContinue();
                    sleep(1500);
                    getDialogues().selectOption("Sure, I'll give it a go.");
                    sleep(1500);
                    getDialogues().clickContinue();
                    sleep(1000);

It just loops back to "Talk-to" and clicks continue once, then restarts again and talks to the judge. A never ending cycle. I tried removing the if statement and even adding another but it didn't work. Can't test the latter part of my script because I can't even get passed the dialogue portion, lol. Help?

 

you need to change the structure, it isn't a very efficient way of doing it.

 

NPC judge = npcs.closestThatContains("Competition Judge");

         if(judge != null) {
             if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) {
                 if(getDialogues().isPendingContinuation()) {
                     getDialogues().clickContinue();
                     sleep(850);
                 }
                 else if(getDialogues().inDialogue()) {
                      getDialogues().selectOption("Sure, I'll give it a go.");
                      sleep(850);
                 } else {
                      judge.interact("Talk-to");
                 }
            }
         }
Edited by Precise
Link to comment
Share on other sites

Even with that, don't use a static wait time. That's a sure sign of a bot. At least randomize your sleep time.

 

 

 

you need to change the structure, it isn't a very efficient way of doing it.

 

NPC judge = npcs.closestThatContains("Competition Judge");

         if(judge != null) {
             if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) {
                 if(getDialogues().isPendingContinuation()) {
                     getDialogues().clickContinue();
                     sleep(850);
                 }
                 else if(getDialogues().inDialogue()) {
                      getDialogues().selectOption("Sure, I'll give it a go.");
                      sleep(850);
                 } else {
                      judge.interact("Talk-to");
                 }
            }
         }

 

 

Worked, thanks :D Changed to this now, hope I did the sleeping right:

                NPC judge = npcs.closestThatContains("Competition Judge");
                if(judge != null) {
                    if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) {
                        if(getDialogues().isPendingContinuation()) {
                            getDialogues().clickContinue();
                            sleep(MethodProvider.gRandom(400, 850));
                        }
                        else if(getDialogues().inDialogue()) {
                            getDialogues().selectOption("Sure, I'll give it a go.");
                            sleep(MethodProvider.gRandom(400, 850));
                        } else {
                            judge.interact("Talk-to");
                        }
                    }
                }

Might I ask why I always see if (  != null ) in scripts? What is it significant about that condition? Can't it just not be used with the same outcome?

Link to comment
Share on other sites

Worked, thanks biggrin.png Changed to this now, hope I did the sleeping right:

                NPC judge = npcs.closestThatContains("Competition Judge");
                if(judge != null) {
                    if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) {
                        if(getDialogues().isPendingContinuation()) {
                            getDialogues().clickContinue();
                            sleep(MethodProvider.gRandom(400, 850));
                        }
                        else if(getDialogues().inDialogue()) {
                            getDialogues().selectOption("Sure, I'll give it a go.");
                            sleep(MethodProvider.gRandom(400, 850));
                        } else {
                            judge.interact("Talk-to");
                        }
                    }
                }

Might I ask why I always see if (  != null ) in scripts? What is it significant about that condition? Can't it just not be used with the same outcome?

 

well if the NPC isn't there it will return null, and when you invoke the method judge.interact("Talk-to") it will throw a null pointer error.

Link to comment
Share on other sites

well if the NPC isn't there it will return null, and when you invoke the method judge.interact("Talk-to") it will throw a null pointer error.

 

Got it :) I've tried it on my own, and everything runs smooth now except for the part where it has to close the new interface that opens once an arrow is fired. Here's the new code:

                if(judge != null) {
                    if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) {
                        if(getDialogues().isPendingContinuation()) {
                            getDialogues().clickContinue();
                            sleep(MethodProvider.gRandom(400, 850));
                        }
                        else if(getDialogues().inDialogue()) {
                            getDialogues().selectOption("Sure, I'll give it a go.");
                            sleep(MethodProvider.gRandom(400, 850));
                        } else {
                            judge.interact("Talk-to");
                        }
                    }
                }
                while (getInventory().contains("Bronze Arrow")) {
                    getEquipment().equip(EquipmentSlot.ARROWS, "Bronze Arrow");
                }
                while (getEquipment().isWearingItem(EquipmentSlot.ARROWS, "Bronze Arrow")) {
                    Targets.interact("Fire-at");
                    sleep(MethodProvider.gRandom(600, 1250));
                    getInterfaces().closeOpenInterface();
                }

I tried using interfaces, Interfaces, getInterfaces().getOpenInterfaces().close()

 

Anything I could think of. Do I have to create a static variable for the open interface, and add .close() to it or something?

Link to comment
Share on other sites

You could do it several ways:

  1. Interact with the interface child when its parent becomes visible
  2. Close the open interface using the default methods when the interface becomes visible

#2 is the easiest and can be done like so: 

interfaces.closeOpenInterface();

Of course these will both require checks that the interface is visible + not null before interacting with them.

Link to comment
Share on other sites

I added a method in the dialogues class for completing a dialogue with the specified actions, just so it's easier.

 

Might I ask why I always see if (  != null ) in scripts? What is it significant about that condition? Can't it just not be used with the same outcome?

Instance variables don't hold the object itself but instead a pointer to the objects data out on the heap. If that variable is pointing to nothing it will contain a "null" reference and throw NullPointerExceptions if you try to use the object it's pointing (or not, in this case) to. The variable itself just contains an empty pointer.

 

I would recommend reading this: http://osbot.org/forum/topic/47833-java-pass-by-value/

Link to comment
Share on other sites

You could do it several ways:

  1. Interact with the interface child when its parent becomes visible
  2. Close the open interface using the default methods when the interface becomes visible

#2 is the easiest and can be done like so: 

interfaces.closeOpenInterface();

Of course these will both require checks that the interface is visible + not null before interacting with them.

 

Like so?

if (interfaces.getOpenInterface().isVisible() && interfaces.getOpenInterface() != null)
                        interfaces.closeOpenInterface();

Tested and it returns an error :/ I might just try the parent/child method but I'll have to look at the API because I know nothing about that lol

Link to comment
Share on other sites

You shouldn't be relying on static sleeps to get you to the next dialogue. If it takes any longer than 1500ms to the next dialogue, your script will fail. What if the mouse misclicks? What if you're connected to a laggy server? 

 

Eric had mentioned that so I changed the script to be random sleep times smile.png If I did something wrong with the new sleep times please let me know:

         if(judge != null) {
                    if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) {
                        if(getDialogues().isPendingContinuation()) {
                            getDialogues().clickContinue();
                            sleep(MethodProvider.gRandom(400, 850));
                        }
                        else if(getDialogues().inDialogue()) {
                            getDialogues().selectOption("Sure, I'll give it a go.");
                            sleep(MethodProvider.gRandom(400, 850));
                        } else {
                            judge.interact("Talk-to");
                        }
                    }
                }
                while (getInventory().contains("Bronze Arrow")) {
                    getEquipment().equip(EquipmentSlot.ARROWS, "Bronze Arrow");
                }
                while (getEquipment().isWearingItem(EquipmentSlot.ARROWS, "Bronze Arrow")) {
                    Targets.interact("Fire-at");
                    sleep(MethodProvider.gRandom(600, 1250));
                    getInterfaces().closeOpenInterface();
                }

Still getting the interface issue, just sits there when the results of the arrow pop up. Perhaps it's not recognized as an interface? Idk

Edited by igetbanned
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...