Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.34 KB | None | 0 0
  1. import org.rsbot.event.listeners.PaintListener;
  2. import org.rsbot.script.Script;
  3. import org.rsbot.script.ScriptManifest;
  4. import org.rsbot.script.methods.Game;
  5. import org.rsbot.script.methods.Skills;
  6. import org.rsbot.script.wrappers.RSArea;
  7. import org.rsbot.script.wrappers.RSItem;
  8. import org.rsbot.script.wrappers.RSObject;
  9. import org.rsbot.script.wrappers.RSTile;
  10.  
  11. import java.awt.*;
  12. import java.awt.event.MouseEvent;
  13. import java.awt.event.MouseListener;
  14. import java.util.Date;
  15.  
  16. @ScriptManifest(authors = {"TechGuard"}, keywords = "Smithing", name = "TechSmither", version = 1.0, description = "Smelts Everything at Al Kharid")
  17. public class TechSmither extends Script implements PaintListener, MouseListener {
  18. public boolean running, usedBank = false;
  19. public long startTime;
  20. public int startExp = 0, startLevel = 0, gainedExp = 0, gainedLevel = 0,
  21. smeltedBars = 0, barID = 0, runEnergy = 50;
  22. public int[] oreID;
  23.  
  24. RSTile bankTile, furnaceTile;
  25. RSArea bankArea, furnaceArea;
  26.  
  27. public boolean onStart(){
  28. camera.setPitch(true);
  29. camera.setPitch(true);
  30. startTime = System.currentTimeMillis();
  31. startExp = skills.getCurrentExp(Skills.SMITHING);
  32. startLevel = skills.getCurrentLevel(Skills.SMITHING);
  33. trentCrafterGUI g = new trentCrafterGUI();
  34. g.setVisible(true);
  35. while(g.isVisible()){
  36. sleep(100);
  37. }
  38. running = true;
  39. Date date = new Date(startTime);
  40. sm("Started at "+String.format("%02d:%02d:%02d", date.getHours(), date.getMinutes(), date.getSeconds()));
  41. return true;
  42. }
  43.  
  44. public void onFinish(){
  45. running = false;
  46. Date date = new Date(System.currentTimeMillis());
  47. sm("Stopped at "+String.format("%02d:%02d:%02d", date.getHours(), date.getMinutes(), date.getSeconds()));
  48. Date date2 = new Date(System.currentTimeMillis()-startTime);
  49. sm("Runned for "+String.format("%02d:%02d:%02d", date2.getHours(), date2.getMinutes(), date2.getSeconds()));
  50. }
  51.  
  52. public void sm(String s){
  53. log(s);
  54. }
  55.  
  56. public boolean onBreakStart(){
  57. running = false;
  58. return true;
  59. }
  60.  
  61. public void onBreakFinish(){
  62. running = true;
  63. }
  64.  
  65. public void mouseClicked(MouseEvent m) {
  66. }
  67.  
  68. public void mouseEntered(MouseEvent m) {
  69. }
  70.  
  71. public void mouseExited(MouseEvent m) {
  72. }
  73.  
  74. public void mousePressed(MouseEvent m) {
  75. }
  76.  
  77. public void mouseReleased(MouseEvent m) {
  78. }
  79.  
  80. public void antiBan(){
  81. int rand = random(0, 1099);
  82. if (rand < 99) {
  83. runEnergy = random(30, 100);
  84. } else if (rand >= 99 && rand < 199) {
  85. camera.setAngle(random(1, 360));
  86. } else if (rand >= 199 && rand < 299) {
  87. mouse.move(random(1, 770), random(1, 550));
  88. } else if (rand >= 299 && rand < 399) {
  89. mouse.move(random(1, 770), random(1, 550));
  90. } else if (rand >= 399 && rand < 499) {
  91. mouse.setSpeed(random(6, 8));
  92. } else if (rand >= 499 && rand < 599) {
  93. if(game.getCurrentTab() != Game.TAB_INVENTORY){
  94. game.openTab(Game.TAB_INVENTORY);
  95. } else
  96. if(game.getCurrentTab() != Game.TAB_STATS){
  97. game.openTab(Game.TAB_STATS);
  98. sleep(random(500, 1000));
  99. skills.doHover(Skills.SMITHING);
  100. }
  101. }
  102. }
  103.  
  104. public int loop(){
  105. if(!running) return 50;
  106. if(game.isLoggedIn()){
  107. mouse.setSpeed(random(6, 8));
  108. }
  109. while(interfaces.get(906).containsText("Logging")){
  110. sleep(10000);
  111. }
  112. if(walking.getEnergy() >= runEnergy && getMyPlayer().isMoving()){
  113. walking.setRun(true);
  114. return random(500, 1000);
  115. }
  116. if(getMyPlayer().isMoving()){
  117. antiBan();
  118. sleep(random(500, 1000));
  119. }
  120. if((inventory.getCount(oreID) > 0 && inventory.getCount(barID) < 1) && usedBank){
  121. if(!atBank()) usedBank = false;
  122. walking.walkTo(furnaceTile);
  123. return random(1000, 1500);
  124. }
  125. if(atBank()){
  126. if(bank.isOpen()){
  127. sleep(random(500, 800));
  128. if(inventory.getCount(barID) > 0){
  129. smeltedBars += inventory.getCount(barID);
  130. deposit(barID, inventory.getCount(barID));
  131. sleep(random(600, 1200));
  132. }
  133. for(int i = 0; i < oreID.length; i++){
  134. if(inventory.getCount(oreID[i]) > 0){
  135. deposit(oreID[i], inventory.getCount(oreID[i]));
  136. sleep(random(600, 1200));
  137. }
  138. }
  139. int j = (int)(28 / oreID.length);
  140. for(int i = 0; i < oreID.length; i++){
  141. withdraw(oreID[i], j);
  142. sleep(random(500, 1000));
  143. }
  144. bank.close();
  145. usedBank = true;
  146. return random(500, 100);
  147. } else {
  148. RSObject banker = objects.getNearest(35648);
  149. if(banker != null){
  150. if(!calc.tileOnScreen(banker.getLocation())){
  151. walking.walkTo(bankTile);
  152. return random(500, 1000);
  153. }
  154. if(!banker.doAction("Use-quickly")){
  155. camera.turnTo(banker);
  156. } else {
  157. sleep(800, 900);
  158. }
  159. return random(500, 900);
  160. }
  161. }
  162. }
  163. if(atFurnace()){
  164. if((inventory.getCount(oreID) < 1 && inventory.getCount(barID) > 0) && !isSmelting()){
  165. walking.walkTo(bankTile);
  166. return random(1000, 1500);
  167. }
  168. if(isSmelting()){
  169. antiBan();
  170. return random(100, 1500);
  171. } else {
  172. RSObject furnace = objects.getNearest(11666);
  173. if(furnace != null){
  174. if(!furnace.isOnScreen()){
  175. walking.walkTo(furnaceTile);
  176. return random(500, 1000);
  177. }
  178. if(!furnace.doAction("Smelt")){
  179. camera.turnTo(furnace);
  180. } else {
  181. interfaces.getComponent(905, 16).doClick(true);
  182. sleep(800, 900);
  183. }
  184. return random(500, 900);
  185. }
  186. }
  187. }
  188. if((inventory.getCount(oreID) > 0 && inventory.getCount(barID) < 1)){
  189. walking.walkTo(furnaceTile);
  190. return random(500, 1000);
  191. }
  192. if((inventory.getCount(oreID) < 1 && inventory.getCount(barID) > 0)){
  193. walking.walkTo(bankTile);
  194. return random(500, 1000);
  195. }
  196. return 50;
  197. }
  198.  
  199. public boolean atBank(){
  200. return bankArea.contains(getMyPlayer().getLocation());
  201. }
  202.  
  203. public boolean atFurnace(){
  204. return furnaceArea.contains(getMyPlayer().getLocation());
  205. }
  206.  
  207. public boolean isSmelting(){
  208. if(getMyPlayer().getAnimation() == -1){
  209. sleep(random(200, 500));
  210. if(getMyPlayer().getAnimation() == -1){
  211. sleep(random(200, 500));
  212. if(getMyPlayer().getAnimation() == -1){
  213. return false;
  214. }
  215. }
  216. }
  217. return true;
  218. }
  219.  
  220. public void withdraw(int itemId, int amount){
  221. RSItem item = bank.getItem(itemId);
  222. String action = "";
  223. if(amount == 1){
  224. item.doClick(true);
  225. return;
  226. }
  227. if(amount == 0){
  228. action = "Withdraw-All";
  229. }
  230. if(item.getComponent().containsAction("Withdraw-"+amount)){
  231. action = "Withdraw-"+amount;
  232. } else {
  233. action = "Withdraw-X";
  234. }
  235. item.getComponent().doAction(action);
  236. if(action.equals("Withdraw-X")){
  237. sleep(random(1000, 1500));
  238. keyboard.sendText(""+amount, true);
  239. }
  240. }
  241.  
  242. public void deposit(int itemId, int amount){
  243. RSItem item = inventory.getItem(itemId);
  244. String action = "";
  245. if(amount == 1){
  246. item.doClick(true);
  247. return;
  248. }
  249. if(amount == 0){
  250. action = "Deposit-All";
  251. }
  252. if(item.getComponent().containsAction("Deposit-"+amount)){
  253. action = "Deposit-"+amount;
  254. } else {
  255. action = "Deposit-X";
  256. }
  257. item.getComponent().doAction(action);
  258. if(action.equals("Deposit-X")){
  259. sleep(random(1000, 1500));
  260. keyboard.sendText(""+amount, true);
  261. }
  262. }
  263.  
  264. private final BasicStroke stroke1 = new BasicStroke(1);
  265.  
  266. private final Font font1 = new Font("Arial", 1, 18);
  267. private final Font font2 = new Font("Arial", 1, 24);
  268.  
  269. public void onRepaint(Graphics g1){
  270. gainedExp = skills.getCurrentExp(Skills.SMITHING)-startExp;
  271. gainedLevel = skills.getCurrentLevel(Skills.SMITHING)-startLevel;
  272. String time = (new Date(System.currentTimeMillis())).getHours()+
  273. " hours and "+(new Date(System.currentTimeMillis())).getMinutes()+" minutes";
  274. /*
  275. Graphics2D g = (Graphics2D)g1;
  276. g.setColor(new Color(255, 255, 255));
  277. g.fillRect(3, 341, 504, 127);
  278. String str = "TechSmither v1.0";
  279. g.setFont(font2);
  280. g.setColor(new Color(0, 0, 0));
  281. g.drawString(str, 350, 173-(str.length()/2));
  282. g.setFont(font1);
  283. g.drawString("Gained Exp: "+gainedExp, 10, 350);
  284. g.drawString("Gained Level(s): "+gainedLevel, 10, 365);
  285. g.drawString("Bars Smelted: "+smeltedBars, 10, 380);
  286. g.drawString("Running for: "+time, 10, 395);*/
  287. }
  288.  
  289. public class trentCrafterGUI extends javax.swing.JFrame {
  290. public trentCrafterGUI() {
  291. initComponents();
  292. }
  293. @SuppressWarnings("unchecked")
  294. private void initComponents() {
  295. jLabel1 = new javax.swing.JLabel();
  296. jComboBox1 = new javax.swing.JComboBox();
  297. jComboBox2 = new javax.swing.JComboBox();
  298. jLabel2 = new javax.swing.JLabel();
  299. jLabel3 = new javax.swing.JLabel();
  300. jButton1 = new javax.swing.JButton();
  301. jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
  302. jLabel1.setText("TechSmither v1.0");
  303. String[] bars = {"Bronze Bar", "Iron Bar", "Silver Bar",
  304. "Steel Bar", "Gold Bar", "Mithril Bar", "Adamant Bar", "Rune Bar"};
  305. jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(bars));
  306. jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Al Kharid"}));
  307. jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
  308. jLabel2.setText("Bar to Smelt:");
  309. jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
  310. jLabel3.setText("Location:");
  311. jButton1.setText("Start");
  312. jButton1.addActionListener(new java.awt.event.ActionListener() {
  313. public void actionPerformed(java.awt.event.ActionEvent evt) {
  314. jButton1ActionPerformed(evt);
  315. }
  316. });
  317. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  318. getContentPane().setLayout(layout);
  319. layout.setHorizontalGroup(layout
  320. .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  321. .addGroup(layout.createSequentialGroup()
  322. .addContainerGap()
  323. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  324. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,layout.createSequentialGroup()
  325. .addComponent(jLabel1)
  326. .addGap(174,174,174))
  327. .addGroup(layout.createSequentialGroup()
  328. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  329. .addComponent(jComboBox1,javax.swing.GroupLayout.PREFERRED_SIZE,276,javax.swing.GroupLayout.PREFERRED_SIZE)
  330. .addComponent(jComboBox2,javax.swing.GroupLayout.PREFERRED_SIZE,276,javax.swing.GroupLayout.PREFERRED_SIZE)
  331. .addGroup(layout.createSequentialGroup()
  332. .addComponent(jLabel2)
  333. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,168,javax.swing.GroupLayout.PREFERRED_SIZE))
  334. .addGroup(layout.createSequentialGroup()
  335. .addComponent(jLabel3)
  336. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,219,javax.swing.GroupLayout.PREFERRED_SIZE)))
  337. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE))
  338. .addGroup(layout.createSequentialGroup()
  339. .addComponent(jButton1,javax.swing.GroupLayout.DEFAULT_SIZE,276,Short.MAX_VALUE)
  340. .addContainerGap()))));
  341. layout.setVerticalGroup(layout
  342. .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  343. .addGroup(layout.createSequentialGroup()
  344. .addContainerGap()
  345. .addComponent(jLabel1)
  346. .addGap(18, 18, 18)
  347. .addComponent(jLabel2)
  348. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  349. .addComponent(jComboBox1,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE)
  350. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  351. .addComponent(jLabel3)
  352. .addGap(4, 4, 4)
  353. .addComponent(jComboBox2,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE)
  354. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  355. .addComponent(jButton1)
  356. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE)));
  357. pack();
  358. }
  359. private javax.swing.JButton jButton1;
  360. private javax.swing.JComboBox jComboBox1;
  361. private javax.swing.JComboBox jComboBox2;
  362. private javax.swing.JLabel jLabel1;
  363. private javax.swing.JLabel jLabel2;
  364. private javax.swing.JLabel jLabel3;
  365.  
  366. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){
  367. String itemName = jComboBox1.getSelectedItem().toString();
  368. String location = jComboBox2.getSelectedItem().toString();
  369. if(location.contains("Al Kharid")){
  370. bankTile = new RSTile(3269, 3168);
  371. bankArea = new RSArea(new RSTile(3272, 3173), new RSTile(3269, 3161));
  372. furnaceTile = new RSTile(3274, 3186);
  373. furnaceArea = new RSArea(new RSTile(3276, 3188), new RSTile(3273, 3184));
  374. //RSArea = new RSArea( north-east RSTile, South-west RSTile );
  375. }
  376. if(itemName.equals("Bronze Bar")){
  377. barID = 2349;
  378. oreID = new int[]{436,438};
  379. }
  380. if(itemName.equals("Iron Bar")){
  381. barID = 2351;
  382. oreID = new int[]{440};
  383. }
  384. if(itemName.equals("Silver Bar")){
  385. barID = 2355;
  386. oreID = new int[]{442};
  387. }
  388. if(itemName.equals("Steel Bar")){
  389. barID = 2353;
  390. oreID = new int[]{440,453,453};
  391. }
  392. if(itemName.equals("Gold Bar")){
  393. barID = 2357;
  394. oreID = new int[]{444};
  395. }
  396. if(itemName.equals("Mithril Bar")){
  397. barID = 2359;
  398. oreID = new int[]{447,453,453,453};
  399. }
  400. if(itemName.equals("Adamant Bar")){
  401. barID = 2361;
  402. oreID = new int[]{449,453,453,453,453,453,453};
  403. }
  404. if(itemName.equals("Rune Bar")){
  405. barID = 2363;
  406. oreID = new int[]{451,453,453,453,453,453,453,453,453};
  407. }
  408. this.setVisible(false);
  409. }
  410. }
  411. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement