Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.rsbot.script.*;
- import org.rsbot.bot.*;
- import org.rsbot.accessors.Model;
- import org.rsbot.accessors.RSAnimable;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.event.listeners.*;
- import org.rsbot.event.events.*;
- import org.rsbot.util.*;
- import org.rsbot.bot.input.*;
- import java.awt.*;
- import java.util.*;
- import java.io.*;
- import java.net.*;
- import javax.swing.*;
- @ScriptManifest(authors = { "Blake" }, category = "Woodcutting", name = "xWillows", version = 1.0, description =
- "<html><body><center><br><font size=6>BNS Scripting xWillows V1.17</font><br><br>" +
- "<br><br> xWillowss is a new script, start in Draynor Village while logged in" +
- " and start the script :)" +
- "Report any bugs to the email, xrealm@live.com" +
- "<br>The script is in BETA")
- public class xWillows extends Script implements PaintListener {
- /* Paint variables */
- private int startLevel;
- private String status = "";
- public int levelsgained;
- public int startexp;
- public int nextlvl;
- public int exp;
- public int logsChopped;
- public int logperhour;
- public int expGained;
- public int chopped;
- public float expsec;
- public float expmin;
- public int axetype;
- public float exphour;
- public long timeRunning = 0, seconds = 0 ,minutes = 0, hours = 0;
- public long startTime = System.currentTimeMillis();
- /* EOF */
- /* anti ban fixes */
- public int pchatoff = 0;
- public int cameralow = 0;
- public boolean check = true;
- /* EOF */
- /* id's */
- public RSTile firstTree = new RSTile(3087, 3237);
- int Clicks = 0;
- public int[] axes = { 1359, 1349, 1351, 1353, 1355, 1357, 1361, 6739, 13661 };
- public int willowTree[] = { 5551, 5553, 5552 };
- public int bankID = 2213;
- public RSTile[] Banktile = { new RSTile(3094, 3241), new RSTile(3094, 3243) };
- public RSTile Banks = new RSTile(3094, 3243);
- public RSTile Trees = new RSTile(3087, 3233);
- public RSTile willowTile = new RSTile(3087, 3233);
- public int wcanim = 867;
- /* EOF */
- final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
- public boolean onStart(Map<String, String> args) {
- startTime = System.currentTimeMillis();
- startLevel = skills.getCurrentSkillLevel(STAT_WOODCUTTING);
- logsChopped = 0;
- pchatoff = 0;
- cameralow = 0;
- if (startLevel == 0) {
- startLevel = skills.getCurrentSkillLevel(Constants.STAT_WOODCUTTING);
- }
- return true;
- }
- public RSObject getClosestTreeByID(final int... ids) {
- RSObject cur = null;
- double dist = -1;
- for (int x = 0; x < 104; x++) {
- outer: for (int y = 0; y < 104; y++) {
- final RSObject o = getObjectAt(x + Bot.getClient().getBaseX(),
- y + Bot.getClient().getBaseY());
- if (o != null) {
- boolean isObject = false;
- for (final int id : ids) {
- if (o.getID() == id) {
- isObject = true;
- break;
- }
- }
- if (isObject) {
- final RSObject tl = getObjectAt(x
- + Bot.getClient().getBaseX() - 1, y
- + Bot.getClient().getBaseY());
- final RSObject tb = getObjectAt(x
- + Bot.getClient().getBaseX(), y
- + Bot.getClient().getBaseY() - 1);
- final int id = o.getID();
- if (tl != null && tl.getID() == id || tb != null
- && tb.getID() == id) {
- continue outer;
- }
- final double distTmp = calculateDistance(getMyPlayer()
- .getLocation(), o.getLocation());
- if (cur == null || distTmp < dist) {
- dist = distTmp;
- cur = o;
- }
- }
- }
- }
- }
- return cur;
- }
- boolean clickTree(RSObject obj1,String action) {
- if (!(obj1.getObject() instanceof RSAnimable)) {
- return atTree(obj1, action);
- }
- RSAnimable anim = (RSAnimable) obj1.getObject();
- Model model = obj1.getModel();
- int index = random(0, model.getXPoints().length);
- int xoff = model.getXPoints()[index];
- int yoff = model.getZPoints()[index];
- int zoff = model.getYPoints()[index];
- final Point p = Calculations.worldToScreen(anim.getX() + xoff, anim
- .getY()
- + zoff, -yoff);
- if (p.x == -1)
- return false;
- while (getMyPlayer().isMoving()) {
- wait(random(20,120));
- }
- moveMouse(getModelPoint(obj1), 3, 3);
- return atMenu(action);
- }
- private Point getModelPoint(RSObject obj) {
- Model model = obj.getModel();
- RSAnimable animable = (RSAnimable) obj.getObject();
- Point[] screenCoords = new Point[model.getXPoints().length];
- for (int i = 0; i < screenCoords.length; i++) {
- int x = model.getXPoints()[i] + animable.getX();
- int z = model.getZPoints()[i] + animable.getY();
- int y = model.getYPoints()[i]
- + Calculations.tileHeight(animable.getX(), animable.getY());
- screenCoords[i] = Calculations.w2s(x, y, z);
- }
- return screenCoords[random(0, screenCoords.length)];
- }
- public boolean openBank() {
- walkPathMM(Banktile, 1, 1);
- RSObject bank = findObject(bankID);
- if (bank == null) {
- turnToObject(bank);
- return false;
- }
- if (bank != null) {
- turnToObject(bank);
- atObject(bank, "Use-quickly");
- return true;
- }
- return true;
- }
- public boolean depositLogs() {
- bank.depositAllExcept(axes);
- bank.close();
- walkTileMM(willowTile, 1, 1);
- return true;
- }
- public int loop() {
- RSObject tree = getClosestTreeByID(willowTree);
- try {
- if (cameralow == 0) {
- setCameraAltitude(true);
- cameralow = 1;
- }
- if (pchatoff == 0) {
- setPrivateChat(CHAT_MODE.OFF);
- pchatoff = 1;
- }//switch world int world switchWorld
- // public boolean walkPathMM(RSTile[] path, int maxDist, int randX, int randY)
- //public static int distanceBetween(RSTile t1, RSTile t2)
- if (getEnergy() > random(30, 60)) {
- setRun(true);
- }
- if (getMyPlayer().isMoving()) {
- return random(500, 700);
- }
- if(getMyPlayer().getAnimation() == wcanim){
- status = "Chopping";
- return random(400, 600);
- }
- if (distanceTo(Trees) > 7 && !isInventoryFull()) {
- status = "Banking";
- walkPathMM(randomizePath(generateProperPath(Trees),2,2));
- return random(100, 200);
- }
- if (distanceTo(Banks) > 6 && isInventoryFull()) {
- walkPathMM(randomizePath(generateProperPath(Banks),2,2));
- if (!bank.isOpen()) {
- openBank();
- }
- if (bank.isOpen()) {
- depositLogs();
- }
- return random(100, 200);
- }
- if(distanceTo(firstTree) > 70) {
- walkPathMM(randomizePath(generateProperPath(firstTree),2,2));
- wait(random(500,1000));
- Clicks++;
- if(Clicks++ >= 10000){
- log("You have clicked 10000 times and you are still not where you want to be!");
- wait(random(500000, 1000000));
- }
- }
- if (getMyPlayer().isInCombat()) {
- log("Player in combat!!");
- walkPathMM(Banktile, 1, 1);
- return random(150, 220);
- }
- if (isInventoryFull()) {
- status = "Banking";
- if (!bank.isOpen()) {
- openBank();
- }
- if (bank.isOpen()) {
- depositLogs();
- return random(700, 900);
- }
- return random(700, 900);
- }
- if (tree == null) {
- status = "Looking for tree";
- turnToObject(tree);
- } else {
- clickTree(tree, "Chop down");
- return random(300, 500);
- }
- clickTree(tree, "Chop down");
- return random(300, 500);
- } catch (Exception e) {
- return random(300, 500);
- }
- }
- /* Paint */
- public void onRepaint(Graphics g) {
- Mouse m = Bot.getClient().getMouse();
- if (isLoggedIn()) {
- if ( startexp == 0) {
- startexp = skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING);
- }
- nextlvl = skills.getCurrentSkillLevel(Constants.STAT_WOODCUTTING) + 1;
- final int fill = (int) (.8 * (double) nextlvl);
- expGained = skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING) - startexp;
- levelsgained = skills.getCurrentSkillLevel(Constants.STAT_WOODCUTTING) - startLevel;
- timeRunning = System.currentTimeMillis() - startTime;
- seconds = timeRunning / 1000;
- logsChopped = expGained/68;
- if (seconds >= 60) {
- minutes = seconds / 60;
- seconds -= minutes * 60;
- }
- if (minutes >= 60) {
- hours = minutes / 60;
- minutes -= hours * 60;
- }
- if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0) {
- expsec = ((float) expGained)/(float)(seconds + (minutes*60) + (hours*60*60));
- }
- expmin = expsec * 60;
- exphour = expmin * 60;
- /* body and text for paint */
- g.setColor(new Color(0, 0, 0, 175));
- g.fillRoundRect(1, 62, 125, 230, 10, 10);
- g.setColor(Color.WHITE);
- g.drawString("BnS Scripts xWillows", 5, 77);
- g.drawString("Version: 1", 5, 95);
- g.drawString("Run Time: " + hours + ":" + minutes + ":" + seconds, 5, 132);
- g.drawString("Status: "+status+"", 5, 159);
- g.drawString("XP/Hour: "+ exphour +"" , 5, 174);
- g.drawString("Levels Gained: "+levelsgained+"", 5, 201);
- g.drawString("XP Gained: "+ expGained +"", 5, 216);
- g.setColor(new Color(0, 0, 0));
- g.fillRoundRect(5, 219, 80, 230, 9, 9);
- g.setColor(new Color(0, 255, 0));
- g.fillRoundRect(5, 219, (skills.getPercentToNextLevel(STAT_WOODCUTTING) * 80 / 100), 230, 9, 9);
- g.setColor(Color.red);
- g.drawString(Integer.toString(nextlvl) + "%", 5, 231);
- g.setColor(Color.magenta);
- g.drawRect(5, 219, 80, 13);
- g.setColor(Color.white);
- g.drawString("Logs chopped: "+ logsChopped +"", 5, 258);
- }
- }
- /* random tab */
- private void openRandomTab() {
- int randomNumber = random(1, 13);
- if (randomNumber <= 13) {
- if (randomNumber == 1 && !(getCurrentTab() == TAB_STATS)) {
- openTab(TAB_STATS);
- }
- if (randomNumber == 2 && !(getCurrentTab() == TAB_ATTACK)) {
- openTab(TAB_ATTACK);
- }
- if (randomNumber == 3 && !(getCurrentTab() == TAB_EQUIPMENT)) {
- openTab(TAB_EQUIPMENT);
- }
- if (randomNumber == 4 && !(getCurrentTab() == TAB_FRIENDS)) {
- openTab(TAB_FRIENDS);
- }
- if (randomNumber == 6 && !(getCurrentTab() == TAB_MAGIC)) {
- openTab(TAB_MAGIC);
- }
- if (randomNumber == 7 && !(getCurrentTab() == TAB_NOTES)) {
- openTab(TAB_NOTES);
- }
- if (randomNumber == 8 && !(getCurrentTab() == TAB_OPTIONS)) {
- openTab(TAB_OPTIONS);
- }
- if (randomNumber == 9 && (getCurrentTab() == TAB_PRAYER)) {
- openTab(TAB_PRAYER);
- }
- if (randomNumber == 10 && !(getCurrentTab() == TAB_IGNORE)) {
- openTab(TAB_IGNORE);
- }
- if (randomNumber == 11 && !(getCurrentTab() == TAB_CLAN)) {
- openTab(TAB_CLAN);
- }
- if (randomNumber == 12 && !(getCurrentTab() == TAB_INVENTORY)) {
- openTab(TAB_INVENTORY);
- }
- if (randomNumber == 13 && !(getCurrentTab() == TAB_MUSIC)) {
- openTab(TAB_MUSIC);
- }
- }
- }
- /* antiban */
- public void antiban() {
- int randomNumber = random(1, 3);
- if (randomNumber <= 3) {
- if (randomNumber == 1) {
- openRandomTab();
- wait(random(100, 500));
- moveMouse(631, 254, random(60, 200));
- wait(random(1300, 2200));
- }
- if (randomNumber == 2) {
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- wait(random(200, 700));
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- }
- if (randomNumber == 3) {
- wait(random(100, 200));
- setCameraRotation(random(1,360));
- wait(random(100, 200));
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement