Advertisement
Guest User

Untitled

a guest
Sep 17th, 2015
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.12 KB | None | 0 0
  1. package scripts.moneymaking.tabber;
  2.  
  3. import org.tribot.api.General;
  4. import org.tribot.api.Timing;
  5. import org.tribot.api.input.Keyboard;
  6. import org.tribot.api.input.Mouse;
  7. import org.tribot.api.util.ABCUtil;
  8. import org.tribot.api2007.Banking;
  9. import org.tribot.api2007.Camera;
  10. import org.tribot.api2007.GameTab;
  11. import org.tribot.api2007.GameTab.TABS;
  12. import org.tribot.api2007.Interfaces;
  13. import org.tribot.api2007.Inventory;
  14. import org.tribot.api2007.Magic;
  15. import org.tribot.api2007.NPCChat;
  16. import org.tribot.api2007.NPCs;
  17. import org.tribot.api2007.Objects;
  18. import org.tribot.api2007.Player;
  19. import org.tribot.api2007.Walking;
  20. import org.tribot.api2007.WebWalking;
  21. import org.tribot.api2007.types.RSInterface;
  22. import org.tribot.api2007.types.RSItem;
  23. import org.tribot.api2007.types.RSNPC;
  24. import org.tribot.api2007.types.RSObject;
  25.  
  26. import scripts.methods.Methods;
  27.  
  28. public class Butler {
  29.  
  30. private Main main;
  31.  
  32. public final String DEMON_MESSAGE = "Master, if thou desirest my continued service, thou must render unto me the 10000 coins that are due me!";
  33.  
  34. public final String BUTLER_MESSAGE = "If you do not pay me I will have to give you my notice, sir. My fee is 5000 coins.";
  35.  
  36. private int withdrawIncrease = 0;
  37.  
  38. public Butler(Main main) {
  39. setMain(main);
  40. }
  41.  
  42. public RSNPC getButler() {
  43. RSNPC[] butler = NPCs.findNearest(getMain().getButlerType().getName());
  44. if(butler != null && butler.length > 0) {
  45. return butler[0];
  46. }
  47. return null;
  48. //return Methods.findNPCByModelPoints(new int[] { Constants.DEMON_BUTLER });
  49. }
  50.  
  51. public RSObject getBellPull() {
  52. RSObject[] bellPull = Objects.findNearest(64, "Bell-pull");
  53. if(bellPull != null && bellPull.length > 0) {
  54. return bellPull[0];
  55. }
  56. return null;
  57. }
  58.  
  59. public boolean isFollowing() {
  60. if(getButler().isInteractingWithMe()) {
  61. return true;
  62. }
  63. if(getButlerDistance() <= 1) {
  64. return true;
  65. }
  66. return false;
  67. }
  68.  
  69. public int getButlerDistance() {
  70. RSNPC butler = getButler();
  71. if(butler != null) {
  72. return butler.getPosition().distanceTo(Player.getPosition());
  73. }
  74. return 100;
  75. }
  76.  
  77. public int getBellDistance() {
  78. RSObject bell = getBellPull();
  79. if(bell != null) {
  80. return bell.getPosition().distanceTo(Player.getPosition());
  81. }
  82. return 100;
  83. }
  84.  
  85. public boolean hasButler() {
  86. return getButler() != null || getBellPull() != null;
  87. }
  88.  
  89. public boolean summon() {
  90. if(Inventory.getCount(Constants.SOFT_CLAY_ID + 1) <= 0) {
  91. camelotTeleport();
  92. return false;
  93. }
  94. if(!hasResources()) {
  95. getMain().println("Out of resources.");
  96. getMain().setEndScript(true);
  97. return false;
  98. }
  99. if(Inventory.getCount(Constants.SOFT_CLAY_ID) > 1) {
  100. getMain().setState(State.MAKING_TABS);
  101. return false;
  102. }
  103. RSNPC butler = getButler();
  104. if(butler != null) {
  105. if(Player.getPosition().distanceTo(butler) <= 3) {
  106. giveClay();
  107. return true;
  108. }
  109. }
  110. if(GameTab.open(TABS.OPTIONS)) {
  111. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  112. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  113. Mouse.clickBox(648, 428, 680, 458, 1);
  114. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  115. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  116. if(Interfaces.isInterfaceValid(Constants.HOUSE_OPTION_INTERFACE)) {
  117. RSInterface houseOptions = Interfaces.get(Constants.HOUSE_OPTION_INTERFACE);
  118. if(houseOptions != null) {
  119. if(houseOptions.getChild(Constants.SERVANT_CHILD_ID) != null) {
  120. if(houseOptions.getChild(Constants.SERVANT_CHILD_ID).click("Call Servant")) {
  121. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  122. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  123. if(!Interfaces.isInterfaceValid(Constants.HOUSE_OPTION_INTERFACE)) {
  124. GameTab.open(TABS.INVENTORY);
  125. return isButlerNear(1000);
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. return false;
  133. }
  134.  
  135. private ABCUtil abc = new ABCUtil();
  136.  
  137. private boolean teleported = false;
  138.  
  139. public static final int BANK_ID = 12;
  140. public static final int NOTE_ID = 18;
  141.  
  142. public boolean camelotTeleport() {
  143. while(!teleported && !Constants.isAtCamelot()) {
  144. if(!hasResources()) {
  145. getMain().println("Out of resources.");
  146. getMain().setEndScript(true);
  147. return false;
  148. }
  149. if(Magic.selectSpell("Camelot teleport")) {
  150. if(teleported(3000)) {
  151. if(Constants.isAtCamelot()) {
  152. teleported = true;
  153. WebWalking.walkTo(Constants.CAMELOT_BANK_TILE);
  154. }
  155. }
  156. }
  157. }
  158. while(teleported && !Constants.isAtCamelotBank()) {
  159. WebWalking.walkTo(Constants.CAMELOT_BANK_TILE);
  160. getMain().sleep(50, 150);
  161. }
  162. while(teleported && Constants.isAtCamelotBank()) {
  163. if(!Banking.isBankScreenOpen()) {
  164. Banking.openBankBooth();
  165. }
  166. if(Banking.isBankScreenOpen()) {
  167. RSInterface bank = Interfaces.get(BANK_ID);
  168. if(bank != null) {
  169. if(bank.getChild(NOTE_ID).click("Note")) {
  170. RSItem[] softClay = Banking.find(Constants.SOFT_CLAY_ID);
  171. if(softClay != null && softClay.length > 0) {
  172. while(Inventory.isFull()) {
  173. RSItem[] clay = Inventory.find(Constants.SOFT_CLAY_ID);
  174. if(clay != null && clay.length > 0) {
  175. if(Inventory.isFull())
  176. clay[0].click("Deposit-1");
  177. }
  178. getMain().sleep(50, 150);
  179. }
  180. if(softClay[0].click("Withdraw-All")) {
  181. if(Inventory.isFull()) {
  182. Banking.close();
  183. Magic.selectSpell("Teleport to house");
  184. teleported = false;
  185. }
  186. }
  187. } else {
  188. //Login.logout();
  189. getMain().setEndScript(true);
  190. }
  191. }
  192. }
  193. }
  194. getMain().sleep(50, 150);
  195. }
  196. return false;
  197. }
  198.  
  199. public boolean hasResources() {
  200. boolean hasClay = false;
  201. boolean hasLaws = false;
  202. boolean hasRune = false;
  203. boolean hasMoney = false;
  204. if(Inventory.getCount(Constants.SOFT_CLAY_ID + 1) > 0) {
  205. //getMain().println("Has soft clay");
  206. hasClay = true;
  207. }
  208. if(Inventory.getCount(Constants.LAW_RUNE_ID) > 0) {
  209. //getMain().println("Has law runes.");
  210. hasLaws = true;
  211. }
  212. if(Inventory.getCount(995) > 10000) {
  213. //getMain().println("Has money");
  214. hasMoney = true;
  215. }
  216. switch(getMain().getTabType()) {
  217. case VARROCK:
  218. if(Inventory.getCount(Constants.FIRE_RUNE_ID) > 0 || Inventory.getCount(Constants.AIR_RUNE_ID) > 0) {
  219. //getMain().println("Has fire runes");
  220. hasRune = true;
  221. }
  222. break;
  223. case CAMELOT:
  224. hasRune = true;
  225. break;
  226. case FALADOR:
  227. if(Inventory.getCount(Constants.WATER_RUNE_ID) > 0) {
  228. //getMain().println("Has water runes");
  229. hasRune = true;
  230. }
  231. break;
  232. case LUMBRIDGE:
  233. if(Inventory.getCount(Constants.EARTH_RUNE_ID) > 0) {
  234. //getMain().println("Has water runes");
  235. hasRune = true;
  236. }
  237. break;
  238. case HOUSE:
  239. if(Inventory.getCount(Constants.EARTH_RUNE_ID) > 0) {
  240. //getMain().println("Has air runes");
  241. hasRune = true;
  242. }
  243. break;
  244.  
  245. case ARDOUGNE:
  246. break;
  247. case WATCHTOWER:
  248. break;
  249. }
  250. if(hasMoney && hasClay && hasRune && hasLaws) {
  251. //getMain().println("Has All Resources");
  252. return true;
  253. }
  254. return false;
  255. }
  256.  
  257. public String getPaymentMessage() {
  258. switch(getMain().getButlerType()) {
  259. case DEMON_BUTLER:
  260. return DEMON_MESSAGE;
  261. case BUTLER:
  262. return BUTLER_MESSAGE;
  263. }
  264. return null;
  265. }
  266.  
  267. public boolean payServant(RSNPC butler) {
  268. if(NPCChat.getMessage() != null) {
  269. if(NPCChat.getMessage().equals(getPaymentMessage())) {
  270. if(NPCChat.clickContinue(true)) {
  271. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  272. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  273. if(NPCChat.getOptions() != null) {
  274. if(NPCChat.selectOption(paymentOption(), true)) {
  275. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  276. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  277. if(hasPayed(3000)) {
  278. getMain().servantPayment++;
  279. NPCChat.clickContinue(true);
  280. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  281. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  282. butler.click("Talk-to");
  283. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  284. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  285. getMain().sleep(250, 500);
  286. return true;
  287. }
  288. }
  289. }
  290. }
  291. }
  292. }
  293. return false;
  294. }
  295.  
  296. private String paymentOption() {
  297. switch(getMain().getButlerType()) {
  298. case BUTLER:
  299. return "Pay servant 5000 coins";
  300. case DEMON_BUTLER:
  301. return "Pay servant 10000 coins";
  302. }
  303. return "";
  304. }
  305.  
  306. private boolean hasPreviousTask() {
  307. RSNPC butler = getButler();
  308. ButlerType type = getMain().getButlerType();
  309. if(butler == null) {
  310. return false;
  311. }
  312.  
  313. if(NPCChat.getMessage() == null
  314. && NPCChat.getOptions() == null
  315. && NPCChat.getClickContinueInterface() == null)
  316. butler.click("Talk-to");
  317.  
  318. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  319. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  320.  
  321. talkedToButler(1000);
  322.  
  323. if(Inventory.getCount(Constants.SOFT_CLAY_ID) > 0) {
  324. getMain().setState(State.MAKING_TABS);
  325. return true;
  326. }
  327.  
  328. String[] options = NPCChat.getOptions();
  329. String option = "null";
  330. if(options != null && options.length > 0) {
  331. for(int i = 0; i < options.length; i++) {
  332. if(options[i].contains("Un-note:")) {
  333. option = options[i];
  334. break;
  335. }
  336. }
  337. }
  338.  
  339. if(!option.contains("null")) {
  340.  
  341. if(NPCChat.selectOption(option, true)) {
  342.  
  343. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  344. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  345.  
  346. if(NPCChat.getClickContinueInterface() != null) {
  347.  
  348. if(NPCChat.clickContinue(true)) {
  349.  
  350. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  351. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  352.  
  353. if(receivedClay(20000)) {
  354.  
  355. //if(Methods.distanceTo(getMain(), butler.getPosition()) > 3)
  356. if(NPCChat.getMessage() == null
  357. && NPCChat.getOptions() == null
  358. && NPCChat.getClickContinueInterface() == null)
  359. butler.click("Talk-to");
  360.  
  361. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  362. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  363.  
  364. return Inventory.getCount(Constants.SOFT_CLAY_ID) > 0;
  365. }
  366. }
  367. }
  368. }
  369. } else {
  370. if(payServant(butler)) {
  371. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  372. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  373. return false;
  374. }
  375. if(Inventory.getCount(Constants.SOFT_CLAY_ID) <= 0) {
  376. RSItem[] clay = Inventory.find(Constants.SOFT_CLAY_ID + 1);
  377. if(clay[0].click("Use")) {
  378. if(butler.click("Use")) {
  379. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  380. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  381. }
  382. General.sleep(250, 500);
  383. }
  384. }
  385. if(clickedButler(3000)) {
  386. if(NPCChat.clickContinue(true)) {
  387. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  388. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  389. if(clickedContinue(1000)) {
  390. if(Inventory.getCount(Constants.SOFT_CLAY_ID) > 0) {
  391. getMain().setState(State.MAKING_TABS);
  392. return false;
  393. }
  394. if(NPCChat.selectOption("Yes", true)) {
  395. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  396. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  397. getMain().sleep(250, 500);
  398. int amt = type.equals(ButlerType.BUTLER) ? 20 : (28 - Inventory.getAll().length);
  399. Keyboard.typeSend("" + amt);
  400. if(enteredAmount(3000)) {
  401. if(NPCChat.clickContinue(true)) {
  402. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  403. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  404. if(receivedClay(14000)) {
  405. if(NPCChat.getMessage() == null
  406. && NPCChat.getOptions() == null
  407. && NPCChat.getClickContinueInterface() == null)
  408. butler.click("Talk-to");
  409. General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
  410. abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
  411. return true;
  412. }
  413. }
  414. }
  415. }
  416. }
  417. }
  418. }
  419. }
  420. return false;
  421. }
  422.  
  423. public boolean giveClay() {
  424. if(Inventory.getCount(Constants.SOFT_CLAY_ID + 1) <= 0) {
  425. camelotTeleport();
  426. return false;
  427. }
  428. if(!hasResources()) {
  429. getMain().println("Out of resources.");
  430. getMain().setEndScript(true);
  431. return false;
  432. }
  433. if(Inventory.getCount(Constants.SOFT_CLAY_ID) > 1) {
  434. getMain().setState(State.MAKING_TABS);
  435. return false;
  436. }
  437. if(getButler() == null) {
  438. return false;
  439. }
  440. RSNPC butler = getButler();
  441. if(Player.getPosition().distanceTo(butler) > 3) {
  442. if(!butler.isOnScreen()) {
  443. summon();
  444. return false;
  445. }
  446. }
  447. getMain().getHouse().makingTabs = false;
  448. if(!butler.isOnScreen()) {
  449. Camera.turnToTile(butler);
  450. }
  451. if(Player.getPosition().distanceTo(butler) > 3) {
  452. Walking.walkTo(butler);
  453. }
  454. while(Player.isMoving() && Player.getPosition().distanceTo(butler) > 2 && !butler.isOnScreen()) {
  455. getMain().sleep(50, 150);
  456. }
  457. RSItem[] clay = Inventory.find(Constants.SOFT_CLAY_ID + 1);
  458. if(clay == null || clay.length <= 0) {
  459. return false;
  460. }
  461. if(hasPreviousTask()) {
  462. getMain().setState(State.MAKING_TABS);
  463. return true;
  464. }
  465. return false;
  466. }
  467.  
  468. private boolean teleported(int i) {
  469. long t = System.currentTimeMillis();
  470. while (Timing.timeFromMark(t) < i) {
  471. if(Constants.isAtCamelot()) {
  472. return true;
  473. }
  474. getMain().sleep(40, 80);
  475. }
  476. return false;
  477. }
  478.  
  479. private boolean clickedContinue(int i) {
  480. long t = System.currentTimeMillis();
  481. while (Timing.timeFromMark(t) < i) {
  482. if(NPCChat.getOptions() != null) {
  483. return true;
  484. }
  485. getMain().sleep(40, 80);
  486. }
  487. return false;
  488. }
  489.  
  490. private boolean enteredAmount(int i) {
  491. long t = System.currentTimeMillis();
  492. while (Timing.timeFromMark(t) < i) {
  493. if(NPCChat.getMessage() != null) {
  494. return true;
  495. }
  496. getMain().sleep(40, 80);
  497. }
  498. return false;
  499. }
  500.  
  501. public boolean hasPayed(int i) {
  502. long t = System.currentTimeMillis();
  503. while (Timing.timeFromMark(t) < i) {
  504. if(NPCChat.getMessage() != null) {
  505. return true;
  506. }
  507. getMain().sleep(40, 80);
  508. }
  509. return false;
  510. }
  511.  
  512. public boolean isButlerNear(int i) {
  513. long t = System.currentTimeMillis();
  514. while (Timing.timeFromMark(t) < i) {
  515. RSNPC butler = getButler();
  516. if(butler != null) {
  517. if(Player.getPosition().distanceTo(butler) <= 3) {
  518. return true;
  519. }
  520. }
  521. if(NPCChat.getMessage() != null) {
  522. return true;
  523. }
  524. getMain().sleep(40, 80);
  525. }
  526. return false;
  527. }
  528.  
  529. public boolean talkedToButler(int i) {
  530. long t = System.currentTimeMillis();
  531. while (Timing.timeFromMark(t) < i) {
  532. if(NPCChat.getMessage() != null) {
  533. return true;
  534. }
  535. if(NPCChat.getClickContinueInterface() != null) {
  536. return true;
  537. }
  538. if(NPCChat.getOptions() != null) {
  539. return true;
  540. }
  541. getMain().sleep(40, 80);
  542. }
  543. return false;
  544. }
  545.  
  546.  
  547. private boolean receivedClay(int i) {
  548. long t = System.currentTimeMillis();
  549. while (Timing.timeFromMark(t) < i) {
  550. Methods.performAntiBan(getMain());
  551. if(!GameTab.open(TABS.INVENTORY)) {
  552. GameTab.open(TABS.INVENTORY);
  553. }
  554. if(!Player.isMoving() && !getMain().getHouse().isAtLectern()) {
  555. Walking.walkTo(getMain().getHouse().getLectern());
  556. }
  557. if(getButler() != null) {
  558. if(getButler().getPosition().distanceTo(Player.getPosition()) > 3) {
  559. Walking.walkTo(getButler());
  560. }
  561. }
  562. if(Inventory.getCount(Constants.SOFT_CLAY_ID) > 0) {
  563. return true;
  564. }
  565. getMain().sleep(40, 80);
  566. }
  567. return false;
  568. }
  569.  
  570. private boolean clickedButler(int i) {
  571. long t = System.currentTimeMillis();
  572. while (Timing.timeFromMark(t) < i) {
  573. if(NPCChat.getClickContinueInterface() != null) {
  574. return true;
  575. }
  576. if(NPCChat.getMessage() != null) {
  577. return true;
  578. }
  579. if(NPCChat.getOptions() != null) {
  580. return true;
  581. }
  582. getMain().sleep(40, 80);
  583. }
  584. return false;
  585. }
  586.  
  587. public void setMain(Main main) {
  588. this.main = main;
  589. }
  590.  
  591. public Main getMain() {
  592. return main;
  593. }
  594.  
  595. public void setWithdrawIncrease(int withdrawIncrease) {
  596. this.withdrawIncrease = withdrawIncrease;
  597. }
  598.  
  599. public int getWithdrawIncrease() {
  600. return withdrawIncrease;
  601. }
  602. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement