/** * @author RegeX * modified by RulerEric */ import javax.swing.*; import java.awt.*; public class IMPRimmington extends Script implements ServerMessageListener { public static String[] commands = { "imp_rm" }; int rockID; //IRON, GOLD, COPPER, TIN private static final int[][] ores= {{9718,9719,9717},{9720,9722},{9709,9708,9710},{9714,9716}}; private static final int OBJECT_BANK_BOOTH = 11758; private static final int OBJECT_FURANCE = 2781; private static final Tile TILE_MINE = new Tile(2977, 3240); private static final Tile RUN_AWAY = new Tile(2971, 3200); private static final Tile LUMBY = new Tile(3225, 3219); private static final Tile LUMBY2 = new Tile(3234, 3224); private static final Tile OUT_LUMBY = new Tile(3212, 3280); private static final Tile OUT_LUMBY1 = new Tile(3154, 3292); private static final Tile OUT_LUMBY2 = new Tile(3106, 3297); private static final boolean DEBUG_MSG = false; private static boolean FirstTime = true; private static boolean savedselected = false; private static final Tile[] PATH_RIMMINGTON_MINE_TO_FALADOR_BANK = new Tile[] { new Tile(2969, 3239), new Tile(2977, 3241), new Tile(2977, 3249), new Tile(2977, 3258), new Tile(2977, 3267), new Tile(2977, 3267), new Tile(2981, 3272), new Tile(2986, 3275), new Tile(2991, 3280), new Tile(2995, 3284), new Tile(3000, 3289), new Tile(3004, 3293), new Tile(3005, 3300), new Tile(3005, 3309), new Tile(3007, 3315), new Tile(3008, 3323), new Tile(3008, 3332), new Tile(3008, 3341), new Tile(3008, 3350), new Tile(3008, 3358), new Tile(3013, 3355) }; private static final Tile[] FALADOR_FURNACE_TO_FALADOR_BANK = new Tile[] { new Tile(3013, 3355), new Tile(2974, 3369) }; private static final Tile[] PATH_RIMMINGTON_MINE_TO_FALADOR_FURNACE = new Tile[] { new Tile(2969, 3239), new Tile(2977, 3241), new Tile(2977, 3249), new Tile(2977, 3258), new Tile(2977, 3267), new Tile(2977, 3267), new Tile(2981, 3272), new Tile(2986, 3275), new Tile(2991, 3280), new Tile(2995, 3284), new Tile(3000, 3289), new Tile(3004, 3293), new Tile(3005, 3300), new Tile(3005, 3309), new Tile(3007, 3315), new Tile(3008, 3323), new Tile(3008, 3332), new Tile(3008, 3341), new Tile(3008, 3350), new Tile(3004, 3353), new Tile(2995, 3358), new Tile(2986, 3361), new Tile(2985, 3368), new Tile(2981, 3372), new Tile(2974, 3369) }; private long startTime = System.currentTimeMillis(); private Tile rockPos; private boolean inFurnace = false; private boolean bankDrop; private boolean increment; private int attachCount; private int gold; private int goldbars; private int iron; private int ironbars; private int copper; private int tin; private int bronzebars; private int trips; private JLabel JLabelTitle; private JProgressBar JProgressBarStatus; private JRadioButton JRadioButtonGold; private JRadioButton JRadioButtonIron; private JRadioButton JRadioButtonBoth; private JRadioButton JRadioButtonCopper; private JRadioButton JRadioButtonTin; private JRadioButton JRadioButtonTinPlusCopper; private ButtonGroup ButtonGroupore; private JRadioButton JRadioButtonBank; private JRadioButton JRadioButtonDrop; private ButtonGroup ButtonGrouppick; private JLabel JLabelGold; private JLabel JLabelGoldBars; private JLabel JLabelIron; private JLabel JLabelIronBars; private JLabel JLabelCopper; private JLabel JLabelTin; private JLabel JLabelBronzeBars; private JLabel JLabelTime; private JLabel JLabelTrips; private JLabel JLabelGoldvalue; private JLabel JLabelGoldBarsvalue; private JLabel JLabelIronvalue; private JLabel JLabelIronBarsvalue; private JLabel JLabelCoppervalue; private JLabel JLabelTinvalue; private JLabel JLabelBronzeBarsvalue; private JLabel JLabelTimevalue; private JLabel JLabelTripsvalue; private JCheckBox JCheckBoxSmelt; private JPanel JPanelMain; private JFrame JFrameMain; public boolean start(String command, String[] args) { JLabelTitle = new JLabel("By RulerEric"); JProgressBarStatus = new JProgressBar(0, 3); JProgressBarStatus.setStringPainted(true); JRadioButtonGold = new JRadioButton("Gold", false); JRadioButtonIron = new JRadioButton("Iron", false); JRadioButtonTin = new JRadioButton("Tin", false); JRadioButtonBoth = new JRadioButton("Gold then Iron", true); JRadioButtonCopper = new JRadioButton("Copper", false); JRadioButtonTin = new JRadioButton("Tin", false); JRadioButtonTinPlusCopper = new JRadioButton("1/2 Copper & 1/2 Tin"); ButtonGroupore = new ButtonGroup(); ButtonGroupore.add(JRadioButtonGold); ButtonGroupore.add(JRadioButtonIron); ButtonGroupore.add(JRadioButtonBoth); ButtonGroupore.add(JRadioButtonCopper); ButtonGroupore.add(JRadioButtonTin); ButtonGroupore.add(JRadioButtonTinPlusCopper); JRadioButtonBank = new JRadioButton("Bank", true); JRadioButtonDrop = new JRadioButton("Drop", false);; ButtonGrouppick = new ButtonGroup(); ButtonGrouppick.add(JRadioButtonBank); ButtonGrouppick.add(JRadioButtonDrop); JLabelTrips = new JLabel(" Trips: "); JLabelGold = new JLabel(" Gold: "); JLabelGoldBars = new JLabel(" Gold Bars: "); JLabelIron = new JLabel(" Iron: "); JLabelIronBars = new JLabel(" Iron Bars"); JLabelCopper = new JLabel(" Copper: "); JLabelTin = new JLabel(" Tin: "); JLabelBronzeBars = new JLabel(" Bronze Bars: "); JLabelTime = new JLabel(" Time in mins: "); JLabelGoldvalue = new JLabel("0"); JLabelGoldBarsvalue = new JLabel("0"); JLabelIronvalue = new JLabel("0"); JLabelIronBarsvalue = new JLabel("0"); JLabelCoppervalue = new JLabel("0"); JLabelTinvalue = new JLabel("0"); JLabelBronzeBarsvalue = new JLabel("0"); JLabelTimevalue = new JLabel("0"); JLabelTripsvalue = new JLabel("0"); JCheckBoxSmelt = new JCheckBox("Make bars before Bank?"); JPanelMain = new JPanel(); JPanelMain.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = 2; JPanelMain.add(JLabelTitle, c); c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; JPanelMain.add(JProgressBarStatus, c); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelTrips, c); c.gridx = 1; c.gridy = 2; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelTripsvalue, c); c.gridx = 0; c.gridy = 3; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelGold, c); c.gridx = 1; c.gridy = 3; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelGoldvalue, c); c.gridx = 0; c.gridy = 4; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelGoldBars, c); c.gridx = 1; c.gridy = 4; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelGoldBarsvalue, c); c.gridx = 0; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelIron, c); c.gridx = 1; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelIronvalue, c); c.gridx = 0; c.gridy = 6; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelIronBars, c); c.gridx = 1; c.gridy = 6; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelIronBarsvalue, c); c.gridx = 0; c.gridy = 7; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelCopper, c); c.gridx = 1; c.gridy = 7; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelCoppervalue, c); c.gridx = 0; c.gridy = 8; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelTin, c); c.gridx = 1; c.gridy = 8; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelTinvalue, c); c.gridx = 0; c.gridy = 9; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelBronzeBars, c); c.gridx = 1; c.gridy = 9; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelBronzeBarsvalue, c); c.gridx = 0; c.gridy = 10; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelTime, c); c.gridx = 1; c.gridy = 10; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JLabelTimevalue, c); c.gridx = 0; c.gridy = 11; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JRadioButtonBank, c); c.gridx = 1; c.gridy = 11; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JRadioButtonDrop, c); c.gridx = 0; c.gridy = 12; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JCheckBoxSmelt, c); c.gridx = 0; c.gridy = 13; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JRadioButtonTinPlusCopper, c); c.gridx = 0; c.gridy = 14; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JRadioButtonBoth, c); c.gridx = 0; c.gridy = 15; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JRadioButtonGold, c); c.gridx = 0; c.gridy = 16; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JRadioButtonIron, c); c.gridx = 0; c.gridy = 17; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JRadioButtonCopper, c); c.gridx = 0; c.gridy = 18; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; JPanelMain.add(JRadioButtonTin, c); JFrameMain = new JFrame("IMP Rimmington 2"); JFrameMain.setLayout(new GridLayout()); JFrameMain.setSize(220, 420); JFrameMain.setResizable(false); JFrameMain.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JFrameMain.getContentPane().add(JPanelMain); JFrameMain.setVisible(true); init(); return true; } private void init() { EventManager.addServerMessageListener(this); startTime = System.currentTimeMillis(); } public void serverMessage(String message) { if (message.indexOf("you are dead") != -1) { JProgressBarStatus.setString("You died"); //shutdown(); } else if (message.indexOf("carefully attach") != -1) { attachCount++; } else if (message.indexOf("manage to") != -1) { rockPos = null; } } public long run(long ticks) { if(FirstTime) { progressReport(); FirstTime=false; } if(JCheckBoxSmelt.isSelected() != savedselected) { progressReport(); savedselected=JCheckBoxSmelt.isSelected(); } long rez = runCombat(); if (rez != 0){ return rez; } boolean b; if (JRadioButtonBank.isSelected()){ rez = runBank(); } else { rez = runDrop(); } if (rez != 0){ return rez; } rez = runArea(); if (rez != 0){ return rez; } return runMine(); } private long runCombat() { if (inCombat(myPlayer())) { if (distanceTo(TILE_MINE) < 30) { JProgressBarStatus.setString("We are under attack"); walktotile(RUN_AWAY); return random(2500, 3000); } } return 0; } private long runBank() { if (bankDrop) { if(JCheckBoxSmelt.isSelected()) { //iron gold bronze if(inventoryCount(440) > 0 && getCurrentStat(getSkillIndex("Smithing")) > 14 || inventoryCount(444) > 0 && getCurrentStat(getSkillIndex("Smithing")) > 40|| (inventoryCount(438) > 0 && inventoryCount(436) > 0)) { Tile[] path = PATH_RIMMINGTON_MINE_TO_FALADOR_FURNACE; boolean near_path = false; for(int i=0;i 0) { JProgressBarStatus.setValue(2); JProgressBarStatus.setString("Walking to Smelt"); walkPath(path, 15); return random(3000, 3500); } else { if (!(inFurnace)) { int furance = findObject(OBJECT_FURANCE); if (furance != -1) { atObject(furance, 2); inFurnace = true; return random(2000, 3500); } } else { System.out.println("atInterface"); inFurnace = false; if(inventoryCount(440) > 0 && getCurrentStat(getSkillIndex("Smithing")) > 14) { atInterface(3989,1); if(inventoryCount(440) > 10){ return 10*random(3500,4000)+1000; } else { return inventoryCount(440)*random(3500,4000); } } else if(inventoryCount(444) > 0 && getCurrentStat(getSkillIndex("Smithing")) > 40) { atInterface(4001,1); if(inventoryCount(444) > 10){ return 10*random(3500,4000)+1000; } else { return inventoryCount(444)*random(3500,4000); } } else if(inventoryCount(438) > 0 && inventoryCount(436) > 0) { atInterface(2807,1); if(inventoryCount(438) > 10){ return 10*random(3500,4000)+1000; } else { return inventoryCount(438)*random(3500,4000); } } } } } else if (getInterface() == OBJECT_FURANCE){ closeInterface(); } } Tile[] path = PATH_RIMMINGTON_MINE_TO_FALADOR_BANK; boolean near_path = false; for(int i=0;i 2) { JProgressBarStatus.setValue(2); JProgressBarStatus.setString("Walking to Bank"); walkPath(path, 15); return random(3000, 3500); } else { if (getInterface() != Constants.INTERFACE_BANK) { int booth = findObject(OBJECT_BANK_BOOTH); if (booth != -1) { increment=true; JProgressBarStatus.setValue(3); JProgressBarStatus.setString("Opening bank"); atObject(booth, 2); return random(3000, 3500); } } else if (getInterface() == Constants.INTERFACE_BANK) { if (inventoryCount() > getInvCountSuffix(" pickaxe")) { return bankOre(); } else { closeInterface(); JProgressBarStatus.setValue(0); JProgressBarStatus.setString("Finished banking"); progressReport(); bankDrop = false; } } } } if (inventoryCount() == 28 && !bankDrop) { JProgressBarStatus.setString("Inv Full"); bankDrop = true; return 1; } else { bankDrop = false; } return 0; } private long runDrop() { if (inventoryCount() == getInvCountSuffix(" pickaxe") && bankDrop) { bankDrop = false; return 0; } if (bankDrop) { return dropOre(); } if (inventoryCount() == 28) { JProgressBarStatus.setString("Time to drop.."); progressReport(); bankDrop = true; return 1; } return 0; } //if not in mine go to the mine private long runArea() { if (distanceTo(TILE_MINE) > 15) { JProgressBarStatus.setValue(0); if (distanceTo(LUMBY) < 190){ JProgressBarStatus.setString("Walking to Mine from Lumby"); if (distanceTo(LUMBY) < 8) { return walktotile(LUMBY2); } else if (distanceTo(LUMBY) < 60) { return walktotile(OUT_LUMBY); } else if (distanceTo(OUT_LUMBY) < 57) { return walktotile(OUT_LUMBY1); } else { return walktotile(OUT_LUMBY2); } } else { JProgressBarStatus.setString("Walking to Mine"); Tile[] path = reversePath(PATH_RIMMINGTON_MINE_TO_FALADOR_BANK); boolean near_path = false; for(int i=0;i 5) { walktotile(pos); return random(1100, 2000); } else { rockPos = pos; atObject(rockID, 1); return random(3000, 3500); } } //finds iron rockID = findObject(ores[0]); if (rockID != -1) { Tile pos = objectPos(rockID); if (distanceTo(pos) > 5) { walktotile(pos); return random(1100, 2000); } else { rockPos = pos; atObject(rockID, 1); return random(3000, 3500); } } else { JProgressBarStatus.setString("Couldn't find rock, waiting..."); return random(3000, 3500); } } else { if(JRadioButtonIron.isSelected()){ rockID = findObject(ores[0]); } else if(JRadioButtonGold.isSelected()) { rockID = findObject(ores[1]); } else if(JRadioButtonCopper.isSelected()) { rockID = findObject(ores[2]); } else if(JRadioButtonTin.isSelected()) { rockID = findObject(ores[3]); } else if(JRadioButtonTinPlusCopper.isSelected()) { if(getInvCountPrefix("coppe") < 14){ rockID = findObject(ores[2]); } else { rockID = findObject(ores[3]); } } if (rockID != -1) { Tile pos = objectPos(rockID); if (distanceTo(pos) > 10) { walktotile(pos); return random(1100, 2000); } else { rockPos = pos; atObject(rockID, 1); return random(3000, 3500); } } else { JProgressBarStatus.setString("Couldn't find rock, waiting..."); return random(3000, 3500); } } } else { } return 200; } private long dropOre() { int[] inv = getInventory(); if (getTab() != Constants.TAB_INVENTORY) { selectTab(Constants.TAB_INVENTORY); return random(250, 500); } for (int i = 0; i < inv.length; i++) { if (inv[i] != -1 && !getItemName(inv[i]).toLowerCase().endsWith(" pickaxe")) { dropItem(inv[i], i); return random(1000, 1500); } } return 0; } private long bankOre() { int[] inv = getInventory(); if(increment){ iron += inventoryCount(440); ironbars += inventoryCount(2351); copper += inventoryCount(436); bronzebars += inventoryCount(2349); tin += inventoryCount(438); gold += inventoryCount(444); goldbars += inventoryCount(2347); trips++; increment=false; } for (int i = 0; i < inv.length; i++) { if (inv[i] != -1 && !getItemName(inv[i]).toLowerCase().endsWith(" pickaxe")) { depositAll(inv[i], i); return random(1000, 1500); } } return 0; } private long progressReport() { int minutes = (int) ((System.currentTimeMillis() - startTime) / 60000); JLabelTimevalue. setText(""+minutes); JLabelIronvalue. setText(""+iron); JLabelIronBarsvalue. setText(""+ironbars); JLabelGoldvalue. setText(""+gold); JLabelGoldBarsvalue. setText(""+goldbars); JLabelCoppervalue. setText(""+copper); JLabelTinvalue. setText(""+tin); JLabelBronzeBarsvalue. setText(""+bronzebars); JLabelTripsvalue. setText(""+trips); if(JCheckBoxSmelt.isSelected()) { if(getCurrentStat(getSkillIndex("Mining")) > 14 && getCurrentStat(getSkillIndex("Smithing")) > 14) { JRadioButtonIron.setEnabled(true); if(getCurrentStat(getSkillIndex("Mining")) > 39 && getCurrentStat(getSkillIndex("Smithing")) > 39) { JRadioButtonGold.setEnabled(true); JRadioButtonBoth.setEnabled(true); } else { JRadioButtonGold.setEnabled(false); JRadioButtonBoth.setEnabled(false); } } else { JRadioButtonIron.setEnabled(false); JRadioButtonGold.setEnabled(false); JRadioButtonBoth.setEnabled(false); } } else { if(getCurrentStat(getSkillIndex("Mining")) > 14) { JRadioButtonIron.setEnabled(true); if(getCurrentStat(getSkillIndex("Mining")) > 39) { JRadioButtonGold.setEnabled(true); JRadioButtonBoth.setEnabled(true); } else { JRadioButtonGold.setEnabled(false); JRadioButtonBoth.setEnabled(false); } } else { JRadioButtonIron.setEnabled(false); JRadioButtonGold.setEnabled(false); JRadioButtonBoth.setEnabled(false); } } return 0; } /** * walktotile finds a tile in the direct of the destination tile. If the * tile it finds it unreachable it searchs in a spiral pattern for one that * is * * @author esnellman * @param Destination, * tile to run toward */ private long walktotile(Tile Destination) { if (distanceTo(Destination) > 9) { int x_diff = (Destination.x - getPosition(myPlayer()).x); int y_diff = (Destination.y - getPosition(myPlayer()).y); int abs_x_diff = Math.abs(x_diff); int abs_y_diff = Math.abs(y_diff); int multiple = random(7, 9); int x = (int) (getPosition(myPlayer()).x + multiple * x_diff / (abs_x_diff + abs_y_diff)); int y = (int) (getPosition(myPlayer()).y + multiple * y_diff / (abs_x_diff + abs_y_diff)); int x_change = 0; int y_change = 0; int size = 0; if (!(canReach(new Tile(x, y)))) { // center multiple = 5; x = (int) (getPosition(myPlayer()).x + multiple * x_diff / (abs_x_diff + abs_y_diff)); y = (int) (getPosition(myPlayer()).y + multiple * y_diff / (abs_x_diff + abs_y_diff)); while (!(canReach(new Tile(x + x_change, y + y_change)))) { /* * BOX: [1, 2] [-1, 1][0, 1][1, 1] [-1, 0][0, 0][1, 0] * [-1,-1][0,-1][1,-1] */ if (size >= 8) { if (DEBUG_MSG) { log("[WalkToTile] -D [Error]or[LOGIN?] failed to find a tile in range"); } return random(1500, 2000); } // along x+ top of box else if (y_change == size && x_change < size && x_change > 0) { x_change++; } // directly above origin else if (x_change == 0 && y_change >= 0) { y_change++; x_change++; size++; } // along x- top of box else if (y_change == size && x_change < 0) { x_change++; } // along bottom of box else if (y_change == (-1 * size) && x_change > (-1 * size)) { x_change--; } // along right side of box else if (x_change == size) { y_change--; } // along left side of box else if (x_change == -1 * size) { y_change++; } if (DEBUG_MSG) { log("[WalkToTile] -D trying x_change= " + x_change + " y_change= " + y_change); } } } Tile walkto = new Tile(x + x_change, y + y_change); if (DEBUG_MSG) { log("[WalkToTile] -D Walking to X:" + Integer.toString(x) + " Y:" + Integer.toString(y)); } walk(walkto); } else { walk(Destination); } return random(2500, 3000); } }