Advertisement
Guest User

Untitled

a guest
May 18th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. /**
  2. * Created by Adam on 5/16/2017.
  3. */
  4.  
  5. import org.osbot.rs07.api.filter.AreaFilter;
  6. import org.osbot.rs07.api.filter.NameFilter;
  7. import org.osbot.rs07.api.map.Area;
  8. import org.osbot.rs07.api.map.constants.Banks;
  9. import org.osbot.rs07.script.Script;
  10. import org.osbot.rs07.script.ScriptManifest;
  11. import org.osbot.rs07.utility.ConditionalSleep;
  12.  
  13. import javax.swing.*;
  14. import java.awt.*;
  15. import java.awt.event.ActionEvent;
  16. import java.awt.event.ActionListener;
  17.  
  18.  
  19. @ScriptManifest(name = "WoodCutter", author = "Mechagoober", version = 1.0, info = "", logo = "")
  20.  
  21.  
  22. public class WoodCutter extends Script {
  23.  
  24.  
  25.  
  26.  
  27. Banking banking = new Banking();
  28.  
  29. State state;
  30.  
  31. Area area = new Area(3274, 3436, 3288, 3409);
  32. Area bank = new Area(3250, 3423, 3257, 3419);
  33. String tree = new String();
  34.  
  35. boolean startScript = false;
  36.  
  37. public enum State {
  38. Bank, Chop, Drop, Walk
  39. }
  40.  
  41.  
  42. public State getState() {
  43. switch (state) {
  44.  
  45. case Bank:
  46. if (inventory.isFull()) {
  47. banking.bank();
  48. return State.Bank;
  49. }
  50.  
  51. case Walk:
  52. if (!area.contains(myPlayer()) && !inventory.isFull()) ;
  53.  
  54.  
  55. return State.Walk;
  56.  
  57. case Chop:
  58. if ((area.contains(myPlayer())) && (!inventory.isFull()) && !myPlayer().isAnimating() && area.contains(getObjects().closest("Tree"))) {
  59. cutTree();
  60. }
  61. }
  62. return State.Chop;
  63. }
  64.  
  65.  
  66. @Override
  67.  
  68.  
  69. public void onStart() {
  70.  
  71.  
  72.  
  73.  
  74.  
  75. //Code here will execute before the loop is started
  76.  
  77.  
  78. }
  79.  
  80.  
  81. @Override
  82.  
  83.  
  84. public void onExit() {
  85.  
  86.  
  87. //Code here will execute after the script ends
  88.  
  89.  
  90. }
  91.  
  92.  
  93. @Override
  94.  
  95.  
  96. public int onLoop() {
  97.  
  98. if (startScript == true) {
  99.  
  100. getState();
  101.  
  102.  
  103. }
  104.  
  105. return 100; //The amount of time in milliseconds before the loop starts over
  106.  
  107.  
  108. }
  109.  
  110. public void walk() {
  111. if ((inventory.isEmptyExcept("Bronze axe")) && (!area.contains(myPlayer()))) {
  112. getWalking().webWalk(area);
  113. }
  114. }
  115.  
  116.  
  117. public void bank() {
  118.  
  119.  
  120. while (inventory.isFull() && !bank.contains(myPlayer())) {
  121. getWalking().webWalk(Banks.VARROCK_EAST);
  122. }
  123. if (inventory.isFull() && bank.contains(myPlayer())) {
  124. objects.closest(new NameFilter<>("Bank booth"), new AreaFilter<>(Banks.VARROCK_EAST)).interact("Bank");
  125.  
  126. new ConditionalSleep(5000, 1000) {
  127.  
  128. @Override
  129. public boolean condition() throws InterruptedException {
  130. return objects.closest("Bank booth").interact("Bank");
  131. }
  132. }.sleep();
  133. }
  134. }
  135.  
  136.  
  137. public void cutTree() {
  138. if ((area.contains(myPlayer())) && (!inventory.isFull()) && !myPlayer().isAnimating() && area.contains(getObjects().closest("Tree"))) {
  139. objects.closest(new NameFilter<>("Tree"), new AreaFilter<>(area)).interact("Chop down");
  140. new AreaFilter<>(area);
  141.  
  142. new ConditionalSleep(5000, 600) {
  143. @Override
  144. public boolean condition() throws InterruptedException {
  145. return objects.closest("Tree").interact("Chop down");
  146. }
  147. }.sleep();
  148.  
  149. }
  150. }
  151.  
  152.  
  153. @Override
  154.  
  155.  
  156. public void onPaint(Graphics2D g) {
  157.  
  158.  
  159. //This is where you will put your code for paint(s)
  160.  
  161.  
  162. }
  163.  
  164. public void createGUI() {
  165. JFrame frame = new JFrame();
  166. frame.setSize(600, 400);
  167.  
  168.  
  169. JPanel panel = new JPanel(new GridBagLayout());
  170.  
  171. JCheckBox c1 = new JCheckBox("Tree");
  172. JCheckBox c2 = new JCheckBox("Oak");
  173. JButton start = new JButton("Start");
  174.  
  175. c1.addActionListener(new ActionListener() {
  176.  
  177. @Override
  178. public void actionPerformed(ActionEvent e) {
  179. // tree = "Tree";
  180. }
  181. });
  182.  
  183. c2.addActionListener(new ActionListener() {
  184. @Override
  185. public void actionPerformed(ActionEvent e) {
  186. // tree = "Oak";
  187. }
  188. });
  189. start.addActionListener(new ActionListener() {
  190. @Override
  191. public void actionPerformed(ActionEvent e) {
  192. frame.dispose();
  193. // startScript = true;
  194.  
  195. }
  196. });
  197.  
  198. GridBagConstraints c = new GridBagConstraints();
  199.  
  200.  
  201. c.insets = new Insets(10, 10, 10, 10);
  202. c.gridx = 0;
  203. c.gridy = 1;
  204. panel.add(c1, c);
  205. c.gridx = 0;
  206. c.gridy = 2;
  207. panel.add(c2, c);
  208. c.gridx = 0;
  209. c.gridy = 3;
  210. panel.add(start, c);
  211.  
  212.  
  213. frame.add(panel);
  214. frame.pack();
  215.  
  216. frame.setVisible(true);
  217.  
  218. }
  219. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement