Jump to content

Door Handler


Recommended Posts

Posted (edited)

According to the API I can check if an entity is reachable: https://osbot.org/api/org/osbot/rs07/api/DoorHandler.html#canReachOrOpen-org.osbot.rs07.api.model.Entity-

However the following always returns true even if it should return false:

NPC juliet = script.npcs.closest("Juliet");
log(getDoorHandler().canReachOrOpen(juliet.getPosition()));

 

Edited by harrypotter
Posted (edited)
22 minutes ago, harrypotter said:

According to the API I can check if an entity is reachable: https://osbot.org/api/org/osbot/rs07/api/DoorHandler.html#canReachOrOpen-org.osbot.rs07.api.model.Entity-

However the following always returns true even if it should return false:


NPC juliet = script.npcs.closest("Juliet");
log(getDoorHandler().canReachOrOpen(juliet));

 

Juliet isn't a door though?

I'd do something like this:

if (julietArea.contains(myPlayer()) {
	RS2Object door = getObjects.closest("Door");
	if (door != null && door.hasAction("Open")) {
		door.interact("Open");
	}
	
	// then rest of code to interact with the NPC "Juliet"

}

EDIT: julietArea being the area you are in when wanting to interact with Juliet. Use @Explv 's dope map to find the area for it by going up a floor (https://explv.github.io/).

Edited by Magarac
Posted (edited)
19 minutes ago, Magarac said:

Juliet isn't a door though?

I'd do something like this:


if (julietArea.contains(myPlayer()) {
	RS2Object door = getObjects.closest("Door");
	if (door != null && door.hasAction("Open")) {
		door.interact("Open");
	}
	
	// then rest of code to interact with the NPC "Juliet"

}

EDIT: julietArea being the area you are in when wanting to interact with Juliet. Use @Explv 's dope map to find the area for it by going up a floor (https://explv.github.io/).

Sorry my snippet should read: 

NPC juliet = script.npcs.closest("Juliet");
log(getDoorHandler().canReachOrOpen(juliet.getPosition()));

This still returns true for the position, even if behind a door.

Edited by harrypotter
  • Like 1
Posted
3 minutes ago, harrypotter said:

Sorry my snippet should read: 


NPC juliet = script.npcs.closest("Juliet");
log(getDoorHandler().canReachOrOpen(juliet.getPosition()));

This still returns true for the area, even if behind a door.

Hmm I'm not exactly sure why it's returning true, other than the fact that (reach || open) might be working like an OR statement does and since it CAN open the door it returns true always. Try doing the door check like I posted, cause doors always have either a "Open" or "Close" option.

  • Like 1
Posted
2 minutes ago, Magarac said:

Hmm I'm not exactly sure why it's returning true, other than the fact that (reach || open) might be working like an OR statement does and since it CAN open the door it returns true always. Try doing the door check like I posted, cause doors always have either a "Open" or "Close" option.

You could be right, flew straight over my head the naming there haha!

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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