Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • isFacing & getTilePlayerIsFacing


    Soldtodie

    Recommended Posts


    public enum Rotation {

    NORTH(1024, new Tile(0, 1)),
    EAST(1536, new Tile(1, 0)),
    SOUTH(0, new Tile(0, -1)),
    WEST(512, new Tile(-1, 0)),
    NORTH_EAST(1280, new Tile(1, 1)),
    SOUTH_EAST(1792, new Tile(1, -1)),
    SOUTH_WEST(256, new Tile(-1, -1)),
    NORTH_WEST(768, new Tile(-1, 1));

    private int rotation;
    private Tile direction;

    Rotation(int rotation, Tile direction) {
    this.rotation = rotation;
    this.direction = direction;
    }

    public int getRotation() {
    return this.rotation;
    }

    public Tile getDirection() {
    return this.direction;
    }

    }


    public Tile getTilePlayerIsFacing(Player player, boolean onlyCardinal) {

    if(player != null) {
    Rotation rot = getRotation(player.getRotation(), onlyCardinal ? 4 : 8);
    if(rot != null) {
    return player.getTile().translate(rot.getDirection());
    }
    }

    return null;
    }

    public Rotation getRotation(int rotation, int loop) {
    for(int i = 0; i < loop; i++) {
    if(Math.abs(Rotation.values()[i].getRotation() - rotation) <= 128) {
    return Rotation.values()[i];
    }
    }
    return null;
    }

    public boolean isFacing(Player player, Tile pos, boolean onlyCardinal) {

    if (player != null && pos != null) {
    Rotation rot = getRotation(player.getRotation(), onlyCardinal ? 4 : 8);
    if (rot != null) {
    if (player.getTile().translate(rot.getDirection()).equals(pos)) {
    return true;
    }
    }
    }

    return false;
    }

     

    Link to comment
    Share on other sites

    • 1 month later...

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.