Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.runecrafting.abysscrafter;
- import org.tribot.api.Timing;
- import org.tribot.api2007.Camera;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.NPCChat;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSObject;
- import scripts.methods.Methods;
- public class Ditch {
- private Main main;
- public Ditch(Main main) {
- setMain(main);
- }
- public void setMain(Main main) {
- this.main = main;
- }
- public Main getMain() {
- return main;
- }
- public boolean clickedDitch = false;
- public boolean cross() {
- if(clickedDitch
- //|| Player.getPosition().getY() >= Locations.CROSSED_DITCH_TILE.getY()
- || (Player.getAnimation() == 6132)) {
- //clickedDitch = true;
- return false;
- }
- RSObject ditch = Methods.findObjectByModelPoints(new int[] { Constants.DITCH });
- if(ditch != null) {
- if(!ditch.isOnScreen() && Methods.distanceTo(getMain(), ditch.getPosition()) > 6) {
- WebWalking.walkTo(ditch);
- Camera.turnToTile(ditch);
- }
- int y = Player.getPosition().getY();
- if(ditch.isOnScreen()) {
- if(ditch.click("Cross")) {
- //clickedDitch = true;
- int distance = Methods.distanceTo(getMain(), ditch.getPosition());
- if(crossedDitch(y, distance * 1000)) {
- clickedDitch = true;
- return true;
- }
- }
- } else {
- WebWalking.walkTo(ditch);
- Camera.turnToTile(ditch);
- }
- }
- return false;
- }
- private boolean crossedDitch(int y, int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- if (NPCChat.getMessage() != null) {
- clickedDitch = false;
- return false;
- }
- if (Player.getAnimation() == 6132) {
- //clickedDitch = true;
- return true;
- }
- if (Player.getPosition().getY() > Locations.DITCH_TILE.getY()) {
- return true;
- }
- getMain().sleep(50, 150);
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement