Guest User

Untitled

a guest
Jul 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.72 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.  
  6. import com.rarebot.event.listeners.PaintListener;
  7. import com.rarebot.script.Script;
  8. import com.rarebot.script.ScriptManifest;
  9. import com.rarebot.script.methods.Skills;
  10. import com.rarebot.script.wrappers.*;
  11.  
  12.  
  13. @ScriptManifest(authors = { "The_Physicist" }, name = "EdgevilleSmelter by The_Physicist", description = "Start with Gold ore or Gold bars in inv in edge bank or furnace...", version = 1.0)
  14. public class EdgevilleGoldSmelter extends Script implements PaintListener {
  15.  
  16.  
  17. public static final RSTile bankTile = new RSTile(3097, 3496);
  18. public static final RSTile smeltTile = new RSTile(3109,3501);
  19. public int bankID = 42377;
  20. public int goldBar = 2357;
  21. public int goldOre = 444;
  22. public int startLvl, startExp, barsSmelted;
  23. private long startTime;
  24. private String bar, state = "Loading";
  25.  
  26. public boolean onStart() {
  27. startTime = System.currentTimeMillis();
  28. return true;
  29. }
  30.  
  31. @Override
  32. public int loop() {
  33. RSArea atFurnace = new RSArea(new RSTile(3104,3485), new RSTile(3113,3505));
  34. RSArea atBank = new RSArea(new RSTile(3091,3493), new RSTile(3099,3500));
  35. if (getMyPlayer().getAnimation() == 3243) {
  36. antiBan();
  37. sleep(random(5000,10000));}
  38. else {
  39.  
  40. if (getMyPlayer().isMoving() == true) {
  41. if(random(1, 100) == 1)
  42.  
  43. sleep(random(1000,1500));
  44. } else {
  45. if (!inventory.contains(goldOre)) {
  46. if (!atBank.contains(getMyPlayer().getLocation())) {
  47. log ("Not at bank, walking to bank!");
  48. walk(bankTile);
  49. sleep (random(500,700));
  50. }
  51. Bank();
  52. } else
  53. if (!inventory.contains(goldBar) || inventory.contains(goldOre)) {
  54. if (!atFurnace.contains(getMyPlayer().getLocation())) {
  55. log ("Not at Furnace, walking to furnace");
  56. walk(smeltTile);
  57. sleep (random(500,700));
  58. }
  59. smeltGold();
  60. }
  61. }
  62. }
  63.  
  64. return random(200,500);
  65.  
  66. }
  67.  
  68. private void smeltGold() {
  69. state = "Smelting!";
  70. RSObject furnace = objects.getNearest(26814);
  71. RSInterface main = interfaces.get(905);
  72. RSComponent comp = main.getComponent(19);
  73. if (furnace.isOnScreen()) {
  74. furnace.doClick();
  75. sleep (random(500,700));
  76. sleep(random(750,1250));
  77. if (main.isValid()) {
  78. comp.doClick();
  79. log("Smelting!");
  80. for (int w = 0; w < 300 && getMyPlayer().isIdle(); w++) {
  81. sleep(10);
  82. }
  83. }
  84. } else {
  85. sleep(100);
  86. }
  87. }
  88.  
  89.  
  90. public void Bank() {
  91. state = "Banking!";
  92. if (!bank.isOpen()) {
  93. bank.open();
  94. } else {
  95. if (!inventory.contains(goldOre)) {
  96. if (inventory.isFull()) {
  97. bank.depositAllExcept(561);
  98. if (bank.getCount(goldOre) >= 27) {
  99. bank.withdraw(goldOre, 28);
  100. }
  101. } else {
  102. log("No more gold ore in bank.");
  103. stopScript(true);
  104. }
  105. }
  106. }
  107. }
  108.  
  109. private boolean walk(RSTile dest) {
  110. final Point p = calc.tileToMinimap(dest);
  111. if (p.x != -1 && p.y != -1) {
  112. if (!mouse.getLocation().equals(p)) {
  113. mouse.hop(p);
  114. mouse.click(true);
  115. mouse.moveSlightly();
  116. return true;
  117. }
  118. }
  119. return false;
  120. }
  121.  
  122.  
  123. public void antiBan() {
  124. state = "Antiban!";
  125. try {
  126. mouse.setSpeed(random(4, 8));
  127. switch(random(0, 10)) {
  128. case 1:
  129. mouse.moveRandomly(400, 800);
  130. log ("Antiban - Moving mouse randomly!");
  131. break;
  132. case 3:
  133. mouse.moveRandomly(900, 1200);
  134. log ("Antiban - Moving mouse randomly!");
  135. break;
  136. case 4:
  137. mouse.moveRandomly(200, 700);
  138. mouse.moveOffScreen();;
  139. log ("Antiban - Moving mouse randomly!");
  140. break;
  141. case 5:
  142. mouseObserve();
  143. log ("Antiban - Right clicking random player!!");
  144. break;
  145. case 6:
  146. if(game.isFixed() && !getMyPlayer().isMoving() &&
  147. random(0, 2) == 1) {
  148. mouse.move(random(527, 540), random(58, 65), 0, 0);
  149. sleep(random(200, 400));
  150. mouse.click(true);
  151. mouse.moveRandomly(20, 50);
  152. sleep(random(300, 500));
  153. }
  154. break;
  155. case 7:
  156. camera.setAngle(random(1, 359));
  157. break;
  158. }
  159. }catch (Exception e) {}
  160. return;
  161. }
  162.  
  163. public void mouseObserve()
  164. {
  165. int mouseSpeed = random(5,8);
  166. mouse.setSpeed(mouseSpeed);
  167. if(random(0,2) == 0)
  168. {
  169. RSObject o = getRandomObject();
  170. if(o != null)
  171. {
  172. RSTile t = (o.getLocation());
  173. mouse.click(calc.tileToScreen(t),false);
  174. if(menu.isOpen())
  175. {
  176. sleep(500,800+menu.getSize()*80+random(-10,+10));
  177. while(menu.isOpen())
  178. {
  179. if(random(0,101) <= 10)
  180. {
  181. mouseExamine();
  182. }
  183. else
  184. mouseMoveDownMenu();
  185. moveMouseOffMenu();
  186. }
  187. }
  188. }
  189. }
  190. else
  191. {
  192. RSPlayer p = getRandomPlayer();
  193. if(p != null)
  194. {
  195. RSTile t = (p.getLocation());
  196. mouse.click(calc.tileToScreen(t),false);
  197. sleep(900,1500);
  198. if(menu.isOpen())
  199. {
  200. sleep(500,800+menu.getSize()*80+random(-10,+10));
  201. while(menu.isOpen())
  202. {
  203. mouseMoveDownMenu();
  204. moveMouseOffMenu();
  205. }
  206. }
  207. }
  208. }
  209. }
  210.  
  211. public void mouseExamine()
  212. {
  213. if(menu.isOpen())
  214. {
  215. menu.doAction("Examine");
  216. }
  217. sleep(300,600);
  218. }
  219.  
  220. public void mouseMoveDownMenu()
  221. {
  222. mouse.setSpeed(random(5,8));
  223. Point b = menu.getLocation();
  224. if(menu.isOpen())
  225. {
  226. int x = b.x;
  227. int y = b.y;
  228. int x2 = (x+218);
  229. int y2 = 0;y2 = y2+menu.getSize()*17;
  230. mouse.move(random(x,x2),random(y+30,y2));
  231. }
  232. sleep(800,2300);
  233. }
  234.  
  235. public void moveMouseOffMenu()
  236. {
  237. Point b = menu.getLocation();
  238. if(menu.isOpen())
  239. {
  240. int x = b.x;
  241. int y = b.y;
  242. if(random(0,2)==0)
  243. {
  244. x = x+random(-20,-50);
  245. }
  246. else
  247. {
  248. x = (x+218)+random(+20,+50);
  249. }
  250. if(random(0,2)==0)
  251. {
  252. y = y+random(-20,-50);
  253. }
  254. else
  255. {
  256. y = (y+menu.getSize()*17)+random(+20,+50);
  257. }
  258. mouse.move(x,y);
  259. sleep(random(100,400));
  260. }
  261. }
  262.  
  263. public RSObject getRandomObject()
  264. {
  265. RSObject[] o = objects.getAll();
  266. RSObject op = o[random(0,o.length)];
  267. if(o.length <= 1)
  268. return null;
  269. long timeStart = mTime();
  270. while(!op.isOnScreen() && op.getModel() == null)
  271. {
  272. if(mTime() - timeStart >= 2000)
  273. return null;
  274. op = o[random(0,o.length)];
  275. }
  276.  
  277. return op;
  278. }
  279.  
  280. public RSPlayer getRandomPlayer()
  281. {
  282. RSPlayer[] p = players.getAll();
  283. RSPlayer rp = p[random(0,p.length)];
  284. if(p.length <= 1)
  285. return null;
  286. long timeStart = mTime();
  287. while(!rp.isOnScreen() && rp.getName() == getMyPlayer().getName())
  288. {
  289. if(mTime() - timeStart >= 2000)
  290. return null;
  291. rp = p[random(0,p.length)];
  292. }
  293. if(rp == null)
  294. return null;
  295.  
  296. return rp;
  297. }
  298.  
  299. private long mTime()
  300. {
  301. return System.currentTimeMillis();
  302. }
  303.  
  304. public void onRepaint(Graphics g) {
  305. if (game.isLoggedIn()) {
  306. long runTime = System.currentTimeMillis() - startTime;
  307. int seconds = (int) (runTime / 1000 % 60);
  308. int minutes = (int) (runTime / 1000 / 60) % 60;
  309. int hours = (int) (runTime / 1000 / 60 / 60) % 60;
  310.  
  311. StringBuilder b = new StringBuilder();
  312. if (hours < 10) {
  313. b.append('0');
  314. }
  315. b.append(hours);
  316. b.append(':');
  317. if (minutes < 10) {
  318. b.append('0');
  319. }
  320. b.append(minutes);
  321. b.append(':');
  322. if (seconds < 10) {
  323. b.append('0');
  324. }
  325. b.append(seconds);
  326.  
  327. if (startLvl <= 0 || startExp <= 0) {
  328. startLvl = skills.getCurrentLevel(Skills.SMITHING);
  329. startExp = skills.getCurrentExp(Skills.SMITHING);
  330. }
  331.  
  332. int x = 294;
  333. int y = 4;
  334. int xl = 222;
  335. int yl = 85;
  336.  
  337. g.setColor(new Color(0, 0, 0, 120));
  338. g.fillRect(x, y, xl, yl);
  339. g.setColor(new Color(248, 237, 22));
  340. g.drawRect(x, y, xl, yl);
  341.  
  342. g.setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
  343. g.drawString(getClass().getAnnotation(ScriptManifest.class).name()
  344. + " v"
  345. + getClass().getAnnotation(ScriptManifest.class).version(),
  346. x + 10, y += 15);
  347. g.drawString(
  348. "Gained: "
  349. + (skills.getCurrentExp(Skills.SMITHING) - startExp < 1000 ? skills
  350. .getCurrentExp(Skills.SMITHING) - startExp
  351. : Math.round((skills
  352. .getCurrentExp(Skills.SMITHING) - startExp) * 10) / 10)
  353. + " Exp"
  354. + " || Exp/Hour: "
  355. + (int) ((skills.getCurrentExp(Skills.SMITHING) - startExp) * 3600000D / ((double) System
  356. .currentTimeMillis() - (double) startTime)),
  357. x + 10, y += 15);
  358. g.drawString("Smelted: " + (Math.round(((skills.getCurrentExp(Skills.SMITHING) - startExp < 1000 ? skills
  359. .getCurrentExp(Skills.SMITHING) - startExp
  360. : Math.round((skills
  361. .getCurrentExp(Skills.SMITHING) - startExp) * 10) / 10)) / 56.2)) + " Gold" + " Bars",
  362. x + 10, y += 15);
  363. g.drawString("Time Running: " + b, x + 10, y += 15);
  364. g.drawString("Current State: ", x + 10, y += 15);
  365. g.setColor(Color.RED);
  366. g.drawString(state, x + 95, y);
  367. }
  368. }
  369. }
Add Comment
Please, Sign In to add comment