Code:
{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf510
{\fonttbl\f0\fmodern\fcharset0 Courier;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\deftab720
\pard\pardeftab720
\f0\fs24 \cf0 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.script.Script;\
import com.speljohan.rsbot.script.wrappers.*;\
import com.speljohan.rsbot.accessors.NPC;\
\
public class EvilsMagicTreeChopper extends Script implements PaintListener \{\
public double getVersion() \{\
return(0.01);\
\}\
\
public String getName() \{\
return("EvilsMagicTreeChopper");\
\}\
\
public String getAuthor() \{\
return("iamastickperson@hotmail.com");\
\}\
\
public String getScriptCategory() \{\
return("Woodcutting");\
\}\
\
public String getScriptDescription( ) \{\
String html = "";\
\
html += "<html>\\n";\
html += "<body>\\n";\
html += "<h2>" + getName() + " v" + getVersion() + "</h2><br>\\n";\
html += "Author: " + getAuthor() + "<br><br>\\n";\
html += "Start in Seers Village bank with a axe (can be equipped or not)May take a while to load as it will need to make sure it is not in a random event before teleporting home and walking back.";\
//html += "<center>\\n";\
//html += "Arguments:<input type=\\"text\\" name=\\"args\\">\\n";\
//html += "</center>\\n";\
html += "</body>\\n";\
html += "</html\\n";\
\
return(html);\
\}\
\
public boolean onStart(String[] args) \{\
Bot.getEventManager( ).addListener(PaintListener.class, this);\
\
return(true);\
\}\
\
public void onFinish() \{\
Bot.getEventManager().removeListener(PaintListener.class, this);\
\}\
\
int waitAfterMoving = -1;\
\
int failCount = 0;\
\
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(waitAfterMoving != -1) \{\
int toReturn = waitAfterMoving;\
waitAfterMoving = -1;\
return toReturn;\
\}\
if(checkAttack()) \{\
return random(800, 1000);\
\}\
if(checkEnt()) \{\
return random(800, 1000);\
\}\
if(getMyPlayer().getAnimation() != -1) \{\
return random(150, 200);\
\}\
int result = work();\
if(result != -1) \{\
failCount = 0;\
return result;\
\}\
if(walkBack()) \{\
failCount = 0;\
return random(500, 800);\
\}\
failCount ++;\
if(failCount >= 10) \{\
failCount = 0;\
homeTele();\
return random(2000, 3000);\
\}\
return random(1000, 2000);\
\}\
\
public boolean checkEnt() \{\
if(getMyPlayer().getInteracting() != null) \{\
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[i]]);\
if(getMyPlayer().getInteracting().equals(npc) && Arrays.asList(treeNames).contains(npc.getName())) \{\
if(clickTree() > 0) \{\
walkTileMM(tree1Tile);\
\}\
return true;\
\}\
\}\
\}\
return false;\
\}\
\
boolean cameraMoving = false;\
\
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 checkAttack() \{\
if(getMyPlayer().isInCombat()) \{\
return runFromCombat();\
\} else \{\
return false;\
\}\
\}\
\
public boolean runFromCombat() \{\
if(atBank()) \{\
bankToTrees();\
return true;\
\}\
if(atTrees()) \{\
treesToBank();\
return true;\
\}\
return false;\
\}\
int loads = 0;\
\
public void onRepaint(Graphics g) \{\
g.setColor(Color.YELLOW);\
g.drawString("EvilsMagicTreeChopper", 260, 20);\
g.drawString("Loads: " + loads, 260, 38);\
\}\
\
public int work() \{\
if(getInventoryCount() != 28) \{\
return chop();\
\} else \{\
return bank();\
\}\
\}\
\
public int chop() \{\
if(atTrees()) \{\
int result = clickTree();\
if(result > 0) \{\
if(result == 1) \{\
waitAfterMoving = random(500, 800);\
\}\
return random(500, 800);\
\} else \{\
if(result == -1) \{\
spinView();\
\} else \{\
if(distanceTo(centerTile) > 2) \{\
RSTile rCenterTile = new RSTile(centerTile.getX() + random(-1, 1), centerTile.getY() + random(-1, 1));\
emWalkTile(rCenterTile);\
\}\
\}\
return random(500, 800);\
\}\
\} else \{\
if(bankToTrees()) \{\
return random(500, 800);\
\} else \{\
return -1;\
\}\
\}\
\}\
\
public int bank() \{\
if(atBank()) \{\
if(RSInterface.getInterface(INTERFACE_BANK).isValid()) \{\
bank.depositAllExcept(1349, 1351, 1353, 1355, 1357, 1359, 6739);\
loads ++;\
return random(500, 800);\
\} else \{\
runOn();\
if(distanceTo(bankTile) > 0) \{\
if(emWalkTile(bankTile)) \{\
waitAfterMoving = random(200, 300);\
return random(500, 800);\
\} else \{\
return -1;\
\}\
\} else \{\
if(useBanker()) \{\
return random(500, 800);\
\} else \{\
return -1;\
\}\
\}\
\}\
\} else \{\
if(treesToBank()) \{\
return random(500, 800);\
\} else \{\
return -1;\
\}\
\}\
\}\
\
public boolean useBanker() \{\
RSNPC npc = getNearestNPCByID(bankerID);\
return atNPC(npc, "Bank Banker");\
\}\
\
public boolean atBank() \{\
return distanceTo(bankTile) < 15;\
\}\
\
public boolean bankToTrees() \{\
return emWalkPath(bankToTreesPath);\
\}\
\
public boolean treesToBank() \{\
return emWalkPath(treesToBankPath);\
\}\
\
public boolean atTrees() \{\
return distanceTo(tree1Tile) < 10 || distanceTo(tree2Tile) < 10;\
\}\
\
public int clickTree() \{\
RSObject object = findObject(treeID);\
if(object == null || distanceTo(object.getLocation()) > 16) \{\
return -2;\
\}\
if(atObject(object, "Chop")) \{\
return 1;\
\}\
if(distanceTo(object.getLocation()) > 3) \{\
if(emWalkTile(object.getLocation())) \{\
return 2;\
\}\
\}\
return -1;\
\}\
\
public boolean emWalkPath(RSTile[] path) \{\
for(int I = path.length - 1; I >= 0; I--) \{\
if(emWalkTile(path[i])) \{\
return true;\
\}\
\}\
return false;\
\}\
\
public boolean emWalkTile(RSTile tile) \{\
if(distanceTo(tile) <= 16) \{\
walkTileMM(tile);\
return true;\
\} else \{\
return false;\
\}\
\}\
\
public void homeTele() \{\
openTab(Script.TAB_MAGIC);\
castSpell(1);\
\}\
\
public boolean walkBack() \{\
return emWalkPath(walkBackPath);\
\}\
\
public void runOn() \{\
setRun(true);\
\}\
\
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;\
\}\
\}\
\
//bank to tree walk\
public RSTile[] bankToTreesPath = \{new RSTile(2727,3493),new RSTile(2724,3476),new RSTile(2721,3458),new RSTile(2710,3443),new RSTile(2702,3427),new RSTile(2698,3424)\};\
\
//tree to bank walk\
public RSTile[] treesToBankPath = \{new RSTile(2708,3435),new RSTile(2715,3447),new RSTile(2724,3461),new RSTile(2722,3474),new RSTile(2727,3474),new RSTile(2727,3482),new RSTile(2727,3493)\};\
\
public int treeID = 1306;\
\
public RSTile tree1Tile = new RSTile(2696, 3423);\
\
public RSTile tree2Tile = new RSTile(2691, 3424);\
\
public RSTile tree3Tile = new RSTile(2690, 3426);\
\
public int bankerID = 495;\
\
public RSTile bankTile = new RSTile(2727, 3494);\
\
public RSTile centerTile = new RSTile(2731, 3491);\
\
public final String[] treeNames = \{"Magic"\};\
\
//The one hell of a death and home teleport walk D:, my hand started to hurt after typing this.\
public RSTile[] walkBackPath = \{new RSTile(3222,3216),new RSTile(3227,3234),new RSTile(3218,3251),new RSTile(3199,3246),new RSTile(3162,3240),new RSTile(3143,3234),new RSTile(3127,3222),new RSTile(3113,3224),new RSTile(3102,3240),new RSTile(3103,3259),new RSTile(3105,3272),new RSTile(3097,3286),new RSTile(3078,3282),new RSTile(3062,3275),new RSTile(3042,3272),new RSTile(3024,3276),new RSTile(3010,3281),new RSTile(3007,3294),new RSTile(3008,3312),new RSTile(3006,3344),new RSTile(3001,3356),new RSTile(2998,3363),new RSTile(2989,3371),new RSTile(2974,3379),new RSTile(2965,3394),new RSTile(2961,3410),new RSTile(2951,3422),new RSTile(2946,3434),new RSTile(2939,3451),new RSTile(2924,3449),new RSTile(2918,3433),new RSTile(2908,3419),new RSTile(2891,3422),new RSTile(2875,3429),new RSTile(2866,3455),new RSTile(2858,3466),new RSTile(2856,3480),new RSTile(2862,3494),new RSTile(2855,3509),new RSTile(2841,3507),new RSTile(2851,3496),new RSTile(2848,3479),new RSTile(2843,3468),new RSTile(2844,3459),new RSTile(2853,3445),new RSTile(2842,3432),new RSTile(2829,3438),new RSTile(2812,3436),new RSTile(2797,3433),new RSTile(2784,3442),new RSTile(2778,3447),new RSTile(2773,3454),new RSTile(2763,3466),new RSTile(2759,3471),new RSTile(2750,3474),new RSTile(2742,3476),new RSTile(2727,2484),new RSTile(2725,3491),new RSTile(2726,3493)\};\
\
\}\
}