All pastes #1681290 Raw Edit

Miscellany

public text v1 · immutable
#1681290 ·published 2009-11-21 19:52 UTC
rendered paste body
import org.rsbot.script.*;
import org.rsbot.bot.*;
import org.rsbot.script.wrappers.*;
import org.rsbot.event.listeners.*;
import org.rsbot.event.events.*;

@ScriptManifest(authors = { "ToySoldier, Twistedmind" }, category = "Crafting", name = "TnT FlaxPicker", version = 1.00, description = "<html><body bgcolor = Red><font color = Black><center><h2> TnT FlaxPicker v1 :: Made By Toy Soldier & Twistedmind</h2>")
public class TnTFlaxPicker extends Script/* implements PaintListener*/ {
/**********************
*  Variables         *
**********************/
//-----------------------------------------------------
public long startTime = System.currentTimeMillis();
//-----------------------------------------------------
public int flaxPicked = 0;
//-----------------------------------------------------

public RSTile[] bankToFlax = new RSTile[] {
new RSTile(2725, 3491), new RSTile(2726, 3478), new RSTile(2728, 3465),
new RSTile(2728, 3455), new RSTile(2733, 3443), new RSTile(2738, 3443)
};

//------------------------------------------------------
public RSTile[] flaxToBank = new RSTile[] { 
new RSTile(2738, 3443), new RSTile(2733, 3443), new RSTile(2728, 3455),
new RSTile(2728, 3465), new RSTile(2726, 3478), new RSTile(2725, 3491)
};

//-------------------------------------------------------
public int BankBoothID = 25808;
//-------------------------------------------------------
public int FlaxID = 2646;
//-------------------------------------------------------
public boolean atBank(){

RSObject bank = getNearestObjectByID(BankBoothID);
if (bank == null){
return false;
}
return tileOnScreen(bank.getLocation());
};
//--------------------------------------------------------
public boolean atFlax(){
RSObject flax = getNearestObjectByID(FlaxID);
if(flax == null){
return false;
}
return tileOnScreen(flax.getLocation());
};
//---------------------------------------------------------
public boolean handleBank(){
RSObject bankBooth = getNearestObjectByID(BankBoothID);
if(bank == null){
return false; //We couldn't find the bank :(
}
if(bank.isOpen()){
bank.depositAll();
bank.close();
} else {
atObject(bankBooth, "Use-Quickly");
}
return true;
};
//---------------------------------------------------------
public boolean walkToBank(){
RSTile[] randomizedPath = randomizePath(flaxToBank, 2, 2);
RSTilePath path = new RSTilePath(randomizedPath, this);
try{
return path.walkToEnd();
} catch (InterruptedException e){
e.printStackTrace();
}
return false;
};
//---------------------------------------------------------
public boolean needToBank(){
return isInventoryFull();
};
//---------------------------------------------------------
public boolean pickFlax(){
RSObject flax = getNearestObjectByID(FlaxID);
if(flax == null){
return false;
}
return atObject(flax, "Pick");
};
//---------------------------------------------------------
public boolean walkToFlax(){
RSTile[] randomizedPath = randomizePath(bankToFlax, 2, 2);
RSTilePath path = new RSTilePath(randomizedPath, this);
try {
return path.walkToEnd();
} catch (InterruptedException e) {
e.printStackTrace();
}
return false;
};
//---------------------------------------------------------
public boolean moving(){
return getMyPlayer().isMoving();
}
//---------------------------------------------------------
/*********************
*        GUI        *
*********************/
 
public boolean onStart(){
//No GUI here, just a timer for the Paint :)
startTime = System.currentTimeMillis();
return false;
}
 
//--------------------------------------------------------
 
 
/*********************
*       Paint       *
*********************/
/*  
public void onRepaint(Graphics g){
if(isLoggedIn()) {
//---------Timer--------------------
long millis = System.currentTimeMillis() - startTime;
long hours = millis / (1000 * 60 * 60);
millis -= hours * (1000 * 60 * 60);
long minutes = millis / (1000 * 60);
millis -= minutes / (1000 * 60);
long seconds = millis / 1000;
long minutes2 = minutes + (hours * 60); <- Commented for now
g.setColor(Color.WHITE);
g.drawString("Time running:",x,y);
g.drawString(hours + ":" + minutes + ":" + seconds);
}
}
*/  
//--------------------------------------------------------
/*********************
*   Loop            *
*********************/

public int loop(){
if(moving()) return random(500,1000);
if(needToBank()){
if(atBank()){
if(handleBank()){
return random(500, 1000);
}
}
else {
if(walkToBank()){
return random(800,1100);
}
//if we walk we wanna stop.
}
} else {
//We dont need to bank inside these brackets
if(atFlax()){
if(pickFlax()){
flaxPicked++;
return random(900,1600);
}
} else{
/* if(walkToFlax()){
return random(800,1100);
*/
walkToFlax();
}
}
return random(500,800);
}
}