Advertisement
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 java.awt.Polygon;
- import java.util.ArrayList;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.*;
- @ScriptManifest(
- authors = ("ibotlots"),
- version = 1.0,
- keywords = "Blast",
- description = "Makes Mithril Bolts at the Blast Furnace",
- name = "Blast Furnace"
- )
- public class BlastFurnace extends Script implements PaintListener{
- //ID'S.
- private int coaln = 454;
- private int mithn = 448;
- private int barID = 2359;
- private int mith = 447;
- private int coal = 453;
- private int hammer = 2347;
- private int bolts = 9379;
- private int money = 995;
- private int lol = 1;
- private long startTime = 0;
- private int barcount = 0;
- @Override
- public boolean onStart(){
- startTime = System.currentTimeMillis();
- log("Started Up");
- return true;
- }
- @Override
- public int loop() {
- while( lol > 0){
- RSItem Mith = inventory.getItem(448);
- RSItem Coal = inventory.getItem(454);
- RSNPC Ordan = npcs.getNearest("Ordan");
- RSObject Belt = objects.getNearest(9100);
- RSObject Dispenser = objects.getNearest(9092);
- RSObject Anvil = objects.getNearest(17073);
- RSTile beltTile = new RSTile(1943,4967);
- RSTile ordanTile = new RSTile(1936, 4966);
- RSTile dispenserTile = new RSTile(1940,4963);
- RSTile anvilTile = new RSTile(1938,4971);
- inventory.dropAllExcept(mithn,coaln,barID,mith,coal,hammer,bolts,money);
- if(!inventory.containsAll(mithn,coaln,money,hammer)){
- log("Out of Ore or Cash or Hammers");
- lol = -1;
- }
- if(lol < 0){
- return(0);
- }
- if(lol==1){
- //Stage 1 - Un-noting Mithril
- if(Ordan.isOnScreen() && inventory.getCount() < 6){
- Mith.doAction("Use"); // Select mithril notes
- sleep(random(20,150));
- clickNPC(Ordan, "Use Mithril ore ->", false); // Use mithril on Ordan
- sleep(random(3000,5000));
- if(interfaces.get(232).isValid()){
- interfaces.get(232).getComponent(5).doClick(); // Click X
- sleep(random(1500,2000));
- keyboard.sendText("23", true); //Type 23
- sleep(random(1500,2000));
- interfaces.get(241).getComponent(5).doClick(); //Click Continue
- sleep(random(1500,2000));
- interfaces.get(228).getComponent(2).doClick(); //It's a deal!
- sleep(random(1500,2000));
- interfaces.get(64).getComponent(5).doClick(); //Click to Continue
- sleep(random(1000,1500));
- }
- }
- else if(inventory.getCount()>25){
- lol = 2;
- }
- else {
- walking.walkTileOnScreen(ordanTile);
- sleep(random(1000,2000));
- }
- }
- if(lol==2){
- //Placing Mithril on Belt
- if(Belt.isOnScreen()){
- Belt.doClick();
- sleep(random(3000,5000));
- interfaces.get(228).getComponent(2).doClick(); //Yes
- sleep(random(2000,3000));
- if(inventory.getCount()<=5){
- lol=3;
- }
- }
- else {
- walking.walkTileOnScreen(beltTile);
- sleep(random(1000,2000));
- }
- }
- if(lol==3){
- //Stage 3 - Un-noting Coal
- if(Ordan.isOnScreen() && inventory.getCount() < 6){
- Coal.doAction("Use"); // Select coal notes
- sleep(random(20,150));
- clickNPC(Ordan, "Use Coal ->", false); // Use coal on Ordan
- sleep(random(3000,5000));
- if(interfaces.get(232).isValid()){
- interfaces.get(232).getComponent(5).doClick(); // Click X
- sleep(random(1500,2000));
- keyboard.sendText("23", true); //Type 23
- sleep(random(1500,2000));
- interfaces.get(241).getComponent(5).doClick(); //Click Continue
- sleep(random(1500,2000));
- interfaces.get(228).getComponent(2).doClick(); //It's a deal!
- sleep(random(1500,2000));
- interfaces.get(64).getComponent(5).doClick(); //Click to Continue
- sleep(random(1000,1500));
- }
- }
- else if(inventory.getCount()>25){
- lol = 4;
- }
- else {
- walking.walkTileOnScreen(ordanTile);
- sleep(random(1000,2000));
- }
- }
- if(lol==4){
- //Placing Coal on Belt
- if(Belt.isOnScreen()){
- Belt.doClick();
- sleep(random(3000,5000));
- interfaces.get(228).getComponent(2).doClick(); //Yes
- sleep(random(2000,3000));
- if(inventory.getCount()<=5){
- lol=5;
- }
- }
- else {
- walking.walkTileOnScreen(beltTile);
- sleep(random(1000,2000));
- }
- }
- if(lol==5){
- //Stage 5 - Un-noting Coal Again
- if(Ordan.isOnScreen() && inventory.getCount() < 6){
- Coal.doAction("Use"); // Select coal notes
- sleep(random(20,150));
- clickNPC(Ordan, "Use Coal ->", false); // Use coal on Ordan
- sleep(random(3000,5000));
- if(interfaces.get(232).isValid()){
- interfaces.get(232).getComponent(5).doClick(); // Click X
- sleep(random(1500,2000));
- keyboard.sendText("23", true); //Type 23
- sleep(random(1500,2000));
- interfaces.get(241).getComponent(5).doClick(); //Click Continue
- sleep(random(1500,2000));
- interfaces.get(228).getComponent(2).doClick(); //It's a deal!
- sleep(random(1500,2000));
- interfaces.get(64).getComponent(5).doClick(); //Click to Continue
- sleep(random(1000,1500));
- }
- }
- if(inventory.getCount()>25){
- lol = 6;
- }
- else {
- walking.walkTileOnScreen(ordanTile);
- sleep(random(1000,2000));
- }
- }
- if(lol==6){
- //Placing Coal on Belt Again
- if(Belt.isOnScreen()){
- Belt.doClick();
- sleep(random(3000,5000));
- interfaces.get(228).getComponent(2).doClick(); //Yes
- sleep(random(2000,3000));
- if(inventory.getCount()<=5){
- lol=7;
- }
- }
- else {
- walking.walkTileOnScreen(beltTile); //Walk to belt if not on screen
- sleep(random(1000,2000));
- }
- }
- if(lol==7){
- while(!Dispenser.isOnScreen()){ //Walk to dispenser if it's not on screen
- walking.walkTileOnScreen(dispenserTile);
- }
- while(inventory.getCount()<25){ //Picking up bars
- sleep(random(5000,10000));
- Dispenser.doClick();
- sleep(random(1000,2000));
- if(interfaces.get(28).getComponent(34).containsText("23")){
- interfaces.get(28).getComponent(35).doClick();
- sleep(random(1000,2000));
- }
- interfaces.get(28).getComponent(12).doClick();
- }
- lol = 8;
- }
- if(lol==8){
- //Smithing the bars
- if(Anvil.isOnScreen()&& getMyPlayer().isIdle()){
- if(!interfaces.get(300).isValid()){
- RSItem Bar = inventory.getItem(barID);
- Bar.doAction("Use"); // Select a bar
- sleep(random(1500,2000));
- Anvil.doAction("Use Mithril bar -> Anvil");
- sleep(random(3000,4000));
- if(interfaces.get(300).isValid()){
- interfaces.getComponent(300, 53).doAction("Make All");
- sleep(57000);
- }
- sleep(3000);
- }
- }
- else if(!Anvil.isOnScreen()){
- walking.walkTileOnScreen(anvilTile);
- sleep(random(1000,2000));
- }
- else {
- sleep(random(1000,2000));
- }
- if(inventory.getCount()==5){
- barcount = barcount + 23;
- lol=1;
- }
- }
- }
- return(1);
- }
- public void onFinish() {
- log("All Done");
- }
- private boolean clickNPC(RSNPC npc, String action,
- boolean useCentralClicking) {
- Point p;
- int def = mouse.getSpeed();
- for (int i = 0; i < 4; i++) {
- if (isPartiallyOnScreen(npc.getModel())) {
- p = useCentralClicking ? getCentralPoint(npc.getModel())
- : getPointOnScreen(npc.getModel(), true);
- do {
- p = useCentralClicking ? getCentralPoint(npc.getModel())
- : getPointOnScreen(npc.getModel(), false);
- mouse.move(p, 0, 0);
- } while (isPartiallyOnScreen(npc.getModel()) && p.x != -1
- && p.y != -1 && p != null && calc.pointOnScreen(p)
- && !bank.isOpen()
- && !mouse.getLocation().equals(p)
- && !menu.contains(action));
- String[] items = menu.getItems();
- if (items.length > 0
- && items[0].toLowerCase().startsWith(
- action.toLowerCase())) {
- mouse.click(true);
- return true;
- } else if (menu.contains(action)) {
- mouse.setSpeed(random(6, 9));
- mouse.click(false);
- sleep(random(100, 200));
- for (int x = 0; x < 4; x++) {
- if (menu.doAction(action)) {
- mouse.setSpeed(def);
- return true;
- }
- }
- }
- if (!menu.contains(action) && menu.isOpen()) {
- do {
- mouse.moveRandomly(random(180, 422));
- } while (menu.isOpen());
- sleep(random(75, 220));
- return false;
- }
- }
- }
- return false;
- }
- private boolean isPartiallyOnScreen(RSModel m) {
- return getPointOnScreen(m, true) != null;
- }
- private Point getPointOnScreen(RSModel m, boolean first) {
- if (m == null) {
- return null;
- }
- ArrayList<Point> list = new ArrayList<Point>();
- try {
- Polygon[] tris = m.getTriangles();
- for (int i = 0; i < tris.length; i++) {
- Polygon p = tris[i];
- for (int j = 0; j < p.xpoints.length; j++) {
- Point pt = new Point(p.xpoints[j], p.ypoints[j]);
- if (calc.pointOnScreen(pt)) {
- if (first) {
- return pt;
- }
- list.add(pt);
- }
- }
- }
- } catch (Exception e) {
- }
- return list.size() > 0 ? list.get(random(0, list.size())) : null;
- }
- private Point getCentralPoint(RSModel m) {
- if (m == null) {
- return null;
- }
- try {
- int x = 0, y = 0, total = 0;
- for (Polygon poly : m.getTriangles()) {
- for (int i = 0; i < poly.npoints; i++) {
- x += poly.xpoints[i];
- y += poly.ypoints[i];
- total++;
- }
- }
- Point central = new Point(x / total, y / total);
- Point curCentral = null;
- double dist = 20000;
- for (Polygon poly : m.getTriangles()) {
- for (int i = 0; i < poly.npoints; i++) {
- Point p = new Point(poly.xpoints[i], poly.ypoints[i]);
- if (!calc.pointOnScreen(p)) {
- continue;
- }
- double dist2 = distanceBetween(central, p);
- if (curCentral == null || dist2 < dist) {
- curCentral = p;
- dist = dist2;
- }
- }
- }
- return curCentral;
- } catch (Exception e) {
- }
- return null;
- }
- private double distanceBetween(Point p1, Point p2) {
- return Math.sqrt(((p1.x - p2.x) * (p1.x - p2.x))
- + ((p1.y - p2.y) * (p1.y - p2.y)));
- }
- //PAINT
- @Override
- public void onRepaint(Graphics g) {
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000*60*60);
- millis -= hours * (1000*60*60);
- long minutes = millis / (1000*60);
- millis -= minutes * (1000*60);
- long seconds = millis / 1000;
- long experience = barcount*80;
- long exppersec = experience / (60*60*hours+60*minutes+seconds);
- long exppermin = exppersec / 60;
- long expperhour = exppermin / 60;
- g.setColor(Color.ORANGE);
- g.drawRect(1, 340, 519, 135);
- g.setColor(Color.BLACK);
- g.setFont(new Font("Arial", 0, 12));
- g.drawString("Runetime: "+hours+":"+minutes+":"+seconds,267,372);
- g.drawString("Bars Used: "+barcount, 267, 387);
- g.drawString("Experience Gained: "+experience, 267, 402);
- g.drawString("Experience per Hour: "+expperhour, 267, 417);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement