Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics2D;
- import java.awt.Polygon;
- import java.awt.Rectangle;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.HashSet;
- import java.util.Random;
- import org.osbot.rs07.api.Bank;
- import org.osbot.rs07.api.Camera;
- import org.osbot.rs07.api.Configs;
- import org.osbot.rs07.api.Dialogues;
- import org.osbot.rs07.api.Inventory;
- import org.osbot.rs07.api.LocalWalker;
- import org.osbot.rs07.api.NPCS;
- import org.osbot.rs07.api.Objects;
- import org.osbot.rs07.api.Skills;
- import org.osbot.rs07.api.Widgets;
- import org.osbot.rs07.api.filter.Filter;
- import org.osbot.rs07.api.map.Position;
- import org.osbot.rs07.api.model.NPC;
- import org.osbot.rs07.api.model.Player;
- import org.osbot.rs07.api.model.RS2Object;
- import org.osbot.rs07.api.ui.RS2Widget;
- import org.osbot.rs07.api.ui.Skill;
- import org.osbot.rs07.api.util.ExperienceTracker;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- @ScriptManifest(name="Blast 4 dayz", author="Dubzieisme23", version=1.0, info="", logo="")
- public class Blast
- extends Script
- {
- private long startTime;
- private long timeElapsed;
- private long startTime1;
- private long timeElapsed1;
- private boolean paid;
- public int count;
- public long timerM;
- public long timerS;
- private long minute;
- private long second;
- private int coalBelt;
- private int ironBelt;
- private int barsMade;
- private int coalPrice;
- private int ironPrice;
- private int barPrice;
- private int profit;
- public Blast.Area bridgeArea;
- public Blast()
- {
- this.paid = true;
- this.count = 0;
- this.coalBelt = 0;
- this.ironBelt = 0;
- this.barsMade = 0;
- this.bridgeArea = new Blast.Area(1940, 4967, 1942, 4967);
- }
- class Constants
- {
- public static final int coal = 453;
- public static final int iron = 440;
- public static final int ironBar = 2351;
- public static final int steelBar = 2353;
- Constants() {}
- }
- static class Random
- {
- public static final Random random = new Random();
- public static final int getPerHour(double a, long a1)
- {
- return (int)(a * 3600000.0D / a1);
- }
- public static int nextInt(int a, int a1)
- {
- return a1 < a ? a1 + nextInt(a - a1) : a + (a1 == a ? 0 : nextInt(a1 - a));
- }
- public static long nextLong(long a)
- {
- return (random.nextDouble() * a);
- }
- public static long nextLong(long a, long a1)
- {
- return a1 < a ? a1 + nextLong(a - a1) : a + (a1 == a ? 0L : nextLong(a1 - a));
- }
- public static int nextInt(int a)
- {
- return (int)(random.nextDouble() * a);
- }
- }
- class Area
- {
- private final Polygon area;
- private int z;
- public Area(Position... tiles)
- {
- this.area = new Polygon();
- for (Position tile : tiles)
- {
- this.area.addPoint(tile.getX(), tile.getY());
- this.z = tile.getZ();
- }
- }
- public Area(Position ne, Position sw)
- {
- this(new Position[] { new Position(Math.max(ne.getX(), sw.getX()) + 1, Math.max(ne.getY() + 1, sw.getY()), ne.getZ()), new Position(
- Math.max(ne.getX(), sw.getX()) + 1, Math.min(ne.getY(), sw.getY()), ne.getZ()), new Position(
- Math.min(ne.getX(), sw.getX()), Math.min(ne.getY(), sw.getY()), ne.getZ()), new Position(
- Math.min(ne.getX(), sw.getX()), Math.max(ne.getY(), sw.getY() + 1), ne.getZ()) });
- this.z = ne.getZ();
- }
- public Area(int x1, int y1, int x2, int y2)
- {
- this(x1, y1, x2, y2, 0);
- }
- public Area(int x1, int y1, int x2, int y2, int z)
- {
- this(new Position(x1 > x2 ? x1 : x2, y1 > y2 ? y1 : y2, z), new Position(x1 > x2 ? x2 : x1, y1 > y2 ? y2 : y1, z));
- this.z = z;
- }
- public Position[] getTiles()
- {
- HashSet<Position> tiles = new HashSet();
- Rectangle areaBounds = this.area.getBounds();
- for (int x = areaBounds.x; x <= areaBounds.x + areaBounds.width; x++) {
- for (int y = areaBounds.y; y <= areaBounds.y + areaBounds.height; y++) {
- if (this.area.contains(x, y)) {
- tiles.add(new Position(x, y, this.z));
- }
- }
- }
- return (Position[])tiles.toArray(new Position[tiles.size()]);
- }
- public Position getRandomTile()
- {
- Position[] tiles = getTiles();
- new Blast.Random();return tiles[Blast.Random.nextInt(0, tiles.length - 1)];
- }
- public boolean contains(int x, int y)
- {
- return this.area.contains(x, y);
- }
- public boolean contains(Position tile)
- {
- return (contains(tile.getX(), tile.getY())) && ((this.z < 0) || (tile.getZ() == this.z));
- }
- }
- public void onStart()
- {
- log("What's gucci?");
- this.startTime = System.currentTimeMillis();
- this.startTime1 = System.currentTimeMillis();
- GrandExchange ge = new GrandExchange();
- try
- {
- this.coalPrice = ge.getBuyingPrice(453);
- this.ironPrice = ge.getBuyingPrice(440);
- this.barPrice = ge.getBuyingPrice(2353);
- }
- catch (IOException e)
- {
- log("cant grab");
- }
- }
- public void onExit()
- {
- log("Bye nigga");
- }
- public void checkTime()
- {
- if (getSkills().getStatic(Skill.SMITHING) < 60)
- {
- if ((this.timerM == 10L) && (this.timerS == 0L))
- {
- log("reset");
- this.paid = false;
- }
- }
- else {
- log("nothing");
- }
- }
- public void checkFailure()
- {
- if (this.inventory.contains(new int[] { 440 })) {
- this.ironBelt -= 27;
- }
- if (this.inventory.contains(new int[] { 453 })) {
- this.coalBelt -= 27;
- }
- }
- public void resetTime()
- {
- if (getSkills().getStatic(Skill.SMITHING) < 60)
- {
- this.startTime1 = System.currentTimeMillis();
- this.paid = true;
- }
- else
- {
- log("nothing");
- }
- }
- public int getOptionCount()
- {
- RS2Widget var0;
- return this.dialogues.isPendingOption() ? 0 : ((var0 = this.widgets.get(219, 0)) != null) && (var0.isVisible()) ? var0.getChildWidgets().length - 3 : 0;
- }
- public RS2Widget getNPCChatWidget()
- {
- RS2Widget var0;
- return ((var0 = this.widgets.get(219, 0)) != null) && (var0.isVisible()) ? var0 : null;
- }
- public ArrayList<String> getOptions()
- {
- ArrayList var1 = new ArrayList();
- RS2Widget var0;
- if ((var0 = getNPCChatWidget()) != null)
- {
- RS2Widget[] var5;
- int var4 = (var5 = var0.getChildWidgets()).length;
- int var3;
- for (int var6 = var3 = 0; var6 < var4; var6 = var3)
- {
- RS2Widget var2;
- if ((!(var2 = var5[var3]).getMessage().equals("")) && (var2.getTextColor() == 0)) {
- var1.add(var2.getMessage());
- }
- var3++;
- }
- }
- return var1;
- }
- public void pay()
- throws InterruptedException
- {
- log("pay");
- NPC Man = (NPC)this.npcs.closest(new Filter[] { new Filter()
- {
- public boolean match(NPC npc)
- {
- return npc.getName().equals("Blast Furnace Foreman");
- }
- } });
- if (Man != null)
- {
- log("!=null");
- if (getDialogues().isPendingOption())
- {
- getDialogues().selectOption(1);
- resetTime();
- }
- else
- {
- Man.interact(new String[] { "Pay" });
- sleep(1000L);
- }
- }
- }
- public int onLoop()
- throws InterruptedException
- {
- if ((this.dialogues.inDialogue()) && (this.dialogues.isPendingContinuation())) {
- this.dialogues.clickContinue();
- }
- if (this.paid)
- {
- if ((this.coalBelt == 0) || ((this.coalBelt == 27) && (this.ironBelt == 0)))
- {
- if ((!this.inventory.contains(new int[] { 453 })) || (this.coalBelt != 0))
- {
- if ((!this.inventory.contains(new int[] { 440 })) || (this.coalBelt != 27)) {}
- }
- else
- {
- log("start");
- if (!this.dialogues.isPendingContinuation())
- {
- log("2nd");
- if (getWidgets().get(28, 0) != null) {
- getWidgets().get(28, 118).interact(new String[] { "Close" });
- }
- if (getBank().isOpen()) {
- getBank().close();
- }
- RS2Object conveyor = (RS2Object)getObjects().closest(new Filter[] { new Filter()
- {
- public boolean match(RS2Object object)
- {
- if ((object != null) && (object.getName() != null) && (object.getName().equals("Conveyor belt"))) {
- if (object.hasAction(new String[] { "Put-ore-on" })) {
- return true;
- }
- }
- return false;
- }
- } });
- if (!myPlayer().isMoving()) {
- if (this.dialogues.isPendingOption())
- {
- if (this.dialogues.selectOption(new String[] { "Yes" }))
- {
- if (this.inventory.contains(new int[] { 453 })) {
- this.coalBelt += 27;
- } else if (this.inventory.contains(new int[] { 440 })) {
- this.ironBelt += 27;
- }
- sleep(random(1000, 2000));
- }
- }
- else if ((conveyor != null) && ((conveyor.getPosition().distance(myPlayer()) < 8) || (this.bridgeArea.contains(myPlayer().getPosition()))))
- {
- conveyor.interact(new String[] { "Put-ore-on" });
- sleep(random(1000, 2000));
- }
- else
- {
- log("fuck me");
- log(this.bridgeArea.getRandomTile());
- this.localWalker.walk(this.bridgeArea.getRandomTile());
- sleep(random(2000, 3000));
- }
- }
- break label1546;
- }
- if (!getDialogues().isPendingContinuation()) {
- break label1546;
- }
- log("here");
- if (this.widgets.getWidgetContainingText(new String[] { "You must ask the foreman's permission" }) == null) {
- break label1546;
- }
- this.paid = false;
- break label1546;
- }
- if ((!this.inventory.contains(new int[] { 453 })) && (this.coalBelt == 0))
- {
- RS2Object gameObject = (RS2Object)this.objects.closest(new String[] { "Bank chest" });
- if (this.inventory.isEmptyExcept(new int[] { 995 })) {
- if (((RS2Object)this.objects.closest(new int[] { 26707 })).getPosition().distance(myPlayer()) >= 4)
- {
- this.localWalker.walk(this.objects.closest(new int[] { 26707 }));
- this.camera.toEntity(gameObject);
- }
- else if (!this.bank.isOpen())
- {
- gameObject.interact(new String[] { "Use" });
- sleep(1000L);
- if (this.widgets.get(402, 2) != null) {
- this.widgets.get(402, 2, 11).interact(new String[] { "Close" });
- }
- }
- else
- {
- this.bank.withdrawAll(453);
- }
- }
- }
- else if ((!this.inventory.contains(new int[] { 440 })) && (this.coalBelt == 27) && (this.ironBelt == 0))
- {
- RS2Object gameObject = (RS2Object)this.objects.closest(new String[] { "Bank chest" });
- if (this.inventory.isEmptyExcept(new int[] { 995 })) {
- if (((RS2Object)this.objects.closest(new int[] { 26707 })).getPosition().distance(myPlayer()) >= 4)
- {
- this.localWalker.walk(this.objects.closest(new int[] { 26707 }));
- this.camera.toEntity(gameObject);
- }
- else if (!this.bank.isOpen())
- {
- gameObject.interact(new String[] { "Use" });
- sleep(1000L);
- if (this.widgets.get(402, 2) != null) {
- this.widgets.get(402, 2, 11).interact(new String[] { "Close" });
- }
- }
- else
- {
- this.bank.withdrawAll(440);
- }
- }
- }
- }
- else
- {
- log("waiting on bars");
- if (!this.inventory.contains(new int[] { 2353 }))
- {
- RS2Object Disp = (RS2Object)this.objects.closest(new int[] { 9092 });
- checkFailure();
- checkTime();
- if (Disp.hasAction(new String[] { "Search" }))
- {
- log("Waiting");
- if (((RS2Object)this.objects.closest(new int[] { 9092 })).getPosition().distance(myPlayer()) >= 3) {
- this.localWalker.walk(this.objects.closest(new int[] { 9092 }));
- }
- Disp.hover();
- return random(500, 1000);
- }
- if (Disp.hasAction(new String[] { "Take" })) {
- if (getWidgets().get(28, 0) != null)
- {
- if (this.configs.get(545) > 0) {
- if (this.configs.get(545) < 65536) {
- getWidgets().get(28, 109).interact(new String[] { "Take" });
- } else {
- getWidgets().get(28, 110).interact(new String[] { "Take" });
- }
- }
- sleep(random(1000, 2000));
- getWidgets().get(28, 118).interact(new String[] { "Close" });
- }
- else if (Disp != null)
- {
- if (Disp.hasAction(new String[] { "Take" }))
- {
- Disp.interact(new String[] { "Take" });
- sleep(random(1000, 2500));
- }
- }
- }
- }
- else if (this.inventory.contains(new int[] { 2353 }))
- {
- RS2Object gameObject = (RS2Object)this.objects.closest(new String[] { "Bank chest" });
- if (((RS2Object)this.objects.closest(new int[] { 26707 })).getPosition().distance(myPlayer()) >= 4)
- {
- this.localWalker.walk(this.objects.closest(new int[] { 26707 }));
- this.camera.toEntity(gameObject);
- }
- else if (!this.bank.isOpen())
- {
- gameObject.interact(new String[] { "Use" });
- sleep(1000L);
- }
- else
- {
- this.bank.depositAllExcept(new int[] { 995 });
- this.coalBelt = 0;
- this.ironBelt = 0;
- this.barsMade += 27;
- }
- }
- }
- }
- else if (!this.paid) {
- if (this.inventory.contains(new int[] { 995 }))
- {
- log("have to pay");
- pay();
- }
- else
- {
- log("get coins");
- stop();
- }
- }
- label1546:
- checkTime();
- return 100;
- }
- public void onPaint(Graphics2D g)
- {
- int exp = this.experienceTracker.getGainedXP(Skill.MAGIC);
- this.timeElapsed = (System.currentTimeMillis() - this.startTime);
- this.timeElapsed1 = (System.currentTimeMillis() - this.startTime1);
- this.second = (this.timeElapsed / 1000L % 60L);
- this.minute = (this.timeElapsed / 60000L % 60L);
- long hour = this.timeElapsed / 3600000L % 24L;
- this.timerS = (this.timeElapsed1 / 1000L % 60L);
- this.timerM = (this.timeElapsed1 / 60000L % 60L);
- this.profit = (this.barPrice - (this.ironPrice + this.coalPrice));
- g.drawString("Runtime: " + hour + ":" + this.minute + ":" + this.second, 17, 358);
- g.drawString("Paid: " + this.paid, 17, 370);
- g.drawString("Timer: 0:" + this.timerM + ":" + this.timerS, 17, 390);
- g.drawString("Coal: " + this.coalBelt, 400, 358);
- g.drawString("Iron: " + this.ironBelt, 400, 370);
- g.drawString("Bars: " + this.barsMade, 400, 382);
- g.drawString("Bars/H: " + (int)(this.barsMade * 3600000.0D / this.timeElapsed), 400, 394);
- g.drawString("Proft/H: " + (int)(this.barsMade * this.profit * 3600000.0D / this.timeElapsed), 400, 406);
- g.drawString("Coal Price: " + this.coalPrice, 400, 40);
- g.drawString("Iron Price: " + this.ironPrice, 400, 52);
- g.drawString("Bar Price: " + this.barPrice, 400, 64);
- g.drawString("Profit Per: " + this.profit, 400, 76);
- g.drawString("Profit: " + this.profit * this.barsMade, 400, 418);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement