Guest User

Untitled

a guest
Jul 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.90 KB | None | 0 0
  1. //AIOWcer V0.1
  2.  
  3. import java.awt.*;
  4. import java.util.Map;
  5.  
  6. import org.rsbot.event.events.ServerMessageEvent;
  7. import org.rsbot.event.listeners.PaintListener;
  8. import org.rsbot.event.listeners.ServerMessageListener;
  9. import org.rsbot.script.Script;
  10. import org.rsbot.script.wrappers.RSObject;
  11. import org.rsbot.script.wrappers.RSTile;
  12.  
  13. @org.rsbot.script.ScriptManifest(authors = { "Indaface" }, category = "Woodcutting", name = "aio Wcer", version = 0.1, description = "<html><head></head><body bgcolor='#222222'><center><table><tr><td width='350' valign='top'><center><div style='font-family:Calibri, Arial;color:#FF3300; font-size:36px'>aioWcer</div><div style='font-family:Calibri, Arial;color:#FFFFFF; font-size:16px'>v0.1 by Indaface <br /></a></div><div style='font-family:Calibri, Arial;color:#FF3300; font-size:16px'>Quick Select</div><div><table bordercolor='#FF3300' border='1' cellpadding='0' cellspacing='0' ><tr><td align='center' style='font-family:Calibri, Arial;color:#FFFFFF; font-size:12px'><b>Tree Locations</b> <br /><select name='trees'><option>WestVarrock RegularLogs<option>EastVarrock Oaks<option>Draynor Willows</select>")
  14. public class AIOWcer extends Script implements PaintListener, ServerMessageListener {
  15.  
  16. public enum actions {
  17. WALKING_TO_TREES, CHOPPING, BANKING, WALKING_TO_BANK, WAIT //add pickup nests and dropping in future update
  18. }
  19.  
  20. private static final actions WAIT = null;
  21.  
  22. public String bankAt = "";
  23. public String chopAt = "";
  24. public long startTime = System.currentTimeMillis();
  25. public int[] axes = { 1349, 1351, 1353, 1355, 1357, 1359, 1361, 6739 };
  26. public int[] treeID;
  27. public int[] logsID = { 1511, 1521, 1519 };
  28. public int StartingExp;
  29. public int ExpGained;
  30.  
  31. public int[] bankBooths = {2213};
  32. public int[] nestIDs = { 5070, 5071, 5072, 5073, 5074, 5075, 7413 };
  33.  
  34. public RSTile[] toBank, toTrees;
  35. public int price;
  36. public int profit;
  37. public int nestzFound;
  38. public int cut;
  39. public int startExp;
  40.  
  41. public int[] NormalTree = { 5004, 5005, 5045, 3879, 3881, 3882, 3883,
  42. 3885, 3886, 3887, 3888, 3889, 3890, 3891, 3892, 3893, 3928, 3967,
  43. 3968, 4048, 4049, 4050, 4051, 4052, 4053, 4054, 3033, 3034, 3035,
  44. 3036, 2409, 2447, 2448, 1330, 1331, 1332, 1310, 1305, 1304, 1303,
  45. 1301, 1276, 1277, 1278, 1279, 1280, 8742, 8743, 8973, 8974, 1315,
  46. 1316 };
  47.  
  48. public int[] OakTree = { 1281, 3037, 8462, 8463, 8464, 8465, 8466, 8467 };
  49.  
  50. public int[] WillowTree = { 1308, 5551, 5552, 5553, 8481, 8482, 8483,
  51. 8484, 8485, 8486, 8487, 8488 };
  52.  
  53. public int[] YewTree = { 1309, 8503, 8504, 8505, 8506, 8507, 8508, 8509,
  54. 8510, 8511, 8512, 8513 };
  55.  
  56. // /////////LOCATIONS///////////////
  57. public boolean onStart(Map<String, String> args) {
  58. log("aioWcer Initialized!");
  59. log("I hope you Enjoy the script");
  60. log("Check my thread to make sure that your version of this script is up to date..");
  61.  
  62. if (args.get("trees").equals("WestVarrock RegularLogs")) {
  63. bankAt = "WestVarrock Bank";
  64. chopAt = "WestVarrock RegularLogs";
  65. price = 36;
  66. logsID = new int[] { 1511 };
  67. treeID = new int[] { 1278 };
  68. toTrees = new RSTile[] { new RSTile(3184, 3444),
  69. new RSTile(3173, 3456), new RSTile(3157, 3459) };
  70. toBank = reversePath(toTrees);
  71. }
  72.  
  73. if (args.get("trees").equals("EastVarrock Oaks")) {
  74. //bankAt = ""
  75. //chopAT = ""
  76. price = 48;
  77. logsID = new int[] { 1521 };
  78. treeID = new int[] { 1281 };
  79. toTrees = new RSTile[] { new RSTile(3175, 3451),
  80. new RSTile(3160, 3455)};
  81. toBank = new RSTile[] { new RSTile(3160, 3455),
  82. new RSTile(3175, 3450), new RSTile(3185, 3443)};
  83. }
  84.  
  85. if (args.get("trees").equals("Draynor Willows")) {
  86. bankAt = "Draynor Bank";
  87. chopAt = "Draynor Willows";
  88. price = 8;
  89. logsID = new int[] { 1519 };
  90. treeID = new int[] { 5553, 5551, 5552 };
  91. toTrees = new RSTile[] { new RSTile(3087, 3243), new RSTile(3087, 3235)};
  92. toBank = new RSTile[] { new RSTile(3087, 3242), new RSTile(3094, 3243)};
  93. }
  94. return true;
  95. }
  96.  
  97. public void serverMessageRecieved(ServerMessageEvent e) {
  98. String message = e.getMessage();
  99. if (message.contains("YOU GET SOME LOGS")) {
  100. cut += 1;
  101. }
  102. }
  103.  
  104. public actions getAction() {
  105. if(inArea(bankAt) && !inventoryContains(logsID) && !bank.isOpen()) {
  106. return actions.WALKING_TO_TREES;
  107. }
  108. if(inArea(bankAt) && isInventoryFull()) {
  109. return actions.BANKING;
  110. }
  111. if(inArea(chopAt) && isInventoryFull() && !inArea(bankAt)) {
  112. return actions.WALKING_TO_BANK;
  113. }
  114. if(inArea(chopAt) && !getMyPlayer().isMoving() && !isInventoryFull()) {
  115. return actions.CHOPPING;
  116. }
  117. return WAIT;
  118. }
  119.  
  120. ///////LOOP/////////
  121. public int loop() {
  122. if(!isRunning() && getEnergy() > random(60,80)) {
  123. setRun(true);
  124. }
  125.  
  126. actions act = getAction();
  127. switch (act) {
  128. case WALKING_TO_TREES:
  129. walkPathMM(toTrees);
  130. break;
  131. case WALKING_TO_BANK:
  132. walkPathMM(toBank);
  133. break;
  134. case BANKING:
  135. walkPathMM(toBank);
  136. if(!bank.isOpen()) {
  137. RSObject bankBooth = getNearestObjectByID(bankBooths);
  138. if(bankBooth != null) {
  139. atObject(bankBooth, "se-Quickly");
  140. return random(500, 1000);
  141. }
  142. }
  143. if(bank.isOpen()) {
  144. bank.depositAllExcept(axes);
  145. bank.close();
  146. return random(400, 600);
  147. }
  148. break;
  149. case CHOPPING:
  150.  
  151. if (getMyPlayer().getAnimation() != 867) {
  152. RSObject tree = getNearestObjectByID(treeID);
  153. if(tree != null) {
  154. atTree(tree, "chop");
  155. if(treeID == null){
  156. log("Cannot find tree to chop. Hold on gimme a second");
  157. return (random(500,1000));
  158. }
  159. if (treeID == null) {
  160. log("Tree is null");
  161. return 500;
  162. }
  163. }
  164. }
  165. }
  166. return(random(500, 1000));
  167. }
  168.  
  169. public boolean CHOPPING() {
  170. if(treeID == null);
  171. return (false);
  172. }
  173.  
  174. public void continueWalk(RSTile[] path) {
  175. if(!getMyPlayer().isMoving() && distanceTo(getDestination()) <= random(3, 6)) {
  176. walkPathMM(randomizePath(path, 2, 2));
  177. }
  178. }
  179.  
  180. public boolean inArea(String area) {
  181.  
  182. int x = getMyPlayer().getLocation().getX();
  183. int y = getMyPlayer().getLocation().getY();
  184. if(area.equals("Draynor Bank")) {
  185. return x >= 3092 && x <= 3097 && y >= 3240 && y <= 3245;
  186. }
  187.  
  188. if(area.equals("Draynor Willows")) {
  189. return x >= 3081 && x <= 3091 && y >= 3226 && y <= 3238;
  190. }
  191.  
  192. if(area.equals("WestVarrock Bank")) {
  193. return x >= 3182 && x <= 3188 && y >= 3436 && y <= 3445;
  194. }
  195.  
  196. if(area.equals("WestVarrock RegularLogs")) {
  197. return x >= 3149 && x <= 3159 && y >= 3150 && y <= 3461;
  198. }
  199.  
  200. return x >= 1 && x <= 1 && y >= 1 && y <= 1;
  201. }
  202.  
  203. public void onFinish(){
  204. log("Thank you for choosing AIOWcer. I hope you enjoyed it.");
  205. }
  206.  
  207. public void onRepaint(Graphics render) {
  208. if (isLoggedIn()) {
  209.  
  210. render.setColor(new Color(128, 0, 128));
  211.  
  212. long millis = System.currentTimeMillis() - startTime;
  213. long hours = millis / (1000 * 60 * 60);
  214. millis -= hours * (1000 * 60 * 60);
  215. long minutes = millis / (1000 * 60);
  216. millis -= minutes * (1000 * 60);
  217. long seconds = millis / 1000;
  218.  
  219. render.drawString("Time Running: " + hours + ":" + minutes + ":"
  220. + seconds, 240, 356);
  221.  
  222. if (StartingExp == 0) {
  223. StartingExp = skills.getCurrentSkillExp(STAT_WOODCUTTING);
  224. ExpGained = skills.getCurrentSkillExp(STAT_WOODCUTTING);
  225. }
  226.  
  227. render.setColor(new Color(255, 0, 0));
  228. render.drawString("Exp Gained: ", ExpGained, ExpGained);
  229. }
  230. }
  231. }
  232.  
  233. //GUI
  234. /****************************************************************/
  235. /* GUI */
  236. /* */
  237. /****************************************************************/
  238. import java.awt.*;
  239. import java.awt.event.*;
  240. import java.util.*;
  241. import javax.swing.*;
  242. import javax.swing.event.*;
  243. /**
  244. * Summary description for GUI
  245. *
  246. */
  247. public class GUI extends JFrame
  248. {
  249. // Variables declaration
  250. private JLabel jLabel1;
  251. private JTextArea jTextArea1;
  252. private JList jList1;
  253. private JScrollPane jScrollPane1;
  254. private JButton Start;
  255. private JPanel contentPane;
  256. // End of variables declaration
  257.  
  258.  
  259. public GUI()
  260. {
  261. super();
  262. initializeComponent();
  263. //
  264. // TODO: Add any constructor code after initializeComponent call
  265. //
  266.  
  267. this.setVisible(true);
  268. }
  269.  
  270. /**
  271. * This method is called from within the constructor to initialize the form.
  272. * WARNING: Do NOT modify this code. The content of this method is always regenerated
  273. * by the Windows Form Designer. Otherwise, retrieving design might not work properly.
  274. * Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
  275. * to retrieve your design properly in future, before revising this method.
  276. */
  277. @SuppressWarnings("unchecked")
  278. private void initializeComponent()
  279. {
  280. ArrayList arr;
  281.  
  282. jLabel1 = new JLabel();
  283. jTextArea1 = new JTextArea();
  284. jList1 = new JList();
  285. jScrollPane1 = new JScrollPane();
  286. Start = new JButton();
  287. contentPane = (JPanel)this.getContentPane();
  288.  
  289. //
  290. // jLabel1
  291. //
  292. jLabel1.setText(" Place and TreeType");
  293. //
  294. // jTextArea1
  295. //
  296. jTextArea1.setText(" -Thank you for using AIOWcer!\n -Please post any problems that you have with this script\n on my thread.\n -Please choose Place and TreeType below in which you want\n to cut below");
  297. //
  298. // jList1
  299. //
  300. arr = new ArrayList();
  301. arr.add("WestVarrock RegularLogs");
  302. arr.add("EastVarrock Oaks");
  303. arr.add("Draynor Willows");
  304. jList1.setListData(arr.toArray());
  305. jList1.addListSelectionListener(new ListSelectionListener() {
  306. public void valueChanged(ListSelectionEvent e)
  307. {
  308. jList1_valueChanged(e);
  309. }
  310.  
  311. });
  312. //
  313. // jScrollPane1
  314. //
  315. jScrollPane1.setViewportView(jList1);
  316. //
  317. // Start
  318. //
  319. Start.setText("Start");
  320. Start.addActionListener(new ActionListener() {
  321. public void actionPerformed(ActionEvent e)
  322. {
  323. Start_actionPerformed(e);
  324. }
  325.  
  326. });
  327. //
  328. // contentPane
  329. //
  330. contentPane.setLayout(null);
  331. addComponent(contentPane, jLabel1, 152,108,139,18);
  332. addComponent(contentPane, jTextArea1, 8,5,433,91);
  333. addComponent(contentPane, jScrollPane1, 153,130,139,60);
  334. addComponent(contentPane, Start, 354,238,83,28);
  335. //
  336. // AIOWcer
  337. //
  338. this.setTitle("AIOWcer - extends JFrame");
  339. this.setLocation(new Point(0, 0));
  340. this.setSize(new Dimension(465, 311));
  341. }
  342.  
  343. /** Add Component Without a Layout Manager (Absolute Positioning) */
  344. private void addComponent(Container container,Component c,int x,int y,int width,int height)
  345. {
  346. c.setBounds(x,y,width,height);
  347. container.add(c);
  348. }
  349.  
  350. //
  351. // TODO: Add any appropriate code in the following Event Handling Methods
  352. //
  353. private void jList1_valueChanged(ListSelectionEvent e)
  354. {
  355. System.out.println("\njList1_valueChanged(ListSelectionEvent e) called.");
  356. if(!e.getValueIsAdjusting())
  357. {
  358. Object o = jList1.getSelectedValue();
  359. System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
  360. // TODO: Add any handling code here for the particular object being selected
  361.  
  362. }
  363. }
  364.  
  365. private void Start_actionPerformed(ActionEvent e)
  366. {
  367. System.out.println("\nStart_actionPerformed(ActionEvent e) called.");
  368. // TODO: Add any handling code here
  369.  
  370. }
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395. //============================= Testing ================================//
  396. //= =//
  397. //= The following main method is just for testing this class you built.=//
  398. //= After testing,you may simply delete it. =//
  399. //======================================================================//
  400. public static void main(String[] args)
  401. {
  402. JFrame.setDefaultLookAndFeelDecorated(true);
  403. JDialog.setDefaultLookAndFeelDecorated(true);
  404. try
  405. {
  406. UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
  407. }
  408. catch (Exception ex)
  409. {
  410. System.out.println("Failed loading L&F: ");
  411. System.out.println(ex);
  412. }
  413. new AIOWcer();
  414. }
  415. //= End of Testing =
  416.  
  417.  
  418. }
Add Comment
Please, Sign In to add comment