- import impsoft.bots.ColorBot;
- import impsoft.bots.input.KeyboardCommand;
- import impsoft.bots.input.MouseCommand;
- import impsoft.bots.reflection.NPC;
- import impsoft.bots.reflection.PhysicalObject;
- import impsoft.bots.reflection.WorldObject;
- import impsoft.scripting.ibot.builtin.itemrec.ItemSlot;
- import impsoft.scripting.ibot.builtin.ocr.NPCChat;
- import impsoft.scripting.ibot.builtin.tabs.InventoryTab;
- import impsoft.scripting.ibot.enums.Skill;
- import impsoft.scripting.ibot.interfaces.AutoPaint;
- import impsoft.scripting.ibot.itemrec.ItemNameExact;
- import impsoft.scripting.ibot.structs.AryanTile;
- import impsoft.scripting.types.ColorScript;
- import impsoft.scripting.types.ColorSkeltonScriptable;
- import impsoft.scripting.types.parallel.scriptjobs.RepeatableScriptJob;
- import impsoft.scripting.types.parallel.scriptjobs.ScriptJob;
- import impsoft.utils.general.Timer;
- import impsoft.utils.ibot.RandomGenerator;
- import impsoft.utils.uber.UberClickOptions;
- import impsoft.utils.uber.UberScriptUtils;
- import impsoft.values.constant.Areas;
- import impsoft.values.variable.SettingsManager;
- import java.awt.*;
- import java.awt.event.KeyEvent;
- import java.text.DecimalFormat;
- import java.util.EnumSet;
- import java.util.regex.Pattern;
- import javax.swing.*;
- public class Cooker extends ColorScript implements AutoPaint {
- public Cooker(ColorBot c) {
- super(c);
- }
- public static void setFood(final Cooking c) {
- selected = c;
- }
- public static void setLocation(final CookingLocations c) {
- currentCookingLocation = c;
- }
- private boolean hover = false;
- private NPCChat chat;
- private static Cooking selected;
- private static CookingLocations currentCookingLocation = CookingLocations.ROGUE_DEN;
- private final InventoryTab tab = new InventoryTab(this);
- private final CookerMethods method = new CookerMethods(this);
- private final CookerUIV2 GUI = new CookerUIV2();
- private final Rectangle cookAll = new Rectangle(246, 398, 39, 36);
- private State botState = State.GET_STATE;
- private String status = "";
- private enum State {
- GET_STATE, COOK, BANK
- }
- private final RenderingHints antialiasing = new RenderingHints(
- RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- private final Color color1 = new Color(0, 0, 0, 169);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(255, 255, 255);
- private final Color color4 = new Color(204, 51, 0, 219);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 12);
- private final Font font2 = new Font("Arial", 0, 11);
- private final DecimalFormat df = new DecimalFormat("0.00");
- private double seconds;
- private final int getXTL() {
- return xpLevels[currentLv + 1] - currentXp;
- }
- private final int getXTTL() {
- return xpLevels[currentLv + 1] - xpLevels[currentLv];
- }
- private final int[] xpLevels = { 0, 0, 83, 174, 276, 388, 512, 650, 801,
- 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973,
- 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031,
- 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408,
- 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127,
- 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636,
- 184040, 203254, 224466, 247886, 273742, 302288, 333804, 368599,
- 407015, 449428, 496254, 547953, 605032, 668051, 737627, 814445,
- 899257, 992895, 1096278, 1210421, 1336443, 1475581, 1629200,
- 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594,
- 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253,
- 7195629, 7944614, 8771558, 9684577, 10692629, 11805606, 13034431,
- 200000000 };
- private int cooked = 0;
- private int currentLv = 0;
- private int startLv = 0;
- private int currentXp = 0;
- private int startXp = 0;
- private Timer timer = new Timer(0);
- @Override
- public void paint(Graphics render) {
- seconds = timer.getTimeElapsed() / 1000.00D;
- Graphics2D g = (Graphics2D) render;
- g.setRenderingHints(antialiasing);
- if (fire != null && fire.getGameScreenLocation() != null) {
- g.setColor(new Color(255, 51, 0, 125));
- g.fillPolygon(fire.getGameScreenLocation(41, -48, 56, -45, 0, 0));
- }
- if (emerald != null && emerald.getGameScreenLocation() != null) {
- g.setColor(Color.black);
- g.drawPolygon(emerald.getGameScreenLocationSmaller());
- }
- g.setColor(color1);
- g.fillRoundRect(13, 349, 200, 100, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(13, 349, 200, 100, 16, 16);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("CSCooker", 23, 367);
- g.setFont(font2);
- g.drawString("Timer: " + timer.toStringTimeElapsed(), 25, 380);
- g.drawString("Experience Gained: " + (currentXp - startXp), 25, 390);
- if (seconds != 0)
- g.drawString("Experience Gained/hr: "
- + df.format(((currentXp - startXp) * 3600) / seconds), 25,
- 400);
- else
- g.drawString("Experience Gained/hr: 0.00", 25, 400);
- g.drawString("Fish Cooked: " + cooked, 25, 410);
- if (seconds != 0)
- g.drawString("Fish Cooked/hr: "
- + df.format((cooked * 3600) / seconds), 25, 420);
- else
- g.drawString("Fish Cooked/hr: 0.00", 25, 420);
- g.drawString("Status: " + status, 25, 430);
- g.setColor(color4);
- g.fillRoundRect(25, 435, 186, 12, 16, 16);
- g.setColor(Color.green);
- g.fillRoundRect(25, 435,
- (int) ((1.00f - ((float) getXTL() / (float) getXTTL())) * 186),
- 12, 16, 16);
- g.setFont(new Font("Bodoni MT", 2, 16));
- g.setColor(Color.white);
- g.drawString("V" + version, 160, 367);
- g.setColor(new Color(0, 0, 0, 185));
- g.fillRect(399, 300, 106, 14);
- g.setColor(Color.black);
- g.drawRect(399, 300, 106, 14);
- g.setFont(new Font("Arial", 0, 10));
- g.setColor(Color.white);
- if (bankTimer != null)
- g.drawString("Bank timer: " + bankTimer.getTimeElapsed(), 402, 310);
- else
- g.drawString("Bank timer: 0", 402, 310);
- }
- private NPC emerald;
- private PhysicalObject fire;
- private ItemSlot fish;
- private int fail = 0;
- @Override
- public void script() {
- try {
- while (!isLoggedIn())
- sleep(1000);
- addScriptJob(new RepeatableScriptJob(this) {
- public long runL() throws InterruptedException {
- SettingsManager.setMouseSpeedLong(RandomGenerator
- .randomNormalDouble(1.2, 1.7));
- return random(70000, 200000);
- }
- });
- startLv = theTabs.Statistics.getStatBottom(Skill.COOKING);
- startXp = theTabs.Statistics.getStatExperience(Skill.COOKING);
- currentLv = startLv;
- currentXp = startXp;
- GUI.setVisible(true);
- while (GUI.isVisible())
- sleep(1000);
- log("GUI Finished, starting script");
- timer.reset();
- while (true) {
- if (fire == null) {
- log("Finding the fire.");
- fire = method.getPOOnTile(new AryanTile(103043, 104973));
- }
- if (fail >= 10)
- method.logOff("Too many fails.");
- s: switch (botState) {
- case GET_STATE:
- botState = getState(selected);
- break;
- case COOK:
- if (theBank.isInterfaceUp())
- theBank.exit();
- cooking: while (method.tab()) {
- if (theTabs.Inventory.count("Raw") == 0) {
- botState = State.COOK;
- break s;
- }
- clickFire();
- while (isMoving())
- sleep(100, 200);
- if (!theNPCChatFinder.isNPCChatUp())
- continue cooking;
- if (theTopText.getTopText().contains("ook"))
- mouseClickRight(getCurrentMouseXY());
- else {
- mouseMove(cookAll);
- sleep(125, 250);
- if (theTopText.getTopText().contains("ook"))
- mouseClickRight(getCurrentMouseXY());
- else
- continue cooking;
- }
- status = "Waiting for NPC Chat";
- for (int i = 0; i < 10 && !theMenuFinder.isMenuUp(); i++)
- sleep(90, 130);
- boolean moved = hover && random(1, 7) == 5;
- if (theMenuFinder.doMenu("Cook All")) {
- sleep(3000);
- while (method.tab()) {
- status = "Cooking";
- forLoop: for (int i = 0; i < 10;) {
- if (theNPCChatFinder.isNPCChatUp()
- && (chat = theNPCChatFinder
- .getNPCChat())
- .contains("Click here")) {
- if (chat.contains("ched level"))
- log("Level up");
- chat.selectContains("Click here");
- waitTillNPCChatChangesFrom(chat);
- continue forLoop;
- }
- method.tab();
- sleep(400, 600);
- if (theTabs.Inventory.count("Raw") == 0) {
- botState = State.BANK;
- break s;
- }
- sleep(190, 230);
- cooked = (int) ((currentXp - startXp) / selected
- .getExperience());
- currentLv = theTabs.Statistics
- .getStatBottom(Skill.COOKING);
- currentXp = theTabs.Statistics
- .getStatExperience(Skill.COOKING);
- if (getAnimation() == -1)
- i++;
- if (!moved
- && tab.count(selected.getName()) <= random(
- 3, 5)) {
- if (emerald != null
- && emerald
- .getGameScreenLocation() != null) {
- mouseClickRight(emerald
- .getRecommendPointToClick());
- sleep(200, 800);
- enterCommand(MouseCommand.Move(
- getPriority(), Thread
- .currentThread(),
- getCurrentMouseX()
- + random(2, 7),
- getCurrentMouseY()
- + random(20, 32)));
- moved = true;
- }
- }
- }
- sleep(500, 800);
- if (tab.count(selected.getName()) == 0)
- break cooking;
- method.antiban();
- }
- } else
- continue cooking;
- }
- botState = State.BANK;
- break;
- case BANK:
- status = "Banking";
- while (true) {
- openBank();
- bankTimer = new Timer(4000);
- while (bankTimer.isNotUp() && !theBank.isInterfaceUp())
- sleep(100, 250);
- if (bankTimer.isUp())
- continue;
- bankTimer = null;
- status = "Depositing items";
- if (theBank.isInterfaceUp())
- theBank.doDepositAll();
- else
- continue;
- status = "Withdrawing items";
- if (theBank.isInterfaceUp())
- theBank.doWithDrawAll(selected.getName(), true);
- else
- continue;
- break;
- }
- botState = State.COOK;
- break;
- }
- }
- } catch (final InterruptedException e) {
- }
- }
- private Timer bankTimer;
- private void clickFire() throws InterruptedException {
- cooking: while (true) {
- if (theNPCChatFinder.isNPCChatUp())
- break cooking;
- fish = tab.findSlot(new ItemNameExact(selected.getName()));
- if (fish != null) {
- if (!tab.isAItemSelected()) {
- status = "Clicking the fish";
- fish.mouseClickLeftOn();
- }
- sleep(180, 260);
- if (!tab.isAItemSelected())
- continue cooking;
- status = "Clicking the fire";
- UberScriptUtils.clickWorldObject(this, fire, null, Pattern
- .compile(".*Fire.*", Pattern.CASE_INSENSITIVE), //
- method.CHECK_TEXT);
- status = "Moving the mouse";
- mouseMove(cookAll);
- for (int i = 0; i < 10 && !theNPCChatFinder.isNPCChatUp(); i++)
- sleep(150, 200);
- sleep(300, 600);
- }
- }
- }
- private final void openBank() throws InterruptedException {
- if (theMenuFinder.doMenu("Bank Emerald Benedict"))
- return;
- emerald = theWorldObjectFinder.findNPC(currentCookingLocation
- .getNPCName());
- if (emerald != null) {
- if (emerald.getGameScreenLocation() == null)
- method.walkTo(emerald);
- UberScriptUtils.clickWorldObject(this, emerald, null, Pattern
- .compile(".*ank.Eme.*", Pattern.CASE_INSENSITIVE),
- method.STANDARD);
- } else
- method.logOff("Banker not found.");
- }
- private State getState(final Cooking c) throws InterruptedException {
- method.tab();
- return tab.count(c.getName()) != 0 ? State.COOK : State.BANK;
- }
- public enum CookingLocations {
- ROGUE_DEN("Rogue's Den", "Emerald Benedict");
- private String name;
- private String npcName;
- /*
- * Temporary since this current enum set-up only support Rogue's den and
- * not any other location at the moment.
- */
- CookingLocations(final String name, final String npcName) {
- this.name = name;
- this.npcName = npcName;
- }
- public final String getNPCName() {
- return npcName;
- }
- public final String getLocationName() {
- return name;
- }
- }
- @SuppressWarnings("unchecked")
- public class CookerMethods {
- private ColorSkeltonScriptable css;
- public CookerMethods(final ColorSkeltonScriptable css) {
- this.css = css;
- }
- public final EnumSet STANDARD = EnumSet.of(UberClickOptions.WALK,
- UberClickOptions.CLICK_USING_PRECISION,
- UberClickOptions.CLICK_USING_PREDICTIONS,
- UberClickOptions.USE_MENU);
- public final EnumSet NO_MENU = EnumSet.of(UberClickOptions.WALK,
- UberClickOptions.CLICK_USING_PRECISION,
- UberClickOptions.CLICK_USING_PREDICTIONS);
- public final EnumSet CHECK_TEXT = EnumSet.of(
- UberClickOptions.CLICK_USING_PRECISION,
- UberClickOptions.CLICK_USING_PREDICTIONS,
- UberClickOptions.USE_MENU);
- public final EnumSet HOVER = EnumSet.of(
- UberClickOptions.CLICK_USING_PRECISION,
- UberClickOptions.CLICK_USING_PREDICTIONS,
- UberClickOptions.USE_MENU_BUT_DONT_SELECT);
- public final boolean tab() throws InterruptedException {
- if (!css.theTabs.Inventory.isSelected())
- css.enterCommand(KeyboardCommand.downUp(css.getPriority(),
- Thread.currentThread(), KeyEvent.VK_F1, css.random(25,
- 85)));
- return true;
- }
- public final void logOff(final Object o) throws InterruptedException {
- css.log(o);
- if (css.theBank.isInterfaceUp())
- css.theBank.exit();
- css.theTabs.Logout.click();
- css.sleep(2000, 4000);
- css.stopRandom("Login");
- css.theTabs.Logout.clickLogOut();
- css.shutDown();
- }
- public final void walkTo(final AryanTile tile)
- throws InterruptedException {
- final ScriptJob sj = css.theParallelWalking
- .walkToUsingWebKillPrevious(tile);
- while (tile.getCenterGameScreenLocation(css) == null)
- css.sleep(200);
- sj.forceKill();
- }
- public final void walkTo(final WorldObject wo)
- throws InterruptedException {
- final AryanTile t = wo.getLocation();
- final ScriptJob sj = css.theParallelWalking
- .walkToUsingWebKillPrevious(t);
- while (t.getCenterGameScreenLocation(css) == null)
- css.sleep(200);
- sj.forceKill();
- }
- public final PhysicalObject getPOOnTile(final AryanTile tile) {
- for (PhysicalObject po : css.getAllPhysicalObjects())
- if (po.getLocation().equals(tile))
- return po;
- return null;
- }
- public final void antiban() throws InterruptedException {
- if (css.random(1, 50) == 25) {
- switch (css.random(1, 5)) {
- case 1:
- css.mouseMove(Areas.ENTIRE);
- css.log("Mouse moved to " + css.getCurrentMouseXY());
- break;
- case 2:
- final int i = css.random(1, 4);
- for (int j = 0; i < i; j++) {
- css.mouseMove(Areas.ENTIRE);
- css.log("Mouse moved to " + css.getCurrentMouseXY());
- css.sleep(900, 1400);
- }
- break;
- case 3:
- css.theCamera.setYawRandom();
- css.log("Camera moved.");
- break;
- case 4:
- css.sleep(600, 1500);
- css.log("Random sleep.");
- break;
- }
- }
- }
- }
- public enum Cooking {
- SHRIMP("Raw shrimps", 30), SARDINE("Raw sardine", 40), ANCHOVIES(
- "Raw anchovies", 30), HERRING("Raw herring", 50), MACKEREL(
- "Raw mackerel", 60), TROUT("Raw trout", 70), COD("Raw cod", 70), PIKE(
- "Raw pike", 80), SALMON("Raw salmon", 90), TUNA("Raw tuna", 100), LOBSTER(
- "Raw lobster", 120), BASS("Raw bass", 130), SWORDFISH(
- "Raw swordfish", 140), MONKFISH("Raw monkfish", 160), SHARK(
- "Raw shark", 200), SEA_TURTLE("Raw sea turtle", 212), CAVEFISH(
- "Raw cavefish", 214), MANTA_RAY("Raw manta ray", 216), ROCKTAIL(
- "Raw rocktail", 225);
- private String name;
- private double experience;
- Cooking(final String name, final double experience) {
- this.name = name;
- this.experience = experience;
- }
- public final String getName() {
- return name;
- }
- public final double getExperience() {
- return experience;
- }
- }
- public class CookerUIV2 extends JFrame {
- public CookerUIV2() {
- initComponents();
- }
- private void initComponents() {
- locationBox = new JComboBox();
- foodList = new JComboBox();
- startButton = new JButton();
- jCheckBox1 = new JCheckBox();
- setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
- setTitle("CookerUIV2");
- locationBox.setModel(new DefaultComboBoxModel(new String[] {
- "Locations:", "Rogue's Den" }));
- foodList.setModel(new DefaultComboBoxModel(new String[] { "Food:",
- "Raw shrimp", "Raw sardine", "Raw achovies", "Raw herring",
- "Raw mackerel", "Raw trout", "Raw cod", "Raw pike",
- "Raw salmon", "Raw tuna", "Raw lobster", "Raw bass",
- "Raw swordfish", "Raw monkfish", "Raw shark",
- "Raw sea turtle", "Raw cavefish", "Raw manta ray",
- "Raw rocktail" }));
- startButton.setText("Start");
- startButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- startButtonActionPerformed(evt);
- }
- });
- jCheckBox1.setText("Hover");
- GroupLayout layout = new GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout
- .setHorizontalGroup(layout
- .createParallelGroup(GroupLayout.Alignment.LEADING)
- .addGroup(
- layout
- .createSequentialGroup()
- .addContainerGap()
- .addGroup(
- layout
- .createParallelGroup(
- GroupLayout.Alignment.TRAILING,
- false)
- .addComponent(
- foodList,
- GroupLayout.Alignment.LEADING,
- 0,
- GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)
- .addComponent(
- locationBox,
- GroupLayout.Alignment.LEADING,
- 0,
- 122,
- Short.MAX_VALUE))
- .addPreferredGap(
- LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(
- layout
- .createParallelGroup(
- GroupLayout.Alignment.LEADING)
- .addComponent(
- jCheckBox1)
- .addComponent(
- startButton,
- GroupLayout.PREFERRED_SIZE,
- 76,
- GroupLayout.PREFERRED_SIZE))
- .addContainerGap(
- GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)));
- layout.setVerticalGroup(layout.createParallelGroup(
- GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addContainerGap().addGroup(
- layout.createParallelGroup(
- GroupLayout.Alignment.BASELINE)
- .addComponent(locationBox,
- GroupLayout.PREFERRED_SIZE,
- GroupLayout.DEFAULT_SIZE,
- GroupLayout.PREFERRED_SIZE)
- .addComponent(jCheckBox1)).addPreferredGap(
- LayoutStyle.ComponentPlacement.RELATED).addGroup(
- layout.createParallelGroup(
- GroupLayout.Alignment.BASELINE)
- .addComponent(foodList,
- GroupLayout.PREFERRED_SIZE,
- GroupLayout.DEFAULT_SIZE,
- GroupLayout.PREFERRED_SIZE)
- .addComponent(startButton))
- .addContainerGap(GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)));
- pack();
- }
- private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {
- hover = jCheckBox1.isSelected();
- final String b = foodList.getSelectedItem().toString();
- final String a = foodList.getSelectedItem().toString();
- for (CookingLocations c : CookingLocations.values())
- if (c.getLocationName().equalsIgnoreCase(a))
- Cooker.setLocation(c);
- for (Cooking c : Cooking.values())
- if (c.getName().equalsIgnoreCase(b))
- Cooker.setFood(c);
- dispose();
- }
- private JComboBox foodList;
- private JCheckBox jCheckBox1;
- private JComboBox locationBox;
- private JButton startButton;
- }
- public static String name = "CSCooker";
- public static String description = "Cooks anything at rogue's den";
- public static double version = 1.30;
- }