Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.util.LinkedList;
- import java.util.List;
- import javax.swing.*;
- import com.rarebot.event.events.MessageEvent;
- import com.rarebot.event.listeners.MessageListener;
- import com.rarebot.event.listeners.PaintListener;
- import com.rarebot.script.wrappers.RSItem;
- import com.rarebot.script.Script;
- import com.rarebot.script.ScriptManifest;
- import com.rarebot.script.methods.Skills;
- import com.rarebot.script.util.Filter;
- import com.rarebot.script.wrappers.RSNPC;
- import com.rarebot.script.wrappers.RSTile;
- @ScriptManifest(authors = "UberMouse & TheKoolKat", name = "UberFalconry", keywords = "Hunter", version = 1.5, description = "Catches kebbits at falconry area")
- public class UberFalconry extends Script implements MessageListener, PaintListener {
- private static List<Strategy> strategies = new LinkedList<Strategy>();
- //Booleans
- private boolean debug = false;
- private boolean reGetFalcon = false;
- private boolean buryBones = true;
- private boolean doBoneWork = false; //Flag that will bury the bones after dropping junk
- //IDS
- public int[] kebbitIDs = { 5098, 5099, 5100 };
- private int kebbitID = 5098;
- private int[] falconIDs = {5094, 5095, 5096};
- private int falconerID = 5093;
- private int[] junk = { 526, 10125,10115,10127 };
- //Tiles
- private RSTile falconerTile = new RSTile(2375, 3604);
- //Statistics
- private long startTime;
- private int kebbitsCaught = 0;
- private int startXPHunter;
- private int startXPPrayer;
- private int startLevelHunter;
- private int startLevelPrayer;
- public interface Strategy {
- public void execute();
- public boolean isValid();
- }
- public class Debug {
- public void debug(Object text, boolean severe)
- {
- if (debug) {
- String className = this.getClass().getName();
- if (className.contains("$"))
- className = className.split("\\$")[1];
- StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
- int stacktraceIndex;
- if (stackTraceElements[2].getMethodName() == "debug")
- stacktraceIndex = 3;
- else
- stacktraceIndex = 2;
- StackTraceElement stacktrace = stackTraceElements[stacktraceIndex];
- String methodName = stacktrace.getMethodName();
- if (!severe)
- log("[" + className + "] -> [" + methodName + "] -> " + text);
- else
- log.severe("[" + className + "] -> [" + methodName + "] -> " + text);
- }
- }
- public void debug(Object text)
- {
- debug(text, false);
- }
- }
- public boolean onStart()
- {
- if (!game.isLoggedIn()) {
- log.severe("Start script loggedin.");
- stopScript();
- }
- GUI gui = new GUI(this);
- gui.setVisible(true);
- while (gui.isVisible())
- sleep(100);
- startTime = System.currentTimeMillis();
- startXPHunter = skills.getCurrentExp(Skills.HUNTER);
- startXPPrayer = skills.getCurrentExp(Skills.PRAYER);
- startLevelHunter = skills.getCurrentLevel(Skills.HUNTER);
- startLevelPrayer = skills.getCurrentLevel(Skills.PRAYER);
- //Determine which Kebbit to catch
- if (startLevelHunter >= 69)
- kebbitID = kebbitIDs[2];
- else if (startLevelHunter >= 57)
- kebbitID = kebbitIDs[1];
- else if (startLevelHunter >= 43)
- kebbitID = kebbitIDs[0];
- else
- {
- log("Your hunter level is too low for falconry. You need at least level 43!");
- stopScript();
- }
- strategies.add(new reGetFalcon());
- strategies.add(new dropJunk());
- strategies.add(new buryBones());
- strategies.add(new catchKebbit());
- strategies.add(new takeFalcon());
- return true;
- }
- @Override
- public int loop()
- {
- try {
- if (interfaces.canContinue())
- interfaces.clickContinue();
- if (!getMyPlayer().isIdle() || !game.isLoggedIn())
- return 400;
- mouse.setSpeed(random(4, 7));
- for (Strategy strategy : strategies) {
- // debug = false;
- if (strategy.isValid()) {
- // debug = true;
- strategy*****cute();
- return random(500, 1000);
- }
- }
- }
- catch (NullPointerException e) {}
- return 10;
- }
- public void turnToNPC(RSNPC npc)
- {
- if (npc == null)
- return;
- if (!npc.isOnScreen()) {
- //camera.turnToCharacter(npc, random(10,25));
- //if (!npc.isOnScreen())
- walking.walkTileMM(walking.getClosestTileOnMap(npc.getLocation()));
- }
- }
- public class catchKebbit extends Debug implements Strategy {
- @Override
- public void execute()
- {
- RSNPC kebbit = npcs.getNearest(new Filter<RSNPC>() {
- @Override
- public boolean accept(RSNPC t)
- {
- if (t.getID() == kebbitID)
- return true;
- return false;
- }
- });
- turnToNPC(kebbit);
- if (kebbit.doAction("Catch")) {
- int timeout = 0;
- while (npcs.getNearest(falconIDs) == null && ++timeout < 20)
- sleep(100);
- }
- }
- @Override
- public boolean isValid()
- {
- return (npcs.getNearest(falconIDs) == null);
- }
- }
- public class takeFalcon implements Strategy {
- @Override
- public void execute()
- {
- RSNPC falcon = npcs.getNearest(falconIDs);
- turnToNPC(falcon);
- if (falcon.doAction("Retrieve")) {
- kebbitsCaught++;
- int timeout = 0;
- while (npcs.getNearest(falconIDs) != null && ++timeout < 25)
- sleep(100);
- }
- }
- @Override
- public boolean isValid()
- {
- return (npcs.getNearest(falconIDs) != null);
- }
- }
- public class dropJunk implements Strategy {
- @Override
- public void execute()
- {
- mouse.setSpeed(4);
- for (RSItem item : inventory.getItems()) {
- if (arrayContains(junk, item.getID())) {
- //Are we dropping bones?
- if (buryBones == true && item.getID() == 526)
- {
- //Do nothing since we don't want to drop the bone
- }
- else
- {
- //Drop junk item
- mouse.setSpeed(5);
- item.doAction("Drop");
- sleep(random(300, 500));
- //Occasionally sleep extra long for antiban measure
- int rndVal = random(1, 30);
- if (rndVal == 1) sleep(random(2000,3000));
- }
- }
- }
- //When we're done we will set a flag so that we can bury the bones now
- doBoneWork = true;
- }
- @Override
- public boolean isValid()
- {
- return inventory.getCount() > 26;
- }
- }
- public class buryBones implements Strategy {
- @Override
- public void execute()
- {
- mouse.setSpeed(4);
- int[] boneID = {526};
- for (RSItem item : inventory.getItems()) {
- if (arrayContains(boneID, item.getID())) {
- //If this item is a bone, bury it
- if (item.getID() == 526)
- {
- item.doClick(true);
- sleep(random(700, 900));
- }
- }
- }
- doBoneWork = false; //Stop working with bones, we're done
- }
- @Override
- public boolean isValid()
- {
- return doBoneWork;
- }
- }
- public class reGetFalcon implements Strategy {
- @Override
- public void execute()
- {
- walking.newTilePath(walking.findPath(falconerTile)).traverse();
- RSNPC falconer = npcs.getNearest(falconerID);
- turnToNPC(falconer);
- if (falconer.isOnScreen()) {
- if (falconer.doAction("Falconry")) {
- int timeout = 0;
- while (!interfaces.getComponent(236, 1).isValid() && ++timeout < 20)
- sleep(100);
- if (interfaces.getComponent(236, 1).doClick()) {
- timeout = 0;
- while (!interfaces.canContinue() && ++timeout < 20) {
- sleep(100);
- }
- reGetFalcon = false;
- }
- }
- }
- }
- @Override
- public boolean isValid()
- {
- return reGetFalcon;
- }
- }
- public boolean arrayContains(int[] array, int num)
- {
- for (int i : array) {
- if (i == num)
- return true;
- }
- return false;
- }
- @Override
- public void messageReceived(MessageEvent e)
- {
- String txt = e.getMessage();
- if (txt.contains("you see it heading back to the f"))
- reGetFalcon = true;
- }
- public String getTime(long millis)
- {
- long time = millis / 1000;
- String seconds = Integer.toString((int) (time % 60));
- String minutes = Integer.toString((int) ((time % 3600) / 60));
- String hours = Integer.toString((int) (time / 3600));
- for (int i = 0; i < 2; i++) {
- if (seconds.length() < 2) {
- seconds = "0" + seconds;
- }
- if (minutes.length() < 2) {
- minutes = "0" + minutes;
- }
- if (hours.length() < 2) {
- hours = "0" + hours;
- }
- }
- String returnThis = hours + ":" + minutes + ":" + seconds;
- return returnThis;
- }
- private final Color color1 = new Color(0, 0, 153, 125);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(255, 255, 255);
- private final Color color4 = new Color(255, 0, 51);
- private final Color color5 = new Color(51, 255, 0);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 12);
- int xpGainedHunter, xpGainedPrayer, xpPHHunter, xpPHPrayer, kebbitsPH;
- long ttlCalcH, ttlCalcP;
- String TTLH, TTLP, timeRan;
- public void onRepaint(Graphics g)
- {
- xpGainedHunter = skills.getCurrentExp(Skills.HUNTER) - startXPHunter;
- xpGainedPrayer = skills.getCurrentExp(skills.PRAYER) - startXPPrayer;
- xpPHHunter = (int) ((xpGainedHunter) * 3600000D / (System.currentTimeMillis() - startTime));
- xpPHPrayer = (int) ((xpGainedPrayer) * 3600000D / (System.currentTimeMillis() - startTime));
- String TTLH,TTLP;
- if(xpPHHunter != 0)
- ttlCalcH = (long) (skills.getExpToNextLevel(Skills.HUNTER) * 3600000D) / xpPHHunter;
- if(xpPHPrayer != 0)
- ttlCalcP = (long) (skills.getExpToNextLevel(Skills.HUNTER) * 3600000D) / xpPHHunter;
- kebbitsPH = (int) ((kebbitsCaught) * 3600000D / (System.currentTimeMillis() - startTime));
- TTLH = getTime(ttlCalcH);
- TTLP = getTime(ttlCalcP);
- timeRan = getTime(System.currentTimeMillis() - startTime);
- Color background = new Color(0,0,0,150);
- Color background2 = new Color(180,0,0,100);
- Color background3 = new Color(0,0,0,100);
- if (game.isLoggedIn()) {
- //=== Begin drawing the HUD ===
- int topOfHUD = 25; //Where the top of the HUD is (below the indicator text)
- //Draw the title box (200 pixels wide, 20 pixels tall)
- g.setColor(background);
- g.fillRect(3, topOfHUD, 170, 20);
- g.setColor(Color.black);
- g.drawRect(3, topOfHUD, 170, 20);
- g.setColor(Color.black);
- g.drawString(" Uber Falconry", 40, topOfHUD + 16);
- g.setColor(Color.red);
- g.drawString(" Uber Falconry", 41, topOfHUD + 15);
- //Draw the information box (200 pixels wide, 80 pixels tall)
- g.setColor(background3);
- g.fillRect(3, topOfHUD + 20, 170, 65);
- g.setColor(Color.black);
- g.drawRect(3, topOfHUD + 20, 170, 65);
- //Fill the box with information
- int firstListEntry = topOfHUD + 35; //Calculate where the first entry goes
- int currentListEntry = 0; //Changes for each entry as the number is incremented
- int numberOfListEntries = 0; //Tracks how many items in in this list
- g.setFont(new Font("sans serif", Font.PLAIN, 12));
- currentListEntry = firstListEntry + (numberOfListEntries * 15);
- g.setColor(Color.white);
- g.drawString("Time Running: " + timeRan, 8, currentListEntry);
- numberOfListEntries++; currentListEntry = firstListEntry + (numberOfListEntries * 15);
- g.setColor(Color.green);
- g.drawString("Kebbits Caught: " + kebbitsCaught + " (" + kebbitsPH + "/hr)", 8, currentListEntry);
- numberOfListEntries++; currentListEntry = firstListEntry + (numberOfListEntries * 15);
- g.setColor(Color.green);
- g.drawString("Hunter Exp: " + xpGainedHunter + " (" + xpPHHunter + "/hr)", 8, currentListEntry);
- numberOfListEntries++; currentListEntry = firstListEntry + (numberOfListEntries * 15);
- g.setColor(Color.green);
- g.drawString("Prayer Exp: " + xpGainedPrayer + " (" + xpPHPrayer + "/hr)", 8, currentListEntry);
- //Draw progressbar for hunter
- String statName = "Hunter level: " + skills.getRealLevel(skills.HUNTER);
- int statXPGained = xpGainedHunter;
- int statXPToGo = skills.getExpToNextLevel(skills.HUNTER);
- int statPercent = skills.getPercentToNextLevel(skills.HUNTER);
- int statLevelsGained = skills.getCurrentLevel(Skills.HUNTER) - startLevelHunter;
- //Add levels gained to the level indicator if we gained any levels
- if (statLevelsGained > 0)
- {
- statName = statName + " (+" + statLevelsGained + ")";
- //Recalculate which Kebbit to catch too
- if (startLevelHunter >= 69)
- kebbitID = kebbitIDs[2];
- else if (startLevelHunter >= 57)
- kebbitID = kebbitIDs[1];
- else
- kebbitID = kebbitIDs[0];
- }
- double drawPercent = (statPercent * 1.7);
- g.setColor(background3);
- g.fillRect(3, topOfHUD + 85, 170, 25);
- g.setColor(Color.black);
- g.drawRect(3, topOfHUD + 85, 170, 25);
- g.setColor(background2);
- g.fillRect(4, topOfHUD + 86, (int) drawPercent, 24);
- g.setColor(Color.white);
- g.setFont(new Font("Verdana", Font.PLAIN, 9));
- g.drawString(statName, 8, topOfHUD + 96);
- g.drawString("XP Gained " + statXPGained + " | " + statXPToGo + " to lvl", 8, topOfHUD + 106);
- g.setColor(Color.black);
- //Draw progressbar for prayer
- if (buryBones == true)
- {
- statName = "Prayer level: " + skills.getRealLevel(skills.PRAYER);
- statXPGained = xpGainedPrayer;
- statXPToGo = skills.getExpToNextLevel(skills.PRAYER);
- statPercent = skills.getPercentToNextLevel(skills.PRAYER);
- statLevelsGained = skills.getCurrentLevel(Skills.PRAYER) - startLevelPrayer;
- //Add levels gained to the level indicator if we gained any levels
- if (statLevelsGained > 0)
- statName = statName + " (+" + statLevelsGained + ")";
- drawPercent = (statPercent * 1.7);
- g.setColor(background3);
- g.fillRect(3, topOfHUD + 110, 170, 25);
- g.setColor(Color.black);
- g.drawRect(3, topOfHUD + 110, 170, 25);
- g.setColor(background2);
- g.fillRect(4, topOfHUD + 111, (int) drawPercent, 24);
- g.setColor(Color.white);
- g.setFont(new Font("Verdana", Font.PLAIN, 9));
- g.drawString(statName, 8, topOfHUD + 121);
- g.drawString("XP Gained " + statXPGained + " | " + statXPToGo + " to lvl", 8, topOfHUD + 131);
- g.setColor(Color.black);
- }
- }
- }
- class GUI extends JFrame {
- UberFalconry script;
- public GUI(final UberFalconry script) {
- this.script = script;
- script.loop();
- initComponents();
- }
- private void startBtnActionPerformed(ActionEvent e)
- {
- if (kebbitSelect.getSelectedIndex() == 0)
- script.buryBones = true;
- else
- script.buryBones = false;
- dispose();
- }
- private void initComponents()
- {
- // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
- // Generated using JFormDesigner Evaluation license - Taylor Lodge
- kebbitLabel = new JLabel();
- kebbitSelect = new JComboBox(new Object[] {"Yes", "No"});
- startBtn = new JButton();
- //======== this ========
- Container contentPane = getContentPane();
- contentPane.setLayout(null);
- //---- kebbitLabel ----
- kebbitLabel.setText("Bury Bones?");
- contentPane.add(kebbitLabel);
- kebbitLabel.setBounds(new Rectangle(new Point(5, 5), kebbitLabel.getPreferredSize()));
- contentPane.add(kebbitSelect);
- kebbitSelect.setBounds(5, 25, 110, kebbitSelect.getPreferredSize().height);
- //---- startBtn ----
- startBtn.setText("Start");
- startBtn.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- startBtnActionPerformed(e);
- }
- });
- contentPane.add(startBtn);
- startBtn.setBounds(new Rectangle(new Point(10, 55), startBtn.getPreferredSize()));
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < contentPane.getComponentCount(); i++) {
- Rectangle bounds = contentPane.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = contentPane.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- contentPane.setMinimumSize(preferredSize);
- contentPane.setPreferredSize(preferredSize);
- }
- pack();
- setLocationRelativeTo(getOwner());
- // JFormDesigner - End of component initialization //GEN-END:initComponents
- }
- // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
- // Generated using JFormDesigner Evaluation license - Taylor Lodge
- private JLabel kebbitLabel;
- private JComboBox kebbitSelect;
- private JButton startBtn;
- // JFormDesigner - End of variables declaration //GEN-END:variables
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement