Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Point;
- import com.rarebot.event.listeners.PaintListener;
- import com.rarebot.script.Script;
- import com.rarebot.script.ScriptManifest;
- import com.rarebot.script.methods.Skills;
- import com.rarebot.script.wrappers.*;
- @ScriptManifest(authors = { "The_Physicist" }, name = "EdgevilleSmelter by The_Physicist", description = "Start with Gold ore or Gold bars in inv in edge bank or furnace...", version = 1.0)
- public class EdgevilleGoldSmelter extends Script implements PaintListener {
- public static final RSTile bankTile = new RSTile(3097, 3496);
- public static final RSTile smeltTile = new RSTile(3109,3501);
- public int bankID = 42377;
- public int goldBar = 2357;
- public int goldOre = 444;
- public int startLvl, startExp, barsSmelted;
- private long startTime;
- private String bar, state = "Loading";
- public boolean onStart() {
- startTime = System.currentTimeMillis();
- return true;
- }
- @Override
- public int loop() {
- RSArea atFurnace = new RSArea(new RSTile(3104,3485), new RSTile(3113,3505));
- RSArea atBank = new RSArea(new RSTile(3091,3493), new RSTile(3099,3500));
- if (getMyPlayer().getAnimation() == 3243) {
- antiBan();
- sleep(random(5000,10000));}
- else {
- if (getMyPlayer().isMoving() == true) {
- if(random(1, 100) == 1)
- sleep(random(1000,1500));
- } else {
- if (!inventory.contains(goldOre)) {
- if (!atBank.contains(getMyPlayer().getLocation())) {
- log ("Not at bank, walking to bank!");
- walk(bankTile);
- sleep (random(500,700));
- }
- Bank();
- } else
- if (!inventory.contains(goldBar) || inventory.contains(goldOre)) {
- if (!atFurnace.contains(getMyPlayer().getLocation())) {
- log ("Not at Furnace, walking to furnace");
- walk(smeltTile);
- sleep (random(500,700));
- }
- smeltGold();
- }
- }
- }
- return random(200,500);
- }
- private void smeltGold() {
- state = "Smelting!";
- RSObject furnace = objects.getNearest(26814);
- RSInterface main = interfaces.get(905);
- RSComponent comp = main.getComponent(19);
- if (furnace.isOnScreen()) {
- furnace.doClick();
- sleep (random(500,700));
- sleep(random(750,1250));
- if (main.isValid()) {
- comp.doClick();
- log("Smelting!");
- for (int w = 0; w < 300 && getMyPlayer().isIdle(); w++) {
- sleep(10);
- }
- }
- } else {
- sleep(100);
- }
- }
- public void Bank() {
- state = "Banking!";
- if (!bank.isOpen()) {
- bank.open();
- } else {
- if (!inventory.contains(goldOre)) {
- if (inventory.isFull()) {
- bank.depositAllExcept(561);
- if (bank.getCount(goldOre) >= 27) {
- bank.withdraw(goldOre, 28);
- }
- } else {
- log("No more gold ore in bank.");
- stopScript(true);
- }
- }
- }
- }
- private boolean walk(RSTile dest) {
- final Point p = calc.tileToMinimap(dest);
- if (p.x != -1 && p.y != -1) {
- if (!mouse.getLocation().equals(p)) {
- mouse.hop(p);
- mouse.click(true);
- mouse.moveSlightly();
- return true;
- }
- }
- return false;
- }
- public void antiBan() {
- state = "Antiban!";
- try {
- mouse.setSpeed(random(4, 8));
- switch(random(0, 10)) {
- case 1:
- mouse.moveRandomly(400, 800);
- log ("Antiban - Moving mouse randomly!");
- break;
- case 3:
- mouse.moveRandomly(900, 1200);
- log ("Antiban - Moving mouse randomly!");
- break;
- case 4:
- mouse.moveRandomly(200, 700);
- mouse.moveOffScreen();;
- log ("Antiban - Moving mouse randomly!");
- break;
- case 5:
- mouseObserve();
- log ("Antiban - Right clicking random player!!");
- break;
- case 6:
- if(game.isFixed() && !getMyPlayer().isMoving() &&
- random(0, 2) == 1) {
- mouse.move(random(527, 540), random(58, 65), 0, 0);
- sleep(random(200, 400));
- mouse.click(true);
- mouse.moveRandomly(20, 50);
- sleep(random(300, 500));
- }
- break;
- case 7:
- camera.setAngle(random(1, 359));
- break;
- }
- }catch (Exception e) {}
- return;
- }
- public void mouseObserve()
- {
- int mouseSpeed = random(5,8);
- mouse.setSpeed(mouseSpeed);
- if(random(0,2) == 0)
- {
- RSObject o = getRandomObject();
- if(o != null)
- {
- RSTile t = (o.getLocation());
- mouse.click(calc.tileToScreen(t),false);
- if(menu.isOpen())
- {
- sleep(500,800+menu.getSize()*80+random(-10,+10));
- while(menu.isOpen())
- {
- if(random(0,101) <= 10)
- {
- mouseExamine();
- }
- else
- mouseMoveDownMenu();
- moveMouseOffMenu();
- }
- }
- }
- }
- else
- {
- RSPlayer p = getRandomPlayer();
- if(p != null)
- {
- RSTile t = (p.getLocation());
- mouse.click(calc.tileToScreen(t),false);
- sleep(900,1500);
- if(menu.isOpen())
- {
- sleep(500,800+menu.getSize()*80+random(-10,+10));
- while(menu.isOpen())
- {
- mouseMoveDownMenu();
- moveMouseOffMenu();
- }
- }
- }
- }
- }
- public void mouseExamine()
- {
- if(menu.isOpen())
- {
- menu.doAction("Examine");
- }
- sleep(300,600);
- }
- public void mouseMoveDownMenu()
- {
- mouse.setSpeed(random(5,8));
- Point b = menu.getLocation();
- if(menu.isOpen())
- {
- int x = b.x;
- int y = b.y;
- int x2 = (x+218);
- int y2 = 0;y2 = y2+menu.getSize()*17;
- mouse.move(random(x,x2),random(y+30,y2));
- }
- sleep(800,2300);
- }
- public void moveMouseOffMenu()
- {
- Point b = menu.getLocation();
- if(menu.isOpen())
- {
- int x = b.x;
- int y = b.y;
- if(random(0,2)==0)
- {
- x = x+random(-20,-50);
- }
- else
- {
- x = (x+218)+random(+20,+50);
- }
- if(random(0,2)==0)
- {
- y = y+random(-20,-50);
- }
- else
- {
- y = (y+menu.getSize()*17)+random(+20,+50);
- }
- mouse.move(x,y);
- sleep(random(100,400));
- }
- }
- public RSObject getRandomObject()
- {
- RSObject[] o = objects.getAll();
- RSObject op = o[random(0,o.length)];
- if(o.length <= 1)
- return null;
- long timeStart = mTime();
- while(!op.isOnScreen() && op.getModel() == null)
- {
- if(mTime() - timeStart >= 2000)
- return null;
- op = o[random(0,o.length)];
- }
- return op;
- }
- public RSPlayer getRandomPlayer()
- {
- RSPlayer[] p = players.getAll();
- RSPlayer rp = p[random(0,p.length)];
- if(p.length <= 1)
- return null;
- long timeStart = mTime();
- while(!rp.isOnScreen() && rp.getName() == getMyPlayer().getName())
- {
- if(mTime() - timeStart >= 2000)
- return null;
- rp = p[random(0,p.length)];
- }
- if(rp == null)
- return null;
- return rp;
- }
- private long mTime()
- {
- return System.currentTimeMillis();
- }
- public void onRepaint(Graphics g) {
- if (game.isLoggedIn()) {
- long runTime = System.currentTimeMillis() - startTime;
- int seconds = (int) (runTime / 1000 % 60);
- int minutes = (int) (runTime / 1000 / 60) % 60;
- int hours = (int) (runTime / 1000 / 60 / 60) % 60;
- StringBuilder b = new StringBuilder();
- if (hours < 10) {
- b.append('0');
- }
- b.append(hours);
- b.append(':');
- if (minutes < 10) {
- b.append('0');
- }
- b.append(minutes);
- b.append(':');
- if (seconds < 10) {
- b.append('0');
- }
- b.append(seconds);
- if (startLvl <= 0 || startExp <= 0) {
- startLvl = skills.getCurrentLevel(Skills.SMITHING);
- startExp = skills.getCurrentExp(Skills.SMITHING);
- }
- int x = 294;
- int y = 4;
- int xl = 222;
- int yl = 85;
- g.setColor(new Color(0, 0, 0, 120));
- g.fillRect(x, y, xl, yl);
- g.setColor(new Color(248, 237, 22));
- g.drawRect(x, y, xl, yl);
- g.setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
- g.drawString(getClass().getAnnotation(ScriptManifest.class).name()
- + " v"
- + getClass().getAnnotation(ScriptManifest.class).version(),
- x + 10, y += 15);
- g.drawString(
- "Gained: "
- + (skills.getCurrentExp(Skills.SMITHING) - startExp < 1000 ? skills
- .getCurrentExp(Skills.SMITHING) - startExp
- : Math.round((skills
- .getCurrentExp(Skills.SMITHING) - startExp) * 10) / 10)
- + " Exp"
- + " || Exp/Hour: "
- + (int) ((skills.getCurrentExp(Skills.SMITHING) - startExp) * 3600000D / ((double) System
- .currentTimeMillis() - (double) startTime)),
- x + 10, y += 15);
- g.drawString("Smelted: " + (Math.round(((skills.getCurrentExp(Skills.SMITHING) - startExp < 1000 ? skills
- .getCurrentExp(Skills.SMITHING) - startExp
- : Math.round((skills
- .getCurrentExp(Skills.SMITHING) - startExp) * 10) / 10)) / 56.2)) + " Gold" + " Bars",
- x + 10, y += 15);
- g.drawString("Time Running: " + b, x + 10, y += 15);
- g.drawString("Current State: ", x + 10, y += 15);
- g.setColor(Color.RED);
- g.drawString(state, x + 95, y);
- }
- }
- }
Add Comment
Please, Sign In to add comment