Created
March 26, 2024 12:45
-
-
Save chsami/bd78308c951bb4c21f8394e5267998c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Tile getTile(WorldPoint point) { | |
LocalPoint a = LocalPoint.fromWorld(Microbot.getClient(), point); | |
if (a == null) { | |
return null; | |
} | |
return Microbot.getClient().getScene().getTiles()[point.getPlane()][a.getSceneX()][a.getSceneY()]; | |
} | |
public static boolean isDoorPresent(WorldPoint a, WorldPoint b) { | |
WallObject wallObject = getTile(a).getWallObject(); | |
if (wallObject != null) { | |
ObjectComposition objectComposition = Microbot.getClientThread().runOnClientThread(() -> Microbot.getClient().getObjectDefinition(wallObject.getId())); | |
if (objectComposition == null) { | |
return false; | |
} | |
boolean found = false; | |
for (String action : objectComposition.getActions()) { | |
if (action != null && action.equals("Open")) { | |
found = true; | |
break; | |
} | |
} | |
if (!found) { | |
return false; | |
} | |
int orientation = wallObject.getOrientationA(); | |
if (orientation == 1) { | |
//blocks west | |
if (a.dx(-1).equals(b)) { | |
return true; | |
} | |
} | |
if (orientation == 4) { | |
//blocks east | |
if (a.dx(+1).equals(b)) { | |
return true; | |
} | |
} | |
if (orientation == 2) { | |
//blocks north | |
if (a.dy(1).equals(b)) { | |
return true; | |
} | |
} | |
if (orientation == 8) { | |
//blocks south | |
return a.dy(-1).equals(b); | |
} | |
} | |
WallObject wallObjectb = getTile(b).getWallObject(); | |
if (wallObjectb == null) { | |
return false; | |
} | |
ObjectComposition objectCompositionb = Microbot.getClientThread().runOnClientThread(() -> Microbot.getClient().getObjectDefinition(wallObjectb.getId())); | |
if (objectCompositionb == null) { | |
return false; | |
} | |
boolean foundb = false; | |
for (String action : objectCompositionb.getActions()) { | |
if (action != null && action.equals("Open")) { | |
foundb = true; | |
break; | |
} | |
} | |
if (!foundb) { | |
return false; | |
} | |
int orientationb = wallObjectb.getOrientationA(); | |
if (orientationb == 1) { | |
//blocks east | |
if (b.dx(-1).equals(a)) { | |
return true; | |
} | |
} | |
if (orientationb == 4) { | |
//blocks south | |
if (b.dx(+1).equals(a)) { | |
return true; | |
} | |
} | |
if (orientationb == 2) { | |
//blocks south | |
if (b.dy(+1).equals(a)) { | |
return true; | |
} | |
} | |
if (orientationb == 8) { | |
//blocks north | |
return b.dy(-1).equals(a); | |
} | |
return false; | |
} | |
//usage for testing purpose | |
//this code will check if the there is a door between the current player location and -1 on the x | |
boolean isDoored = CollisionMap.isDoorPresent(CollisionMap.getTile(Microbot.getClient().getLocalPlayer().getWorldLocation()), | |
CollisionMap.getTile(new WorldPoint( | |
Microbot.getClient().getLocalPlayer().getWorldLocation().getX() - 1, | |
Microbot.getClient().getLocalPlayer().getWorldLocation().getY(), | |
Microbot.getClient().getLocalPlayer().getWorldLocation().getPlane()))); | |
if (isDoored) { | |
System.out.println("is doored"); | |
WallObject wallObject = CollisionMap.getTile(Microbot.getClient().getLocalPlayer().getWorldLocation()).getWallObject(); | |
if(wallObject == null){ | |
wallObject = CollisionMap.getTile(new WorldPoint( | |
Microbot.getClient().getLocalPlayer().getWorldLocation().getX() - 1, | |
Microbot.getClient().getLocalPlayer().getWorldLocation().getY(), | |
Microbot.getClient().getLocalPlayer().getWorldLocation().getPlane())).getWallObject(); | |
} | |
Rs2GameObject.interact(wallObject); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment