import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.*;
import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.event.listeners.PaintListener;
import com.speljohan.rsbot.accessors.NPC;
import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.script.Script;
import com.speljohan.rsbot.script.Calculations;
import com.speljohan.rsbot.script.wrappers.*;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.plugin.NonPluginClass;
public class DPDraynorWillowChopper extends Script implements PaintListener {
public static int[] tree = { 1308, 5551, 5552, 5553, 8481, 8482,
8483, 8484, 8485, 8486, 8487, 8488 };
public static int bankBooth = 2213;
public static RSTile treeTile = new RSTile(3086, 3234);
public static RSTile bankTile = new RSTile(3092, 3245);
public final String[] treeNames = {"Willow"};
public RSTile lumbTile = new RSTile(3223, 3218);
public RSTile[] lumbToDraynorBankPath = {
new RSTile(3222, 3219), new RSTile(3232, 3224), new RSTile(3227, 3234), new RSTile(3222, 3244), new RSTile(3211, 3246), new RSTile(3200, 3247), new RSTile(3189, 3246), new RSTile(3178, 3243), new RSTile(3168, 3238), new RSTile(3157, 3236), new RSTile(3146, 3232), new RSTile(3136, 3227), new RSTile(3125, 3227), new RSTile(3114, 3228), new RSTile(3108, 3238), new RSTile(3103, 3248),
new RSTile(3092, 3245)};
public String getName() {
return "Dontpanic's Draynor Willow Chopper";
}
public double getVersion() {
return 2.0;
}
public String getAuthor() {
return "Dontpanic -
[email protected]";
}
public boolean onStart(String[] args) {
Bot.getEventManager( ).addListener(PaintListener.class, this);
return(true);
}
public void onFinish() {
Bot.getEventManager().removeListener(PaintListener.class, this);
}
public DPDraynorWillowChopper() {
setParameters();
}
private void setParameters() {
super.setParameter("category", "Dontpanic Scripts");
super.setParameter("name", "Dontpanic's Draynor Willow Chopper");
super.setParameter("author", "Dontpanic -
[email protected]");
super.setParameter("version", 2.0);
String desc = super.getScriptDescription();
super.setParameter("description", "<h1>Dontpanic's Draynor Willow Chopper</h1><p>Start anywhere with your axe equipped or in your inventory.</p>");
}
boolean wasMoving = false;
int loads = 0;
public void onRepaint(Graphics g) {
g.setColor(Color.YELLOW);
g.drawString("Dontpanic's Draynor Willow Chopper", 260, 20);
g.drawString("Loads: " + loads, 260, 38);
}
boolean cameraMoving = false;
public int loop() {
if(!isLoggedIn()) {
return random(100,200);
}
if(checkSpinningView()) {
return random(200, 300);
}
if(checkCamera()) {
return random(500, 800);
}
if(getMyPlayer().isMoving()) {
return random(150, 200);
}
if(checkLumb()) {
return random(800, 1000);
}
int checkLostResult = checkLost();
if(checkLostResult > -1) {
return checkLostResult;
}
if(checkAttack()) {
return random(800, 1000);
}
if(checkEnt()) {
return random(800, 1000);
}
if(getMyPlayer().getAnimation() != -1) {
return random(150, 200);
}
if(getInventoryCount() != 28) {
return doChop();
} else {
return doBank();
}
}
public int doChop() {
if(distanceTo(treeTile) > 10) {
walkTileMM(treeTile);
return random(800, 1000);
}
if(wasMoving) {
wasMoving = false;
return random(500, 700);
}
if(clickTree()) {
return random(800, 1000);
} else {
if(distanceTo(treeTile) > 10) {
walkTileMM(treeTile);
return random(800, 1000);
} else {
return random(100, 200);
}
}
}
public boolean checkCamera() {
if(cameraMoving) {
if(Bot.getClient().getCameraCurveY() >= 380) {
Bot.getInputManager().releaseKey((char) KeyEvent.VK_UP);
cameraMoving = false;
}
return true;
} else if (Bot.getClient().getCameraCurveY() < 380) {
Bot.getInputManager().pressKey((char) KeyEvent.VK_UP);
cameraMoving = true;
return true;
}
return false;
}
public boolean clickTree() {
RSObject object = findObject(tree);
/*if (object == null || Calculations.tileToScreen(object.getLocation()).getX() == -1) {
return false;
}
Point point = new Point((int) Calculations.tileToScreen(object.getLocation()).getX() + random(0,5), (int) Calculations.tileToScreen(object.getLocation()).getY() - random(32, 33));
moveMouse(point);
clickMouse(point, true);
wasMoving = true;*/
if(object == null || distanceTo(object.getLocation()) > 16) {
return false;
}
if(atTile(object.getLocation(), "Chop")) {
wasMoving = true;
return true;
}
if(distanceTo(object.getLocation()) > 3) {
return dpWalkTile(object.getLocation());
}
spinView();
return false;
}
public int doBank() {
if(distanceTo(bankTile) > 3) {
walkTileMM(bankTile);
setRun(true);
return random(800, 1000);
}
if(RSInterface.getInterface(INTERFACE_BANK).isValid()) {
bank.depositAllExcept(1349, 1351, 1353, 1355, 1357, 1359, 6739);
loads ++;
return random(100, 500);
} else {
RSObject object = findObject(bankBooth);
atObject(object, "uickly");
return random(500,600);
}
}
public boolean checkEnt() {
int count = Bot.getClient().getNPCCount();
NPC[] npcs = Bot.getClient().getNPCArray();
int[] ints = Bot.getClient().getNPCIndexArray();
for (int i = 0; i < count; i++)
{
RSNPC npc = new RSNPC(npcs[ints
]);
if(getMyPlayer().getInteracting() != null && getMyPlayer().getInteracting().equals(npc) && Arrays.asList(treeNames).contains(npc.getName())) {
if(!clickTree()) {
walkTileMM(treeTile);
}
return true;
}
}
return false;
}
public boolean checkAttack() {
if(getMyPlayer().isInCombat()) {
if(distanceTo(bankTile) > 3) {
walkTileMM(bankTile);
} else {
walkTileMM(treeTile);
}
return true;
} else {
return false;
}
}
/*boolean attacked = false;
int attHP = -1;
public boolean checkAttack() {
int maxHP = skills.getLvlByExp(skills.getCurrentSkillExp(3));
int curHP = skills.getCurrentSkillLevel(3);
if(curHP < maxHP) {
if(attacked) {
if(curHP > attHP) {
attHP = curHP;
}
if(curHP >= attHP) {
return false;
} else {
attacked = false;
}
}
if(!attacked) {
if(distanceTo(bankTile) > 3) {
walkTileMM(bankTile);
} else {
walkTileMM(treeTile);
}
attHP = -1;
attacked = true;
return true;
}
} else {
if(attacked) {
attacked = false;
}
if(attHP != -1) {
attHP = -1;
}
}
return false;
}*/
public void spinView() {
Bot.getInputManager().pressKey((char) KeyEvent.VK_RIGHT);
spinningView = true;
}
boolean spinningView = false;
public boolean checkSpinningView() {
if(spinningView) {
Bot.getInputManager().releaseKey((char) KeyEvent.VK_RIGHT);
spinningView = false;
return true;
} else {
return false;
}
}
public boolean dpWalkPath(RSTile[] path) {
for(int i = path.length - 1; i >= 0; i--) {
if(dpWalkTile(path)) {
return true;
}
}
return false;
}
public boolean dpWalkTile(RSTile tile) {
if(distanceTo(tile) <= 16) {
walkTileMM(tile);
return true;
} else {
return false;
}
}
public boolean checkLumb() {
if(distanceTo(lumbTile) < 20) {
dpWalkPath(lumbToDraynorBankPath);
return true;
}
return false;
}
boolean lostTriedWalk = false;
public int checkLost() {
if(homeTeled) {
homeTeled = false;
if(getMyPlayer().getAnimation() != -1) {
return random(11000,12000);
}
}
if((distanceTo(treeTile) > 10) && (distanceTo(bankTile)>5)) {
if(!lostTriedWalk) {
lostTriedWalk = true;
walkTileMM(treeTile);
return random(800, 1000);
}
lostTriedWalk = false;
homeTele();
return random(3000, 4000);
} else if(lostTriedWalk) {
lostTriedWalk = false;
}
return -1;
}
boolean homeTeled = false;
public void homeTele() {
openTab(Script.TAB_MAGIC);
castSpell(1);
homeTeled = true;
}
}