Advertisement
Guest User

Untitled

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