rendered paste bodyimport java.awt.*;
import java.util.*;
import java.util.Map;
import com.speljohan.rsbot.event.events.ServerMessageEvent;
import com.speljohan.rsbot.event.listeners.PaintListener;
import com.speljohan.rsbot.event.listeners.ServerMessageListener;
import com.speljohan.rsbot.accessors.Player;
import com.speljohan.rsbot.bot.*;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;
import com.speljohan.rsbot.script.Methods;
import com.speljohan.rsbot.accessors.*;
public class original extends Script implements PaintListener { //Opens Script
public String getName() {
return "Original Runecrafter and Yew Woodcutter";}
public String getNotes(){
return "Start At Trees!";}
public String getAuthor() {
return "xyz123abc";}
public double getVersion() {
return 1.0;}
public String getScriptCategory() {
return "Runecrafting";}
public String getScriptDescription() { //Opens Description
String html = "<html>";
html += "<body>";
html += "<center>";
html += "<b><font size=\"5\" color=\"red\">" + getName() + " v" + getVersion() + "</font></b>";
html += "<br></br>";
html += "<font size=\"4\" color=\"black\">by xyz123abc<br></b></font>";
html += "<br></br>";
html += "<font size=\"3\" color=\"black\"><b> </b>Select Location:</b></font>";
html += "<hr></hr>";
html += "<select name='Rune'>";
html += "<option>Earth Runes<option>Air Runes</select>";
html += "<hr></hr>";
html += "<tr><td colspan=2><b><font size=\"3\">   Enjoy!. </font></b></td><td colspan=\"2\" align=right>"
+ getVersion() + "   </td></tr></table>";
html += "</center></body>";
html += "</html>";
return (html);
} //Closes Description
// ONSTART AND ONFINISH SEQUENCE
// -----------------
public boolean onStart(Map<String, String> args) {
// Bot.getEventManager().addListener(PaintListener.class, this);
treeID = 1309;
if(iHaveAtLeastOneOfTheFollowing(axesIDS, true, true) == false) {
log("Erm, I need an axe, either equiped or not");
return false;
}
if (args.get("Rune").equals("Earth Runes")) { //This is for earth runes
musicianTiles = new int[][] { {3291}, {3455} };
tiaraID = 5535;
runeID = 557;
tilesXsBanktoAltar = new int[] {3254, 3254, 3260, 3267, 3273, 3279, 3285, 3286, 3288, 3288, 3291, 3299, 3300, 3304};
tilesYsBanktoAltar = new int[] {3420, 3427, 3428, 3428, 3429, 3429, 3434, 3441, 3447, 3453, 3459, 3463, 3469, 3474};
treesToBankXs = new int[] {3303, 3296, 3293, 3292, 3292, 3284, 3275, 3264, 3255, 3253};
treesToBankYs = new int[] {3472, 3467, 3458, 3448, 3436, 3430, 3428, 3428, 3428, 3420};
innerPortalXY = new int[] {2655, 4829};
outterPortalXs = new int[] {3306,3306};
outterPortalYs = new int[] {3473,3473};
altarXs = new int[] {2657, 2658};
altarYs = new int[] {4841, 4841};
portalToAltarXs = new int[] {2656, 2655, 2656};
portalToAltarYs = new int[] {4829, 4835, 4841};
altarToTreesXs = new int[] {3302,3296,3298,3304};
altarToTreesYs = new int[] {3477,3472,3467,3472};
treeLocationsXs = new int[] {3305};
treeLocationsYs = new int[] {3470};
returningAtErrorSweetPoint = new RSTile(3284,3428);
bankTilesXY = new int[][] { {3252,3253,3254,3255}, {3420,3420,3420,3420} };
staircaseXY = new int[][] { {3256}, {3421} };
bankArea = new RSArea(3250, 3419, 8, 6);
portalToAltarXsReversed = reverseArray(portalToAltarXs);
portalToAltarYsReversed = reverseArray(portalToAltarYs);
}
/* else {
musicianTiles;
outterPortalXs = new int[] {};
outterPortalYs = new int[] {};
}
*/
if (equipmentContains(tiaraID) == false) {
log("Erm, you had better equip a tiara. A talisman is inneficient, btw");
return false;
}
itemsNotToBeDeposited = new int[axesIDS.length + runeEssenceID.length];
System.arraycopy(axesIDS, 0, itemsNotToBeDeposited, 0, axesIDS.length);
System.arraycopy(runeEssenceID, 0, itemsNotToBeDeposited, axesIDS.length, runeEssenceID.length);
return true;
}
public void onFinish() {
// Bot.getEventManager().removeListener(PaintListener.class, this);
}
// HERE STARTS DECLARATION OF VARIABLES
// ------------------------------------
public int[][] stepDist = { {18,19,23,24,25,29,30,31}, {16,17,32,33}/*, {13,14,15,20,21,22,26,27,28}*/ };
public int[][] musicianTiles;
public int actionChoosed = 6;
public int lastAction = 6;
public int randInLoop1 = 210;
public int randInLoop2 = 732;
public int[] axesIDS = {1351,1349,1353,1355,1361,1357,1359,6739};
public int[] runeEssenceID = {1436, 1437};
public int[] itemsNotToBeDeposited;
public int runeID,tiaraID;
public int treeID;
public int[] treeLocationsXs;
public int[] treeLocationsYs;
public RSTile nextTree = new RSTile(-1,-1);
public int[] tilesXsBanktoAltar;
public int[] tilesYsBanktoAltar;
public int[] altarToTreesXs;
public int[] altarToTreesYs;
public int[] tilesXsBanktoAltarReversed;
public int[] tilesYsBanktoAltarReversed;
public int[] innerPortalXY;
public int[] outterPortalXs;
public int[] outterPortalYs;
public int[] altarXs;
public int[] altarYs;
public int[] portalToAltarXs;
public int[] portalToAltarYs;
public int[] portalToAltarXsReversed;
public int[] portalToAltarYsReversed;
public int[] treesToBankXs;
public int[] treesToBankYs;
public int nextTreeX,nextTreeY;
public RSTile returningAtErrorSweetPoint;
public int[][] staircaseXY;
public RSArea bankArea;
public int woodcuttingAnimation = 867;
public int[][] bankTilesXY;
public int choppedFirstTree = 0;
public int repeatLastAction = 0;
public int performedChoosedAction3AtLeastOnce = 0;
public int currentAnimation = -1;
public int timeAtSameTree = 0;
public int timeAtSameTreeRandomValue = 0;
public int spamVar = 0;
public boolean defaultAlwaysRunning = false;
public String spamString = "";
public String[] randomColor = new String[] {"", "white:", "", "red:", "cyan:", "purple:", "green:"};
public String[] randomEffect = new String[] {"", "wave:", "wave2:", "scroll:", "shake:", "", "glow1:", "glow2:", "glow3:"};
public String[] randomWords = new String[] {"thing", "tree", "yew", "doing this", "woodcutting", "mining", "fishing"};
public String[] customText = new String[] {("Yawn"), ("My boredomness Level is " + random(95,99)), ("This " + randomWords[random(0,2)] + " sure is hard"), ("If I keep " + randomWords[random(3,4)] + " I will get sick"), ("I should seriously think about going " + randomWords[random(4,6)]), ("I wonder how much are yews today"), ("busy, busy, busy"), ("Ah, nature!"), ("Die, evil tree!")};
public String nextRandomMessage = "";
public String[] repaintTexts = new String[] {("Hola!"), ("Este es mi primer script")};
public int[][] firstDestinationStepSize = { {18, 19, 23, 24, 25, 29, 30, 31}, {16, 17, 32, 33} };
// HERE ENDS DECLARATION OF VARIABLES
//----------------------------------
// HERE STARTS DECLARATION OF CUSTOM METHODS
//------------------------------------------
public void onRepaint(Graphics g) {
if (isLoggedIn()) {
int repaintCounter0 = 0;
g.setColor(Color.cyan);
for(int repaintCounter = 0; repaintCounter < repaintTexts.length; repaintCounter++) {
g.drawString(repaintTexts[repaintCounter], (510 - (repaintTexts[repaintCounter].length() * 6) ), (12 + (15 * repaintCounter)) );
repaintCounter0 = repaintCounter;
}
g.drawString("La animacion actual es " + (currentAnimation), (510 - (("La animacion actual es " + (currentAnimation)).length() * 6) ), (12 + (15 * (repaintCounter0 + 1))) );
}
}
public int customEndScript(final String lastMessage) {
log(lastMessage);
return -1;
}
public boolean customInterfaceCloser () {
for(int sC = 0; sC <= 30; sC++) {
moveMouse(627, 85, 4, 4);
wait(random(478,723));
if (atMenu("Walk here") == true) {
return true;
}
moveMouse(600, 95, 4, 4);
}
customEndScript("customInterfaceCloserFailed");
return false;
}
public int chooseActionBasedOnLast (int lastActionTemp) {
int actionChoosedTemp = 5;
switch (lastActionTemp) {
case 1: //Case1 selects After going to Ruins
actionChoosedTemp = 2;
return actionChoosedTemp;
case 2: //Case2 selects After Exiting Ruins
if (calculateDistance(getMyPlayer().getLocation(),(new RSTile(altarToTreesXs[0], altarToTreesYs[0]))) <= 6) {
actionChoosedTemp = 3;
}
else {
actionChoosedTemp = 6;
}
return actionChoosedTemp;
case 3: //Case3 selects after cutting trees
if (isInventoryFull() == true) {
timeAtSameTree = 0;
repeatLastAction = 0;
choppedFirstTree = 0;
performedChoosedAction3AtLeastOnce = 0;
log("Inventory is full, bank");
actionChoosedTemp = 5;
return actionChoosedTemp;
}
if (repeatLastAction == 1) {
actionChoosedTemp = 3;
return actionChoosedTemp;
}
if (runeID != 557) {
actionChoosedTemp = 3;
return actionChoosedTemp;
}
if ((calculateDistance(getMyPlayer().getLocation(),(new RSTile(treesToBankXs[0],treesToBankYs[0]))) <= 12) && (calculateDistance(getMyPlayer().getLocation(),(new RSTile(treesToBankXs[0],treesToBankYs[0]))) >= 6)) {
walkTo((treesToBankXs[0] + random(-1,1)),(treesToBankYs[0]) + random(-1,1));
actionChoosedTemp = 5;
return actionChoosedTemp;
}
else {
if(calculateDistance(getMyPlayer().getLocation(),(new RSTile(treesToBankXs[0],treesToBankYs[0]))) < 6) {
actionChoosedTemp = 5;
return actionChoosedTemp;
}
if(calculateDistance(getMyPlayer().getLocation(),(new RSTile(treesToBankXs[0],treesToBankYs[0]))) > 12) {
actionChoosedTemp = 6;
return actionChoosedTemp;
}
}
return actionChoosedTemp;
case 5: //Case5 selects after banking
if (getInventoryCountA(runeEssenceID) >= 26) {
if (bank.isOpen() == true) {
customInterfaceCloser();
}
actionChoosedTemp = 1;
}
else {
actionChoosedTemp = 6;
}
return actionChoosedTemp;
case 6:
actionChoosedTemp = 5;
}
return actionChoosedTemp;
} //Will Choose Action.
public boolean useCabbagePort() {
return true;
}
public boolean goToNextDestiny(int whatIsThisActionAgain) {
int anyVar = 0;
switch (whatIsThisActionAgain) {
case 1: //actionChoosed1 takes us to the outside of the ruins
walkAPathContinuously(tilesXsBanktoAltar, tilesYsBanktoAltar, 1, 5, defaultAlwaysRunning);
wait(random(1523,2099));
if ((calculateDistance(getMyPlayer().getLocation(),(new RSTile(outterPortalXs[random(0,(outterPortalXs.length - 1))], outterPortalYs[random(0,(outterPortalXs.length - 1))]))) >= 9) || ((calculateDistance(getMyPlayer().getLocation(),(new RSTile(outterPortalXs[random(0,(outterPortalXs.length - 1))], outterPortalYs[random(0,(outterPortalXs.length - 1))]))) >= 15) && (getMyPlayer().isMoving() == true))) {
log("case1 thought I was far from ruins");
return false;
}
break;
case 2: //actionChoosed2 enters the ruins, crafts runes at altar and exits the ruins
anyVar = random(0,((outterPortalXs.length) - 1));
dansLeQuadre(outterPortalXs[anyVar], outterPortalYs[anyVar], "Enter", 45);
wait(random(3723,4000)); //Recently, even Entering ruins is sluggish
walkAPathContinuously(portalToAltarXs, portalToAltarYs, 1, 3, defaultAlwaysRunning);
anyVar = random( 0, ((altarXs.length) - 1));
dansLeQuadre(altarXs[anyVar], altarYs[anyVar], "Craft", 45);
wait(random(3332,3692)); //runecrafting animation takes time
walkAPathContinuously(portalToAltarXsReversed, portalToAltarYsReversed, 1, 3, defaultAlwaysRunning);
wait(random(498,633));
dansLeQuadre(innerPortalXY[0], innerPortalXY[1], "Use", 45);
wait(random(3332,3692)); //Loading a big landscape (Varrock) takes time
break;
case 3: //actionChoosed3 takes us to yews, doesn't cut them
if(isInventoryFull() == true) {
return false;
}
if(performedChoosedAction3AtLeastOnce == 1) {
return true;
}
if(calculateDistance(getMyPlayer().getLocation(),(new RSTile(altarToTreesXs[0],altarToTreesYs[0]))) >= 5) {
log("Am I that far from ruins after exiting?");
return false;
}
walkAPathContinuously(altarToTreesXs, altarToTreesYs, 1 ,3, defaultAlwaysRunning);
if(calculateDistance(getMyPlayer().getLocation(),(new RSTile(altarToTreesXs[(altarToTreesXs.length - 1)],altarToTreesYs[(altarToTreesYs.length - 1)]))) >= 9) {
log("Am I that far from trees?");
return false;
}
break;
case 5: //actionChoosed5 goes to Bank
final int randomBankTileSelected = random(0,(bankTilesXY[1].length - 1));
if(calculateDistance(getMyPlayer().getLocation(),(new RSTile(treesToBankXs[0],treesToBankYs[0]))) <= 4) {
walkAPathContinuously(treesToBankXs, treesToBankYs, 1, 5, false);
break;
}
if(calculateDistance(getMyPlayer().getLocation(),(new RSTile(bankTilesXY[0][randomBankTileSelected],bankTilesXY[1][randomBankTileSelected]))) <= 12) {
walkTo(bankTilesXY[0][randomBankTileSelected],bankTilesXY[1][randomBankTileSelected]);
break;
}
else {
return false;
}
case 6:
if (getMyPlayer().getHeight() == 1) {
if (runeID == 557) {
dansLeQuadre(staircaseXY[0][0], staircaseXY[1][0], "Climb-down Staircase", 15);
}
}
if (bankArea.contains(getMyPlayer().getLocation())) {
return true;
}
if (calculateDistance(getMyPlayer().getLocation(),(new RSTile (altarXs[0],altarYs[0]))) <= 20) {
if (getInventoryCount(runeEssenceID) >= 26) {
dansLeQuadre(altarXs[0], altarYs[0], "Craft", 30);
wait(random(3332,3692));
}
walkTo(innerPortalXY[0], innerPortalXY[1]);
dansLeQuadre(innerPortalXY[0], innerPortalXY[1], "Use", 30);
wait(random(3332,3692));
}
/*
if (runeID != 557) {
useCabbagePort();
}
if(calculateDistance((getMyPlayer().getLocation()),(returningAtErrorSweetPoint)) <= 200) {
int locationAtReturningPathAtError = findFirstStepInPath(treesToBankXs,treesToBankYs);
walkAPathContinuously(treesToBankXs, treesToBankYs, locationAtReturningPathAtError, 5, defaultAlwaysRunning);
}
else {
customEndScript("Case 6 could not solve the error");
}
break;
*/
}
return true;
}
public boolean makeAPathWithCoordinatesArrays(int[] arrayX,int[] arrayY) {
return true;
}
public boolean dansLeQuadre (int posX, int posY, final String action, final int allowedAttemps) {
for (int simpleCounter = 0; simpleCounter < allowedAttemps; simpleCounter++) {
final Point location = Calculations.tileToScreen(new RSTile(posX, posY));
if (location.x == -1 || location.y == -1) {
wait(random(478,723));
continue;
}
moveMouse(location, 2, 2);
wait(random(478,723));
if (atMenu(action) == true) {
return true;
}
moveMouse(250, 160 , 15, 15);
wait(random(478,723));
}
return false;
}
public boolean withdrawSomethingLikeThis(final int posX, final int posY, final String action) {
for (int simpleCounter = 0; simpleCounter <= 15; simpleCounter++) {
moveMouse(posX, posY, 3, 3);
wait (random(300,425));
if (atMenu(action) == true) {
return true;
}
wait (random(100,177));
moveMouse(random(7,1000), random(6,999), 2, 2);
wait (random(100,177));
}
return false ;
}
public int getInventoryCountA (int[] caughtArray) {
int iCTemp = 0;
if (caughtArray.length < 1) {
customEndScript ("problem: custom getInventoryCount received 0 array");
}
if (caughtArray.length == 1) {
return getInventoryCount (caughtArray[0]);
}
if (caughtArray.length > 1) {
for (int simpleCounter = 0; simpleCounter < caughtArray.length; simpleCounter++) {
iCTemp += getInventoryCount (caughtArray[simpleCounter]);
}
}
return iCTemp;
}
public boolean bank () {
if (getInventoryCountA(runeEssenceID) >= 27) {
customInterfaceCloser ();
return true;
}
if (getInventoryCountA(runeEssenceID) < 27) {
if(bank.isOpen() == false && openBankJM() == false) {
return false;
}
if (bank.isOpen() == true) {
log ("bank is open, get to work!");
for (int simpleCounter = 0; simpleCounter <=15; simpleCounter++) {
if ( (getInventoryCount() - getInventoryCountA(runeEssenceID)) <= 1) {
break;
}
bank.depositAllExcept (itemsNotToBeDeposited);
if ( (bank.isOpen() == false && openBankJM() == false) || simpleCounter == 15) {
return false;
}
wait (random(102,195));
moveMouse (5, 5, 3, 3);
wait (random(102,195));
}
wait(random(350,790));
for (int counterError = 0; counterError <= 15; counterError++) {
if ( (bank.isOpen() == false && openBankJM() == false) || counterError == 20) {
return false;
}
if (withdrawSomethingLikeThis(51,109,"All") == true) {
wait(random(250, 503));
break;
}
moveMouse (5, 5, 3, 3);
wait(random(500, 800));
}
if(getInventoryCountA(runeEssenceID) >= 27) {
customInterfaceCloser ();
}
else {
return false;
}
}
}
return false;
} //Closes bank
public boolean openBankJM() {
for (int counterError = 0; counterError < 32; counterError++) {
if ((dansLeQuadre (random(3252, 3254), 3419, "Use-quickly", 1) == true) || (dansLeQuadre (random(3252,3254), 3419, "Bank Banker", 1) == true) || bank.isOpen() == true) {
return true;
wait (random(1355, 1829));
}
else {
if (counterError >= 30) {
return false;
}
else {
moveMouse (5, 5, 3, 3);
wait (random(700, 1111));
}
}
}
return false;
}
public RSTile treeSelect() {
int shortestTreeIndex = 0;
int[] availableTreesXs = new int[10];
int[] availableTreesYs = new int[10];
int availableTreesTrueLength = 0;
int[] distanceToEachTree = new int[treeLocationsXs.length];
int aTIndex = 0;
int currentDist = 0;
for(int aTCounter = 0; aTCounter < treeLocationsYs.length; aTCounter++) {
if (getObjectAt((treeLocationsXs[aTCounter]),(treeLocationsYs[aTCounter])).getID() == treeID) {
availableTreesXs[aTIndex] = treeLocationsXs[aTCounter];
availableTreesYs[aTIndex] = treeLocationsYs[aTCounter];
aTIndex++;
availableTreesTrueLength++;
}
}
if(availableTreesTrueLength > 1) {
for(int cDTTCounter = 0; cDTTCounter < (availableTreesTrueLength); cDTTCounter++) {
currentDist = (int)calculateDistance(getMyPlayer().getLocation(),(new RSTile(availableTreesXs[cDTTCounter],availableTreesYs[cDTTCounter])));
distanceToEachTree[cDTTCounter] = currentDist;
}
currentDist = distanceToEachTree[0];
for(int sDCounter = 0; sDCounter < (distanceToEachTree.length); sDCounter++) {
if(distanceToEachTree[sDCounter] < currentDist) {
currentDist = distanceToEachTree[sDCounter];
shortestTreeIndex = sDCounter;
}
}
RSTile treeSelected = new RSTile(availableTreesXs[shortestTreeIndex],availableTreesYs[shortestTreeIndex]);
return treeSelected;
}
else {
if((availableTreesTrueLength == 1) && (getObjectAt((availableTreesXs[0]),(availableTreesYs[0])).getID()) == treeID) {
RSTile treeSelected = new RSTile(treeLocationsXs[0],treeLocationsYs[0]);
return treeSelected;
}
else {
RSTile treeSelected = new RSTile(-1,-1);
return treeSelected;
}
}
}
public int[] reverseArray(int[] tilesReceived){
final int theLength = tilesReceived.length;
int[] tilesReversedTemp = new int[theLength];
for (int counter = 0; counter <= (theLength - 1); counter++) {
tilesReversedTemp[counter] = tilesReceived[((theLength - 1) - counter)];
}
return tilesReversedTemp;
}
public int findFirstStepInPath(int[] receivedEmergencyPathXs, int[] receivedEmergencyPathYs) {
int firstStepIs = 0;
boolean forFailed = false;
final int theLength = receivedEmergencyPathXs.length;
for(int searchingCounter = 0; searchingCounter < (theLength -1); searchingCounter++) {
if(calculateDistance((getMyPlayer().getLocation()),new RSTile((receivedEmergencyPathXs[searchingCounter]),(receivedEmergencyPathYs[searchingCounter]))) <= calculateDistance((getMyPlayer().getLocation()), new RSTile((receivedEmergencyPathXs[(searchingCounter + 1)]),(receivedEmergencyPathYs[(searchingCounter + 1)])))) {
firstStepIs = searchingCounter;
break;
}
forFailed = true;
}
if (forFailed != false) {
firstStepIs = (theLength - 1);
}
return firstStepIs;
}
public boolean walkAPathContinuously(int[] arrayX,int[] arrayY,int firstStep, int distanceBeforeNext, boolean defaultRunningTemp) {
RSTile nextStepTile = new RSTile(0,0);
int firstStepCheck = 0;
int totalDistance = (int) calculateDistance (( getMyPlayer().getLocation()), (new RSTile(arrayX[firstStep],arrayY[firstStep])) );
if (totalDistance <= 12) {
walkTileMM (new RSTile((arrayX[firstStep] + myCoordinateRandomOffset()),(arrayY[firstStep] + myCoordinateRandomOffset())));
firstStepCheck = 1;
}
if (firstStepCheck == 0 && totalDistance > 30) {
customEndScript ("Im too far away from first step. Last action " + lastAction);
firstStepCheck = 1;
}
if (firstStepCheck == 0) {
int originX = getMyPlayer().getLocation().getX();
int originY = getMyPlayer().getLocation().getY();
int destinationX = arrayX[firstStep];
int destinationY = arrayY[firstStep];
int stepSize = 0;
int numberOfSteps = 0;
if (checkElementPresentIntArray (totalDistance, stepDist[0]) == true) {
stepSize = 6;
firstStepCheck = 1;
}
if (firstStepCheck == 0 && checkElementPresentIntArray (totalDistance, stepDist[1]) == true) {
stepSize = 8;
firstStepCheck = 1;
}
if (firstStepCheck == 0) {
stepSize = 7;
}
numberOfSteps = (int) (totalDistance / stepSize);
int[][] longFirstStep = new int[2][numberOfSteps];
for (int sC1 = 0; sC1 < numberOfSteps; sC1++) {
longFirstStep[0][sC1] = ( ( (destinationX - originX) * (sC1 + 1) ) / stepSize );
longFirstStep[1][sC1] = ( ( (destinationY - originY) * (sC1 + 1) ) / stepSize );
}
walkAPathContinuously (longFirstStep[0], longFirstStep[1], 0, 4, defaultAlwaysRunning);
}
if ( ( defaultRunningTemp == true ) || ( (isRunning() == false) && (getEnergy() > random(37,58)) ) ) {
setRun(true);
}
dontLetYourPlayerMove(50);
if ((arrayX.length - firstStep) >= 3) {
for (int counter = (firstStep + 1); counter <= (arrayX.length - 2); counter++) {
final int myCoordinateRandomOffsetX = myCoordinateRandomOffset();
final int myCoordinateRandomOffsetY = myCoordinateRandomOffset();
nextStepTile = new RSTile((arrayX[counter] + myCoordinateRandomOffsetX),(arrayY[counter] + myCoordinateRandomOffsetY));
for(int walkingRetries = 0; walkingRetries <= 20; walkingRetries++) {
if(walkTileMM(nextStepTile) == true) {
break;
}
wait(random(481,522));
if(walkingRetries >= 19) {
walkTo(nextStepTile);
break;
}
if(walkingRetries == 20) {
customEndScript("I failed at outter for in WalkAPathContinuously. " + lastAction + " was last action. " + counter);
}
}
for (int counter2 = 0; counter2 < 32; counter2++) {
if(counter2 == 31) {
customEndScript("I failed at inner for in WalkAPathContinuously. " + lastAction + " was last action. " + counter);
}
if(checkPlayersLocationAgainstDestination((arrayX[counter] + myCoordinateRandomOffsetX), (arrayY[counter] + myCoordinateRandomOffsetY), distanceBeforeNext) == true) {
break;
}
else {
wait(random(343,722));
}
}
}
if (checkPlayersLocationAgainstDestination(arrayX[arrayX.length - 2], arrayX[arrayY.length - 2], 2) == false) {
walkTo(arrayX[arrayX.length - 2],arrayY[arrayY.length - 2]);
}
}
if ((arrayX.length - firstStep) >= 2) {
final int myCoordinateRandomOffsetX = (random(-1,1));
final int myCoordinateRandomOffsetY = (random(-1,1));
for(int walkingRetries = 0; walkingRetries <= 20; walkingRetries++) {
if(walkTileMM(new RSTile((arrayX[arrayX.length - 1] + myCoordinateRandomOffsetX), (arrayY[arrayX.length - 1] + myCoordinateRandomOffsetY))) == true) {
break;
}
wait(random(481,522));
if(walkingRetries >= 19) {
walkTo(nextStepTile);
break;
}
if(walkingRetries == 20) {
customEndScript("I failed at very last step for WalkAPathContinuously. " + lastAction + " was last action. ");
}
}
if (checkPlayersLocationAgainstDestination(arrayX[arrayX.length - 1], arrayX[arrayY.length - 1], 2) == false) {
walkTo(arrayX[arrayX.length - 1],arrayY[arrayY.length - 1]);
}
}
log("successfully ended path directed by " + lastAction);
return true;
}
public boolean checkPlayersLocationAgainstDestination (final int posX, final int posY, final int allowedDistance) {
for (int simpleCounter = 0; simpleCounter <= 30; simpleCounter++) {
if( (calculateDistance( (getMyPlayer().getLocation()), (new RSTile(posX,posY)) ) <= allowedDistance) || (getMyPlayer().isMoving() == false) ) {
return true;
}
wait(random(107,302));
}
return false;
}
public boolean dontLetYourPlayerMove(int allowedChecks) {
for(int simpleCounter = 0; simpleCounter <= allowedChecks; simpleCounter++) {
if (getMyPlayer().isMoving() == false) {
return true;
}
wait(random(109,237));
}
return false;
}
public int myCoordinateRandomOffset() {
int randVar1 = 0;
if (1 >= (random(0,4))) {
randVar1 = 1;
}
if (2 >= (random(0,5))) {
randVar1 = randVar1 * (-1);
}
return randVar1;
}
public int realGetAnimation() {
int theRealThing = -1;
for(int wCCounter = 0; wCCounter <=20; wCCounter++) {
theRealThing = getMyPlayer().getAnimation();
if(theRealThing == 867) {
return theRealThing;
}
wait(random(250,350));
}
return -1;
}
public boolean iHaveAtLeastOneOfTheFollowing(int[] ItemIDS, boolean checkInventoryO, boolean checkEquipmentO) {
final int theLength = ItemIDS.length;
if (checkInventoryO == true) {
for(int itemsCounter = 0; itemsCounter < (theLength); itemsCounter++) {
if(inventoryContains(ItemIDS[itemsCounter]) == true) {
return true;
}
}
}
if (checkEquipmentO == true) {
for(int itemsCounter = 0; itemsCounter < (theLength); itemsCounter++) {
if(equipmentContains(ItemIDS[itemsCounter]) == true) {
return true;
}
}
}
return false;
}
public boolean checkElementPresentIntArray (int elementSent, int[] caughtArray) {
for (int simpleCounter = 0; simpleCounter < caughtArray.length; simpleCounter++) {
if (elementSent == caughtArray[simpleCounter]) {
return true;
}
}
return false;
}
// HERE ENDS DECLARATION OF CUSTOM METHODS
//----------------------------------------
public int loop() { //Opens Loop
actionChoosed = chooseActionBasedOnLast(lastAction);
// log("Im performing " + actionChoosed + " and I have " + getInventoryCount(runeEssenceID) + " runeessence");
if(bank.isOpen() == true) {
actionChoosed = 5;
}
switch (actionChoosed) {
case 1:
lastAction = 1;
if (goToNextDestiny(actionChoosed) != true) {
goToNextDestiny(6);
}
return random(randInLoop1,randInLoop2);
case 2:
lastAction = 2;
if (goToNextDestiny(actionChoosed) != true) {
goToNextDestiny(6);
}
return random(randInLoop1,randInLoop2);
case 3:
if (performedChoosedAction3AtLeastOnce == 0) {
timeAtSameTreeRandomValue = random(171926,232323);
lastAction = 3;
if (goToNextDestiny(actionChoosed) != true) {
goToNextDestiny(6);
}
performedChoosedAction3AtLeastOnce = 1;
repeatLastAction = 1;
}
for (int counterWood = 0; counterWood < 25; counterWood++) { //Technically, Woodcutting starts here
if (choppedFirstTree == 1) {
currentAnimation = realGetAnimation();
if(currentAnimation == 867) {
if (timeAtSameTree >= timeAtSameTreeRandomValue) {
sendText(nextRandomMessage, true);
timeAtSameTree = 0;
}
spamVar = random(542,899);
timeAtSameTree += spamVar;
return(spamVar);
}
}
if ((currentAnimation == -1) && (runeID == 557) && (choppedFirstTree == 1)) {
log("well, currentanimation got -1");
break;
}
timeAtSameTree = 0;
nextTree = treeSelect();
if (nextTree.getX() == -1) { //Wait If no tree is found
if (runeID == 557) {
break;
}
return (random(2501,3202));
}
log ("tree position is: " + nextTree.getX() + "," + nextTree.getY());
for (int selectingTreeCounter = 0; selectingTreeCounter <= 60; selectingTreeCounter++) {
if (dansLeQuadre(nextTree.getX(), nextTree.getY(), "Chop down Yew", 1) == true) {
choppedFirstTree = 1;
nextRandomMessage = String.valueOf(randomColor[random(0,(randomColor.length-1))]) + String.valueOf(randomEffect[random(0,(randomEffect.length-1))]) + String.valueOf(customText[random(0,(customText.length-1))]);
return(random(2230,2572));
}
log ((selectingTreeCounter + 1) + " intentos hacia el arbol");
wait (random(211,321));
if (selectingTreeCounter == 29) {
return(random(10,25));
}
}
}
timeAtSameTree = 0;
repeatLastAction = 0;
choppedFirstTree = 0;
performedChoosedAction3AtLeastOnce = 0;
return random(10,15);
case 5:
lastAction = 5;
if (goToNextDestiny(actionChoosed) != true) {
goToNextDestiny(6);
}
if (getInventoryCount(runeEssenceID) >= 26) {
break;
}
if (bank() != true) {
goToNextDestiny(6);
}
return random(randInLoop1,randInLoop2);
case 6:
lastAction = 6;
if (goToNextDestiny(actionChoosed) != true) {
return customEndScript("Case 6 Error detection was unable to solve a problem");
}
} //Closes switch in loop
return random(randInLoop1,randInLoop2);
} //Closes Loop
} //Closes Script