ruinmaster56
Newcomer
- Joined
- Feb 15, 2009
- Sythe Gold
- 0
- Messages
- 1
can anyone make me a barbarian outpost willow cutter and dropper? please
import java.awt.*;
import java.util.Map;
import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.script.Skills;
import com.speljohan.rsbot.script.wrappers.RSPlayer;
import com.speljohan.rsbot.script.Bank;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;
import com.speljohan.rsbot.event.listeners.PaintListener;
public class barbWillow extends Script implements PaintListener {
public void onRepaint(Graphics g)
{
if(isLoggedIn()) {
int Xbox = 227;
int Ybox = 345;
int Xprint = Xbox + 5;
int Yprint = Ybox + 15;
long millis = System.currentTimeMillis() - startTime1;
long hours = millis / (1000 * 60 * 60);
millis -= hours * (1000 * 60 * 60);
long minutes = millis / (1000 * 60);
millis -= minutes * (1000 * 60);
long seconds = millis / 1000;
int XPChange = skills.getCurrentSkillExp(8) - startXP;
int LevelChange = skills.getCurrentSkillLevel(8) - startLevel;
float XPperSec = 0;
float XPperMin = XPperSec*60;
float XPperHour = XPperMin*60;
if ((minutes > 0 || hours > 0 || seconds > 0) && XPChange > 0) {
XPperSec = ((float) XPChange)/(float)(seconds + (minutes*60) + (hours*60*60));
}
g.setColor(Color.red);
g.drawRoundRect(Xbox, Ybox, 270 - 1, 95 - 1,20,20);
g.setColor(new Color(255, 255, 255, 100));
g.fillRoundRect(Xbox + 1, Ybox + 1, 270 - 2, 95 - 2,20,20);
g.setColor(Color.black);
g.drawString("Banked " + Integer.toString(logsBanked) + " Willow Logs", Xprint, Yprint);
g.drawString("Runtime: " + hours + " hours " + minutes + " minutes " + seconds + " seconds.",
Xprint, Yprint+15);
g.drawString("Current: " + skills.getCurrentSkillLevel(8) + " levels and " + skills.getCurrentSkillExp(8) + " exp.", Xprint, Yprint+30);
g.drawString("Gained: " + LevelChange + " levels and " + XPChange + " exp.",
Xprint, Yprint+45);
g.drawString("Found: " + nestsFound + " nests", Xprint, Yprint+60);
g.drawString(skills.getXPToNextLevel(8) + " XP to next level, we are " + skills.getPercentToNextLevel(8) + "% to next level.", Xprint, Yprint+75);
}
}
public static final int WOODCUTTING_STAT = Skills.getStatIndex("Woodcutting");
public boolean FullInv = false;
public int DepoBox = 20228;
private final int[] nestIds = { 5075, 5074, 5073, 5072, 5071, 5070, 7413 };
private final int[] axeIDs = { 1349, 1351, 1353, 1355, 1357, 1359, 1361,
6739 };
public static int[] willowTrees = { 1308, 5551, 5552, 5553, 8481, 8482,
8483, 8484, 8485, 8486, 8487, 8488 };
public static int willowLogs = 1519;
public int logcount;
int startLevel = 0;
int startXP = 0;
public int logsBanked = 0;
int State = 0;
int Door = 20195;
int nestsFound = 0;
int randomRun = random(20, 65);
int checkTime;
long startTime;
long lastCheck;
long startTime1 = System.currentTimeMillis();
public String getName() {
return "Barb Outpost Willow Depositer";
}
public double getVersion() {
return 1.2;
}
@Override
public String getScriptCategory() {
return "WoodCutting";
}
public String getAuthor() {
return "Slayer";
}
public String getScriptDescription() {
return "<html>\n" +
"<head></head>\n" +
"<body>\n" +
"<center>" +
"<h2>" + getName() + "</h2>" +
"</center>\n" +
"<b>Author:</b> " + getAuthor() + "<br />" +
"<b>Version:</b> " + getVersion() + "<br />" +
"<b>Features:</b>" +
"<ul><li>Start at Willows.</li></ul>" +
"<ul><li>No Args!</li></ul>" +
"</body>\n" +
"</html>";
}
public boolean onStart(String[] s) {
logcount = 0;
logsBanked = 0;
startTime1 = System.currentTimeMillis();
if(isLoggedIn()){
startLevel = skills.getCurrentSkillLevel(8);
startXP = skills.getCurrentSkillExp(8);
}
Bot.getEventManager().addListener(PaintListener.class, this);
log("Started Slayer's Outpost Chopper");
return true;
}
public void onFinish() {
Bot.getEventManager().removeListener(PaintListener.class, this);
}
public int loop() {
//log("State: " + State);
try{
switch(State)
{
case 0:
if (ent()) {
walkTileMM(new RSTile(2520 + (random( -1, 2)), 3580 + (random(-1, 2))));
return chop();
}
if (busy()) {
RSItemTile nest = getGroundItemByID(nestIds);
if (nest != null) {
log("Found nest");
atTile(nest, "Take");
nestsFound++;
}
antiBan();
return random(800, 1000);
}
if(distanceTo(new RSTile(2535 + (random( -1, 1)), 3574 + (random(-1, 1)))) < 3) {
State = 2;
return random(750,1000);
}
if (isInventoryFull()){
State = 1;
return random(750,1500);
}
if(distanceTo(new RSTile(2520 + (random( -1, 2)), 3580 + (random(-1, 2)))) > 7) {
State = 3;
return random(750,1000);
}
return chop();
case 1:
return walkToBank();
case 2:
RSObject depositBox = findObject(DepoBox);
if(distanceTo(depositBox.getLocation()) > 5)
{
walkTileMM(depositBox.getLocation());
return random(500,750);
}
if (findObject(DepoBox) != null) {
if (!RSInterface.getInterface(INTERFACE_DEPOSITBOX).isValid()) {
atObject(findObject(DepoBox),"Deposit");
return random(1000, 1250);
}
}
if (RSInterface.getInterface(INTERFACE_DEPOSITBOX).isValid()) {
logsBanked += getInventoryCount(willowLogs);
depositAllDepositBoxExcept(axeIDs);
State++;
}
if(inventoryContains(willowLogs)) { // if your full.
return random(1000, 1250);
}
case 3:
return walkToCuttingSpot();
}
}catch(Exception e){
e.printStackTrace();
}
return random(500, 1000);
}
public int chop() {
RSObject Tree = findClosestObjectInRange(willowTrees, 8);
setCameraAltitude(true);
setCameraRotation(170);
try {
// System.out.println("Tree Location:" + Tree.getLocation().getX() +
// " - " + Tree.getLocation().getY());
// System.out.println("My Location:" +
// getMyPlayer().getLocation().getX() + " - " +
// getMyPlayer().getLocation().getY());
// atObject(Tree, "Chop down");
int treeX, treeY;
treeX = (int) Calculations.tileToScreen(Tree.getLocation()).getX();
treeY = (int) Calculations.tileToScreen(Tree.getLocation()).getY();
treeX = treeX + random(10, 20);
treeY = treeY - random(5, 10);
Point t = new Point(treeX, treeY);
moveMouse(t);
clickMouse(true);
State = 0;
} catch (NullPointerException NPE) {
NPE.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
return(random(1000,2000));
}
public int walkToBank() {
if(getMyPlayer().isMoving()) return random(1500,2000);
if (distanceTo(new RSTile(2535 + (random( -1, 1)), 3574 + (random(-1, 1)))) < 7){
wait(random(750,1500));
State++;
return random(750,1500);
} else if (distanceTo(findObject(Door)) <= 30){
walkTileMM(new RSTile(2520 + random(-1,2), 3571 + random(-1,2)));
wait(random(4000,4500));
setCameraRotation(271);
atDoor(findObject(Door), "e", "Open");
wait(random(1500,2000));
} else {
walkTileMM(new RSTile(2535 + (random( -1, 1)), 3574 + (random(-1, 1))));
wait(random(750,1500));
}
return random(500,1500);
}
public int walkToCuttingSpot() {
if(getMyPlayer().isMoving()) return random(1500,2000);
if (distanceTo(new RSTile(2520 + (random( -1, 2)), 3580 + (random(-1, 2)))) < 7){
wait(random(750,1500));
State = 0;
return random(750,1500);
} else if (distanceTo(findObject(Door)) <= 30){
walkTileMM(new RSTile(2523 + random(-1,2), 3571 + random(-1,1)));
wait(random(3000,4000));
setCameraRotation(271);
atDoor(findObject(Door), "e", "Open");
wait(random(1500,2000));
} else {
walkTileMM(new RSTile(2523 + random(-1,2), 3571 + random(-1,1)));
wait(random(750,1250));
walkTileMM(new RSTile(2520 + (random( -1, 2)), 3580 + (random(-1, 2))));
wait(random(750,1500));
}
return random(500,1500);
}
public RSObject findClosestObjectInRange(int IDs[], int range) {
try {
int myX, myY, minX, minY, maxX, maxY, objX, objY;
RSObject temp;
RSObject output = null;
myX = getMyPlayer().getLocation().getX();
myY = getMyPlayer().getLocation().getY();
minX = range * -1;
minY = range * -1;
maxX = range;
maxY = range;
for (int x = minX; x < maxX; x++) {
for (int y = minY; y < maxY; y++) {
objX = myX + x;
objY = myY + y;
temp = getObjectAt(objX, objY);
if (temp == null) {
continue;
}
for (int ID : IDs) {
if (temp.getID() == ID) {
if (output == null) {
output = temp;
} else {
if (distanceTo(temp.getLocation()) < distanceTo(output
.getLocation())) {
output = temp;
}
}
}
}
}
}
return output;
}
catch (Exception e) {
e.printStackTrace();
}
return null;
}
public boolean busy() {
if (getMyPlayer().isInCombat()) {
runAway();
return true;
}
if (getMyPlayer().getAnimation() == 879
|| getMyPlayer().getAnimation() == 875
|| getMyPlayer().getAnimation() == 867
|| getMyPlayer().getAnimation() == 2846) {
return true;
}
if (getMyPlayer().isMoving()) {
return true;
}
return false;
}
public Point getDepositInventoryItemPoint(int invIndex) {
int col = (invIndex % 7);
int row = (invIndex / 7);
int x = 121 + (col * 48);
int y = 85 + (row * 50);
return new Point(x, y);
}
public boolean depositAllDepositBoxExcept(int...items) {
int inventoryCount = getInventoryCount();
for (int off = 0; off < getInventoryArray().length; off++) {
if (getInventoryArray()[off] == -1) {
continue;
}
boolean skip = false;
for (int item: items) {
if (getInventoryArray()[off] == item) {
skip = true;
break;
}
}
if (skip) {
continue;
}
for (int tries = 0; tries < 5; tries++) {
atDepositInventoryItem(getInventoryArray()[off], "Deposit-All");
wait(random(1000, 1500));
if(getInventoryCount() < inventoryCount) {
break;
}
}
if (getInventoryCount() >= inventoryCount) {
// equally, otherwise
// something realy weird
// happend :P
return false;
}
inventoryCount = getInventoryCount();
}
return true;
}
public boolean atDepositInventoryItem(int itemID, String txt) {
if (!interfaceExists(INTERFACE_DEPOSITBOX) || !isLoggedIn()) {
return false;
}
for (int off = 0; off < getInventoryArray().length; off++) {
if (getInventoryArray()[off] == itemID) {
clickMouse(getDepositInventoryItemPoint(off), 3, 3, false);
wait(random(200,300));
return atMenu(txt);
}
}
return false;
}
public boolean runAway() {
RSTile a, b;
a = getMyPlayer().getLocation();
b = new RSTile(a.getX() + 10, a.getY() + 10);
walkTileMM(b);
wait(random(10000, 20000));
walkTileMM(a);
return true;
}
int antiBan() {
int p = Math.round(random(1, 11));
switch (p) {
case 1:
wait(random(1000, 1500));
return( random(500, 750) );
case 2:
int x = random(0, 750);
int y = random(0, 500);
moveMouse(0, 0, x, y);
return( random(1000, 1500) );
case 3:
// Is the current tab the inventory?
if ( getCurrentTab( ) != TAB_INVENTORY ) {
// No, so switch to the inventory tab.
openTab( TAB_INVENTORY );
return( random(500, 750) );
}
else {
// No, so return
return( random(500, 750) );
}
case 4:
int x1 = random(0, 750);
int y1 = random(0, 500);
moveMouse(0, 0, x1, y1);
return( random(1000, 1500) );
case 5:
if ( random(1, 8) == 2 ){
int angle = (getCameraAngle( ) + random(-90, 90));
if ( angle < 0) angle = 0;
if ( angle > 359) angle = 0;
setCameraRotation( angle );
}
return( random(500, 750) );
case 6:
int x2 = random(0, 750);
int y2 = random(0, 500);
moveMouse(0, 0, x2, y2);
return( random(1000, 1500) );
}
return (random(500, 700));
}
public boolean ent() {
RSNPC ent = getNearestNPCByName("Willow");
if (distanceTo(ent) <= 2) {
log("Found Ent changing Tree");
return true;
}
return false;
}
}

