ULTIMATE GUIDE

LoG iN

Join the forum, it's quick and easy

ULTIMATE GUIDE

LoG iN

ULTIMATE GUIDE

Would you like to react to this message? Create an account in a few clicks or log in to continue.

ULTIMATE GUIDE


    Defflaxpicker

    avatar
    Turk4life321
    Admin


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

    Defflaxpicker Empty Defflaxpicker

    Post  Turk4life321 Fri Jan 01, 2010 4:36 am

    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.util.Map;

    import org.rsbot.bot.Bot;
    import org.rsbot.event.events.ServerMessageEvent;
    import org.rsbot.event.listeners.PaintListener;
    import org.rsbot.event.listeners.ServerMessageListener;
    import org.rsbot.script.Script;
    import org.rsbot.script.ScriptManifest;
    import org.rsbot.script.wrappers.RSCharacter;
    import org.rsbot.script.wrappers.RSObject;
    import org.rsbot.script.wrappers.RSTile;

    @ScriptManifest(authors = { "Defmenow, alekz for paint" }, category = "Money", name = "defFlaxPicker", version = 2.0, description = "<html><head></head><body> Start in seers bank with no items in inventory</body></html\n")
    public class defFlaxPicker extends Script implements PaintListener,
    ServerMessageListener {


    public boolean startScript = false;

    public long startTime = System.currentTimeMillis();
    private String status = "";

    int flaxPicked;
    public int waitForAnim = 827;
    public int flaxid = 2646;
    public int bankboothid = 25808;
    private int RunningEnergy = random(15, 80);


    RSTile[] BankPath = { new RSTile(2725, 3485), new RSTile(2728, 3474), new RSTile(2727, 3463), new RSTile(2729, 3453), new RSTile(2733, 3443), new RSTile(2739, 3443) };
    RSTile[] FlaxPath = { new RSTile(2739, 3443), new RSTile(2733, 3443), new RSTile(2729, 3453), new RSTile(2727, 3463), new RSTile(2728, 3474), new RSTile(2725, 3485), new RSTile(2726, 3491) };


    protected int getMouseSpeed() {
    return 6;
    }

    @SuppressWarnings("deprecation")
    public boolean onStart(final Map<String, String> args) {
    startTime = System.currentTimeMillis();
    Bot.getEventManager().addListener(PaintListener.class, this);
    return true;
    }

    public boolean needToBank() {
    return isInventoryFull();
    }

    public boolean atBank() {
    status = "Banking";
    RSObject bank = getNearestObjectByID(bankboothid);
    if(bank == null) return false;
    return tileOnScreen(bank.getLocation());
    }

    public boolean atFlax() {
    status = "At Field";
    RSObject flax = getNearestObjectByID(flaxid);
    if(flax == null) return false;
    return tileOnScreen(flax.getLocation());
    }

    public boolean handleBank() {
    status = "Depositing";
    RSObject bankbooth = getNearestObjectByID(bankboothid);
    if(bank == null)
    return false;
    if(bank.isOpen()){
    bank.depositAll();
    }else{
    atObject(bankbooth, "uickly");
    }
    return true;
    }

    public boolean pickFlax(){
    status = "Picking Flax";
    RSObject flax = getNearestObjectByID(flaxid);
    if(flax == null)
    if(((RSCharacter) getMyPlayer()).getAnimation() != 827)
    return false;

    return atObject(flax, "Pick");
    }

    public boolean walkToFlax(){
    status = "Walking to Flax";
    if (getEnergy() >= RunningEnergy && !isRunning()) {
    setRun(true);
    RunningEnergy = random(15, 30);
    wait(random(400, 500));
    }
    if(!getMyPlayer().isMoving() || distanceTo(getDestination()) <= random(6, Cool)
    {
    walkPathMM(randomizePath(BankPath, 2, 2), 16);
    return false;
    }

    return true;
    }

    public boolean walkToBank(){
    status = "Walking to Bank";
    if (getEnergy() >= RunningEnergy && !isRunning()) {
    setRun(true);
    RunningEnergy = random(15, 30);
    wait(random(400, 500));
    }
    if(!getMyPlayer().isMoving() || distanceTo(getDestination()) <= random(6, Cool)
    {
    walkPathMM(randomizePath(FlaxPath, 2, 2), 16);
    return false;
    }

    return true;
    }

    public boolean flag(int dist){
    if(getMyPlayer().getAnimation() != -1) return false;
    if(distanceTo(getDestination()) <= dist) return true;
    return false;
    }

    public int loop() {
    setCameraAltitude(true);
    if(needToBank()) {
    if(atBank()) {
    if(handleBank())
    return random(800, 1000);
    }else{
    if(flag(random(4, 7))){
    // ready to walk
    if(walkToBank())
    return random(800, 1000);
    }else{
    // no ready to walk
    return random(800, 1000);
    }
    }
    }else{
    if(atFlax()){
    pickFlax();
    return random(800, 1000);
    }else{
    if(flag(random(4, 7))){
    if(walkToFlax())
    return random(800, 1000);
    }else{

    return random(800, 1000);
    }
    }
    }
    return random(200, 400);
    }

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

    public void onRepaint(final Graphics g) {
    if (isLoggedIn()) {
    long millis = System.currentTimeMillis() - startTime;
    long flaxPerHour = 0;
    if (flaxPicked > 0)
    flaxPerHour = flaxPicked * 3600 / (millis / 1000);
    long hours = millis / (1000 * 60 * 60);
    millis -= hours * (1000 * 60 * 60);
    long minutes = millis / (1000 * 60);
    millis -= minutes * (1000 * 60);
    long seconds = millis / 1000;

    g.setColor(new Color(0, 0, 0, 170));
    g.fillRect(382, 372, 117, 87);
    g.setColor(Color.BLACK);
    g.drawRect(382, 372, 117, 87);
    g.setColor(Color.RED);
    int X = 385;
    int Y = 387;
    g.setFont(new Font("Calibri", Font.BOLD, 14));
    g.drawString("defFlaxPicker", X, Y);
    Y += 7;
    g.setColor(Color.WHITE);
    g.drawLine(382, Y, 499, Y);
    g.setColor(Color.WHITE);
    Y += 13;
    g.setFont(new Font("Calibri", Font.BOLD, 12));
    g.drawString("Time running: " + hours + ":" + minutes + ":"
    + seconds + "", X, Y);
    Y += 15;
    g.drawString("Status: " + status , X, Y);
    Y += 15;
    g.drawString("Flax Picked: " + Integer.toString(flaxPicked) + "", X, Y);
    Y += 15;
    g.drawString("Flax Per hour: " +flaxPerHour+ "", X, Y);
    }
    }

    public void serverMessageRecieved(final ServerMessageEvent m) {
    final String message = m.getMessage();
    if (message.contains("You pick some flax")) {
    flaxPicked++;
    }
    }
    }

      Current date/time is Thu Mar 28, 2024 4:42 pm