Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package monkfishfrenzy;
- import com.kbotpro.scriptsystem.events.PaintEventListener;
- import com.kbotpro.scriptsystem.events.ServerMessageListener;
- import com.kbotpro.scriptsystem.interfaces.Looped;
- import com.kbotpro.scriptsystem.runnable.Script;
- import com.kbotpro.scriptsystem.various.GrandExchangeLookup;
- import com.kbotpro.scriptsystem.various.KTimer;
- import com.kbotpro.scriptsystem.wrappers.GroundItem;
- import com.kbotpro.scriptsystem.wrappers.IComponent;
- import com.kbotpro.scriptsystem.wrappers.NPC;
- import com.kbotpro.scriptsystem.wrappers.Tile;
- import org.apache.commons.lang.ArrayUtils;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- import javax.swing.border.TitledBorder;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.image.BufferedImage;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.text.NumberFormat;
- import java.util.ArrayList;
- public class MonkfishFrenzy extends Script implements PaintEventListener, ServerMessageListener, ActionListener {
- private int[] invAntipot = new int[ ] {175, 177, 179};
- private int coins = 995;
- private int[] whirlpools = new int[ ] { 403, 404, 406, 406};
- private int npcSpots = 3848;
- private int npcArnold = 3824;
- private int net = 303;
- private int randomRunValue = 45;
- private Tile[] toDock = new Tile[] {
- new Tile(2333, 3692), new Tile(2337, 3693), new Tile(2339, 3697),
- new Tile(2340, 3798), new Tile(2346, 3799)};
- private Tile[] toBank = walking.reversePath( toDock );
- private Tile bankTile = new Tile(2330, 3689 );
- private Tile lumby = new Tile(3223, 3218);
- private volatile int catches = 0;
- private int antiBanActive = 0;
- private State state;
- private boolean poisoned = false;
- private int cured = 0;
- private int checkTime;
- private KTimer time;
- private long lastCheck;
- private int startLevel;
- private int startExp;
- private int whirlpoolsAvoided;
- private int oldLevels;
- private int countToNext = 0;
- private int avoidedCombat;
- private int index = skills.SKILL_FISHING;
- private int stats = game.TAB_STATS;
- private String status = "Starting Up!";
- KTimer breakTimer = new KTimer(random(3600000, 12000000));
- boolean breaking = false;
- private int monkPrice;
- private long fishHour, profitHour, expHour = 0;
- private int xpPerCatch = 120;
- NumberFormat nf = NumberFormat.getInstance();
- public boolean useBreaks = true;
- public boolean useAntiBan = true;
- public boolean hidePaint = true;
- public int antiBanLevel = 1;
- public String[] aBOptions = {"1", "2", "3"};
- public JFrame frame;
- private boolean debug = false;
- public void createAndShowGUI() {
- //Create and set up the window.
- frame = new JFrame("Monkfish Frenzy By The Bru Crew");
- final JLabel antiBanInfo = new JLabel("Select Your AntiBan Activity", null, JLabel.CENTER);
- final JLabel antiBanInfo2 = new JLabel("1, Lowest, 3 Highest", null, JLabel.CENTER);
- final JComboBox antiBanOptions = new JComboBox(aBOptions);
- JCheckBox antiBan = new JCheckBox("Use AntiBan");
- JPanel breakPanel = new JPanel(new BorderLayout());
- JCheckBox breaks = new JCheckBox("Use Breaks");
- JPanel antiBanPanel = new JPanel(new BorderLayout());
- JPanel innerAntiBan = new JPanel(new BorderLayout());
- JPanel paintPanel = new JPanel(new BorderLayout());
- JCheckBox paint = new JCheckBox("Hide Paint");
- JButton startScript = new JButton("Update & Start Fishin!");
- JLabel mainLabel = new JLabel("Monkfish Frenzy Settings", null, JLabel.CENTER);
- frame.setLocationRelativeTo(null);
- ActionListener paintListener = new ActionListener() {
- public void actionPerformed(ActionEvent actionEvent) {
- AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
- hidePaint = abstractButton.getModel().isSelected();
- }
- };
- ActionListener breakListener = new ActionListener() {
- public void actionPerformed(ActionEvent actionEvent) {
- AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
- useBreaks = abstractButton.getModel().isSelected();
- }
- };
- ActionListener startListener = new ActionListener() {
- public void actionPerformed(ActionEvent actionEvent) {
- if ("enable".equals(actionEvent.getActionCommand()))
- sleep(random(500,750));
- frame.setVisible(false);
- }
- };
- TitledBorder breakTitle;
- breakTitle = BorderFactory.createTitledBorder("Use Breaks");
- breakPanel.setBorder(breakTitle);
- breaks.setToolTipText("Periodically Use Breaks?");
- breaks.addActionListener(breakListener);
- breaks.setSelected(true);
- breakPanel.add(breaks);
- frame.add(breakPanel, BorderLayout.LINE_START);
- TitledBorder antiBanTitle = BorderFactory.createTitledBorder("Use AntiBan");
- antiBanPanel.setBorder(antiBanTitle);
- ActionListener antiBanListener = new ActionListener() {
- public void actionPerformed(ActionEvent actionEvent) {
- AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
- useAntiBan = abstractButton.getModel().isSelected();
- if (!abstractButton.getModel().isSelected()) {
- antiBanOptions.setEnabled(false);
- antiBanInfo.setVisible(false);
- antiBanInfo2.setVisible(false);
- } else {
- antiBanOptions.setEnabled(true);
- antiBanInfo.setVisible(true);
- antiBanInfo2.setVisible(true);
- }
- }
- };
- antiBan.addActionListener(antiBanListener);
- antiBan.setSelected(true);
- antiBan.setToolTipText("Use AntiBan?");
- innerAntiBan.add(antiBan, BorderLayout.LINE_END);
- antiBanOptions.setPreferredSize(new Dimension(50, 10));
- antiBanOptions.setSelectedIndex(0);
- antiBanOptions.addActionListener(this);
- antiBanOptions.setToolTipText("Select your Anti-Ban Activity Level!");
- antiBanPanel.add(antiBanInfo, BorderLayout.CENTER);
- antiBanPanel.add(antiBanInfo2, BorderLayout.PAGE_END);
- innerAntiBan.add(antiBanOptions, BorderLayout.LINE_START);
- antiBanPanel.add(innerAntiBan, BorderLayout.PAGE_START);
- frame.add(antiBanPanel, BorderLayout.CENTER);
- TitledBorder paintTitle = BorderFactory.createTitledBorder("Hide Paint");
- paintPanel.setBorder(paintTitle);
- paint.setToolTipText("Hide Paint on Mouse Over");
- paint.addActionListener(paintListener);
- paint.setSelected(true);
- paintPanel.add(paint);
- frame.add(paintPanel, BorderLayout.LINE_END);
- startScript.setToolTipText("Jump on them Monkies!");
- startScript.setHorizontalTextPosition(AbstractButton.CENTER);
- startScript.addActionListener(startListener);
- startScript.setActionCommand("enable");
- frame.add(startScript, BorderLayout.PAGE_END);
- mainLabel.setHorizontalTextPosition(JLabel.CENTER);
- frame.add(mainLabel, BorderLayout.PAGE_START);
- //Display the window.
- frame.pack();
- frame.setVisible(true);
- }
- public void actionPerformed(ActionEvent e) {
- JComboBox cb = (JComboBox)e.getSource();
- String antiBanLevelString = (String) cb.getSelectedItem();
- antiBanLevel = Integer.parseInt(antiBanLevelString);
- }
- public void takeBreak() {
- //long breakedtime = 0;
- if(useBreaks){
- if (breakTimer.isDone() && !breaking) {
- breaking = true;
- enableRandom(false, "AutoLogin");
- game.exitToLogin();
- //breakedtime = time.getTimeElapsed();
- breakTimer.addTime(random(2000000, 450000));
- } else if (breakTimer.isDone() && breaking) {
- //time.reset();
- //time.addTime(breakedtime);
- breaking = false;
- enableRandom(true, "AutoLogin");
- breakTimer.addTime(random(7200000, 10800000));
- }
- }
- }
- @Override
- public void stop() {
- frame.setVisible(false);
- }
- @Override
- public String getName( ) {
- return( "Monkfish Frenzy" );
- }
- public void debug(String s) {
- if(debug)
- log.log(s);
- }
- @Override
- public void onStart() {
- setUserInputEnabled(false);
- monkPrice = new GrandExchangeLookup(7944).getMarketPrice();
- time = new KTimer();
- status = "Starting Up";
- mouse.setDefaultSpeed(1.4);
- status = "Creating GUI";
- createAndShowGUI();
- }
- NPC spot = null;
- @Override
- public void registerWorkers() {
- createWorker(new Looped() {
- public int loop() {
- takeBreak();
- if (!breaking && game.isLoggedIn()) {
- state = getState();
- switch(state){
- case Setup:
- if ( game.getRunningEnergy() >= randomRunValue && !isRunning()) {
- status = "Setting run.";
- walking.setRunning( true );
- randomRunValue = random(45, 65);
- break;
- }
- if (inventory.contains(coins)) {
- if(inventory.getCount(true, coins) <= 500) {
- inventory.atItem(coins, "drop");
- status = "Dropped Coins less than 500";
- break;
- }
- }
- break;
- case InCombat:
- status = "Getting Out Of Combat";
- runAway();
- break;
- case Fishing:
- status = "Fishing";
- GroundItem itemTile = groundItems.getClosestItem( net );
- if(itemTile != null){
- if ( itemTile.onScreen()) {
- log("Recovered gear.");
- itemTile.doAction("Take");
- sleep(random(750, 900));
- } else if(!getMyPlayer().isMoving()) {
- log("Walking to gear location.");
- walking.walkToMM(itemTile.getLocation());
- sleep(random(1700, 1900));
- }
- break;
- }
- spot = getClosestNPC(25, spot, npcSpots);
- if(spot != null) {
- if(spot.onScreen() && !inventory.isFull()){
- spot.doAction("Net");
- sleep(random(500, 750));
- while(getMyPlayer().isMoving())
- sleep(random(2000, 2500));
- break;
- } else if(!getMyPlayer().isMoving()) {
- walking.walkToMM(spot.getLocation().randomizeTile(3, 3));
- sleep(random(700, 900));
- break;
- }
- break;
- } else {
- try{
- walkLocalPath(toDock, 2, 2, random(5,10));
- sleep(random(700,900));
- }catch(Exception e){
- log("Exception Thrown");
- }
- }
- break;
- case Banking:
- status = "Banking";
- if(bank.isOpen()){
- bank.depositAllExcept(net);
- if(!inventory.contains(net)){
- log("Withdrawing Small Fishing Net");
- bank.withdrawX(net, 1);
- break;
- }
- bank.close();
- break;
- }
- NPC arnold = npcs.getClosest(40, npcArnold);
- if (arnold != null) {
- if(arnold.onScreen()) {
- arnold.doAction("Bank");
- sleep(random(750, 900));
- } else if(distanceTo(bankTile) <= 10) {
- if(!getMyPlayer().isMoving()) {
- walking.walkToMM(bankTile.randomizeTile(2, 2));
- sleep(random(700, 900));
- }
- } else if(distanceTo(bankTile) > 10) {
- try {
- walkLocalPath(toBank, 2, 2, random(5,10));
- sleep(random(700, 900));
- }catch(Exception e){
- log("Exception Thrown");
- }
- }
- } else {
- try {
- walkLocalPath(toBank, 2, 2, random(5,10));
- sleep(random(1700,1900));
- }catch(Exception e){
- log("Exception Thrown");
- }
- }
- break;
- case Poisoned:
- status = "Poisoned";
- if(!inventory.contains(invAntipot)) {
- if(bank.isOpen()){
- bank.depositAllExcept(net);
- sleep(random(500,750));
- if(bank.contains(175)) {
- bank.withdrawX(175, 1); }
- else if(bank.contains(177)) {
- bank.withdrawX(177, 1);
- } else if(bank.contains(179)) {
- bank.withdrawX(179, 1);
- }
- bank.close();
- break;
- }
- NPC arnoldPoison = npcs.getClosest(40, npcArnold);
- if (arnoldPoison != null) {
- if(arnoldPoison.onScreen()) {
- arnoldPoison.doAction("Bank");
- sleep(random(750, 900));
- } else if(distanceTo(bankTile) <= 10) {
- walking.walkToMM(bankTile.randomizeTile(2, 2));
- sleep(random(1700, 1900));
- } else if(distanceTo(bankTile) > 10) {
- try {
- walkLocalPath(toBank, 2, 2, random(5,10));
- sleep(random(1700,1900));
- }catch(Exception e){
- log("Exception Thrown");
- }
- }
- } else {
- try {
- walkLocalPath(toBank, 2, 2, random(5,10));
- sleep(random(1700,1900));
- }catch(Exception e){
- log("Exception Thrown");
- }
- }
- } else {
- for(int i=0; i<3; i++) {
- if ( poisoned && inventory.atItem(invAntipot[i], "Drink") ) {
- log("Drunk part of anti-pot.");
- cured++;
- poisoned = false;
- break;
- }
- }
- }
- break;
- case Busy:
- NPC whirl = npcs.getClosest(25, whirlpools );
- if ( whirl != null && distanceTo(whirl.getLocation( )) <= 2 && getMyPlayer().getInteracting() == whirl ) {
- status = "Avoiding whirlpool.";
- log("Avoiding whirlpool");
- walking.walkToMM(new Tile (getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY() - 2));
- sleep(random(1000,1500));
- whirlpoolsAvoided++;
- break;
- }
- return antiBan();
- case Dead:
- log.logImportant("In Lumby, Stopping All Scripts.");
- stopAllScripts();
- default:
- return random(1300, 1800);
- }
- }
- return random(1000, 1750);
- }
- });
- }
- public String getAuthor( ) {
- return( "The Bru Crew" );
- }
- public double getVersion( ) {
- return( 3.0 );
- }
- private int antiBan() {
- int gamble = 1;
- KTimer countDownTimer = new KTimer(random(60000, 180000));
- if(useAntiBan == true) {
- if(antiBanLevel == 1)
- gamble = random(1, 300);
- else if(antiBanLevel == 2)
- gamble = random(1, 200);
- else if(antiBanLevel == 3)
- gamble = random(1, 100);
- switch (gamble) {
- case 1:
- return random(500, 750);
- case 2:
- int x = random(0, 750);
- int y = random(0, 500);
- mouse.moveMouse(x, y);
- antiBanActive++;
- return random(500, 750);
- case 3:
- if (game.getCurrentTab() != game.TAB_INVENTORY) {
- game.openTab(game.TAB_INVENTORY);
- }
- return random(500, 700);
- case 4:
- if (getMyPlayer().isMoving()) {
- return random(750, 1000);
- }
- if (countDownTimer.isDone()) {
- countDownTimer = new KTimer(random(60000, 180000));
- if (game.getCurrentTab() != stats) {
- game.openTab(stats);
- }
- mouse.moveMouse(random(674, 733), random(266, 292));
- antiBanActive++;
- sleep(random(5000, 8000));
- if (game.getCurrentTab() != game.TAB_INVENTORY) {
- game.openTab(game.TAB_INVENTORY);
- }
- return random(250, 500);
- }
- case 5:
- if (random(1, 8) == 2) {
- double angle = camera.getAngle() + random(-90, 90);
- if (angle < 0) {
- angle = 0;
- }
- if (angle > 359) {
- angle = 0;
- }
- int rotateAngle = (int) angle;
- antiBanActive++;
- camera.setAngle(rotateAngle);
- }
- return random(500, 750);
- }
- }
- debug("Anti-Ban Used: " + antiBanActive + " Times.");
- return random(500, 750);
- }
- public void onRepaint( Graphics g ) {
- int exp = 0;
- int levels;
- int mouse_x = (int) mouse.getMousePos().getX();
- int mouse_y = (int) mouse.getMousePos().getY();
- int fishingLevel = skills.getCurrentLevel(index);
- Color White = new Color(255, 255, 255, 200);
- int percentToLevel = (int) skills.getPercToNextLevel(index);
- levels = fishingLevel - startLevel;
- if(!breaking) {
- exp = skills.getExperience(index) - startExp;
- }
- if ( startLevel == 0 || startExp == 0 ) {
- startLevel = skills.getCurrentLevel(index);
- startExp = skills.getExperience(index);
- }
- countToNext = (skills.getExperienceToNextLevel(index) / xpPerCatch) + 1;
- if (levels > oldLevels) {
- oldLevels = levels;
- }
- g.setColor(White);
- if(!(mouse_x > 0 && mouse_x < 240 && mouse_y < 337 && mouse_y > 180) || !hidePaint || breaking) {
- g.drawString(getName( ) + " v" + getVersion( ) + " By: " + getAuthor(), 9, 205);
- g.drawString("Currently: " + status, 9, 221);
- g.drawString("Current Fishing Level: " + fishingLevel + " | Percent To Next: " + percentToLevel, 9, 237);
- g.drawString("XP Gained: " + nf.format(exp) + " | Per hour: " + nf.format(expHour), 9, 253);
- g.drawString("Catches: " + nf.format(catches) + " | Per hour: " + nf.format(fishHour), 9, 269);
- g.drawString("Profit: " + nf.format(catches * monkPrice) + " | Per hour: " + nf.format(profitHour), 9, 285);
- g.drawString("Catches to next level: " + nf.format(countToNext), 9, 301);
- g.drawString("Time running: " + time.getFormattedTime(time.getTimeElapsed()), 9, 317);
- g.drawString(breakText() , 9, 333);
- }
- }
- public String breakText() {
- String textTime, text;
- if(breaking) {
- text = "Resuming in: ";
- } else {
- text = "Next Break In: ";
- }
- if(useBreaks) {
- textTime = breakTimer.getFormattedTime(breakTimer.getTimeRemaining());
- }
- else {
- textTime = "Not Breaking";
- return textTime;
- }
- return text + textTime;
- }
- public void onServerMessage(String e) {
- if ( e.contains("poisoned") && !poisoned) {
- log("Poisoned!");
- poisoned = true;
- }
- if ( e.contains("catch a monkfish")){
- catches++;
- fishHour = (((long)catches * 1000L * 60L * 60L)) / (time.getTimeElapsed());
- profitHour = fishHour*monkPrice;
- expHour = fishHour*xpPerCatch;
- }
- }
- public void runAway() {
- Tile foo, foo2;
- foo = getMyPlayer().getLocation();
- walking.setRunning(true);
- foo2 = new Tile(foo.getX() + random(8, 10), foo.getY()
- + random(8, 10));
- walking.walkToMM(foo2);
- sleep(random(2000, 4000));
- walking.walkToMM(foo);
- avoidedCombat++;
- }
- private State getState() {
- IComponent fullfish = interfaces.getComponent(210,1);
- if(distanceTo(lumby) < 40 )
- return State.Dead;
- if(getMyPlayer().isInCombat()){
- return State.InCombat;
- }
- if(poisoned) {
- return State.Poisoned;
- }
- if(fullfish != null) {
- if (fullfish.textContainsIgnoreCase("carry any")) {
- game.openTab(game.TAB_INVENTORY);
- return State.Banking;
- }
- }
- if ( inventory.getCount(false, net) < 1 ) {
- return State.Banking;
- }
- if( inventory.isFull())
- return State.Banking;
- if((inventory.getCount(true, coins) > 0 && inventory.getCount(true, coins) <= 500) || (game.getRunningEnergy() >= randomRunValue && !isRunning())) {
- return State.Setup;
- }
- if(getMyPlayer().getAnimation() != -1) {
- return State.Busy;
- }
- return State.Fishing;
- }
- private enum State {
- InCombat, Fishing, Banking, Poisoned, Busy, Dead, Setup
- }
- private boolean isRunning() {
- return (interfaces.getComponent(750, 3) != null && interfaces.getComponent(750, 3).getTextureID() == 783);
- }
- private NPC getClosestNPC(int range, NPC exclude, int... IDs) {
- if (!isLoggedIn()) {
- return null;
- }
- if (exclude == null) {
- return npcs.getClosest(range, IDs);
- }
- final int excludeId = exclude.getID();
- final Tile excludeLoc = exclude.getLocation();
- final Tile myPos = botEnv.players.getMyPlayer().getLocation();
- int minX = myPos.getX() - range;
- int minY = myPos.getY() - range;
- int maxX = myPos.getX() + range;
- int maxY = myPos.getY() + range;
- java.util.List<NPC> objList = new ArrayList<NPC>();
- for (NPC n : npcs.getNPCs()) {
- if (n.getLocation().equals(excludeLoc))
- continue;
- if (n.getLocation().getX() < 2323)
- continue;
- if (!ArrayUtils.contains(IDs, n.getID()))
- continue;
- objList.add(n);
- }
- if (objList.isEmpty())
- return null;
- double closest = 9999;
- NPC closestNPC = null;
- for (NPC n : objList) {
- double distance = myPos.distanceToPrecise(n.getLocation());
- if (distance < closest) {
- closest = distance;
- closestNPC = n;
- }
- }
- return closestNPC;
- }
- public boolean walkLocalPath(Tile[] tiles, final int randX, final int randY, final int flag) {
- Tile destination = (tiles[tiles.length - 1]);
- debug("WalkLocalPath: "+destination.toString()+" | on MM: " + calculations.tileToMinimap(destination));
- boolean finished = false;
- while (!finished) {
- finished = walking.walkToMM(destination);
- sleep(random(800, 1200));
- if (players.getMyPlayer().isMoving()) {
- final Tile dest = walking.getDestination();
- if (dest != null)
- if (((int) players.getMyPlayer().distanceTo(dest)) > flag) {
- continue;
- }
- }
- Tile[] mutable = tiles;
- ArrayUtils.reverse(mutable);
- for (Tile t: mutable){
- debug(""+finished);
- if(finished)
- break;
- finished = walking.walkToMM(t);
- }
- }
- return finished;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement