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


    LumbridgeFlaxSpinner

    avatar
    Turk4life321
    Admin


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

    LumbridgeFlaxSpinner Empty LumbridgeFlaxSpinner

    Post  Turk4life321 Fri Jan 01, 2010 4:45 am

    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.util.Map;

    import org.rsbot.bot.Bot;
    import org.rsbot.event.listeners.PaintListener;
    import org.rsbot.script.Script;
    import org.rsbot.script.ScriptManifest;
    import org.rsbot.script.wrappers.*;

    @ScriptManifest(authors = { "Marneus901" }, category = "Crafting", name = "Lumbridge Flax Spinner",
    description = "<html><head><style type=\"text/css\"> hr {color: white} p {margin-left: 20px}</style></head><body><center><b><font size=\"4\" color=\"red\">Lumbridge Flax Spinner v0.6</font></b><br></center><center><table border=\"0\"><tr><td colspan=\"2\"><center><font size=\"4\"><b>:: Script Settings ::</b></font><BR><font size=\"2\" color=\"red\">Thanks to Aelin for this script setup screen!</font></center></td></tr><tr><td colspan=\"2\"><hr></td></tr><tr><td><center><tr><td colspan=\"2\"><font size=\"4\" color=\"blue\">Start at Lumbridge Bank.<BR></font></center></td></tr></select></td></tr></center></td></tr><tr><td><b>Logout at randoms? : </b></td><td><input type=\"checkbox\" name=\"randomlog\" value=\"true\"></center></td></tr><tr><td><b>Use Clan Chat AntiBan? : </b></td><td><input type=\"checkbox\" name=\"ccantiban\" value=\"true\"></center></td></tr><tr><td><b>Clan chat name to join : </b><tr><td><center><input type=\"text\" name=\"ccname\" value=\"\"></center><br></table></center></body></html>", version = 0.7)
    public class LumbridgeFlaxSpinner extends Script implements PaintListener{
    public boolean autoUpdate;
    public int currentLevel;
    public int startXP = skills.getCurrentSkillExp(STAT_CRAFTING);
    public float gainedXP=0;
    public int startLevel = skills.getCurrentSkillLevel(STAT_CRAFTING);
    public String botStatus="";
    public long runTime=0;
    public int failCounter=0;
    public int antiBan=0;
    public boolean useCCAntiBan=false;
    public String ccName;
    //---------------------------------------------------
    public RSObject bankObject=null;
    public RSNPC bankerObject=null;
    public boolean randomsLogout=false;
    public int flaxID = 1779;
    public int bowstringID = 1777;
    public int spinAnimID = 1563;
    public RSTile bankTile = new RSTile(3208, 3221);
    public RSTile ladderTile = new RSTile(3205, 3208);
    public RSTile spinWheelTile = new RSTile(3209, 3212);
    public long idleTime;
    public long startIdleTime;
    public long maxIdleTime;
    public int bsCount=0;
    public int newBSCount=0;
    public float flaxSpun=0;
    public boolean Hours=false;
    public boolean Spins=false;
    public int numHours=0;
    public int numSpins=0;
    public int spinningCount=-1;
    public int bs=-1;
    public String STATUS="Loading...";
    private enum State {
    WALKTOSPIN, SPINWHEEL, SPIN, WALKTOBANK, OPENBANK, BANK, LOST, LOGOUT
    }

    public String getName(){return "Lumbridge Flax Spinner";}
    public String getAuthor(){return "Marneus901";}
    public String getScriptCategory(){return "Crafting";}
    public double getVersion(){return 0.7;}
    public boolean isWelcomeButton()
    {
    RSInterface welcomeInterface = RSInterface.getInterface(378);
    if(welcomeInterface.getChild(45).getAbsoluteX() > 20 || (!welcomeInterface.getChild(117).getText().equals("10.1120.190") && !welcomeInterface.getChild(117).getText().equals(""))) {
    log("We still are in Welcome Screen");
    return true;
    } else {
    return false;
    }
    }
    public void onFinish(){
    return;
    }
    public void onRepaint(Graphics g) {
    int X = 305;
    int Y = 5;
    long millis = System.currentTimeMillis() - runTime;
    long hours = millis / (1000 * 60 * 60);
    millis -= hours * (1000 * 60 * 60);
    long minutes = millis / (1000 * 60);
    millis -= minutes * (1000 * 60);
    long seconds = millis / 1000;
    if (isLoggedIn()) {
    currentLevel=skills.getCurrentSkillLevel(STAT_CRAFTING);
    gainedXP=skills.getCurrentSkillExp(STAT_CRAFTING)-startXP;
    g.setColor(new Color(50, 50, 50, 150));
    g.fillRoundRect(X, Y, 210, 155, 20, 20);
    g.setColor(new Color(50, 50, 50, 255));
    g.drawRoundRect(X, Y, 210, 155, 20, 20);
    Y+=15;
    X+=5;
    g.setColor(new Color(238, 238, 224));
    g.drawString(getName() + " v" + getVersion(), X, Y);
    Y+=15;
    g.drawString("Runtime : " + hours + ":" + minutes + ":" + seconds, X, Y);
    if(Hours && numHours>=hours){
    log("Done running.");
    stopScript();
    }
    Y+=15;
    g.drawString("Flax Spun : " + (int)gainedXP/15, X, Y);
    if(Spins && numSpins>=(int)gainedXP/15){
    log("Done spinning.");
    stopScript();
    }
    Y+=15;
    g.drawString("XP Gain : " + (int)gainedXP, X, Y);
    Y+=15;
    g.drawString("XP until level : " + skills.getXPToNextLevel(STAT_CRAFTING), X, Y);
    Y+=6;
    g.setColor(Color.RED);
    g.fill3DRect(X, Y, 200, 10, true);
    Color PERCBAR = new Color((int)(255 - Math.floor(2.55*(double)skills.getPercentToNextLevel(STAT_CRAFTING))), 255, 0, 150);
    g.setColor(PERCBAR);
    g.fill3DRect(X, Y, skills.getPercentToNextLevel(STAT_CRAFTING)*2, 10, true);
    Y+=23;
    g.setColor(new Color(238, 238, 224));
    g.drawString("Levels Gained : " + (skills.getCurrentSkillLevel(STAT_CRAFTING)-startLevel), X, Y);
    Y+=15;
    long aminutes=minutes+(hours*60);
    if(gainedXP>0 && aminutes>0){
    g.drawString("Experience Per Hour : " + (int)((gainedXP*3600)/(((hours*60)*60)+(minutes*60)+seconds)), X, Y);
    Y+=15;
    g.drawString("Spins Per Hour : " + (int)((gainedXP/15*3600)/(((hours*60)*60)+(minutes*60)+seconds)), X, Y);
    }
    Y+=15;
    g.drawString("Status : " + STATUS, X, Y);
    }
    }
    public boolean onStart(Map<String, String> args) {
    runTime=System.currentTimeMillis();
    useCCAntiBan=args.get("ccantiban") != null ? true : false;
    randomsLogout=args.get("randomlog") != null ? true : false;
    if(useCCAntiBan){
    ccName=args.get("ccname");
    if(ccName==null || ccName.length()<1){
    useCCAntiBan=false;
    }
    }
    return true;
    }
    public boolean atMenu(String action){
    if(Bot.getClient().isMenuOpen()){
    for(int i=0;i<getMenuItems().size();++i){
    if(getMenuIndex(action)==i){
    atMenuItem(i);
    return true;
    }
    }
    while(Bot.getClient().isMenuOpen())
    moveMouse(random(-1, 750), random(-1, 500));
    return false;
    }
    return false;
    }
    public void isSpinning(){
    int bs =getInventoryCount(bowstringID);
    int newbs = getInventoryCount(bowstringID);
    for(int i=0;i<30;++i){
    if(getMyPlayer().getAnimation()==spinAnimID ||
    newbs>bs){
    bs=newbs;
    i=0;
    }
    wait(random(100,200));
    newbs = getInventoryCount(bowstringID);
    if(random(0,4)==3){
    antiBan(random(40,60));
    }
    if(RSInterface.getChildInterface(740, 3).isValid())
    atInterface(RSInterface.getChildInterface(740, 3));
    if(getInventoryCount(flaxID)==0)
    return;
    }
    }
    public boolean getSpinCount(){
    boolean rtn=false;
    newBSCount=getInventoryCount(bowstringID);
    if(newBSCount>bsCount){
    flaxSpun=flaxSpun+(newBSCount-bsCount);
    bsCount=newBSCount;
    rtn=true;
    }
    if(bsCount==28 && newBSCount<bsCount)
    bsCount=0;
    return rtn;
    }
    public void joinCC(){
    RSInterfaceChild i = RSInterface.getChildInterface(589, 2);//Hit button
    if(i.containsText("Join")){
    if(getCurrentTab()!=TAB_CLAN)
    openTab(TAB_CLAN);
    wait(random(100,200));
    if (i.isValid()){
    Rectangle pos = i.getArea();
    if (pos.x == -1 || pos.y == -1 || pos.width == -1 || pos.height == -1)
    return;
    moveMouse((int) random(pos.getMinX(), pos.getMaxX()), (int) random(pos.getMinY(), pos.getMaxY()));
    wait(random(100,150));
    clickMouse(true);
    }
    wait(random(200,500));
    i = RSInterface.getChildInterface(752, 4);//Dialog to enter name
    if (i.isValid()){
    input.sendKeys(ccName, true);
    return;
    }
    }
    }/*
    public void openTab(int tab) {
    int id=0;
    if(tab>=0 && tab<=7){
    id = 72+tab;
    }
    else if(tab<=15 && tab>=Cool{
    id = 51+tab;
    }
    else{
    log("Invalid tab number");
    return;
    }
    RSInterfaceChild i = RSInterface.getChildInterface(548, id);
    Point pt = new Point(i.getAbsoluteX()+(i.getWidth()/2), i.getAbsoluteY()+(i.getHeight()/2));
    moveMouse(pt, 10, 10);
    wait(random(100,200));
    clickMouse(true);
    }*/
    public void antiBan(int rand){
    antiBan=random(0,rand);
    if(antiBan<10){
    antiBan=random(1,50);
    if(antiBan<3 && getState()==State.SPIN){
    if(getCurrentTab()!=TAB_STATS){
    openTab(TAB_STATS);
    wait(random(200,250));
    }
    if(random(0,5)>1){
    moveMouse(random(555, 715), random(225, 450));
    wait(random(100,200));
    }
    moveMouse(632, 372, 7, 7);
    wait(random(1000,2000));
    }
    else if(antiBan==38){
    if(getCurrentTab()!=9){
    openTab(9);
    }
    wait(random(1000,2000));
    }
    else if(antiBan==39){
    if(getCurrentTab()!=11){
    openTab(11);
    }
    wait(random(1000,2000));
    }
    else if(antiBan==40){
    setCameraRotation(random(0,359));
    }
    else
    moveMouse(random(-1, 750), random(-1, 500));
    }
    }
    public State getState(){
    if(distanceBetween(getMyPlayer().getLocation(), ladderTile)>20)
    return State.LOGOUT;
    if(getInventoryCount(flaxID)!=0){
    if(getPlane()==2){
    return State.WALKTOSPIN;
    }
    else if(getPlane()==1){
    if(RSInterface.getChildInterface(459, 16).isValid())
    return State.SPIN;
    return State.SPINWHEEL;
    }
    }
    //3209 3213
    else{
    if(getPlane()==2){
    if(bank.isOpen())
    return State.BANK;
    return State.OPENBANK;
    }
    else if(getPlane()==1){
    return State.WALKTOBANK;
    }
    }
    return State.LOST;
    }
    public int loop() {
    if(useCCAntiBan){
    joinCC();
    }

    setCameraAltitude(true);


    if(RSInterface.getChildInterface(740, 3).isValid())
    atInterface(RSInterface.getChildInterface(740, 3));

    switch(getState()){
    case LOGOUT :
    STATUS="Lost or random.";
    if(randomsLogout){
    log.warning("Probably a random dude. Logging out!");
    stopScript();
    }
    break;
    case WALKTOSPIN :
    STATUS="Walking to ladder...";
    spinningCount=-1;
    if(tileOnScreen(ladderTile))
    atTile(ladderTile, "Climb-down");
    else
    if(!getMyPlayer().isMoving())
    walkTileMM(ladderTile, 2, 2);
    wait(random(100,500));
    break;
    case WALKTOBANK :
    STATUS="Walking to ladder...";
    spinningCount=-1;
    RSInterfaceChild i = RSInterface.getChildInterface(459, 16);
    if (i.getAbsoluteX() != -1 && i.getAbsoluteY() != -1)
    if(!getMyPlayer().isMoving())
    walkTileMM(ladderTile, 2, 2);
    if(tileOnScreen(ladderTile))
    atTile(ladderTile, "Climb-up");
    else
    if(!getMyPlayer().isMoving())
    walkTileMM(ladderTile, 2, 2);
    wait(random(100,500));
    break;
    case SPINWHEEL :
    if(tileOnScreen(spinWheelTile)){
    if(spinningCount==-1 || spinningCount>20){
    STATUS="Clicking spinwheel...";
    atTile(spinWheelTile, "Spin");
    }
    else{
    STATUS="Spinning...";
    int newbs = getInventoryCount(bowstringID);
    if(getMyPlayer().getAnimation()==spinAnimID ||
    newbs>bs){
    bs=newbs;
    spinningCount=0;
    }
    if(random(0,4)==3){
    antiBan(random(40,60));
    }
    if(getInventoryCount(flaxID)==0)
    return 10;
    spinningCount++;
    }
    return random(100,200);
    }
    else{
    if(!getMyPlayer().isMoving())
    walkTileMM(new RSTile(3209, 3213), 1, 1);
    spinningCount=-1;
    }
    wait(random(100,500));
    break;
    case OPENBANK :
    STATUS="Opening bank...";
    spinningCount=-1;
    if(tileOnScreen(bankTile))
    atTile(bankTile, "Use-quickly");
    else
    if(!getMyPlayer().isMoving())
    walkTileMM(new RSTile(bankTile.getX()+1, bankTile.getY()-2), 2, 2);
    wait(random(100,500));
    break;
    case SPIN :
    i = RSInterface.getChildInterface(459, 16);
    Rectangle pos = i.getArea();
    if (pos.x == -1 || pos.y == -1 || pos.width == -1 || pos.height == -1)
    return random(50,100);
    moveMouse((int) random(pos.getMinX(), pos.getMaxX()), (int) random(pos.getMinY(), pos.getMaxY()));
    wait(random(100,150));
    clickMouse(false);
    wait(random(100,150));
    atMenu("Make All");
    bs = getInventoryCount(bowstringID);
    spinningCount=0;
    break;
    case BANK :
    spinningCount=-1;
    if(getInventoryCount()>0){
    bank.depositAll();
    for(int k=0;k<20;++k){
    if(getInventoryCount()==0)
    break;
    wait(random(150,200));
    }
    break;
    }
    for (int k=0;getInventoryCount(flaxID)==0 && bank.isOpen() && k < 10; ++k){
    STATUS="Widthdrawing";
    if(bank.getItemByID(flaxID) == null){
    bank.close();
    log("Out of flax!");
    stopScript();
    }
    moveMouse(new Point(52, 108), 5, 5);
    wait(random(50,100));
    clickMouse(false);
    wait(random(100,200));
    atMenu("Withdraw-All");
    for(k=0;k<15;++k){
    if(getInventoryCount(flaxID)>0)
    break;
    wait(random(50, 100));
    }
    }
    break;
    case LOST :
    STATUS="On floor 1.";
    spinningCount=-1;
    if(tileOnScreen(ladderTile))
    atTile(ladderTile, "Climb-up");
    else
    if(tileToMinimap(ladderTile) != new Point(-1,-1))
    if(!getMyPlayer().isMoving())
    walkTileMM(ladderTile, 1, 1);
    else if(randomsLogout){
    log("Lost or at a random. Logging.");
    stopScript();
    }
    wait(random(100,500));
    break;
    default :
    break;
    }
    if(random(0,5)==1)
    moveMouse(random(-1, 750), random(-1, 500));
    return 10;
    }
    }

      Current date/time is Fri Mar 29, 2024 4:18 am