Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.util.Random;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.wrappers.RSComponent;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors = { "evanson and mrfluffy" }, name = "Livid Farmer", description = "Farms the Livid Plants at the Livid Farm", version = 1.00)
- public class LividFarmer extends Script implements PaintListener, MouseListener {
- private int ASTRAL_ID = 9075;
- private int NATURE_ID = 561;
- private int farmingxp;
- private int magexp;
- private int startfarmingxp = 0;
- private int startfarminglv;
- private int startmagexp = 0;
- private int startmagelv;
- private long start1 = 0;
- private long starttime = 0;
- private final Color color1 = new Color(180, 255, 153);
- private final Color color2 = new Color(0, 102, 51);
- private final BasicStroke stroke1 = new BasicStroke(2);
- private final Font font1 = new Font("Lucida Handwriting", 0, 18);
- private final Font font2 = new Font("Lucida Handwriting", 1, 18);
- private final Font font3 = new Font("Arial", 0, 14);
- private final Color color3 = new Color(204, 0, 0);
- private final Color color4 = new Color(0, 0, 0);
- private final Color color5 = new Color(255, 255, 255);
- private final BasicStroke stroke2 = new BasicStroke(1);
- private final BasicStroke stroke3 = new BasicStroke(2);
- private boolean showPaint = true;
- public final static RSTile[] LIVID_PLANTS = { new RSTile(2098, 3943),
- new RSTile(2100, 3943), new RSTile(2102, 3943),
- new RSTile(2104, 3943), new RSTile(2106, 3943),
- new RSTile(2106, 3946), new RSTile(2104, 3946),
- new RSTile(2102, 3946), new RSTile(2100, 3946),
- new RSTile(2098, 3946), new RSTile(2098, 3949),
- new RSTile(2100, 3949), new RSTile(2102, 3949),
- new RSTile(2104, 3949), new RSTile(2106, 3949) };
- public boolean onStart() {
- startfarmingxp = skills.getCurrentExp(Skills.FARMING);
- startfarminglv = skills.getCurrentLevel(Skills.FARMING);
- startmagexp = skills.getCurrentExp(Skills.MAGIC);
- startmagelv = skills.getCurrentLevel(Skills.MAGIC);
- starttime = System.currentTimeMillis();
- return inventory.containsAll(ASTRAL_ID, NATURE_ID);
- }
- //@SuppressWarnings({ })
- //@Override
- public int loop() {
- if (!getMyPlayer().getLocation().equals(new RSTile(2101, 3946))) {
- if (calc.tileOnScreen(new RSTile(2101, 3946)))
- walking.walkTileOnScreen(new RSTile(2101, 3946));
- else
- walking.walkTo(new RSTile(2101, 3946));
- try {
- Thread.sleep(696);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- camera.setAngle(0);
- camera.setPitch(true);
- long start = System.currentTimeMillis();
- try {
- start1 = start;
- // RSTile[] random = LIVID_PLANTS;
- // Random rgen = new Random(System.currentTimeMillis());
- // for(int i = 0; i > random.length; i++){
- // int randomPosition = rgen.nextInt(random.length);
- // RSTile temp = random[i];
- // random[i] = random[randomPosition];
- // random[randomPosition] = temp;
- //
- // }
- for (RSTile t : LIVID_PLANTS) {
- if (!tiles.interact(t, "fertilise e")) {
- if (menu.doAction("cure")) {
- waitForInterface(1081, 2000);
- getButton(t).doClick();
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- }
- }
- } else {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- }
- }
- // while(getMyPlayer().getAnimation() != -1){
- // try {
- // Thread.sleep(100);
- // } catch (InterruptedException e) {}
- // }
- }
- for(int i = LIVID_PLANTS.length - 1; i >= 0; i--){
- RSTile t = LIVID_PLANTS[i] ;
- if (!tiles.interact(t, "fertilise e")) {
- if (menu.doAction("cure")) {
- waitForInterface(1081, 2000);
- getButton(t).doClick();
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- }
- }
- } else {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- }
- }
- // while(getMyPlayer().getAnimation() != -1){
- // try {
- // Thread.sleep(100);
- // } catch (InterruptedException e) {}
- // }
- }
- } catch (Exception e) {
- }
- try {
- Thread.sleep((start + 59750) - System.currentTimeMillis());
- } catch (Exception e) {
- }
- return 200;
- }
- RSComponent getButton(RSTile t) {
- if (t.equals(new RSTile(2098, 3949))
- || t.equals(new RSTile(2100, 3949))
- || t.equals(new RSTile(2102, 3949))
- || t.equals(new RSTile(2106, 3949))) {
- return interfaces.get(1081).getComponent(3);
- }
- if (t.equals(new RSTile(2104, 3949))
- || t.equals(new RSTile(2102, 3946))
- || t.equals(new RSTile(2104, 3946))
- || t.equals(new RSTile(2106, 3946)))
- return interfaces.get(1081).getComponent(4);
- if (t.equals(new RSTile(2098, 3943))
- || t.equals(new RSTile(2106, 3943))
- || t.equals(new RSTile(2100, 3946)))
- return interfaces.get(1081).getComponent(5);
- return interfaces.get(1081).getComponent(6);
- }
- private boolean waitForInterface(int id, int timeout) {
- long start = System.currentTimeMillis();
- while (start + timeout > System.currentTimeMillis()) {
- if (interfaces.get(id).isValid())
- return true;
- try {
- Thread.sleep(125);
- } catch (InterruptedException e) {
- }
- }
- return false;
- }
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- final long runtime = System.currentTimeMillis() - starttime;
- long runtime2 = runtime;
- final long hours = (long) runtime2 / 3600000;
- runtime2 -= hours * 3600000;
- final long mins = (long) runtime2 / 60000;
- runtime2 -= mins * 60000;
- final long secs = (long) runtime2 / 1000;
- farmingxp = skills.getCurrentExp(Skills.FARMING) - startfarmingxp;
- magexp = skills.getCurrentExp(Skills.MAGIC) - startmagexp;
- if(showPaint) {
- g.setColor(color1);
- g.fillRoundRect(546, 205, 188, 259, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(546, 205, 188, 259, 16, 16);
- g.setFont(font1);
- g.drawString("mrfluffy's", 588, 229);
- g.setFont(font2);
- g.drawString("Livid Farmer", 562, 255);
- g.setFont(font3);
- g.drawString("Farm Level: " + skills.getCurrentLevel(Skills.FARMING) + " (+" + ((skills.getCurrentLevel(Skills.FARMING) - startfarminglv)) + ")", 561, 290);
- g.drawString("Farm XP: " + farmingxp, 561, 315);
- g.drawString("Farming XP/Hr: " + ((long) (farmingxp) * 3600000 / runtime), 561, 340);
- g.drawString("Magic Level: " + skills.getCurrentLevel(Skills.MAGIC) + " (+" + ((skills.getCurrentLevel(Skills.MAGIC) - startmagelv)) + ")", 561, 365);
- g.drawString("Mage XP: " + magexp, 561, 390);
- g.drawString("Running For: " + hours + ":" + mins + ":" + secs, 561, 415);
- g.setColor(color2);
- g.fillRect(708, 208, 17, 17);
- g.setColor(color4);
- g.setStroke(stroke2);
- g.drawRect(708, 208, 17, 17);
- g.setColor(color5);
- g.setStroke(stroke3);
- g.drawLine(722, 210, 710, 223);
- g.drawLine(710, 210, 722, 222);
- }
- if(!showPaint) {
- g.setColor(color2);
- g.fillRect(708, 208, 17, 17);
- g.setColor(color4);
- g.setStroke(stroke2);
- g.drawRect(708, 208, 17, 17);
- g.setColor(color5);
- g.setStroke(stroke3);
- g.drawOval(711, 211, 11, 11);
- }
- }
- @Override
- public void mouseClicked(MouseEvent e) {
- Point p = e.getPoint();
- if(p.x > 708 && p.x < 725 && p.y > 208 && p.y < 225) {
- showPaint = !showPaint;
- }
- }
- @Override
- public void mousePressed(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseEntered(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement