Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.69 KB | None | 0 0
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Container;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Point;
  8. import java.awt.Rectangle;
  9. import java.awt.RenderingHints;
  10. import java.awt.event.ActionEvent;
  11. import java.awt.event.ActionListener;
  12. import java.awt.event.MouseEvent;
  13. import java.awt.event.MouseListener;
  14.  
  15. import javax.swing.DefaultComboBoxModel;
  16. import javax.swing.GroupLayout;
  17. import javax.swing.JButton;
  18. import javax.swing.JComboBox;
  19. import javax.swing.JFrame;
  20. import javax.swing.JLabel;
  21. import javax.swing.LayoutStyle;
  22.  
  23. import org.rsbot.event.listeners.PaintListener;
  24. import org.rsbot.script.Script;
  25. import org.rsbot.script.ScriptManifest;
  26. import org.rsbot.script.util.Timer;
  27. import org.rsbot.script.wrappers.*;
  28. import java.awt.*;
  29.  
  30.  
  31. @ScriptManifest(authors = { "Itz_Craze" }, name = "cSmither", version = 1.10, description = "AIO Varrock Smither")
  32. public class cSmither extends Script implements PaintListener, MouseListener{
  33.  
  34. private int barID;
  35. private double barXP;
  36. private int barsUsed;
  37. private int expGained;
  38. private int startXP;
  39. private long startTime;
  40. private int anvilID = 2783;
  41. private int bankID = 782;
  42. private int interfaceID = 300;
  43. private int componentID;
  44. private int hammerID = 2347;
  45. RSTile banktile = new RSTile(3189, 3435);
  46. RSTile anviltile = new RSTile(3188, 3425);
  47. private boolean scroll = false;
  48. private int runs = 0;
  49.  
  50. private static final Color MOUSE_COLOR = new Color(255, 255, 255),
  51. MOUSE_BORDER_COLOR = new Color(0, 0, 153),
  52. MOUSE_CENTER_COLOR = new Color(51, 255, 255);
  53. private boolean pressed = false;
  54. private int absoluteY = 0;
  55.  
  56. private boolean guiwait = true;
  57. cSmitherGUI g = new cSmitherGUI();
  58.  
  59. public boolean onStart(){
  60.  
  61. startTime = System.currentTimeMillis();
  62. startXP = skills.getCurrentExp(skills.SMITHING);
  63.  
  64. g.setVisible(true);
  65. while(guiwait == true){
  66. sleep(500);
  67. }
  68.  
  69. return true;
  70. }
  71.  
  72. @Override
  73. public int loop() {
  74. if(inventory.getCount(barID) > 2){
  75. if(atBank()){
  76. walkToAnvil();
  77. } else if(atAnvil()){
  78. makeItems();
  79. }
  80. } else if(inventory.getCount(barID) <= 2){
  81. if(atBank()){
  82. useBank();
  83. } else {
  84. walkToBank();
  85. }
  86. }
  87. return 0;
  88. }
  89.  
  90. private boolean atAnvil() {
  91. RSObject anvil = objects.getNearest(anvilID);
  92. if(anvil != null){
  93. if(anvil.isOnScreen()){
  94. return true;
  95. }
  96. }
  97. return false;
  98. }
  99.  
  100. private void walkToBank() {
  101. walking.walkTileMM(banktile);
  102. sleep(1000, 1600);
  103. while(getMyPlayer().isMoving()){
  104. sleep(180, 400);
  105. }
  106.  
  107. }
  108.  
  109. private void useBank() {
  110. RSObject Bank = objects.getNearest(bankID);
  111. if(bank.isOpen()){
  112. bank.depositAllExcept(hammerID, barID);
  113. sleep(400, 700);
  114. if(bank.getCount(barID) <= 5){
  115. env.takeScreenshot(true);
  116. stopScript();
  117. }
  118. bank.withdraw(barID, 27);
  119. sleep(400, 700);
  120. bank.close();
  121. } else {
  122. Bank.interact("Use-quickly");
  123. sleep(600, 1000);
  124. }
  125.  
  126. }
  127.  
  128. private void makeItems() {
  129. RSItem bar = inventory.getItem(barID);
  130. RSObject anvil = objects.getNearest(anvilID);
  131. if(anvil != null && anvil.isOnScreen()){
  132. bar.interact("Use");
  133. sleep(180, 400);
  134. anvil.doClick();
  135. sleep(1500, 1700);
  136. if(interfaces.get(interfaceID).isValid()){
  137. if(scroll == false){
  138. interfaces.getComponent(interfaceID, componentID).interact("Make All");
  139. Timer t = new Timer(3000);
  140. while(t.isRunning()){
  141. if(getMyPlayer().getAnimation() != -1){
  142. t.reset();
  143. if(interfaces.canContinue()){
  144. interfaces.clickContinue();
  145. }
  146. }
  147. sleep(100);
  148. }
  149. runs++;
  150. } else {
  151. if(runs == 0){
  152. mouse.move(495, 276);
  153. mouse.click(true);
  154. interfaces.getComponent(interfaceID, componentID).interact("Make All");
  155. Timer t = new Timer(3000);
  156. while(t.isRunning()){
  157. if(getMyPlayer().getAnimation() != -1){
  158. t.reset();
  159. if(interfaces.canContinue()){
  160. interfaces.clickContinue();
  161. }
  162. }
  163. sleep(100);
  164. }
  165. } else {
  166. interfaces.getComponent(interfaceID, componentID).interact("Make All");
  167. Timer t = new Timer(3000);
  168. while(t.isRunning()){
  169. if(getMyPlayer().getAnimation() != -1){
  170. t.reset();
  171. if(interfaces.canContinue()){
  172. interfaces.clickContinue();
  173. }
  174. }
  175. sleep(100);
  176. }
  177. }
  178. runs++;
  179. }
  180. }
  181. }
  182. }
  183.  
  184.  
  185. private void walkToAnvil() {
  186. walking.walkTileMM(anviltile);
  187. sleep(1000, 1600);
  188. while(getMyPlayer().isMoving()){
  189. sleep(180, 400);
  190. }
  191.  
  192. }
  193.  
  194. private boolean atBank() {
  195. RSObject bank = objects.getNearest(bankID);
  196. if(bank != null){
  197. if(bank.isOnScreen()){
  198. return true;
  199. }
  200. }
  201. return false;
  202. }
  203.  
  204. private void drawMouse(Graphics a) {
  205. ((Graphics2D) a).setRenderingHints(new RenderingHints(
  206. RenderingHints.KEY_ANTIALIASING,
  207. RenderingHints.VALUE_ANTIALIAS_ON));
  208. Point p = mouse.getLocation();
  209. Graphics2D spinG = (Graphics2D) a.create();
  210. Graphics2D spinGRev = (Graphics2D) a.create();
  211. Graphics2D spinG2 = (Graphics2D) a.create();
  212. spinG.setColor(MOUSE_BORDER_COLOR);
  213. spinGRev.setColor(MOUSE_COLOR);
  214. spinG.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2
  215. * Math.PI / 180.0, p.x, p.y);
  216. spinGRev.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d)
  217. * 2 * Math.PI / 180.0, p.x, p.y);
  218. final int outerSize = 20;
  219. final int innerSize = 12;
  220. spinG.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
  221. BasicStroke.JOIN_ROUND));
  222. spinGRev.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
  223. BasicStroke.JOIN_ROUND));
  224. spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize,
  225. outerSize, 100, 75);
  226. spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize,
  227. outerSize, -100, 75);
  228. spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2),
  229. innerSize, innerSize, 100, 75);
  230. spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2),
  231. innerSize, innerSize, -100, 75);
  232. a.setColor(MOUSE_CENTER_COLOR);
  233. a.fillOval(p.x, p.y, 2, 2);
  234. spinG2.setColor(MOUSE_CENTER_COLOR);
  235. spinG2.rotate(System.currentTimeMillis() % 2000d / 2000d * 360d
  236. * Math.PI / 180.0, p.x, p.y);
  237. spinG2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
  238. BasicStroke.JOIN_ROUND));
  239. spinG2.drawLine(p.x - 5, p.y, p.x + 5, p.y);
  240. spinG2.drawLine(p.x, p.y - 5, p.x, p.y + 5);
  241. }
  242.  
  243. //START: Code generated using Enfilade's Easel
  244. private final Color color1 = new Color(0, 0, 102);
  245. private final Color color2 = new Color(0, 0, 0);
  246. private final Color color3 = new Color(255, 255, 255);
  247.  
  248. private final BasicStroke stroke1 = new BasicStroke(1);
  249.  
  250. private final Font font1 = new Font("Arial", 0, 18);
  251. private final Font font2 = new Font("Arial", 0, 13);
  252.  
  253.  
  254.  
  255.  
  256. public void onRepaint(Graphics g1) {
  257. drawMouse(g1);
  258.  
  259. expGained = skills.getCurrentExp(skills.SMITHING) - startXP;
  260.  
  261. long milis = System.currentTimeMillis() - startTime;
  262. long hours = milis / (1000 * 60 * 60);
  263. milis -= hours * (1000 * 60 * 60);
  264. long minutes = milis / (1000 * 60);
  265. milis -= minutes * (1000 * 60);
  266. long seconds = milis / (1000);
  267. milis = seconds * 1000;
  268.  
  269. float xpsec = 0;
  270. if (minutes > 0 || hours > 0 || seconds > 0 && expGained > 0){
  271. xpsec = ((float) expGained /(float)(seconds + (minutes * 60) + (hours * 60 * 60)));
  272. }
  273. float xpmin = xpsec * 60;
  274. float xphour = xpmin * 60;
  275.  
  276. barsUsed = (int) (expGained / barXP);
  277.  
  278. Graphics2D g = (Graphics2D)g1;
  279. g.setColor(color1);
  280. g.fillRoundRect(8, 11, 171, 104, 16, 16);
  281. g.setColor(color2);
  282. g.setStroke(stroke1);
  283. g.drawRoundRect(8, 11, 171, 104, 16, 16);
  284. g.setFont(font1);
  285. g.setColor(color3);
  286. g.drawString("cSmither", 50, 30);
  287. g.setFont(font2);
  288. g.drawString("Time Run: " + hours + ":" + minutes + ":" + seconds, 13, 50);
  289. g.drawString("Bars Used: " + barsUsed, 13, 70);
  290. g.drawString("XP Gained: " + expGained, 13, 90);
  291. g.drawString("XP Per Hr: " + xphour, 13, 110);
  292. }
  293. //END: Code generated using Enfilade's Easel
  294.  
  295. /**
  296. * @author Alex Martin
  297. */
  298. public class cSmitherGUI extends JFrame {
  299. public cSmitherGUI() {
  300. initComponents();
  301. }
  302.  
  303. private void button1ActionPerformed(ActionEvent e) {
  304. String bar = comboBox1.getSelectedItem().toString();
  305. if(bar.equals("Bronze")){
  306. barID = 2349;
  307. barXP = 12.5;
  308. } else if(bar.equals("Iron")){
  309. barID = 2351;
  310. barXP = 25;
  311. } else if(bar.equals("Steel")){
  312. barID = 2353;
  313. barXP = 37.5;
  314. } else if(bar.equals("Mithril")){
  315. barID = 2359;
  316. barXP = 50;
  317. } else if(bar.equals("Adamant")){
  318. barID = 2361;
  319. barXP = 62.5;
  320. } else if(bar.equals("Rune")){
  321. barID = 2363;
  322. barXP = 75;
  323. }
  324. String item = comboBox2.getSelectedItem().toString();
  325. if(item.equals("Dagger")){
  326. componentID = 18;
  327. } else if(item.equals("Hatchet")){
  328. componentID = 26;
  329. } else if(item.equals("Mace")){
  330. componentID = 34;
  331. } else if(item.equals("Medium Helm")){
  332. componentID = 42;
  333. } else if(item.equals("Crossbow Bolts")){
  334. componentID = 50;
  335. } else if(item.equals("Sword")){
  336. componentID = 58;
  337. } else if(item.equals("Dart Tips")){
  338. componentID = 66;
  339. } else if(item.equals("Nails")){
  340. componentID = 74;
  341. } else if(item.equals("Wire")){
  342. componentID = 82;
  343. } else if(item.equals("Arrow Tips")){
  344. componentID = 106;
  345. } else if(item.equals("Scimitar")){
  346. componentID = 114;
  347. } else if(item.equals("Crossbow Limbs")){
  348. componentID = 122;
  349. } else if(item.equals("Longsword")){
  350. componentID = 130;
  351. } else if(item.equals("Throwing Knife")){
  352. componentID = 138;
  353. } else if(item.equals("Full Helm")){
  354. componentID = 146;
  355. } else if(item.equals("Square Shield")){
  356. componentID = 154;
  357. } else if(item.equals("War Hammer")){
  358. componentID = 178;
  359. } else if(item.equals("Battle Axe")){
  360. componentID = 186;
  361. } else if(item.equals("Chainbody")){
  362. componentID = 194;
  363. scroll = true;
  364. } else if(item.equals("Kite Shield")){
  365. componentID = 202;
  366. scroll = true;
  367. } else if(item.equals("Claws")){
  368. componentID = 210;
  369. scroll = true;
  370. } else if(item.equals("2-Handed Sword")){
  371. componentID = 218;
  372. scroll = true;
  373. } else if(item.equals("Plateskirt")){
  374. componentID = 226;
  375. scroll = true;
  376. } else if(item.equals("Platelegs")){
  377. componentID = 234;
  378. scroll = true;
  379. } else if(item.equals("Platebody")){
  380. componentID = 242;
  381. scroll = true;
  382. } else if(item.equals("Pickaxe")){
  383. componentID = 267;
  384. scroll = true;
  385. }
  386. guiwait = false;
  387. g.dispose();
  388. }
  389.  
  390. private void initComponents() {
  391. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  392. // Generated using JFormDesigner Evaluation license - Alex Martin
  393. button1 = new JButton();
  394. label1 = new JLabel();
  395. label2 = new JLabel();
  396. comboBox1 = new JComboBox();
  397. label3 = new JLabel();
  398. comboBox2 = new JComboBox();
  399. label4 = new JLabel();
  400.  
  401. //======== this ========
  402. Container contentPane = getContentPane();
  403.  
  404. //---- button1 ----
  405. button1.setText("Start");
  406. button1.addActionListener(new ActionListener() {
  407. @Override
  408. public void actionPerformed(ActionEvent e) {
  409. button1ActionPerformed(e);
  410. }
  411. });
  412.  
  413. //---- label1 ----
  414. label1.setText("cSmither");
  415. label1.setFont(new Font("Tahoma", Font.PLAIN, 26));
  416.  
  417. //---- label2 ----
  418. label2.setText("Bar to Use:");
  419. label2.setFont(new Font("Tahoma", Font.PLAIN, 18));
  420.  
  421. //---- comboBox1 ----
  422. comboBox1.setModel(new DefaultComboBoxModel(new String[] {
  423. "Bronze",
  424. "Iron",
  425. "Steel",
  426. "Mithril",
  427. "Adamant",
  428. "Rune"
  429. }));
  430.  
  431. //---- label3 ----
  432. label3.setText("Item To Make: ");
  433. label3.setFont(new Font("Tahoma", Font.PLAIN, 18));
  434.  
  435. //---- comboBox2 ----
  436. comboBox2.setModel(new DefaultComboBoxModel(new String[] {
  437. "Dagger",
  438. "Hatchet",
  439. "Mace",
  440. "Medium Helm",
  441. "Crossbow Bolts",
  442. "Sword",
  443. "Dart Tips",
  444. "Nails",
  445. "Wire",
  446. "Arrow Tips",
  447. "Scimitar",
  448. "Crossbow Limbs",
  449. "Longsword",
  450. "Throwing Knife",
  451. "Full Helm",
  452. "Square Shield",
  453. "War Hammer",
  454. "Battle Axe",
  455. "Chainbody",
  456. "Kite Shield",
  457. "Claws",
  458. "2-Handed Sword",
  459. "Plateskirt",
  460. "Platelegs",
  461. "Platebody",
  462. "Pickaxe"
  463. }));
  464.  
  465. //---- label4 ----
  466. label4.setText("By: Itz_Craze");
  467. label4.setFont(new Font("Tahoma", Font.PLAIN, 14));
  468.  
  469. GroupLayout contentPaneLayout = new GroupLayout(contentPane);
  470. contentPane.setLayout(contentPaneLayout);
  471. contentPaneLayout.setHorizontalGroup(
  472. contentPaneLayout.createParallelGroup()
  473. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  474. .addContainerGap()
  475. .addComponent(label4)
  476. .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 241, Short.MAX_VALUE)
  477. .addComponent(button1, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
  478. .addGap(33, 33, 33))
  479. .addGroup(contentPaneLayout.createSequentialGroup()
  480. .addGap(137, 137, 137)
  481. .addComponent(label1)
  482. .addContainerGap(154, Short.MAX_VALUE))
  483. .addGroup(contentPaneLayout.createSequentialGroup()
  484. .addGap(48, 48, 48)
  485. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
  486. .addGroup(contentPaneLayout.createSequentialGroup()
  487. .addComponent(label3)
  488. .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
  489. .addComponent(comboBox2, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  490. .addGroup(contentPaneLayout.createSequentialGroup()
  491. .addComponent(label2)
  492. .addGap(18, 18, 18)
  493. .addComponent(comboBox1, GroupLayout.PREFERRED_SIZE, 167, GroupLayout.PREFERRED_SIZE)))
  494. .addContainerGap(70, Short.MAX_VALUE))
  495. );
  496. contentPaneLayout.setVerticalGroup(
  497. contentPaneLayout.createParallelGroup()
  498. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  499. .addGap(21, 21, 21)
  500. .addComponent(label1)
  501. .addGap(25, 25, 25)
  502. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  503. .addComponent(label2)
  504. .addComponent(comboBox1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  505. .addGap(36, 36, 36)
  506. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  507. .addComponent(label3)
  508. .addComponent(comboBox2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
  509. .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 53, Short.MAX_VALUE)
  510. .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
  511. .addComponent(button1, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
  512. .addComponent(label4))
  513. .addGap(21, 21, 21))
  514. );
  515. pack();
  516. setLocationRelativeTo(getOwner());
  517. // JFormDesigner - End of component initialization //GEN-END:initComponents
  518. }
  519.  
  520. // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
  521. // Generated using JFormDesigner Evaluation license - Alex Martin
  522. private JButton button1;
  523. private JLabel label1;
  524. private JLabel label2;
  525. private JComboBox comboBox1;
  526. private JLabel label3;
  527. private JComboBox comboBox2;
  528. private JLabel label4;
  529. // JFormDesigner - End of variables declaration //GEN-END:variables
  530. }
  531.  
  532. @Override
  533. public void mouseClicked(MouseEvent arg0) {
  534. // TODO Auto-generated method stub
  535.  
  536. }
  537.  
  538. @Override
  539. public void mouseEntered(MouseEvent arg0) {
  540. // TODO Auto-generated method stub
  541.  
  542. }
  543.  
  544. @Override
  545. public void mouseExited(MouseEvent arg0) {
  546. // TODO Auto-generated method stub
  547.  
  548. }
  549.  
  550. @Override
  551. public void mousePressed(MouseEvent arg0) {
  552. Point mp = arg0.getPoint();
  553. final Rectangle toggleRectangle = new Rectangle(493, absoluteY + 3, 16,
  554. 15);
  555. if (toggleRectangle.contains(mp)) {
  556. pressed = !pressed;
  557. }
  558. }
  559.  
  560. @Override
  561. public void mouseReleased(MouseEvent arg0) {
  562. // TODO Auto-generated method stub
  563.  
  564. }
  565.  
  566. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement