Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.32 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Point;
  5. import java.awt.Rectangle;
  6. import java.awt.image.BufferedImage;
  7. import org.rsbot.event.listeners.PaintListener;
  8. import org.rsbot.script.Script;
  9. import org.rsbot.script.ScriptManifest;
  10. import org.rsbot.script.methods.Calculations;
  11. import org.rsbot.script.methods.Interfaces;
  12. import org.rsbot.script.methods.Inventory;
  13. import org.rsbot.script.methods.Keyboard;
  14. import org.rsbot.script.methods.Mouse;
  15. import org.rsbot.script.methods.NPCs;
  16. import org.rsbot.script.methods.Objects;
  17. import org.rsbot.script.methods.Skills;
  18. import org.rsbot.script.methods.Walking;
  19. import org.rsbot.script.util.Timer;
  20. import org.rsbot.script.wrappers.RSComponent;
  21. import org.rsbot.script.wrappers.RSInterface;
  22. import org.rsbot.script.wrappers.RSNPC;
  23. import org.rsbot.script.wrappers.RSObject;
  24. import org.rsbot.script.wrappers.RSPlayer;
  25. import org.rsbot.script.wrappers.RSTile;
  26.  
  27. @ScriptManifest(authors={"happyfeet"}, name="DemonButlerOakLarder", version=1.0D, description="<html><head></head><body><center><strong><h2>Pedreiro</h2></strong><br /><br />Start near the oak larder space with butler following you.<br />Fetch 24 Planks once before starting.<br /><br />Options: <select name=\"Op\"><option>Oak Larder<option>Oak Dungeon Door<option>Mahogany Table</select><br />Butler: <select name=\"BUTLER\"><option>Rick<option>Maid<option>Cook<option>Butler<option>Demon Butler</select></center><br /></body></html>")
  28. public class DemonButlerOakLarder extends Script
  29. implements PaintListener
  30. {
  31. private int oakB = 13566;
  32. private int oakUn = 15403;
  33. public String status = "";
  34. private int oakPlank = 8778;
  35. private int oakDB = 13345;
  36. private int oakDUn = 15327;
  37. private int mahB = 13298;
  38. private int mahUn = 15298;
  39. private int mahPlank = 8782;
  40. private long startingTime;
  41. private int startXP = 0;
  42. private int startLvl = 0;
  43. private long scriptStartTime = 0L;
  44. final ScriptManifest properties = (ScriptManifest)getClass().getAnnotation(ScriptManifest.class);
  45. private Rectangle experienceProgressBar;
  46. private int rick = 4235;
  47. private int maid = 4237;
  48. private int cook = 4239;
  49. BufferedImage normal = null;
  50. BufferedImage clicked = null;
  51. private int nbutler = 4241;
  52. private int dbutler = 4243;
  53. private int Built;
  54. private int Unbuilt;
  55. private int plank;
  56. private int choose;
  57. private int butler;
  58. private long startExp;
  59. private long st;
  60. private long startLevel;
  61. private RSTile nearLarder;
  62. private boolean ButlerHere = true;
  63.  
  64. public int waitForInventoryCount(int item, int count, int timeout)
  65. {
  66. long start = System.currentTimeMillis();
  67. while (System.currentTimeMillis() - start < timeout) {
  68. if (this.inventory.getCount(new int[] { item }) >= count) {
  69. break;
  70. }
  71. }
  72. return this.inventory.getCount(new int[] { item });
  73. }
  74.  
  75. public int loop()
  76. {
  77. if (this.calc.distanceTo(this.nearLarder) > 3) {
  78. this.walking.walkTo(this.nearLarder);
  79. return 1300;
  80. }
  81. if (manageInterfaces()) {
  82. return 800;
  83. }
  84. if (this.inventory.getCount(new int[] { this.plank }) < 16) {
  85. if (this.npcs.getNearest(new int[] { this.butler }) != null) {
  86. if (!this.ButlerHere) {
  87. this.ButlerHere = true;
  88. int waitCount = 24;
  89. if (this.inventory.getCount(new int[] { this.plank }) < 1) {
  90. waitForInventoryCount(this.plank, waitCount, 3000);
  91. }
  92.  
  93. }
  94.  
  95. if (this.inventory.getCount(new int[] { this.plank }) <= 6) if (this.objects.getNearest(new int[] { this.Built }) != null) {
  96. this.npcs.getNearest(new int[] { this.butler }).doAction("Fetch-from-bank");
  97. sleep(1300);
  98. }
  99. if ((this.interfaces.get(242).isValid()) || (this.interfaces.get(232).isValid()) || (this.interfaces.get(234).isValid())) {
  100. if (this.inventory.getCount(new int[] { this.plank }) < 16) {
  101. manageInterfaces();
  102. return 1500;
  103. }
  104. }
  105. if (this.inventory.getCount(new int[] { this.plank }) >= 16)
  106. return 1500;
  107. }
  108. else
  109. {
  110. this.ButlerHere = false;
  111. if (this.objects.getNearest(new int[] { this.Built }) != null) {
  112. this.objects.getNearest(new int[] { this.Built }).doAction("Remove");
  113. return 1500;
  114. }
  115. }
  116. }
  117. if (this.objects.getNearest(new int[] { this.Built }) != null) if (this.inventory.getCount(new int[] { this.plank }) > 6) {
  118. this.objects.getNearest(new int[] { this.Built }).doAction("Remove");
  119. return 1500;
  120. }
  121. if (this.objects.getNearest(new int[] { this.Unbuilt }) != null) if (this.inventory.getCount(new int[] { this.plank }) > 7) {
  122. this.objects.getNearest(new int[] { this.Unbuilt }).doAction("Build");
  123. this.objects.getNearest(new int[] { this.Unbuilt }).doAction("Build");
  124. this.objects.getNearest(new int[] { this.Unbuilt }).doAction("Build");
  125. sleep(1500);
  126. this.mouse.move(110, 140);
  127. sleep(600);
  128. this.mouse.click(true);
  129. sleep(2000);
  130. return 1200;
  131. }
  132. return 1;
  133. }
  134.  
  135. public int getMouseSpeed() {
  136. return 0;
  137. }
  138. private boolean manageInterfaces() {
  139. if ((isValid(this.interfaces.get(242), 5)) &&
  140. (this.interfaces.get(232).containsText("any of those ite"))) {
  141. log("Out of planks! Thanks for using Oak Larder maker :)");
  142. stopScript(true);
  143. return true;
  144. }
  145.  
  146. if (this.interfaces.get(394).isValid()) {
  147. clickThaLarder(8234);
  148. this.nearLarder = getMyPlayer().getLocation();
  149. return true;
  150. }
  151. if ((isValid(this.interfaces.get(232), 3)) &&
  152. (this.interfaces.get(232).containsText("Pay servant"))) {
  153. this.interfaces.getComponent(232, 3).doClick();
  154. return true;
  155. }
  156.  
  157. if (isValid(this.interfaces.get(228), 2)) {
  158. this.mouse.move(random(250, 280), random(398, 412));
  159. sleep(random(15, 50));
  160. this.mouse.click(true);
  161. return true;
  162. }
  163. if (isValid(this.interfaces.get(241), 5)) {
  164. if ((this.interfaces.get(241).containsText("Yes, madam?")) || (this.interfaces.get(241).containsText("Yes, sir?")) || (this.interfaces.get(241).containsText("Your goods")))
  165. return false;
  166. this.interfaces.getComponent(241, 5).doClick();
  167. return true;
  168. }
  169. if (isValid(this.interfaces.get(234), 2)) {
  170. if (this.inventory.getCount(new int[] { this.plank }) < 16) {
  171. this.interfaces.getComponent(234, 2).doClick();
  172. }
  173. else {
  174. this.objects.getNearest(new int[] { this.Built }).doAction("Walk here");
  175. }
  176. return true;
  177. }
  178.  
  179. if (isValid(this.interfaces.get(232), 3)) {
  180. this.interfaces.getComponent(232, 3).doClick();
  181. sleep(random(1000, 2000));
  182. this.keyboard.sendText("24", true);
  183. sleep(random(100, 200));
  184. return true;
  185. }
  186. if (isValid(this.interfaces.get(242), 6)) { this.interfaces.getComponent(242, 6).doClick();
  187. return true; }
  188. if (this.interfaces.get(243).containsText("until thou art ready."))
  189. return false;
  190. if (isValid(this.interfaces.get(243), 7)) {
  191. this.interfaces.getComponent(243, 7).doClick();
  192. return true;
  193. }
  194. return false;
  195. }
  196.  
  197. private boolean isValid(RSInterface a, int child) {
  198. return (a.isValid()) && (a.getComponent(child).getAbsoluteY() > 30);
  199. }
  200.  
  201. public boolean onStart()
  202. {
  203. this.mouse.setSpeed(random(0, 5));
  204. this.scriptStartTime = System.currentTimeMillis();
  205. this.startXP = this.skills.getCurrentExp(22);
  206. this.startLvl = this.skills.getCurrentLevel(22);
  207. this.st = System.currentTimeMillis();
  208.  
  209. this.butler = this.dbutler;
  210.  
  211. this.Built = this.oakB;
  212. this.Unbuilt = 15403;
  213. this.plank = this.oakPlank;
  214. this.choose = 0;
  215.  
  216. return true;
  217. }
  218.  
  219. public boolean clickThaLarder(int itemID)
  220. {
  221. RSComponent LarderMenu = this.interfaces.get(394).getComponent(11);
  222. if ((LarderMenu == null) || (LarderMenu.getComponents() == null)) {
  223. return false;
  224. }
  225. for (RSComponent item : LarderMenu.getComponents()) {
  226. if ((item != null) && (item.getComponentID() == itemID)) {
  227. LarderMenu.doClick();
  228. sleep(2000);
  229. }
  230. }
  231. return true;
  232. }
  233.  
  234. public void drawMouse(Graphics g) {
  235. if (this.normal != null) {
  236. double mouseX = this.mouse.getLocation().getX() - 8.0D;
  237. double mouseY = this.mouse.getLocation().getY() - 8.0D;
  238. double mousePressX = this.mouse.getPressLocation().getX() - 8.0D;
  239. double mousePressY = this.mouse.getPressLocation().getY() - 8.0D;
  240. if (System.currentTimeMillis() - this.mouse.getPressTime() < 400L) {
  241. g.drawImage(this.clicked, (int)mousePressX, (int)mousePressY, null);
  242. }
  243. g.drawImage(this.normal, (int)mouseX, (int)mouseY, null);
  244. }
  245. }
  246.  
  247. public void onRepaint(Graphics g)
  248. {
  249. long runTime = 0L;
  250. long seconds = 0L;
  251. long minutes = 0L;
  252. long hours = 0L;
  253. int percent = 0;
  254. int currentXP = 0;
  255. int currentLVL = 0;
  256. int gainedXP = 0;
  257. int gainedLVL = 0;
  258. int lapsPerHour = 0;
  259. int expPerHour = 0;
  260.  
  261. runTime = System.currentTimeMillis() - this.scriptStartTime;
  262.  
  263. percent = this.skills.getPercentToNextLevel(22);
  264. currentXP = this.skills.getCurrentExp(22);
  265. currentLVL = this.skills.getCurrentLevel(22);
  266. gainedXP = currentXP - this.startXP;
  267. gainedLVL = currentLVL - this.startLvl;
  268. expPerHour = (int)(3600000.0D / runTime * gainedXP);
  269. int fillBar = (int)(4.7D * percent);
  270. drawMouse(g);
  271.  
  272. g.setColor(new Color(32, 0, 0, 175));
  273. g.fillRect(23, 387, 470, 26);
  274. g.setColor(new Color(108, 108, 108, 200));
  275. g.fillRect(25, 389, 470, 26);
  276.  
  277. g.setColor(new Color(0, 0, 0, 175));
  278. g.fillRoundRect(7, 345, 506, 129, 7, 7);
  279.  
  280. g.setColor(new Color(139, 0, 0, 175));
  281. g.fillRect(24, 388, 470, 26);
  282. g.setColor(new Color(0, 166, 0, 200));
  283. g.fillRect(24, 388, fillBar, 26);
  284.  
  285. g.setColor(new Color(207, 58, 58, 175));
  286. g.fillRect(24, 401, 470, 13);
  287. g.setColor(new Color(128, 219, 128, 200));
  288. g.fillRect(24, 401, fillBar, 13);
  289.  
  290. g.setFont(new Font("Verdana", 0, 14));
  291. g.setColor(new Color(0, 0, 0, 255));
  292. g.drawString(percent + "% - " + this.skills.getExpToNextLevel(22) + "xp remaining", 43, 406);
  293.  
  294. g.setFont(new Font("Verdana", 3, 20));
  295. g.setColor(Color.red);
  296. g.drawString("DemonButlerOakLarder by Happyfeet", 48, 375);
  297.  
  298. g.setFont(new Font("Verdana", 0, 12));
  299. g.setColor(new Color(225, 225, 225, 175));
  300.  
  301. g.drawString("Current Lvl: " + currentLVL + " (+ " + gainedLVL + ")", 24, 445);
  302. g.drawString("Exp Gained: " + gainedXP + " (" + expPerHour + "/hr)", 24, 460);
  303.  
  304. g.drawString("Run Time: " + Timer.format(runTime), 250, 445);
  305. try {
  306. if (expPerHour > 0) {
  307. long sTNL = this.skills.getExpToNextLevel(22) / (expPerHour / 3600);
  308. long hTNL = sTNL / 3600L;
  309. sTNL -= hTNL * 3600L;
  310. long mTNL = sTNL / 60L;
  311. sTNL -= mTNL * 60L;
  312. g.drawString("Level in: " + hTNL + ":" + mTNL + ":" + sTNL + " (" + percent + "%)", 250, 460);
  313. }
  314. else {
  315. g.drawString("Level in: 0:0:0 (" + percent + "%)", 250, 460);
  316. }
  317. }
  318. catch (Exception e) {
  319. g.drawString("Level in: -1:-1:-1 (" + percent + "%)", 250, 460);
  320. }
  321. }
  322. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement