import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.DefaultComboBoxModel; import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.LayoutStyle; import javax.swing.border.EmptyBorder; import org.rsbot.event.events.MessageEvent; import org.rsbot.event.listeners.MessageListener; 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.util.Timer; import org.rsbot.script.wrappers.RSItem; import org.rsbot.script.wrappers.RSNPC; import org.rsbot.script.wrappers.RSObject; @ScriptManifest(authors = { "Robert G" }, name = "RoguesDenCooker", description = "Cook's lobster's in Rogue's den.", version = 1.00) public class RoguesDenCooker extends Script implements PaintListener, MessageListener { private int em = 2271; private int fire = 2732; private int raw_shrimp = 317; private int raw_crayfish = 13435; private int raw_sardine = 327; private int raw_herring = 345; private int raw_anchovies = 321; private int raw_mackerel = 353; private int raw_trout = 335; private int raw_cod = 341; private int raw_pike = 349; private int raw_salmon = 331; private int raw_tuna = 359; private int raw_lobster = 377; private int raw_bass = 363; private int raw_swordfish = 371; private int raw_monkfish = 7944; private int raw_karambwan = 3142; private int raw_shark = 383; private int raw_rocktail = 15270; private int fish; private Timer timer; private String status = "Loading"; public int startLVL, currentLVL, gainedLVL, startXP, currentXP, gainedXP, xpPH, foodTNL, TNL; public long timeTNL; public int cooked = 0, burnt = 0; public int cookedPH; private double foodXP; public long startTime = System.currentTimeMillis(); // timer long runTime, seconds, minutes = 0, hours = 0; long runTime2, seconds2, minutes2 = 0, hours2 = 0; String addZero = "", addZero2 = ""; RogueGui g = new RogueGui(); private boolean guiWait = true; @Override public boolean onStart() { startLVL = skills.getCurrentLevel(Skills.COOKING); startXP = skills.getCurrentExp(Skills.COOKING); startTime = System.currentTimeMillis(); timer = new Timer(3500); g.setVisible(true); while (guiWait || g.isVisible()) { sleep(100); } return true; } public void cook() { status = "Cooking"; RSItem l = inventory.getItem(fish); RSObject f = objects.getNearest(fire); if (canCook()) { if (!inventory.isItemSelected()) { l.doClick(true); } sleep(random(500, 600)); if (inventory.isItemSelected()) { mouse.setSpeed(12); f.doAction("Use " + l.getName() + " -> Fire"); } sleep(random(2000, 2200)); } if (!canCook()) { walking.walkTileMM(f.getLocation(), 2, 2); } } private boolean canCook() { RSObject f = objects.getNearest(fire); if (f != null) { if (f.isOnScreen()) { return true; } } return false; } private boolean canBank() { RSNPC m = npcs.getNearest(em); if (m.isOnScreen()) { return true; } return false; } private void startBank() { status = "Banking"; RSNPC m = npcs.getNearest(em); if (canBank()) { m.doAction("Bank"); sleep(random(1200, 1400)); } else { if (!canBank()) { walking.walkTileMM(m.getLocation(), 2, 2); } } } private void bank() { if (!bank.open()) { startBank(); } else { if (bank.open()) { if (inventory.getCount() != 0) { bank.depositAll(); sleep(random(900, 1000)); } if (bank.getCount(fish) == 0 && inventory.getCount(fish) == 0) { log("Ran out of fish."); } else { if (!inventory.contains(fish)) { bank.withdraw(fish, 0); } if (inventory.contains(fish)) { bank.close(); } } } } } public void antiban() { status = "Antiban"; int b = random(0, 10); switch (b) { case 1: if (random(0, 10) == 5) { log("[Antiban] move mouse"); mouse.moveSlightly(); sleep(200, 600); mouse.moveRandomly(150, 350); } break; case 2: if (random(0, 13) == 2) { log("[Antiban] Turn screen"); camera.setAngle(random(30, 70)); sleep(400, 1200); } break; case 3: if (random(0, 24) == 6) { log("[Antiban] mouse off screen"); mouse.moveOffScreen(); sleep(random(600, random(1200, 2000))); } break; default: break; } } public void onFinish() { env.saveScreenshot(true); log("Thank's for using RoguesDenCooker"); log("You gained " + gainedLVL + " cooking level's in " + hours2 + ":" + addZero + minutes2 + ":" + addZero2 + seconds2); } @Override public int loop() { try { if (!game.isLoggedIn()) { sleep(1000); } if (interfaces.canContinue()) interfaces.clickContinue(); if (players.getMyPlayer().getAnimation() == 897) { antiban(); timer.reset(); } if (interfaces.getComponent(905, 14).isValid()) { interfaces.getComponent(905, 14).doClick(); sleep(1000, 1200); return 0; } if (inventory.contains(fish)) { if (getMyPlayer().getAnimation() != 897 && timer.getRemaining() == 0) { cook(); return 0; } } if (!inventory.contains(fish)) { bank(); return 0; } } catch (Exception e) { } return 0; } @Override public void messageReceived(MessageEvent e) { String x = e.getMessage().toLowerCase(); if (x.contains("roast")) cooked++; else if (x.contains("accidentaly")) burnt++; } private String formatTime(final long time) { final int sec = (int) (time / 1000), h = sec / 3600, m = sec / 60 % 60, s = sec % 60; return (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":" + (s < 10 ? "0" + s : s); } // START: Code generated using Enfilade's Easel private final Color color1 = new Color(0, 0, 0, 155); private final Color color2 = new Color(51, 255, 0); private final Color color3 = new Color(255, 51, 0); private final Color color4 = new Color(0, 0, 0); private final BasicStroke stroke1 = new BasicStroke(1); private final Font font1 = new Font("Georgia", 1, 16); private final Font font2 = new Font("Georgia", 0, 12); @Override public void onRepaint(Graphics g1) { Graphics2D g = (Graphics2D) g1; g.setColor(color1); g.fillRect(355, 5, 160, 232); g.setColor(color2); g.setStroke(stroke1); g.drawRect(355, 5, 160, 232); g.setFont(font1); g.drawString("RoguesDenCooker", 360, 25); g.setFont(font2); g.drawString("Run Time: " + hours2 + ":" + addZero + minutes2 + ":" + addZero2 + seconds2, 360, 45); g.drawString("Start Level: " + startLVL, 360, 60); g.drawString("Current Level: " + currentLVL, 360, 75); g.drawString("Level's Gained: " + gainedLVL, 360, 90); g.drawString("XP Gained: " + gainedXP, 360, 105); g.drawString("XP Per Hour: " + xpPH, 360, 120); g.drawString("Food Cooked: " + cooked, 360, 135); g.drawString("Food Per Hour: " + cookedPH, 360, 150); g.drawString("Food Burnt: " + burnt, 360, 165); g.drawString("Food TNL: " + foodTNL, 360, 180); g.drawString("Time TNL: " + formatTime(timeTNL), 360, 195); g.drawString("Status: " + status, 360, 210); // mouse paint g.setColor(Color.black); g.drawLine(0, (int) (mouse.getLocation().getY()) + 1, 800, (int) (mouse.getLocation().getY()) + 1); g.drawLine((int) (mouse.getLocation().getX()) + 1, 0, (int) (mouse.getLocation().getX()) + 1, 800); foodTNL = (int) (skills.getExpToNextLevel(Skills.COOKING) / foodXP); xpPH = (int) ((gainedXP) * 3600000.0 / runTime); cookedPH = (int) ((cooked) * 3600000.0 / runTime); currentLVL = skills.getCurrentLevel(Skills.COOKING); gainedXP = skills.getCurrentExp(Skills.COOKING) - startXP; gainedLVL = skills.getCurrentLevel(Skills.COOKING) - startLVL; TNL = skills.getExpToNextLevel(Skills.COOKING); timeTNL = (long) ((double) TNL / (double) xpPH * 3600000); runTime2 = System.currentTimeMillis() - startTime; runTime = System.currentTimeMillis() - startTime; seconds2 = runTime2 / 1000; // seconds if (seconds2 >= 60) { // minutes minutes2 = seconds2 / 60; seconds2 -= (minutes2 * 60); } if (minutes2 >= 60) { // hours hours2 = minutes2 / 60; minutes2 -= (hours2 * 60); } // adds zero before seconds if (seconds2 >= 10) { addZero2 = ""; } else if (seconds2 < 10) { addZero2 = "0"; } int percent = skills.getPercentToNextLevel(Skills.COOKING); int length = percent * 150 / 100; g.setColor(color3); g.fillRect(360, 215, 150, 18); g.setColor(color2); g.drawRect(360, 215, 150, 18); g.setColor(color2); g.fillRect(360, 215, +length, 18); g.setColor(color2); g.drawRect(360, 215, +length, 18); g.setColor(color4); g.drawString(percent + " %", 424, 228); } /** * @author Robert G */ public class RogueGui extends JFrame { /** * */ private static final long serialVersionUID = 1L; public RogueGui() { initComponents(); } private void okButtonActionPerformed(ActionEvent e) { String chosen = foodSelected.getSelectedItem().toString().toLowerCase(); if(chosen.contains("shrimp")) { fish = raw_shrimp; foodXP = 30; } if(chosen.contains("crayfish")) { fish = raw_crayfish; foodXP = 30; } if(chosen.contains("sardine")) { fish = raw_sardine; foodXP = 40; } if(chosen.contains("herring")) { fish = raw_herring; foodXP = 50; } if(chosen.contains("anchovies")) { fish = raw_anchovies; foodXP = 30; } if(chosen.contains("mackerel")) { fish = raw_mackerel; foodXP = 60; } if(chosen.contains("trout")) { fish = raw_trout; foodXP = 70; } if(chosen.contains("cod")) { fish = raw_cod; foodXP = 75; } if(chosen.contains("pike")) { fish = raw_pike; foodXP = 80; } if(chosen.contains("salmon")) { fish = raw_salmon; foodXP = 90; } if(chosen.contains("tuna")) { fish = raw_tuna; foodXP = 100; } if(chosen.contains("lobster")) { fish = raw_lobster; foodXP = 120; } if(chosen.contains("bass")) { fish = raw_bass; foodXP = 130; } if(chosen.contains("swordfish")) { fish = raw_swordfish; foodXP = 140; } if(chosen.contains("monkfish")) { fish = raw_monkfish; foodXP = 150; } if(chosen.contains("karambwan")) { fish = raw_karambwan; foodXP = 190; } if(chosen.contains("shark")) { fish = raw_shark; foodXP = 210; } if(chosen.contains("rocktail")) { fish = raw_rocktail; foodXP = 225; } g.dispose(); guiWait = false; } private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Robert G dialogPane = new JPanel(); contentPanel = new JPanel(); label1 = new JLabel(); label2 = new JLabel(); foodSelected = new JComboBox(); buttonBar = new JPanel(); okButton = new JButton(); //======== this ======== Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); //======== dialogPane ======== { dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); // JFormDesigner evaluation mark dialogPane.setBorder(new javax.swing.border.CompoundBorder( new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0), "", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red), dialogPane.getBorder())); dialogPane.addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}}); dialogPane.setLayout(new BorderLayout()); //======== contentPanel ======== { //---- label1 ---- label1.setText("Welcome to RoguesDenCooker by Robert G!"); label1.setFont(new Font("Tahoma", Font.BOLD, 16)); label1.setEnabled(false); //---- label2 ---- label2.setText("Please select food to cook:"); //---- foodSelected ---- foodSelected.setModel(new DefaultComboBoxModel(new String[] { "Shrimp", "Crayfish", "Sardine", "Herring", "Anchovies", "Mackerel", "Trout", "Cod", "Pike", "Salmon", "Tuna", "Lobster", "Bass", "Swordfish", "Monkfish", "Karambwan", "Shark", "Rocktail" })); GroupLayout contentPanelLayout = new GroupLayout(contentPanel); contentPanel.setLayout(contentPanelLayout); contentPanelLayout.setHorizontalGroup( contentPanelLayout.createParallelGroup() .addGroup(contentPanelLayout.createSequentialGroup() .addGroup(contentPanelLayout.createParallelGroup() .addComponent(label1) .addGroup(contentPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(label2) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(foodSelected, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE))) .addContainerGap(10, Short.MAX_VALUE)) ); contentPanelLayout.setVerticalGroup( contentPanelLayout.createParallelGroup() .addGroup(contentPanelLayout.createSequentialGroup() .addComponent(label1) .addGap(26, 26, 26) .addGroup(contentPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(foodSelected, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(label2)) .addContainerGap(146, Short.MAX_VALUE)) ); } dialogPane.add(contentPanel, BorderLayout.CENTER); //======== buttonBar ======== { buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); buttonBar.setLayout(new GridBagLayout()); ((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 80}; ((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; //---- okButton ---- okButton.setText("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButtonActionPerformed(e); } }); buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } dialogPane.add(buttonBar, BorderLayout.SOUTH); } contentPane.add(dialogPane, BorderLayout.CENTER); 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 - Robert G private JPanel dialogPane; private JPanel contentPanel; private JLabel label1; private JLabel label2; private JComboBox foodSelected; private JPanel buttonBar; private JButton okButton; // JFormDesigner - End of variables declaration //GEN-END:variables } }