├── .gitignore ├── DreambotAgility └── src │ └── main │ └── java │ └── nezz │ └── dreambot │ ├── AgilityTree.java │ ├── course │ ├── Course.java │ └── impl │ │ ├── AlKharid.java │ │ └── Draynor.java │ └── roof │ ├── Obstacle.java │ └── Roof.java ├── DreambotAutoBuyer └── src │ └── nezz │ └── dreambot │ ├── autobuyer │ └── gui │ │ ├── ScriptVars.java │ │ └── buyerGui.java │ ├── scriptmain │ └── autobuyer │ │ └── AutoBuyer.java │ └── tools │ └── PricedItem.java ├── DreambotDruids └── src │ └── nezz │ └── dreambot │ ├── druids │ └── gui │ │ ├── ScriptVars.java │ │ └── druidsGui.java │ ├── scriptmain │ └── druids │ │ ├── Druids.java │ │ └── Herbs.java │ └── tools │ └── PricedItem.java ├── DreambotFisher └── src │ └── nezz │ └── dreambot │ ├── fisher │ ├── enums │ │ └── Fish.java │ └── gui │ │ ├── ScriptVars.java │ │ └── fisherGui.java │ ├── scriptmain │ └── fisher │ │ └── Fisher.java │ └── tools │ └── PricedItem.java ├── DreambotFlaxPicker └── src │ └── nezz │ └── dreambot │ ├── scriptmain │ └── flaxpicker │ │ └── Flax.java │ └── tools │ └── PricedItem.java ├── DreambotFletcher └── src │ └── nezz │ └── dreambot │ ├── fletcher │ └── gui │ │ ├── ScriptVars.java │ │ └── fletchGUI.java │ └── scriptmain │ └── fletch │ ├── Fletcher.java │ └── Fletching.java ├── DreambotHerblore └── src │ └── nezz │ └── dreambot │ ├── herblore │ └── gui │ │ ├── ScriptVars.java │ │ └── herbloreGui.java │ ├── scriptmain │ └── herblore │ │ ├── DebugScreens.java │ │ ├── Herblore.java │ │ ├── Herbs.java │ │ ├── Identify.java │ │ ├── Potions.java │ │ ├── Pots.java │ │ ├── States.java │ │ └── UnfPotions.java │ └── tools │ └── PricedItem.java ├── DreambotHillPrayer └── src │ └── nezz │ └── dreambot │ └── scriptmain │ └── hillprayer │ └── HillPrayer.java ├── DreambotHunter └── src │ └── nezz │ └── dreambot │ ├── scriptmain │ └── hunter │ │ ├── Hunt.java │ │ ├── Hunter.java │ │ └── gui │ │ ├── ScriptVars.java │ │ └── hunterGui.java │ └── tools │ └── PricedItem.java ├── DreambotIronKnifer └── src │ └── nezz │ └── dreambot │ ├── scriptmain │ └── ironknifer │ │ ├── AnvilSmith.java │ │ └── IronKnifer.java │ └── tools │ └── PricedItem.java ├── DreambotMiner └── src │ └── nezz │ └── dreambot │ ├── filemethods │ └── FileMethods.java │ ├── powerminer │ └── gui │ │ ├── ScriptVars.java │ │ └── minerGui.java │ ├── scriptmain │ └── powerminer │ │ ├── MineTask.java │ │ └── Miner.java │ └── tools │ └── PricedItem.java ├── DreambotPackBuyer └── src │ └── nezz │ └── dreambot │ ├── packbuyer │ └── gui │ │ ├── ScriptVars.java │ │ └── buyerGui.java │ ├── scriptmain │ └── packbuyer │ │ └── PackBuyer.java │ └── tools │ └── PricedItem.java ├── DreambotThiever └── src │ └── nezz │ └── dreambot │ ├── scriptmain │ └── thiever │ │ └── Thiever.java │ └── thiever │ ├── enums │ └── Thieving.java │ └── gui │ ├── ScriptVars.java │ └── thieverGui.java ├── DreambotTutIsland └── src │ └── nezz │ └── dreambot │ ├── filemethods │ └── FileMethods.java │ ├── scriptmain │ └── tutisland │ │ └── TutorialIsland.java │ └── tutisland │ └── gui │ ├── ScriptVars.java │ └── tutIslandGui.java └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | 26 | #Idea Files 27 | *.idea 28 | *.xml 29 | *.iml 30 | 31 | #Git Files 32 | *.gitignore 33 | 34 | */target/* 35 | 36 | out/* -------------------------------------------------------------------------------- /DreambotAgility/src/main/java/nezz/dreambot/AgilityTree.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot; 2 | 3 | import nezz.dreambot.course.impl.AlKharid; 4 | import nezz.dreambot.course.impl.Draynor; 5 | import org.dreambot.api.methods.interactive.Players; 6 | import org.dreambot.api.script.Category; 7 | import org.dreambot.api.script.ScriptManifest; 8 | import org.dreambot.api.script.frameworks.treebranch.TreeScript; 9 | import org.dreambot.api.script.listener.PaintListener; 10 | 11 | import java.awt.*; 12 | 13 | @ScriptManifest(category = Category.AGILITY, name = "Nezz Agility", description = "Free Agility script", author = "Nezz", version = 1.0) 14 | public class AgilityTree extends TreeScript implements PaintListener { 15 | //TODO probably make it finish course before checking if next course is valid. 16 | @Override 17 | public void onStart(String... params) { 18 | onStart(); 19 | } 20 | 21 | @Override 22 | public void onStart() { 23 | addBranches( 24 | new AlKharid(), 25 | new Draynor()); 26 | } 27 | 28 | @Override 29 | public void onExit() { 30 | super.onExit(); 31 | } 32 | 33 | @Override 34 | public void onPaint(Graphics2D graphics) { 35 | if(getCurrentBranchName() != null){ 36 | graphics.drawString(getCurrentBranchName()+":"+getCurrentLeafName(), 5, 135); 37 | graphics.drawString("Moving: " + Players.getLocal().isMoving(), 5, 150); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /DreambotAgility/src/main/java/nezz/dreambot/course/Course.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.course; 2 | 3 | import nezz.dreambot.roof.Obstacle; 4 | import nezz.dreambot.roof.Roof; 5 | import org.dreambot.api.methods.Calculations; 6 | import org.dreambot.api.methods.interactive.Players; 7 | import org.dreambot.api.methods.map.Map; 8 | import org.dreambot.api.methods.map.Tile; 9 | import org.dreambot.api.methods.walking.impl.Walking; 10 | import org.dreambot.api.script.frameworks.treebranch.Branch; 11 | import org.dreambot.api.utilities.Logger; 12 | import org.dreambot.api.utilities.Sleep; 13 | 14 | import java.util.List; 15 | 16 | public abstract class Course extends Branch { 17 | 18 | private final Tile start; 19 | private final Obstacle startObs; 20 | 21 | public Course(Tile start, Obstacle startObs){ 22 | this.start = start; 23 | this.startObs = startObs; 24 | } 25 | 26 | public abstract List getRoofs(); 27 | 28 | public int start(){ 29 | if(start.distance() > 5 || !Map.canReach(start)){ 30 | if(Walking.getDestinationDistance() > 5){ 31 | if(!Walking.isRunEnabled() && Walking.getRunEnergy() > 35){ 32 | Walking.toggleRun(); 33 | Sleep.sleepTick(); 34 | } 35 | return Calculations.random(350, 800); 36 | } 37 | Walking.walk(start); 38 | } 39 | else{ 40 | if(startObs.traverse()){ 41 | Sleep.sleepUntil(()->getRoofs().get(0).getArea().contains(Players.getLocal().getTile()) && !Players.getLocal().isMoving() && !Players.getLocal().isAnimating(), ()->Players.getLocal().isMoving() || Players.getLocal().isAnimating(), 3000,150); 42 | return Calculations.random(400,700); 43 | } 44 | } 45 | return Calculations.random(100,250); 46 | } 47 | 48 | public boolean needsStart(){ 49 | return getCurrent() == null; 50 | } 51 | 52 | private int currentIndex = -1; 53 | 54 | public Roof getCurrent(){ 55 | Logger.debug("Current index; " + currentIndex); 56 | for(int i = Math.max(currentIndex, 0); i < getRoofs().size(); i++){ 57 | Roof roof = getRoofs().get(i); 58 | if(roof.getArea().contains(Players.getLocal().getTile())){ 59 | currentIndex = i; 60 | return roof; 61 | } 62 | } 63 | if(currentIndex >= 0 && Players.getLocal().getTile().getZ() > 0){ 64 | //we shouldn't reset 65 | return getRoofs().get(currentIndex); 66 | } 67 | currentIndex = -1; 68 | return null; 69 | } 70 | public Roof getNext(){ 71 | if(currentIndex >= getRoofs().size()-1){ 72 | return null; 73 | } 74 | return getRoofs().get(currentIndex+1); 75 | } 76 | 77 | @Override 78 | public int onLoop(){ 79 | if(needsStart()){ 80 | Logger.debug("Starting course!"); 81 | return start(); 82 | } 83 | Roof curr = getCurrent(); 84 | return curr != null ? curr.traverse(getNext()) : Calculations.random(400, 700); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /DreambotAgility/src/main/java/nezz/dreambot/course/impl/AlKharid.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.course.impl; 2 | 3 | import nezz.dreambot.course.Course; 4 | import nezz.dreambot.roof.Obstacle; 5 | import nezz.dreambot.roof.Roof; 6 | import org.dreambot.api.methods.map.Area; 7 | import org.dreambot.api.methods.map.Tile; 8 | import org.dreambot.api.methods.skills.Skill; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class AlKharid extends Course { 14 | private List areas = new ArrayList<>(); 15 | 16 | public AlKharid() { 17 | super(new Tile(3273, 3195, 0), new Obstacle("Rough wall", "Climb", new Tile(3273, 3195, 0))); 18 | areas.add(new Roof(new Obstacle("Tightrope", "Cross", null)).buildArea(new Area(3279, 3193, 3270, 3180, 3))); 19 | areas.add(new Roof(new Obstacle("Cable", "Swing-across", null)).buildArea(new Area(3273, 3174, 3264, 3161, 3))); 20 | areas.add(new Roof(new Obstacle("Zip line", "Teeth-grip", null)).buildArea(new Area(3282, 3175, 3303, 3160, 3))); 21 | areas.add(new Roof(new Obstacle("Tropical Tree", "Swing-across", null)).buildArea(new Area(3321, 3157, 3308, 3173, 1))); 22 | areas.add(new Roof(new Obstacle("Roof top beams", "Climb", null)).buildArea(new Area(3317, 3174, 3312, 3180, 2))); 23 | areas.add(new Roof(new Obstacle("Tightrope", "Cross", null)).buildArea(new Area(3319, 3180, 3310, 3187, 3))); 24 | areas.add(new Roof(new Obstacle("Gap", "Jump", null)).buildArea(new Area(3306, 3184, 3296, 3195, 3))); 25 | } 26 | 27 | @Override 28 | public boolean isValid() { 29 | return Skill.AGILITY.getBoostedLevel() >= 20; 30 | } 31 | 32 | @Override 33 | public List getRoofs() { 34 | return areas; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /DreambotAgility/src/main/java/nezz/dreambot/course/impl/Draynor.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.course.impl; 2 | 3 | import nezz.dreambot.course.Course; 4 | import nezz.dreambot.roof.Obstacle; 5 | import nezz.dreambot.roof.Roof; 6 | import org.dreambot.api.methods.map.Area; 7 | import org.dreambot.api.methods.map.Tile; 8 | import org.dreambot.api.methods.skills.Skill; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class Draynor extends Course { 14 | private List areas = new ArrayList<>(); 15 | 16 | public Draynor() { 17 | super(new Tile(3104, 3279, 0), new Obstacle("Rough wall", "Climb", new Tile(3104, 3279, 0))); 18 | areas.add(new Roof(new Obstacle("Tightrope", "Cross", null)).buildArea(new Area(3099, 3277, 3103, 3281, 3))); 19 | areas.add(new Roof(new Obstacle("Tightrope", "Cross", null)).buildArea(new Area(new Tile(3090, 3276, 3), 20 | new Tile(3091, 3276, 3), 21 | new Tile(3089, 3275, 3), 22 | new Tile(3090, 3275, 3), 23 | new Tile(3091, 3275, 3), 24 | new Tile(3088, 3274, 3), 25 | new Tile(3089, 3274, 3), 26 | new Tile(3090, 3274, 3), 27 | new Tile(3091, 3274, 3), 28 | new Tile(3089, 3273, 3), 29 | new Tile(3090, 3273, 3)))); 30 | areas.add(new Roof(new Obstacle("Narrow wall", "Balance", null)).buildArea(new Area(3094, 3265, 3089, 3267, 3))); 31 | areas.add(new Roof(new Obstacle("Wall", "Jump-up", null)).buildArea(new Area(3088, 3261, 3088, 3258, 3))); 32 | areas.add(new Roof(new Obstacle("Gap", "Jump", null)).buildArea(new Area(3087, 3255, 3094, 3255, 3))); 33 | areas.add(new Roof(new Obstacle("Crate", "Climb-down", null)).buildArea(new Area(3096, 3261, 3101, 3256, 3))); 34 | } 35 | 36 | @Override 37 | public boolean isValid() { 38 | return Skill.AGILITY.getBoostedLevel() >= 10; 39 | } 40 | 41 | @Override 42 | public List getRoofs() { 43 | return areas; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /DreambotAgility/src/main/java/nezz/dreambot/roof/Obstacle.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.roof; 2 | 3 | import lombok.*; 4 | import org.dreambot.api.methods.interactive.GameObjects; 5 | import org.dreambot.api.methods.interactive.Players; 6 | import org.dreambot.api.methods.map.Tile; 7 | import org.dreambot.api.methods.walking.impl.Walking; 8 | import org.dreambot.api.utilities.Sleep; 9 | import org.dreambot.api.wrappers.interactive.GameObject; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @Builder(access = AccessLevel.PUBLIC) 15 | public class Obstacle { 16 | private String name; 17 | private String action; 18 | private Tile start; 19 | 20 | public boolean traverse(){ 21 | if(start != null && start.distance() > 3){ 22 | Walking.walk(start); 23 | Sleep.sleepUntil(()->start.distance() <= 3, ()-> Players.getLocal().isMoving(), 1200, 200); 24 | return false; 25 | } 26 | GameObject obj = GameObjects.closest(f->f.getName().equalsIgnoreCase(name) && f.hasAction(action), start != null ? start : Players.getLocal().getTile()); 27 | if(obj == null){ 28 | return false; 29 | } 30 | if(obj.distance() > 5){ 31 | Walking.walk(obj); 32 | Sleep.sleepUntil(()->obj.distance() <= 5, ()->Players.getLocal().isMoving(), 2000, 100); 33 | } 34 | return obj.interact(action); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /DreambotAgility/src/main/java/nezz/dreambot/roof/Roof.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.roof; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.dreambot.api.methods.Calculations; 6 | import org.dreambot.api.methods.interactive.Players; 7 | import org.dreambot.api.methods.map.Area; 8 | import org.dreambot.api.methods.map.Tile; 9 | import org.dreambot.api.utilities.Logger; 10 | import org.dreambot.api.utilities.Sleep; 11 | 12 | import java.util.ArrayList; 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | /** 17 | * contains areas and obstacle information 18 | */ 19 | @Getter 20 | @Setter 21 | public class Roof { 22 | private Obstacle obstacle; 23 | private Area area; 24 | 25 | public Roof(Obstacle obstacle) { 26 | this.obstacle = obstacle; 27 | } 28 | 29 | public Roof buildArea(Area area) { 30 | if (this.area == null) { 31 | this.area = area; 32 | return this; 33 | } 34 | //TODO update this when db updates for better area stuff 35 | List areaTiles = new ArrayList<>(Arrays.asList(area.getTiles())); 36 | areaTiles.addAll(Arrays.asList(this.area.getTiles())); 37 | this.area = new Area(areaTiles.toArray(new Tile[0])); 38 | return this; 39 | } 40 | 41 | public int traverse(Roof next) { 42 | if (obstacle.traverse()) { 43 | Sleep.sleepUntil(() -> !area.contains(Players.getLocal().getTile()), () -> Players.getLocal().isMoving() || Players.getLocal().isAnimating(), 3000, 300); 44 | if (next != null) { 45 | Sleep.sleepUntil(() -> next.getArea().contains(Players.getLocal().getTile()) && !Players.getLocal().isMoving() && !Players.getLocal().isAnimating(), () -> Players.getLocal().isMoving() || Players.getLocal().isAnimating(), 3000, 300); 46 | if (next.getArea().contains(Players.getLocal().getTile())) { 47 | return Calculations.random(250, 600); 48 | } 49 | } else { 50 | Sleep.sleepUntil(() -> !Players.getLocal().isMoving() && !Players.getLocal().isAnimating() && Players.getLocal().getTile().getZ() == 0, 3000); 51 | Sleep.sleepTicks(2); 52 | return Calculations.random(450, 800); 53 | } 54 | } else { 55 | Logger.debug("Failed to interact with obstacle?"); 56 | } 57 | return Calculations.random(120, 350); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /DreambotAutoBuyer/src/nezz/dreambot/autobuyer/gui/ScriptVars.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.autobuyer.gui; 2 | 3 | import nezz.dreambot.tools.PricedItem; 4 | 5 | public class ScriptVars { 6 | public PricedItem item; 7 | public String itemName; 8 | public String shopName; 9 | public int shopId; 10 | public int minAmt = 0; 11 | public boolean hopWorlds = false; 12 | public boolean f2p = false; 13 | public boolean started = false; 14 | } 15 | -------------------------------------------------------------------------------- /DreambotAutoBuyer/src/nezz/dreambot/autobuyer/gui/buyerGui.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.autobuyer.gui; 2 | 3 | import javax.swing.JFrame; 4 | import javax.swing.JPanel; 5 | import javax.swing.border.EmptyBorder; 6 | 7 | import java.awt.Toolkit; 8 | 9 | import javax.swing.JLabel; 10 | import javax.swing.JTextField; 11 | import javax.swing.JCheckBox; 12 | import javax.swing.JButton; 13 | 14 | import java.awt.event.ActionListener; 15 | import java.awt.event.ActionEvent; 16 | import java.awt.Color; 17 | 18 | public class buyerGui extends JFrame { 19 | 20 | /** 21 | * 22 | */ 23 | private static final long serialVersionUID = 1L; 24 | private JPanel contentPane; 25 | 26 | private JTextField txtItemName; 27 | private JTextField txtShopName; 28 | JCheckBox chckbxHopWorlds = new JCheckBox("hop worlds"); 29 | private JTextField txtMinAmt; 30 | 31 | 32 | public buyerGui(final ScriptVars var) { 33 | setTitle("DreamBot Pack Buyer"); 34 | setIconImage(Toolkit.getDefaultToolkit().getImage(buyerGui.class.getResource("/javax/swing/plaf/metal/icons/ocean/computer.gif"))); 35 | setAlwaysOnTop(true); 36 | setResizable(false); 37 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 38 | setBounds(100, 100, 276, 237); 39 | contentPane = new JPanel(); 40 | contentPane.setBackground(Color.WHITE); 41 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 42 | setContentPane(contentPane); 43 | contentPane.setLayout(null); 44 | 45 | JPanel panel = new JPanel(); 46 | panel.setBounds(0, 0, 270, 163); 47 | contentPane.add(panel); 48 | panel.setLayout(null); 49 | 50 | JLabel lblItemName = new JLabel("Item Name:"); 51 | lblItemName.setBounds(0, 11, 93, 14); 52 | panel.add(lblItemName); 53 | 54 | txtItemName = new JTextField(); 55 | txtItemName.setText("Iron arrow"); 56 | txtItemName.setBounds(96, 9, 132, 20); 57 | panel.add(txtItemName); 58 | txtItemName.setColumns(10); 59 | 60 | txtShopName = new JTextField(); 61 | txtShopName.setText("Betty"); 62 | txtShopName.setColumns(10); 63 | txtShopName.setBounds(96, 36, 132, 20); 64 | panel.add(txtShopName); 65 | 66 | JLabel lblShopName = new JLabel("Shop Identifier:"); 67 | lblShopName.setBounds(0, 38, 93, 14); 68 | panel.add(lblShopName); 69 | 70 | JLabel lblPerItem = new JLabel("f2p:"); 71 | lblPerItem.setBounds(0, 69, 93, 14); 72 | panel.add(lblPerItem); 73 | 74 | JLabel lblHopWorlds = new JLabel("Hop Worlds:"); 75 | lblHopWorlds.setBounds(0, 94, 73, 14); 76 | panel.add(lblHopWorlds); 77 | 78 | chckbxHopWorlds.setBounds(96, 90, 97, 23); 79 | panel.add(chckbxHopWorlds); 80 | 81 | JLabel lblMinimumAmt = new JLabel("Minimum Amt:"); 82 | lblMinimumAmt.setBounds(0, 121, 93, 14); 83 | panel.add(lblMinimumAmt); 84 | 85 | txtMinAmt = new JTextField(); 86 | txtMinAmt.setText("10"); 87 | txtMinAmt.setBounds(96, 118, 39, 20); 88 | panel.add(txtMinAmt); 89 | txtMinAmt.setColumns(10); 90 | 91 | final JCheckBox chckbxFpOnly = new JCheckBox("f2p only"); 92 | chckbxFpOnly.setBounds(96, 63, 97, 23); 93 | panel.add(chckbxFpOnly); 94 | 95 | JButton btnNewButton = new JButton("Start!"); 96 | btnNewButton.addActionListener(new ActionListener() { 97 | public void actionPerformed(ActionEvent arg0) { 98 | try { 99 | var.shopId = Integer.parseInt(txtShopName.getText()); 100 | } catch (Exception e) { 101 | var.shopName = txtShopName.getText(); 102 | } 103 | var.itemName = txtItemName.getText(); 104 | var.hopWorlds = chckbxHopWorlds.isSelected(); 105 | var.f2p = chckbxFpOnly.isSelected(); 106 | var.minAmt = Integer.parseInt(txtMinAmt.getText()); 107 | var.started = true; 108 | dispose(); 109 | } 110 | }); 111 | btnNewButton.setBounds(0, 174, 270, 34); 112 | contentPane.add(btnNewButton); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /DreambotAutoBuyer/src/nezz/dreambot/scriptmain/autobuyer/AutoBuyer.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.autobuyer; 2 | 3 | import nezz.dreambot.autobuyer.gui.ScriptVars; 4 | import nezz.dreambot.autobuyer.gui.buyerGui; 5 | import nezz.dreambot.tools.PricedItem; 6 | import org.dreambot.api.Client; 7 | import org.dreambot.api.methods.Calculations; 8 | import org.dreambot.api.methods.container.impl.Inventory; 9 | import org.dreambot.api.methods.container.impl.Shop; 10 | import org.dreambot.api.methods.filter.Filter; 11 | import org.dreambot.api.methods.interactive.NPCs; 12 | import org.dreambot.api.methods.interactive.Players; 13 | import org.dreambot.api.methods.world.World; 14 | import org.dreambot.api.methods.world.Worlds; 15 | import org.dreambot.api.methods.worldhopper.WorldHopper; 16 | import org.dreambot.api.script.AbstractScript; 17 | import org.dreambot.api.script.Category; 18 | import org.dreambot.api.script.ScriptManifest; 19 | import org.dreambot.api.utilities.Sleep; 20 | import org.dreambot.api.utilities.Timer; 21 | import org.dreambot.api.wrappers.interactive.NPC; 22 | import org.dreambot.api.wrappers.items.Item; 23 | 24 | import java.awt.*; 25 | import java.util.List; 26 | 27 | @ScriptManifest(author = "Nezz", name = "DreamBot Auto Buyer", version = 0, category = Category.MONEYMAKING, description = "Buys any pack and opens it") 28 | public class AutoBuyer extends AbstractScript { 29 | 30 | Timer timer; 31 | ScriptVars sv = new ScriptVars(); 32 | State state; 33 | boolean hoppingWorlds = false; 34 | private long startGP = 0; 35 | 36 | Filter shopFilter = n -> { 37 | if (n == null || !n.exists()) 38 | return false; 39 | if (sv.shopId > 0 && n.getID() == sv.shopId) { 40 | return true; 41 | } 42 | return !sv.shopName.equals("") && sv.shopName.equals(n.getName()); 43 | }; 44 | 45 | boolean started = false; 46 | 47 | private enum State { 48 | BUY, HOP 49 | } 50 | 51 | private State getState() { 52 | if (hoppingWorlds) 53 | return State.HOP; 54 | return State.BUY; 55 | } 56 | 57 | public void onStart() { 58 | buyerGui gui = new buyerGui(sv); 59 | gui.setVisible(true); 60 | while (!sv.started) { 61 | Sleep.sleep(200); 62 | } 63 | startGP = Inventory.count("Coins"); 64 | sv.item = new PricedItem(sv.itemName, true); 65 | timer = new Timer(); 66 | started = true; 67 | } 68 | 69 | /** 70 | * Gets a World ID that makes it through the filters. 71 | * 72 | * @return Integer value of the world. 73 | */ 74 | private int getHopWorld() { 75 | int hopTo = 0; 76 | if (sv.f2p) { 77 | List worlds = Worlds.all(w -> w.isF2P() && !w.isPVP() && !w.isHighRisk()); 78 | hopTo = Worlds.getRandomWorld(worlds).getWorld(); 79 | } else { 80 | List worlds = Worlds.all(w -> !w.isF2P() && !w.isPVP() && !w.isHighRisk()); 81 | hopTo = Worlds.getRandomWorld(worlds).getWorld(); 82 | } 83 | return hopTo; 84 | } 85 | 86 | @Override 87 | public int onLoop() { 88 | //Check if you're logged in, if you aren't cut out and sleep for a bit. 89 | if (!Client.isLoggedIn()) { 90 | return Calculations.random(300, 500); 91 | } 92 | //calculate gp used, if you don't have enough gold to go another minute kill script. 93 | int gp = Inventory.count("Coins"); 94 | int gpPerMin = (timer.getHourlyRate((int) startGP - gp) / 60) / 6; 95 | if (gp > 0 && gp < gpPerMin) { 96 | log("You can't last another minute: " + gpPerMin); 97 | log("Current gp: " + gp); 98 | stop(); 99 | return -1; 100 | } 101 | //if you're moving and your destination is still far away, return and sleep 102 | if (Players.getLocal().isMoving() && Client.getDestination() != null && Client.getDestination().distance(Players.getLocal().getTile()) > 3) 103 | return Calculations.random(200, 300); 104 | //start actual script stuff 105 | //get state 106 | state = getState(); 107 | switch (state) { 108 | case HOP: 109 | /* 110 | * HOP state. This will hop worlds and disclude PVP and High Risk. 111 | * If you've selected F2P hopping, it will only hop to f2p worlds, otherwise 112 | * Any other members world. 113 | */ 114 | //if you're actually hopping worlds, do stuff 115 | if (sv.hopWorlds) { 116 | //if shop is open close it. 117 | if (Shop.isOpen()) { 118 | Shop.close(); 119 | Sleep.sleepUntil(() -> !Shop.isOpen(), 1200); 120 | } 121 | //find a world to hop to 122 | int hopTo = getHopWorld(); 123 | //check for new world 15 times 124 | for(int i = 0; i < 10; i++){ 125 | if(hopTo != Worlds.getCurrentWorld()){ 126 | break; 127 | } 128 | hopTo = getHopWorld(); 129 | } 130 | //Quickhop to the world. 131 | log("Hopping to: " + hopTo); 132 | WorldHopper.quickHop(hopTo); 133 | //sleep until the login handler is solving. 134 | Sleep.sleepUntil(() -> Client.getInstance().getScriptManager().getCurrentScript().getRandomManager().isSolving(), 30000); 135 | } else { 136 | //if you don't have hopping selected, just sleep for 30-50 seconds 137 | //this lets the items regenerate a bit in the shop. 138 | Sleep.sleep(30000, 50000); 139 | } 140 | //set hoppingWorlds to false 141 | hoppingWorlds = false; 142 | break; 143 | case BUY: 144 | /* 145 | * BUY State. This state is where the shopping is handled. 146 | * This will interact with the nearest entity with "Trade" in its name 147 | * Then it'll search for the item. 148 | */ 149 | //if shop isn't open, try to open it. 150 | if (!Shop.isOpen()) { 151 | NPC shopper = NPCs.closest(shopFilter); 152 | if (shopper != null) { 153 | shopper.interact("Trade"); 154 | } 155 | //sleep until it's open. 156 | Sleep.sleepUntil(Shop::isOpen, Calculations.random(1500, 2500)); 157 | } else { 158 | //validate will guarantee the items in the shop are updated. 159 | //get the item from the shop 160 | Item pack = Shop.get(sv.itemName); 161 | //calculate buy amount based on min amount and current item amount 162 | int buyAmt = pack.getAmount() - sv.minAmt; 163 | //if it's not null and the amount is greater than min amount, buy it. 164 | if (pack.getAmount() > sv.minAmt) { 165 | //make buy amount divisible by 10 166 | //this makes it so you only use the buy 10 action 167 | buyAmt = buyAmt / 10; 168 | if (buyAmt == 0) 169 | buyAmt++; 170 | buyAmt = buyAmt * 10; 171 | //buy the item. 172 | Shop.purchase(pack, buyAmt); 173 | } 174 | //check if the item is null or the amount is less than your min amount. 175 | pack = Shop.get(sv.itemName); 176 | if ((pack == null || pack.getAmount() <= sv.minAmt) && sv.hopWorlds) 177 | hoppingWorlds = true; 178 | //sv.item.update(); 179 | } 180 | break; 181 | } 182 | return Calculations.random(10, 20); 183 | } 184 | 185 | //keeps track of the last time the profit updated 186 | private long profUpdate = 0; 187 | //keeps track of the last profit. 188 | private int lastProfit = 0; 189 | 190 | public int getProfit() { 191 | //if you're not logged in or the item amount is 0, return lastProfit 192 | if (!Client.isLoggedIn() || Inventory.count(sv.item.getName()) <= 0 || Inventory.count("Coins") <= 0) { 193 | return lastProfit; 194 | } 195 | //if lastProfit is 0 or 600ms has passed since last update, update lastProfit 196 | if (lastProfit == 0 || System.currentTimeMillis() - profUpdate > 600) { 197 | //update item tracker 198 | sv.item.update(); 199 | //get current value of the items 200 | int currValue = sv.item.getValue(); 201 | //get spent gold 202 | int spent = (int) startGP - Inventory.count("Coins"); 203 | //get profit 204 | lastProfit = currValue - spent; 205 | //update the timer 206 | profUpdate = System.currentTimeMillis(); 207 | } 208 | return lastProfit; 209 | } 210 | 211 | public void onPaint(Graphics g) { 212 | if (started) { 213 | if (state != null) { 214 | g.drawString("State: " + state, 5, 50); 215 | } 216 | g.drawString(sv.item.getName() + " bought(p/h): " + sv.item.getAmount() + "(" + timer.getHourlyRate(sv.item.getAmount()) + ")", 5, 65); 217 | g.drawString("GP Made(p/h): " + getProfit() + "(" + timer.getHourlyRate(getProfit()) + ")", 5, 80); 218 | g.drawString("Runtime: " + timer.formatTime(), 5, 95); 219 | } 220 | } 221 | 222 | } 223 | -------------------------------------------------------------------------------- /DreambotAutoBuyer/src/nezz/dreambot/tools/PricedItem.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.tools; 2 | 3 | import org.dreambot.api.methods.container.impl.Inventory; 4 | import org.dreambot.api.methods.grandexchange.LivePrices; 5 | import org.dreambot.api.utilities.Logger; 6 | 7 | public class PricedItem { 8 | private String name; 9 | private int lastCount = 0; 10 | private int amount = 0; 11 | private int price = 0; 12 | private int id = 0; 13 | 14 | public PricedItem(String name, boolean getPrice) { 15 | this.name = name; 16 | if (Inventory.contains(name)) { 17 | lastCount = Inventory.count(name); 18 | } 19 | if (getPrice) { 20 | String tempName = name; 21 | if (name.contains("arrow")) 22 | tempName += "s"; 23 | Logger.log("Getting price"); 24 | price = LivePrices.get(tempName); 25 | Logger.log("Got price: " + price); 26 | } else 27 | price = 0; 28 | } 29 | 30 | public void update() { 31 | int increase = 0; 32 | if (id == 0) 33 | increase = Inventory.count(name) - lastCount; 34 | else 35 | increase = Inventory.count(id) - lastCount; 36 | if (increase < 0) 37 | increase = 0; 38 | amount += increase; 39 | if (id == 0) 40 | lastCount = Inventory.count(name); 41 | else 42 | lastCount = Inventory.count(id); 43 | } 44 | 45 | public String getName() { 46 | return name; 47 | } 48 | 49 | public int getAmount() { 50 | return amount; 51 | } 52 | 53 | public int getPrice() { 54 | return price; 55 | } 56 | 57 | public int getValue() { 58 | if (amount <= 0) 59 | return 0; 60 | return amount * price; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /DreambotDruids/src/nezz/dreambot/druids/gui/ScriptVars.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.druids.gui; 2 | 3 | public class ScriptVars { 4 | public int[] keepHerbs; 5 | public String[] loot; 6 | public boolean started = false; 7 | } 8 | -------------------------------------------------------------------------------- /DreambotDruids/src/nezz/dreambot/druids/gui/druidsGui.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.druids.gui; 2 | 3 | import javax.swing.JFrame; 4 | import javax.swing.JPanel; 5 | import javax.swing.border.EmptyBorder; 6 | 7 | import java.awt.Toolkit; 8 | 9 | import javax.swing.JCheckBox; 10 | import javax.swing.JButton; 11 | 12 | import java.awt.event.ActionListener; 13 | import java.awt.event.ActionEvent; 14 | import java.awt.Color; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import javax.swing.JTabbedPane; 19 | 20 | import nezz.dreambot.scriptmain.druids.Herbs; 21 | 22 | public class druidsGui extends JFrame { 23 | 24 | /** 25 | * 26 | */ 27 | private static final long serialVersionUID = 1L; 28 | private JPanel contentPane; 29 | 30 | public druidsGui(final ScriptVars var) { 31 | setTitle("DreamBot"); 32 | setIconImage(Toolkit 33 | .getDefaultToolkit() 34 | .getImage( 35 | druidsGui.class 36 | .getResource("/javax/swing/plaf/metal/icons/ocean/computer.gif"))); 37 | setAlwaysOnTop(true); 38 | setResizable(false); 39 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 40 | setBounds(100, 100, 308, 257); 41 | contentPane = new JPanel(); 42 | contentPane.setBackground(Color.WHITE); 43 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 44 | setContentPane(contentPane); 45 | contentPane.setLayout(null); 46 | 47 | JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); 48 | tabbedPane.setBounds(0, 0, 302, 206); 49 | contentPane.add(tabbedPane); 50 | 51 | JPanel panel_1 = new JPanel(); 52 | tabbedPane.addTab("Loot(Herb)", null, panel_1, null); 53 | panel_1.setLayout(null); 54 | 55 | final JCheckBox chckbxGuam = new JCheckBox("Guam"); 56 | chckbxGuam.setBounds(16, 33, 69, 23); 57 | panel_1.add(chckbxGuam); 58 | 59 | final JCheckBox chckbxMarrentill = new JCheckBox("Marrentill"); 60 | chckbxMarrentill.setBounds(87, 33, 81, 23); 61 | panel_1.add(chckbxMarrentill); 62 | 63 | final JCheckBox chckbxDwarf = new JCheckBox("Dwarfweed"); 64 | chckbxDwarf.setBounds(16, 111, 88, 23); 65 | panel_1.add(chckbxDwarf); 66 | 67 | final JCheckBox chckbxTarromin = new JCheckBox("Tarromin"); 68 | chckbxTarromin.setBounds(170, 33, 88, 23); 69 | panel_1.add(chckbxTarromin); 70 | 71 | final JCheckBox chckbxHarralander = new JCheckBox("Harralander"); 72 | chckbxHarralander.setBounds(16, 59, 106, 23); 73 | panel_1.add(chckbxHarralander); 74 | 75 | final JCheckBox chckbxRanarr = new JCheckBox("Ranarr"); 76 | chckbxRanarr.setBounds(99, 85, 69, 23); 77 | panel_1.add(chckbxRanarr); 78 | 79 | final JCheckBox chckbxIrit = new JCheckBox("Irit"); 80 | chckbxIrit.setBounds(207, 59, 51, 23); 81 | panel_1.add(chckbxIrit); 82 | 83 | final JCheckBox chckbxCadantine = new JCheckBox("Cadantine"); 84 | chckbxCadantine.setBounds(106, 111, 88, 23); 85 | panel_1.add(chckbxCadantine); 86 | 87 | final JCheckBox chckbxAvantoe = new JCheckBox("Avantoe"); 88 | chckbxAvantoe.setBounds(124, 59, 81, 23); 89 | panel_1.add(chckbxAvantoe); 90 | 91 | final JCheckBox chckbxKwuarm = new JCheckBox("Kwuarm"); 92 | chckbxKwuarm.setBounds(16, 85, 81, 23); 93 | panel_1.add(chckbxKwuarm); 94 | 95 | final JCheckBox chckbxTorstol = new JCheckBox("Torstol"); 96 | chckbxTorstol.setBounds(196, 111, 69, 23); 97 | panel_1.add(chckbxTorstol); 98 | 99 | final JCheckBox chckbxLantadyme = new JCheckBox("Lantadyme"); 100 | chckbxLantadyme.setBounds(170, 85, 88, 23); 101 | panel_1.add(chckbxLantadyme); 102 | 103 | final JCheckBox[] chckbxArray = new JCheckBox[]{chckbxGuam, chckbxMarrentill, chckbxTarromin, chckbxHarralander, 104 | chckbxAvantoe, chckbxIrit, chckbxKwuarm, chckbxRanarr, chckbxDwarf, chckbxCadantine, chckbxTorstol, chckbxLantadyme}; 105 | 106 | JCheckBox chckbxAllHerbs = new JCheckBox("All Herbs"); 107 | chckbxAllHerbs.addActionListener(new ActionListener() { 108 | public void actionPerformed(ActionEvent arg0) { 109 | for (JCheckBox chck : chckbxArray) { 110 | if (chck != null) 111 | chck.setSelected(true); 112 | } 113 | } 114 | }); 115 | chckbxAllHerbs.setBounds(6, 7, 81, 23); 116 | panel_1.add(chckbxAllHerbs); 117 | 118 | JPanel panel_2 = new JPanel(); 119 | panel_2.setLayout(null); 120 | tabbedPane.addTab("Loot(Rune)", null, panel_2, null); 121 | 122 | final JCheckBox chckbxAir = new JCheckBox("Air"); 123 | chckbxAir.setBounds(16, 33, 53, 23); 124 | panel_2.add(chckbxAir); 125 | 126 | final JCheckBox chckbxEarth = new JCheckBox("Earth"); 127 | chckbxEarth.setBounds(71, 33, 67, 23); 128 | panel_2.add(chckbxEarth); 129 | 130 | final JCheckBox chckbxBody = new JCheckBox("Body"); 131 | chckbxBody.setBounds(140, 33, 58, 23); 132 | panel_2.add(chckbxBody); 133 | 134 | final JCheckBox chckbxMind = new JCheckBox("Mind"); 135 | chckbxMind.setBounds(200, 33, 58, 23); 136 | panel_2.add(chckbxMind); 137 | 138 | final JCheckBox chckbxNature = new JCheckBox("Nature"); 139 | chckbxNature.setBounds(71, 59, 67, 23); 140 | panel_2.add(chckbxNature); 141 | 142 | final JCheckBox chckbxLaw = new JCheckBox("Law"); 143 | chckbxLaw.setBounds(16, 59, 58, 23); 144 | panel_2.add(chckbxLaw); 145 | 146 | final JCheckBox[] runeArray = new JCheckBox[]{chckbxAir, chckbxEarth, chckbxBody, chckbxMind, chckbxLaw, chckbxNature}; 147 | 148 | JCheckBox chckbxAllRunes = new JCheckBox("All Runes"); 149 | chckbxAllRunes.addActionListener(new ActionListener() { 150 | public void actionPerformed(ActionEvent arg0) { 151 | for (JCheckBox chck : runeArray) { 152 | if (chck != null) 153 | chck.setSelected(true); 154 | } 155 | } 156 | }); 157 | chckbxAllRunes.setBounds(6, 7, 81, 23); 158 | panel_2.add(chckbxAllRunes); 159 | 160 | final JCheckBox chckbxMithrilBolts = new JCheckBox("Mithril Bolts"); 161 | chckbxMithrilBolts.setBounds(6, 105, 97, 23); 162 | panel_2.add(chckbxMithrilBolts); 163 | 164 | JButton btnNewButton = new JButton("START"); 165 | btnNewButton.addActionListener(new ActionListener() { 166 | public void actionPerformed(ActionEvent arg0) { 167 | List namedLoot = new ArrayList(); 168 | List idLoot = new ArrayList(); 169 | boolean herb = false; 170 | for (JCheckBox chck : chckbxArray) { 171 | if (chck != null && chck.isSelected()) { 172 | herb = true; 173 | Herbs h = Herbs.getForName(chck.getText()); 174 | if (h != null) { 175 | idLoot.add(h.getUnnotedGrimyId()); 176 | } 177 | } 178 | } 179 | var.keepHerbs = new int[idLoot.size()]; 180 | for (int i = 0; i < idLoot.size(); i++) { 181 | var.keepHerbs[i] = idLoot.get(i); 182 | } 183 | if (herb) 184 | namedLoot.add("Herb"); 185 | for (JCheckBox chck : runeArray) { 186 | if (chck != null && chck.isSelected()) { 187 | namedLoot.add(chck.getText() + " rune"); 188 | } 189 | } 190 | if (chckbxMithrilBolts.isSelected()) { 191 | namedLoot.add("Mithril bolts"); 192 | } 193 | var.loot = namedLoot.toArray(new String[namedLoot.size()]); 194 | var.started = true; 195 | dispose(); 196 | } 197 | }); 198 | btnNewButton.setBounds(0, 205, 302, 23); 199 | contentPane.add(btnNewButton); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /DreambotDruids/src/nezz/dreambot/scriptmain/druids/Druids.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.druids; 2 | 3 | import nezz.dreambot.druids.gui.ScriptVars; 4 | import nezz.dreambot.druids.gui.druidsGui; 5 | import nezz.dreambot.tools.PricedItem; 6 | import org.dreambot.api.Client; 7 | import org.dreambot.api.input.Mouse; 8 | import org.dreambot.api.methods.Calculations; 9 | import org.dreambot.api.methods.container.impl.Inventory; 10 | import org.dreambot.api.methods.container.impl.bank.Bank; 11 | import org.dreambot.api.methods.container.impl.bank.BankLocation; 12 | import org.dreambot.api.methods.dialogues.Dialogues; 13 | import org.dreambot.api.methods.filter.Filter; 14 | import org.dreambot.api.methods.interactive.GameObjects; 15 | import org.dreambot.api.methods.interactive.NPCs; 16 | import org.dreambot.api.methods.interactive.Players; 17 | import org.dreambot.api.methods.item.GroundItems; 18 | import org.dreambot.api.methods.map.Area; 19 | import org.dreambot.api.methods.map.Tile; 20 | import org.dreambot.api.methods.skills.Skill; 21 | import org.dreambot.api.methods.skills.SkillTracker; 22 | import org.dreambot.api.methods.walking.impl.Walking; 23 | import org.dreambot.api.script.AbstractScript; 24 | import org.dreambot.api.script.Category; 25 | import org.dreambot.api.script.ScriptManifest; 26 | import org.dreambot.api.utilities.Sleep; 27 | import org.dreambot.api.utilities.Timer; 28 | import org.dreambot.api.utilities.impl.Condition; 29 | import org.dreambot.api.wrappers.interactive.Character; 30 | import org.dreambot.api.wrappers.interactive.GameObject; 31 | import org.dreambot.api.wrappers.interactive.NPC; 32 | import org.dreambot.api.wrappers.interactive.Player; 33 | import org.dreambot.api.wrappers.items.GroundItem; 34 | import org.dreambot.api.wrappers.items.Item; 35 | 36 | import java.awt.*; 37 | import java.util.ArrayList; 38 | import java.util.List; 39 | 40 | @ScriptManifest(author = "Nezz", description = "Kills druids at Ardy", name = "DreamBot Druid Killer", version = 0, category = Category.COMBAT) 41 | public class Druids extends AbstractScript { 42 | 43 | private Timer timer; 44 | ScriptVars sv = new ScriptVars(); 45 | Filter druidFilter = n -> { 46 | if (n == null || n.getActions() == null || n.getActions().length <= 0) 47 | return false; 48 | if (n.getName() == null || !n.getName().equals("Chaos druid")) 49 | return false; 50 | if (n.isInCombat()) { 51 | Character c = n.getInteractingCharacter(); 52 | if (c == null) 53 | return false; 54 | if (c.getName() == null) 55 | return false; 56 | return c.getName().equals(Players.getLocal().getName()); 57 | } 58 | return true; 59 | }; 60 | Area druidArea = new Area(new Tile(2560, 3358, 0), new Tile(2564, 3354, 0)); 61 | 62 | Filter itemFilter = gi -> { 63 | if (gi == null || !gi.exists() || gi.getName() == null) { 64 | return false; 65 | } 66 | if (!druidArea.contains(gi)) { 67 | return false; 68 | } 69 | for (int i = 0; i < sv.loot.length; i++) { 70 | if (gi.getName().contains("Grimy")) { 71 | for (int ii = 0; ii < sv.keepHerbs.length; ii++) { 72 | if (gi.getID() == sv.keepHerbs[ii]) 73 | return true; 74 | } 75 | return false; 76 | } else if (gi.getName().equals(sv.loot[i])) 77 | return true; 78 | } 79 | return false; 80 | }; 81 | Condition itemDeposited = Inventory::isEmpty; 82 | Condition attacking = () -> Players.getLocal().isInCombat(); 83 | private final Tile druidsTile = new Tile(2565, 3356, 0); 84 | /*Tile[] druidsToBank = new Tile[]{new Tile(2565,3356,0),new Tile(2567,3356,0), 85 | new Tile(2569,3356,0),new Tile(2570,3355,0),new Tile(2571,3354,0), 86 | new Tile(2572,3353,0),new Tile(2573,3352,0),new Tile(2574,3351,0), 87 | new Tile(2575,3350,0),new Tile(2577,3350,0),new Tile(2579,3350,0), 88 | new Tile(2580,3351,0),new Tile(2582,3351,0),new Tile(2582,3353,0), 89 | new Tile(2582,3355,0),new Tile(2582,3357,0),new Tile(2582,3359,0), 90 | new Tile(2582,3361,0),new Tile(2582,3363,0),new Tile(2582,3365,0), 91 | new Tile(2582,3367,0),new Tile(2583,3368,0),new Tile(2585,3368,0), 92 | new Tile(2587,3368,0),new Tile(2589,3368,0),new Tile(2591,3368,0), 93 | new Tile(2593,3368,0),new Tile(2595,3368,0),new Tile(2597,3368,0), 94 | new Tile(2599,3368,0),new Tile(2601,3368,0),new Tile(2603,3368,0), 95 | new Tile(2605,3368,0),new Tile(2607,3368,0),new Tile(2608,3367,0), 96 | new Tile(2609,3366,0),new Tile(2610,3365,0),new Tile(2610,3363,0), 97 | new Tile(2610,3361,0),new Tile(2610,3359,0),new Tile(2610,3357,0), 98 | new Tile(2611,3355,0),new Tile(2612,3354,0),new Tile(2613,3353,0), 99 | new Tile(2613,3351,0),new Tile(2613,3349,0),new Tile(2613,3347,0), 100 | new Tile(2613,3345,0),new Tile(2613,3343,0),new Tile(2613,3341,0), 101 | new Tile(2614,3339,0),new Tile(2615,3338,0),new Tile(2599,3378,0), 102 | new Tile(2615,3338,0),new Tile(2616,3337,0),new Tile(2616,3335,0), 103 | new Tile(2617,3334,0)};*/ 104 | 105 | List lootTrack = new ArrayList<>(); 106 | GameObject door = null; 107 | private boolean started = false; 108 | //current state 109 | private State state; 110 | 111 | private enum State { 112 | ATTACK, LOOT, WALK_TO_BANK, WALK_TO_DRUIDS, BANK, DROP 113 | } 114 | 115 | private State getState() { 116 | if (needsToDrop()) 117 | return State.DROP; 118 | else if (Inventory.isFull()) { 119 | if (BankLocation.ARDOUGNE_NORTH.getArea(3).contains(Players.getLocal())) { 120 | return State.BANK; 121 | } else 122 | return State.WALK_TO_BANK; 123 | } else { 124 | if (druidArea.contains(Players.getLocal())) { 125 | GroundItem gi = GroundItems.closest(itemFilter); 126 | if (gi != null && druidArea.contains(gi)) { 127 | return State.LOOT; 128 | } else { 129 | return State.ATTACK; 130 | } 131 | } else { 132 | return State.WALK_TO_DRUIDS; 133 | } 134 | } 135 | } 136 | 137 | @Override 138 | public void onStart() { 139 | druidsGui gui = new druidsGui(sv); 140 | gui.setVisible(true); 141 | while (!sv.started) { 142 | sleep(100); 143 | } 144 | timer = new Timer(); 145 | for (int i = 0; i < sv.keepHerbs.length; i++) { 146 | Herbs h = Herbs.getForUNGrimyID(sv.keepHerbs[i]); 147 | if (h != null) { 148 | lootTrack.add(new PricedItem("Herb", h.getUnnotedGrimyId(), false)); 149 | } 150 | } 151 | for (int i = 0; i < sv.loot.length; i++) { 152 | if (sv.loot[i].equals("Herb")) 153 | continue; 154 | lootTrack.add(new PricedItem(sv.loot[i], false)); 155 | } 156 | SkillTracker.start(Skill.DEFENCE); 157 | SkillTracker.start(Skill.ATTACK); 158 | SkillTracker.start(Skill.STRENGTH); 159 | //Client.getInstance().getScriptManager().getIDleMouseController().setIdleTime(10000); 160 | //Client.disableIdleMouse(); 161 | started = true; 162 | log("Starting DreamBot's Druid Killing Script!"); 163 | } 164 | 165 | private void updateLoot() { 166 | for (PricedItem p : lootTrack) { 167 | p.update(); 168 | } 169 | } 170 | 171 | private boolean needHerb(int id) { 172 | for (int i = 0; i < sv.keepHerbs.length; i++) { 173 | if (id == sv.keepHerbs[i]) 174 | return true; 175 | } 176 | return false; 177 | } 178 | 179 | private boolean needItem(String name) { 180 | for (int i = 0; i < sv.loot.length; i++) { 181 | if (name.equalsIgnoreCase(sv.loot[i].toLowerCase()) || name.contains("Grimy")) { 182 | return true; 183 | } 184 | } 185 | return false; 186 | } 187 | 188 | private boolean needsToDrop() { 189 | for (int i = 0; i < 28; i++) { 190 | Item item = Inventory.getItemInSlot(i); 191 | if (item != null && !item.getName().equals("") && !item.getName().equals("null")) { 192 | if (item.getName().contains("Grimy") && !needHerb(item.getID())) { 193 | return true; 194 | } else if (!needItem(item.getName())) 195 | return true; 196 | } 197 | } 198 | 199 | return false; 200 | } 201 | 202 | @Override 203 | public int onLoop() { 204 | Player myPlayer = Players.getLocal(); 205 | if (!Walking.isRunEnabled() && Walking.getRunEnergy() > Calculations.random(30, 70)) { 206 | Walking.toggleRun(); 207 | } 208 | if (myPlayer.isMoving() && Client.getDestination() != null && Client.getDestination().distance(myPlayer) > 5) 209 | return Calculations.random(300, 600); 210 | Dialogues.clickContinue(); 211 | state = getState(); 212 | switch (state) { 213 | case DROP: 214 | for (int i = 0; i < 28; i++) { 215 | Item item = Inventory.getItemInSlot(i); 216 | if (item != null) { 217 | if (item.getName().contains("Grimy") && !needHerb(item.getID())) { 218 | if (Herbs.getForUNGrimyID(item.getID()).canIdHerb(Skill.HERBLORE.getBoostedLevel())) { 219 | Inventory.interact(i, "Identify"); 220 | sleep(600, 900); 221 | } 222 | Inventory.interact(i, "Drop"); 223 | sleep(600, 900); 224 | } else if (!needItem(item.getName())) { 225 | Inventory.interact(i, "Drop"); 226 | sleep(600, 900); 227 | } 228 | } 229 | } 230 | break; 231 | case BANK: 232 | if (Bank.isOpen()) { 233 | Bank.depositAllItems(); 234 | Sleep.sleepUntil(itemDeposited, 1000); 235 | } else { 236 | Bank.open(BankLocation.ARDOUGNE_SOUTH); 237 | Sleep.sleepUntil(Bank::isOpen, 1200); 238 | } 239 | break; 240 | case ATTACK: 241 | NPC druid = NPCs.closest(druidFilter); 242 | if (druid != null) { 243 | if (!myPlayer.isInCombat()) { 244 | druid.interact("Attack"); 245 | Sleep.sleepUntil(attacking, 3000); 246 | } else { 247 | sleep(400, 800); 248 | } 249 | } else { 250 | sleep(300, 600); 251 | } 252 | break; 253 | case LOOT: 254 | if (myPlayer.isInCombat()) 255 | break; 256 | final GroundItem gi = GroundItems.closest(itemFilter); 257 | if (gi != null && druidArea.contains(gi.getTile())) { 258 | gi.interact("Take"); 259 | if (Mouse.getLastCrosshairColorID() == 2) { 260 | Sleep.sleepUntil(() -> { 261 | GroundItem gi_ = GroundItems.closest(_gi -> { 262 | if (_gi == null || _gi.getName() == null) 263 | return false; 264 | if (!itemFilter.match(_gi)) 265 | return false; 266 | return _gi.getID() == gi.getID() && _gi.getTile().equals(gi.getTile()); 267 | }); 268 | return gi_ == null; 269 | }, 2000); 270 | } 271 | } 272 | break; 273 | case WALK_TO_BANK: 274 | if (druidArea.contains(Players.getLocal())) { 275 | door = GameObjects.closest("Door"); 276 | if (door != null) { 277 | door.interact("Open"); 278 | Sleep.sleepUntil(() -> !druidArea.contains(Players.getLocal()), 1200); 279 | } 280 | } else { 281 | Walking.walk(BankLocation.ARDOUGNE_NORTH.getCenter()); 282 | //Walking.walkTilePath(druidsToBank, Calculations.random(20,30)); 283 | } 284 | break; 285 | case WALK_TO_DRUIDS: 286 | if (Bank.isOpen()) { 287 | Bank.close(); 288 | Sleep.sleepUntil(() -> !Bank.isOpen(), 1200); 289 | } 290 | if (myPlayer.getTile().getY() > 9000) { 291 | GameObject ladder = GameObjects.closest("Ladder"); 292 | if (ladder != null) { 293 | if (ladder.interact("Climb-up")) { 294 | Sleep.sleepUntil(() -> Players.getLocal().getTile().getY() < 9000, 2000); 295 | } 296 | } 297 | } else { 298 | /* 299 | Tile[] bankToDruids = new Tile[druidsToBank.length]; 300 | for(int i = 0; i < druidsToBank.length; i++){ 301 | bankToDruids[i] = druidsToBank[druidsToBank.length - 1 - i]; 302 | }*/ 303 | if (Players.getLocal().distance(druidsTile) < 8) { 304 | door = GameObjects.closest(11723); 305 | if (door != null) { 306 | door.interact("Pick-lock"); 307 | Sleep.sleepUntil(() -> druidArea.contains(Players.getLocal()), 1200); 308 | } 309 | } else { 310 | Walking.walk(druidsTile); 311 | //Walking.walkTilePath(bankToDruids, Calculations.random(10,15)); 312 | } 313 | } 314 | break; 315 | } 316 | updateLoot(); 317 | return 200; 318 | } 319 | 320 | @Override 321 | public void onExit() { 322 | log("Stopping testing!"); 323 | } 324 | 325 | public long getGainedExperience() { 326 | long att; 327 | long str; 328 | long def; 329 | att = SkillTracker.getGainedExperience(Skill.ATTACK); 330 | str = SkillTracker.getGainedExperience(Skill.STRENGTH); 331 | def = SkillTracker.getGainedExperience(Skill.DEFENCE); 332 | return att + str + def; 333 | } 334 | 335 | public long getGainedExperienceHour() { 336 | long att; 337 | long str; 338 | long def; 339 | att = SkillTracker.getGainedExperiencePerHour(Skill.ATTACK); 340 | str = SkillTracker.getGainedExperiencePerHour(Skill.STRENGTH); 341 | def = SkillTracker.getGainedExperiencePerHour(Skill.DEFENCE); 342 | return att + str + def; 343 | } 344 | 345 | public void onPaint(Graphics g) { 346 | if (started) { 347 | int baseY = 15; 348 | g.setColor(Color.green); 349 | if (state != null) 350 | g.drawString("State: " + state, 5, baseY); 351 | baseY += 15; 352 | g.drawString("Runtime: " + timer.formatTime(), 5, baseY); 353 | baseY += 15; 354 | g.drawString("Experience(p/h): " + getGainedExperience() + "(" + getGainedExperienceHour() + ")", 5, baseY); 355 | baseY += 15; 356 | //g.drawString("Level(gained): " + Skills.getRealLevel(Skill.DEFENCE) + "(" + SkillTracker.getGainedLevels(Skill.DEFENCE) + ")", 5, baseY); 357 | //baseY+=15; 358 | baseY = 15; 359 | for (int i = 0; i < lootTrack.size(); i++) { 360 | PricedItem p = lootTrack.get(i); 361 | if (p != null && p.getAmount() > 0) { 362 | String name = p.getName(); 363 | if (p.getId() > 0) { 364 | name = Herbs.getForUNGrimyID(p.getId()).getName(); 365 | } 366 | g.drawString(name + "(p/h):" + p.getAmount() + "(" + timer.getHourlyRate(p.getAmount()) + ")", 400, baseY); 367 | baseY += 15; 368 | } 369 | } 370 | } 371 | } 372 | 373 | } 374 | -------------------------------------------------------------------------------- /DreambotDruids/src/nezz/dreambot/scriptmain/druids/Herbs.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.druids; 2 | 3 | public enum Herbs { 4 | GUAM(3, 249, 250, 199, 200, 2.5), 5 | MARRENTILL(5, 251, 252, 201, 202, 3.8), 6 | TARROMIN(11, 253, 254, 203, 204, 5), 7 | HARRALANDER(20, 255, 256, 205, 206, 6.3), 8 | RANARR(25, 257, 258, 207, 208, 7.5), 9 | TOADFLAX(30, 2998, 2999, 3049, 3050, 8), 10 | IRIT(40, 259, 260, 209, 210, 8.8), 11 | AVANTOE(48, 261, 262, 211, 212, 10), 12 | KWUARM(54, 263, 264, 213, 214, 11.3), 13 | SNAPDRAGON(59, 3000, 3001, 3051, 3052, 11.8), 14 | CADANTINE(65, 265, 266, 215, 216, 12.5), 15 | LANTADYME(67, 2481, 2482, 2485, 2486, 13.1), 16 | DWARFWEED(70, 267, 268, 217, 218, 13.8), 17 | TORSTOL(75, 269, 270, 219, 220, 15); 18 | 19 | private final int idLevel; 20 | private final int unnotedCleanId; 21 | private final int notedCleanId; 22 | private final int unnotedGrimyId; 23 | private final int notedGrimyId; 24 | final double expGained; 25 | 26 | Herbs(int idLevel, int unnotedCleanId, int notedCleanId, int unnotedGrimyId, int notedGrimyId, double expGained) { 27 | this.idLevel = idLevel; 28 | this.unnotedCleanId = unnotedCleanId; 29 | this.notedCleanId = notedCleanId; 30 | this.unnotedGrimyId = unnotedGrimyId; 31 | this.notedGrimyId = notedGrimyId; 32 | this.expGained = expGained; 33 | } 34 | 35 | public static Herbs getForName(String herbName) { 36 | for (Herbs h : values()) { 37 | if (h.getName().equalsIgnoreCase(herbName.toLowerCase())) 38 | return h; 39 | } 40 | return null; 41 | } 42 | 43 | public static Herbs getForUNGrimyID(int id) { 44 | for (Herbs h : values()) { 45 | if (h.getUnnotedGrimyId() == id) { 46 | return h; 47 | } 48 | } 49 | return null; 50 | } 51 | 52 | public int getUnnotedGrimyId() { 53 | return unnotedGrimyId; 54 | } 55 | 56 | public String getName() { 57 | return name().charAt(0) + name().substring(1).toLowerCase(); 58 | } 59 | 60 | public boolean canIdHerb(int currentLevel) { 61 | return currentLevel >= idLevel; 62 | } 63 | } -------------------------------------------------------------------------------- /DreambotDruids/src/nezz/dreambot/tools/PricedItem.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.tools; 2 | 3 | import org.dreambot.api.methods.container.impl.Inventory; 4 | import org.dreambot.api.methods.grandexchange.LivePrices; 5 | import org.dreambot.api.utilities.Logger; 6 | 7 | public class PricedItem { 8 | private String name; 9 | private int lastCount = 0; 10 | private int amount = 0; 11 | private int price = 0; 12 | private int id = 0; 13 | 14 | public PricedItem(String name, boolean getPrice){ 15 | this.name = name; 16 | if(Inventory.contains(name)){ 17 | lastCount = (int) Inventory.count(name); 18 | } 19 | if(getPrice){ 20 | String tempName = name; 21 | if(name.contains("arrow")) 22 | tempName+="s"; 23 | Logger.log("Getting price"); 24 | price = LivePrices.get(tempName); 25 | Logger.log("Got price: " + price); 26 | } 27 | else 28 | price = 0; 29 | } 30 | 31 | public PricedItem(String name, int id, boolean getPrice){ 32 | this.name = name; 33 | this.setId(id); 34 | if(Inventory.contains(id)) 35 | lastCount = (int) Inventory.count(id); 36 | if(getPrice) 37 | price = LivePrices.get(name); 38 | else 39 | price = 0; 40 | } 41 | 42 | public void update(){ 43 | int increase = 0; 44 | if(id==0) 45 | increase = (int) (Inventory.count(name)- lastCount); 46 | else 47 | increase = (int) (Inventory.count(id)- lastCount); 48 | if(increase < 0) 49 | increase = 0; 50 | amount+=increase; 51 | if(id==0) 52 | lastCount = (int) Inventory.count(name); 53 | else 54 | lastCount = (int) Inventory.count(id); 55 | } 56 | 57 | public void setName(String name){ 58 | this.name = name; 59 | } 60 | public void setAmount(int amt){ 61 | this.amount = amt; 62 | } 63 | public void setPrice(int price){ 64 | this.price = price; 65 | } 66 | public String getName(){ 67 | return name; 68 | } 69 | public int getAmount(){ 70 | return amount; 71 | } 72 | 73 | public int getPrice(){ 74 | return price; 75 | } 76 | public int getValue(){ 77 | if(amount <= 0) 78 | return 0; 79 | return amount * price; 80 | } 81 | 82 | public int getId() { 83 | return id; 84 | } 85 | 86 | public void setId(int id) { 87 | this.id = id; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /DreambotFisher/src/nezz/dreambot/fisher/enums/Fish.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.fisher.enums; 2 | 3 | public enum Fish { 4 | SHRIMP("Small fishing net", "", new String[]{"Raw shrimps", "Raw anchovies"}, "Net"), 5 | TROUT("Fly fishing rod", "Feather", new String[]{"Raw trout", "Raw salmon"}, "Lure"), 6 | HERRING("Fishing rod", "Fishing bait", new String[]{"Raw herring", "Raw sardine"}, "Bait"), 7 | LOBSTER("Lobster pot", "", new String[]{"Raw lobster"}, "Cage"); 8 | 9 | private final String itemName; 10 | private final String[] reqActions; 11 | private final String reqItem; 12 | private final String[] fish; 13 | 14 | Fish(String itemName, String reqItem, String[] fish, String... reqActions) { 15 | this.itemName = itemName; 16 | this.reqItem = reqItem; 17 | this.reqActions = reqActions; 18 | this.fish = fish; 19 | } 20 | 21 | public String getItemName() { 22 | return this.itemName; 23 | } 24 | 25 | public String[] getRequiredActions() { 26 | return this.reqActions; 27 | } 28 | 29 | public String getRequiredItem() { 30 | return this.reqItem; 31 | } 32 | 33 | public String[] getFish() { 34 | return this.fish; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /DreambotFisher/src/nezz/dreambot/fisher/gui/ScriptVars.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.fisher.gui; 2 | 3 | import org.dreambot.api.methods.container.impl.bank.BankLocation; 4 | 5 | import nezz.dreambot.fisher.enums.Fish; 6 | 7 | public class ScriptVars { 8 | public Fish yourFish; 9 | public BankLocation yourBank; 10 | public boolean powerFish = false; 11 | public boolean started = false; 12 | } 13 | -------------------------------------------------------------------------------- /DreambotFisher/src/nezz/dreambot/fisher/gui/fisherGui.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.fisher.gui; 2 | 3 | import javax.swing.JFrame; 4 | import javax.swing.JPanel; 5 | import javax.swing.border.EmptyBorder; 6 | 7 | import java.awt.Toolkit; 8 | 9 | import javax.swing.JLabel; 10 | import javax.swing.JComboBox; 11 | import javax.swing.DefaultComboBoxModel; 12 | import javax.swing.JCheckBox; 13 | import javax.swing.JButton; 14 | 15 | import org.dreambot.api.methods.container.impl.bank.BankLocation; 16 | 17 | import java.awt.event.ActionListener; 18 | import java.awt.event.ActionEvent; 19 | import java.awt.Color; 20 | 21 | import nezz.dreambot.fisher.enums.Fish; 22 | 23 | public class fisherGui extends JFrame { 24 | 25 | /** 26 | * 27 | */ 28 | private static final long serialVersionUID = 1L; 29 | private JPanel contentPane; 30 | JCheckBox chckbxPowerFish = new JCheckBox("Power Fish?"); 31 | JComboBox comboBox_1 = new JComboBox(); 32 | JComboBox comboBox = new JComboBox(); 33 | 34 | 35 | public fisherGui(final ScriptVars var) { 36 | setTitle("DreamBot Fisher"); 37 | setIconImage(Toolkit.getDefaultToolkit().getImage(fisherGui.class.getResource("/javax/swing/plaf/metal/icons/ocean/computer.gif"))); 38 | setAlwaysOnTop(true); 39 | setResizable(false); 40 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 41 | setBounds(100, 100, 276, 167); 42 | contentPane = new JPanel(); 43 | contentPane.setBackground(Color.WHITE); 44 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 45 | setContentPane(contentPane); 46 | contentPane.setLayout(null); 47 | 48 | JPanel panel = new JPanel(); 49 | panel.setBounds(0, 0, 270, 101); 50 | contentPane.add(panel); 51 | panel.setLayout(null); 52 | 53 | JLabel lblYourFish = new JLabel("Your Fish:"); 54 | lblYourFish.setBounds(10, 11, 72, 14); 55 | panel.add(lblYourFish); 56 | 57 | comboBox.setModel(new DefaultComboBoxModel(Fish.values())); 58 | comboBox.setBounds(92, 8, 168, 20); 59 | panel.add(comboBox); 60 | 61 | JLabel lblYourBank = new JLabel("Your Bank:"); 62 | lblYourBank.setBounds(10, 36, 72, 14); 63 | panel.add(lblYourBank); 64 | 65 | comboBox_1.setModel(new DefaultComboBoxModel(BankLocation.values())); 66 | comboBox_1.setBounds(92, 33, 168, 20); 67 | panel.add(comboBox_1); 68 | 69 | chckbxPowerFish.setBounds(92, 60, 97, 23); 70 | panel.add(chckbxPowerFish); 71 | 72 | JButton btnNewButton = new JButton("Start!"); 73 | btnNewButton.addActionListener(new ActionListener() { 74 | public void actionPerformed(ActionEvent arg0) { 75 | var.powerFish = chckbxPowerFish.isSelected(); 76 | var.yourBank = BankLocation.values()[comboBox_1.getSelectedIndex()]; 77 | var.yourFish = Fish.values()[comboBox.getSelectedIndex()]; 78 | var.started = true; 79 | dispose(); 80 | } 81 | }); 82 | btnNewButton.setBounds(0, 101, 270, 34); 83 | contentPane.add(btnNewButton); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /DreambotFisher/src/nezz/dreambot/scriptmain/fisher/Fisher.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.fisher; 2 | 3 | import nezz.dreambot.fisher.gui.ScriptVars; 4 | import nezz.dreambot.fisher.gui.fisherGui; 5 | import nezz.dreambot.tools.PricedItem; 6 | import org.dreambot.api.Client; 7 | import org.dreambot.api.methods.Calculations; 8 | import org.dreambot.api.methods.container.impl.Inventory; 9 | import org.dreambot.api.methods.container.impl.bank.Bank; 10 | import org.dreambot.api.methods.filter.Filter; 11 | import org.dreambot.api.methods.interactive.NPCs; 12 | import org.dreambot.api.methods.interactive.Players; 13 | import org.dreambot.api.methods.map.Area; 14 | import org.dreambot.api.methods.map.Map; 15 | import org.dreambot.api.methods.map.Tile; 16 | import org.dreambot.api.methods.skills.Skill; 17 | import org.dreambot.api.methods.skills.SkillTracker; 18 | import org.dreambot.api.methods.skills.Skills; 19 | import org.dreambot.api.methods.walking.impl.Walking; 20 | import org.dreambot.api.script.AbstractScript; 21 | import org.dreambot.api.script.Category; 22 | import org.dreambot.api.script.ScriptManifest; 23 | import org.dreambot.api.utilities.Sleep; 24 | import org.dreambot.api.utilities.Timer; 25 | import org.dreambot.api.wrappers.interactive.NPC; 26 | import org.dreambot.api.wrappers.interactive.Player; 27 | import org.dreambot.api.wrappers.items.Item; 28 | 29 | import java.awt.*; 30 | import java.util.ArrayList; 31 | import java.util.Hashtable; 32 | import java.util.List; 33 | 34 | @ScriptManifest(author = "Nezz", description = "AIO Fisher", name = "DreamBot AIO Fisher", version = 0, category = Category.FISHING) 35 | public class Fisher extends AbstractScript { 36 | 37 | private Timer timer; 38 | private Tile startTile; 39 | ScriptVars sv = new ScriptVars(); 40 | Hashtable poolHash = new Hashtable<>(); 41 | Filter poolFilter = n -> { 42 | if (n == null)// || !n.exists()) 43 | return false; 44 | if (n.getName() == null || !n.getName().equals("Fishing spot")) 45 | return false; 46 | String[] actions = n.getActions(); 47 | if (actions == null || actions.length <= 0) 48 | return false; 49 | for (String action : sv.yourFish.getRequiredActions()) { 50 | if (!n.hasAction(action)) 51 | return false; 52 | } 53 | return canReach(n); 54 | }; 55 | List lootTrack = new ArrayList<>(); 56 | //current state 57 | private State state; 58 | NPC myPool = null; 59 | long activeTime = 0; 60 | private boolean started = false; 61 | 62 | private enum State { 63 | FISH, DROP, BANK 64 | } 65 | 66 | private State getState() { 67 | if (Inventory.isFull()) { 68 | if (sv.powerFish) { 69 | return State.DROP; 70 | } else { 71 | return State.BANK; 72 | } 73 | } 74 | return State.FISH; 75 | } 76 | 77 | public Tile getWalkableTile(NPC pool) { 78 | Tile walkableTile; 79 | if (!poolHash.containsKey(pool.getTile())) { 80 | Tile t = pool.getTile(); 81 | Tile n = new Tile(t.getX(), t.getY() + 1, t.getZ()); 82 | Tile e = new Tile(t.getX() + 1, t.getY(), t.getZ()); 83 | Tile s = new Tile(t.getX(), t.getY() - 1, t.getZ()); 84 | Tile w = new Tile(t.getX() - 1, t.getY(), t.getZ()); 85 | if (Map.canReach(n)) 86 | walkableTile = n; 87 | else if (Map.canReach(e)) 88 | walkableTile = e; 89 | else if (Map.canReach(s)) 90 | walkableTile = s; 91 | else if (Map.canReach(w)) 92 | walkableTile = w; 93 | else 94 | walkableTile = null; 95 | if (walkableTile != null) { 96 | log("Adding tile to hash: <" + pool.getTile() + "," + walkableTile + ">"); 97 | poolHash.put(pool.getTile(), walkableTile); 98 | } 99 | } else { 100 | walkableTile = poolHash.get(pool.getTile()); 101 | } 102 | return walkableTile; 103 | } 104 | 105 | public boolean canReach(NPC pool) { 106 | return getWalkableTile(pool) != null; 107 | } 108 | 109 | @Override 110 | public void onStart() { 111 | fisherGui gui = new fisherGui(sv); 112 | gui.setVisible(true); 113 | while (!sv.started) { 114 | sleep(100); 115 | } 116 | startTile = Players.getLocal().getTile(); 117 | SkillTracker.start(Skill.FISHING); 118 | for (String s : sv.yourFish.getFish()) { 119 | lootTrack.add(new PricedItem(s, false)); 120 | } 121 | timer = new Timer(); 122 | log("Starting DreamBot's AIO Fishing script!"); 123 | started = true; 124 | } 125 | 126 | private boolean needToStop() { 127 | if (!Inventory.contains(sv.yourFish.getItemName())) 128 | return true; 129 | return !sv.yourFish.getRequiredItem().equals("") && !Inventory.contains(sv.yourFish.getRequiredItem()); 130 | } 131 | 132 | private void updateLoot() { 133 | for (PricedItem p : lootTrack) { 134 | p.update(); 135 | } 136 | } 137 | 138 | @Override 139 | public int onLoop() { 140 | if (needToStop()) { 141 | stop(); 142 | return 1; 143 | } 144 | Player myPlayer = Players.getLocal(); 145 | if (!Walking.isRunEnabled() && Walking.getRunEnergy() > Calculations.random(30, 70)) { 146 | Walking.toggleRun(); 147 | Sleep.sleepUntil(Walking::isRunEnabled, 1200); 148 | } 149 | if (myPlayer.isMoving() && Client.getDestination() != null && Client.getDestination().distance(myPlayer) > 5) 150 | return Calculations.random(300, 600); 151 | state = getState(); 152 | switch (state) { 153 | case BANK: 154 | if (Bank.isOpen()) { 155 | for (int i = 0; i < 28; i++) { 156 | Item item = Inventory.getItemInSlot(i); 157 | if (item != null) { 158 | if (!item.getName().equals(sv.yourFish.getItemName()) && !item.getName().equals(sv.yourFish.getRequiredItem())) { 159 | Bank.depositAll(item.getName()); 160 | sleep(600); 161 | } 162 | } 163 | } 164 | } else { 165 | Area a = sv.yourBank.getArea(5); 166 | if (a.contains(Players.getLocal().getTile())) { 167 | Bank.open(sv.yourBank); 168 | } else { 169 | Walking.walk(sv.yourBank.getCenter()); 170 | Sleep.sleepUntil(() -> Players.getLocal().isMoving(), 1200); 171 | } 172 | } 173 | break; 174 | case DROP: 175 | for (int i = 0; i < 28; i++) { 176 | Item item = Inventory.getItemInSlot(i); 177 | if (item != null && !item.getName().equals(sv.yourFish.getItemName()) && !item.getName().equals(sv.yourFish.getRequiredItem())) { 178 | Inventory.interact(i, "Drop"); 179 | sleep(Calculations.random(150, 350)); 180 | } 181 | } 182 | break; 183 | case FISH: 184 | if (Bank.isOpen()) { 185 | Bank.close(); 186 | Sleep.sleepUntil(() -> !Bank.isOpen(), 1200); 187 | } 188 | if (myPlayer.getAnimation() == -1 || (System.currentTimeMillis() - activeTime > Calculations.random(250000, 280000))) { 189 | NPC pool = NPCs.closest(poolFilter); 190 | myPool = pool; 191 | if (pool != null) { 192 | if (pool.isOnScreen() && pool.distance(Players.getLocal()) < 5) { 193 | pool.interact(sv.yourFish.getRequiredActions()[0]); 194 | Sleep.sleepUntil(() -> Players.getLocal().getAnimation() != -1, 1200); 195 | sleep(1500); 196 | activeTime = System.currentTimeMillis(); 197 | } else { 198 | log("Walk to pool"); 199 | Walking.walk(getWalkableTile(myPool)); 200 | Sleep.sleepUntil(() -> Players.getLocal().isMoving(), 1000); 201 | } 202 | } else { 203 | if (this.startTile.distance(Players.getLocal()) < 15) 204 | sleep(600); 205 | else { 206 | if (myPlayer.distance(startTile) > 5) { 207 | Walking.walk(startTile); 208 | Sleep.sleepUntil(() -> Players.getLocal().isMoving(), 1200); 209 | } else { 210 | Walking.walk(myPlayer.getTile()); 211 | Sleep.sleepUntil(() -> Players.getLocal().isMoving(), 1200); 212 | sleep(300); 213 | } 214 | } 215 | } 216 | } 217 | break; 218 | } 219 | updateLoot(); 220 | return (int) Calculations.nextGaussianRandom(500, 200); 221 | } 222 | 223 | @Override 224 | public void onExit() { 225 | log("Stopping testing!"); 226 | } 227 | 228 | public void onPaint(Graphics g) { 229 | if (started) { 230 | g.setColor(Color.green); 231 | g.drawString("Experience(p/h): " + SkillTracker.getGainedExperience(Skill.FISHING) + "(" + SkillTracker.getGainedExperiencePerHour(Skill.FISHING) + ")", 5, 90); 232 | g.drawString("Runtime: " + timer.formatTime(), 5, 105); 233 | g.drawString("Level(gained): " + Skills.getRealLevel(Skill.FISHING) + "(" + SkillTracker.getGainedLevels(Skill.FISHING) + ")", 5, 120); 234 | int place = 0; 235 | for (int i = 0; i < lootTrack.size(); i++) { 236 | PricedItem p = lootTrack.get(i); 237 | if (p != null && p.getAmount() > 0) { 238 | g.drawString(p.getName() + "(p/h):" + p.getAmount() + "(" + timer.getHourlyRate(p.getAmount()) + ")", 5, 135 + place * 15); 239 | place++; 240 | } 241 | } 242 | if (state != null) 243 | g.drawString("State: " + state, 5, 135 + place * 15); 244 | 245 | } 246 | } 247 | 248 | } 249 | -------------------------------------------------------------------------------- /DreambotFisher/src/nezz/dreambot/tools/PricedItem.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.tools; 2 | 3 | import org.dreambot.api.methods.container.impl.Inventory; 4 | import org.dreambot.api.methods.grandexchange.LivePrices; 5 | import org.dreambot.api.utilities.Logger; 6 | 7 | public class PricedItem { 8 | private String name; 9 | private int lastCount = 0; 10 | private int amount = 0; 11 | private int price = 0; 12 | private int id = 0; 13 | 14 | public PricedItem(String name, boolean getPrice) { 15 | this.name = name; 16 | if (Inventory.contains(name)) { 17 | lastCount = Inventory.count(name); 18 | } 19 | if (getPrice) { 20 | String tempName = name; 21 | if (name.contains("arrow")) 22 | tempName += "s"; 23 | Logger.log("Getting price"); 24 | price = LivePrices.get(tempName); 25 | Logger.log("Got price: " + price); 26 | } else 27 | price = 0; 28 | } 29 | 30 | public void update() { 31 | int increase = 0; 32 | if (id == 0) 33 | increase = Inventory.count(name) - lastCount; 34 | else 35 | increase = Inventory.count(id) - lastCount; 36 | if (increase < 0) 37 | increase = 0; 38 | amount += increase; 39 | if (id == 0) 40 | lastCount = Inventory.count(name); 41 | else 42 | lastCount = Inventory.count(id); 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public void setAmount(int amt) { 50 | this.amount = amt; 51 | } 52 | 53 | public void setPrice(int price) { 54 | this.price = price; 55 | } 56 | 57 | public String getName() { 58 | return name; 59 | } 60 | 61 | public int getAmount() { 62 | return amount; 63 | } 64 | 65 | public int getPrice() { 66 | return price; 67 | } 68 | 69 | public int getValue() { 70 | if (amount <= 0) 71 | return 0; 72 | return amount * price; 73 | } 74 | 75 | public int getId() { 76 | return id; 77 | } 78 | 79 | public void setId(int id) { 80 | this.id = id; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /DreambotFlaxPicker/src/nezz/dreambot/scriptmain/flaxpicker/Flax.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.flaxpicker; 2 | 3 | import nezz.dreambot.tools.PricedItem; 4 | import org.dreambot.api.Client; 5 | import org.dreambot.api.input.Mouse; 6 | import org.dreambot.api.methods.Calculations; 7 | import org.dreambot.api.methods.container.impl.Inventory; 8 | import org.dreambot.api.methods.container.impl.bank.Bank; 9 | import org.dreambot.api.methods.container.impl.bank.BankLocation; 10 | import org.dreambot.api.methods.interactive.GameObjects; 11 | import org.dreambot.api.methods.interactive.Players; 12 | import org.dreambot.api.methods.map.Area; 13 | import org.dreambot.api.methods.map.Tile; 14 | import org.dreambot.api.methods.walking.impl.Walking; 15 | import org.dreambot.api.script.AbstractScript; 16 | import org.dreambot.api.script.Category; 17 | import org.dreambot.api.script.ScriptManifest; 18 | import org.dreambot.api.utilities.Sleep; 19 | import org.dreambot.api.utilities.Timer; 20 | import org.dreambot.api.wrappers.interactive.GameObject; 21 | import org.dreambot.api.wrappers.widgets.Menu; 22 | 23 | import java.awt.*; 24 | 25 | @ScriptManifest(author = "Nezz", category = Category.MONEYMAKING, description = "Picks flax", name = "DreamBot Flax Picker", version = 0) 26 | public class Flax extends AbstractScript { 27 | 28 | 29 | private final Tile FLAX_TILE = new Tile(2741, 3446, 0); 30 | private final Area FLAX_AREA = new Area(2737, 3450, 2745, 3444); 31 | 32 | private int runThresh = Calculations.random(30, 70); 33 | private int walkThresh = Calculations.random(4, 8); 34 | 35 | private Timer timer; 36 | private PricedItem flax = null; 37 | private GameObject flaxToPick = null; 38 | 39 | public void onStart() { 40 | flax = new PricedItem("Flax", false); 41 | timer = new Timer(); 42 | } 43 | 44 | private State state = null; 45 | 46 | private enum State { 47 | PICK, BANK 48 | } 49 | 50 | private State getState() { 51 | if (Inventory.isFull()) { 52 | return State.BANK; 53 | } else 54 | return State.PICK; 55 | } 56 | 57 | private GameObject getFlax() { 58 | if (flaxToPick == null || !flaxToPick.exists()) { 59 | flaxToPick = GameObjects.closest("Flax"); 60 | } 61 | return flaxToPick; 62 | } 63 | 64 | @Override 65 | public int onLoop() { 66 | flax.update(); 67 | if (!Walking.isRunEnabled() && Walking.getRunEnergy() > runThresh) { 68 | Walking.toggleRun(); 69 | runThresh = Calculations.random(30, 70); 70 | } 71 | if (!Walking.shouldWalk(walkThresh)) { 72 | return Calculations.random(500, 700); 73 | } 74 | walkThresh = Calculations.random(4, 8); 75 | state = getState(); 76 | switch (state) { 77 | case BANK: 78 | flaxToPick = null; 79 | if (BankLocation.SEERS.getArea(5).contains(Players.getLocal())) { 80 | if (Bank.isOpen()) { 81 | Bank.depositAllItems(); 82 | Sleep.sleepUntil(Inventory::isEmpty, 1200); 83 | } else { 84 | Bank.open(); 85 | Sleep.sleepUntil(Bank::isOpen, 1200); 86 | } 87 | } else { 88 | Walking.walk(BankLocation.SEERS.getCenter()); 89 | sleep(700, 900); 90 | } 91 | break; 92 | case PICK: 93 | if (FLAX_AREA.contains(Players.getLocal())) { 94 | if (Menu.getDefaultAction().equals("Pick")) { 95 | Mouse.click(false); 96 | sleep((int) (Calculations.random(300, 400) * Client.seededRandom())); 97 | } else { 98 | GameObject flax = getFlax(); 99 | if (flax != null) { 100 | flax.interact("Pick"); 101 | sleep((int) (Calculations.random(300, 500) * Client.seededRandom())); 102 | } 103 | } 104 | } else { 105 | Walking.walk(FLAX_TILE); 106 | sleep(700, 900); 107 | } 108 | break; 109 | } 110 | return (int) (Calculations.random(200, 300) * Client.seededRandom()); 111 | } 112 | 113 | public void onPaint(Graphics g) { 114 | if (state != null) { 115 | g.drawString("State: " + state, 10, 35); 116 | g.drawString("Runtime: " + timer.formatTime(), 10, 50); 117 | g.drawString("Flax(p/h): " + flax.getAmount() + "(" + timer.getHourlyRate(flax.getAmount()) + ")", 10, 65); 118 | } 119 | } 120 | 121 | 122 | } 123 | -------------------------------------------------------------------------------- /DreambotFlaxPicker/src/nezz/dreambot/tools/PricedItem.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.tools; 2 | 3 | import org.dreambot.api.methods.container.impl.Inventory; 4 | import org.dreambot.api.methods.grandexchange.LivePrices; 5 | import org.dreambot.api.utilities.Logger; 6 | 7 | public class PricedItem { 8 | private String name; 9 | private int lastCount = 0; 10 | private int amount = 0; 11 | private int price = 0; 12 | private int id = 0; 13 | 14 | public PricedItem(String name, boolean getPrice) { 15 | this.name = name; 16 | if (Inventory.contains(name)) { 17 | lastCount = Inventory.count(name); 18 | } 19 | if (getPrice) { 20 | String tempName = name; 21 | if (name.contains("arrow")) 22 | tempName += "s"; 23 | Logger.log("Getting price"); 24 | price = LivePrices.get(tempName); 25 | Logger.log("Got price: " + price); 26 | } else 27 | price = 0; 28 | } 29 | 30 | public void update() { 31 | int increase = 0; 32 | if (id == 0) 33 | increase = Inventory.count(name) - lastCount; 34 | else 35 | increase = Inventory.count(id) - lastCount; 36 | if (increase < 0) 37 | increase = 0; 38 | amount += increase; 39 | if (id == 0) 40 | lastCount = Inventory.count(name); 41 | else 42 | lastCount = Inventory.count(id); 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public void setAmount(int amt) { 50 | this.amount = amt; 51 | } 52 | 53 | public void setPrice(int price) { 54 | this.price = price; 55 | } 56 | 57 | public String getName() { 58 | return name; 59 | } 60 | 61 | public int getAmount() { 62 | return amount; 63 | } 64 | 65 | public int getPrice() { 66 | return price; 67 | } 68 | 69 | public int getValue() { 70 | if (amount <= 0) 71 | return 0; 72 | return amount * price; 73 | } 74 | 75 | public int getId() { 76 | return id; 77 | } 78 | 79 | public void setId(int id) { 80 | this.id = id; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /DreambotFletcher/src/nezz/dreambot/fletcher/gui/ScriptVars.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.fletcher.gui; 2 | 3 | import nezz.dreambot.scriptmain.fletch.Fletching; 4 | 5 | public class ScriptVars { 6 | public Fletching fletch; 7 | public boolean chopNDrop = false; 8 | public boolean progress = false; 9 | public boolean started = false; 10 | } 11 | -------------------------------------------------------------------------------- /DreambotFletcher/src/nezz/dreambot/fletcher/gui/fletchGUI.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.fletcher.gui; 2 | 3 | import javax.swing.JFrame; 4 | import javax.swing.JPanel; 5 | import javax.swing.border.EmptyBorder; 6 | 7 | import java.awt.Toolkit; 8 | 9 | import javax.swing.JLabel; 10 | import javax.swing.JComboBox; 11 | import javax.swing.DefaultComboBoxModel; 12 | import javax.swing.JCheckBox; 13 | import javax.swing.JButton; 14 | 15 | import nezz.dreambot.scriptmain.fletch.Fletching; 16 | 17 | import java.awt.event.ActionListener; 18 | import java.awt.event.ActionEvent; 19 | import java.awt.Color; 20 | 21 | public class fletchGUI extends JFrame { 22 | 23 | /** 24 | * 25 | */ 26 | private static final long serialVersionUID = 1L; 27 | private JPanel contentPane; 28 | JCheckBox chckbxPowerFish = new JCheckBox("Chop n Drop"); 29 | JComboBox comboBox = new JComboBox(); 30 | 31 | 32 | public fletchGUI(final ScriptVars var) { 33 | setTitle("DreamBot Fletcher"); 34 | setIconImage(Toolkit.getDefaultToolkit().getImage(fletchGUI.class.getResource("/javax/swing/plaf/metal/icons/ocean/computer.gif"))); 35 | setAlwaysOnTop(true); 36 | setResizable(false); 37 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 38 | setBounds(100, 100, 276, 167); 39 | contentPane = new JPanel(); 40 | contentPane.setBackground(Color.WHITE); 41 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 42 | setContentPane(contentPane); 43 | contentPane.setLayout(null); 44 | 45 | JPanel panel = new JPanel(); 46 | panel.setBounds(0, 0, 270, 101); 47 | contentPane.add(panel); 48 | panel.setLayout(null); 49 | 50 | JLabel lblYourFish = new JLabel("Fletch:"); 51 | lblYourFish.setBounds(10, 11, 72, 14); 52 | panel.add(lblYourFish); 53 | 54 | comboBox.setModel(new DefaultComboBoxModel(Fletching.values())); 55 | comboBox.setBounds(92, 8, 168, 20); 56 | panel.add(comboBox); 57 | 58 | chckbxPowerFish.setBounds(92, 35, 97, 23); 59 | panel.add(chckbxPowerFish); 60 | 61 | final JCheckBox chckbxProgress = new JCheckBox("Progress"); 62 | chckbxProgress.setBounds(92, 61, 97, 23); 63 | panel.add(chckbxProgress); 64 | 65 | JButton btnNewButton = new JButton("Start!"); 66 | btnNewButton.addActionListener(new ActionListener() { 67 | public void actionPerformed(ActionEvent arg0) { 68 | var.fletch = Fletching.values()[comboBox.getSelectedIndex()]; 69 | var.chopNDrop = chckbxPowerFish.isSelected(); 70 | var.progress = chckbxProgress.isSelected(); 71 | var.started = true; 72 | dispose(); 73 | } 74 | }); 75 | btnNewButton.setBounds(0, 101, 270, 34); 76 | contentPane.add(btnNewButton); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /DreambotFletcher/src/nezz/dreambot/scriptmain/fletch/Fletcher.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.fletch; 2 | 3 | import nezz.dreambot.fletcher.gui.ScriptVars; 4 | import nezz.dreambot.fletcher.gui.fletchGUI; 5 | import org.dreambot.api.input.Mouse; 6 | import org.dreambot.api.methods.Calculations; 7 | import org.dreambot.api.methods.container.impl.Inventory; 8 | import org.dreambot.api.methods.container.impl.bank.Bank; 9 | import org.dreambot.api.methods.input.Keyboard; 10 | import org.dreambot.api.methods.interactive.GameObjects; 11 | import org.dreambot.api.methods.interactive.Players; 12 | import org.dreambot.api.methods.skills.Skill; 13 | import org.dreambot.api.methods.skills.SkillTracker; 14 | import org.dreambot.api.methods.skills.Skills; 15 | import org.dreambot.api.methods.widget.Widget; 16 | import org.dreambot.api.methods.widget.Widgets; 17 | import org.dreambot.api.script.AbstractScript; 18 | import org.dreambot.api.script.Category; 19 | import org.dreambot.api.script.ScriptManifest; 20 | import org.dreambot.api.utilities.Sleep; 21 | import org.dreambot.api.utilities.Timer; 22 | import org.dreambot.api.wrappers.interactive.GameObject; 23 | import org.dreambot.api.wrappers.items.Item; 24 | import org.dreambot.api.wrappers.widgets.WidgetChild; 25 | 26 | import java.awt.*; 27 | 28 | @ScriptManifest(author = "Nezz", category = Category.FLETCHING, description = "Fletcher", name = "Dreambot Fletcher", version = 0) 29 | public class Fletcher extends AbstractScript { 30 | 31 | ScriptVars sv = new ScriptVars(); 32 | Timer t; 33 | boolean started = false; 34 | State state; 35 | 36 | private enum State { 37 | FLETCH, CHOP, DROP, BANK 38 | } 39 | 40 | private State getState() { 41 | if (Inventory.isFull()) { 42 | if (Inventory.contains(sv.fletch.getLog()) && Inventory.contains("Knife")) { 43 | return State.FLETCH; 44 | } else { 45 | if (sv.chopNDrop) { 46 | return State.DROP; 47 | } else { 48 | return State.BANK; 49 | } 50 | } 51 | } else { 52 | if (!sv.chopNDrop) { 53 | if (Inventory.contains(sv.fletch.getLog()) && Inventory.contains("Knife")) { 54 | return State.FLETCH; 55 | } else { 56 | return State.BANK; 57 | } 58 | } else { 59 | return State.CHOP; 60 | } 61 | } 62 | } 63 | 64 | public void onStart() { 65 | fletchGUI gui = new fletchGUI(sv); 66 | gui.setVisible(true); 67 | while (!sv.started) { 68 | sleep(300); 69 | } 70 | t = new Timer(); 71 | SkillTracker.start(Skill.FLETCHING); 72 | log("Starting Dreambot Fletcher"); 73 | started = true; 74 | } 75 | 76 | @Override 77 | public int onLoop() { 78 | int returnThis = -1; 79 | if (progress()) 80 | return 1; 81 | state = getState(); 82 | switch (state) { 83 | case BANK: 84 | if (Bank.isOpen()) { 85 | if (Inventory.contains(sv.fletch.getName())) { 86 | Bank.depositAll(sv.fletch.getName()); 87 | Sleep.sleepUntil(() -> !Inventory.contains(sv.fletch.getName()), 2000); 88 | returnThis = Calculations.random(300, 600); 89 | } else { 90 | if (!Bank.contains(sv.fletch.getLog())) { 91 | log("Out of: " + sv.fletch.getLog()); 92 | return -1; 93 | } 94 | Bank.withdrawAll(sv.fletch.getLog()); 95 | Sleep.sleepUntil(() -> Inventory.contains(sv.fletch.getLog()), 2000); 96 | returnThis = Calculations.random(300, 600); 97 | } 98 | } else { 99 | Bank.open(); 100 | Sleep.sleepUntil(Bank::isOpen, 2000); 101 | returnThis = Calculations.random(300, 600); 102 | } 103 | break; 104 | case CHOP: 105 | if (Inventory.isItemSelected()) { 106 | Mouse.click(); 107 | } 108 | GameObject tree = GameObjects.closest(sv.fletch.getTree()); 109 | if (tree != null && tree.exists() && Players.getLocal().getAnimation() == -1) { 110 | tree.interact("Chop down"); 111 | Sleep.sleepUntil(() -> Players.getLocal().getAnimation() != -1, 3500); 112 | returnThis = Calculations.random(300, 600); 113 | } else { 114 | sleep(300, 600); 115 | returnThis = Calculations.random(300, 500); 116 | } 117 | break; 118 | case DROP: 119 | for (int i = 0; i < 28; i++) { 120 | Item item = Inventory.getItemInSlot(i); 121 | if (item != null && !item.getName().contains("axe") && !item.getName().equals("Knife")) { 122 | Inventory.interact(i, "Drop"); 123 | sleep(100, 300); 124 | } 125 | } 126 | returnThis = Calculations.random(300, 600); 127 | break; 128 | case FLETCH: 129 | if (Bank.isOpen()) { 130 | Bank.close(); 131 | Sleep.sleepUntil(() -> !Bank.isOpen(), 1200); 132 | return 1; 133 | } else if (Players.getLocal().getAnimation() == -1) { 134 | if (Inventory.contains("Knife")) { 135 | final Widget par = Widgets.getWidget(sv.fletch.getParent()); 136 | WidgetChild chil = null; 137 | if (par != null) { 138 | chil = par.getChild(sv.fletch.getChild()); 139 | } 140 | if (chil != null && chil.isVisible()) { 141 | /*Mouse.move(chil.getRectangle()); 142 | for(String action : Menu.getMenuActions()){ 143 | log(action); 144 | } 145 | Mouse.click(true); 146 | try { 147 | Menu.clickAction("Make X"); 148 | } catch (InterruptedException e) { 149 | e.printStackTrace(); 150 | }*/ 151 | chil.interact("Make X"); 152 | Sleep.sleepUntil(() -> !par.getChild(sv.fletch.getChild()).isVisible(), 2000); 153 | if (!chil.isVisible()) { 154 | int typ = Calculations.random(1, 9); 155 | Keyboard.type((Integer.toString(typ) + typ + typ), true); 156 | sleep(456, 765); 157 | } 158 | returnThis = Calculations.random(300, 600); 159 | } else { 160 | Inventory.interact("Knife", "Use"); 161 | sleep(345, 654); 162 | Rectangle r = Inventory.slotBounds(Inventory.slot(sv.fletch.getLog())); 163 | Mouse.move(r.getLocation()); 164 | Mouse.click(); 165 | Sleep.sleepUntil(() -> { 166 | Widget par1 = Widgets.getWidget(sv.fletch.getParent()); 167 | WidgetChild chil1 = null; 168 | if (par1 != null) { 169 | chil1 = par1.getChild(sv.fletch.getChild()); 170 | } 171 | return chil1 != null && chil1.isVisible(); 172 | }, 2000); 173 | returnThis = Calculations.random(300, 600); 174 | } 175 | } else { 176 | log("No knife!?"); 177 | } 178 | } else { 179 | returnThis = Calculations.random(300, 600); 180 | } 181 | break; 182 | } 183 | return returnThis; 184 | } 185 | 186 | public boolean progress() { 187 | if (!sv.progress || sv.fletch.ordinal() == Fletching.values().length - 1) 188 | return false; 189 | if (Skills.getRealLevel(Skill.FLETCHING) >= Fletching.values()[sv.fletch.ordinal() + 1].getLevel()) { 190 | sv.fletch = Fletching.values()[sv.fletch.ordinal() + 1]; 191 | return true; 192 | } 193 | return false; 194 | } 195 | 196 | public void onPaint(Graphics g) { 197 | if (started) { 198 | if (state != null) { 199 | g.drawString("State: " + state, 10, 50); 200 | } 201 | g.drawString("Runtime: " + t.formatTime(), 10, 65); 202 | g.drawString("Experience(p/h): " + SkillTracker.getGainedExperience(Skill.FLETCHING) + "(" + SkillTracker.getGainedExperiencePerHour(Skill.FLETCHING) + ")", 10, 80); 203 | g.drawString("Level(gained): " + Skills.getRealLevel(Skill.FLETCHING) + "(" + SkillTracker.getGainedLevels(Skill.FLETCHING) + ")", 10, 95); 204 | g.drawString("Fletching: " + sv.fletch.getName(), 10, 110); 205 | } 206 | } 207 | 208 | } 209 | -------------------------------------------------------------------------------- /DreambotFletcher/src/nezz/dreambot/scriptmain/fletch/Fletching.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.fletch; 2 | 3 | public enum Fletching { 4 | Arrows("Arrow shaft", "Logs", 305, 2, 1, 5), 5 | Shortbowu("Shortbow (u)", "Logs", 305, 3, 5, 5), 6 | Longbowu("Longbow (u)", "Logs", 305, 4, 10, 10), 7 | OakShortbowu("Oak shortbow (u)", "Oak logs", 304, 2, 20, 16.5), 8 | OakLongbowu("Oak longbow (u)", "Oak logs", 304, 3, 25, 25), 9 | WillowShortbowu("Willow shortbow (u)", "Willow logs", 304, 2, 35, 33.3), 10 | WillowLongbowu("Willow longbow (u)", "Willow logs", 304, 3, 40, 41.5); 11 | 12 | private final String name; 13 | private final String log; 14 | private final int parent; 15 | private final int child; 16 | private final int level; 17 | private final double experience; 18 | 19 | Fletching(String name, String reqItem, int parent, int child, int level, double experience) { 20 | this.name = name; 21 | this.parent = parent; 22 | this.child = child; 23 | this.level = level; 24 | this.experience = experience; 25 | this.log = reqItem; 26 | } 27 | 28 | public String getName() { 29 | return this.name; 30 | } 31 | 32 | public int getParent() { 33 | return this.parent; 34 | } 35 | 36 | public int getChild() { 37 | return this.child; 38 | } 39 | 40 | public int getLevel() { 41 | return this.level; 42 | } 43 | 44 | public double getExperience() { 45 | return this.experience; 46 | } 47 | 48 | public String getLog() { 49 | return log; 50 | } 51 | 52 | public String getTree() { 53 | if (getLog().equals("Logs")) 54 | return "Tree"; 55 | else 56 | return (name.split(" ")[0]); 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /DreambotHerblore/src/nezz/dreambot/herblore/gui/ScriptVars.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.herblore.gui; 2 | 3 | import nezz.dreambot.scriptmain.herblore.Herbs; 4 | import nezz.dreambot.scriptmain.herblore.Pots; 5 | 6 | public class ScriptVars { 7 | public Herbs yourHerb = Herbs.GUAM; 8 | public Pots yourPot = Pots.AttackPotion; 9 | public boolean id = false; 10 | public boolean potions = false; 11 | public boolean debug = false; 12 | public boolean started = false; 13 | public boolean unfPotions = false; 14 | } 15 | -------------------------------------------------------------------------------- /DreambotHerblore/src/nezz/dreambot/herblore/gui/herbloreGui.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.herblore.gui; 2 | 3 | import javax.swing.JFrame; 4 | import javax.swing.JPanel; 5 | import javax.swing.border.EmptyBorder; 6 | 7 | import java.awt.Toolkit; 8 | 9 | import javax.swing.JLabel; 10 | import javax.swing.JComboBox; 11 | import javax.swing.DefaultComboBoxModel; 12 | import javax.swing.JButton; 13 | 14 | 15 | import java.awt.event.ActionListener; 16 | import java.awt.event.ActionEvent; 17 | import java.awt.Color; 18 | 19 | import javax.swing.JTabbedPane; 20 | 21 | import nezz.dreambot.scriptmain.herblore.Herbs; 22 | import nezz.dreambot.scriptmain.herblore.Pots; 23 | 24 | 25 | public class herbloreGui extends JFrame { 26 | 27 | /** 28 | * 29 | */ 30 | private static final long serialVersionUID = 1L; 31 | private JPanel contentPane; 32 | JComboBox comboBox_1;// = new JComboBox(); 33 | JComboBox comboBox;// = new JComboBox(); 34 | JComboBox comboBox_2; 35 | JLabel label = new JLabel("1"); 36 | JLabel level = new JLabel("1"); 37 | JLabel ing_1 = new JLabel("Ing. 1"); 38 | JLabel ing_2 = new JLabel("Ing. 2"); 39 | 40 | 41 | public herbloreGui(final ScriptVars var) { 42 | setTitle("DreamBot"); 43 | setIconImage(Toolkit.getDefaultToolkit().getImage(herbloreGui.class.getResource("/javax/swing/plaf/metal/icons/ocean/computer.gif"))); 44 | setAlwaysOnTop(true); 45 | setResizable(false); 46 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 47 | setBounds(100, 100, 308, 174); 48 | contentPane = new JPanel(); 49 | contentPane.setBackground(Color.WHITE); 50 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 51 | setContentPane(contentPane); 52 | contentPane.setLayout(null); 53 | 54 | JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); 55 | tabbedPane.setBounds(0, 0, 302, 115); 56 | contentPane.add(tabbedPane); 57 | 58 | JPanel panel = new JPanel(); 59 | tabbedPane.addTab("Main", null, panel, null); 60 | panel.setLayout(null); 61 | 62 | comboBox = new JComboBox(); 63 | comboBox.setModel(new DefaultComboBoxModel(new String[]{"Identify", "Potions", "Debug", "Unf Potions"})); 64 | comboBox.setBounds(66, 11, 76, 20); 65 | panel.add(comboBox); 66 | 67 | JLabel lblMode = new JLabel("Mode:"); 68 | lblMode.setBounds(10, 14, 46, 14); 69 | panel.add(lblMode); 70 | 71 | JPanel panel_1 = new JPanel(); 72 | tabbedPane.addTab("Identify", null, panel_1, null); 73 | panel_1.setLayout(null); 74 | 75 | comboBox_1 = new JComboBox(); 76 | comboBox_1.addActionListener(new ActionListener() { 77 | public void actionPerformed(ActionEvent arg0) { 78 | Herbs h = Herbs.values()[comboBox_1.getSelectedIndex()]; 79 | var.yourHerb = h; 80 | label.setText("" + h.getIdLevel()); 81 | } 82 | }); 83 | comboBox_1.setModel(new DefaultComboBoxModel(Herbs.values())); 84 | comboBox_1.setBounds(123, 11, 139, 20); 85 | panel_1.add(comboBox_1); 86 | 87 | JLabel lblChooseYourHerb = new JLabel("Choose your Herb:"); 88 | lblChooseYourHerb.setBounds(10, 14, 123, 14); 89 | panel_1.add(lblChooseYourHerb); 90 | 91 | JLabel lblLevelRequired = new JLabel("Level Required:"); 92 | lblLevelRequired.setBounds(10, 62, 92, 14); 93 | panel_1.add(lblLevelRequired); 94 | 95 | label.setBounds(123, 62, 46, 14); 96 | panel_1.add(label); 97 | 98 | 99 | JPanel panel_2 = new JPanel(); 100 | tabbedPane.addTab("Potions", null, panel_2, null); 101 | panel_2.setLayout(null); 102 | 103 | JLabel lblChooseYourPotion = new JLabel("Choose your Potion:"); 104 | lblChooseYourPotion.setBounds(14, 8, 98, 14); 105 | panel_2.add(lblChooseYourPotion); 106 | 107 | comboBox_2 = new JComboBox(); 108 | comboBox_2.addActionListener(new ActionListener() { 109 | public void actionPerformed(ActionEvent arg0) { 110 | Pots p = Pots.values()[comboBox_2.getSelectedIndex()]; 111 | var.yourPot = p; 112 | ing_1.setText(p.getIngredientOne()); 113 | ing_2.setText(p.getIngredientTwo()); 114 | level.setText("" + p.getLevel()); 115 | } 116 | }); 117 | comboBox_2.setModel(new DefaultComboBoxModel(Pots.values())); 118 | comboBox_2.setBounds(117, 5, 165, 20); 119 | panel_2.add(comboBox_2); 120 | 121 | JLabel lblIng = new JLabel("Ing. 1:"); 122 | lblIng.setBounds(14, 33, 46, 14); 123 | panel_2.add(lblIng); 124 | 125 | JLabel lblIng_1 = new JLabel("Ing. 2:"); 126 | lblIng_1.setBounds(14, 48, 46, 14); 127 | panel_2.add(lblIng_1); 128 | 129 | JLabel lblLevel = new JLabel("Level: "); 130 | lblLevel.setBounds(14, 62, 46, 14); 131 | panel_2.add(lblLevel); 132 | 133 | level.setBounds(70, 62, 46, 14); 134 | panel_2.add(level); 135 | 136 | ing_1.setBounds(70, 33, 133, 14); 137 | panel_2.add(ing_1); 138 | 139 | ing_2.setBounds(70, 48, 133, 14); 140 | panel_2.add(ing_2); 141 | 142 | 143 | JButton btnNewButton = new JButton("START"); 144 | btnNewButton.addActionListener(new ActionListener() { 145 | public void actionPerformed(ActionEvent arg0) { 146 | if (comboBox.getSelectedIndex() == 0) 147 | var.id = true; 148 | else if (comboBox.getSelectedIndex() == 1) 149 | var.potions = true; 150 | else if (comboBox.getSelectedIndex() == 2) 151 | var.debug = true; 152 | else if (comboBox.getSelectedIndex() == 3) 153 | var.unfPotions = true; 154 | var.yourHerb = Herbs.values()[comboBox_1.getSelectedIndex()]; 155 | var.started = true; 156 | dispose(); 157 | } 158 | }); 159 | btnNewButton.setBounds(0, 119, 302, 23); 160 | contentPane.add(btnNewButton); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /DreambotHerblore/src/nezz/dreambot/scriptmain/herblore/DebugScreens.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.herblore; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | import java.util.List; 6 | 7 | import nezz.dreambot.herblore.gui.ScriptVars; 8 | 9 | import org.dreambot.api.methods.container.impl.Inventory; 10 | import org.dreambot.api.methods.container.impl.bank.Bank; 11 | import org.dreambot.api.methods.skills.Skill; 12 | import org.dreambot.api.methods.skills.Skills; 13 | import org.dreambot.api.methods.trade.Trade; 14 | import org.dreambot.api.script.AbstractScript; 15 | import org.dreambot.api.wrappers.items.Item; 16 | 17 | public class DebugScreens extends States { 18 | 19 | public DebugScreens(AbstractScript as, ScriptVars sv) { 20 | this.as = as; 21 | this.sv = sv; 22 | } 23 | 24 | List bank; 25 | Item[] trade; 26 | 27 | @Override 28 | public String getMode() { 29 | return "Debugging screens"; 30 | } 31 | 32 | public boolean drawBank = false; 33 | public boolean drawTrade = false; 34 | 35 | @Override 36 | public int execute() { 37 | if (Trade.isOpen()) { 38 | trade = Trade.getItems(false); 39 | drawTrade = true; 40 | } else 41 | drawTrade = false; 42 | if (Bank.isOpen()) { 43 | drawBank = true; 44 | bank = Bank.all(); 45 | } else 46 | drawBank = false; 47 | return 500; 48 | } 49 | 50 | @Override 51 | public String getState() { 52 | return "Drawing"; 53 | } 54 | 55 | private int drawInventory(Graphics g) { 56 | Color color = new Color(0, 0, 0, 120); 57 | g.setColor(color); 58 | g.fillRect(400, 2, 150, 15); 59 | g.setColor(Color.blue); 60 | g.drawString("INVENTORY:", 400, 15); 61 | int baseY = 30; 62 | for (int i = 0; i < 28; i++) { 63 | boolean clean = false; 64 | g.setColor(Color.green); 65 | Item item = Inventory.getItemInSlot(i); 66 | if (item != null) { 67 | Herbs h = null; 68 | for (Herbs herb : Herbs.values()) { 69 | int itemId = item.getID(); 70 | if (itemId == herb.getNotedCleanId() || itemId == herb.getUnnotedCleanId()) { 71 | clean = true; 72 | h = herb; 73 | break; 74 | } 75 | if (itemId == herb.getNotedGrimyId() || itemId == herb.getUnnotedGrimyId()) { 76 | clean = false; 77 | h = herb; 78 | break; 79 | } 80 | } 81 | if (h != null) { 82 | g.setColor(color); 83 | g.fillRect(400, baseY - 13, 150, 15); 84 | if (!h.canIdHerb(Skill.HERBLORE.getBoostedLevel()) && !clean) { 85 | g.setColor(Color.red); 86 | } else if (clean) { 87 | g.setColor(Color.yellow); 88 | } else { 89 | g.setColor(Color.green); 90 | } 91 | g.drawString(h.getName() + ": " + item.getID() + "(" + item.getAmount() + ")", 400, baseY); 92 | baseY += 15; 93 | } 94 | } 95 | } 96 | return baseY; 97 | } 98 | 99 | private void drawBank(Graphics g, int baseY) { 100 | Color color = new Color(0, 0, 0, 120); 101 | g.setColor(color); 102 | g.fillRect(400, baseY - 13, 150, 15); 103 | g.setColor(Color.blue); 104 | g.drawString("BANK:", 400, baseY); 105 | baseY += 15; 106 | for (Item item : bank) { 107 | boolean clean = false; 108 | g.setColor(Color.green); 109 | if (item != null) { 110 | Herbs h = null; 111 | for (Herbs herb : Herbs.values()) { 112 | int itemId = item.getID(); 113 | if (itemId == herb.getNotedCleanId() || itemId == herb.getUnnotedCleanId()) { 114 | clean = true; 115 | h = herb; 116 | break; 117 | } 118 | if (itemId == herb.getNotedGrimyId() || itemId == herb.getUnnotedGrimyId()) { 119 | clean = false; 120 | h = herb; 121 | break; 122 | } 123 | } 124 | if (h != null) { 125 | g.setColor(color); 126 | g.fillRect(400, baseY - 13, 150, 15); 127 | if (!h.canIdHerb(Skill.HERBLORE.getBoostedLevel()) && !clean) { 128 | g.setColor(Color.red); 129 | } else if (clean) { 130 | g.setColor(Color.yellow); 131 | } else { 132 | g.setColor(Color.green); 133 | } 134 | g.drawString(h.getName() + ": " + item.getID() + "(" + item.getAmount() + ")", 400, baseY); 135 | baseY += 15; 136 | } 137 | } 138 | } 139 | } 140 | 141 | private void drawTrade(Graphics g, int baseY) { 142 | Color color = new Color(0, 0, 0, 120); 143 | g.setColor(color); 144 | g.fillRect(400, baseY - 13, 150, 15); 145 | g.setColor(Color.blue); 146 | g.drawString("TRADE:", 400, baseY); 147 | baseY += 15; 148 | for (Item item : trade) { 149 | boolean clean = false; 150 | g.setColor(Color.green); 151 | if (item != null) { 152 | Herbs h = null; 153 | for (Herbs herb : Herbs.values()) { 154 | int itemId = item.getID(); 155 | if (itemId == herb.getNotedCleanId() || itemId == herb.getUnnotedCleanId()) { 156 | clean = true; 157 | h = herb; 158 | break; 159 | } 160 | if (itemId == herb.getNotedGrimyId() || itemId == herb.getUnnotedGrimyId()) { 161 | clean = false; 162 | h = herb; 163 | break; 164 | } 165 | } 166 | if (h != null) { 167 | g.setColor(color); 168 | g.fillRect(400, baseY - 13, 150, 15); 169 | if (!h.canIdHerb(Skill.HERBLORE.getBoostedLevel()) && !clean) { 170 | g.setColor(Color.red); 171 | } else if (clean) { 172 | g.setColor(Color.yellow); 173 | } else { 174 | g.setColor(Color.green); 175 | } 176 | g.drawString(h.getName() + ": " + item.getID() + "(" + item.getAmount() + ")", 400, baseY); 177 | baseY += 15; 178 | } 179 | } 180 | } 181 | } 182 | 183 | @Override 184 | public void draw(Graphics g) { 185 | int y = drawInventory(g); 186 | if (drawBank) { 187 | drawBank(g, y); 188 | } 189 | if (drawTrade) 190 | drawTrade(g, y); 191 | } 192 | 193 | } 194 | -------------------------------------------------------------------------------- /DreambotHerblore/src/nezz/dreambot/scriptmain/herblore/Herblore.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.herblore; 2 | 3 | import nezz.dreambot.herblore.gui.ScriptVars; 4 | import nezz.dreambot.herblore.gui.herbloreGui; 5 | import org.dreambot.api.methods.skills.Skill; 6 | import org.dreambot.api.methods.skills.SkillTracker; 7 | import org.dreambot.api.script.AbstractScript; 8 | import org.dreambot.api.script.Category; 9 | import org.dreambot.api.script.ScriptManifest; 10 | import org.dreambot.api.utilities.Timer; 11 | 12 | import java.awt.*; 13 | 14 | @ScriptManifest(author = "Nezz", category = Category.HERBLORE, 15 | description = "ID's, makes potions, or debugs trade/inventory screens", 16 | name = "Dreambot's Herblore", version = 0) 17 | public class Herblore extends AbstractScript { 18 | 19 | private final ScriptVars sv = new ScriptVars(); 20 | herbloreGui gui; 21 | private States states; 22 | private boolean started = false; 23 | Timer timer; 24 | 25 | public void onStart() { 26 | gui = new herbloreGui(sv); 27 | gui.setVisible(true); 28 | while (!sv.started) { 29 | sleep(500); 30 | } 31 | if (sv.id) 32 | states = new Identify(this, sv); 33 | else if (sv.debug) 34 | states = new DebugScreens(this, sv); 35 | else if (sv.potions) 36 | states = new Potions(this, sv); 37 | else if (sv.unfPotions) 38 | states = new UnfPotions(this, sv); 39 | else 40 | states = null; 41 | if (states == null) { 42 | System.out.println("States is null?"); 43 | } 44 | SkillTracker.start(Skill.HERBLORE); 45 | timer = new Timer(); 46 | started = true; 47 | log("Starting Dreambot's Herblore Script!"); 48 | } 49 | 50 | @Override 51 | public int onLoop() { 52 | if (states == null) { 53 | stop(); 54 | return 1; 55 | } else { 56 | int ret = 0; 57 | try { 58 | ret = states.execute(); 59 | } catch (InterruptedException e) { 60 | ret = -1; 61 | e.printStackTrace(); 62 | } 63 | if (ret < 0) { 64 | stop(); 65 | return 100; 66 | } else { 67 | return ret; 68 | } 69 | } 70 | } 71 | 72 | public void onPaint(Graphics g) { 73 | if (started) { 74 | g.drawString("Runtime: " + timer.formatTime(), 10, 30); 75 | states.draw(g); 76 | } 77 | 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /DreambotHerblore/src/nezz/dreambot/scriptmain/herblore/Herbs.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.herblore; 2 | 3 | public enum Herbs { 4 | GUAM(3, 249, 250, 199, 200, 2.5), 5 | MARRENTILL(5, 251, 252, 201, 202, 3.8), 6 | TARROMIN(11, 253, 254, 203, 204, 5), 7 | HARRALANDER(20, 255, 256, 205, 206, 6.3), 8 | RANARR(25, 257, 258, 207, 208, 7.5), 9 | TOADFLAX(30, 2998, 2999, 3049, 3050, 8), 10 | IRIT(40, 259, 260, 209, 210, 8.8), 11 | AVANTOE(48, 261, 262, 211, 212, 10), 12 | KWUARM(54, 263, 264, 213, 214, 11.3), 13 | SNAPDRAGON(59, 3000, 3001, 3051, 3052, 11.8), 14 | CADANTINE(65, 265, 266, 215, 216, 12.5), 15 | LANTADYME(67, 2481, 2482, 2485, 2486, 13.1), 16 | DWARFWEED(70, 267, 268, 217, 218, 13.8), 17 | TORSTOL(75, 269, 270, 219, 220, 15); 18 | 19 | private final int idLevel; 20 | private final int unnotedCleanId; 21 | private final int notedCleanId; 22 | private final int unnotedGrimyId; 23 | private final int notedGrimyId; 24 | final double expGained; 25 | 26 | Herbs(int idLevel, int unnotedCleanId, int notedCleanId, int unnotedGrimyId, int notedGrimyId, double expGained) { 27 | this.idLevel = idLevel; 28 | this.unnotedCleanId = unnotedCleanId; 29 | this.notedCleanId = notedCleanId; 30 | this.unnotedGrimyId = unnotedGrimyId; 31 | this.notedGrimyId = notedGrimyId; 32 | this.expGained = expGained; 33 | } 34 | 35 | public int getUnnotedGrimyId() { 36 | return unnotedGrimyId; 37 | } 38 | 39 | public int getIdLevel() { 40 | return idLevel; 41 | } 42 | 43 | public int getUnnotedCleanId() { 44 | return unnotedCleanId; 45 | } 46 | 47 | public int getNotedCleanId() { 48 | return notedCleanId; 49 | } 50 | 51 | public int getNotedGrimyId() { 52 | return notedGrimyId; 53 | } 54 | 55 | public String getName() { 56 | return name().charAt(0) + name().substring(1).toLowerCase(); 57 | } 58 | 59 | public boolean canIdHerb(int currentLevel) { 60 | return currentLevel >= idLevel; 61 | } 62 | } -------------------------------------------------------------------------------- /DreambotHerblore/src/nezz/dreambot/scriptmain/herblore/Identify.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.herblore; 2 | 3 | import nezz.dreambot.herblore.gui.ScriptVars; 4 | import nezz.dreambot.tools.PricedItem; 5 | import org.dreambot.api.methods.Calculations; 6 | import org.dreambot.api.methods.container.impl.Inventory; 7 | import org.dreambot.api.methods.container.impl.bank.Bank; 8 | import org.dreambot.api.script.AbstractScript; 9 | import org.dreambot.api.utilities.Sleep; 10 | import org.dreambot.api.utilities.impl.Condition; 11 | import org.dreambot.api.wrappers.items.Item; 12 | 13 | public class Identify extends States { 14 | 15 | public Identify(AbstractScript as, ScriptVars sv) { 16 | this.as = as; 17 | this.sv = sv; 18 | this.lootList.add(new PricedItem(sv.yourHerb.getName(), sv.yourHerb.getUnnotedCleanId(), false)); 19 | } 20 | 21 | Condition depositItems = Inventory::isEmpty; 22 | Condition withdrawItems = () -> !Inventory.isEmpty(); 23 | 24 | public String getState() { 25 | if (Inventory.contains(sv.yourHerb.getUnnotedGrimyId())) 26 | return "IDENTIFY"; 27 | else 28 | return "BANK"; 29 | } 30 | 31 | public int execute() { 32 | int returnThis = -1; 33 | state = getState(); 34 | switch (state) { 35 | case "BANK": 36 | if (Bank.isOpen()) { 37 | if (Inventory.contains(sv.yourHerb.getUnnotedCleanId())) { 38 | Bank.depositAllItems(); 39 | Sleep.sleepUntil(depositItems, 2000); 40 | returnThis = 200; 41 | } else { 42 | if (Bank.contains(sv.yourHerb.getUnnotedGrimyId())) { 43 | Bank.withdrawAll(sv.yourHerb.getUnnotedGrimyId()); 44 | Sleep.sleepUntil(withdrawItems, 2000); 45 | returnThis = 200; 46 | } else { 47 | Bank.close(); 48 | } 49 | } 50 | } else { 51 | updateLoot(); 52 | Bank.open(); 53 | if (Inventory.isItemSelected()) { 54 | Inventory.deselect(); 55 | } 56 | returnThis = 200; 57 | } 58 | break; 59 | case "IDENTIFY": 60 | if (Bank.isOpen()) { 61 | Bank.close(); 62 | } else { 63 | for (int i = 0; i < 28; i++) { 64 | Item item = Inventory.getItemInSlot(i); 65 | if (item != null && item.getName().contains("Grimy")) { 66 | Inventory.slotInteract(i, "Clean"); 67 | Sleep.sleep(100, 300); 68 | this.updateLoot(); 69 | } 70 | } 71 | } 72 | returnThis = Calculations.random(600, 800); 73 | this.updateLoot(); 74 | break; 75 | } 76 | return returnThis; 77 | } 78 | 79 | public String getMode() { 80 | return "Identify Herbs"; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /DreambotHerblore/src/nezz/dreambot/scriptmain/herblore/Potions.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.herblore; 2 | 3 | import nezz.dreambot.herblore.gui.ScriptVars; 4 | import nezz.dreambot.tools.PricedItem; 5 | import org.dreambot.api.methods.Calculations; 6 | import org.dreambot.api.methods.container.impl.Inventory; 7 | import org.dreambot.api.methods.container.impl.bank.Bank; 8 | import org.dreambot.api.methods.input.Keyboard; 9 | import org.dreambot.api.methods.interactive.Players; 10 | import org.dreambot.api.methods.widget.Widget; 11 | import org.dreambot.api.methods.widget.Widgets; 12 | import org.dreambot.api.script.AbstractScript; 13 | import org.dreambot.api.utilities.Logger; 14 | import org.dreambot.api.utilities.Sleep; 15 | import org.dreambot.api.utilities.impl.Condition; 16 | import org.dreambot.api.wrappers.widgets.WidgetChild; 17 | 18 | 19 | public class Potions extends States { 20 | 21 | public Potions(AbstractScript as, ScriptVars sv) { 22 | this.as = as; 23 | this.sv = sv; 24 | lootList.add(new PricedItem(sv.yourPot.getName() + "(3)", false)); 25 | } 26 | 27 | @Override 28 | public String getMode() { 29 | return "Making potions: " + sv.yourPot.getName(); 30 | } 31 | 32 | Condition makePot = () -> Widgets.getChildWidget(309, 2) != null; 33 | 34 | private boolean wasAnimating = false; 35 | 36 | @Override 37 | public int execute() { 38 | int returnThis = -1; 39 | this.state = getState(); 40 | switch (state) { 41 | case "Finish Potion": 42 | if (Bank.isOpen()) { 43 | Bank.close(); 44 | returnThis = 600; 45 | wasAnimating = false; 46 | } else if (wasAnimating && amIAnimating()) { 47 | this.updateLoot(); 48 | returnThis = 600; 49 | } else if (Widgets.getWidget(309) != null && Widgets.getWidget(309).getChild(2) != null) { 50 | Widget par = Widgets.getWidget(309); 51 | WidgetChild child = null; 52 | if (par != null) { 53 | child = par.getChild(2); 54 | } 55 | if (child != null) { 56 | Keyboard.type(" ", false); 57 | Sleep.sleepUntil(() -> Players.getLocal().isAnimating(), 1200); 58 | wasAnimating = Players.getLocal().isAnimating(); 59 | returnThis = 400; 60 | } else { 61 | wasAnimating = false; 62 | Logger.log("Issues?"); 63 | returnThis = 1000; 64 | } 65 | } else { 66 | if (!Inventory.isItemSelected()) { 67 | Inventory.interact(sv.yourPot.getIngredientTwo(), "Use"); 68 | returnThis = 400; 69 | wasAnimating = false; 70 | } else { 71 | Inventory.interact(sv.yourPot.getUnfName(), "Use"); 72 | Sleep.sleepUntil(makePot, 2000); 73 | Widget par = Widgets.getWidget(309); 74 | WidgetChild child = null; 75 | if (par != null) { 76 | child = par.getChild(2); 77 | } 78 | if (child != null) { 79 | if (child.interact("Make All")) { 80 | wasAnimating = true; 81 | Sleep.sleepUntil(() -> Players.getLocal().getAnimation() != -1, 1200); 82 | } 83 | returnThis = 400; 84 | } else { 85 | Logger.log("Issues?"); 86 | returnThis = 1000; 87 | } 88 | } 89 | } 90 | break; 91 | case "Start Potion": 92 | if (Bank.isOpen()) { 93 | Bank.close(); 94 | returnThis = 600; 95 | wasAnimating = false; 96 | } else if (wasAnimating && amIAnimating()) { 97 | returnThis = 600; 98 | } else if (Widgets.getWidget(309) != null && Widgets.getWidget(309).getChild(2) != null) { 99 | Widget par = Widgets.getWidget(309); 100 | WidgetChild child = null; 101 | if (par != null) { 102 | child = par.getChild(2); 103 | } 104 | if (child != null) { 105 | if (child.interact("Make All")) { 106 | wasAnimating = true; 107 | Sleep.sleepUntil(() -> Players.getLocal().getAnimation() != -1, 1200); 108 | } else { 109 | wasAnimating = false; 110 | } 111 | returnThis = 400; 112 | } else { 113 | wasAnimating = false; 114 | Logger.log("Issues?"); 115 | returnThis = 1000; 116 | } 117 | } else { 118 | if (!Inventory.isItemSelected()) { 119 | Inventory.interact(sv.yourPot.getIngredientOne(), "Use"); 120 | returnThis = 400; 121 | wasAnimating = false; 122 | } else { 123 | Inventory.interact("Vial of water", "Use"); 124 | Sleep.sleepUntil(makePot, 2000); 125 | Widget par = Widgets.getWidget(309); 126 | WidgetChild child = null; 127 | if (par != null) { 128 | child = par.getChild(2); 129 | } 130 | if (child != null) { 131 | returnThis = 200; 132 | if (child.interact("Make All")) { 133 | wasAnimating = true; 134 | Sleep.sleepUntil(() -> Players.getLocal().getAnimation() != -1, 1200); 135 | } else { 136 | wasAnimating = false; 137 | } 138 | } else { 139 | wasAnimating = false; 140 | Logger.log("Issues?"); 141 | returnThis = 1000; 142 | } 143 | } 144 | } 145 | break; 146 | case "Bank": 147 | this.updateLoot(); 148 | wasAnimating = false; 149 | if (Bank.isOpen()) { 150 | if (Inventory.contains(sv.yourPot.getName() + "(3)")) { 151 | Bank.depositAllItems(); 152 | Sleep.sleepUntil(Inventory::isEmpty, 1200); 153 | returnThis = 100; 154 | } else { 155 | if (Inventory.isEmpty()) { 156 | if (Bank.contains(sv.yourPot.getUnfName())) { 157 | Logger.log("withdrawing unfinished potion"); 158 | Bank.withdraw(sv.yourPot.getUnfName(), 14); 159 | } else if (Bank.contains(sv.yourPot.getIngredientOne())) { 160 | Logger.log("withdrawing ingredient one"); 161 | Bank.withdraw(sv.yourPot.getIngredientOne(), 14); 162 | } else { 163 | Logger.log("You don't have the items!"); 164 | return -1; 165 | } 166 | returnThis = 600; 167 | } else if (Inventory.contains(sv.yourPot.getIngredientOne())) { 168 | if (Bank.contains("Vial of water")) { 169 | Logger.log("Vial of water"); 170 | Bank.withdrawAll("Vial of water"); 171 | returnThis = 600; 172 | } else { 173 | Logger.log("You don't have any vials of water!"); 174 | } 175 | } else if (Inventory.contains(sv.yourPot.getUnfName())) { 176 | if (!Inventory.contains(sv.yourPot.getIngredientTwo())) { 177 | Logger.log("Get ingredient two"); 178 | Bank.withdrawAll(sv.yourPot.getIngredientTwo()); 179 | returnThis = 600; 180 | } else { 181 | Logger.log("You don't have any of your second ingredient!"); 182 | } 183 | } else { 184 | Logger.log("Something went wrong"); 185 | } 186 | } 187 | } else { 188 | Logger.log("Opening bank!"); 189 | Bank.open(); 190 | if (Inventory.isItemSelected()) { 191 | Inventory.deselect(); 192 | } 193 | Logger.log("Waiting for bank to open"); 194 | Sleep.sleepUntil(Bank::isOpen, Calculations.random(1200, 1500)); 195 | 196 | returnThis = 200; 197 | } 198 | break; 199 | } 200 | return returnThis; 201 | } 202 | 203 | private boolean amIAnimating() { 204 | for (int i = 0; i < 50; i++) { 205 | if (Players.getLocal().getAnimation() != -1) 206 | return true; 207 | else 208 | Sleep.sleep(30); 209 | } 210 | return false; 211 | } 212 | 213 | @Override 214 | public String getState() { 215 | if (Inventory.contains("Vial of water") || Inventory.contains(sv.yourPot.getIngredientOne())) { 216 | if (Inventory.contains("Vial of water") && Inventory.contains(sv.yourPot.getIngredientOne())) 217 | return "Start Potion"; 218 | else { 219 | if (Inventory.contains("Vial of water") && Inventory.contains(sv.yourPot.getUnfName()) && Inventory.contains(sv.yourPot.getIngredientTwo())) 220 | return "Finish Potion"; 221 | return "Bank"; 222 | } 223 | } else if (Inventory.contains(sv.yourPot.getUnfName())) { 224 | if (Inventory.contains(sv.yourPot.getIngredientTwo())) { 225 | return "Finish Potion"; 226 | } else { 227 | return "Bank"; 228 | } 229 | } else 230 | return "Bank"; 231 | } 232 | 233 | 234 | } 235 | -------------------------------------------------------------------------------- /DreambotHerblore/src/nezz/dreambot/scriptmain/herblore/Pots.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.herblore; 2 | 3 | public enum Pots { 4 | //doesn't have Sanfew serum, Guthix balance potion, and Guthix rest tea 5 | AttackPotion("Attack potion", 3, 25, "Guam leaf", "Eye of newt"), 6 | Antipoison("Antipoison", 5, 37.5, "Marrentill", "Unicorn horn dust"), 7 | RelicymsBalm("Relicym's balm", 8, 40, "Rogue's purse", "Snake weed"), 8 | StrengthPotion("Strength potion", 12, 50, "Tarromin", "Limpwurt root"), 9 | Serum207("Serum 207", 15, 50, "Tarromin", "Ashes"), 10 | GuamTar("Guam tar", 19, 30, "Guam leaf", "Swamp tar"),//need 15 swamp tar how to do that? 11 | StatRestorePotion("Stat restore potion", 22, 62.5, "Harralander", "Red spiders' eggs"), 12 | BlamishOil("Blamish oil", 25, 80, "Harralander", "Blamish snail slime"), 13 | EnergyPotion("Energy potion", 26, 67.5, "Harralander", "Chocolate dust"), 14 | DefencePotion("Defence potion", 30, 75, "Ranarr weed", "White berries"), 15 | MarrentillTar("Marrentil tar", 31, 42.5, "Marrentill", "Swamp tar"), //need 15 swamp tar 16 | AgilityPotion("Agility potion", 34, 80, "Toadflax", "Toad's legs"), 17 | CombatPotion("Combat potion", 36, 84, "Harralander", "Goat horn dust"), 18 | PrayerPotion("Prayer potion", 38, 87.5, "Ranarr weed", "Snape grass"), 19 | TarrominTar("Tarromin tar", 39, 55, "Tarromin", "Swamp tar"),//15 swamp tar 20 | HarralanderTar("HarralanderTar", 44, 72.5, "Harralander", "Swamp tar"), //15 swamp tar 21 | SuperAttackPotion("Super attack", 45, 100, "Irit leaf", "Eye of newt"), 22 | SuperAntipoison("Superantipoison", 48, 106.3, "Irit leaf", "Unicorn horn dust"), 23 | FishingPotion("Fishing potion", 50, 112.5, "Avantoe", "Snape grass"), 24 | SuperEnergyPotion("Super energy", 52, 117.5, "Avantoe", "Mort myre fungus"), 25 | ShrinkingPotion("Shrinking potion", 52, 6, "Tarromin", "Shrunk Ogleroot"), 26 | HuntingPotion("Hunting potion", 53, 87.5, "Avantoe", "Ground kebbit teeth"), 27 | SuperStrengthPotion("Super strength", 55, 125, "Kwuarm", "Limpwurt root"), 28 | MagicEssencePotion("Magic essence potion", 57, 130, "Starflower", "Crushed gorak claw"), 29 | WeaponPoison("Weapon poison", 60, 137.5, "Kwuarm", "Dragon scale dust"), 30 | SuperRestorePotion("Super restore", 63, 142.5, "Snapdragon", "Red spiders' eggs"), 31 | SuperDefencePotion("Super defence", 66, 150, "Cadantine", "White berries"), 32 | ExtraStrongAntiPoisonPotion("Extra strong antipoison potion", 68, 155, "Toadflax", "Yew roots"), 33 | AntiFirePotion("Anti-fire potion", 69, 157.5, "Lantadyme", "Dragon scale dust"), 34 | RangingPotion("Ranging potion", 72, 162.5, "Dwarf weed", "Wine of Zamorak"), 35 | ExtraStrongWeaponPoison("Extra strong weapon poison", 73, 165, "Coconut milk", "Cactus spine"),//and Red spiders' eggs 36 | MagicPotion("Magic potion", 76, 172.5, "Lantadyme", "Potato cactus"), 37 | ZamorakPotion("Zamorak potion", 78, 175, "Torstol", "Jangerberries"), 38 | SuperStrongAntipoisonPotion("Super strong antipoison potion", 79, 177.5, "Coconut milk", "Magic roots"), //ingredient 1 also includes Irit leaf 39 | SaradominBrew("Saradomin brew", 81, 180, "Toadflax", "Crushed bird's nest"), 40 | SuperStrongWeaponPoison("Super strong weapon poison", 82, 190, "Coconut milk", "Nightshade"),//also includes Poison ivy berries in ingredient 2 41 | ExtendedAntifire("Extended antifire", 69, 110, "Antifire potion", "Lava scale shard"); 42 | 43 | public final String name; 44 | final int level; 45 | final double experience; 46 | final String ingredientOne; 47 | final String ingredientTwo; 48 | 49 | public String getName() { 50 | return this.name; 51 | } 52 | 53 | public int getLevel() { 54 | return this.level; 55 | } 56 | 57 | public double getExperience() { 58 | return this.experience; 59 | } 60 | 61 | public String getIngredientOne() { 62 | return this.ingredientOne; 63 | } 64 | 65 | public String getIngredientTwo() { 66 | return this.ingredientTwo; 67 | } 68 | 69 | Pots(String name, int level, double experience, String ingredientOne, String ingredientTwo) { 70 | this.name = name; 71 | this.level = level; 72 | this.experience = experience; 73 | this.ingredientOne = ingredientOne; 74 | this.ingredientTwo = ingredientTwo; 75 | } 76 | 77 | public static String returnIngredientOne(int index) { 78 | for (Pots p : Pots.values()) { 79 | if (p.ordinal() == index) { 80 | return p.getIngredientOne(); 81 | } 82 | } 83 | return null; 84 | } 85 | 86 | public static String returnIngredientTwo(int index) { 87 | for (Pots p : Pots.values()) { 88 | if (p.ordinal() == index) { 89 | return p.getIngredientTwo(); 90 | } 91 | } 92 | return null; 93 | } 94 | 95 | public static int returnLvlReq(int index) { 96 | for (Pots p : Pots.values()) { 97 | if (p.ordinal() == index) { 98 | return p.getLevel(); 99 | } 100 | } 101 | return 0; 102 | } 103 | 104 | public static double returnXPGained(int index) { 105 | for (Pots p : Pots.values()) { 106 | if (p.ordinal() == index) { 107 | return p.getExperience(); 108 | } 109 | } 110 | return 0; 111 | } 112 | 113 | public String getUnfName() { 114 | String first = getIngredientOne().split(" ")[0]; 115 | return first + " potion (unf)"; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /DreambotHerblore/src/nezz/dreambot/scriptmain/herblore/States.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.herblore; 2 | 3 | import java.awt.Graphics; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import nezz.dreambot.herblore.gui.ScriptVars; 8 | import nezz.dreambot.tools.PricedItem; 9 | 10 | import org.dreambot.api.methods.skills.Skill; 11 | import org.dreambot.api.methods.skills.SkillTracker; 12 | import org.dreambot.api.methods.skills.Skills; 13 | import org.dreambot.api.script.AbstractScript; 14 | 15 | public abstract class States { 16 | 17 | public AbstractScript as; 18 | public ScriptVars sv; 19 | public String[] states; 20 | public String state; 21 | public List lootList = new ArrayList<>(); 22 | 23 | public abstract String getMode(); 24 | 25 | public abstract int execute() throws InterruptedException; 26 | 27 | public void draw(Graphics g) { 28 | int baseY = 45; 29 | g.drawString("Mode: " + getMode(), 10, baseY); 30 | baseY += 15; 31 | g.drawString("Current state: " + getCurrentState(), 10, baseY); 32 | baseY += 15; 33 | g.drawString("Experience(p/h): " + SkillTracker.getGainedExperience(Skill.HERBLORE) + "(" + SkillTracker.getGainedExperiencePerHour(Skill.HERBLORE) + ")", 10, baseY); 34 | baseY += 15; 35 | g.drawString("Level(gained): " + Skills.getRealLevel(Skill.HERBLORE) + "(" + SkillTracker.getGainedLevels(Skill.HERBLORE) + ")", 10, baseY); 36 | baseY += 15; 37 | for (PricedItem pi : lootList) { 38 | if (pi != null && pi.getAmount() > 0) { 39 | g.drawString(pi.getName() + ": " + pi.getAmount(), 10, baseY); 40 | baseY += 15; 41 | } 42 | } 43 | } 44 | 45 | public String getCurrentState() { 46 | return this.state; 47 | } 48 | 49 | public abstract String getState(); 50 | 51 | public void updateLoot() { 52 | for (PricedItem pi : lootList) { 53 | if (pi != null) 54 | pi.update(); 55 | } 56 | } 57 | 58 | public List getLootList() { 59 | return this.lootList; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /DreambotHerblore/src/nezz/dreambot/scriptmain/herblore/UnfPotions.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.herblore; 2 | 3 | import nezz.dreambot.herblore.gui.ScriptVars; 4 | import nezz.dreambot.tools.PricedItem; 5 | import org.dreambot.api.methods.Calculations; 6 | import org.dreambot.api.methods.container.impl.Inventory; 7 | import org.dreambot.api.methods.container.impl.bank.Bank; 8 | import org.dreambot.api.methods.interactive.Players; 9 | import org.dreambot.api.methods.widget.Widget; 10 | import org.dreambot.api.methods.widget.Widgets; 11 | import org.dreambot.api.script.AbstractScript; 12 | import org.dreambot.api.utilities.Logger; 13 | import org.dreambot.api.utilities.Sleep; 14 | import org.dreambot.api.utilities.impl.Condition; 15 | import org.dreambot.api.wrappers.widgets.WidgetChild; 16 | 17 | 18 | public class UnfPotions extends States { 19 | 20 | public UnfPotions(AbstractScript as, ScriptVars sv) { 21 | this.as = as; 22 | this.sv = sv; 23 | lootList.add(new PricedItem(sv.yourPot.getName() + "(3)", false)); 24 | } 25 | 26 | @Override 27 | public String getMode() { 28 | return "Making Unfinished potions: " + sv.yourPot.getName(); 29 | } 30 | 31 | Condition makePot = () -> Widgets.getChildWidget(309, 2) != null; 32 | 33 | private boolean wasAnimating = false; 34 | 35 | @Override 36 | public int execute() { 37 | int returnThis = -1; 38 | this.state = getState(); 39 | switch (state) { 40 | case "Start Potion": 41 | if (Bank.isOpen()) { 42 | Bank.close(); 43 | returnThis = 600; 44 | wasAnimating = false; 45 | } else if (wasAnimating && amIAnimating()) { 46 | returnThis = 600; 47 | } else if (Widgets.getWidget(309) != null && Widgets.getWidget(309).getChild(2) != null) { 48 | Widget par = Widgets.getWidget(309); 49 | WidgetChild child = null; 50 | if (par != null) { 51 | child = par.getChild(2); 52 | } 53 | if (child != null) { 54 | if (child.interact("Make All")) { 55 | wasAnimating = true; 56 | Sleep.sleepUntil(() -> Players.getLocal().getAnimation() != -1, 1200); 57 | } else { 58 | wasAnimating = false; 59 | } 60 | returnThis = 400; 61 | } else { 62 | wasAnimating = false; 63 | Logger.log("Issues?"); 64 | returnThis = 1000; 65 | } 66 | } else { 67 | if (!Inventory.isItemSelected()) { 68 | Inventory.interact(sv.yourPot.getIngredientOne(), "Use"); 69 | returnThis = 400; 70 | wasAnimating = false; 71 | } else { 72 | Inventory.interact("Vial of water", "Use"); 73 | Sleep.sleepUntil(makePot, 2000); 74 | Widget par = Widgets.getWidget(309); 75 | WidgetChild child = null; 76 | if (par != null) { 77 | child = par.getChild(2); 78 | } 79 | if (child != null) { 80 | if (child.interact("Make All")) { 81 | wasAnimating = true; 82 | Sleep.sleepUntil(() -> Players.getLocal().getAnimation() != -1, 1200); 83 | } else { 84 | wasAnimating = false; 85 | } 86 | } else { 87 | wasAnimating = false; 88 | Logger.log("Issues?"); 89 | returnThis = 1000; 90 | } 91 | } 92 | } 93 | break; 94 | case "Bank": 95 | this.updateLoot(); 96 | wasAnimating = false; 97 | if (Bank.isOpen()) { 98 | if (Inventory.contains(sv.yourPot.getUnfName())) { 99 | Bank.depositAllItems(); 100 | Sleep.sleepUntil(Inventory::isEmpty, 1200); 101 | returnThis = 100; 102 | } else { 103 | if (Inventory.isEmpty()) { 104 | if (Bank.contains(sv.yourPot.getIngredientOne())) { 105 | Logger.log("withdrawing ingredient one"); 106 | Bank.withdraw(sv.yourPot.getIngredientOne(), 14); 107 | } else { 108 | Logger.log("You don't have the items!"); 109 | return -1; 110 | } 111 | returnThis = 600; 112 | } else if (Inventory.contains(sv.yourPot.getIngredientOne())) { 113 | if (Bank.contains("Vial of water")) { 114 | Logger.log("Vial of water"); 115 | Bank.withdrawAll("Vial of water"); 116 | returnThis = 600; 117 | } else { 118 | Logger.log("You don't have any vials of water!"); 119 | } 120 | } else { 121 | Logger.log("Something went wrong"); 122 | } 123 | } 124 | } else { 125 | Logger.log("Opening bank!"); 126 | if (Inventory.isItemSelected()) { 127 | Inventory.deselect(); 128 | } 129 | Bank.open(); 130 | Logger.log("Waiting for bank to open"); 131 | Sleep.sleepUntil(Bank::isOpen, Calculations.random(1200, 1500)); 132 | 133 | returnThis = 200; 134 | } 135 | break; 136 | } 137 | return returnThis; 138 | } 139 | 140 | private boolean amIAnimating() { 141 | for (int i = 0; i < 50; i++) { 142 | if (Players.getLocal().getAnimation() != -1) 143 | return true; 144 | else 145 | Sleep.sleep(30); 146 | } 147 | return false; 148 | } 149 | 150 | @Override 151 | public String getState() { 152 | if (Inventory.contains("Vial of water") || Inventory.contains(sv.yourPot.getIngredientOne())) { 153 | if (Inventory.contains("Vial of water") && Inventory.contains(sv.yourPot.getIngredientOne())) 154 | return "Start Potion"; 155 | else 156 | return "Bank"; 157 | } else 158 | return "Bank"; 159 | } 160 | 161 | 162 | } 163 | -------------------------------------------------------------------------------- /DreambotHerblore/src/nezz/dreambot/tools/PricedItem.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.tools; 2 | 3 | import org.dreambot.api.methods.container.impl.Inventory; 4 | import org.dreambot.api.methods.grandexchange.LivePrices; 5 | import org.dreambot.api.utilities.Logger; 6 | 7 | public class PricedItem { 8 | private String name; 9 | private int lastCount = 0; 10 | private int amount = 0; 11 | private int price = 0; 12 | private int id = 0; 13 | 14 | public PricedItem(String name, boolean getPrice) { 15 | this.name = name; 16 | if (Inventory.contains(name)) { 17 | lastCount = Inventory.count(name); 18 | } 19 | if (getPrice) { 20 | String tempName = name; 21 | if (name.contains("arrow")) 22 | tempName += "s"; 23 | Logger.log("Getting price"); 24 | price = LivePrices.get(tempName); 25 | Logger.log("Got price: " + price); 26 | } else 27 | price = 0; 28 | } 29 | 30 | public PricedItem(String name, int id, boolean getPrice) { 31 | this.name = name; 32 | this.setId(id); 33 | if (Inventory.contains(id)) 34 | lastCount = Inventory.count(id); 35 | if (getPrice) 36 | price = LivePrices.get(name); 37 | else 38 | price = 0; 39 | } 40 | 41 | public void update() { 42 | int increase = 0; 43 | if (id == 0) 44 | increase = Inventory.count(name) - lastCount; 45 | else 46 | increase = Inventory.count(id) - lastCount; 47 | if (increase < 0) 48 | increase = 0; 49 | amount += increase; 50 | if (id == 0) 51 | lastCount = Inventory.count(name); 52 | else 53 | lastCount = Inventory.count(id); 54 | } 55 | 56 | public void setName(String name) { 57 | this.name = name; 58 | } 59 | 60 | public void setAmount(int amt) { 61 | this.amount = amt; 62 | } 63 | 64 | public void setPrice(int price) { 65 | this.price = price; 66 | } 67 | 68 | public String getName() { 69 | return name; 70 | } 71 | 72 | public int getAmount() { 73 | return amount; 74 | } 75 | 76 | public int getPrice() { 77 | return price; 78 | } 79 | 80 | public int getValue() { 81 | if (amount <= 0) 82 | return 0; 83 | return amount * price; 84 | } 85 | 86 | public int getId() { 87 | return id; 88 | } 89 | 90 | public void setId(int id) { 91 | this.id = id; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /DreambotHillPrayer/src/nezz/dreambot/scriptmain/hillprayer/HillPrayer.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.hillprayer; 2 | 3 | import org.dreambot.api.Client; 4 | import org.dreambot.api.methods.Calculations; 5 | import org.dreambot.api.methods.container.impl.Inventory; 6 | import org.dreambot.api.methods.interactive.NPCs; 7 | import org.dreambot.api.methods.interactive.Players; 8 | import org.dreambot.api.methods.item.GroundItems; 9 | import org.dreambot.api.methods.skills.Skill; 10 | import org.dreambot.api.methods.skills.SkillTracker; 11 | import org.dreambot.api.methods.skills.Skills; 12 | import org.dreambot.api.methods.walking.impl.Walking; 13 | import org.dreambot.api.script.AbstractScript; 14 | import org.dreambot.api.script.Category; 15 | import org.dreambot.api.script.ScriptManifest; 16 | import org.dreambot.api.utilities.Sleep; 17 | import org.dreambot.api.utilities.Timer; 18 | import org.dreambot.api.wrappers.interactive.NPC; 19 | import org.dreambot.api.wrappers.items.GroundItem; 20 | 21 | import java.awt.*; 22 | 23 | @ScriptManifest(name = "Prayer on the Hill", author = "Nezz", description = "Kills hill giants and buries their bones", version = 1, category = Category.PRAYER) 24 | public class HillPrayer extends AbstractScript { 25 | 26 | private final Timer t = new Timer(); 27 | 28 | private enum State { 29 | KILL, LOOT, BURY, SLEEP 30 | } 31 | 32 | private State getState() { 33 | if (Players.getLocal().isInCombat()) { 34 | return State.SLEEP; 35 | } else { 36 | GroundItem gi = GroundItems.closest("Big bones", "Limpwurt root"); 37 | if (gi != null) { 38 | return State.LOOT; 39 | } else if (Inventory.contains("Big bones")) { 40 | return State.BURY; 41 | } else 42 | return State.KILL; 43 | } 44 | } 45 | 46 | private State state = null; 47 | 48 | @Override 49 | public void onStart() { 50 | SkillTracker.start(Skill.PRAYER); 51 | } 52 | 53 | @Override 54 | public int onLoop() { 55 | if (!Client.isLoggedIn()) { 56 | return 600; 57 | } 58 | state = getState(); 59 | switch (state) { 60 | case BURY: 61 | Inventory.interact("Big bones", "Bury"); 62 | sleep(600, 900); 63 | break; 64 | case KILL: 65 | if (Players.getLocal().isInCombat()) { 66 | return Calculations.random(300, 600); 67 | } 68 | NPC giant = NPCs.closest(n -> { 69 | if (n == null || n.getName() == null || !n.getName().equals("Hill Giant")) 70 | return false; 71 | return !n.isInCombat() || (n.getInteractingCharacter() != null && n.getInteractingCharacter().getName().equals(Players.getLocal().getName())); 72 | }); 73 | if (giant != null) { 74 | giant.interact("Attack"); 75 | Sleep.sleepUntil(() -> Players.getLocal().isInCombat(), 2000); 76 | } 77 | break; 78 | case LOOT: 79 | GroundItem gi = GroundItems.closest("Big bones", "Limpwurt root"); 80 | if (gi != null) { 81 | if (gi.isOnScreen()) { 82 | gi.interact("Take"); 83 | sleep(900, 1200); 84 | } else { 85 | Walking.walk(gi.getTile()); 86 | } 87 | } 88 | break; 89 | case SLEEP: 90 | sleep(300, 600); 91 | break; 92 | } 93 | return Calculations.random(300, 600); 94 | } 95 | 96 | public void onPaint(Graphics g) { 97 | g.setColor(Color.WHITE); 98 | g.setFont(new Font("Arial", Font.BOLD, 11)); 99 | g.drawString("Time Running: " + t.formatTime(), 25, 50); 100 | g.drawString("Experience(p/h): " + SkillTracker.getGainedExperience(Skill.PRAYER) + "(" + SkillTracker.getGainedExperiencePerHour(Skill.PRAYER) + ")", 25, 65); 101 | g.drawString("Level(gained): " + Skills.getRealLevel(Skill.PRAYER) + "(" + SkillTracker.getGainedLevels(Skill.PRAYER) + ")", 25, 80); 102 | if (state != null) 103 | g.drawString("State: " + state, 25, 95); 104 | } 105 | 106 | @Override 107 | public void onExit() { 108 | 109 | } 110 | } -------------------------------------------------------------------------------- /DreambotHunter/src/nezz/dreambot/scriptmain/hunter/Hunt.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.hunter; 2 | 3 | 4 | public enum Hunt { 5 | CrimsonSwift("Crimson Swift", "Bird snare", "Bird snare", 9345, 9373, 9344, "Lay", "Check", "Dismantle", "Red feather", "Bones", "Raw bird meat"), 6 | CopperLongtail("Copper Longtail", "Bird snare", "Bird snare", 9345, 9379, 9344, "Lay", "Check", "Dismantle", "Orange feather", "Bones", "Raw bird meat"), 7 | TropicalWagtail("Tropical Wagtail", "Bird snare", "Bird snare", 9345, 9348, 9344, "Lay", "Check", "Dismantle", "Stripy feather", "Bones", "Raw bird meat"), 8 | GreyChin("Grey Chin", "Box trap", "Shaking box", 9380, 9382, 9385, "Lay", "Check", "Dismantle", "Chinchompa"), 9 | RedChin("Red Chin", "Box trap", "Shaking box", 9380, 9383, 9385, "Lay", "Check", "Dismantle", "Red chinchompa"); 10 | 11 | private final String name; 12 | private final String trapName; 13 | private final String emptyTrapName; 14 | private final String layAction; 15 | private final String emptyAction; 16 | private final String dismantleAction; 17 | private final String trackItem; 18 | private final int emptyTrapID; 19 | private final int fullTrapID; 20 | private final int brokenTrapID; 21 | private final String[] dropItems; 22 | 23 | Hunt(String name, String trapName, String emptyTrapName, int emptyTrapID, int fullTrapID, int brokenTrapID, String layAction, String emptyAction, String dismantleAction, String trackItem, String... dropItems) { 24 | this.name = name; 25 | this.trapName = trapName; 26 | this.emptyTrapName = emptyTrapName; 27 | this.emptyTrapID = emptyTrapID; 28 | this.fullTrapID = fullTrapID; 29 | this.brokenTrapID = brokenTrapID; 30 | this.layAction = layAction; 31 | this.emptyAction = emptyAction; 32 | this.dismantleAction = dismantleAction; 33 | this.trackItem = trackItem; 34 | this.dropItems = dropItems; 35 | } 36 | 37 | public String getName() { 38 | return this.name; 39 | } 40 | 41 | public String getTrapName() { 42 | return this.trapName; 43 | } 44 | 45 | public String getEmptyTrapName() { 46 | return this.emptyTrapName; 47 | } 48 | 49 | public String getLayAction() { 50 | return this.layAction; 51 | } 52 | 53 | public String getEmptyAction() { 54 | return this.emptyAction; 55 | } 56 | 57 | public String getTrackItem() { 58 | return this.trackItem; 59 | } 60 | 61 | public String getDismantleAction() { 62 | return this.dismantleAction; 63 | } 64 | 65 | public int getEmptyTrapID() { 66 | return this.emptyTrapID; 67 | } 68 | 69 | public int getFullTrapID() { 70 | return this.fullTrapID; 71 | } 72 | 73 | public int getBrokenTrapID() { 74 | return this.brokenTrapID; 75 | } 76 | 77 | public String[] getDropItems() { 78 | return this.dropItems; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /DreambotHunter/src/nezz/dreambot/scriptmain/hunter/Hunter.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.hunter; 2 | 3 | import nezz.dreambot.scriptmain.hunter.gui.ScriptVars; 4 | import nezz.dreambot.scriptmain.hunter.gui.hunterGui; 5 | import nezz.dreambot.tools.PricedItem; 6 | import org.dreambot.api.Client; 7 | import org.dreambot.api.methods.Calculations; 8 | import org.dreambot.api.methods.container.impl.Inventory; 9 | import org.dreambot.api.methods.interactive.GameObjects; 10 | import org.dreambot.api.methods.interactive.Players; 11 | import org.dreambot.api.methods.item.GroundItems; 12 | import org.dreambot.api.methods.map.Map; 13 | import org.dreambot.api.methods.map.Tile; 14 | import org.dreambot.api.methods.skills.Skill; 15 | import org.dreambot.api.methods.skills.SkillTracker; 16 | import org.dreambot.api.methods.skills.Skills; 17 | import org.dreambot.api.script.AbstractScript; 18 | import org.dreambot.api.script.Category; 19 | import org.dreambot.api.script.ScriptManifest; 20 | import org.dreambot.api.utilities.Sleep; 21 | import org.dreambot.api.utilities.Timer; 22 | import org.dreambot.api.wrappers.interactive.GameObject; 23 | import org.dreambot.api.wrappers.items.GroundItem; 24 | import org.dreambot.api.wrappers.items.Item; 25 | 26 | import java.awt.*; 27 | import java.util.List; 28 | 29 | @ScriptManifest(author = "Nezz", description = "Catches stuff", name = "DreamBot Hunter", version = 0, category = Category.HUNTING) 30 | public class Hunter extends AbstractScript { 31 | 32 | PricedItem track; 33 | ScriptVars sv = new ScriptVars(); 34 | 35 | public void onStart() { 36 | hunterGui gui = new hunterGui(sv); 37 | gui.setVisible(true); 38 | while (!sv.started) { 39 | sleep(200); 40 | } 41 | track = new PricedItem(sv.huntThis.getTrackItem(), false); 42 | Tile startTile = Players.getLocal().getTile(); 43 | sv.trapTiles = new Tile[getTrapAmount()]; 44 | getTileArray(getTrapAmount()); 45 | SkillTracker.start(Skill.HUNTER); 46 | startingLevel = Skills.getRealLevel(Skill.HUNTER); 47 | rt = new Timer(); 48 | log("Starting script!"); 49 | } 50 | 51 | private int getTrapAmount() { 52 | int amount = 0; 53 | int level = Skills.getRealLevel(Skill.HUNTER); 54 | if (level < 20) 55 | amount = 1; 56 | else if (level < 40) 57 | amount = 2; 58 | else if (level < 60) 59 | amount = 3; 60 | else if (level < 80) 61 | amount = 4; 62 | else { 63 | amount = 5; 64 | } 65 | if (Inventory.count(sv.huntThis.getTrapName()) < amount) { 66 | amount = Inventory.count(sv.huntThis.getTrapName()); 67 | } 68 | return amount; 69 | } 70 | 71 | private void getTileArray(int traps) { 72 | Tile p = Players.getLocal().getTile(); 73 | switch (traps) { 74 | case 1: 75 | sv.trapTiles[0] = Players.getLocal().getTile(); 76 | break; 77 | case 2: 78 | for (int i = 0; i < sv.trapTiles.length; i++) { 79 | sv.trapTiles[i] = new Tile(Players.getLocal().getTile().getX() - i, Players.getLocal().getTile().getY(), Players.getLocal().getTile().getZ()); 80 | } 81 | break; 82 | case 3: 83 | for (int i = 0; i < sv.trapTiles.length; i++) { 84 | sv.trapTiles[i] = new Tile(Players.getLocal().getTile().getX() - i, Players.getLocal().getTile().getY(), Players.getLocal().getTile().getZ()); 85 | } 86 | break; 87 | case 4: 88 | sv.trapTiles[0] = p; 89 | sv.trapTiles[1] = new Tile(p.getX() - 1, p.getY() + 1, p.getZ()); 90 | sv.trapTiles[2] = new Tile(p.getX() + 1, p.getY() + 1, p.getZ()); 91 | sv.trapTiles[3] = new Tile(p.getX() - 1, p.getY() - 1, p.getZ()); 92 | break; 93 | case 5: 94 | sv.trapTiles[0] = p; 95 | sv.trapTiles[1] = new Tile(p.getX() - 1, p.getY() + 1, p.getZ()); 96 | sv.trapTiles[2] = new Tile(p.getX() + 1, p.getY() + 1, p.getZ()); 97 | sv.trapTiles[3] = new Tile(p.getX() - 1, p.getY() - 1, p.getZ()); 98 | sv.trapTiles[4] = new Tile(p.getX() + 1, p.getY() - 1, p.getZ()); 99 | break; 100 | } 101 | } 102 | 103 | private Timer rt; 104 | 105 | private int startingLevel = 0; 106 | 107 | private State state; 108 | 109 | private enum State { 110 | LAY_TRAP, PICK_TRAP, EMPTY_TRAP, SLEEP, DROP 111 | } 112 | 113 | private boolean trapDown() { 114 | for (Tile t : sv.trapTiles) { 115 | List tileItems = GroundItems.getForTile(t); 116 | if (tileItems == null || tileItems.size() <= 0) { 117 | continue; 118 | } 119 | for (GroundItem gi : tileItems) { 120 | if (gi != null && gi.getName() != null) { 121 | return gi.getName().equals(sv.huntThis.getTrapName()); 122 | } 123 | } 124 | } 125 | return false; 126 | } 127 | 128 | private boolean trapOnTile(Tile t) { 129 | List tileItems = GroundItems.getForTile(t); 130 | if (tileItems == null || tileItems.size() <= 0) { 131 | return false; 132 | } 133 | for (GroundItem gi : tileItems) { 134 | if (gi != null && gi.getName() != null) { 135 | return gi.getName().equals(sv.huntThis.getTrapName()); 136 | } 137 | } 138 | return false; 139 | } 140 | 141 | private State getState() { 142 | if (trapDown()) { 143 | return State.PICK_TRAP; 144 | } 145 | if (sv.huntThis.getDropItems().length > 0 && Inventory.contains(sv.huntThis.getDropItems()) && !(trapFull() || trapBroken() || !allTrapsLaid())) 146 | return State.DROP; 147 | if (trapFull() || trapBroken()) 148 | return State.EMPTY_TRAP; 149 | if (!allTrapsLaid()) 150 | return State.LAY_TRAP; 151 | return State.SLEEP; 152 | } 153 | 154 | @Override 155 | public int onLoop() { 156 | if (Skills.getRealLevel(Skill.HUNTER) >= sv.stopAt) { 157 | stop(); 158 | return -1; 159 | } else if (getTrapAmount() > sv.trapTiles.length) { 160 | sv.trapTiles = new Tile[getTrapAmount()]; 161 | getTileArray(getTrapAmount()); 162 | } 163 | state = getState(); 164 | switch (state) { 165 | case DROP: 166 | if (standingOnTrap()) { 167 | final Tile t = new Tile(Players.getLocal().getX(), Players.getLocal().getY() - 1, Players.getLocal().getZ()); 168 | Map.interact(t, "Walk here"); 169 | Sleep.sleepUntil(() -> Players.getLocal().getTile().equals(t) && !Players.getLocal().isMoving(), 5000); 170 | } else { 171 | for (int i = 0; i < sv.huntThis.getDropItems().length; i++) { 172 | if (Inventory.contains(sv.huntThis.getDropItems()[i])) { 173 | Inventory.interact(sv.huntThis.getDropItems()[i], "Drop"); 174 | sleep(Calculations.random(400, 700)); 175 | } 176 | } 177 | } 178 | break; 179 | case EMPTY_TRAP: 180 | if (trapFull()) { 181 | GameObject fullTrap = getFullTrap(); 182 | if (fullTrap != null) { 183 | fullTrap.interact(sv.huntThis.getEmptyAction()); 184 | long t = System.currentTimeMillis(); 185 | while (System.currentTimeMillis() - t < 3000 && posContainsFullTrap(fullTrap.getTile())) { 186 | sleep(30); 187 | } 188 | } 189 | } 190 | if (trapBroken()) { 191 | GameObject brokenTrap = getBrokenTrap(); 192 | if (brokenTrap != null) { 193 | brokenTrap.interact(sv.huntThis.getDismantleAction()); 194 | long t = System.currentTimeMillis(); 195 | while (System.currentTimeMillis() - t < 3000 && posContainsBrokenTrap(brokenTrap.getTile())) { 196 | sleep(30); 197 | } 198 | } 199 | } 200 | break; 201 | case LAY_TRAP: 202 | final Tile nextPos = getNextTrapPos(); 203 | if (nextPos != null) { 204 | if (!Players.getLocal().getTile().equals(nextPos)) { 205 | Tile t = Client.getDestination(); 206 | if (t != null && t.equals(nextPos)) { 207 | Sleep.sleepUntil(() -> Players.getLocal().getTile().equals(nextPos), 1200); 208 | } else { 209 | Map.interact(nextPos, "Walk here"); 210 | Sleep.sleepUntil(() -> Players.getLocal().getTile().equals(nextPos), 1200); 211 | } 212 | } else { 213 | Item trap = Inventory.get(sv.huntThis.getTrapName()); 214 | if (trap != null) { 215 | if (Players.getLocal().getTile().equals(nextPos)) { 216 | Inventory.interact(trap.getName(), sv.huntThis.getLayAction()); 217 | long t = System.currentTimeMillis(); 218 | while (System.currentTimeMillis() - t < 6000 && (!posContainsTrap(nextPos) || Players.getLocal().getAnimation() != -1)) { 219 | sleep(30); 220 | } 221 | } 222 | } 223 | sleep(Calculations.random(1100, 1400)); 224 | } 225 | } 226 | break; 227 | case PICK_TRAP: 228 | final GroundItem yourTrap = GroundItems.closest(sv.huntThis.getTrapName()); 229 | if (yourTrap != null) { 230 | yourTrap.interact("Take"); 231 | Sleep.sleepUntil(() -> !trapOnTile(yourTrap.getTile()), 1200); 232 | } 233 | break; 234 | case SLEEP: 235 | sleep(Calculations.random(100, 200)); 236 | if (standingOnTrap()) { 237 | final Tile t = new Tile(Players.getLocal().getX(), Players.getLocal().getY() - 1, Players.getLocal().getZ()); 238 | Map.interact(t, "Walk here"); 239 | Sleep.sleepUntil(() -> Players.getLocal().getTile().equals(t), 1200); 240 | sleep(Calculations.random(300, 800)); 241 | } 242 | break; 243 | } 244 | return Calculations.random(150, 250); 245 | } 246 | 247 | private boolean standingOnTrap() { 248 | for (int i = 0; i < sv.trapTiles.length; i++) { 249 | if (Players.getLocal().getTile().equals(sv.trapTiles[i])) 250 | return true; 251 | } 252 | return false; 253 | } 254 | 255 | private GameObject getBrokenTrap() { 256 | for (int i = 0; i < sv.trapTiles.length; i++) { 257 | final Tile yourPos = sv.trapTiles[i]; 258 | if (posContainsBrokenTrap(yourPos)) { 259 | return GameObjects.closest(r -> { 260 | if (r == null || r.getID() != sv.huntThis.getBrokenTrapID()) 261 | return false; 262 | return r.getTile().equals(yourPos); 263 | }); 264 | } 265 | 266 | } 267 | return null; 268 | } 269 | 270 | private GameObject getFullTrap() { 271 | for (int i = 0; i < sv.trapTiles.length; i++) { 272 | final Tile yourPos = sv.trapTiles[i]; 273 | if (posContainsFullTrap(yourPos)) { 274 | return GameObjects.closest(r -> { 275 | if (r == null || r.getID() != sv.huntThis.getFullTrapID()) 276 | return false; 277 | return r.getTile().equals(yourPos); 278 | }); 279 | } 280 | 281 | } 282 | return null; 283 | } 284 | 285 | private boolean trapBroken() { 286 | for (int i = 0; i < sv.trapTiles.length; i++) { 287 | final Tile yourPos = sv.trapTiles[i]; 288 | if (posContainsBrokenTrap(yourPos)) 289 | return true; 290 | } 291 | return false; 292 | } 293 | 294 | private boolean posContainsBrokenTrap(final Tile p) { 295 | GameObject currTrap = GameObjects.closest(r -> { 296 | if (r.getName() == null || r.getID() != sv.huntThis.getBrokenTrapID()) 297 | return false; 298 | return r.getTile().equals(p); 299 | }); 300 | return currTrap != null; 301 | } 302 | 303 | private boolean trapFull() { 304 | for (int i = 0; i < sv.trapTiles.length; i++) { 305 | final Tile yourPos = sv.trapTiles[i]; 306 | if (posContainsFullTrap(yourPos)) 307 | return true; 308 | } 309 | return false; 310 | } 311 | 312 | private boolean posContainsFullTrap(final Tile p) { 313 | GameObject currTrap = GameObjects.closest(r -> { 314 | if (r.getName() == null || r.getID() != sv.huntThis.getFullTrapID()) 315 | return false; 316 | return r.getTile().equals(p); 317 | }); 318 | return currTrap != null; 319 | } 320 | 321 | private boolean allTrapsLaid() { 322 | return getNextTrapPos() == null; 323 | } 324 | 325 | private Tile getNextTrapPos() { 326 | for (int i = 0; i < sv.trapTiles.length; i++) { 327 | final Tile yourPos = sv.trapTiles[i]; 328 | if (!posContainsTrap(yourPos)) 329 | return sv.trapTiles[i]; 330 | } 331 | return null; 332 | } 333 | 334 | private boolean posContainsTrap(final Tile p) { 335 | GameObject currTrap = GameObjects.closest(r -> { 336 | if (r.getName() == null || !r.getName().equals(sv.huntThis.getTrapName())) 337 | return false; 338 | return r.getTile().equals(p); 339 | }); 340 | return currTrap != null; 341 | } 342 | 343 | 344 | public void onExit() { 345 | log("Exiting script!"); 346 | } 347 | 348 | @Override 349 | public void onPaint(Graphics2D g) { 350 | if (sv.started) { 351 | track.update(); 352 | if (state != null) 353 | g.drawString("State: " + state, 5, 50); 354 | g.drawString("Exp gained(p/h): " + SkillTracker.getGainedExperience(Skill.HUNTER) + "(" + SkillTracker.getGainedExperiencePerHour(Skill.HUNTER) + ")", 5, 65); 355 | g.drawString("Level: " + Skills.getRealLevel(Skill.HUNTER) + "(" + (Skills.getRealLevel(Skill.HUNTER) - startingLevel) + ")", 5, 80); 356 | g.drawString("Runtime: " + rt.formatTime(), 5, 95); 357 | g.drawString("Currently hunting: " + sv.huntThis.getName(), 5, 110); 358 | g.drawString(track.getName() + "(p/h): " + track.getAmount() + "(" + rt.getHourlyRate(track.getAmount()) + ")", 5, 125); 359 | } 360 | } 361 | 362 | } 363 | -------------------------------------------------------------------------------- /DreambotHunter/src/nezz/dreambot/scriptmain/hunter/gui/ScriptVars.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.hunter.gui; 2 | 3 | import org.dreambot.api.methods.map.Tile; 4 | 5 | import nezz.dreambot.scriptmain.hunter.Hunt; 6 | 7 | 8 | public class ScriptVars { 9 | public Hunt huntThis; 10 | public Tile[] trapTiles; 11 | public int stopAt = 0; 12 | public boolean started = false; 13 | } 14 | -------------------------------------------------------------------------------- /DreambotHunter/src/nezz/dreambot/scriptmain/hunter/gui/hunterGui.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.hunter.gui; 2 | 3 | import javax.swing.JFrame; 4 | import javax.swing.JPanel; 5 | import javax.swing.border.EmptyBorder; 6 | 7 | import java.awt.Toolkit; 8 | 9 | import javax.swing.JLabel; 10 | import javax.swing.JComboBox; 11 | import javax.swing.DefaultComboBoxModel; 12 | import javax.swing.JTextField; 13 | import javax.swing.JButton; 14 | 15 | import java.awt.event.ActionListener; 16 | import java.awt.event.ActionEvent; 17 | import java.awt.Color; 18 | 19 | import nezz.dreambot.scriptmain.hunter.Hunt; 20 | 21 | 22 | public class hunterGui extends JFrame { 23 | 24 | /** 25 | * 26 | */ 27 | private static final long serialVersionUID = 1L; 28 | private JPanel contentPane; 29 | JComboBox comboBox = new JComboBox(); 30 | private JTextField stopAtField; 31 | 32 | 33 | public hunterGui(final ScriptVars var) { 34 | setTitle("DreamBot Hunter"); 35 | setIconImage(Toolkit.getDefaultToolkit().getImage(hunterGui.class.getResource("/javax/swing/plaf/metal/icons/ocean/computer.gif"))); 36 | setAlwaysOnTop(true); 37 | setResizable(false); 38 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 39 | setBounds(100, 100, 276, 193); 40 | contentPane = new JPanel(); 41 | contentPane.setBackground(Color.WHITE); 42 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 43 | setContentPane(contentPane); 44 | contentPane.setLayout(null); 45 | 46 | JPanel panel = new JPanel(); 47 | panel.setBounds(0, 0, 270, 131); 48 | contentPane.add(panel); 49 | panel.setLayout(null); 50 | 51 | comboBox.setModel(new DefaultComboBoxModel(Hunt.values())); 52 | comboBox.setBounds(10, 11, 128, 20); 53 | panel.add(comboBox); 54 | 55 | JLabel lblStopAt = new JLabel("Stop at:"); 56 | lblStopAt.setBounds(10, 42, 54, 14); 57 | panel.add(lblStopAt); 58 | 59 | stopAtField = new JTextField(); 60 | stopAtField.setText("19"); 61 | stopAtField.setBounds(74, 42, 40, 20); 62 | panel.add(stopAtField); 63 | stopAtField.setColumns(10); 64 | 65 | JButton btnNewButton = new JButton("Start!"); 66 | btnNewButton.addActionListener(new ActionListener() { 67 | public void actionPerformed(ActionEvent arg0) { 68 | var.huntThis = Hunt.values()[comboBox.getSelectedIndex()]; 69 | var.stopAt = Integer.parseInt(stopAtField.getText()); 70 | var.started = true; 71 | dispose(); 72 | } 73 | }); 74 | btnNewButton.setBounds(0, 130, 270, 34); 75 | contentPane.add(btnNewButton); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /DreambotHunter/src/nezz/dreambot/tools/PricedItem.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.tools; 2 | 3 | import org.dreambot.api.methods.container.impl.Inventory; 4 | import org.dreambot.api.methods.grandexchange.LivePrices; 5 | import org.dreambot.api.utilities.Logger; 6 | 7 | public class PricedItem { 8 | private String name; 9 | private int lastCount = 0; 10 | private int amount = 0; 11 | private int price = 0; 12 | private int id = 0; 13 | 14 | public PricedItem(String name, boolean getPrice) { 15 | this.name = name; 16 | if (Inventory.contains(name)) { 17 | lastCount = Inventory.count(name); 18 | } 19 | if (getPrice) { 20 | String tempName = name; 21 | if (name.contains("arrow")) 22 | tempName += "s"; 23 | Logger.log("Getting price"); 24 | price = LivePrices.get(tempName); 25 | Logger.log("Got price: " + price); 26 | } else 27 | price = 0; 28 | } 29 | 30 | public void update() { 31 | int increase = 0; 32 | if (id == 0) 33 | increase = Inventory.count(name) - lastCount; 34 | else 35 | increase = Inventory.count(id) - lastCount; 36 | if (increase < 0) 37 | increase = 0; 38 | amount += increase; 39 | if (id == 0) 40 | lastCount = Inventory.count(name); 41 | else 42 | lastCount = Inventory.count(id); 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public void setAmount(int amt) { 50 | this.amount = amt; 51 | } 52 | 53 | public void setPrice(int price) { 54 | this.price = price; 55 | } 56 | 57 | public String getName() { 58 | return name; 59 | } 60 | 61 | public int getAmount() { 62 | return amount; 63 | } 64 | 65 | public int getPrice() { 66 | return price; 67 | } 68 | 69 | public int getValue() { 70 | if (amount <= 0) 71 | return 0; 72 | return amount * price; 73 | } 74 | 75 | public int getId() { 76 | return id; 77 | } 78 | 79 | public void setId(int id) { 80 | this.id = id; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /DreambotIronKnifer/src/nezz/dreambot/scriptmain/ironknifer/AnvilSmith.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.ironknifer; 2 | 3 | import org.dreambot.api.methods.Calculations; 4 | import org.dreambot.api.methods.input.Keyboard; 5 | import org.dreambot.api.methods.interactive.GameObjects; 6 | import org.dreambot.api.methods.widget.Widgets; 7 | import org.dreambot.api.utilities.Sleep; 8 | import org.dreambot.api.wrappers.interactive.GameObject; 9 | import org.dreambot.api.wrappers.widgets.WidgetChild; 10 | 11 | public class AnvilSmith { 12 | private final int SMITH_PARENT = 312; 13 | private final int IRON_KNIFE = 24; 14 | private final int CLOSE_BUTTON_PARENT = 1; 15 | private final int CLOSE_BUTTON_CHILD = 11; 16 | //548,119 17 | private final int ENTER_AMT_PARENT = 548; 18 | private final int ENTER_AMT_CHILD = 119; 19 | 20 | private long closeUpdate = 0; 21 | private long knifeUpdate = 0; 22 | private long anvilUpdate = 0; 23 | private long entAmtUpdate = 0; 24 | private WidgetChild closeButton = null; 25 | private WidgetChild ironKnife = null; 26 | private WidgetChild enterAmt = null; 27 | private GameObject anvil = null; 28 | 29 | public WidgetChild getCloseButton() { 30 | if (closeButton == null || System.currentTimeMillis() - closeUpdate > 5000) { 31 | WidgetChild temp = Widgets.getChildWidget(SMITH_PARENT, CLOSE_BUTTON_PARENT); 32 | if (temp != null) { 33 | closeButton = temp.getChild(CLOSE_BUTTON_CHILD); 34 | closeUpdate = System.currentTimeMillis(); 35 | } 36 | } 37 | return closeButton; 38 | } 39 | 40 | public WidgetChild getKnifeWidget() { 41 | if (ironKnife == null || System.currentTimeMillis() - knifeUpdate > 5000) { 42 | ironKnife = Widgets.getChildWidget(SMITH_PARENT, IRON_KNIFE); 43 | knifeUpdate = System.currentTimeMillis(); 44 | } 45 | return ironKnife; 46 | } 47 | 48 | public WidgetChild getEnterAmount() { 49 | if (enterAmt == null || System.currentTimeMillis() - entAmtUpdate > 5000) { 50 | enterAmt = Widgets.getChildWidget(ENTER_AMT_PARENT, ENTER_AMT_CHILD); 51 | entAmtUpdate = System.currentTimeMillis(); 52 | } 53 | return enterAmt; 54 | } 55 | 56 | public boolean needToType() { 57 | return getEnterAmount() != null && getEnterAmount().isVisible() && getEnterAmount().getText().contains("Enter amount"); 58 | } 59 | 60 | public boolean isOpen() { 61 | return getCloseButton() != null && getCloseButton().isVisible(); 62 | } 63 | 64 | public boolean makeKnife() { 65 | if (needToType()) { 66 | int amt = Calculations.random(3, 9); 67 | String type = "" + amt + "" + amt; 68 | Keyboard.type(type, true); 69 | return true; 70 | } else if (!isOpen()) 71 | return false; 72 | else if (getKnifeWidget() != null) { 73 | getKnifeWidget().interact("Smith X sets"); 74 | Sleep.sleepUntil(this::needToType, 2400); 75 | } 76 | return false; 77 | } 78 | 79 | public GameObject getAnvil() { 80 | if (anvil == null || System.currentTimeMillis() - anvilUpdate > 5000) { 81 | anvil = GameObjects.closest("Anvil"); 82 | if (anvil != null) 83 | anvilUpdate = System.currentTimeMillis(); 84 | } 85 | return anvil; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /DreambotIronKnifer/src/nezz/dreambot/scriptmain/ironknifer/IronKnifer.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.ironknifer; 2 | 3 | import nezz.dreambot.tools.PricedItem; 4 | import org.dreambot.api.input.Mouse; 5 | import org.dreambot.api.methods.Calculations; 6 | import org.dreambot.api.methods.container.impl.Inventory; 7 | import org.dreambot.api.methods.container.impl.bank.Bank; 8 | import org.dreambot.api.methods.input.Camera; 9 | import org.dreambot.api.methods.interactive.GameObjects; 10 | import org.dreambot.api.methods.interactive.Players; 11 | import org.dreambot.api.methods.map.Map; 12 | import org.dreambot.api.methods.map.Tile; 13 | import org.dreambot.api.methods.walking.impl.Walking; 14 | import org.dreambot.api.script.AbstractScript; 15 | import org.dreambot.api.script.Category; 16 | import org.dreambot.api.script.ScriptManifest; 17 | import org.dreambot.api.utilities.Sleep; 18 | import org.dreambot.api.utilities.Timer; 19 | import org.dreambot.api.wrappers.interactive.GameObject; 20 | 21 | import java.awt.*; 22 | 23 | @ScriptManifest(author = "Nezz", category = Category.SMITHING, description = "Makes iron knives in Varrock", name = "DreamBot Iron Knifer", version = 0) 24 | public class IronKnifer extends AbstractScript { 25 | PricedItem ironKnife = null; 26 | private State state = null; 27 | private Timer t = null; 28 | private final Tile BANK_TILE = new Tile(3185, 3436, 0); 29 | private final Tile ANVIL_TILE = new Tile(3188, 3425, 0); 30 | private AnvilSmith as = null; 31 | private GameObject bankBooth = null; 32 | private long boothUpdate = 0; 33 | private long lastAnimated = 0; 34 | private int runThresh = Calculations.random(30, 70); 35 | private boolean movedAnvil = false; 36 | private boolean movedBank = false; 37 | 38 | private enum State { 39 | BANK, SMITH 40 | } 41 | 42 | private State getState() { 43 | if (Inventory.contains("Iron bar")) { 44 | return State.SMITH; 45 | } 46 | return State.BANK; 47 | } 48 | 49 | public void onStart() { 50 | as = new AnvilSmith(); 51 | ironKnife = new PricedItem("Iron knife", false); 52 | t = new Timer(); 53 | } 54 | 55 | private Point getRandomPoint(Tile t) { 56 | Point point = null; 57 | Point p = Map.tileToMiniMap(t); 58 | if (p.x > 0) 59 | point = randomizePoint(p); 60 | return point; 61 | } 62 | 63 | private Point randomizePoint(Point p) { 64 | return new Point(p.x + Calculations.random(-5, 5), p.y + Calculations.random(-5, 5)); 65 | } 66 | 67 | private Rectangle getRect(Tile t) { 68 | Point p = Map.tileToMiniMap(t); 69 | return new Rectangle(p.x - 5, p.y - 5, 10, 10); 70 | } 71 | 72 | private boolean walk(Tile t) { 73 | Point p = getRandomPoint(t); 74 | if (p == null) 75 | return false; 76 | Mouse.move(p); 77 | sleep(60, 150); 78 | Mouse.click(); 79 | Sleep.sleepUntil(() -> Players.getLocal().isMoving(), 1200); 80 | return Players.getLocal().isMoving(); 81 | } 82 | 83 | private GameObject getBankBooth() { 84 | if (bankBooth == null || System.currentTimeMillis() - boothUpdate > 5000) { 85 | bankBooth = GameObjects.closest(go -> { 86 | if (go == null || !go.exists() || go.getName() == null) 87 | return false; 88 | if (!go.getName().equals("Bank booth")) 89 | return false; 90 | return go.getTile().equals(new Tile(3186, 3436, 0));// || go.getTile().equals(new Tile(3186,3438,0)); 91 | }); 92 | boothUpdate = System.currentTimeMillis(); 93 | } 94 | log("Booth tile: " + bankBooth.getTile()); 95 | return bankBooth; 96 | } 97 | 98 | private boolean waitForWalk() { 99 | if (!Players.getLocal().isMoving() || state == null) { 100 | return false; 101 | } 102 | Tile destination = Walking.getDestination(); 103 | if (destination != null && destination.distance(Players.getLocal()) < Calculations.random(3, 6)) { 104 | return false; 105 | } 106 | if (state.equals(State.BANK) && getBankBooth() != null && getBankBooth().isOnScreen()) { 107 | return false; 108 | } else return !state.equals(State.SMITH) || as.getAnvil() == null || !as.getAnvil().isOnScreen(); 109 | } 110 | 111 | private String getCameraDirection() { 112 | int yaw = Camera.getYaw(); 113 | if (yaw > 1800 || yaw < 300) 114 | return "N"; 115 | else if (yaw < 800) { 116 | return "W"; 117 | } else if (yaw < 1300) { 118 | return "S"; 119 | } else 120 | return "E"; 121 | } 122 | 123 | private Rectangle getHoverSpot() { 124 | Rectangle r = null; 125 | if (state.equals(State.BANK)) { 126 | switch (getCameraDirection()) { 127 | case "S": 128 | r = new Rectangle(0, 0, 165, 340); 129 | break; 130 | case "N": 131 | r = new Rectangle(330, 0, 185, 340); 132 | break; 133 | case "W": 134 | r = new Rectangle(0, 200, 515, 115); 135 | break; 136 | case "E": 137 | r = new Rectangle(0, 0, 515, 125); 138 | break; 139 | } 140 | } else { 141 | Rectangle temp = Players.getLocal().getBoundingBox(); 142 | r = new Rectangle(temp.x - 50, temp.y - 50, temp.height + 100, temp.width + 100); 143 | } 144 | return r; 145 | } 146 | 147 | 148 | @Override 149 | public int onLoop() { 150 | if (!Walking.isRunEnabled() && Walking.getRunEnergy() > runThresh) { 151 | Walking.toggleRun(); 152 | runThresh = Calculations.random(30, 70); 153 | } 154 | if (waitForWalk()) 155 | return Calculations.random(300, 600); 156 | state = getState(); 157 | switch (state) { 158 | case BANK: 159 | movedAnvil = false; 160 | if (!Bank.isOpen()) { 161 | if (BANK_TILE.distance(Players.getLocal()) > 5 && !Players.getLocal().isMoving()) { 162 | walk(BANK_TILE); 163 | } else if (!Players.getLocal().isMoving()) { 164 | Bank.open(); 165 | Sleep.sleepUntil(Bank::isOpen, 3600); 166 | } else if (!movedBank) { 167 | Mouse.move(getHoverSpot()); 168 | movedBank = true; 169 | } 170 | } else { 171 | if (Inventory.contains("Iron knife")) { 172 | ironKnife.update(); 173 | Bank.depositAllExcept("Hammer"); 174 | Sleep.sleepUntil(() -> !Inventory.contains("Iron knife"), 1200); 175 | } else if (Bank.contains("Iron bar")) { 176 | Bank.withdrawAll("Iron bar"); 177 | Sleep.sleepUntil(() -> Inventory.contains("Iron bar"), 1200); 178 | } else { 179 | log("Out of bars!"); 180 | stop(); 181 | } 182 | } 183 | break; 184 | case SMITH: 185 | movedBank = false; 186 | if (as.isOpen() || Inventory.isItemSelected() || !amIAnimating()) { 187 | if (as.isOpen()) { 188 | as.makeKnife(); 189 | Sleep.sleepUntil(() -> !as.isOpen(), 1200); 190 | } else { 191 | if (ANVIL_TILE.distance(Players.getLocal()) > 5 && !Players.getLocal().isMoving()) { 192 | walk(ANVIL_TILE); 193 | /*Walking.walk(ANVIL_TILE); 194 | Sleep.sleepUntil(new Condition(){ 195 | public boolean verify(){ 196 | return Players.getLocal().isMoving(); 197 | } 198 | },1200);*/ 199 | Tile dest = Walking.getDestination(); 200 | if (dest != null && dest.distance(ANVIL_TILE) < 4) { 201 | if (!Inventory.isItemSelected()) { 202 | sleep(400, 1400); 203 | Inventory.interact("Iron bar", "Use"); 204 | } 205 | } 206 | } else { 207 | if (Inventory.isItemSelected()) { 208 | if (!Players.getLocal().isMoving()) { 209 | if (as.getAnvil() != null) { 210 | as.getAnvil().interact("Use"); 211 | Sleep.sleepUntil(() -> as.isOpen(), 2400); 212 | } 213 | } else if (!movedAnvil) { 214 | Mouse.move(getHoverSpot()); 215 | movedAnvil = true; 216 | } 217 | } else { 218 | Inventory.interact("Iron bar", "Use"); 219 | Sleep.sleepUntil(Inventory::isItemSelected, 1200); 220 | } 221 | } 222 | } 223 | } else { 224 | ironKnife.update(); 225 | sleep(300, 500); 226 | } 227 | break; 228 | } 229 | return Calculations.random(100, 200); 230 | } 231 | 232 | public boolean amIAnimating() { 233 | if (System.currentTimeMillis() - lastAnimated > 5000) { 234 | if (Players.getLocal().getAnimation() != -1) { 235 | lastAnimated = System.currentTimeMillis(); 236 | return true; 237 | } 238 | return false; 239 | } 240 | for (int i = 0; i < 20; i++) { 241 | if (Players.getLocal().getAnimation() != -1) { 242 | lastAnimated = System.currentTimeMillis(); 243 | return true; 244 | } else { 245 | sleep(50); 246 | } 247 | } 248 | return false; 249 | } 250 | 251 | @Override 252 | public void onPaint(Graphics g) { 253 | if (t != null) { 254 | ((Graphics2D) g).draw(getRect(BANK_TILE)); 255 | ((Graphics2D) g).draw(getRect(ANVIL_TILE)); 256 | ((Graphics2D) g).draw(getHoverSpot()); 257 | g.drawString("Runtime: " + t.formatTime(), 10, 35); 258 | g.drawString("State: " + state.toString(), 10, 50); 259 | g.drawString("Knives(p/h): " + ironKnife.getAmount() + "(" + t.getHourlyRate(ironKnife.getAmount()) + ")", 10, 65); 260 | } 261 | } 262 | 263 | 264 | //312,24 265 | //312,1,11 266 | } 267 | -------------------------------------------------------------------------------- /DreambotIronKnifer/src/nezz/dreambot/tools/PricedItem.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.tools; 2 | 3 | import org.dreambot.api.methods.container.impl.Inventory; 4 | import org.dreambot.api.methods.grandexchange.LivePrices; 5 | import org.dreambot.api.utilities.Logger; 6 | 7 | public class PricedItem { 8 | private String name; 9 | private int lastCount = 0; 10 | private int amount = 0; 11 | private int price = 0; 12 | private int id = 0; 13 | 14 | public PricedItem(String name, boolean getPrice) { 15 | this.name = name; 16 | if (Inventory.contains(name)) { 17 | lastCount = Inventory.count(name); 18 | } 19 | if (getPrice) { 20 | String tempName = name; 21 | if (name.contains("arrow")) 22 | tempName += "s"; 23 | Logger.log("Getting price"); 24 | price = LivePrices.get(tempName); 25 | Logger.log("Got price: " + price); 26 | } else 27 | price = 0; 28 | } 29 | 30 | public void update() { 31 | int increase = 0; 32 | if (id == 0) 33 | increase = Inventory.count(name) - lastCount; 34 | else 35 | increase = Inventory.count(id) - lastCount; 36 | if (increase < 0) 37 | increase = 0; 38 | amount += increase; 39 | if (id == 0) 40 | lastCount = Inventory.count(name); 41 | else 42 | lastCount = Inventory.count(id); 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public void setAmount(int amt) { 50 | this.amount = amt; 51 | } 52 | 53 | public void setPrice(int price) { 54 | this.price = price; 55 | } 56 | 57 | public String getName() { 58 | return name; 59 | } 60 | 61 | public int getAmount() { 62 | return amount; 63 | } 64 | 65 | public int getPrice() { 66 | return price; 67 | } 68 | 69 | public int getValue() { 70 | if (amount <= 0) 71 | return 0; 72 | return amount * price; 73 | } 74 | 75 | public int getId() { 76 | return id; 77 | } 78 | 79 | public void setId(int id) { 80 | this.id = id; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /DreambotMiner/src/nezz/dreambot/filemethods/FileMethods.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.filemethods; 2 | 3 | import java.io.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | 8 | public class FileMethods { 9 | private BufferedReader in; 10 | private BufferedWriter out; 11 | private String filepath; 12 | private String scriptName; 13 | 14 | public FileMethods(String scriptName){ 15 | this(scriptName, false); 16 | } 17 | public FileMethods(String filePath, boolean force){ 18 | if(force){ 19 | this.filepath = filePath+System.getProperty("file.separator"); 20 | } 21 | else{ 22 | this.filepath = System.getProperty("scripts.path"); 23 | this.scriptName = filePath; 24 | this.filepath+=scriptName + System.getProperty("file.separator"); 25 | System.out.println("FILE PATH: " + filepath); 26 | } 27 | } 28 | 29 | public void writeFile(String[] toWrite, String filename){ 30 | filename+=".txt"; 31 | try { 32 | File theDir = new File(filepath); 33 | // if the directory does not exist, create it 34 | if (!theDir.exists()) { 35 | boolean result = theDir.mkdirs(); 36 | if(result) { 37 | System.out.println("DIR created"); 38 | } 39 | } 40 | out = new BufferedWriter(new FileWriter(filepath+filename)); 41 | //Write out the specified string to the file 42 | for(int i = 0; i < toWrite.length; i++){ 43 | if(i != toWrite.length - 1){ 44 | out.write(toWrite[i]); 45 | out.newLine(); 46 | } 47 | else{ 48 | out.write(toWrite[i]); 49 | } 50 | } 51 | //flushes and closes the stream 52 | out.close(); 53 | }catch(IOException e){ 54 | System.out.println("There was a problem:" + e); 55 | } 56 | 57 | } 58 | 59 | public void writeFile(List toWrite, String filename){ 60 | filename+=".txt"; 61 | try { 62 | File theDir = new File(filepath); 63 | // if the directory does not exist, create it 64 | if (!theDir.exists()) { 65 | boolean result = theDir.mkdirs(); 66 | if(result) { 67 | System.out.println("DIR created"); 68 | } 69 | } 70 | out = new BufferedWriter(new FileWriter(filepath+filename)); 71 | //Write out the specified string to the file 72 | for(int i = 0; i < toWrite.size(); i++){ 73 | if(i != toWrite.size() - 1){ 74 | out.write(toWrite.get(i)); 75 | out.newLine(); 76 | } 77 | else{ 78 | out.write(toWrite.get(i)); 79 | } 80 | } 81 | //flushes and closes the stream 82 | out.close(); 83 | }catch(IOException e){ 84 | System.out.println("There was a problem:" + e); 85 | } 86 | 87 | } 88 | 89 | public String readFile(String filename){ 90 | filename+=".txt"; 91 | String tempFinder = ""; 92 | try { 93 | in = new BufferedReader(new FileReader(filepath+filename)); 94 | String temp = in.readLine(); 95 | while(temp != null){ 96 | tempFinder+=temp; 97 | temp = in.readLine(); 98 | if(temp != null) 99 | tempFinder+="\n"; 100 | } 101 | in.close(); 102 | }catch(IOException e){ 103 | System.out.println("There was a problem:" + e); 104 | } 105 | return tempFinder; 106 | } 107 | 108 | public String[] readFileArray(String filename){ 109 | filename+=".txt"; 110 | List fileContents = new ArrayList(); 111 | try { 112 | in = new BufferedReader(new FileReader(filepath+filename)); 113 | String temp = in.readLine(); 114 | while(temp != null){ 115 | if(temp.length() > 0){ 116 | fileContents.add(temp.trim()); 117 | } 118 | temp = in.readLine(); 119 | } 120 | in.close(); 121 | }catch(IOException e){ 122 | System.out.println("There was a problem:" + e); 123 | } 124 | return fileContents.toArray(new String[fileContents.size()]); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /DreambotMiner/src/nezz/dreambot/powerminer/gui/ScriptVars.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.powerminer.gui; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import nezz.dreambot.scriptmain.powerminer.MineTask; 7 | 8 | 9 | public class ScriptVars { 10 | public List tasks = new ArrayList(); 11 | public boolean started = false; 12 | } 13 | -------------------------------------------------------------------------------- /DreambotMiner/src/nezz/dreambot/powerminer/gui/minerGui.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.powerminer.gui; 2 | 3 | import nezz.dreambot.filemethods.FileMethods; 4 | import nezz.dreambot.scriptmain.powerminer.MineTask; 5 | import org.dreambot.api.Client; 6 | import org.dreambot.api.methods.container.impl.bank.BankLocation; 7 | import org.dreambot.api.methods.interactive.Players; 8 | import org.dreambot.api.methods.map.Tile; 9 | 10 | import javax.swing.*; 11 | import javax.swing.border.EmptyBorder; 12 | import java.awt.*; 13 | import java.awt.event.ActionEvent; 14 | import java.awt.event.ActionListener; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | public class minerGui extends JFrame { 19 | 20 | /** 21 | * 22 | */ 23 | private static final long serialVersionUID = 1L; 24 | private JPanel contentPane; 25 | private JTextField oreID; 26 | private JTextField goalField; 27 | private JTextField oreNameField; 28 | private JTextField tileField; 29 | JList list = new JList(); 30 | final JCheckBox chckbxDontMove = new JCheckBox("Don't Move"); 31 | FileMethods fm = new FileMethods("DreambotMiner"); 32 | 33 | 34 | private DefaultListModel model1 = new DefaultListModel(); 35 | private JTextField txtFilename; 36 | 37 | public minerGui(final ScriptVars var) { 38 | setTitle("Dreambot Power Miner"); 39 | setIconImage(Toolkit.getDefaultToolkit().getImage(minerGui.class.getResource("/javax/swing/plaf/metal/icons/ocean/computer.gif"))); 40 | setAlwaysOnTop(true); 41 | setResizable(false); 42 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 43 | setBounds(100, 100, 419, 322); 44 | contentPane = new JPanel(); 45 | contentPane.setBackground(SystemColor.inactiveCaptionText); 46 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 47 | setContentPane(contentPane); 48 | contentPane.setLayout(null); 49 | 50 | JLabel lblEnterTree = new JLabel("Enter Ore IDs:"); 51 | lblEnterTree.setForeground(Color.WHITE); 52 | lblEnterTree.setBounds(10, 11, 78, 14); 53 | contentPane.add(lblEnterTree); 54 | 55 | oreID = new JTextField(); 56 | oreID.setText("0,1,2"); 57 | oreID.setBounds(86, 11, 120, 20); 58 | contentPane.add(oreID); 59 | oreID.setColumns(10); 60 | 61 | JLabel lblTrainTilLevel = new JLabel("Goal:"); 62 | lblTrainTilLevel.setForeground(Color.WHITE); 63 | lblTrainTilLevel.setBounds(10, 36, 35, 14); 64 | contentPane.add(lblTrainTilLevel); 65 | 66 | goalField = new JTextField(); 67 | goalField.setText("Level=99"); 68 | goalField.setBounds(54, 33, 76, 20); 69 | contentPane.add(goalField); 70 | goalField.setColumns(10); 71 | 72 | final JComboBox comboBox = new JComboBox(); 73 | comboBox.setModel(new DefaultComboBoxModel(BankLocation.values())); 74 | comboBox.setBounds(54, 58, 152, 20); 75 | contentPane.add(comboBox); 76 | 77 | final JCheckBox chckbxPowermine = new JCheckBox("Powermine"); 78 | 79 | 80 | JButton btnNewButton = new JButton("Start"); 81 | btnNewButton.addActionListener(new ActionListener() { 82 | public void actionPerformed(ActionEvent arg0) { 83 | var.started = true; 84 | dispose(); 85 | } 86 | }); 87 | btnNewButton.setBounds(10, 215, 393, 23); 88 | contentPane.add(btnNewButton); 89 | 90 | JLabel lblBank = new JLabel("Bank:"); 91 | lblBank.setForeground(Color.WHITE); 92 | lblBank.setBounds(10, 61, 46, 14); 93 | contentPane.add(lblBank); 94 | 95 | chckbxPowermine.setForeground(Color.WHITE); 96 | chckbxPowermine.setBackground(Color.BLACK); 97 | chckbxPowermine.setBounds(54, 85, 97, 23); 98 | contentPane.add(chckbxPowermine); 99 | 100 | JLabel lblNewLabel = new JLabel("Ore Name:"); 101 | lblNewLabel.setForeground(Color.WHITE); 102 | lblNewLabel.setBounds(10, 118, 67, 14); 103 | contentPane.add(lblNewLabel); 104 | 105 | oreNameField = new JTextField(); 106 | oreNameField.setText("Iron ore"); 107 | oreNameField.setBounds(76, 115, 86, 20); 108 | contentPane.add(oreNameField); 109 | oreNameField.setColumns(10); 110 | 111 | JButton btnNewButton_1 = new JButton("Add Task"); 112 | btnNewButton_1.addActionListener(new ActionListener() { 113 | public void actionPerformed(ActionEvent arg0) { 114 | String[] oreids = oreID.getText().split(","); 115 | int[] ids = new int[oreids.length]; 116 | for (int i = 0; i < ids.length; i++) { 117 | ids[i] = Integer.parseInt(oreids[i]); 118 | } 119 | String goal = goalField.getText(); 120 | String oreName = oreNameField.getText(); 121 | BankLocation bank = BankLocation.values()[comboBox.getSelectedIndex()]; 122 | boolean powermine = chckbxPowermine.isSelected(); 123 | String tileText = tileField.getText(); 124 | String[] tileVals = tileText.split(","); 125 | int x = Integer.parseInt(tileVals[0]); 126 | int y = Integer.parseInt(tileVals[1]); 127 | int z = Integer.parseInt(tileVals[2]); 128 | Tile startTile = new Tile(x, y, z); 129 | boolean dontMove = chckbxDontMove.isSelected(); 130 | MineTask mt = new MineTask(oreName, ids, startTile, goal, powermine, bank, dontMove); 131 | var.tasks.add(mt); 132 | model1.addElement(mt.toString()); 133 | list.setModel(model1); 134 | } 135 | }); 136 | btnNewButton_1.setBounds(10, 181, 228, 23); 137 | contentPane.add(btnNewButton_1); 138 | 139 | list.setVisibleRowCount(12); 140 | list.setToolTipText(""); 141 | list.setModel(model1); 142 | list.setBackground(Color.LIGHT_GRAY); 143 | list.setForeground(Color.WHITE); 144 | list.setBounds(251, 11, 152, 167); 145 | contentPane.add(list); 146 | 147 | JSeparator separator = new JSeparator(); 148 | separator.setOrientation(SwingConstants.VERTICAL); 149 | separator.setToolTipText("hi"); 150 | separator.setBackground(Color.WHITE); 151 | separator.setBounds(248, 0, 3, 213); 152 | contentPane.add(separator); 153 | 154 | JButton btnNewButton_2 = new JButton("Remove Task"); 155 | btnNewButton_2.addActionListener(new ActionListener() { 156 | public void actionPerformed(ActionEvent arg0) { 157 | String selected = list.getSelectedValue(); 158 | if (selected != null) { 159 | int index = list.getSelectedIndex(); 160 | var.tasks.remove(index); 161 | model1.removeElement(selected); 162 | list.setModel(model1); 163 | } 164 | } 165 | }); 166 | btnNewButton_2.setBounds(251, 181, 152, 23); 167 | contentPane.add(btnNewButton_2); 168 | 169 | JLabel lblTile = new JLabel("Tile:"); 170 | lblTile.setForeground(Color.WHITE); 171 | lblTile.setBounds(10, 143, 46, 14); 172 | contentPane.add(lblTile); 173 | 174 | tileField = new JTextField(); 175 | Tile myTile = null; 176 | String tile = "1234,1234,0"; 177 | if (Client.isLoggedIn()) { 178 | myTile = Players.getLocal().getTile(); 179 | } 180 | if (myTile != null) 181 | tile = myTile.getX() + "," + myTile.getY() + "," + myTile.getZ(); 182 | tileField.setText(tile); 183 | tileField.setBounds(76, 140, 86, 20); 184 | contentPane.add(tileField); 185 | tileField.setColumns(10); 186 | 187 | chckbxDontMove.setBackground(Color.BLACK); 188 | chckbxDontMove.setForeground(Color.WHITE); 189 | chckbxDontMove.setBounds(153, 85, 85, 23); 190 | contentPane.add(chckbxDontMove); 191 | 192 | txtFilename = new JTextField(); 193 | txtFilename.setText("filename"); 194 | txtFilename.setBounds(10, 249, 86, 20); 195 | contentPane.add(txtFilename); 196 | txtFilename.setColumns(10); 197 | 198 | JButton btnSave = new JButton("Save"); 199 | btnSave.addActionListener(new ActionListener() { 200 | public void actionPerformed(ActionEvent arg0) { 201 | saveFile(var, txtFilename.getText()); 202 | } 203 | }); 204 | btnSave.setBounds(106, 248, 57, 23); 205 | contentPane.add(btnSave); 206 | 207 | JButton btnLoad = new JButton("Load"); 208 | btnLoad.addActionListener(new ActionListener() { 209 | public void actionPerformed(ActionEvent arg0) { 210 | loadFile(var, txtFilename.getText()); 211 | } 212 | }); 213 | btnLoad.setBounds(173, 248, 57, 23); 214 | contentPane.add(btnLoad); 215 | } 216 | 217 | public void saveFile(final ScriptVars var, String fileName) { 218 | //StringBuilder sb = new StringBuilder(); 219 | List sb = new ArrayList(); 220 | for (MineTask mt : var.tasks) { 221 | //add name 222 | sb.add(mt.getOreName()); 223 | //sb.add("\n"); 224 | //add id's 225 | String idString = ""; 226 | for (int i = 0; i < mt.getIDs().length; i++) { 227 | idString += mt.getIDs()[i]; 228 | if (i < (mt.getIDs().length - 1)) 229 | idString += (","); 230 | } 231 | sb.add(idString); 232 | //sb.add("\n"); 233 | //add tile 234 | sb.add(mt.getStartTile().getX() + "," + mt.getStartTile().getY() + "," + mt.getStartTile().getZ()); 235 | //sb.add("\n"); 236 | //add goal 237 | sb.add(mt.getGoal()); 238 | //sb.add("\n"); 239 | //add powermine 240 | sb.add("" + mt.isPowerMine()); 241 | //sb.add("\n"); 242 | //add bank 243 | sb.add(mt.getBank().toString()); 244 | //sb.add("\n"); 245 | //add don't move 246 | sb.add("" + mt.dontMove()); 247 | //sb.add("\n"); 248 | } 249 | //sb.add("END FILE"); 250 | fm.writeFile(sb, fileName); 251 | } 252 | 253 | public void loadFile(final ScriptVars var, String fileName) { 254 | var.tasks.clear(); 255 | model1.clear(); 256 | String[] content = fm.readFileArray(fileName); 257 | //(ctx, oreName, ids, startTile, goal, powermine, bank, dontMove); 258 | for (int i = 0; i < content.length; i += 7) { 259 | //get name 260 | String oreName = content[i]; 261 | //get ids 262 | String idString = content[i + 1]; 263 | String[] idsString = idString.split(","); 264 | int[] ids = new int[idsString.length]; 265 | for (int ii = 0; ii < ids.length; ii++) { 266 | ids[ii] = Integer.parseInt(idsString[ii]); 267 | } 268 | //get tile 269 | String tileString = content[i + 2]; 270 | String[] tileStringSplit = tileString.split(","); 271 | Tile startTile = new Tile(Integer.parseInt(tileStringSplit[0]), Integer.parseInt(tileStringSplit[1]), Integer.parseInt(tileStringSplit[2])); 272 | //get goal 273 | String goal = content[i + 3]; 274 | //get powermine 275 | String powermineString = content[i + 4]; 276 | boolean powermine = false; 277 | if (powermineString.toLowerCase().equals("true")) { 278 | powermine = true; 279 | } 280 | //get bank 281 | String bankString = content[i + 5]; 282 | BankLocation bank = null; 283 | for (BankLocation b : BankLocation.values()) { 284 | if (b.toString().equals(bankString)) { 285 | bank = b; 286 | break; 287 | } 288 | } 289 | //get dont move 290 | String dontMoveString = content[i + 6]; 291 | boolean dontMove = false; 292 | if (dontMoveString.toLowerCase().equals("true")) 293 | dontMove = true; 294 | 295 | MineTask mt = new MineTask(oreName, ids, startTile, goal, powermine, bank, dontMove); 296 | System.out.println(mt.toString()); 297 | var.tasks.add(mt); 298 | model1.addElement(mt.toString()); 299 | list.setModel(model1); 300 | } 301 | } 302 | } 303 | -------------------------------------------------------------------------------- /DreambotMiner/src/nezz/dreambot/scriptmain/powerminer/MineTask.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.powerminer; 2 | 3 | import nezz.dreambot.tools.PricedItem; 4 | import org.dreambot.api.methods.container.impl.bank.Bank; 5 | import org.dreambot.api.methods.container.impl.bank.BankLocation; 6 | import org.dreambot.api.methods.filter.Filter; 7 | import org.dreambot.api.methods.interactive.GameObjects; 8 | import org.dreambot.api.methods.interactive.Players; 9 | import org.dreambot.api.methods.map.Tile; 10 | import org.dreambot.api.methods.skills.Skill; 11 | import org.dreambot.api.methods.skills.Skills; 12 | import org.dreambot.api.utilities.Timer; 13 | import org.dreambot.api.wrappers.interactive.GameObject; 14 | import org.dreambot.api.wrappers.items.Item; 15 | 16 | import java.util.List; 17 | 18 | public class MineTask { 19 | private String goal; 20 | private Tile startTile; 21 | private int[] ids; 22 | private boolean powermine; 23 | private Timer t; 24 | private String oreName; 25 | private PricedItem oreTracker; 26 | private BankLocation bank; 27 | private boolean finished = false; 28 | private boolean dontMove; 29 | 30 | private final Filter rockFilter = go -> { 31 | if (go == null || !go.exists() || go.getName() == null || !go.getName().equals("Rocks")) 32 | return false; 33 | boolean hasID = false; 34 | for (int i = 0; i < getIDs().length; i++) { 35 | if (go.getID() == getIDs()[i]) { 36 | hasID = true; 37 | break; 38 | } 39 | } 40 | if (!hasID) 41 | return false; 42 | return !dontMove() || !(go.distance(Players.getLocal()) > 1); 43 | }; 44 | 45 | public MineTask(String oreName, int[] ids, Tile startTile, String goal, boolean powermine, BankLocation bank, boolean dontMove) { 46 | this.oreName = oreName; 47 | this.ids = ids; 48 | this.startTile = startTile; 49 | this.goal = goal; 50 | this.powermine = powermine; 51 | this.oreTracker = new PricedItem(oreName, false); 52 | this.bank = bank; 53 | this.dontMove = dontMove; 54 | t = new Timer(); 55 | } 56 | 57 | public boolean dontMove() { 58 | return this.dontMove; 59 | } 60 | 61 | public void resetTimer() { 62 | t = new Timer(); 63 | } 64 | 65 | public boolean reachedGoal() { 66 | if (goal.toLowerCase().contains("bank")) { 67 | Item ore = Bank.get(oreName); 68 | if (ore == null) 69 | return false; 70 | else { 71 | if (ore.getAmount() >= Integer.parseInt(goal.split("=")[1])) { 72 | this.finished = true; 73 | return true; 74 | } 75 | return false; 76 | } 77 | } else if (goal.toLowerCase().contains("level")) { 78 | this.finished = Skills.getRealLevel(Skill.MINING) >= Integer.parseInt(goal.split("=")[1]); 79 | return finished; 80 | } else if (goal.toLowerCase().contains("mine")) { 81 | this.finished = oreTracker.getAmount() >= Integer.parseInt(goal.split("=")[1]); 82 | return finished; 83 | } 84 | return false; 85 | } 86 | 87 | private GameObject getClosest(List rocks) { 88 | GameObject currRock = null; 89 | double dist = Double.MAX_VALUE; 90 | for (GameObject go : rocks) { 91 | if (currRock == null) { 92 | currRock = go; 93 | dist = go.distance(Players.getLocal()); 94 | continue; 95 | } 96 | double tempDist = go.distance(Players.getLocal()); 97 | if (tempDist < dist) { 98 | currRock = go; 99 | dist = tempDist; 100 | } 101 | } 102 | return currRock; 103 | } 104 | 105 | public Filter getRockFilter() { 106 | return this.rockFilter; 107 | } 108 | 109 | public GameObject getRock() { 110 | List acceptableRocks = GameObjects.all(rockFilter); 111 | return getClosest(acceptableRocks); 112 | } 113 | 114 | public boolean isPowerMine() { 115 | return powermine; 116 | } 117 | 118 | public Tile getStartTile() { 119 | return startTile; 120 | } 121 | 122 | public String getGoal() { 123 | return goal; 124 | } 125 | 126 | public PricedItem getTracker() { 127 | return oreTracker; 128 | } 129 | 130 | public String getOreName() { 131 | return oreName; 132 | } 133 | 134 | public Timer getTimer() { 135 | return t; 136 | } 137 | 138 | public int[] getIDs() { 139 | return ids; 140 | } 141 | 142 | public BankLocation getBank() { 143 | return bank; 144 | } 145 | 146 | public boolean getFinished() { 147 | return this.finished; 148 | } 149 | 150 | public void setDontMove(boolean dontMove) { 151 | this.dontMove = dontMove; 152 | } 153 | 154 | public void setPowerMine(boolean powermine) { 155 | this.powermine = powermine; 156 | } 157 | 158 | public void setStarTile(Tile startTile) { 159 | this.startTile = startTile; 160 | } 161 | 162 | public void setGoal(String goal) { 163 | this.goal = goal; 164 | } 165 | 166 | public void setTracker(PricedItem oreTracker) { 167 | this.oreTracker = oreTracker; 168 | } 169 | 170 | public void setOreName(String oreName) { 171 | this.oreName = oreName; 172 | } 173 | 174 | public void setIDs(int[] ids) { 175 | this.ids = ids; 176 | } 177 | 178 | public void setBank(BankLocation bank) { 179 | this.bank = bank; 180 | } 181 | 182 | public void setFinished(boolean finished) { 183 | this.finished = finished; 184 | } 185 | 186 | public String toString() { 187 | StringBuilder sb = new StringBuilder(); 188 | sb.append("Ore Name: ").append(oreName).append("\n"); 189 | sb.append("IDs: "); 190 | for (int i = 0; i < ids.length; i++) { 191 | if (ids[i] > 0) 192 | sb.append(ids[i]); 193 | if (i != ids.length - 1 && ids[i + 1] != 0) { 194 | sb.append(","); 195 | } 196 | } 197 | sb.append("\n"); 198 | sb.append("Tile: ").append(startTile.toString()).append("\n"); 199 | sb.append("Bank: ").append(bank.toString()).append("\n"); 200 | sb.append("Goal: ").append(goal).append("\n"); 201 | sb.append("Powermine: ").append(powermine).append("\n"); 202 | sb.append("Don't Move: ").append(dontMove); 203 | return sb.toString(); 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /DreambotMiner/src/nezz/dreambot/scriptmain/powerminer/Miner.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.powerminer; 2 | 3 | import nezz.dreambot.powerminer.gui.ScriptVars; 4 | import nezz.dreambot.powerminer.gui.minerGui; 5 | import org.dreambot.api.Client; 6 | import org.dreambot.api.input.Mouse; 7 | import org.dreambot.api.methods.Calculations; 8 | import org.dreambot.api.methods.container.impl.Inventory; 9 | import org.dreambot.api.methods.container.impl.bank.Bank; 10 | import org.dreambot.api.methods.input.Camera; 11 | import org.dreambot.api.methods.interactive.GameObjects; 12 | import org.dreambot.api.methods.interactive.Players; 13 | import org.dreambot.api.methods.map.Map; 14 | import org.dreambot.api.methods.map.Tile; 15 | import org.dreambot.api.methods.skills.Skill; 16 | import org.dreambot.api.methods.skills.SkillTracker; 17 | import org.dreambot.api.methods.skills.Skills; 18 | import org.dreambot.api.methods.walking.impl.Walking; 19 | import org.dreambot.api.script.AbstractScript; 20 | import org.dreambot.api.script.Category; 21 | import org.dreambot.api.script.ScriptManifest; 22 | import org.dreambot.api.utilities.Sleep; 23 | import org.dreambot.api.utilities.Timer; 24 | import org.dreambot.api.wrappers.interactive.GameObject; 25 | import org.dreambot.api.wrappers.interactive.Player; 26 | import org.dreambot.api.wrappers.items.Item; 27 | 28 | import java.awt.*; 29 | import java.util.List; 30 | 31 | @ScriptManifest(author = "Nezz", description = "Power Miner", name = "DreamBot Power Miner", version = 1.1, category = Category.MINING) 32 | public class Miner extends AbstractScript { 33 | 34 | private Timer timer; 35 | ScriptVars sv = new ScriptVars(); 36 | //current state 37 | private State state; 38 | private GameObject currRock = null; 39 | //private Tile startTile = null; 40 | private MineTask currTask = null; 41 | private int taskPlace = 0; 42 | private boolean started = false; 43 | private minerGui gui = null; 44 | 45 | private enum State { 46 | MINE, DROP, BANK, GUI 47 | } 48 | 49 | private State getState() { 50 | if (!started) { 51 | return State.GUI; 52 | } 53 | if (currTask.isPowerMine()) { 54 | if (Inventory.contains(currTask.getOreName())) 55 | return State.DROP; 56 | } else if (Inventory.isFull()) { 57 | return State.BANK; 58 | } 59 | return State.MINE; 60 | } 61 | 62 | @Override 63 | public void onStart() { 64 | log("Starting DreamBot's AIO Mining script!"); 65 | } 66 | 67 | @Override 68 | public int onLoop() { 69 | if (started) { 70 | if (currTask.reachedGoal()) { 71 | log("Finished current task!"); 72 | taskPlace++; 73 | if (taskPlace >= sv.tasks.size()) { 74 | log("Finished all tasks!"); 75 | stop(); 76 | return 1; 77 | } 78 | currTask = sv.tasks.get(taskPlace); 79 | currTask.resetTimer(); 80 | return 200; 81 | } 82 | Player myPlayer = Players.getLocal(); 83 | if (!Walking.isRunEnabled() && Walking.getRunEnergy() > Calculations.random(30, 70)) { 84 | Walking.toggleRun(); 85 | } 86 | if (myPlayer.isMoving() && Client.getDestination() != null && Client.getDestination().distance(myPlayer) > 5) 87 | return Calculations.random(300, 600); 88 | if (Players.getLocal().isInCombat()) 89 | return Calculations.random(300, 600); 90 | } 91 | state = getState(); 92 | switch (state) { 93 | case GUI: 94 | if (gui == null) { 95 | gui = new minerGui(sv); 96 | sleep(300); 97 | } else if (!gui.isVisible() && !sv.started) { 98 | gui.setVisible(true); 99 | sleep(1000); 100 | } else { 101 | if (!sv.started) { 102 | sleep(300); 103 | } else { 104 | currTask = sv.tasks.get(0); 105 | currTask.resetTimer(); 106 | SkillTracker.start(Skill.MINING); 107 | timer = new Timer(); 108 | started = true; 109 | } 110 | } 111 | break; 112 | case BANK: 113 | if (Bank.isOpen()) { 114 | if (Inventory.get(i -> { 115 | if (i == null || i.getName() == null) { 116 | return false; 117 | } 118 | return i.getName().contains("pickaxe"); 119 | }) != null) { 120 | for (int i = 0; i < 28; i++) { 121 | final Item item = Inventory.getItemInSlot(i); 122 | if (item != null && !item.getName().contains("pickaxe")) { 123 | Bank.depositAll(item.getName()); 124 | Sleep.sleepUntil(() -> !Inventory.contains(item.getName()), 2000); 125 | } 126 | } 127 | } else { 128 | Bank.depositAllItems(); 129 | Sleep.sleepUntil(Inventory::isEmpty, 2000); 130 | } 131 | } else { 132 | if (currTask.getBank().getArea(4).contains(Players.getLocal())) { 133 | Bank.open(); 134 | Sleep.sleepUntil(Bank::isOpen, 2000); 135 | } else { 136 | Walking.walk(currTask.getBank().getCenter()); 137 | Sleep.sleepUntil(() -> Players.getLocal().isMoving(), 2000); 138 | } 139 | } 140 | break; 141 | case DROP: 142 | currRock = null; 143 | Item ore = Inventory.get(currTask.getOreName()); 144 | if (ore != null) { 145 | Inventory.interact(ore.getName(), "Drop"); 146 | Sleep.sleepUntil(() -> { 147 | Item ore1 = Inventory.get(currTask.getOreName()); 148 | return ore1 == null; 149 | }, 1200); 150 | } 151 | break; 152 | case MINE: 153 | if (Bank.isOpen()) { 154 | Bank.close(); 155 | Sleep.sleepUntil(() -> !Bank.isOpen(), 1200); 156 | } else { 157 | if (currTask.getStartTile().distance(Players.getLocal()) > 10) { 158 | Walking.walk(currTask.getStartTile()); 159 | Sleep.sleepUntil(() -> Players.getLocal().isMoving(), 2000); 160 | } else if ((currTask.dontMove() && !Players.getLocal().getTile().equals(currTask.getStartTile()))) { 161 | Walking.walk(currTask.getStartTile()); 162 | Sleep.sleepUntil(() -> Players.getLocal().isMoving(), 2000); 163 | Sleep.sleepUntil(() -> !Players.getLocal().isMoving(), 2000); 164 | } else { 165 | if (Camera.getPitch() < 270) { 166 | Camera.rotateToPitch((int) (Calculations.random(300, 400) * Client.seededRandom())); 167 | } 168 | if (Players.getLocal().getAnimation() == -1 && (currRock == null || !currRock.isOnScreen() || !currTask.isPowerMine())) 169 | currRock = currTask.getRock();//GameObjects.getClosest(currTask.getIDs()); 170 | if (Players.getLocal().getAnimation() == -1) { 171 | if (currRock != null && currRock.exists()) { 172 | if (currRock.interact("Mine")) { 173 | if (currTask.isPowerMine()) { 174 | hover(true); 175 | } else { 176 | Sleep.sleepUntil(() -> Players.getLocal().getAnimation() != -1, 2000); 177 | Sleep.sleepUntil(() -> Players.getLocal().getAnimation() == -1, 1800); 178 | sleep(300, 500); 179 | } 180 | } 181 | } 182 | } else 183 | sleep(300, 600); 184 | } 185 | } 186 | currTask.getTracker().update(); 187 | break; 188 | } 189 | return 200; 190 | } 191 | 192 | public int getFirstEmptySlot() { 193 | for (int i = 0; i < 28; i++) { 194 | Item it = Inventory.getItemInSlot(i); 195 | if (it == null || it.getName().contains("ore")) { 196 | return i; 197 | } 198 | } 199 | return 0; 200 | } 201 | 202 | public void hover(boolean fromInteract) { 203 | int firstEmpty = getFirstEmptySlot(); 204 | Rectangle r = Inventory.slotBounds(firstEmpty); 205 | if (!r.contains(Mouse.getPosition())) { 206 | int x1 = (int) r.getCenterX() - Calculations.random(0, 10); 207 | int y1 = (int) r.getCenterY() - Calculations.random(0, 10); 208 | int x2 = (int) r.getCenterX() + Calculations.random(0, 10); 209 | int y2 = (int) r.getCenterY() + Calculations.random(0, 10); 210 | int fX = Calculations.random(x1, x2); 211 | int fY = Calculations.random(y1, y2); 212 | Mouse.move(new Point(fX, fY)); 213 | } 214 | if (fromInteract) { 215 | Sleep.sleepUntil(() -> Players.getLocal().getAnimation() != -1, 2000); 216 | } 217 | } 218 | 219 | @Override 220 | public void onExit() { 221 | log("Stopping testing!"); 222 | } 223 | 224 | public void onPaint(Graphics g) { 225 | if (started) { 226 | g.setColor(Color.green); 227 | if (state != null) 228 | g.drawString("State: " + state, 5, 50); 229 | g.drawString("Total Runtime: " + timer.formatTime(), 5, 65); 230 | g.drawString("Task Runtime: " + currTask.getTimer().formatTime(), 5, 80); 231 | g.drawString("Experience(p/h): " + SkillTracker.getGainedExperience(Skill.MINING) + "(" + SkillTracker.getGainedExperiencePerHour(Skill.MINING) + ")", 5, 95); 232 | g.drawString("Level(gained): " + Skills.getRealLevel(Skill.MINING) + "(" + SkillTracker.getGainedLevels(Skill.MINING) + ")", 5, 110); 233 | g.drawString("Ores(p/h): " + currTask.getTracker().getAmount() + "(" + timer.getHourlyRate(currTask.getTracker().getAmount()) + ")", 10, 125); 234 | g.drawString("Current task: " + currTask.getOreName() + "::" + currTask.getGoal(), 10, 140); 235 | for (int i = 0; i < sv.tasks.size(); i++) { 236 | MineTask mt = sv.tasks.get(i); 237 | if (mt != null) { 238 | if (mt.getFinished()) { 239 | g.setColor(Color.blue); 240 | } else { 241 | g.setColor(Color.red); 242 | } 243 | String task = mt.getOreName() + "::" + mt.getGoal(); 244 | g.drawString(task, 10, 155 + i * 15); 245 | } 246 | } 247 | } else { 248 | List rocks = GameObjects.all(go -> { 249 | if (go == null || !go.exists() || go.getName() == null || !go.getName().equals("Rocks")) 250 | return false; 251 | return go.isOnScreen(); 252 | }); 253 | if (!rocks.isEmpty()) { 254 | for (GameObject go : rocks) { 255 | Tile rockTile = go.getTile(); 256 | Rectangle tileRect = Map.getBounds(rockTile); 257 | Point startPoint = new Point(tileRect.x, (int) tileRect.getCenterY()); 258 | g.drawString("ID: " + go.getID(), startPoint.x, startPoint.y); 259 | } 260 | } 261 | } 262 | } 263 | } 264 | -------------------------------------------------------------------------------- /DreambotMiner/src/nezz/dreambot/tools/PricedItem.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.tools; 2 | 3 | import org.dreambot.api.methods.container.impl.Inventory; 4 | import org.dreambot.api.methods.grandexchange.LivePrices; 5 | import org.dreambot.api.utilities.Logger; 6 | 7 | public class PricedItem { 8 | private String name; 9 | private int lastCount = 0; 10 | private int amount = 0; 11 | private int price = 0; 12 | private int id = 0; 13 | 14 | public PricedItem(String name, boolean getPrice) { 15 | this.name = name; 16 | if (Inventory.contains(name)) { 17 | lastCount = Inventory.count(name); 18 | } 19 | if (getPrice) { 20 | String tempName = name; 21 | if (name.contains("arrow")) 22 | tempName += "s"; 23 | Logger.log("Getting price"); 24 | price = LivePrices.get(tempName); 25 | Logger.log("Got price: " + price); 26 | } else 27 | price = 0; 28 | } 29 | 30 | public void update() { 31 | int increase; 32 | if (id == 0) 33 | increase = Inventory.count(name) - lastCount; 34 | else 35 | increase = Inventory.count(id) - lastCount; 36 | if (increase < 0) 37 | increase = 0; 38 | amount += increase; 39 | if (id == 0) 40 | lastCount = Inventory.count(name); 41 | else 42 | lastCount = Inventory.count(id); 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public void setAmount(int amt) { 50 | this.amount = amt; 51 | } 52 | 53 | public void setPrice(int price) { 54 | this.price = price; 55 | } 56 | 57 | public String getName() { 58 | return name; 59 | } 60 | 61 | public int getAmount() { 62 | return amount; 63 | } 64 | 65 | public int getPrice() { 66 | return price; 67 | } 68 | 69 | public int getValue() { 70 | if (amount <= 0) 71 | return 0; 72 | return amount * price; 73 | } 74 | 75 | public int getId() { 76 | return id; 77 | } 78 | 79 | public void setId(int id) { 80 | this.id = id; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /DreambotPackBuyer/src/nezz/dreambot/packbuyer/gui/ScriptVars.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.packbuyer.gui; 2 | 3 | public class ScriptVars { 4 | public String packName; 5 | public String shopName; 6 | public int minAmt = 0; 7 | public int perItem; 8 | public boolean hopWorlds = false; 9 | public boolean started = false; 10 | } 11 | -------------------------------------------------------------------------------- /DreambotPackBuyer/src/nezz/dreambot/packbuyer/gui/buyerGui.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.packbuyer.gui; 2 | 3 | import javax.swing.JFrame; 4 | import javax.swing.JPanel; 5 | import javax.swing.border.EmptyBorder; 6 | 7 | import java.awt.Toolkit; 8 | 9 | import javax.swing.JLabel; 10 | import javax.swing.JTextField; 11 | import javax.swing.JCheckBox; 12 | import javax.swing.JButton; 13 | 14 | import java.awt.event.ActionListener; 15 | import java.awt.event.ActionEvent; 16 | import java.awt.Color; 17 | 18 | public class buyerGui extends JFrame { 19 | 20 | /** 21 | * 22 | */ 23 | private static final long serialVersionUID = 1L; 24 | private JPanel contentPane; 25 | 26 | private JTextField txtItemName; 27 | private JTextField txtShopName; 28 | private JTextField txtPerItem; 29 | JCheckBox chckbxHopWorlds = new JCheckBox("hop worlds"); 30 | private JTextField txtMinAmt; 31 | 32 | 33 | public buyerGui(final ScriptVars var) { 34 | setTitle("DreamBot Pack Buyer"); 35 | setIconImage(Toolkit.getDefaultToolkit().getImage(buyerGui.class.getResource("/javax/swing/plaf/metal/icons/ocean/computer.gif"))); 36 | setAlwaysOnTop(true); 37 | setResizable(false); 38 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 39 | setBounds(100, 100, 276, 237); 40 | contentPane = new JPanel(); 41 | contentPane.setBackground(Color.WHITE); 42 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 43 | setContentPane(contentPane); 44 | contentPane.setLayout(null); 45 | 46 | JPanel panel = new JPanel(); 47 | panel.setBounds(0, 0, 270, 163); 48 | contentPane.add(panel); 49 | panel.setLayout(null); 50 | 51 | JLabel lblItemName = new JLabel("Item Name:"); 52 | lblItemName.setBounds(0, 11, 93, 14); 53 | panel.add(lblItemName); 54 | 55 | txtItemName = new JTextField(); 56 | txtItemName.setText("Mind rune pack"); 57 | txtItemName.setBounds(96, 9, 132, 20); 58 | panel.add(txtItemName); 59 | txtItemName.setColumns(10); 60 | 61 | txtShopName = new JTextField(); 62 | txtShopName.setText("Betty"); 63 | txtShopName.setColumns(10); 64 | txtShopName.setBounds(96, 36, 132, 20); 65 | panel.add(txtShopName); 66 | 67 | JLabel lblShopName = new JLabel("Shop Name:"); 68 | lblShopName.setBounds(0, 38, 93, 14); 69 | panel.add(lblShopName); 70 | 71 | txtPerItem = new JTextField(); 72 | txtPerItem.setText("3"); 73 | txtPerItem.setColumns(10); 74 | txtPerItem.setBounds(96, 67, 39, 20); 75 | panel.add(txtPerItem); 76 | 77 | JLabel lblPerItem = new JLabel("Per Item:"); 78 | lblPerItem.setBounds(0, 69, 93, 14); 79 | panel.add(lblPerItem); 80 | 81 | JLabel lblHopWorlds = new JLabel("Hop Worlds:"); 82 | lblHopWorlds.setBounds(0, 94, 73, 14); 83 | panel.add(lblHopWorlds); 84 | 85 | chckbxHopWorlds.setBounds(96, 90, 97, 23); 86 | panel.add(chckbxHopWorlds); 87 | 88 | JLabel lblMinimumAmt = new JLabel("Minimum Amt:"); 89 | lblMinimumAmt.setBounds(0, 121, 93, 14); 90 | panel.add(lblMinimumAmt); 91 | 92 | txtMinAmt = new JTextField(); 93 | txtMinAmt.setText("10"); 94 | txtMinAmt.setBounds(96, 118, 39, 20); 95 | panel.add(txtMinAmt); 96 | txtMinAmt.setColumns(10); 97 | 98 | JButton btnNewButton = new JButton("Start!"); 99 | btnNewButton.addActionListener(new ActionListener() { 100 | public void actionPerformed(ActionEvent arg0) { 101 | var.shopName = txtShopName.getText(); 102 | var.packName = txtItemName.getText(); 103 | var.perItem = Integer.parseInt(txtPerItem.getText()); 104 | var.hopWorlds = chckbxHopWorlds.isSelected(); 105 | var.minAmt = Integer.parseInt(txtMinAmt.getText()); 106 | var.started = true; 107 | dispose(); 108 | } 109 | }); 110 | btnNewButton.setBounds(0, 174, 270, 34); 111 | contentPane.add(btnNewButton); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /DreambotPackBuyer/src/nezz/dreambot/scriptmain/packbuyer/PackBuyer.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.packbuyer; 2 | 3 | import nezz.dreambot.packbuyer.gui.ScriptVars; 4 | import nezz.dreambot.packbuyer.gui.buyerGui; 5 | import nezz.dreambot.tools.PricedItem; 6 | import org.dreambot.api.Client; 7 | import org.dreambot.api.methods.Calculations; 8 | import org.dreambot.api.methods.container.impl.Inventory; 9 | import org.dreambot.api.methods.container.impl.Shop; 10 | import org.dreambot.api.methods.interactive.Players; 11 | import org.dreambot.api.methods.world.Worlds; 12 | import org.dreambot.api.methods.worldhopper.WorldHopper; 13 | import org.dreambot.api.script.AbstractScript; 14 | import org.dreambot.api.script.Category; 15 | import org.dreambot.api.script.ScriptManifest; 16 | import org.dreambot.api.utilities.Sleep; 17 | import org.dreambot.api.utilities.Timer; 18 | import org.dreambot.api.utilities.impl.Condition; 19 | import org.dreambot.api.wrappers.items.Item; 20 | 21 | import java.awt.*; 22 | 23 | @ScriptManifest(author = "Nezz", name = "DreamBot Pack Buyer", version = 0, category = Category.MONEYMAKING, description = "Buys any pack and opens it") 24 | public class PackBuyer extends AbstractScript { 25 | 26 | private boolean hopWorlds = false; 27 | private final int[] f2pWorlds = new int[]{381, 382, 384, 393, 394}; 28 | 29 | ScriptVars sv = new ScriptVars(); 30 | 31 | PricedItem feathers; 32 | State state; 33 | Timer timer; 34 | 35 | boolean started = false; 36 | 37 | private enum State { 38 | BUY, OPEN_PACKS, HOP 39 | } 40 | 41 | private State getState() { 42 | if (Inventory.contains(sv.packName)) { 43 | return State.OPEN_PACKS; 44 | } 45 | if (hopWorlds) 46 | return State.HOP; 47 | if (Inventory.contains(sv.packName)) { 48 | return State.OPEN_PACKS; 49 | } else 50 | return State.BUY; 51 | } 52 | 53 | public void onStart() { 54 | buyerGui gui = new buyerGui(sv); 55 | gui.setVisible(true); 56 | while (!sv.started) { 57 | Sleep.sleep(200); 58 | } 59 | 60 | String itemName = sv.packName.replace(" pack", ""); 61 | log(itemName); 62 | feathers = new PricedItem(itemName, false); 63 | timer = new Timer(); 64 | started = true; 65 | } 66 | 67 | @Override 68 | public int onLoop() { 69 | log("looping"); 70 | if (feathers == null) { 71 | String itemName = sv.packName.replace(" pack", ""); 72 | log(itemName); 73 | feathers = new PricedItem(itemName, false); 74 | } 75 | if (Players.getLocal().isMoving() && Client.getDestination() != null && Client.getDestination().distance(Players.getLocal().getTile()) > 3) 76 | return Calculations.random(200, 300); 77 | state = getState(); 78 | switch (state) { 79 | case HOP: 80 | if (sv.hopWorlds) { 81 | int hopTo = f2pWorlds[Calculations.random(0, f2pWorlds.length - 1)]; 82 | for (int i = 0; i < 15; i++) { 83 | if (hopTo != Worlds.getCurrentWorld()) { 84 | break; 85 | } 86 | hopTo = f2pWorlds[Calculations.random(0, f2pWorlds.length - 1)]; 87 | } 88 | WorldHopper.hopWorld(hopTo); 89 | } else { 90 | Sleep.sleep(30000, 50000); 91 | } 92 | hopWorlds = false; 93 | break; 94 | case BUY: 95 | if (!Shop.isOpen()) { 96 | Shop.open(); 97 | waitFor(Shop::isOpen, 1500); 98 | } else { 99 | Item pack = Shop.get(sv.packName); 100 | if (pack != null && pack.getAmount() > sv.minAmt) { 101 | Shop.purchase(pack, 10); 102 | waitFor(() -> Inventory.contains(sv.packName), 1000); 103 | } else { 104 | try { 105 | Thread.sleep(Calculations.random(200, 300)); 106 | } catch (InterruptedException e) { 107 | e.printStackTrace(); 108 | } 109 | } 110 | pack = Shop.get(sv.packName); 111 | if (pack == null || pack.getAmount() <= sv.minAmt / 2) 112 | hopWorlds = true; 113 | } 114 | break; 115 | case OPEN_PACKS: 116 | if (Shop.isOpen()) { 117 | Shop.close(); 118 | } else { 119 | for (int i = 0; i < 28; i++) { 120 | Item it = Inventory.getItemInSlot(i); 121 | if (it != null && it.getName().equals(sv.packName)) { 122 | Inventory.slotInteract(i, "Open"); 123 | try { 124 | Thread.sleep(Calculations.random(100, 150)); 125 | } catch (InterruptedException e) { 126 | e.printStackTrace(); 127 | } 128 | } 129 | feathers.update(); 130 | } 131 | feathers.update(); 132 | } 133 | break; 134 | } 135 | return Calculations.random(100, 200); 136 | } 137 | 138 | public void waitFor(Condition c, int timeout) { 139 | Sleep.sleepUntil(c, timeout); 140 | } 141 | 142 | public void onPaint(Graphics g) { 143 | if (started) { 144 | if (state != null) { 145 | g.drawString("State: " + state, 5, 50); 146 | } 147 | g.drawString(feathers.getName() + " bought(p/h): " + feathers.getAmount() + "(" + timer.getHourlyRate(feathers.getAmount()) + ")", 5, 65); 148 | g.drawString("GP Made(p/h): " + feathers.getAmount() * (feathers.getPrice() - sv.perItem) + "(" + timer.getHourlyRate(feathers.getAmount() * (feathers.getPrice() - sv.perItem)) + ")", 5, 80); 149 | g.drawString("Time run: " + timer.formatTime(), 5, 95); 150 | } 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /DreambotPackBuyer/src/nezz/dreambot/tools/PricedItem.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.tools; 2 | 3 | import org.dreambot.api.methods.container.impl.Inventory; 4 | import org.dreambot.api.methods.grandexchange.LivePrices; 5 | import org.dreambot.api.utilities.Logger; 6 | 7 | public class PricedItem { 8 | private String name; 9 | private int lastCount = 0; 10 | private int amount = 0; 11 | private int price = 0; 12 | private int id = 0; 13 | 14 | public PricedItem(String name, boolean getPrice) { 15 | this.name = name; 16 | if (Inventory.contains(name)) { 17 | lastCount = Inventory.count(name); 18 | } 19 | if (getPrice) { 20 | String tempName = name; 21 | if (name.contains("arrow")) 22 | tempName += "s"; 23 | Logger.log("Getting price"); 24 | price = LivePrices.get(tempName); 25 | Logger.log("Got price: " + price); 26 | } else 27 | price = 0; 28 | } 29 | 30 | public void update() { 31 | int increase; 32 | if (id == 0) 33 | increase = Inventory.count(name) - lastCount; 34 | else 35 | increase = Inventory.count(id) - lastCount; 36 | if (increase < 0) 37 | increase = 0; 38 | amount += increase; 39 | if (id == 0) 40 | lastCount = Inventory.count(name); 41 | else 42 | lastCount = Inventory.count(id); 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public void setAmount(int amt) { 50 | this.amount = amt; 51 | } 52 | 53 | public void setPrice(int price) { 54 | this.price = price; 55 | } 56 | 57 | public String getName() { 58 | return name; 59 | } 60 | 61 | public int getAmount() { 62 | return amount; 63 | } 64 | 65 | public int getPrice() { 66 | return price; 67 | } 68 | 69 | public int getValue() { 70 | if (amount <= 0) 71 | return 0; 72 | return amount * price; 73 | } 74 | 75 | public int getId() { 76 | return id; 77 | } 78 | 79 | public void setId(int id) { 80 | this.id = id; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /DreambotThiever/src/nezz/dreambot/scriptmain/thiever/Thiever.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.scriptmain.thiever; 2 | 3 | import nezz.dreambot.thiever.gui.ScriptVars; 4 | import nezz.dreambot.thiever.gui.thieverGui; 5 | import org.dreambot.api.input.Mouse; 6 | import org.dreambot.api.methods.container.impl.Inventory; 7 | import org.dreambot.api.methods.container.impl.bank.Bank; 8 | import org.dreambot.api.methods.interactive.GameObjects; 9 | import org.dreambot.api.methods.interactive.NPCs; 10 | import org.dreambot.api.methods.interactive.Players; 11 | import org.dreambot.api.methods.map.Tile; 12 | import org.dreambot.api.methods.skills.Skill; 13 | import org.dreambot.api.methods.skills.SkillTracker; 14 | import org.dreambot.api.methods.skills.Skills; 15 | import org.dreambot.api.methods.walking.impl.Walking; 16 | import org.dreambot.api.script.AbstractScript; 17 | import org.dreambot.api.script.Category; 18 | import org.dreambot.api.script.ScriptManifest; 19 | import org.dreambot.api.utilities.Timer; 20 | import org.dreambot.api.wrappers.interactive.Entity; 21 | import org.dreambot.api.wrappers.items.Item; 22 | 23 | import java.awt.*; 24 | 25 | 26 | @ScriptManifest(author = "Nezz", description = "Thieves stuff", name = "DreamBot Thiever", version = 0, category = Category.THIEVING) 27 | public class Thiever extends AbstractScript { 28 | 29 | ScriptVars sv = new ScriptVars(); 30 | Tile startTile; 31 | State state; 32 | Timer timer; 33 | boolean started = false; 34 | private Entity stealFrom = null; 35 | 36 | private enum State { 37 | STEAL, DROP, HEAL, BANK 38 | } 39 | 40 | private State getState() { 41 | if (healthPerc() < 50) { 42 | return State.HEAL; 43 | } 44 | if (containsOneOf(sv.yourThieving.getDropItems())) { 45 | return State.DROP; 46 | } 47 | if (Inventory.isFull()) { 48 | return State.BANK; 49 | } 50 | return State.STEAL; 51 | } 52 | 53 | private int healthPerc() { 54 | int currHealth = Skills.getBoostedLevel(Skill.HITPOINTS); 55 | int maxHealth = Skills.getRealLevel(Skill.HITPOINTS); 56 | return ((currHealth * 100) / maxHealth); 57 | } 58 | 59 | private boolean containsOneOf(String... itemNames) { 60 | for (String name : itemNames) { 61 | if (name != null && Inventory.contains(name)) 62 | return true; 63 | } 64 | return false; 65 | } 66 | 67 | @Override 68 | public void onStart() { 69 | thieverGui gui = new thieverGui(sv); 70 | gui.setVisible(true); 71 | while (!sv.started) { 72 | sleep(300); 73 | } 74 | SkillTracker.start(Skill.THIEVING); 75 | startTile = Players.getLocal().getTile(); 76 | timer = new Timer(); 77 | started = true; 78 | log("Starting silk thiever!"); 79 | } 80 | 81 | @Override 82 | public int onLoop() { 83 | state = getState(); 84 | log("" + state); 85 | switch (state) { 86 | case DROP: 87 | for (int i = 0; i < 28; i++) { 88 | Item item = Inventory.getItemInSlot(i); 89 | if (item != null) { 90 | for (String name : sv.yourThieving.getDropItems()) { 91 | if (name != null && name.equals(item.getName())) { 92 | Inventory.slotInteract(i, "Drop"); 93 | sleep(200, 400); 94 | break; 95 | } 96 | } 97 | } 98 | } 99 | if (stealFrom != null) { 100 | Mouse.move(stealFrom); 101 | } 102 | sleep(300, 600); 103 | break; 104 | case STEAL: 105 | log(sv.yourThieving.getName()); 106 | stealFrom = NPCs.closest(sv.yourThieving.getName()); 107 | if (stealFrom == null) { 108 | stealFrom = GameObjects.closest(sv.yourThieving.getName()); 109 | } 110 | if (stealFrom != null && Players.getLocal().getAnimation() == -1 && stealFrom.isOnScreen()) { 111 | log("Thieving!"); 112 | stealFrom.interact(sv.yourThieving.getAction()); 113 | sleep(300, 500); 114 | } else { 115 | if (startTile.distance(Players.getLocal()) > 10) { 116 | Walking.walk(startTile); 117 | sleep(300, 600); 118 | } else { 119 | sleep(300, 600); 120 | } 121 | } 122 | 123 | break; 124 | case BANK: 125 | if (Bank.isOpen()) { 126 | Bank.depositAllItems(); 127 | sleep(300, 600); 128 | } else { 129 | if (sv.yourBank.getCenter().distance(Players.getLocal()) > 10) { 130 | Walking.walk(sv.yourBank.getCenter()); 131 | sleep(300, 600); 132 | } else { 133 | Bank.open(sv.yourBank); 134 | sleep(300, 600); 135 | } 136 | } 137 | break; 138 | case HEAL: 139 | for (int i = 0; i < 28; i++) { 140 | Item item = Inventory.getItemInSlot(i); 141 | if (item != null && item.hasAction("Eat")) { 142 | Inventory.slotInteract(i, "Eat"); 143 | sleep(600, 900); 144 | break; 145 | } 146 | } 147 | break; 148 | } 149 | return 1; 150 | } 151 | 152 | @Override 153 | public void onExit() { 154 | log("Stopping silk thiever!"); 155 | } 156 | 157 | public void onPaint(Graphics g) { 158 | if (started) { 159 | g.drawString("Experience gained(p/h): " + SkillTracker.getGainedExperience(Skill.THIEVING) + "(" + SkillTracker.getGainedExperiencePerHour(Skill.THIEVING) + ")", 5, 90); 160 | g.drawString("Level(gained): " + Skills.getRealLevel(Skill.THIEVING) + "(" + SkillTracker.getGainedLevels(Skill.THIEVING) + ")", 5, 105); 161 | g.drawString("Runtime: " + timer.formatTime(), 5, 120); 162 | if (state != null) 163 | g.drawString("State: " + state, 5, 135); 164 | } 165 | 166 | } 167 | 168 | } 169 | -------------------------------------------------------------------------------- /DreambotThiever/src/nezz/dreambot/thiever/enums/Thieving.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.thiever.enums; 2 | 3 | public enum Thieving { 4 | MAN("Man", "Pickpocket"), 5 | TEA_STALL("Tea stall", "Steal-from", "Cup of tea"), 6 | SILK_STALL("Silk stall", "Steal-from", "Silk"), 7 | BAKERS_STALL("Baker's stall", "Steal-from"), 8 | MASTER_FARMER("Master Farmer", "Pickpocket"); 9 | 10 | private final String npcName; 11 | private final String action; 12 | private final String[] dropItems; 13 | 14 | Thieving(String npcName, String action, String... dropItems) { 15 | this.npcName = npcName; 16 | this.action = action; 17 | this.dropItems = dropItems; 18 | } 19 | 20 | public String getName() { 21 | return this.npcName; 22 | } 23 | 24 | public String getAction() { 25 | return this.action; 26 | } 27 | 28 | public String[] getDropItems() { 29 | return this.dropItems; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /DreambotThiever/src/nezz/dreambot/thiever/gui/ScriptVars.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.thiever.gui; 2 | 3 | import org.dreambot.api.methods.container.impl.bank.BankLocation; 4 | 5 | import nezz.dreambot.thiever.enums.Thieving; 6 | 7 | 8 | public class ScriptVars { 9 | public Thieving yourThieving; 10 | public BankLocation yourBank; 11 | public boolean started = false; 12 | } 13 | -------------------------------------------------------------------------------- /DreambotThiever/src/nezz/dreambot/thiever/gui/thieverGui.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.thiever.gui; 2 | 3 | import javax.swing.JFrame; 4 | import javax.swing.JPanel; 5 | import javax.swing.border.EmptyBorder; 6 | 7 | import java.awt.Toolkit; 8 | 9 | import javax.swing.JLabel; 10 | import javax.swing.JComboBox; 11 | import javax.swing.DefaultComboBoxModel; 12 | import javax.swing.JButton; 13 | 14 | import org.dreambot.api.methods.container.impl.bank.BankLocation; 15 | 16 | import java.awt.event.ActionListener; 17 | import java.awt.event.ActionEvent; 18 | import java.awt.Color; 19 | 20 | import nezz.dreambot.thiever.enums.Thieving; 21 | 22 | 23 | public class thieverGui extends JFrame { 24 | 25 | /** 26 | * 27 | */ 28 | private static final long serialVersionUID = 1L; 29 | private JPanel contentPane; 30 | JComboBox comboBox_1 = new JComboBox(); 31 | JComboBox comboBox = new JComboBox(); 32 | 33 | 34 | public thieverGui(final ScriptVars var) { 35 | setTitle("DreamBot Pack Buyer"); 36 | setIconImage(Toolkit.getDefaultToolkit().getImage(thieverGui.class.getResource("/javax/swing/plaf/metal/icons/ocean/computer.gif"))); 37 | setAlwaysOnTop(true); 38 | setResizable(false); 39 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 40 | setBounds(100, 100, 276, 167); 41 | contentPane = new JPanel(); 42 | contentPane.setBackground(Color.WHITE); 43 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 44 | setContentPane(contentPane); 45 | contentPane.setLayout(null); 46 | 47 | JPanel panel = new JPanel(); 48 | panel.setBounds(0, 0, 270, 101); 49 | contentPane.add(panel); 50 | panel.setLayout(null); 51 | 52 | JLabel lblYourThieving = new JLabel("Your Thieving:"); 53 | lblYourThieving.setBounds(10, 11, 72, 14); 54 | panel.add(lblYourThieving); 55 | 56 | comboBox.setModel(new DefaultComboBoxModel(Thieving.values())); 57 | comboBox.setBounds(92, 8, 168, 20); 58 | panel.add(comboBox); 59 | 60 | JLabel lblYourBank = new JLabel("Your Bank:"); 61 | lblYourBank.setBounds(10, 36, 72, 14); 62 | panel.add(lblYourBank); 63 | 64 | comboBox_1.setModel(new DefaultComboBoxModel(BankLocation.values())); 65 | comboBox_1.setBounds(92, 33, 168, 20); 66 | panel.add(comboBox_1); 67 | 68 | JButton btnNewButton = new JButton("Start!"); 69 | btnNewButton.addActionListener(new ActionListener() { 70 | public void actionPerformed(ActionEvent arg0) { 71 | var.yourBank = BankLocation.values()[comboBox_1.getSelectedIndex()]; 72 | var.yourThieving = Thieving.values()[comboBox.getSelectedIndex()]; 73 | var.started = true; 74 | dispose(); 75 | } 76 | }); 77 | btnNewButton.setBounds(0, 101, 270, 34); 78 | contentPane.add(btnNewButton); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /DreambotTutIsland/src/nezz/dreambot/filemethods/FileMethods.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.filemethods; 2 | 3 | import java.io.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | 8 | public class FileMethods { 9 | private BufferedReader in; 10 | private BufferedWriter out; 11 | private String filepath; 12 | private String scriptName; 13 | 14 | public FileMethods(String scriptName){ 15 | this(scriptName, false); 16 | } 17 | public FileMethods(String filePath, boolean force){ 18 | if(force){ 19 | this.filepath = filePath+System.getProperty("file.separator"); 20 | } 21 | else{ 22 | this.filepath = System.getProperty("scripts.path"); 23 | //this.filepath = "C:\\Users\\Public\\Nezz\\"; 24 | this.scriptName = filePath; 25 | this.filepath+=scriptName + System.getProperty("file.separator"); 26 | System.out.println("FILE PATH: " + filepath); 27 | } 28 | } 29 | 30 | public void writeFile(String[] toWrite, String filename){ 31 | filename+=".txt"; 32 | try { 33 | File theDir = new File(filepath); 34 | // if the directory does not exist, create it 35 | if (!theDir.exists()) { 36 | boolean result = theDir.mkdirs(); 37 | if(result) { 38 | System.out.println("DIR created"); 39 | } 40 | } 41 | out = new BufferedWriter(new FileWriter(filepath+filename)); 42 | //Write out the specified string to the file 43 | for(int i = 0; i < toWrite.length; i++){ 44 | if(i != toWrite.length - 1){ 45 | out.write(toWrite[i]); 46 | out.newLine(); 47 | } 48 | else{ 49 | out.write(toWrite[i]); 50 | } 51 | } 52 | //flushes and closes the stream 53 | out.close(); 54 | }catch(IOException e){ 55 | System.out.println("There was a problem:" + e); 56 | } 57 | 58 | } 59 | 60 | public void writeFile(List toWrite, String filename){ 61 | filename+=".txt"; 62 | try { 63 | File theDir = new File(filepath); 64 | // if the directory does not exist, create it 65 | if (!theDir.exists()) { 66 | boolean result = theDir.mkdirs(); 67 | if(result) { 68 | System.out.println("DIR created"); 69 | } 70 | } 71 | out = new BufferedWriter(new FileWriter(filepath+filename)); 72 | //Write out the specified string to the file 73 | for(int i = 0; i < toWrite.size(); i++){ 74 | if(i != toWrite.size() - 1){ 75 | out.write(toWrite.get(i)); 76 | out.newLine(); 77 | } 78 | else{ 79 | out.write(toWrite.get(i)); 80 | } 81 | } 82 | //flushes and closes the stream 83 | out.close(); 84 | }catch(IOException e){ 85 | System.out.println("There was a problem:" + e); 86 | } 87 | 88 | } 89 | 90 | public String readFile(String filename){ 91 | filename+=".txt"; 92 | String tempFinder = ""; 93 | try { 94 | in = new BufferedReader(new FileReader(filepath+filename)); 95 | String temp = in.readLine(); 96 | while(temp != null){ 97 | tempFinder+=temp; 98 | temp = in.readLine(); 99 | if(temp != null) 100 | tempFinder+="\n"; 101 | } 102 | in.close(); 103 | }catch(IOException e){ 104 | System.out.println("There was a problem:" + e); 105 | } 106 | return tempFinder; 107 | } 108 | 109 | public String[] readFileArray(String filename){ 110 | filename+=".txt"; 111 | List fileContents = new ArrayList(); 112 | try { 113 | in = new BufferedReader(new FileReader(filepath+filename)); 114 | String temp = in.readLine(); 115 | while(temp != null){ 116 | if(temp.length() > 0){ 117 | fileContents.add(temp.trim()); 118 | } 119 | temp = in.readLine(); 120 | } 121 | in.close(); 122 | }catch(IOException e){ 123 | System.out.println("There was a problem:" + e); 124 | } 125 | return fileContents.toArray(new String[fileContents.size()]); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /DreambotTutIsland/src/nezz/dreambot/tutisland/gui/ScriptVars.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.tutisland.gui; 2 | 3 | public class ScriptVars { 4 | public String baseName = ""; 5 | public String finalName = ""; 6 | public String email = ""; 7 | public String pass = ""; 8 | public String age = ""; 9 | public boolean started = false; 10 | } 11 | -------------------------------------------------------------------------------- /DreambotTutIsland/src/nezz/dreambot/tutisland/gui/tutIslandGui.java: -------------------------------------------------------------------------------- 1 | package nezz.dreambot.tutisland.gui; 2 | 3 | import javax.swing.JFrame; 4 | import javax.swing.JPanel; 5 | import javax.swing.border.EmptyBorder; 6 | 7 | import java.awt.Toolkit; 8 | 9 | import javax.swing.JButton; 10 | 11 | import java.awt.event.ActionListener; 12 | import java.awt.event.ActionEvent; 13 | import java.awt.Color; 14 | import javax.swing.JTextField; 15 | 16 | public class tutIslandGui extends JFrame { 17 | 18 | /** 19 | * 20 | */ 21 | private static final long serialVersionUID = 1L; 22 | private JPanel contentPane; 23 | private JTextField userNameField; 24 | private JTextField passwordField; 25 | private JTextField ageField; 26 | 27 | 28 | public tutIslandGui(final ScriptVars var) { 29 | setTitle("DreamBot Tutorial Island"); 30 | setIconImage(Toolkit.getDefaultToolkit().getImage(tutIslandGui.class.getResource("/javax/swing/plaf/metal/icons/ocean/computer.gif"))); 31 | setAlwaysOnTop(true); 32 | setResizable(false); 33 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 34 | setBounds(100, 100, 276, 167); 35 | contentPane = new JPanel(); 36 | contentPane.setBackground(Color.WHITE); 37 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 38 | setContentPane(contentPane); 39 | contentPane.setLayout(null); 40 | 41 | JPanel panel = new JPanel(); 42 | panel.setBounds(0, 0, 270, 101); 43 | contentPane.add(panel); 44 | panel.setLayout(null); 45 | 46 | userNameField = new JTextField(); 47 | userNameField.setText("userName"); 48 | userNameField.setBounds(10, 11, 86, 20); 49 | panel.add(userNameField); 50 | userNameField.setColumns(10); 51 | 52 | passwordField = new JTextField(); 53 | passwordField.setText("smd1234"); 54 | passwordField.setBounds(106, 11, 86, 20); 55 | panel.add(passwordField); 56 | passwordField.setColumns(10); 57 | 58 | ageField = new JTextField(); 59 | ageField.setText("20"); 60 | ageField.setBounds(202, 11, 58, 20); 61 | panel.add(ageField); 62 | ageField.setColumns(10); 63 | 64 | JButton btnNewButton = new JButton("Start!"); 65 | btnNewButton.addActionListener(new ActionListener() { 66 | public void actionPerformed(ActionEvent arg0) { 67 | var.baseName = userNameField.getText(); 68 | var.pass = passwordField.getText(); 69 | var.age = ageField.getText(); 70 | var.started = true; 71 | dispose(); 72 | } 73 | }); 74 | btnNewButton.setBounds(0, 101, 270, 34); 75 | contentPane.add(btnNewButton); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DreamBot 2 | Dreambot scripts 3 | --------------------------------------------------------------------------------