Guest User

Untitled

a guest
Jun 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.80 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import java.lang.reflect.Array;
  7.  
  8. import javax.swing.DefaultComboBoxModel;
  9. import javax.swing.JButton;
  10. import javax.swing.JComboBox;
  11. import javax.swing.JFrame;
  12. import javax.swing.JOptionPane;
  13. import javax.swing.JPanel;
  14. import javax.swing.border.EmptyBorder;
  15.  
  16. import com.rarebot.event.listeners.PaintListener;
  17. import com.rarebot.script.Script;
  18. import com.rarebot.script.ScriptManifest;
  19. import com.rarebot.script.methods.Game.Tab;
  20. import com.rarebot.script.wrappers.RSArea;
  21. import com.rarebot.script.wrappers.RSItem;
  22. import com.rarebot.script.wrappers.RSObject;
  23. import com.rarebot.script.wrappers.RSTile;
  24. import com.rarebot.script.wrappers.RSWeb;
  25. import com.rarebot.script.util.Timer;
  26.  
  27. @ScriptManifest(
  28. authors = {"Mortemer2112"},
  29. name = "AIO Jewel Crafter",
  30. description = "Crafts Any Gold or Silver Item At Edgeville & AlKharid",
  31. keywords = "Crafting",
  32. version= 1.03)
  33. public class AIOJewelCrafter extends Script implements PaintListener{
  34.  
  35. private static enum Location{Edgeville, Alkharid;
  36. public static Location getValueAtIndex(int i){
  37. return values()[i];
  38. }
  39. }
  40. private enum Job {StopScript,WalkToBank,WalkToForge,Bank,Crafting,MakeAll,OpenForge}
  41.  
  42. private static String task;
  43. private static String locationName;
  44. private static String itemName;
  45. private Job job = Job.WalkToBank;
  46. AFGUI gui= new AFGUI();
  47. private RSWeb webby;
  48. private static boolean guiWait = true;
  49. private static boolean outOfItems = false;
  50. private static RSTile forgeTile;
  51. private static RSTile bankTile;
  52. private static RSArea bankArea;
  53. private static RSArea forgeArea;
  54. private static int mouseSpeed;
  55. private static int bankMode;
  56. private static int interfaceID;
  57. private static int componentID;
  58. private static int craftItemID;
  59. private static int mouldID = 0;
  60. private static int gemID = 0;
  61. private static int forgeID;
  62.  
  63. private final Color GREEN = new Color(51, 255, 0);
  64. private final Color RED = new Color(255, 0, 0);
  65. private final Color BLACK = new Color(0, 0, 0);
  66. private static String skillName;
  67. private static long startTime;
  68. private static double xpOfItem;
  69. private static double realHours;
  70. private static int totalItemsCrafted;
  71. private static int craftsPerHour;
  72. private static int skillCheckXP;
  73. private static int xpPerHour;
  74. private static int gainedXP;
  75. private static int startXP;
  76. private static int skill;
  77. private static int mx;
  78. private static int my;
  79. private static int levelPercent;
  80.  
  81. public boolean onStart(){
  82. gui.setVisible(true);
  83. while(guiWait){
  84. sleep(1000);
  85. }
  86. task = "starting up";
  87. job = Job.WalkToBank;
  88. startXP = skills.getCurrentExp(skill);
  89. startTime = System.currentTimeMillis();
  90. return true;
  91. }
  92.  
  93. public void onFinish(){
  94. log("AIO Jewel Crafter Ran For "+Timer.format(System.currentTimeMillis() - startTime));
  95. log("Crafted "+totalItemsCrafted+" ("+craftsPerHour+" p/h)");
  96. log("Earned "+gainedXP+" "+skillName+" XP ("+xpPerHour+" p/h)");
  97. }
  98.  
  99. @Override
  100. public int loop() {
  101. mouse.setSpeed(random(mouseSpeed,mouseSpeed+1));
  102. switch(job){
  103. case Crafting:
  104. return Crafting();
  105. case MakeAll:
  106. return MakeAll();
  107. case OpenForge:
  108. return OpenForge();
  109. case WalkToForge:
  110. return WalkToForge();
  111. case Bank:
  112. return Bank();
  113. case WalkToBank:
  114. return WalkToBank();
  115. case StopScript:
  116. log("You Have Run Out Of Crafting Ingredients");
  117. return -1;
  118. default:
  119. log("loop defaulted");
  120. }
  121. return -1;
  122. }
  123.  
  124. private int Crafting(){
  125. task = "Crafting";
  126. if(!inventory.containsAll(craftItemID,mouldID)){
  127. job = Job.WalkToBank;
  128. return 300;
  129. }
  130. if(!isCrafting()){
  131. job = Job.OpenForge;
  132. return 300;
  133. }
  134. return Antiban();
  135. }
  136.  
  137. private int Antiban(){
  138. int x = random(0,100);
  139. switch(x){
  140. case 0:
  141. task = "Antiban: Check Exp";
  142. game.openTab(Tab.STATS);
  143. sleep(400,700);
  144. skills.doHover(skillCheckXP);
  145. sleep(2000,4000);
  146. game.openTab(Tab.INVENTORY);
  147. sleep(500,1000);
  148. mouse.moveSlightly();
  149. break;
  150. default:
  151. if(x > 95){
  152. mouse.moveOffScreen();
  153. }else if(x > 90){
  154. mouse.moveSlightly();
  155. }else if(x > 85){
  156. mouse.moveRandomly(30);
  157. }else if(x > 80){
  158. camera.setAngle(camera.getAngle()+random(5,80));
  159. }else if(x > 75){
  160. camera.setAngle(camera.getAngle()-random(5,80));
  161. }
  162. break;
  163. }
  164. return 500;
  165. }
  166.  
  167. private int MakeAll(){
  168. if(!interfaces.getComponent(interfaceID, componentID).isValid()){
  169. job = Job.OpenForge;
  170. return 300;
  171. }
  172. task = "Clicking - Make All";
  173. mouse.click(interfaces.getComponent(interfaceID, componentID).getPoint(), 5, 5, false);
  174. sleep(random(50,100));
  175. if(menu.click("Make All")){
  176. job = Job.Crafting;
  177. return 300;
  178. }
  179. return 300;
  180. }
  181.  
  182. private boolean isCrafting(){
  183. int start= inventory.getCount(craftItemID);
  184. if(start == 0)return false;
  185. for(int i = 0; i < 10; i++){
  186. sleep(500);
  187. if(inventory.getCount(craftItemID) != start){
  188. return true;
  189. }
  190. }
  191. return false;
  192. }
  193.  
  194. private int OpenForge(){
  195. if(!forgeArea.contains(getMyPlayer().getLocation())){
  196. job= Job.WalkToForge;
  197. return 300;
  198. }
  199. if(interfaces.getComponent(interfaceID, componentID).isValid()){
  200. job = Job.MakeAll;
  201. return 300;
  202. }
  203. if(usedOnForge()){
  204. while(true){
  205. sleep(500,1000);
  206. if(interfaces.getComponent(interfaceID, componentID).isValid())
  207. break;
  208. if(!getMyPlayer().isMoving())
  209. break;
  210. }
  211. job = Job.MakeAll;
  212. return 300;
  213. }
  214. return 200;
  215. }
  216.  
  217. private boolean usedOnForge(){
  218. RSObject forge = objects.getNearest(forgeID);
  219. RSItem item = inventory.getItem(craftItemID);
  220. task = "Using "+item.getName()+" On Forge";
  221. if(inventory.isItemSelected() || inventory.selectItem(item)){
  222. if(forge.doClick(false)){
  223. sleep(50,100);
  224. if(menu.click("Use "+item.getName()+" -> Furnace")){
  225. return true;
  226. }
  227. }else{
  228. camera.turnTo(forge, 50);
  229. }
  230. }
  231. return false;
  232. }
  233.  
  234. private int Bank(){
  235. if(!bankArea.contains(getMyPlayer().getLocation())){
  236. job= Job.WalkToBank;
  237. return 300;
  238. }
  239. if(bank.isOpen() || bank.open()){
  240. task = "Banking";
  241. switch(bankMode){
  242. case 1://one item
  243. if(Bank1()){
  244. job = Job.WalkToForge;
  245. return 300;
  246. }else if(outOfItems){
  247. job = Job.StopScript;
  248. return 300;
  249. }
  250. break;
  251. case 2://two items
  252. if(Bank2()){
  253. job = Job.WalkToForge;
  254. return 300;
  255. }else if(outOfItems){
  256. job = Job.StopScript;
  257. return 300;
  258. }
  259. break;
  260. case 3://3 items
  261. bank.depositAllExcept(mouldID,craftItemID,gemID);
  262. if(Bank3()){
  263. job = Job.WalkToForge;
  264. return 300;
  265. }else if(outOfItems){
  266. job = Job.StopScript;
  267. return 300;
  268. }
  269. break;
  270. }
  271. }
  272. return 300;
  273. }
  274.  
  275. private boolean Bank1(){
  276. bank.depositAllExcept(craftItemID);
  277. if(inventory.getCount(craftItemID) != 28){
  278. bank.depositAllExcept(craftItemID);
  279. sleep(random(400,600));
  280. try{
  281. bank.withdraw(craftItemID, 0);
  282. } catch(Exception e) {
  283. log("Out of crafting materials - stopping script");
  284. outOfItems = true;
  285. }
  286. }
  287. return inventory.getCount(craftItemID) == 28;
  288. }
  289.  
  290. private boolean Bank2(){
  291. bank.depositAllExcept(mouldID,craftItemID);
  292. boolean mould = false;
  293. boolean item = false;
  294. if(inventory.getCount(mouldID) == 1 || setItem(mouldID,1))
  295. mould = true;
  296. if(inventory.getCount(craftItemID) == 27 || setItem(craftItemID,27))
  297. item = true;
  298. return mould && item;
  299. }
  300.  
  301. private boolean Bank3(){
  302. bank.depositAllExcept(mouldID,craftItemID,gemID);
  303. boolean mould = false;
  304. boolean item = false;
  305. boolean gem = false;
  306. if(inventory.getCount(mouldID) == 1 || setItem(mouldID,1))
  307. mould = true;
  308. if(inventory.getCount(craftItemID) == 13 || setItem(craftItemID,13))
  309. item = true;
  310. if(inventory.getCount(gemID) == 13 || setItem(gemID,13))
  311. gem = true;
  312. return mould && item && gem;
  313. }
  314.  
  315. private boolean setItem(int id, int num){
  316. if(inventory.isFull()){
  317. bank.depositAll();
  318. sleep(400,600);
  319. }
  320. if(inventory.getCount(id) > num){
  321. bank.deposit(id, inventory.getCount(id) - num);
  322. sleep(400,600);
  323. }
  324. if(inventory.getCount(id) < num){
  325. bank.withdraw(id, num - inventory.getCount(id));
  326. sleep(400,600);
  327. }
  328. return inventory.getCount(id) == num;
  329. }
  330.  
  331. private int WalkToForge(){
  332. task = "Walking To Forge";
  333. if(walkTo(forgeTile,forgeArea))
  334. job = Job.OpenForge;
  335. return 300;
  336. }
  337.  
  338. private int WalkToBank(){
  339. task = "Walking To Bank";
  340. if(walkTo(bankTile,bankArea))
  341. job = Job.Bank;
  342. return 300;
  343. }
  344.  
  345. private boolean walkTo(RSTile tile,RSArea area){
  346. if(!area.contains(getMyPlayer().getLocation()) &&
  347. (walking.getDestination() == null || !area.contains(walking.getDestination()))){
  348. if(webby == null || !webby.getEnd().equals(tile))
  349. webby = web.getWeb(getMyPlayer().getLocation(), tile);
  350. webby.step();
  351. NRG();
  352. }
  353. return area.contains(getMyPlayer().getLocation());
  354. }
  355.  
  356. private void NRG(){
  357. if(!walking.isRunEnabled() && walking.getEnergy() >= random(9,20)){
  358. mouse.click(interfaces.getComponent(750, 1).getPoint(), 5, 5, true);
  359. sleep(500,1000);
  360. }
  361. }
  362.  
  363. @Override
  364. public void onRepaint(Graphics g) {
  365. mx= mouse.getLocation().x;
  366. my= mouse.getLocation().y;
  367. gainedXP= skills.getCurrentExp(skill) - startXP;
  368. totalItemsCrafted= (int)(gainedXP / xpOfItem);
  369. realHours = (System.currentTimeMillis() - startTime) / 3600000.0;
  370. craftsPerHour = (int)((double)totalItemsCrafted / realHours);
  371. xpPerHour = (int)(craftsPerHour * xpOfItem);
  372. levelPercent = skills.getPercentToNextLevel(skill);
  373. g.setColor(RED);
  374. g.fillRoundRect(3, 320, 511, 21, 16, 16);
  375. g.setColor(GREEN);
  376. g.fillRoundRect(3, 320, (int)(levelPercent/100.0 * 511.0), 21, 16, 16);
  377. g.drawString("+ "+totalItemsCrafted+" Items Made ("+craftsPerHour+" P/H)", 8, 281);
  378. g.drawString("+ "+gainedXP+" Exp Gained ("+xpPerHour+" P/H)", 8, 299);
  379. g.drawString("Making "+itemName+"'s At "+locationName, 8, 317);
  380. g.setColor(BLACK);
  381. g.drawLine(5, my, 750, my);
  382. g.drawLine(mx, 5, mx, 500);
  383. g.drawString(Timer.format(System.currentTimeMillis() - startTime), 460, 335);
  384. g.drawString(levelPercent+"% To Level "+(skills.getRealLevel(skill)+1)+" "+skillName, 200, 335);
  385. g.drawString(task, 13, 335);
  386. }
  387.  
  388. class AFGUI extends JFrame {
  389. public AFGUI() {
  390. setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  391. setBounds(100, 100, 320, 135);
  392. final JPanel contentPane = new JPanel();
  393. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  394. setContentPane(contentPane);
  395. contentPane.setLayout(null);
  396.  
  397. final JComboBox LocationSelect = new JComboBox();
  398. LocationSelect.setModel(new DefaultComboBoxModel(
  399. new String[] {"Edgeville", "Alkharid"}));
  400. LocationSelect.setBounds(5, 5, 150, 30);
  401. contentPane.add(LocationSelect);
  402.  
  403. final JComboBox mSpeed = new JComboBox();
  404. mSpeed.setModel(new DefaultComboBoxModel(
  405. new String[] {"Mouse speed 1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}));
  406. mSpeed.setBounds(160, 5, 150, 30);
  407. contentPane.add(mSpeed);
  408.  
  409. final JComboBox ItemSelect = new JComboBox();
  410. ItemSelect.setModel(new DefaultComboBoxModel(
  411. new String[] {"Ring", "Necklace", "Amulet", "Bracelet", "Holy Symbol", "Silver Tiara", "Silver Bar", "Gold Bar"}));
  412. ItemSelect.setBounds(5, 40, 150, 30);
  413. contentPane.add(ItemSelect);
  414.  
  415. final JComboBox gemSelect = new JComboBox();
  416. gemSelect.setModel(new DefaultComboBoxModel(
  417. new String[] {"No Gem", "Sapphire", "Emerald", "Ruby", "Diamond", "Dragonstone", "Onyx"}));
  418. gemSelect.setBounds(160, 40, 150, 30);
  419. contentPane.add(gemSelect);
  420.  
  421. JButton btnStart = new JButton("START");
  422. btnStart.addActionListener(new ActionListener() {
  423. public void actionPerformed(ActionEvent arg0) {
  424. try {
  425. declareVariables(ItemSelect.getSelectedIndex(),
  426. gemSelect.getSelectedIndex(),
  427. Location.getValueAtIndex(LocationSelect.getSelectedIndex()),
  428. mSpeed.getSelectedIndex()+1);
  429. } catch (Exception e) {
  430. JOptionPane.showConfirmDialog(gui, "error: "+e);
  431. return;
  432. }
  433. guiWait = false;
  434. gui.dispose();
  435. }
  436. });
  437. btnStart.setBounds(85, 75, 150, 30);
  438. contentPane.add(btnStart);
  439. }
  440. }
  441.  
  442.  
  443. private void declareVariables(int craft,int gem,Location loc,int speed){
  444. /*Ring
  445. *Neck
  446. *Amulet
  447. *Bracelet
  448. *Holy Symbol
  449. *Tiara
  450. *Silver bar
  451. *Gold bar
  452. */
  453. final double[][] XP = {
  454. {15.0, 40.0, 55.0, 70.0, 85.0, 100.0, 115.0},
  455. {20.0, 55.0, 60.0, 75.0, 90.0, 105.0, 120.5},
  456. {30.0, 65.0, 70.0, 85.0, 100.0, 150.0, 165.0},
  457. {25.0, 60.0, 65.0, 80.0, 95.0, 110.0, 125.0},
  458. {50.0},
  459. {52.5},
  460. {13.7},
  461. {22.5}
  462. };
  463. final int[][] BANKMODE = {
  464. {2,3,3,3,3,3,3},
  465. {2,3,3,3,3,3,3},
  466. {2,3,3,3,3,3,3},
  467. {2,3,3,3,3,3,3},
  468. {2},
  469. {2},
  470. {1},
  471. {1}
  472. };
  473. final int[][] COMPONENTS = {
  474. {82,84,86,88,90,92,94},
  475. {68,70,72,74,76,78,80},
  476. {53,55,57,59,61,63,65},
  477. {33,35,37,39,41,43,45},
  478. {16},
  479. {44},
  480. {14},
  481. {14}
  482. };
  483. final int[] INTERFACES = {446,446,446,446,905,905,438,438};
  484. final int[] GEMIDS = {0,1607,1605,1603,1601,1615,6573};
  485. final int[] CRAFTITEM = {2357,2357,2357,2357,2355,2355,442,444};
  486. final int[] MOULD = {1592,1597,1595,11065,1599,5523,0,0};
  487. final String[] itemmys = {"Ring","Necklace","Amulet","Bracelet","Holy Symbol","Tiara","Silver Bar","Gold Bar"};
  488. final String[] gemmys = {"Gold ","Sapphire ","Emerald ","Ruby ","Diamond ","Dragonstone ","Onyx "};
  489. bankMode = BANKMODE[craft][gem];
  490. xpOfItem = XP[craft][gem];
  491. interfaceID = INTERFACES[craft];
  492. componentID= COMPONENTS[craft][gem];
  493. mouldID = MOULD[craft];
  494. craftItemID = CRAFTITEM[craft];
  495. gemID = GEMIDS[gem];
  496. mouseSpeed = speed;
  497. if(loc.equals(Location.Edgeville)){
  498. forgeTile= new RSTile(3108,3499);
  499. bankTile= new RSTile(3094,3496);
  500. bankArea= new RSArea(new RSTile (3091,3488),new RSTile(3098,3499));
  501. forgeArea= new RSArea(new RSTile(3106,3497),new RSTile(3111,3502));
  502. forgeID = 26814;
  503. }else if(loc.equals(Location.Alkharid)){
  504. forgeTile= new RSTile(3275,3186);
  505. bankTile= new RSTile(3269,3167);
  506. bankArea= new RSArea(new RSTile (3269,3161),new RSTile(3272,3173));
  507. forgeArea= new RSArea(new RSTile (3272,3188),new RSTile(3277,3184));
  508. forgeID = 2742;
  509. if(craft == 6 || craft == 7){
  510. skill= skills.SMITHING;
  511. skillCheckXP= skills.INTERFACE_SMITHING;
  512. skillName = "Smithing";
  513. }else{
  514. skill= skills.CRAFTING;
  515. skillCheckXP= skills.INTERFACE_CRAFTING;
  516. skillName = "Crafting";
  517. }
  518. locationName = loc.name();
  519. switch(craft){
  520. case 0:
  521. case 1:
  522. case 2:
  523. case 3:
  524. itemName = gemmys[gem]+itemmys[craft];
  525. break;
  526. default:
  527. itemName = itemmys[craft];
  528. break;
  529. }
  530.  
  531. }}
  532.  
  533. }
Add Comment
Please, Sign In to add comment