Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.83 KB | None | 0 0
  1. import java.awt.*;
  2. //import java.awt.Point;
  3. //import java.util.ArrayList;
  4. import java.util.Map;
  5. import org.rsbot.event.events.ServerMessageEvent;
  6. import org.rsbot.event.listeners.PaintListener;
  7. import org.rsbot.event.listeners.ServerMessageListener;
  8. import org.rsbot.script.Script;
  9. import org.rsbot.script.ScriptManifest;
  10. import org.rsbot.script.wrappers.RSInterface;
  11. import org.rsbot.script.wrappers.RSObject;
  12. import org.rsbot.script.wrappers.RSTile;
  13. import org.rsbot.script.wrappers.RSItem;
  14. import org.rsbot.script.methods.Skills;
  15. import org.rsbot.script.methods.Camera;
  16. import org.rsbot.script.methods.Bank;
  17. import org.rsbot.script.methods.Store;
  18. @ScriptManifest(authors = {"Fagerheim"}, name = "fGrSmither", version = 1.36,
  19. description = ("smiths stuff"))
  20. public class fGrSmither extends Script implements PaintListener, ServerMessageListener {
  21. private final int bronze = 2349;
  22. private final int iron = 2351;
  23. private final int steel = 2353;
  24. private final int mith = 2359;
  25. private final int addy = 2361;
  26. private final int rune = 2363;
  27. public boolean awbest;
  28. public int anvil = 2783;
  29. public int bar;
  30. public int bars2 = 0;
  31. public int hammer;
  32. public int chooseIdle = 0;
  33. public int needed = 1;
  34. public int toScroll = 0;
  35. public int energy = random(11, 90);
  36. public int smithIdle = 0;
  37. public int level = 0;
  38. public int startingExp = 0;
  39. public float secExp = 0;
  40. public float minuteExp = 0;
  41. public float hourExp = 0;
  42. public int gainedExp = 0;
  43. public int avgPerHour = 0;
  44. public int antall;
  45. public int oldExp = 0;
  46. public long lastAvgCheck = 0;
  47. public String make = "Scimitar";
  48. public String bars;
  49. public int xpbar = 25;
  50. public int fixedmouse = 5;
  51. public int[] tokeep = { 2347, 2349, 2351, 2353, 2359, 2361, 2363, 14112 };
  52. public int startingLevel;
  53. int smithx = 0;
  54. int smithy = 0;
  55. int smithx2 = 0;
  56. int smithy2 = 0;
  57. long startTime = 0;
  58. long runTime = 0, seconds = 0, minutes = 0, hours = 0;
  59. public RSTile boothTile = new RSTile(3186, 3437);
  60. public RSTile smithTile = new RSTile(3187, 3424);
  61. public void antiBan() {
  62. if (random(1, 12) == 1) {
  63. camera.setAngle(random(1, 359));
  64. }
  65. if (shouldRun()) {
  66. walking.setRun(true);
  67. }
  68. if (random(1, 11) == 1) {
  69. final int x = (int) mouse.getLocation().getX();
  70. final int y = (int) mouse.getLocation().getY();
  71. mouse.move(x + random(-100, 100), y + random(-50, 50));
  72. }
  73. if (random(1, 60) == 1) {
  74. game.openTab(game.TAB_STATS);
  75. mouse.move(random(678, 731), random(240, 261));
  76. sleep(random(731, 2313));
  77. game.openTab(game.TAB_INVENTORY);
  78. }
  79. }
  80. private boolean bank() {
  81. if (bank.isOpen()) {
  82. if (bank.depositAllExcept(tokeep)) {
  83. sleep(random(200, 300));
  84. }
  85. if (inventory.getCount(hammer) != 1) {
  86. bank.withdraw(hammer, 1);
  87. sleep(random(200, 300));
  88. }
  89. if (!(bank.getCount(bar) + inventory.getCount(bar) < needed)) {
  90. bank.withdraw(bar, 0);
  91. sleep(random(200, 300));
  92. if (random(1, 6) == 1) {
  93. bank.close();
  94. }
  95. } else {
  96. while (bank.isOpen()) {
  97. bank.close();
  98. }
  99. log("No Hammer or out of Bars. Terminating.");
  100. stopScript();
  101. }
  102. } else {
  103. openBank();
  104. }
  105. return false;
  106. }
  107. public boolean choosesmith() {
  108. if (make.equals("Dagger") || make.equals("Medium Helm")
  109. || make.equals("Studs") || make.equals("Dart Tip")
  110. || make.equals("Sword") || make.equals("Wire")
  111. || make.equals("Lantern") || make.equals("Grapple Tip")
  112. || make.equals("Mace") || make.equals("Hatchet")
  113. || make.equals("Arrow tips") || make.equals("Crossbow Limb")
  114. || make.equals("Crossbow Bolt") || make.equals("Nails")
  115. || make.equals("Throwing Knife")) {
  116. needed = 1;
  117. }
  118. if (make.equals("Claws") || make.equals("Longsword")
  119. || make.equals("Scimitar") || make.equals("Square Shield")
  120. || make.equals("Full Helm")) {
  121. needed = 2;
  122. }
  123. if (make.equals("Warhammer") || make.equals("Battleaxe")) {
  124. needed = 3;
  125. }
  126. if (make.equals("2-handed Sword") || make.equals("Kiteshield")
  127. || make.equals("Platelegs") || make.equals("Plateskirt")
  128. || make.equals("Chainbody")) {
  129. needed = 3;
  130. toScroll = 1;
  131. }
  132. if (make.equals("Platebody")) {
  133. needed = 5;
  134. toScroll = 1;
  135. }
  136. if (make.equals("Dagger") || make.equals("Iron Spit")
  137. || make.equals("Wire") || make.equals("Crossbow Bolt")
  138. || make.equals("Studs") || make.equals("Longsword")
  139. || make.equals("Lantern") || make.equals("Chainbody")
  140. || make.equals("Plateskirt")) {
  141. smithx = 117;
  142. smithx2 = 119;
  143. }
  144. if (make.equals("Dagger") || make.equals("Hatchet")
  145. || make.equals("Mace") || make.equals("Medium Helm")) {
  146. smithy = 67;
  147. smithy2 = 92;
  148. }
  149. if (make.equals("Hatchet") || make.equals("Grapple Tip")
  150. || make.equals("Sword") || make.equals("Arrow tips")
  151. || make.equals("Throwing Knife") || make.equals("Kiteshield")
  152. || make.equals("Platelegs")) {
  153. smithx = 133;
  154. smithx2 = 236;
  155. }
  156. if (make.equals("Crossbow Bolt") || make.equals("Sword")
  157. || make.equals("Nails") || make.equals("Dart Tip")) {
  158. smithy = 119;
  159. smithy2 = 144;
  160. }
  161. if (make.equals("Mace") || make.equals("Scimitar")
  162. || make.equals("Full Helm") || make.equals("Warhammer")
  163. || make.equals("Platebody") || make.equals("Dart Tip")) {
  164. smithx = 280;
  165. smithx2 = 353;
  166. }
  167. if (make.equals("Studs") || make.equals("Wire")
  168. || make.equals("Iron Spit") || make.equals("Arrow tips")
  169. || make.equals("Scimitar") || make.equals("Crossbow Limb")) {
  170. smithy = 199;
  171. smithy2 = 175;
  172. }
  173. if (make.equals("Medium Helm") || make.equals("Nails")
  174. || make.equals("Crossbow Limb") || make.equals("Square Shield")
  175. || make.equals("2-handed Sword") || make.equals("Battleaxe")) {
  176. smithx = 381;
  177. smithx2 = 483;
  178. }
  179. if (make.equals("Longsword") || make.equals("Throwing Knife")
  180. || make.equals("Full Helm") || make.equals("Square Shield")) {
  181. smithy = 223;
  182. smithy2 = 248;
  183. }
  184. if (make.equals("Lantern") || make.equals("Grapple Tip")
  185. || make.equals("Warhammer") || make.equals("Battleaxe")
  186. || make.equals("Crossbow Limb")) {
  187. smithy = 275;
  188. smithy2 = 300;
  189. }
  190. if (make.equals("Chainbody") || make.equals("Kiteshield")
  191. || make.equals("2-handed Sword")) {
  192. smithy = 216;
  193. smithy2 = 241;
  194. }
  195. if (make.equals("Plateskirt") || make.equals("Platelegs")
  196. || make.equals("Platebody")) {
  197. smithy = 268;
  198. smithy2 = 293;
  199. }
  200. return true;
  201. }
  202. public boolean needToWalk() {
  203. if (inventory.getCount(bar) < needed && calc.distanceTo(boothTile) > 5
  204. || inventory.getCount(hammer) != 1 && calc.distanceTo(boothTile) > 5) {
  205. smithIdle = 0;
  206. return true;
  207. }
  208. return false;
  209. }
  210. public int loop() {
  211. if (interfaces.get(740).getComponent(0).isValid()) {
  212. chooseIdle = 0;
  213. sleep(random(300, 600));
  214. interfaces.get(740).getComponent(3).doAction("continue");
  215. level = skills.getCurrentLevel(Skills.SMITHING);
  216. }
  217. if (chooseIdle != 1) {
  218. choosesmith();
  219. chooseIdle = 1;
  220. }
  221. antiBan();
  222. while (getMyPlayer().isMoving()) {
  223. return random(500, 1500);
  224. }
  225. if (needToWalk()) {
  226. RSTile rboothTile = new RSTile(random(3187, 3188), random(3436, 3438));
  227. walking.walkTo(rboothTile);
  228. return random(285, 321);
  229. }
  230. if (inventory.getCount(hammer) == 1 && inventory.getCount(bar) >= needed
  231. && calc.distanceTo(smithTile) > 5) {
  232. RSTile rsmithTile = new RSTile(random(3186, 3189), random(3421, 3426));
  233. walking.walkTo(rsmithTile);
  234. return random(236, 1026);
  235. }
  236. if (inventory.getCount(bar) <= needed && calc.distanceTo(boothTile) < 5
  237. || inventory.getCount(hammer) != 1 && calc.distanceTo(boothTile) < 5) {
  238. bank();
  239. return random(562, 1074);
  240. }
  241. if (inventory.getCount(hammer) == 1 && inventory.getCount(bar) >= needed
  242. && calc.distanceTo(smithTile) < 5) {
  243. smith();
  244. return random(546, 2023);
  245. }
  246. return random(262, 314);
  247. }
  248. public void onFinish() {
  249. log("Thanks for useing fGrSmither!");
  250. }
  251. @Override
  252. public void onRepaint(Graphics g1) {
  253. Graphics2D g = (Graphics2D)g1;
  254. final Color BG = new Color(0, 0, 0, 200);
  255. final Color RED = new Color(255, 0, 0, 255);
  256. final Color WHITE = new Color(255, 255, 255, 255);
  257. if ((minutes > 0 || hours > 0 || seconds > 0) && gainedExp > 0) {
  258. secExp = (float) gainedExp
  259. / (float) (seconds + minutes * 60 + hours * 60 * 60);
  260. }
  261. minuteExp = secExp * 60;
  262. hourExp = minuteExp * 60;
  263. if (System.currentTimeMillis() - lastAvgCheck >= 500) {
  264. lastAvgCheck = System.currentTimeMillis();
  265. avgPerHour = gainedExp - oldExp;
  266. oldExp = gainedExp;
  267. }
  268. if (startTime == 0) {
  269. startTime = System.currentTimeMillis();
  270. }
  271. runTime = System.currentTimeMillis() - startTime;
  272. seconds = runTime / 1000;
  273. if (seconds >= 60) {
  274. minutes = seconds / 60;
  275. seconds -= minutes * 60;
  276. }
  277. if (minutes >= 60) {
  278. hours = minutes / 60;
  279. minutes -= hours * 60;
  280. }
  281. if (bars2 == 1 || bars2 == 3 || bars2 == 5) {
  282. antall = skills.getExpToNextLevel(Skills.SMITHING) / xpbar
  283. / needed * 2 + 2;
  284. }
  285. if (bars2 == 2 || bars2 == 4 || bars2 == 6) {
  286. antall = skills.getExpToNextLevel(Skills.SMITHING) / xpbar
  287. / needed * +1;
  288. }
  289. gainedExp = skills.getCurrentExp(Skills.SMITHING)
  290. - startingExp;
  291. g.setColor(BG);
  292. g.fill3DRect(305, 180, 205, 150, true);
  293. g.setColor(RED);
  294. g.drawString("fGrSmither v 1.36", 360, 195);
  295. g.setColor(WHITE);
  296. g.drawString("Running for: " + hours + ":" + minutes + ":" + seconds,
  297. 310, 210);
  298. g.drawString("Making: " + bars + " " + make + "'s", 310, 225);
  299. g.drawString("Currently Level: " + level, 310, 240);
  300. g.drawString(skills.getPercentToNextLevel(Skills.SMITHING)
  301. + "% to level " + (level + 1), 310, 255);
  302. g
  303. .drawString(
  304. "Gained "
  305. + (skills.getCurrentLevel(Skills.SMITHING) - startingLevel)
  306. + " levels", 310, 270);
  307. g.drawString("Gained " + gainedExp + " Exp", 310, 285);
  308. g.drawString("Average Exp per hour: " + (int) hourExp, 310, 300);
  309. g.drawString(
  310. (int) antall + " " + make + "s until level " + (level + 1),
  311. 310, 315);
  312. }
  313.  
  314. public boolean onStart() {
  315. startingLevel = skills.getCurrentLevel(Skills.SMITHING);
  316. level = startingLevel;
  317. startingExp = skills.getCurrentExp(Skills.SMITHING);
  318. //final String hammers = args.get("hammer").trim();
  319. //if (hammers.equals("Normal Hammer")) {
  320. hammer = 2347;
  321. //}
  322. //if (hammers.equals("SC Hammer")) {
  323. // hammer = 14112;
  324. //}
  325. //bars = args.get("bar");
  326. bars = "Adamantite";
  327. if (bars.equals("Bronze")) {
  328. bar = bronze;
  329. bars2 = 1;
  330. xpbar = 25;
  331. }
  332. if (bars.equals("Iron")) {
  333. bar = iron;
  334. bars2 = 2;
  335. xpbar = 25;
  336. }
  337. if (bars.equals("Steel")) {
  338. bar = steel;
  339. bars2 = 3;
  340. xpbar = 75;
  341. }
  342. if (bars.equals("Mithril")) {
  343. bar = mith;
  344. bars2 = 4;
  345. xpbar = 50;
  346. }
  347. if (bars.equals("Adamantite")) {
  348. bar = addy;
  349. bars2 = 5;
  350. xpbar = 125;
  351. }
  352. if (bars.equals("Runite")) {
  353. bar = rune;
  354. bars2 = 6;
  355. xpbar = 75;
  356. }
  357. //final String mspeed = args.get("fmousespeed").trim();
  358. fixedmouse = 8;
  359. return true;
  360. }
  361. @Override
  362. public void serverMessageRecieved(ServerMessageEvent e) {
  363. }
  364. public boolean openBank() {
  365. final RSObject bankbooth = objects.getNearest(11402);
  366. if (bankbooth == null) {
  367. return false;
  368. }
  369. if (!calc.tileOnScreen(bankbooth.getLocation())) {
  370. camera.turnToTile(bankbooth.getLocation(), 15);
  371. }
  372. return bankbooth.doAction("Use-quickly");
  373. }
  374. public boolean shouldRun() {
  375. if (walking.getEnergy() > energy + random(-10, 10)) {
  376. return true;
  377. }
  378. return false;
  379. }
  380. public int smith() {
  381. sleep(random(200, 350));
  382. if (smithIdle != 1) {
  383.  
  384. while(interfaces.get(300).isValid() == false) {
  385. inventory.getItem(bar).doAction("Use");
  386. sleep(random(300, 600));
  387. final RSObject anvill = objects.getNearest(anvil);
  388. anvill.doAction("Use " + bars + " bar -> Anvil");
  389. sleep(random(2500, 3000));
  390. }
  391.  
  392. camera.setAngle(random(1, 359));
  393.  
  394. if (interfaces.get(300).isValid()) {
  395. if (toScroll == 1) {
  396. mouse.click(random(492, 504), random(250, 300), true);
  397. toScroll = 0;
  398. }
  399. while(interfaces.get(300).isValid()) {
  400. mouse.click(random(smithx, smithx2), random(smithy, smithy2),false);
  401. menu.doAction("All");
  402. sleep(random(2500, 3000));
  403. }
  404. smithIdle = 1;
  405. }
  406. }
  407. return random(50, 100);
  408. }
  409. public boolean topTextContains(final String s) {
  410. for (int a = 0; a < 10; a++) {
  411. if (menu.getItems()[0].toLowerCase().toLowerCase().contains(
  412. s.toLowerCase())) {
  413. return true;
  414. }
  415. }
  416. return false;
  417. }
  418. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement