Jump to content

NMZ bot super laggy when it goes into NMZ


csvernon

Recommended Posts

Hello everyone, this is my first script.  It will probably look terrible to an experienced eye.  Currently it checks if it needs to bank, starts the previous dream, enters NMZ, kills Elvarg, loots his bones, leaves, and does it all again.  I'm running into the issue that NMZ is very laggy, script wont respond to user input, has high CPU and Memory usage.  Any advise is welcome! :)


                case FIGHT:
                {
                    target = npcs.closest("Elvarg");
                    target.interact("Attack");
                    sleep(random(2500, 4800));
                    new ConditionalSleep(4000, 500) {
                        @Override
                        public boolean condition() throws InterruptedException {
                            return myPlayer().isUnderAttack();
                        }
                          }.sleep();

Edited by csvernon
Link to comment
Share on other sites

Error in Script executor!

java.lang.NullPointerException

                           at main.onLoop(Main.jva:85)

                           at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ro:134)

                           at java.lang.Thread.run(Unknown Source)

 

seems to happen right after I turn on prayers to fight elvarg, so my script 

  target = npcs.closest("Elvarg");
                    target.interact("Attack");

seems busted

28 minutes ago, HunterRS said:

Check the logger, you are probably getting a nullPointer or something.

Check it and post it here :) 

Edited by csvernon
Link to comment
Share on other sites

 

12 minutes ago, csvernon said:

Error in Script executor!

java.lang.NullPointerException

                           at main.onLoop(Main.jva:85)

                           at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ro:134)

                           at java.lang.Thread.run(Unknown Source)

 

seems to happen right after I turn on prayers to fight elvarg, so my script 

  target = npcs.closest("Elvarg");
                    target.interact("Attack");

seems busted

Your problem is that you are not checking if you found the dragon,
change target.interact to:

if(target != null){
    target.interact("Attack");

also, look into conditional sleeps.

Link to comment
Share on other sites

16 minutes ago, csvernon said:

Error in Script executor!

java.lang.NullPointerException

                           at main.onLoop(Main.jva:85)

                           at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ro:134)

                           at java.lang.Thread.run(Unknown Source)

 

seems to happen right after I turn on prayers to fight elvarg, so my script 

  target = npcs.closest("Elvarg");
                    target.interact("Attack");

seems busted

If npcs.closest returns null, and you try to call interact on it, it will throw this error.

Null check it! i.e

target = npcs.closest("Elvarg");
if (target!=null && target.interact("Attack")) {
 // do stuff
}

Also, when you post code, please use the provided code formatting tool in the reply box; so that it's (more) readable. 

There are a host of other improvements that can be made on your code; but soon enough you will find these out when your script misbehaves!

GL!

Apa

  • Like 1
Link to comment
Share on other sites

K, script no longer gets errors, but now it repeatedly attacks elvarg even while in combat, condition sleep isnt working.

Also 

getWalking().walk(new Position(6656, 6912, 1));

hasn't worked at all in NMZ

and when I click on the potion to enter NMZ 

 getObjects().closest("Plinth").interact("Drink");
                    mouse.click(false);

I have to force the mouse to click, if will just go to the object but wont interact.  The object is technically a potion that gains the "Drink" option after the dream is setup but I could only get the mouse to move there when using "Plinth" as the object.

Edited by csvernon
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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