Guest User

Untitled

a guest
Jul 17th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.12 KB | None | 0 0
  1. /*
  2. Yes... I know the code isn't perfect...
  3. Yes I know there are unused variables (cbf removing)
  4. Yes I know this is a horrible way to write a script...
  5. No I don't care because it runs flawlessly... I ran it 15 hours no problems.
  6. */
  7. import java.awt.Color;
  8. import java.awt.Graphics;
  9. import java.util.Map;
  10.  
  11. import org.rsbot.event.events.ServerMessageEvent;
  12. import org.rsbot.event.listeners.*;
  13. import org.rsbot.script.*;
  14. import org.rsbot.script.wrappers.*;
  15. import org.rsbot.event.listeners.PaintListener;
  16.  
  17. import java.awt.Point;
  18.  
  19. @ScriptManifest(authors = { "Kriogenic" }, category = "Mining", name = "Kriogenic Crafting Guild Miner", version = 1.0, description = "<html><body bgcolor =\"#AAAAAAAA\"><font color =\"#3333FF\"><center><h2>Kriogenics Crafting Guild Miner</h2><BR>"
  20. + "<font size=\"3\">You should start this script at the bank but it can be started at the guild also.<br /><select name=\"Rockchoice\"><option>Gold<option>Silver<option>Clay<option>Gold & Silver</select></font></body></html>")
  21. public class CraftingGuildMiner extends Script implements PaintListener, ServerMessageListener{
  22.  
  23. final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
  24. int runEnergy = random(50, 80);
  25. public int Gold[] = {11184,11183,11185};
  26. public int Silver[] = {11186,11187,11188};
  27. public int Clay[] = {11189,11190,11191};
  28. public int GoldSilver[] = { 11184,11183,11185,11186,11187,11188};
  29. public int RocksMined = 0;
  30. public int Pickaxes[] = { 1275, 1265, 1273, 1267, 1271, 15259, 1269 };
  31. public long startTime = System.currentTimeMillis();
  32. public int OpenDoor = 336;
  33. public int ClosedDoor = 336;
  34. public int Booth = 11758;
  35. public int loopwait = 800;
  36. private int RockID[];
  37. private long scriptStartTime = 0;
  38. private int startXP = 0;
  39. private int gainedXP = 0;
  40. long runTime = 0;
  41. long seconds = 0;
  42. long minutes = 0;
  43. long hours = 0;
  44. private String status = "";
  45. String OreID;
  46. String State;
  47.  
  48. int StartingExp;
  49. int GainedExp = 0;
  50.  
  51. RSTile[] ToGuild = {new RSTile(3013, 3355),new RSTile(3007, 3349),
  52. new RSTile(3007, 3335),new RSTile(3006, 3325),new RSTile(2998, 3314),
  53. new RSTile(2989, 3306),new RSTile(2976, 3302),new RSTile(2962, 3300),
  54. new RSTile(2950, 3301),new RSTile(2936, 3295),new RSTile(2933, 3289)};
  55.  
  56. RSTile[] ToSpot = {new RSTile(2933, 3288),new RSTile(2939, 3281)};
  57. RSTile[] ToDoor = reversePath(ToSpot);
  58. RSTile[] ToBank = reversePath(ToGuild);
  59.  
  60.  
  61. public boolean onStart(Map<String, String> args) {
  62. scriptStartTime = System.currentTimeMillis();
  63. status = "Starting Up...";
  64. if (args.get("Rockchoice").equals("Gold")) {
  65. RockID = Gold;
  66. }
  67. if (args.get("Rockchoice").equals("Silver")) {
  68. RockID = Silver;
  69. }
  70. if (args.get("Rockchoice").equals("Clay")) {
  71. RockID = Clay;
  72. }
  73. if (args.get("Rockchoice").equals("Gold & Silver")) {
  74. RockID = GoldSilver;
  75. }
  76. return true;
  77. }
  78.  
  79. public void onFinish() {
  80. return;
  81. }
  82.  
  83. //**************************************//
  84. // METHODS
  85. //**************************************//
  86.  
  87. public void Mine(){
  88. RSObject rock = getNearestObjectByID(RockID);
  89. if(rock == null)
  90. return;
  91.  
  92. while(!tileOnScreen(rock.getLocation())){
  93. try{
  94. if(!getMyPlayer().isMoving()){
  95. walkTileMM(rock.getLocation());
  96. }
  97. }catch(final Exception e){
  98. e.printStackTrace();
  99. }
  100. }
  101. if (getMyPlayer().getAnimation() == -1) {
  102. status = "Mining Rock...";
  103. try{
  104. atObject(rock, "Mine");
  105.  
  106. }catch(final Exception e){
  107. e.printStackTrace();
  108. }
  109. }
  110.  
  111. }
  112.  
  113. public void antiban(){
  114. int randnum = random(0,999);
  115. int[] crotate = {10, 130, 530, 200, 470, 600, 720, 850, 905, 999};
  116. int li;
  117. for(li=0;li < crotate.length;li++){
  118. if(randnum == crotate[li]){
  119. setCameraRotation(random(0, 359));
  120. }
  121. }
  122. if (energyCheck()) {
  123. setRun(true);
  124. wait(random(750,1000));
  125. }
  126. return;
  127. }
  128.  
  129. private boolean energyCheck() {
  130. try {
  131. if (gEnergy() >= runEnergy && !isRunning()) {
  132. runEnergy = random(35, 65);
  133. return true;
  134. } else {
  135. return false;
  136. }
  137. } catch (Exception e) {
  138. return false;
  139. }
  140. }
  141. private int gEnergy() {
  142. return Integer.parseInt(RSInterface.getChildInterface(750, 5).getText());
  143. }
  144.  
  145. public boolean ToGuild() {
  146. final RSTile[] randomizedPath = randomizePath(ToGuild, 2, 2);
  147. final RSTilePath path = new RSTilePath(randomizedPath, this);
  148. status = "Walking to Guild...";
  149. try {
  150.  
  151. return path.walkToEnd();
  152. } catch (final Exception e) {
  153.  
  154. e.printStackTrace();
  155. }
  156. return false;
  157. }
  158.  
  159. public boolean ToSpot() {
  160.  
  161. final RSTile[] randomizedPath = randomizePath(ToSpot, 2, 2);
  162. final RSTilePath path = new RSTilePath(randomizedPath, this);
  163. status = "Walking to rocks...";
  164. try {
  165.  
  166. return path.walkToEnd();
  167. } catch (final Exception e) {
  168.  
  169. e.printStackTrace();
  170. }
  171. return false;
  172. }
  173.  
  174. public boolean ToBank() {
  175. final RSTile[] randomizePath = randomizePath(ToBank, 2, 2);
  176. final RSTilePath path = new RSTilePath(randomizePath, this);
  177. status = "Walking to bank...";
  178. try {
  179.  
  180. return path.walkToEnd();
  181. } catch (final Exception e) {
  182.  
  183. e.printStackTrace();
  184. }
  185. return false;
  186. }
  187.  
  188. public boolean ToDoor() {
  189. final RSTile[] randomizePath = randomizePath(ToDoor, 2, 2);
  190. final RSTilePath path = new RSTilePath(randomizePath, this);
  191. status = "Walking to door...";
  192. try {
  193.  
  194. return path.walkToEnd();
  195. } catch (final Exception e) {
  196.  
  197. e.printStackTrace();
  198. }
  199. return false;
  200. }
  201.  
  202. public boolean needToBank(){
  203. return isInventoryFull();
  204. }
  205.  
  206.  
  207. public boolean handleBank() {
  208. RSObject bankBooth = getNearestObjectByID(Booth);
  209. if(bankBooth == null){
  210. return false;
  211. }
  212. if(bank == null)
  213. return false; //Can't find bank
  214. log("Can't find bank");
  215.  
  216. if(bank.isOpen()){
  217. bank.depositAllExcept(Pickaxes);
  218. }else{
  219. status = "Banking...";
  220. try{
  221.  
  222. if (random(0,25) == 10) {
  223. setCameraRotation(random(0, 359));
  224. }
  225. atObject(bankBooth, "Use-quickly");
  226. }catch(final Exception e){
  227. e.printStackTrace();
  228. }
  229. }
  230.  
  231. return true;
  232. }
  233.  
  234.  
  235.  
  236. public boolean handleDoor() {
  237. if (random(0,25) == 10) {
  238. setCameraRotation(random(0, 359));
  239. }
  240. status = "Opening Door...";
  241. atDoorTiles(new RSTile(2933, 3289), new RSTile(2933, 3288));
  242. wait(random(100,300));
  243. return true;
  244.  
  245. }
  246. public boolean inSquare(int maxX, int maxY, int minX, int minY) {
  247. int x = getMyPlayer().getLocation().getX();
  248. int y = getMyPlayer().getLocation().getY();
  249. if (x >= minX && x <= maxX && y >= minY && y <= maxY) {
  250. return true;
  251. }
  252. return false;
  253. }
  254.  
  255. ////////////////
  256. /////Loop//////
  257. //////////////
  258.  
  259. @Override
  260. public int loop() {
  261. setCameraAltitude(true);
  262. antiban();
  263. RSObject Banker = getNearestObjectByID(Booth);
  264. RSObject Cdoor = getNearestObjectByID(ClosedDoor);
  265. RSObject Rock = getNearestObjectByID(RockID);
  266.  
  267. if(getMyPlayer().isMoving()) return random(400, 1300);
  268.  
  269. if(inSquare(2943, 3291, 2937, 3276)){
  270. if(!needToBank()){
  271. Mine();
  272. }else{
  273. ToDoor();
  274. }
  275.  
  276. ////////////////////
  277.  
  278. }
  279.  
  280. if(inSquare(2931, 3291, 2928, 3289) || inSquare(2938, 3288, 2928, 3287) || inSquare(2938, 3291, 2935, 3288)){
  281.  
  282. if(!needToBank()){
  283. ToSpot();
  284. }else{
  285.  
  286. handleDoor();
  287.  
  288.  
  289. }
  290. }
  291.  
  292.  
  293. if(inSquare(2934, 3292, 2932, 3289)) {
  294. if(!needToBank()){
  295.  
  296. handleDoor();
  297.  
  298. }else{
  299. ToBank();
  300. }
  301. }
  302.  
  303. if(inSquare(3018, 3358, 3009, 3355)){
  304. if(!needToBank()){
  305. ToGuild();
  306. }else{
  307. handleBank();
  308. }
  309. }
  310.  
  311. if(inSquare(3018, 3360, 3009, 3359)){
  312. if(needToBank()){
  313. walkTileMM(getClosestTileOnMap(new RSTile(3012, 3356)));
  314. }
  315. }
  316. return(loopwait);
  317. }
  318.  
  319. @Override
  320. public void onRepaint(Graphics g) {
  321. int currentXP = 0;
  322. int currentLVL = 0;
  323. int OrePerHour = 0;
  324. int nextLvl = 0;
  325. final double xpGain = 25.5;
  326. if (isLoggedIn()) {
  327. runTime = System.currentTimeMillis() - scriptStartTime;
  328. seconds = runTime / 1000;
  329. if ( seconds >= 60 ) {
  330. minutes = seconds / 60;
  331. seconds -= (minutes * 60);
  332. }
  333. if ( minutes >= 60 ) {
  334. hours = minutes / 60;
  335. minutes -= (hours * 60);
  336. }
  337. currentLVL = skills.getCurrentSkillLevel(Skills
  338. .getStatIndex("mining"));
  339. currentXP = skills.getCurrentSkillExp(Skills.getStatIndex("mining"));
  340. nextLvl = skills.getXPToNextLevel(Skills.getStatIndex("mining"));
  341.  
  342. OrePerHour = (int) (3600000.0 / runTime * RocksMined);
  343. g.setColor(new Color(0, 0, 0, 175));
  344. g.fillRoundRect(555, 210, 175, 250, 10, 10);
  345. g.setColor(Color.yellow);
  346. g.drawString("Kriogenic Crafting Guild Miner!",558,222);
  347. g.drawString("Run Time: " + hours + "Hrs " + minutes + "Min " + seconds + "Sec", 560, 247);
  348. g.drawString("Status : " + status, 585, 262);
  349.  
  350. g.drawString("Ore Mined : " + RocksMined , 585, 287);
  351. g.drawString("Ore Per Hour: " + OrePerHour, 585 ,302);
  352.  
  353. g.drawString("Current Level: " + currentLVL, 585, 327);
  354. g.drawString("XP Gained: " + gainedXP, 585, 342);
  355. g.drawString("XP Till Level: " + nextLvl, 585, 357);
  356.  
  357. }
  358. }
  359.  
  360. @Override
  361. public void serverMessageRecieved(ServerMessageEvent arg0) {
  362. String serverString = arg0.getMessage();
  363. if (serverString.contains("You manage to")) {
  364. RocksMined++; //
  365. }
  366. if (serverString.contains("gold")) {
  367. gainedXP += 65;
  368. }
  369. if (serverString.contains("silver")) {
  370. gainedXP += 40;
  371. }
  372. if (serverString.contains("clay")) {
  373. gainedXP += 5;
  374. }
  375.  
  376. }
  377.  
  378. }
Add Comment
Please, Sign In to add comment