Jump to content

doorHandler not behaving as expected


ni562

Recommended Posts

Capture.png

 

when I try and leave the room with the spining wheel, doorHandler sometimes clicks the red door..It not a big deal, but it's happening a little tooo often imo. Im wondering how i can stop it from clicking the red door as it't not at all in my path. 

while (!map.canReach(STAIRS.getRandomPosition())) {
 doorHandler.handleNextObstacle(STAIRS);
 ConditionalSleep(10000);
}

I triple checked the coooords for my STAIRS area and the door is not inside the area! 

Edited by ni562
Link to comment
Share on other sites

Capture.png

 

when I try and leave the room with the spining wheel, doorHandler sometimes clicks the red door..It not a big deal, but it's happening a little tooo often imo. Im wondering how i can stop it from clicking the red door as it't not at all in my path. 

while (!map.canReach(STAIRS.getRandomPosition())) {
 doorHandler.handleNextObstacle(STAIRS);
 ConditionalSleep(10000);
}

I triple checked the coooords for my STAIRS area and the door is not inside the area! 

 

 

You could try this as an alternative solution to DoorHandler, you pass the getDoor method an area that contains the door to distinguish it from other doors:

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

public class DoorHelper {

    private final Script S;
    
    public DoorHelper(final Script S){
        
        this.S = S;
    }
    
    public RS2Object getDoor(Area doorArea){

        //noinspection unchecked
        return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
    }

    public boolean doorIsClosed(RS2Object door){

        return door.hasAction("Open");
    }

    public void openDoor(RS2Object door){

        if(door != null && doorIsClosed(door)){

            door.interact("Open");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !doorIsClosed(door);
                }
            }.sleep();
        }
    }
}
Edited by Explv
Link to comment
Share on other sites

 

You could try this as an alternative solution to DoorHandler, you pass the getDoor method an area that contains the door to distinguish it from other doors:

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

public class DoorHelper {

    private final Script S;
    
    public DoorHelper(final Script S){
        
        this.S = S;
    }
    
    public RS2Object getDoor(Area doorArea){

        //noinspection unchecked
        return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
    }

    public boolean doorIsClosed(RS2Object door){

        return door.hasAction("Open");
    }

    public void openDoor(RS2Object door){

        if(door != null && doorIsClosed(door)){

            door.interact("Open");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !doorIsClosed(door);
                }
            }.sleep();
        }
    }
}

 

Wow i'll try that! How can i pass it a Script object? that it the only part i'm unsure about.. 

Link to comment
Share on other sites

 

You could try this as an alternative solution to DoorHandler, you pass the getDoor method an area that contains the door to distinguish it from other doors:

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

public class DoorHelper {

    private final Script S;
    
    public DoorHelper(final Script S){
        
        this.S = S;
    }
    
    public RS2Object getDoor(Area doorArea){

        //noinspection unchecked
        return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
    }

    public boolean doorIsClosed(RS2Object door){

        return door.hasAction("Open");
    }

    public void openDoor(RS2Object door){

        if(door != null && doorIsClosed(door)){

            door.interact("Open");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !doorIsClosed(door);
                }
            }.sleep();
        }
    }
}
public RS2Object getDoor(Area doorArea){

//noinspection unchecked
return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
}

always returns null, any idea why? 

Link to comment
Share on other sites

 

You could try this as an alternative solution to DoorHandler, you pass the getDoor method an area that contains the door to distinguish it from other doors:

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

public class DoorHelper {

    private final Script S;
    
    public DoorHelper(final Script S){
        
        this.S = S;
    }
    
    public RS2Object getDoor(Area doorArea){

        //noinspection unchecked
        return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
    }

    public boolean doorIsClosed(RS2Object door){

        return door.hasAction("Open");
    }

    public void openDoor(RS2Object door){

        if(door != null && doorIsClosed(door)){

            door.interact("Open");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !doorIsClosed(door);
                }
            }.sleep();
        }
    }
}

Why is it that the ConditionalSleep in the openDoor() method seems to always wait the full 5 seconds and not stop the sleep when the door is open like I would expect it to?

Link to comment
Share on other sites

Why is it that the ConditionalSleep in the openDoor() method seems to always wait the full 5 seconds and not stop the sleep when the door is open like I would expect it to?

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

public class DoorHelper {

    private final Script S;
    
    public DoorHelper(final Script S){
        
        this.S = S;
    }
    
    public RS2Object getDoor(Area doorArea){

        //noinspection unchecked
        return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
    }

    public boolean doorIsClosed(RS2Object door){

        return door.hasAction("Open");
    }

    public void openDoor(Area doorArea){

        RS2Object door = getDoor(doorArea);

        if(door != null && doorIsClosed(door)){

            door.interact("Open");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !doorIsClosed(getDoor(doorArea));
                }
            }.sleep();
        }
    }
}
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...