Advertisement
Guest User

Untitled

a guest
Mar 26th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.65 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.KeyEvent;
  5.  
  6. import org.tribot.api.DynamicClicking;
  7. import org.tribot.api.General;
  8. import org.tribot.api.Screen;
  9. import org.tribot.api.Timing;
  10. import org.tribot.api.input.Keyboard;
  11. import org.tribot.api.input.Mouse;
  12. import org.tribot.api.interfaces.Positionable;
  13. import org.tribot.api.types.generic.Condition;
  14. import org.tribot.api.types.generic.FilterGroup;
  15. import org.tribot.api2007.Banking;
  16. import org.tribot.api2007.Camera;
  17. import org.tribot.api2007.ChooseOption;
  18. import org.tribot.api2007.Game;
  19. import org.tribot.api2007.GameTab;
  20. import org.tribot.api2007.GameTab.TABS;
  21. import org.tribot.api2007.Constants;
  22. import org.tribot.api2007.Equipment;
  23. import org.tribot.api2007.GroundItems;
  24. import org.tribot.api2007.Interfaces;
  25. import org.tribot.api2007.Inventory;
  26. import org.tribot.api2007.Login;
  27. import org.tribot.api2007.NPCChat;
  28. import org.tribot.api2007.NPCs;
  29. import org.tribot.api2007.Objects;
  30. import org.tribot.api2007.Player;
  31. import org.tribot.api2007.Players;
  32. import org.tribot.api2007.Projection;
  33. import org.tribot.api2007.Skills;
  34. import org.tribot.api2007.Walking;
  35. import org.tribot.api2007.WebWalking;
  36. import org.tribot.api2007.types.RSCharacter;
  37. import org.tribot.api2007.types.RSGroundItem;
  38. import org.tribot.api2007.types.RSInterface;
  39. import org.tribot.api2007.types.RSInterfaceChild;
  40. import org.tribot.api2007.types.RSItem;
  41. import org.tribot.api2007.types.RSNPC;
  42. import org.tribot.api2007.types.RSObject;
  43. import org.tribot.api2007.types.RSPlayer;
  44. import org.tribot.api2007.types.RSTile;
  45. import org.tribot.script.Script;
  46. import org.tribot.script.ScriptManifest;
  47. import org.tribot.script.interfaces.Breaking;
  48. import org.tribot.script.interfaces.MessageListening07;
  49. import org.tribot.script.interfaces.Painting;
  50. import org.tribot.script.interfaces.Pausing;
  51. import org.tribot.script.interfaces.RandomEvents;
  52.  
  53. import javax.imageio.ImageIO;
  54.  
  55. import java.io.IOException;
  56. import java.net.URL;
  57. import java.text.NumberFormat;
  58. import java.text.ParseException;
  59. import java.util.ArrayList;
  60.  
  61. @ScriptManifest(authors = {"Flexx"}, version = 1.0, category = "Money making", name = "Tab Maker", description = "Makes varrock tabs! Have a rope bell pull, and your house in Rimmington")
  62. public class TabMaker extends Script implements Painting, MessageListening07, Breaking, RandomEvents {
  63.  
  64. private final long timeBegan = System.currentTimeMillis();
  65.  
  66. private final RSArea bank =
  67. new RSArea(2946, 3097, 0, 2957, 3229, 0);
  68.  
  69. private final RSArea walk =
  70. new RSArea(2539, 3074, 0, 2608, 3109, 0);
  71.  
  72. private final RSArea portal =
  73. new RSArea(2946, 3097, 0, 2957, 3229, 0);
  74.  
  75. private final RSArea rimmington =
  76. new RSArea(2975, 3191, 0, 2929, 3236, 0);
  77.  
  78. private final RSTile portalTile = new RSTile(2954, 3224, 0);
  79.  
  80. int runeID = 0;
  81. int tabsMade = 0;
  82.  
  83. boolean sup = false;
  84. boolean unlogged;
  85. boolean sleeping = false;
  86.  
  87. private final Color blue = new Color(0, 0, 128);
  88.  
  89. public Point first = new Point(258, 429);
  90. public Point second = new Point(259, 427);
  91. public Point third = new Point(261, 431);
  92.  
  93. private boolean onStart(){
  94. println("Starting script...");
  95. Mouse.setSpeed(General.random(114, 120));
  96. Camera.setCameraAngle(100);
  97. Walking.setControlClick(true);
  98. Walking.setWalkingTimeout(General.random(2200,3200));
  99. println("Your mouse speed is: " + Mouse.getSpeed());
  100. return true;
  101. }
  102.  
  103. private boolean houseSelect(){
  104. if(Interfaces.get(232, 0) != null){
  105. return true;
  106. }
  107. return false;
  108. }
  109.  
  110. private boolean loadScreen(){
  111. if(Screen.getColourAt(108,250).equals(Color.black) && Screen.getColourAt(483,51).equals(Color.black)){
  112. return true;
  113. }
  114. return false;
  115. }
  116.  
  117. private void typeName(){
  118. RSInterface hi = Interfaces.get(232,1);
  119. if(hi != null){
  120. hi.click();
  121. waitFor(new Condition() {
  122. @Override
  123. public boolean active() {
  124. return atHouse() && !loadScreen();
  125. }
  126. }, General.random(5000, 6000));
  127. }
  128.  
  129. }
  130.  
  131. private boolean atHouse(){
  132. if(Player.getPosition().getY() > 3500 || Player.getPosition().getY() < 2500 || Player.getPosition().getX() > 2800){
  133. if(!atArea(rimmington)){
  134. return true;
  135. }
  136. }
  137. return false;
  138. }
  139.  
  140. private void enterHouse(){
  141. RSObject[] portal = Objects.findNearest(10, "Portal");
  142. if(portal.length > 0){
  143. if(portal[0].isOnScreen()){
  144. portal[0].hover();
  145. sleep(200,300);
  146. Mouse.click(3);
  147. waitFor(new Condition() {
  148. @Override
  149. public boolean active() {
  150. return ChooseOption.isOpen();
  151. }
  152. }, General.random(3000, 4000));
  153.  
  154. if(ChooseOption.isOpen()){
  155. if(ChooseOption.isOptionValid("Enter")){
  156. if(ChooseOption.select("Enter")){
  157. waitFor(new Condition() {
  158. @Override
  159. public boolean active() {
  160. return houseSelect();
  161. }
  162. }, General.random(3000, 4000));
  163. }
  164. typeName();
  165. }else{
  166. ChooseOption.close();
  167. }
  168. }
  169. }else{
  170. WebWalking.walkTo(portal[0].getPosition());
  171. sleep(100);
  172. while(Player.isMoving()){
  173. sleep(50);
  174. }
  175. }
  176. }
  177. }
  178.  
  179. private void findButler(){
  180. RSObject[] bell = Objects.findNearest(20, "Rope bell-pull");
  181. if(bell.length > 0){
  182. if(bell[0].isOnScreen()){
  183. if(!Player.isMoving()){
  184. if(!ChooseOption.isOpen()){
  185. bell[0].hover();
  186. sleep(100,200);
  187. if(Game.getUptext().contains("Ring")){
  188. Mouse.click(3);
  189. waitFor(new Condition() {
  190. @Override
  191. public boolean active() {
  192. return ChooseOption.isOpen();
  193. }
  194. }, General.random(500, 800));
  195. }else{
  196. return;
  197. }
  198. }else{
  199. if(ChooseOption.isOptionValid("Ring")){
  200. if(ChooseOption.select("Ring")){
  201. sleep(100,200);
  202. while(Player.isMoving()){
  203. sleep(100,200);
  204. }
  205. waitFor(new Condition() {
  206. @Override
  207. public boolean active() {
  208. return butlerTalking();
  209. }
  210. }, General.random(4000, 5000));
  211. }
  212. }else{
  213. ChooseOption.close();
  214. }
  215. }
  216. }
  217. }else{
  218. Walking.blindWalkTo(bell[0].getPosition());
  219. }
  220. }
  221. }
  222.  
  223. private boolean isButler(){
  224. RSNPC[] butler = NPCs.find("Demon butler");
  225. if(butler.length > 0){
  226. if(butler[0].isOnScreen() && butler[0].getPosition().distanceTo(Player.getPosition()) < 3){
  227. return true;
  228. }
  229. }
  230. return false;
  231. }
  232.  
  233. private boolean butlerTalking(){
  234. if(Interfaces.get(241,1) != null){
  235. return true;
  236. }
  237. return false;
  238. }
  239.  
  240. private boolean chatInterfaces(){
  241. if(Interfaces.get(241,1) != null || Interfaces.get(234, 0) != null || Interfaces.get(228, 0) != null
  242. || Interfaces.get(64,1) != null || enterAmount() || Interfaces.get(242,1) != null || Interfaces.get(230,1) != null ||
  243. Interfaces.get(243,2) != null){
  244. return true;
  245. }
  246. return false;
  247. }
  248.  
  249. private boolean enterAmount(){
  250. if(Screen.getColourAt(first).equals(blue) && Screen.getColourAt(second).equals(blue) && Screen.getColourAt(third).equals(blue)){
  251. return true;
  252. }
  253. return false;
  254. }
  255.  
  256. private boolean chooseOption(){
  257. if(Interfaces.get(234, 0) != null){
  258. return true;
  259. }
  260. return false;
  261. }
  262.  
  263. private boolean toBankInterface(){
  264. if(Interfaces.get(234,2) != null){
  265. if(Interfaces.get(234,2).getText().contains("Go to the bank...")){
  266. return true;
  267. }
  268. }
  269. return false;
  270. }
  271.  
  272. private boolean secondChooseOption(){
  273. if(Interfaces.get(228, 0) != null || Interfaces.get(230,0) != null){
  274. return true;
  275. }
  276. return false;
  277. }
  278.  
  279. private boolean takeSomething(){
  280. if(Interfaces.get(228,2) != null){
  281. return true;
  282. }
  283. return false;
  284. }
  285.  
  286. private boolean userChat(){
  287. if(Interfaces.get(64,1) != null){
  288. return true;
  289. }
  290. return false;
  291. }
  292.  
  293. private boolean pageOne(){
  294. if(Interfaces.get(234,1) != null && Interfaces.get(234,1).getText().contains("Wooden")){
  295. return true;
  296. }
  297. return false;
  298. }
  299.  
  300. private boolean pageTwo(){
  301. if(Interfaces.get(234,1) != null && Interfaces.get(234,1).getText().contains("Soft")){
  302. return true;
  303. }
  304. return false;
  305. }
  306.  
  307. private boolean lastChat(){
  308. if(Interfaces.get(242,1) != null){
  309. return true;
  310. }
  311. return false;
  312. }
  313.  
  314. private boolean payMe(){
  315. if(Interfaces.get(243,2) != null){
  316. if(Interfaces.get(243,2).getText().contains("Master")){
  317. return true;
  318. }
  319. }
  320. return false;
  321. }
  322.  
  323. private boolean payInterface(){
  324. if(Interfaces.get(230,1) != null){
  325. if(Interfaces.get(230,1).getText().contains("Pay servant")){
  326. return true;
  327. }
  328. }
  329. return false;
  330. }
  331.  
  332. private boolean fireServant(){
  333. if(Interfaces.get(228,0) != null){
  334. if(Interfaces.get(228,0).getText().contains("Do you really want")){
  335. return true;
  336. }
  337. }
  338. return false;
  339. }
  340.  
  341. private boolean noMoney(){
  342. if(Inventory.getCount(995) < 10000){
  343. return true;
  344. }
  345. return false;
  346. }
  347.  
  348. private void interactButler(){
  349. RSNPC[] butler = NPCs.find("Demon butler");
  350. if(butler.length > 0){
  351. if(!chatInterfaces()){
  352. if(Interfaces.get(79) != null){
  353. Walking.walkTo(Player.getPosition());
  354. }
  355. if(butler[0].click("Talk-to")){
  356. waitFor(new Condition() {
  357. @Override
  358. public boolean active() {
  359. return chatInterfaces();
  360. }
  361. }, General.random(3000, 4000));
  362. }
  363. }else{
  364. if(noMoney()){
  365. println("We've run out of cash, stopping.");
  366. stopScript();
  367. }
  368.  
  369. if(payMe()){
  370. if(NPCChat.getClickContinueInterface() != null){
  371. NPCChat.clickContinue(true);
  372. }
  373. }
  374.  
  375.  
  376. if(lastChat()){
  377. if(NPCChat.getClickContinueInterface() != null){
  378. if(NPCChat.clickContinue(true)){
  379. RSObject[] lectern = Objects.findNearest(15, 13647);
  380. Walking.walkTo(lectern[0].getPosition());
  381. waitFor(new Condition() {
  382. @Override
  383. public boolean active() {
  384. return chatInterfaces();
  385. }
  386. }, General.random(9000, 10000));
  387. }
  388. }
  389. }
  390.  
  391. if(butlerTalking() || userChat()){
  392. if(NPCChat.getClickContinueInterface() != null){
  393. NPCChat.clickContinue(true);
  394. }
  395. }
  396.  
  397. if(chooseOption() || secondChooseOption()){
  398. if(payInterface()){
  399. RSInterface pay = Interfaces.get(230,1);
  400. if(pay != null){
  401. if(pay.hover()){
  402.  
  403. Mouse.click(1);
  404. waitFor(new Condition() {
  405. @Override
  406. public boolean active() {
  407. return lastChat();
  408. }
  409. }, General.random(3000, 4000));
  410. tabsMade = tabsMade - 7;
  411. }
  412. }
  413. }
  414.  
  415. if(toBankInterface()){
  416. RSInterface toBank = Interfaces.get(234,2);
  417. if(toBank != null){
  418. if(toBank.hover()){
  419. Mouse.click(1);
  420. waitFor(new Condition() {
  421. @Override
  422. public boolean active() {
  423. return takeSomething();
  424. }
  425. }, General.random(3000, 4000));
  426. }
  427. }
  428. }
  429.  
  430. if(fireServant()){
  431. println("ALMOST FIRED");
  432. RSInterface no = Interfaces.get(228,2);
  433. if(no != null){
  434. no.hover();
  435. sleep(400,500);
  436. Mouse.click(1);
  437. waitFor(new Condition() {
  438. @Override
  439. public boolean active() {
  440. return !chatInterfaces();
  441. }
  442. }, General.random(3000, 4000));
  443. }
  444. }
  445.  
  446. if(takeSomething()){
  447. RSInterface bringSomething = Interfaces.get(228,2);
  448. if(bringSomething != null){
  449. bringSomething.hover();
  450. Mouse.click(1);
  451. waitFor(new Condition() {
  452. @Override
  453. public boolean active() {
  454. return userChat();
  455. }
  456. }, General.random(3000, 4000));
  457. }
  458. }
  459.  
  460. if(pageOne()){
  461. RSInterface more = Interfaces.get(234,5);
  462. if(more != null){
  463. if(more.hover()){
  464. Mouse.click(1);
  465. waitFor(new Condition() {
  466. @Override
  467. public boolean active() {
  468. return pageTwo();
  469. }
  470. }, General.random(3000, 4000));
  471. }
  472. }
  473. }
  474.  
  475. if(pageTwo()){
  476. RSInterface clay = Interfaces.get(234,1);
  477. if(clay != null){
  478. if(clay.hover()){
  479.  
  480. Mouse.click(1);
  481. waitFor(new Condition() {
  482. @Override
  483. public boolean active() {
  484. return enterAmount();
  485. }
  486. }, General.random(3000, 4000));
  487. }
  488. }
  489. }
  490. }
  491.  
  492. if(enterAmount()){
  493. Keyboard.typeSend("24");
  494. waitFor(new Condition() {
  495. @Override
  496. public boolean active() {
  497. return lastChat();
  498. }
  499. }, General.random(3000, 4000));
  500. if(lastChat()){
  501. if(NPCChat.getClickContinueInterface() != null){
  502. if(NPCChat.clickContinue(true)){
  503. RSObject[] lectern = Objects.findNearest(15, 13647);
  504. if(lectern.length > 0){
  505. Walking.walkTo(lectern[0].getPosition());
  506. waitFor(new Condition() {
  507. @Override
  508. public boolean active() {
  509. return chatInterfaces();
  510. }
  511. }, General.random(9000, 10000));
  512. }
  513. }
  514. }
  515. }
  516. }
  517. }
  518. }
  519. }
  520.  
  521. @Override
  522. public void run() {
  523. if(onStart()){
  524. while(true){
  525. sleep(50,100);
  526. if(atArea(portal)){
  527. enterHouse();
  528. }
  529.  
  530. if(atHouse()){
  531. if(readyToMakeTabs()){
  532. if(!tabOpen()){
  533. Inventory.dropAllExcept(8013,557,995,563, 561,8015,1761,8010);
  534. clickLectern();
  535. }else{
  536. makeTabs();
  537. }
  538. }else{
  539. if(!isButler()){
  540. findButler();
  541. }else{
  542. interactButler();
  543. }
  544. }
  545. }
  546.  
  547. if(!atArea(portal) && !atHouse() && !atArea(walk) && !atArea(bank)){
  548. println("Relocating");
  549. WebWalking.walkTo(portalTile);
  550. }
  551. }
  552. }
  553. }
  554.  
  555. private void makeTabs(){
  556. sleep(300,500);
  557. RSInterface varrock = Interfaces.get(79,17);
  558. if(varrock != null){
  559. if(Inventory.getCount(1761) != 1){
  560. if(varrock.hover()){
  561. Mouse.click(3);
  562. if(ChooseOption.isOpen()){
  563. if(ChooseOption.isOptionValid("Make")){
  564. ChooseOption.select("Make-All");
  565. }
  566. }
  567. waitFor(new Condition() {
  568. @Override
  569. public boolean active() {
  570. return Interfaces.get(79) == null;
  571. }
  572. }, General.random(5000, 6000));
  573. tabsMade++;
  574. }
  575. }else{
  576. if(varrock.click()){
  577. waitFor(new Condition() {
  578. @Override
  579. public boolean active() {
  580. return Player.getAnimation() == -1;
  581. }
  582. }, General.random(5000, 6000));
  583. tabsMade++;
  584. }
  585. }
  586. }
  587. }
  588.  
  589. private boolean readyToMakeTabs(){
  590. if(Inventory.getCount(runeID) > 0 && Inventory.getCount(1761) > 0){
  591. return true;
  592. }
  593. return false;
  594. }
  595.  
  596. private boolean tabOpen(){
  597. if(Interfaces.get(79) != null){
  598. return true;
  599. }
  600. return false;
  601. }
  602.  
  603. private void clickLectern(){
  604. RSObject[] lectern = Objects.findNearest(15, 13647);
  605. if(lectern.length > 0){
  606. if(Player.getPosition().distanceTo(lectern[0].getPosition()) > 3){
  607. Walking.walkTo(lectern[0].getPosition());
  608. sleep(100,200);
  609. while(Player.isMoving()){
  610. sleep(75,100);
  611. }
  612. }else{
  613. if(lectern[0].isOnScreen()){
  614. GameTab.open(TABS.INVENTORY);
  615. if(!ChooseOption.isOpen()){
  616. lectern[0].hover();
  617. waitFor(new Condition() {
  618. @Override
  619. public boolean active() {
  620. return !Game.getUptext().contains("Walk here");
  621. }
  622. }, General.random(500,600));
  623. Mouse.click(3);
  624. waitFor(new Condition() {
  625. @Override
  626. public boolean active() {
  627. return ChooseOption.isOpen();
  628. }
  629. }, General.random(500,600));
  630. }else{
  631. if(ChooseOption.isOptionValid("Study")){
  632. ChooseOption.select("Study");
  633. Mouse.moveBox(325, 171, 494, 26);
  634. waitFor(new Condition() {
  635. @Override
  636. public boolean active() {
  637. return tabOpen();
  638. }
  639. }, General.random(3000, 4000));
  640. }else{
  641. ChooseOption.close();
  642. }
  643. }
  644. }else{
  645. Walking.walkTo(lectern[0].getPosition());
  646. sleep(100);
  647. while(Player.isMoving()){
  648. sleep(75,100);
  649. }
  650. }
  651. }
  652. }
  653. }
  654.  
  655. public boolean waitFor(Condition c, long timeout) {
  656. Timer t = new Timer(timeout);
  657. while ((t.isRunning()) && (!c.active())) {
  658. sleep(20);
  659. }
  660. c.active();
  661. return c.active();
  662. }
  663.  
  664. private boolean atArea(RSArea a){
  665. if(a.ContainsRSTile(Player.getPosition())){
  666. return true;
  667. }
  668. return false;
  669. }
  670.  
  671. private final Color color1 = new Color(102, 204, 0);
  672. private final Color color2 = new Color(0, 0, 0);
  673. private final Color color3 = new Color(255, 0, 0);
  674.  
  675. private final BasicStroke stroke1 = new BasicStroke(1);
  676.  
  677. private final Font font1 = new Font("Arial", 1, 20);
  678. private final Font font2 = new Font("Arial", 0, 11);
  679.  
  680. public void onPaint(Graphics g1) {
  681.  
  682. long timeRan = System.currentTimeMillis() - timeBegan;
  683. int gpGained = ((tabsMade * 370));
  684. int gpPerHour = (int) (gpGained / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
  685. int tabsPerHour = (int) (tabsMade / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
  686. Graphics2D g = (Graphics2D)g1;
  687. g.setColor(color1);
  688. g.fillRect(16, 348, 468, 76);
  689. g.setColor(color2);
  690. g.setStroke(stroke1);
  691. g.drawRect(16, 348, 468, 76);
  692. g.setFont(font1);
  693. g.setColor(color3);
  694. g.drawString("Tabs r fun", 377, 369);
  695. g.setFont(font2);
  696. g.setColor(color2);
  697. g.drawString("Time ran: " + Timing.msToString(timeRan), 24, 365);
  698. g.drawString("Tabs made: " + tabsMade, 25, 396);
  699. g.drawString("Tabs /h: " + tabsPerHour, 26, 410);
  700. g.drawString("Money made: " + gpGained, 155, 398);
  701. g.drawString("Money /h: " + gpPerHour, 155, 408);
  702. g.drawString("Who's house?: ", 96, 378);
  703. }
  704.  
  705. @Override
  706. public void clanMessageReceived(String arg0, String arg1) {
  707. // TODO Auto-generated method stub
  708.  
  709. }
  710.  
  711. @Override
  712. public void personalMessageReceived(String arg0, String arg1) {
  713.  
  714. }
  715.  
  716. @Override
  717. public void playerMessageReceived(String arg0, String arg1) {
  718. // TODO Auto-generated method stub
  719.  
  720. }
  721.  
  722. boolean a = false;
  723.  
  724. @Override
  725. public void serverMessageReceived(String arg0){
  726. if(arg0.contains("You must hire a")){
  727. println("Fired servant, stopping");
  728. stopScript();
  729. }
  730. }
  731.  
  732. @Override
  733. public void tradeRequestReceived(String arg0) {
  734. // TODO Auto-generated method stub
  735.  
  736. }
  737.  
  738. @Override
  739. public void onBreakEnd() {
  740. // TODO Auto-generated method stub
  741.  
  742. }
  743.  
  744. @Override
  745. public void onBreakStart(){
  746. }
  747.  
  748. @Override
  749. public void onRandom(RANDOM_SOLVERS arg0) {
  750. Walking.walkTo(Player.getPosition());
  751. Walking.walkTo(Player.getPosition());
  752. Walking.walkTo(Player.getPosition());
  753. }
  754.  
  755. @Override
  756. public boolean randomFailed(RANDOM_SOLVERS arg0) {
  757. // TODO Auto-generated method stub
  758. return false;
  759. }
  760.  
  761. @Override
  762. public void randomSolved(RANDOM_SOLVERS arg0) {
  763. // TODO Auto-generated method stub
  764.  
  765. }
  766. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement