• Log in or sign up for an account here: https://www.sythe.org/login

i'm looking for iron mining script for scar v3.10

stacked

Active Member
Joined
May 11, 2007
Sythe Gold
0
Messages
190
Location
chillin on sythe
i need a scar script for auto mining west or east of varrock or an ess miner.
if you have on can you plz post the code...
ive been searching for one all day long...
and i want to get the program up and running by sunday...
 
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.util.Map;

import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.event.listeners.PaintListener;
import com.speljohan.rsbot.script.Calculations;
import com.speljohan.rsbot.script.Script;
import com.speljohan.rsbot.script.wrappers.RSCharacter;
import com.speljohan.rsbot.script.wrappers.RSInterface;
import com.speljohan.rsbot.script.wrappers.RSObject;
import com.speljohan.rsbot.script.wrappers.RSTile;

public class GarrettsEssenceMiner extends Script implements PaintListener {

//OTHER VARIABLES
private long scriptStartTime = 0;
private int runEnergy = random(50, 80);
private int closest = -1;
private int essCount = 0;
private int runCount = 0;
private boolean runThis = true;
private boolean setAltitude = true;
private String theAction = null;

//OBJECT
private RSObject door;
private int varrockBooth = 11402;
private int closedDoor = 24381;
private int essence = 2491;
private int portal = 2492;

//ITEM ID
private int[] pickaxe = {1265, 1267, 1269, 1296, 1273, 1271, 1275};
private int pureEssence = 7936;
private int runeEssence = 1436;

//PATHS
private RSTile[] varrockPath = {new RSTile(3253, 3420), new RSTile(3258, 3410), new RSTile(3253, 3401)};

//TILES
private RSTile varrockTeleport = new RSTile(3253, 3401);
private RSTile varrockBank = new RSTile(3253, 3420);

//NPC
private int Aubury = 553;

//ENUM
private static final int WALKTO = 1;
private static final int OPENDOOR = 2;
private static final int TELEPORT = 3;
private static final int FINDPLACE = 4;
private static final int MINE = 5;
private static final int EXIT = 6;
private static final int WALKBACK = 7;
private static final int OPENBANK = 8;
private static final int BANK = 9;
private int ACTION = WALKTO;

public GarrettsEssenceMiner (){
setParameter("author", "Garrett");
setParameter("version", 1.02);
setParameter("name", "Garrett's Essence Miner");
setParameter("category", "Garrett");
}

public String getScriptDescription() {
String html = "<html><head>";
html += "</head><body>";
html += "<center><strong><h2>" + getName() + " v" + getVersion() + "</h2></strong></center>";
html += "<center><strong>Start the script in Varrock East Bank with pickaxe equipped or in inventory.</strong></center>";
html += "</body></html>";
return html;
}

//*******************************************************//
// ON START
//*******************************************************//
public boolean onStart( Map<String,String> args ) {
scriptStartTime = System.currentTimeMillis();
return true;
}

//*******************************************************//
// MAIN LOOP
//*******************************************************//
public int loop() {

if (!isLoggedIn()) {
wait(random(500, 1000));
return random(50,150);
}

if (setAltitude) {
setCameraAltitude(true);
wait(random(250, 500));
setAltitude = false;
}

if (energyCheck()) {
setRun(true);
wait(random(750,1000));
}

if (getPlane() == 1 && playerInArea(3257, 3423, 3250, 3416)) {
if (onTile(new RSTile(3256, 3421), "Staircase", "Climb-down")) {
wait(random(1500, 2000));
while (getMyPlayer().isMoving()) {
wait(100);
}
wait(random(1500, 2000));
}
return 100;
}

if (!inEquipment(pickaxe) && !inInventory(pickaxe)) {
log("Pickaxe was not found.");
wait(10000);
return 100;
}

antiBan();
runScript();

return random(50,150);
}

//*******************************************************//
// OTHER METHODS
//*******************************************************//
private void runScript() {
if (ACTION == WALKTO) {
theAction = "Walk to Aubury";
try {
if (getInventoryCount(pureEssence, runeEssence) > 0) {
ACTION = WALKBACK;
}
if (distanceTo(varrockTeleport) > 7) {
walkPath(varrockPath, false);
return;
} else {
ACTION = OPENDOOR;
return;
}
} catch (Exception e) { }
}
if (ACTION == OPENDOOR) {
theAction = "Checking Door";
try {
if (getNearestObjectByID(portal) != null) {
ACTION = EXIT;
return;
}
if (inAuburyShop() && !isInventoryFull()) {
ACTION = TELEPORT;
return;
}
door = getObjectAt(3253, 3398);
if (door != null) {
if (door.getID() == closedDoor) {
if(getCameraAngle() >= 0 && getCameraAngle() <= 10 || getCameraAngle() >= 350 && getCameraAngle() <= 360) {
if (atDoor(door, "North", "Open")) {
wait(random(750, 1000));
while (getMyPlayer().isMoving()) {
wait(100);
}
wait(random(750, 1000));
return;
}
} else {
int a = random(1,3);
if (a == 1)
setCameraRotation(random(350, 360));
else
setCameraRotation(random(0, 10));
return;
}
} else {
if (isInventoryFull()) {
ACTION = WALKBACK;
return;
} else {
ACTION = TELEPORT;
return;
}
}
} else {
if (isInventoryFull()) {
ACTION = WALKBACK;
return;
} else {
ACTION = TELEPORT;
return;
}
}
} catch (Exception e) { }
}
if (ACTION == TELEPORT) {
theAction = "Teleporting";
try {
if (getNearestNPCByID(Aubury) == null) {
ACTION = FINDPLACE;
return;
}
door = getObjectAt(3253, 3398);
if (door != null) {
if (door.getID() == closedDoor && !inAuburyShop()) {
ACTION = OPENDOOR;
return;
}
}
if (onNPC(getNearestNPCByID(Aubury), "Aubury", "Teleport")) {
wait(random(750, 1000));
while (getMyPlayer().isMoving()) {
wait(100);
}
wait(random(1500, 1750));
return;
}
} catch (Exception e) { }
}
if (ACTION == FINDPLACE) {
theAction = "Finding Location";
try {
if (runThis) {
if (findLocation()) {
runThis = false;
}
}
if (!runThis) {
if (closest != -1) {
if (closest == 0) {
walkTileMM(new RSTile(2919, 4840));
closest = -1;
return;
} else if (closest == 1) {
walkTileMM(new RSTile(2919, 4823));
closest = -1;
return;
} else if (closest == 2) {
walkTileMM(new RSTile(2902, 4842));
closest = -1;
return;
} else if (closest == 3) {
walkTileMM(new RSTile(2902, 4821));
closest = -1;
return;
} else {
closest = -1;
return;
}
} else {
closest = -1;
runThis = true;
ACTION = MINE;
return;
}
}
} catch (Exception e) { }
}
if (ACTION == MINE) {
theAction = "Mining";
try {
if (getNearestNPCByID(Aubury) != null) {
ACTION = TELEPORT;
return;
}
if (isInventoryFull()) {
ACTION = EXIT;
return;
}
if (getMyPlayer().getAnimation() == -1) {
wait(random(500, 1000));
if (getMyPlayer().getAnimation() != -1)
return;
if (onEssence(getNearestObjectByID(essence).getLocation(), "Essence", "Mine")) {
wait(random(750, 1000));
while (getMyPlayer().isMoving()) {
wait(100);
}
wait(random(750, 1000));
return;
}
}
} catch (Exception e) { }
}
if (ACTION == EXIT) {
theAction = "Leaving";
try {
if (getNearestNPCByID(Aubury) != null) {
ACTION = OPENDOOR;
return;
}
if (onTile(getNearestObjectByID(portal).getLocation(), "Portal", "Use")) {
wait(random(750, 1000));
while (getMyPlayer().isMoving()) {
wait(100);
}
wait(random(750, 1000));
return;
}
} catch (Exception e) { }
}
if (ACTION == WALKBACK) {
theAction = "Walking to bank";
try {
if (getNearestObjectByID(portal) != null) {
ACTION = EXIT;
return;
}
if (distanceTo(varrockBank) > 5) {
walkPath(varrockPath, true);
return;
} else {
ACTION = OPENBANK;
return;
}
} catch (Exception e) { }
}
if (ACTION == OPENBANK) {
theAction = "Opening bank";
try {
if (bank.isOpen()) {
ACTION = BANK;
essCount += getInventoryCount(pureEssence, runeEssence);
runCount += 1;
return;
}
if (onTile(getNearestObjectByID(varrockBooth).getLocation(), "Bank booth", "Use-quickly")) {
wait(random(750, 1000));
while (getMyPlayer().isMoving()) {
wait(100);
}
wait(random(750, 1000));
return;
}
} catch (Exception e) { }
}
if (ACTION == BANK) {
theAction = "Banking";
try {
if (getInventoryCount() <= 1) {
ACTION = WALKTO;
return;
}
if (bank.isOpen()) {
if (inInventory(pickaxe)) {
bank.depositAllExcept(pickaxe);
wait(random(250, 500));
} else {
bank.depositAll();
wait(random(250, 500));
}
} else {
wait(random(500, 1000));
if (!bank.isOpen())
if (onTile(getNearestObjectByID(varrockBooth).getLocation(), "Bank booth", "Use-quickly")) {
wait(random(750, 1000));
while (getMyPlayer().isMoving()) {
wait(100);
}
wait(random(750, 1000));
return;
}
}
} catch (Exception e) { }
}
}

private boolean findLocation() {
try {
if (playerInArea(2934, 4822, 2921, 4810)) {
//log("Player Location: South-East");
closest = -1;
return true;
}
if (playerInArea(2933, 4855, 2920, 4843)) {
//log("Player Location: North-East");
closest = -1;
return true;
}
if (playerInArea(2899, 4858, 2880, 4840)) {
//log("Player Location: North-West");
closest = -1;
return true;
}
if (playerInArea(2902, 4822, 2880, 4800)) {
//log("Player Location: South-West");
closest = -1;
return true;
}
if (playerInArea(2920, 4841, 2900, 4820)) {
//log("Player Location: Middle");
int dist = 200;
RSTile[] loc = {new RSTile(2924, 4847), new RSTile(2926, 4819), new RSTile(2896, 4847), new RSTile(2897, 4817)};
for (int i = 0; i < loc.length; i++) {
if (distanceTo(loc) < dist) {
closest = i;
dist = distanceTo(loc);
}
}
return true;
}
if (getNearestObjectByID(essence) != null) {
closest = -1;
return true;
}
return false;
} catch (Exception e) { return false; }
}

private boolean inAuburyShop() {
try {
if (playerInArea(3254, 3404, 3252, 3399) || (getMyPlayer().getLocation().getX() == 3255 && getMyPlayer().getLocation().getY() == 3401))
return true;
return false;
} catch (Exception e) { return false; }
}

public boolean inEquipment(int... itemID) {
try {
for (int item : itemID) {
if (getEquipmentInterface().getInventoryItemCount(item) != 0) {
return true;
}
}
} catch (Exception e) { }
return false;
}

public boolean inInventory(int... itemID) {
try {
for (int i : itemID) {
if (getInventoryCount(i) != 0)
return true;
}
} catch (Exception e) { }
return false;
}

private int gEnergy() {
return Integer.parseInt(RSInterface.getChildInterface(750, 5).getText());
}

private boolean energyCheck() {
try {
if (gEnergy() >= runEnergy && !isRunning()) {
runEnergy = random(35, 65);
return true;
} else {
return false;
}
} catch (Exception e) {
return false;
}
}

public boolean onNPC(RSCharacter npc, String npcName, String action) {
if (npc == null) {
return false;
}
RSTile tile = npc.getLocation();
if (!tile.isValid()) {
return false;
}
if (distanceTo(tile) > 5) {
walkTileMM(tile);
wait(random(340, 1310));
}

try {
Point screenLoc = null;
for (int i = 0; i < 30; i++) {
screenLoc = npc.getScreenLocation();
if (!npc.isValid() || !pointOnScreen(screenLoc)) {
return false;
}
if(getMenuItems().get(0).toLowerCase().contains(npcName.toLowerCase())) {
break;
}
if (getMouseLocation().equals(screenLoc)) {
break;
}
moveMouse(screenLoc);
}
screenLoc = npc.getScreenLocation();
if (getMenuItems().size() <= 1) {
return false;
}
if (getMenuItems().get(0).toLowerCase().contains(action.toLowerCase())) {
clickMouse(true);
return true;
} else {
clickMouse(false);
return atMenu(action);
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
}

public boolean onTile(RSTile tile, String search, String action) {
if (!tile.isValid()) {
return false;
}
if (distanceTo(tile) > 5) {
walkTileMM(tile);
wait(random(340, 1310));
}

try {
Point screenLoc = null;
for (int i = 0; i < 30; i++) {
screenLoc = Calculations.tileToScreen(tile);
if (!pointOnScreen(screenLoc)) {
return false;
}
if(getMenuItems().get(0).toLowerCase().contains(search.toLowerCase())) {
break;
}
if (getMouseLocation().equals(screenLoc)) {
break;
}
moveMouse(screenLoc);
}
screenLoc = Calculations.tileToScreen(tile);
if (getMenuItems().size() <= 1) {
return false;
}
if (getMenuItems().get(0).toLowerCase().contains(action.toLowerCase())) {
clickMouse(true);
return true;
} else {
clickMouse(false);
return atMenu(action);
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
}

public boolean onEssence(RSTile tile, String search, String action) {
if (!tile.isValid()) {
return false;
}
if (distanceTo(tile) > 5) {
walkTileMM(tile);
wait(random(340, 1310));
}

try {
Point screenLoc = null;
for (int i = 0; i < 30; i++) {
screenLoc = Calculations.tileToScreen(tile, 1, 1, 40);
if (!pointOnScreen(screenLoc)) {
return false;
}
if(getMenuItems().get(0).toLowerCase().contains(search.toLowerCase())) {
break;
}
if (getMouseLocation().equals(screenLoc)) {
break;
}
moveMouse(screenLoc);
}
screenLoc = Calculations.tileToScreen(tile);
if (getMenuItems().size() <= 1) {
return false;
}
if (getMenuItems().get(0).toLowerCase().contains(action.toLowerCase())) {
clickMouse(true);
return true;
} else {
clickMouse(false);
return atMenu(action);
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
}

private void walkPath(RSTile[] path, boolean reverse) {
if (!reverse) {
if(!getMyPlayer().isMoving() || distanceTo(getDestination()) <= random(4, 7))
{
walkPathMM(randomizePath(path, 2, 2), 17);
return;
} else antiBan();
}
else {
if(!getMyPlayer().isMoving() || distanceTo(getDestination()) <= random(4, 7))
{
walkPathMM(randomizePath(reversePath(path), 2, 2), 17);
return;
} else antiBan();
}
}

private boolean playerInArea(int maxX, int maxY, int minX, int minY) {
int x = getMyPlayer().getLocation().getX();
int y = getMyPlayer().getLocation().getY();
if (x >= minX && x <= maxX && y >= minY && y <= maxY)
{
return true;
}
return false;
}

private int antiBan() {
int random = random(1, 24);

switch (random) {
case 1:
int x = random(0, 750);
int y = random(0, 500);
if (random(1, 10) == 5)
moveMouse(0, 0, x, y);
return random(1000, 1500);

case 2:
if (getCurrentTab() != TAB_INVENTORY) {
openTab(TAB_INVENTORY);
return random(500, 750);
} else {
return random(500, 750);
}

case 3:
if (random(1, 40) == 30)
{
if (getMyPlayer().isMoving()) {
return random(750, 1000);
}
if (getCurrentTab() != TAB_STATS) {
openTab(TAB_STATS);
}
moveMouse(560, 420, 40, 20);
wait(random(3000, 6000));
return random(100, 200);
}

case 4:
if (random(1, 3) == 2) {
int angle = getCameraAngle() + random(-90, 90);
if (angle < 0) {
angle = 0;
}
if (angle > 359) {
angle = 0;
}

setCameraRotation(angle);
return random(500, 750);
}
}
return 500;
}

//*******************************************************//
// ON FINISH
//*******************************************************//
public void onFinish() {
Bot.getEventManager().removeListener( PaintListener.class, this );
}

//*******************************************************//
// PAINT SCREEN
//*******************************************************//
public void onRepaint(Graphics g) {
long runTime = 0;
long seconds = 0;
long minutes = 0;
long hours = 0;

runTime = System.currentTimeMillis() - scriptStartTime;
seconds = runTime / 1000;
if ( seconds >= 60 ) {
minutes = seconds / 60;
seconds -= (minutes * 60);
}
if ( minutes >= 60 ) {
hours = minutes / 60;
minutes -= (hours * 60);
}

if(getCurrentTab() == TAB_INVENTORY) {
g.setColor(new Color(0, 0, 0, 175));
g.fillRoundRect(555, 210, 175, 250, 10, 10);
g.setColor(Color.WHITE);
int[] coords = new int[] {225, 240, 255, 270, 285, 300, 315, 330, 345, 360, 375, 390, 405, 420, 435, 450};
g.drawString(getName(), 561, coords[0]);
g.drawString("Version: " + getVersion(), 561, coords[1]);
g.drawString("Run Time: " + hours + ":" + minutes + ":" + seconds, 561, coords[3]);
g.drawString("Run Time: " + hours + ":" + minutes + ":" + seconds, 561, coords[3]);
g.drawString("Total Runs: " + runCount, 561, coords[5]);
g.drawString("Total Essence: " + essCount, 561, coords[6]);
g.drawString("Action: " + theAction, 561, coords[15]);
}
}






thats an ess miner for varrock mines and everything
 
duelarena.gg
Back
Top