Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.util.HashSet;
- import java.util.Iterator;
- import java.util.Set;
- import java.awt.*;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.script.*;
- import org.rsbot.script.methods.Game;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.script.util.Timer;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.methods.GrandExchange;
- @ScriptManifest(authors = "Havefunpeeps", keywords = "Harpoons", name = "FunHarpoonBuyer", version = 1.02, description = "Buys Harpoons")
- public class HarpoonBuyer extends Script implements PaintListener, MessageListener {
- private enum State {
- BANK, WALKTOBANK, WALKTOFISHER, BUYHARPOONS, TOGGLERUN, FAILSAFE1, WAIT
- }
- public boolean onStart(){
- mouse.setSpeed(random(6, 10));
- startTime = System.currentTimeMillis();
- HarpoonPrice = grandExchange.lookup(HarpoonID).getGuidePrice();
- log("The Current Version Script you are running is 1.00. Check the forum page for updates");
- log("Start Script by the Fishing shop in Port Sarim. Good Luck on making Cash");
- return true;
- }
- //items//
- int HarpoonID = 311;
- int CoinID = 995;
- int DepBoxID = 36788;
- int FishGuyID = 558;
- int DoorOpenID = 40109;
- int DoorClosedID = 40108;
- int CoinsID = 995;
- private int nextMinRunEnergy = random(20, 50);
- //tiles//
- RSTile DoorTileOutside = new RSTile(3013, 3219);
- RSTile DepBoxTile = new RSTile(3047, 3236);
- RSTile DoorTileInside = new RSTile(3013, 3220);
- RSTile StoreTile = new RSTile(3014, 3224);
- RSTile[] PathToBank = {new RSTile(3013, 3219), new RSTile(3019, 3218), new RSTile(3026, 3218), new RSTile(3027, 3223), new RSTile(3027, 3229), new RSTile(3033, 3235), new RSTile(3037, 3235), new RSTile(3044, 3236), new RSTile(3046, 3236)};
- RSTile[] PathToFisher = {new RSTile(3041, 3236), new RSTile(3036, 3236), new RSTile(3031, 3236), new RSTile(3028, 3233), new RSTile(3028, 3228), new RSTile(3027, 3220), new RSTile(3023, 3218), new RSTile(3016, 3219), new RSTile(3013, 3218)};
- //areas//
- RSArea StoreArea = new RSArea(new RSTile(3011, 3220), new RSTile(3016, 3229));
- RSArea BoothArea = new RSArea(new RSTile(3042, 3235), new RSTile(3051, 3237));
- RSArea DoorArea = new RSArea(new RSTile(3008, 3216), new RSTile(3018, 3219));
- RSArea FailSafe1Area = new RSArea(new RSTile(3006, 3217), new RSTile(3010, 3224));
- //walking
- public long startTime = 0;
- public long millis = 0;
- public long hours = 0;
- public long minutes = 0;
- public long seconds = 0;
- public long last = 0;
- private int Trips;
- private int Harpoons;
- private int TripsHour;
- private int HarpoonsHour;
- private int Profit;
- private int ProfitHour;
- private int HarpoonPrice;
- private State getState() {
- if (!walking.isRunEnabled() && walking.getEnergy() >= nextMinRunEnergy) {
- return State.TOGGLERUN;
- }
- if(inventory.contains(HarpoonID) && BoothArea.contains(players.getMyPlayer().getLocation())) {
- return State.BANK;
- }
- if(inventory.contains(HarpoonID) && !BoothArea.contains(players.getMyPlayer().getLocation())) {
- return State.WALKTOBANK;
- }
- if(StoreArea.contains(players.getMyPlayer().getLocation()) && !inventory.contains(HarpoonID)) {
- return State.BUYHARPOONS;
- }
- if(!inventory.contains(HarpoonID) && !StoreArea.contains(players.getMyPlayer().getLocation())) {
- return State.WALKTOFISHER;
- }
- return State.WAIT;
- }
- private boolean walkPath(RSTile[] path) {
- if (calc.distanceTo(path[path.length - 1]) > 4) {
- RSTile n = getNext(path);
- if(n!=null){
- walking.walkTileMM(n.randomize(2, 2));
- if(random(1,6) != 2){
- mouse.moveRandomly(20);
- }
- }
- }
- return false;
- }
- private RSTile getNext(RSTile[] path) {
- boolean found = false;
- for (int a = 0; a < path.length&&!found; a++) {
- if(calc.tileOnMap(path[path.length-1-a])){
- found = true;
- return path[path.length-1-a];
- }
- }
- return null;
- }
- public void antiBanCamera() {
- int randomNumber3 = random(1, 40);
- if (randomNumber3 == 1 || randomNumber3 == 2 || randomNumber3 == 3) {
- camera.setPitch(random(40, 68));
- }
- if (randomNumber3 == 4 || randomNumber3 == 5 || randomNumber3 == 6) {
- camera.moveRandomly(random(800, 1200));
- }
- if (randomNumber3 == 7 || randomNumber3 == 8 || randomNumber3 == 9) {
- camera.setAngle(random(10, 50));
- }
- if (randomNumber3 == 10 || randomNumber3 == 11) {
- camera.setPitch(true);
- }
- if (randomNumber3 == 12 || randomNumber3 == 13) {
- camera.setPitch(false);
- }
- if (randomNumber3 == 14) {
- camera.moveRandomly(random(400, 800));
- }
- if (randomNumber3 == 15) {
- camera.setAngle(random(5, 40));
- sleep(random(200, 300));
- }
- if (randomNumber3 > 15 && randomNumber3 < 30) {
- camera.setPitch(true);
- }
- if (randomNumber3 > 29) {
- camera.moveRandomly(random(200, 800));
- }
- }
- public int loop() {
- mouse.setSpeed(random(6, 12));
- final State state = getState();
- switch (state) {
- case TOGGLERUN:
- walking.setRun(true);
- sleep(200, 400);
- nextMinRunEnergy = random(27, 40);
- break;
- case WALKTOBANK:
- if(DoorC != null && StoreArea.contains(players.getMyPlayer().getLocation())) {
- DoorC.doAction("Open");
- }
- walkPath(PathToBank);
- sleep(random(1200, 1500));
- antiBanCamera();
- sleep(1000, 2000);
- break;
- case WALKTOFISHER:
- walkPath(PathToFisher);
- sleep(random(1200, 1500));
- RSObject DoorC = objects.getNearest(DoorClosedID);
- if(DoorC != null && DoorArea.contains(players.getMyPlayer().getLocation())) {
- DoorC.doAction("Open");
- if(!players.getMyPlayer().isMoving()) {
- walking.walkTileMM(StoreTile, 2, 2);
- }
- }
- if(DoorC == null) {
- walking.walkTileMM(StoreTile, 2, 2);
- camera.moveRandomly(300);
- }
- antiBanCamera();
- sleep(1000, 2000);
- break;
- case BANK:
- RSObject DepBox = objects.getNearest(DepBoxID);
- RSItem Harpoon2 = inventory.getItem(HarpoonID);
- bank.openDepositBox();
- sleep(400, 599);
- bank.deposit(HarpoonID, 0);
- bank.close();
- break;
- case BUYHARPOONS:
- RSNPC Fisher = npcs.getNearest(FishGuyID);
- RSItem Harpoon = inventory.getItem(HarpoonID);
- if(Fisher != null) {
- if(!players.getMyPlayer().isMoving()) {
- Fisher.doAction("Trade");
- sleep(400, 600);
- }
- }
- if(store.isOpen()) {
- store.buy(HarpoonID, 50);
- sleep(300, 400);
- }
- break;
- case FAILSAFE1:
- walking.walkTileMM(DoorTileOutside, 2, 2);
- break;
- }
- return random(100, 600);
- }
- public void messageReceived(MessageEvent e) {
- String x = e.getMessage().toLowerCase();
- if (x.contains("enough inventory")){
- Trips++;
- }
- }
- //START: Code generated using Enfilade's Easel
- private final Color color1 = new Color(51, 255, 51, 123);
- private final Color color2 = new Color(0, 0, 0);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 9);
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- Harpoons = Trips * 27;
- TripsHour = (int) ((Trips) * 3600000D / (System.currentTimeMillis() - startTime));
- HarpoonsHour = (int) ((Harpoons) * 3600000D / (System.currentTimeMillis() - startTime));
- Profit = HarpoonPrice * Harpoons;
- ProfitHour = HarpoonPrice * HarpoonsHour;
- g.setColor(color1);
- g.fillRoundRect(351, 160, 166, 178, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(351, 160, 166, 178, 16, 16);
- g.setFont(font1);
- g.drawString("Time Ran: "+ hours +":"+ minutes + ":" + seconds, 364, 210);
- g.drawString("Harpoons Bought: " +Harpoons, 363, 227);
- g.drawString("Trips Taken: " +Trips, 363, 268);
- g.drawString("Harpoons Per Hour: " +HarpoonsHour, 364, 248);
- g.drawString("Trips Per Hour: " +TripsHour, 363, 291);
- g.drawString("Profit: " +Profit, 362, 310);
- g.drawString("Profit Per Hour: " +ProfitHour, 360, 329);
- }
- //END: Code generated using Enfilade's Easel
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement