Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.66 KB | None | 0 0
  1. import org.rsbot.script.Script;
  2. import org.rsbot.script.ScriptManifest;
  3. import org.rsbot.script.wrappers.RSInterface;
  4. import org.rsbot.script.wrappers.RSNPC;
  5. import org.rsbot.script.wrappers.RSObject;
  6. import org.rsbot.script.methods.Inventory;
  7. import org.rsbot.script.methods.Keyboard;
  8. import org.rsbot.script.methods.Mouse;
  9. import org.rsbot.script.methods.Game;
  10. import org.rsbot.script.methods.Camera;
  11. import org.rsbot.script.methods.Skills;
  12. import org.rsbot.event.listeners.PaintListener;
  13. import org.rsbot.event.listeners.ServerMessageListener;
  14. import org.rsbot.event.events.ServerMessageEvent;
  15. import org.rsbot.script.util.Timer;
  16. import java.util.Random;
  17. import java.awt.*;
  18.  
  19. // -- Future -- //
  20. // GUI Options
  21. // Make What: Dungeon Doors/Larders
  22.  
  23. @ScriptManifest(authors = { "DhOyLe" }, name = "Larder Pro", version = 1.55, description = "Larder Destroyer!")
  24.  
  25. public class LarderPro extends Script implements PaintListener, ServerMessageListener {
  26.  
  27. int unBuiltID = 15403;
  28. int builtID = 13566;
  29. int plankID = 8778;
  30.  
  31. int builtCount = 0;
  32. int levelsGained = 0;
  33. int xpGained = 0;
  34. int larderXP = 0;
  35. int lardersToLevel = 0;
  36. int expHour = 0;
  37. int expGained = 0;
  38. long millis = 0;
  39. long hours = 0;
  40. long minutes = 0;
  41. long seconds = 0;
  42. long last = 0;
  43. boolean clayHammer = false;
  44. String status = "";
  45.  
  46. //these set in onStart();
  47. int withdraw = 0;
  48. int butlerID = 0;
  49. long startTime = 0;
  50. int startXP = 0;
  51. int con = 0;
  52. String withdrawSTR = "";
  53. String feePrice = "";
  54.  
  55. private boolean intEx(int id) {
  56. RSInterface[] inters = interfaces.getAll();
  57. for (RSInterface inter : inters) {
  58. if (inter.getIndex() == id)
  59. return true;
  60. }
  61. return false;
  62. }
  63.  
  64. public void getPlanks(){
  65. RSNPC butler = npcs.getNearest(butlerID);
  66. if(butler != null){
  67. status = "Fetching planks...";
  68. sleep(random(1000, 1200));
  69. int plankCount = inventory.getCount(plankID);
  70. if(plankCount < 8){
  71. butler.doAction("Fetch-from-bank");
  72. sleep(random(1400, 1600));
  73. if(interfaces.get(242).getComponent(5).containsText(feePrice)){//pay cook & butler
  74. status = "Paying butler...";
  75. mouse.move(random(230, 380), random(445, 461));//click
  76. sleep(random(10,50));
  77. mouse.click(true);
  78. sleep(random(1200, 1400));
  79. if(intEx(232)){
  80. mouse.move(random(120, 400), random(402, 418));//pay from bank
  81. sleep(random(10, 50));
  82. mouse.click(true);
  83. sleep(random(1400, 1600));
  84. if(interfaces.get(210).getComponent(1).containsText("have that much money")){
  85. log("You ran out of cash.");
  86. stopScript(false);
  87. }
  88. }
  89. } else if(interfaces.get(243).getComponent(5).containsText(feePrice)){//pay demon butler
  90. status = "Paying butler...";
  91. mouse.move(random(230, 380), random(445, 461));//click
  92. sleep(random(10,50));
  93. mouse.click(true);
  94. sleep(random(1200, 1400));
  95. if(intEx(232)){
  96. mouse.move(random(120, 400), random(402, 418));//pay from bank
  97. sleep(random(10, 50));
  98. mouse.click(true);
  99. sleep(random(1400, 1600));
  100. if(interfaces.get(210).getComponent(1).containsText("have that much money")){
  101. log("You ran out of cash.");
  102. stopScript(false);
  103. }
  104. }
  105. }
  106. if(interfaces.get(234).getComponent(2).containsText("Fetch another " + withdrawSTR)){//fetching oak planks
  107. mouse.move(random(180, 350), random(379, 394));
  108. sleep(random(10,50));
  109. mouse.click(true);//click fetch
  110. sleep(random(1200, 1400));
  111. if(interfaces.get(241).getComponent(4).containsText("fool")){//cook
  112. log("You don't have any planks left.");
  113. stopScript(false);
  114. }
  115. if(interfaces.get(242).getComponent(5).containsText("any of those items")){//butler
  116. log("You don't have any planks left.");
  117. stopScript(false);
  118. }
  119. if(interfaces.get(242).getComponent(5).containsText("do not have")){//demon butler
  120. log("You don't have any planks left.");
  121. stopScript(true);
  122. }
  123. } else if(interfaces.get(234).getComponent(2).containsText("Fetch another")){//if withdraw was entered incorrectly
  124. mouse.move(random(220, 295), random(413, 428));//click oak planks
  125. sleep(random(10,50));
  126. mouse.click(true);
  127. sleep(random(1400, 1600));
  128. keyboard.sendText("" + withdraw, true);//enter number to withdraw
  129. sleep(random(1200, 1400));
  130. if(interfaces.get(241).getComponent(4).containsText("fool")){//cook
  131. log("You don't have any planks left.");
  132. stopScript(false);
  133. }
  134. if(interfaces.get(242).getComponent(5).containsText("any of those items")){//butler
  135. log("You don't have any planks left.");
  136. stopScript(false);
  137. }
  138. if(interfaces.get(242).getComponent(5).containsText("do not have")){//demon butler
  139. log("You don't have any planks left.");
  140. stopScript(true);
  141. }
  142. } else if(interfaces.get(232).getComponent(2).containsText("Wooden planks.")){//oak planks not set on start
  143. mouse.move(random(225, 295), random(402, 418));//click oak planks
  144. sleep(random(10,50));
  145. mouse.click(true);
  146. sleep(random(1400, 1600));
  147. keyboard.sendText("" + withdraw, true);//enter number to withdraw
  148. sleep(random(1200, 1400));
  149. if(interfaces.get(241).getComponent(4).containsText("fool")){//cook
  150. log("You don't have any planks left.");
  151. stopScript(false);
  152. }
  153. if(interfaces.get(242).getComponent(5).containsText("any of those items")){
  154. log("You don't have any planks left.");
  155. stopScript(false);
  156. }
  157. if(interfaces.get(242).getComponent(5).containsText("do not have")){//demon butler
  158. log("You don't have any planks left.");
  159. stopScript(false);
  160. }
  161. }
  162. }
  163. }
  164. else if(butler == null){
  165. status = "Waiting on butler...";
  166. AntiBan();
  167. sleep(random(450, 550));
  168. //mouse.click(false);
  169. }
  170. }
  171.  
  172. public void buildLarder(){
  173. RSObject larder = objects.getNearest(unBuiltID);
  174. int START = 300;
  175. int END = 1200;
  176. long range = (long)END - (long)START + 1;
  177. long fraction = (long)(range + END);
  178. int randomNumber = (int)(fraction + START);
  179. if(larder != null){
  180. status = "Building Larder...";
  181. larder.doAction("Build");
  182. sleep(random(randomNumber, randomNumber));
  183. if(intEx(394)){
  184. mouse.move(random(97, 132), random(124, 155));
  185. sleep(random(10, 50));
  186. mouse.click(true);
  187. builtCount++;
  188. sleep(random(randomNumber, randomNumber));
  189. }
  190. }
  191. }
  192.  
  193. public void removeLarder(){
  194. RSObject larder = objects.getNearest(builtID);
  195. status = "Removing Larder...";
  196. int START = 300;
  197. int END = 1200;
  198. long range = (long)END - (long)START + 1;
  199. long fraction = (long)(range + END);
  200. int randomNumber = (int)(fraction + START);
  201.  
  202. int START2 = 10;
  203. int END2 = 50;
  204. long range2 = (long)END2 - (long)START2 + 1;
  205. long fraction2 = (long)(range2 + END2);
  206. int randomNumber2 = (int)(fraction2 + START2);
  207.  
  208. if(larder != null){
  209. larder.doAction("Remove");
  210. sleep(random(randomNumber, randomNumber));
  211. if(interfaces.get(228).getComponent(1).containsText("Really remove it?")){
  212. mouse.move(random(230, 290), random(394, 410));
  213. sleep(random(randomNumber2, randomNumber2));
  214. mouse.click(true);
  215. sleep(random(randomNumber, randomNumber));
  216. }
  217. }
  218. }
  219.  
  220. public void AntiBan(){
  221. int num = random(0, 8);
  222. cameraMover();
  223. if(num == 0 || num == 5){
  224. mouseMover();
  225. }
  226. else if(num == 2 || num == 6){
  227. AFK();
  228. }
  229. else if(num == 3 || num == 7){
  230. xpCheck();
  231. }
  232. }
  233.  
  234. public void mouseMover(){
  235. int num = random(0, 6);
  236. int START = 1;
  237. int END = 10;
  238. long range = (long)END - (long)START + 1;
  239. long fraction = (long)(range + END);
  240. int randomNumber = (int)(fraction + START);
  241. if(num == 2 || num == 4){
  242. status = "AntiBan: MouseMover";
  243. int times = random(1, 3);
  244. for(int n = 0; n < times; n++){
  245. mouse.setSpeed(random(randomNumber,randomNumber));
  246. mouse.move(random(0, game.getWidth()), random(0, game.getHeight()));
  247. sleep(random(10, 100));
  248. }
  249. mouse.setSpeed(random(randomNumber,randomNumber));
  250. }
  251. }
  252.  
  253. public void AFK(){
  254. int num = random(0, 300);
  255. if(num == 100 || num == 200){
  256. mouse.setSpeed(random(5, 9));
  257. int offScreen = random(1, 3);
  258. int time = random(1,6);
  259. if(time == 1 || time == 4 || time == 6){
  260. status = "AntiBan: AFK (20-40 sec)";
  261. if(offScreen == 1){
  262. mouseMover();
  263. mouse.moveOffScreen();
  264. }
  265. sleep(random (20000, 40000));
  266. }
  267. if(time == 2 || time == 5){
  268. status = "AntiBan: AFK (1-1.5 mins)";
  269. if(offScreen == 1){
  270. mouseMover();
  271. mouse.moveOffScreen();
  272. }
  273. sleep(random(60000, 90000));
  274. }
  275. if(time == 3){
  276. status = "AntiBan: AFK (2-4 mins)";
  277. if(offScreen == 1){
  278. mouseMover();
  279. mouse.moveOffScreen();
  280. }
  281. sleep(random(120000, 240000));
  282. }
  283. }
  284. }
  285.  
  286. public void xpCheck(){
  287. int num = random(0, 24);
  288. if(num == 8 || num == 16){
  289. int START = 300;
  290. int END = 4000;
  291. long range = (long)END - (long)START + 1;
  292. long fraction = (long)(range + END);
  293. int randomNumber = (int)(fraction + START);
  294.  
  295. int STARTMS = 1;
  296. int ENDMS = 10;
  297. long rangeMS = (long)ENDMS - (long)STARTMS + 1;
  298. long fractionMS = (long)(rangeMS + ENDMS);
  299. int randomNumberMS = (int)(fractionMS + STARTMS);
  300. status = "AntiBan: XP Check";
  301. mouse.setSpeed(random(randomNumberMS, randomNumberMS));
  302. game.openTab(game.TAB_STATS);
  303. sleep(random(randomNumber, randomNumber));
  304. skills.doHover(skills.INTERFACE_CONSTRUCTION);
  305. sleep(random(randomNumber, randomNumber));
  306. game.openTab(game.TAB_INVENTORY);
  307. sleep(random(randomNumber, randomNumber));
  308. }
  309. }
  310.  
  311. public void cameraMover(){
  312. int num = random(0, 12);
  313. int START = 300;
  314. int END = 2000;
  315. long range = (long)END - (long)START + 1;
  316. long fraction = (long)(range + END);
  317. int randomNumber = (int)(fraction + START);
  318. status = "AntiBan: Moving camera";
  319. sleep(random(randomNumber, randomNumber));
  320. camera.setAngle(random(0, 360));
  321. sleep(random(randomNumber, randomNumber));
  322. }
  323.  
  324. public boolean onStart(){
  325. if(npcs.getNearest("Cook") != null){
  326. log("Welcome to LarderPro.");
  327. log("Using the cook.");
  328. butlerID = 4239;
  329. withdraw = 16;
  330. withdrawSTR = "16";
  331. feePrice = "3000";
  332. } else if(npcs.getNearest("Butler") != null){
  333. log("Welcome to LarderPro.");
  334. log("Using normal butler.");
  335. butlerID = 4241;
  336. withdraw = 20;
  337. withdrawSTR = "20";
  338. feePrice = "5000";
  339. } else if(npcs.getNearest("Demon butler") != null){
  340. log("Welcome to LarderPro.");
  341. log("Using demon butler.");
  342. butlerID = 4243;
  343. withdraw = 24;
  344. withdrawSTR = "24";
  345. feePrice = "10000";
  346. } else {
  347. log("Cannot find butler. Please start in your house with your butler following you.");
  348. stopScript(false);
  349. }
  350.  
  351. if(clayHammer == true){
  352. larderXP = 960;
  353. } else {
  354. larderXP = 480;
  355. }
  356. con = skills.CONSTRUCTION;
  357. startTime = System.currentTimeMillis();
  358. startXP = skills.getCurrentExp(con);
  359. return true;
  360. }
  361.  
  362. public void onFinish(){
  363. int xpGained = builtCount * 480;
  364. log("You built " + builtCount + " Larders, gained " + xpGained + " Construction XP and gained " + levelsGained + " level(s).");
  365. log("Thanks for using my script. Check my thread regularly for updates!");
  366. }
  367.  
  368. @Override
  369. public int loop(){
  370. if(objects.getNearest(unBuiltID) != null || objects.getNearest(builtID) == null){
  371. if(inventory.getCount(plankID) < 8){
  372. getPlanks();
  373. }
  374. else if(inventory.getCount(plankID) >= 8){
  375. buildLarder();
  376. }
  377. }
  378. else if(objects.getNearest(unBuiltID) == null || objects.getNearest(builtID) != null){
  379. removeLarder();
  380. }
  381. mouse.setSpeed(random(5, 8));
  382. return (250);
  383. }
  384.  
  385. //START: Code generated using Enfilade's Easel
  386. private final Color color1 = new Color(255, 204, 51);
  387. private final Color color2 = new Color(255, 51, 0);
  388. private final Color color3 = new Color(255, 0, 0);
  389. private final Color color4 = new Color(255, 102, 0);
  390.  
  391. private final BasicStroke stroke1 = new BasicStroke(1);
  392.  
  393. private final Font font1 = new Font("Tahoma", 1, 16);
  394. private final Font font2 = new Font("Tahoma", 0, 12);
  395.  
  396. public void onRepaint(Graphics g1) {
  397. Graphics2D g = (Graphics2D)g1;
  398. millis = System.currentTimeMillis() - startTime;
  399. hours = millis / (1000 * 60 * 60);
  400. millis -= hours * (1000 * 60 * 60);
  401. minutes = millis / (1000 * 60);
  402. millis -= minutes * (1000 * 60);
  403. seconds = millis / 1000;
  404. expGained = skills.getCurrentExp(skills.CONSTRUCTION) - startXP;
  405. expHour = (int) ((expGained) * 3600000 D / (System.currentTimeMillis() - startTime));
  406. lardersToLevel = (int) (skills.getExpToNextLevel(con)/larderXP);
  407. g.setColor(color1);
  408. g.fillRoundRect(312, 208, 201, 127, 16, 16);
  409. g.setColor(color2);
  410. g.setStroke(stroke1);
  411. g.drawRoundRect(312, 208, 201, 127, 16, 16);
  412. g.setFont(font1);
  413. g.setColor(color3);
  414. g.drawString("LarderPro v1.5", 327, 228);
  415. g.setFont(font2);
  416. g.setColor(color4);
  417. g.drawString("Status: " + status, 322, 246);
  418. g.drawString("Time Running: " + hours +":"+ minutes + ":" + seconds, 322, 262);
  419. g.drawString("Larders Made: " + builtCount, 322, 278);
  420. g.drawString("XP To Level: " + skills.getExpToNextLevel(skills.CONSTRUCTION), 322, 294);
  421. g.drawString("XP per Hour: " + expHour, 322, 310);
  422. g.drawString("Larders to Level: " + lardersToLevel, 322, 326);
  423. }
  424. //END: Code generated using Enfilade's Easel
  425.  
  426. public void serverMessageRecieved(ServerMessageEvent e) {
  427. final String string = e.getMessage();
  428. if (string.contains("just advanced")){
  429. levelsGained++;
  430. }
  431. }
  432. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement