Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Yes... I know the code isn't perfect...
- Yes I know there are unused variables (cbf removing)
- Yes I know this is a horrible way to write a script...
- No I don't care because it runs flawlessly... I ran it 15 hours no problems.
- */
- import java.awt.Color;
- import java.awt.Graphics;
- import java.util.Map;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.*;
- import org.rsbot.script.*;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.event.listeners.PaintListener;
- import java.awt.Point;
- @ScriptManifest(authors = { "Kriogenic" }, category = "Mining", name = "Kriogenic Crafting Guild Miner", version = 1.0, description = "<html><body bgcolor =\"#AAAAAAAA\"><font color =\"#3333FF\"><center><h2>Kriogenics Crafting Guild Miner</h2><BR>"
- + "<font size=\"3\">You should start this script at the bank but it can be started at the guild also.<br /><select name=\"Rockchoice\"><option>Gold<option>Silver<option>Clay<option>Gold & Silver</select></font></body></html>")
- public class CraftingGuildMiner extends Script implements PaintListener, ServerMessageListener{
- final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
- int runEnergy = random(50, 80);
- public int Gold[] = {11184,11183,11185};
- public int Silver[] = {11186,11187,11188};
- public int Clay[] = {11189,11190,11191};
- public int GoldSilver[] = { 11184,11183,11185,11186,11187,11188};
- public int RocksMined = 0;
- public int Pickaxes[] = { 1275, 1265, 1273, 1267, 1271, 15259, 1269 };
- public long startTime = System.currentTimeMillis();
- public int OpenDoor = 336;
- public int ClosedDoor = 336;
- public int Booth = 11758;
- public int loopwait = 800;
- private int RockID[];
- private long scriptStartTime = 0;
- private int startXP = 0;
- private int gainedXP = 0;
- long runTime = 0;
- long seconds = 0;
- long minutes = 0;
- long hours = 0;
- private String status = "";
- String OreID;
- String State;
- int StartingExp;
- int GainedExp = 0;
- RSTile[] ToGuild = {new RSTile(3013, 3355),new RSTile(3007, 3349),
- new RSTile(3007, 3335),new RSTile(3006, 3325),new RSTile(2998, 3314),
- new RSTile(2989, 3306),new RSTile(2976, 3302),new RSTile(2962, 3300),
- new RSTile(2950, 3301),new RSTile(2936, 3295),new RSTile(2933, 3289)};
- RSTile[] ToSpot = {new RSTile(2933, 3288),new RSTile(2939, 3281)};
- RSTile[] ToDoor = reversePath(ToSpot);
- RSTile[] ToBank = reversePath(ToGuild);
- public boolean onStart(Map<String, String> args) {
- scriptStartTime = System.currentTimeMillis();
- status = "Starting Up...";
- if (args.get("Rockchoice").equals("Gold")) {
- RockID = Gold;
- }
- if (args.get("Rockchoice").equals("Silver")) {
- RockID = Silver;
- }
- if (args.get("Rockchoice").equals("Clay")) {
- RockID = Clay;
- }
- if (args.get("Rockchoice").equals("Gold & Silver")) {
- RockID = GoldSilver;
- }
- return true;
- }
- public void onFinish() {
- return;
- }
- //**************************************//
- // METHODS
- //**************************************//
- public void Mine(){
- RSObject rock = getNearestObjectByID(RockID);
- if(rock == null)
- return;
- while(!tileOnScreen(rock.getLocation())){
- try{
- if(!getMyPlayer().isMoving()){
- walkTileMM(rock.getLocation());
- }
- }catch(final Exception e){
- e.printStackTrace();
- }
- }
- if (getMyPlayer().getAnimation() == -1) {
- status = "Mining Rock...";
- try{
- atObject(rock, "Mine");
- }catch(final Exception e){
- e.printStackTrace();
- }
- }
- }
- public void antiban(){
- int randnum = random(0,999);
- int[] crotate = {10, 130, 530, 200, 470, 600, 720, 850, 905, 999};
- int li;
- for(li=0;li < crotate.length;li++){
- if(randnum == crotate[li]){
- setCameraRotation(random(0, 359));
- }
- }
- if (energyCheck()) {
- setRun(true);
- wait(random(750,1000));
- }
- return;
- }
- private boolean energyCheck() {
- try {
- if (gEnergy() >= runEnergy && !isRunning()) {
- runEnergy = random(35, 65);
- return true;
- } else {
- return false;
- }
- } catch (Exception e) {
- return false;
- }
- }
- private int gEnergy() {
- return Integer.parseInt(RSInterface.getChildInterface(750, 5).getText());
- }
- public boolean ToGuild() {
- final RSTile[] randomizedPath = randomizePath(ToGuild, 2, 2);
- final RSTilePath path = new RSTilePath(randomizedPath, this);
- status = "Walking to Guild...";
- try {
- return path.walkToEnd();
- } catch (final Exception e) {
- e.printStackTrace();
- }
- return false;
- }
- public boolean ToSpot() {
- final RSTile[] randomizedPath = randomizePath(ToSpot, 2, 2);
- final RSTilePath path = new RSTilePath(randomizedPath, this);
- status = "Walking to rocks...";
- try {
- return path.walkToEnd();
- } catch (final Exception e) {
- e.printStackTrace();
- }
- return false;
- }
- public boolean ToBank() {
- final RSTile[] randomizePath = randomizePath(ToBank, 2, 2);
- final RSTilePath path = new RSTilePath(randomizePath, this);
- status = "Walking to bank...";
- try {
- return path.walkToEnd();
- } catch (final Exception e) {
- e.printStackTrace();
- }
- return false;
- }
- public boolean ToDoor() {
- final RSTile[] randomizePath = randomizePath(ToDoor, 2, 2);
- final RSTilePath path = new RSTilePath(randomizePath, this);
- status = "Walking to door...";
- try {
- return path.walkToEnd();
- } catch (final Exception e) {
- e.printStackTrace();
- }
- return false;
- }
- public boolean needToBank(){
- return isInventoryFull();
- }
- public boolean handleBank() {
- RSObject bankBooth = getNearestObjectByID(Booth);
- if(bankBooth == null){
- return false;
- }
- if(bank == null)
- return false; //Can't find bank
- log("Can't find bank");
- if(bank.isOpen()){
- bank.depositAllExcept(Pickaxes);
- }else{
- status = "Banking...";
- try{
- if (random(0,25) == 10) {
- setCameraRotation(random(0, 359));
- }
- atObject(bankBooth, "Use-quickly");
- }catch(final Exception e){
- e.printStackTrace();
- }
- }
- return true;
- }
- public boolean handleDoor() {
- if (random(0,25) == 10) {
- setCameraRotation(random(0, 359));
- }
- status = "Opening Door...";
- atDoorTiles(new RSTile(2933, 3289), new RSTile(2933, 3288));
- wait(random(100,300));
- return true;
- }
- public boolean inSquare(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;
- }
- ////////////////
- /////Loop//////
- //////////////
- @Override
- public int loop() {
- setCameraAltitude(true);
- antiban();
- RSObject Banker = getNearestObjectByID(Booth);
- RSObject Cdoor = getNearestObjectByID(ClosedDoor);
- RSObject Rock = getNearestObjectByID(RockID);
- if(getMyPlayer().isMoving()) return random(400, 1300);
- if(inSquare(2943, 3291, 2937, 3276)){
- if(!needToBank()){
- Mine();
- }else{
- ToDoor();
- }
- ////////////////////
- }
- if(inSquare(2931, 3291, 2928, 3289) || inSquare(2938, 3288, 2928, 3287) || inSquare(2938, 3291, 2935, 3288)){
- if(!needToBank()){
- ToSpot();
- }else{
- handleDoor();
- }
- }
- if(inSquare(2934, 3292, 2932, 3289)) {
- if(!needToBank()){
- handleDoor();
- }else{
- ToBank();
- }
- }
- if(inSquare(3018, 3358, 3009, 3355)){
- if(!needToBank()){
- ToGuild();
- }else{
- handleBank();
- }
- }
- if(inSquare(3018, 3360, 3009, 3359)){
- if(needToBank()){
- walkTileMM(getClosestTileOnMap(new RSTile(3012, 3356)));
- }
- }
- return(loopwait);
- }
- @Override
- public void onRepaint(Graphics g) {
- int currentXP = 0;
- int currentLVL = 0;
- int OrePerHour = 0;
- int nextLvl = 0;
- final double xpGain = 25.5;
- if (isLoggedIn()) {
- 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);
- }
- currentLVL = skills.getCurrentSkillLevel(Skills
- .getStatIndex("mining"));
- currentXP = skills.getCurrentSkillExp(Skills.getStatIndex("mining"));
- nextLvl = skills.getXPToNextLevel(Skills.getStatIndex("mining"));
- OrePerHour = (int) (3600000.0 / runTime * RocksMined);
- g.setColor(new Color(0, 0, 0, 175));
- g.fillRoundRect(555, 210, 175, 250, 10, 10);
- g.setColor(Color.yellow);
- g.drawString("Kriogenic Crafting Guild Miner!",558,222);
- g.drawString("Run Time: " + hours + "Hrs " + minutes + "Min " + seconds + "Sec", 560, 247);
- g.drawString("Status : " + status, 585, 262);
- g.drawString("Ore Mined : " + RocksMined , 585, 287);
- g.drawString("Ore Per Hour: " + OrePerHour, 585 ,302);
- g.drawString("Current Level: " + currentLVL, 585, 327);
- g.drawString("XP Gained: " + gainedXP, 585, 342);
- g.drawString("XP Till Level: " + nextLvl, 585, 357);
- }
- }
- @Override
- public void serverMessageRecieved(ServerMessageEvent arg0) {
- String serverString = arg0.getMessage();
- if (serverString.contains("You manage to")) {
- RocksMined++; //
- }
- if (serverString.contains("gold")) {
- gainedXP += 65;
- }
- if (serverString.contains("silver")) {
- gainedXP += 40;
- }
- if (serverString.contains("clay")) {
- gainedXP += 5;
- }
- }
- }
Add Comment
Please, Sign In to add comment