- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.awt.RenderingHints;
- import java.util.Map;
- import org.rsbot.bot.Bot;
- import org.rsbot.script.*;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.util.ScreenshotUtil;
- import org.rsbot.event.listeners.*;
- @ScriptManifest(authors = {"Invaderzim"}, category = "Other", name = "Invaderzims Camelot Flax Invader", version = 1.0, description = ("<html><body style=\"background-color: #ffffff; color: #0072ff;"
- + "font-family: Arial; text-align: center;\">"
- + "<h2 style=\"margin-bottom: 0px;\">Invaderzim Camelot Flax Invader</h2>"
- + "<h2 style=\"margin-bottom: 0px;\">V1.0.0</h2>"
- + "<strong>By Invaderzim</strong><br /><br />"
- + "Start at the Camelot bank, or the Flax. <br />"
- + "Thanks for using my Flax Collector. Read the ToS at the bottom please.<br />"
- + "<small>Thanks for actually reading my ToS. This script may not be</small><br />"
- + "<small>distributed to any other site nor the code used without my consent. Thanks again <3, now go get some flax!</small><br />")
- + "<input type=\"checkbox\" name=\"bankBox\" value=\"true\" />"
- + "Agree to ToS? If so, check this box, or script won't work properly =).<br />")
- public class IZFlaxInvader extends Script implements PaintListener, ServerMessageListener {
- //Id's N' such
- int flaxID = 1779;
- int bankboothID = 25808;
- int FlaxID = 2646;
- boolean banking = false;
- long runTime = 0;
- long seconds = 0;
- long minutes = 0;
- long hours = 0;
- public int hourLog = 0;
- private int flaxPicked = 0;
- public long startTime = System.currentTimeMillis();
- //Tiles
- RSTile bankTile=new RSTile(2724,3493);
- RSTile flaxTile=new RSTile(2741, 3448);
- RSTile[] toBank;
- RSTile[] toFlax;
- RSTile[]ToFlax = {new RSTile(2724, 3493), new RSTile(2727, 3480),
- new RSTile(2728, 3466), new RSTile(2729, 3453), new RSTile(2740, 3445)}, ToBank;
- public boolean onStart(Map<String, String> args) { //What the script will do when it has been started.
- camera.setAltitude(true);
- ToBank = walking.reversePath(ToFlax);
- log("Thanks for testing my script out, I really appreciate it. =)");
- banking = (args.get("bankbooth") == null) ? false : true;
- return true;
- }
- @Override
- public int loop() {
- if(inventory.isFull()) {
- if(atBank()) {
- bank();
- } else {
- walk(ToBank);
- }
- } else {
- if(atFlax()) {
- pick();
- } else {
- walk(ToFlax);
- }
- }
- return random(150, 250);
- }
- private boolean atFlax() {
- try {
- if(calc.tileOnScreen(objects.getNearest(FlaxID).getLocation())){
- return true;
- }
- return false;
- } catch (Exception e) {
- return false;
- }
- }
- private boolean walk(RSTile[] path) {
- if(calc.distanceTo(walking.getDestination()) < random(2, 4)) {
- if(walking.walkPathMM(path) == true) {
- return false;
- }
- }
- return true;
- }
- private boolean pick() {
- if (getMyPlayer().isIdle()) {
- final RSObject Flax = objects.getNearest(FlaxID);
- if (Flax == null) {
- walking.walkTileMM(walking.getClosestTileOnMap(flaxTile));
- } else if (Flax !=null && calc.distanceTo(Flax)>4) {
- walking.walkTileMM(walking.getClosestTileOnMap(Flax.getLocation()));
- } else {
- Flax.doAction("Pick");
- sleep(200, 500);
- }
- }
- return true;
- }
- private int bank() {
- if (getMyPlayer().isIdle()) {
- final RSObject BBoth = objects.getNearest(bankboothID);
- if (BBoth == null) {
- walking.walkTileMM(walking.getClosestTileOnMap(bankTile));
- } else if (BBoth!=null && calc.distanceTo(BBoth)>4) {
- walking.walkTileMM(walking.getClosestTileOnMap(BBoth.getLocation()));
- } else {
- if (!bank.isOpen()) {
- BBoth.doAction("Use-quickly");
- sleep(1200, 1500);
- bank.depositAll();
- } else {
- }
- }
- }
- return 50;
- }
- private boolean walkBank() {
- return walking.walkPathMM(ToBank);
- }
- private boolean walkFish() {
- return walking.walkPathMM(ToFlax);
- }
- 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;
- //This variable is used for Anti-aliasing. DO NOT DELETE!
- final RenderingHints rh = new RenderingHints(
- RenderingHints.KEY_TEXT_ANTIALIASING,
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- //This paint was made using Enfilade's Paint Maker <3 <3
- ((Graphics2D)g).setRenderingHints(rh);
- g.setColor(new Color(255, 0, 51));
- g.drawRoundRect(250, 350, 225, 125, 4, 4);
- g.setColor(new Color(0, 102, 204));
- g.fillRoundRect(275, 375, 175, 75, 4, 4);
- g.setFont(new Font("Agency FB", 0, 14));
- g.setColor(new Color(0, 0, 0));
- g.drawString("IZFlax Invader V1.0", 300, 390);
- g.setFont(new Font("Agency FB", 0, 13));
- g.setColor(new Color(0, 0, 0));
- g.drawString("Time Running:" + hours + ":" + minutes + ":" + seconds, 300, 425);
- g.setFont(new Font("Agency FB", 0, 13));
- g.setColor(new Color(0, 0, 0));
- g.drawString("Flax Picked:" + flaxPicked, 300, 450);
- }
- public void serverMessageRecieved(ServerMessageEvent e) {
- String txt = e.getMessage();
- if(txt.contains("You pick some")) flaxPicked++;
- }
- @Override
- public void onFinish() { //What the script will do when stopped.
- log("Thanks for using FlaxInvader!");
- }
- private boolean atBank() {
- try {
- if(calc.tileOnScreen(objects.getNearest(bankboothID).getLocation())){
- return true;
- }
- return false;
- } catch (Exception e) {
- return false;
- }
- }
- }