ULTIMATE GUIDE

LoG iN

ULTIMATE GUIDE


    RuskisRangeGuild

    Share

    Turk4life321
    Admin

    Posts : 41
    Join date : 2009-08-09
    Location : In Saims Room *cough*

    RuskisRangeGuild

    Post  Turk4life321 on Fri Jan 01, 2010 4:54 am

    import java.awt.Point;
    import java.util.Map;

    import org.rsbot.bot.Bot;
    import org.rsbot.event.events.ServerMessageEvent;
    import org.rsbot.event.listeners.ServerMessageListener;
    import org.rsbot.script.Calculations;
    import org.rsbot.script.Script;
    import org.rsbot.script.ScriptManifest;
    import org.rsbot.script.wrappers.RSInterface;
    import org.rsbot.script.wrappers.RSInterfaceChild;
    import org.rsbot.script.wrappers.RSNPC;
    import org.rsbot.script.wrappers.RSTile;



    @ScriptManifest(authors = { "Ruski, Defmenow" }, category = "Combat", name = "RangeGuild", version = 25.2)
    public class RuskisRangeGuild extends Script implements ServerMessageListener {

    @Override
    public int loop() {
    if (RSInterface.getInterface(SCORE_INTERFACE).isValid()) {
    arrowsToShoot--;
    closeScoreInterface();
    return random(700, 1300);
    }

    int openInterface = getOpenInterface();
    switch (openInterface) {
    case 64:
    clickContinue();
    return random(520, 1120);
    case 230:
    if (interfaceContainsText(openInterface, "Sure")) {
    atInterface(230, NEWGAMECHOICE_ID);
    return random(520, 1230);
    }
    break;
    case 241:
    if (interfaceContainsText(openInterface, RULEREMINDER)) {
    arrowsToShoot = 10;
    clickContinue();
    return random(420, 810);
    }
    if (interfaceContainsText(openInterface, COINSWANTED)) {
    arrowsToShoot = 10;
    clickContinue();
    return random(712, 1325);
    }
    if (interfaceContainsText(openInterface, NOARROWS)) {
    if(getInventoryCount(BRONZE_ARROW_ID) > 0) {
    atInventoryItem(BRONZE_ARROW_ID, "Wield");
    return random(712, 1623);
    } else {
    log("no arrows");
    return -1;
    }
    }
    break;
    case 242:
    if (interfaceContainsText(openInterface, FINISHEDGAME)) {
    arrowsToShoot = 0;
    clickContinue();
    return random(610, 1120);
    }
    if (interfaceContainsText(openInterface, GAMENOTSTARTED)) {
    arrowsToShoot = 0;
    clickContinue();
    return random(580, 920);
    }
    if (interfaceContainsText(openInterface, NEWGAME)) {
    arrowsToShoot = 0;
    clickContinue();
    return random(712, 1325);
    }
    break;
    }

    action = getAction();

    if (getInventoryCount(COIN_ID) < 200) {
    log("Run out of coins");
    action = KILLSCRIPT;
    }

    switch (action) {
    case SHOOT:
    if (distanceTo(MAINTILE) > 6) {
    if (tileOnMap(MAINTILE)) {
    walkTileMM(MAINTILE);
    return random(1500, 2500);
    }
    }
    try {
    Point targetScreen = Calculations.tileToScreen(TARGETTILES[0]);
    if (!pointOnScreen(targetScreen)) {
    setCameraAltitude(false);
    turnToTile(TARGETTILES[0]);
    return random(400, 800);
    } else {
    atTile(TARGETTILES[0], "Fire-at");
    return random(2100, 2900);
    }
    } catch (Exception e) {
    System.out.print("case SHOOT error: " + e);
    }
    return random(300, 600);
    case START:
    RSNPC judge = getNearestNPCByID(JUDGE_ID);
    if (judge != null) {
    if (getMyPlayer().isMoving()) {
    return random(400, 800);
    }
    atNPC(judge, "Talk-to");
    return random(1300, 1900);
    }
    return random(240, 930);
    case KILLSCRIPT:
    log("Killing script....");
    return -1;
    }

    return random(230, 510);
    }

    private int getAction() {
    try {
    if (canReach(MAINTILE, false)) {
    if (arrowsToShoot > 0) {
    return SHOOT;
    } else {
    return START;
    }
    } else {
    log("we are lost");
    return KILLSCRIPT;
    }
    } catch (Exception e) {
    System.out.print("getAction() error: " + e);
    return -1;
    }
    }

    private boolean interfaceContainsText(int face, String text) {
    try {
    RSInterfaceChild[] interfaceChildren = RSInterface.getInterface(face).getChildren();
    for (int a = 0; a < interfaceChildren.length; a++) {
    if (RSInterface.getInterface(face).getChild(a).containsText(text)) {
    return true;
    }
    }
    } catch (Exception e) {
    System.out.print("interfaceContains(String) error: " + e);
    return false;
    }
    return false;
    }

    private int getOpenInterface() {
    try {
    for (int a = 0; a < INTERFACE_IDS.length; a++) {
    if (RSInterface.getInterface(INTERFACE_IDS[a]).isValid()) {
    return INTERFACE_IDS[a];
    }
    }
    } catch (Exception e) {
    System.out.print("isInterfaceOpen() error:" + e);
    return -1;
    }
    return -1;
    }

    private boolean closeScoreInterface() {
    try {
    RSInterface scoreInterface = RSInterface.getInterface(SCORE_INTERFACE);
    if (!scoreInterface.isValid()) {
    return false;
    }
    return atInterface(SCORE_INTERFACE, SCORE_INTERFACE_CLOSE);
    } catch (Exception e) {
    System.out.print("closeScoreInterface() error: " + e);
    return false;
    }
    }

    public String getName() {
    return "RuskisRangeGuild v" + getVersion();
    }

    public String getScriptCategory() {
    return "Ruski/Ranging";
    }

    public String getAuthor() {
    return "Ruski";
    }

    public double getVersion() {
    return 1.0;
    }

    @SuppressWarnings("deprecation")
    public boolean onStart(Map<String, String> args) {
    Bot.getEventManager().addListener(ServerMessageListener.class, this);
    return true;
    }

    public void onFinish() {
    Bot.getEventManager().removeListener(ServerMessageListener.class, this);
    }

    public void serverMessageRecieved(ServerMessageEvent arg) {
    }
    private RSTile MAINTILE = new RSTile(2672, 3418);
    private String RULEREMINDER = "Hello again, do you need reminding of the rules?";
    private String FINISHEDGAME = "Well done";
    private String GAMENOTSTARTED = "Sorry, you may only use targets for the";
    private String NEWGAME = "Hello there, would you";
    private int NEWGAMECHOICE_ID = 2;
    private String COINSWANTED = "Great! That will be 200 coins then please.";
    private String NOARROWS = "I suggest you use the";
    private int SCORE_INTERFACE = 325;
    private int SCORE_INTERFACE_CLOSE = 88;
    private int[] INTERFACE_IDS = {64, 230, 241, 242};
    private final int SHOOT = 0;
    private final int START = 1;
    private final int KILLSCRIPT = 2;
    private int action = -1;
    private int arrowsToShoot = 0;
    private RSTile[] TARGETTILES = {
    new RSTile(2679, 3426)
    };
    private int JUDGE_ID = 693;
    private int BRONZE_ARROW_ID = 882;
    private int TICKET_ID = 1464;
    private int COIN_ID = 995;
    }

      Current date/time is Sat Nov 18, 2017 3:13 pm