Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.moneymaking.tabber;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Keyboard;
- import org.tribot.api.input.Mouse;
- import org.tribot.api.util.ABCUtil;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Camera;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Magic;
- import org.tribot.api2007.NPCChat;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSInterface;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSNPC;
- import org.tribot.api2007.types.RSObject;
- import scripts.methods.Methods;
- public class Butler {
- private Main main;
- public final String DEMON_MESSAGE = "Master, if thou desirest my continued service, thou must render unto me the 10000 coins that are due me!";
- 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.";
- private int withdrawIncrease = 0;
- public Butler(Main main) {
- setMain(main);
- }
- public RSNPC getButler() {
- RSNPC[] butler = NPCs.findNearest(getMain().getButlerType().getName());
- if(butler != null && butler.length > 0) {
- return butler[0];
- }
- return null;
- //return Methods.findNPCByModelPoints(new int[] { Constants.DEMON_BUTLER });
- }
- public RSObject getBellPull() {
- RSObject[] bellPull = Objects.findNearest(64, "Bell-pull");
- if(bellPull != null && bellPull.length > 0) {
- return bellPull[0];
- }
- return null;
- }
- public boolean isFollowing() {
- if(getButler().isInteractingWithMe()) {
- return true;
- }
- if(getButlerDistance() <= 1) {
- return true;
- }
- return false;
- }
- public int getButlerDistance() {
- RSNPC butler = getButler();
- if(butler != null) {
- return butler.getPosition().distanceTo(Player.getPosition());
- }
- return 100;
- }
- public int getBellDistance() {
- RSObject bell = getBellPull();
- if(bell != null) {
- return bell.getPosition().distanceTo(Player.getPosition());
- }
- return 100;
- }
- public boolean hasButler() {
- return getButler() != null || getBellPull() != null;
- }
- public boolean summon() {
- if(Inventory.getCount(Constants.SOFT_CLAY_ID + 1) <= 0) {
- camelotTeleport();
- return false;
- }
- if(!hasResources()) {
- getMain().println("Out of resources.");
- getMain().setEndScript(true);
- return false;
- }
- if(Inventory.getCount(Constants.SOFT_CLAY_ID) > 1) {
- getMain().setState(State.MAKING_TABS);
- return false;
- }
- RSNPC butler = getButler();
- if(butler != null) {
- if(Player.getPosition().distanceTo(butler) <= 3) {
- giveClay();
- return true;
- }
- }
- if(GameTab.open(TABS.OPTIONS)) {
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- Mouse.clickBox(648, 428, 680, 458, 1);
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- if(Interfaces.isInterfaceValid(Constants.HOUSE_OPTION_INTERFACE)) {
- RSInterface houseOptions = Interfaces.get(Constants.HOUSE_OPTION_INTERFACE);
- if(houseOptions != null) {
- if(houseOptions.getChild(Constants.SERVANT_CHILD_ID) != null) {
- if(houseOptions.getChild(Constants.SERVANT_CHILD_ID).click("Call Servant")) {
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- if(!Interfaces.isInterfaceValid(Constants.HOUSE_OPTION_INTERFACE)) {
- GameTab.open(TABS.INVENTORY);
- return isButlerNear(1000);
- }
- }
- }
- }
- }
- }
- return false;
- }
- private ABCUtil abc = new ABCUtil();
- private boolean teleported = false;
- public static final int BANK_ID = 12;
- public static final int NOTE_ID = 18;
- public boolean camelotTeleport() {
- while(!teleported && !Constants.isAtCamelot()) {
- if(!hasResources()) {
- getMain().println("Out of resources.");
- getMain().setEndScript(true);
- return false;
- }
- if(Magic.selectSpell("Camelot teleport")) {
- if(teleported(3000)) {
- if(Constants.isAtCamelot()) {
- teleported = true;
- WebWalking.walkTo(Constants.CAMELOT_BANK_TILE);
- }
- }
- }
- }
- while(teleported && !Constants.isAtCamelotBank()) {
- WebWalking.walkTo(Constants.CAMELOT_BANK_TILE);
- getMain().sleep(50, 150);
- }
- while(teleported && Constants.isAtCamelotBank()) {
- if(!Banking.isBankScreenOpen()) {
- Banking.openBankBooth();
- }
- if(Banking.isBankScreenOpen()) {
- RSInterface bank = Interfaces.get(BANK_ID);
- if(bank != null) {
- if(bank.getChild(NOTE_ID).click("Note")) {
- RSItem[] softClay = Banking.find(Constants.SOFT_CLAY_ID);
- if(softClay != null && softClay.length > 0) {
- while(Inventory.isFull()) {
- RSItem[] clay = Inventory.find(Constants.SOFT_CLAY_ID);
- if(clay != null && clay.length > 0) {
- if(Inventory.isFull())
- clay[0].click("Deposit-1");
- }
- getMain().sleep(50, 150);
- }
- if(softClay[0].click("Withdraw-All")) {
- if(Inventory.isFull()) {
- Banking.close();
- Magic.selectSpell("Teleport to house");
- teleported = false;
- }
- }
- } else {
- //Login.logout();
- getMain().setEndScript(true);
- }
- }
- }
- }
- getMain().sleep(50, 150);
- }
- return false;
- }
- public boolean hasResources() {
- boolean hasClay = false;
- boolean hasLaws = false;
- boolean hasRune = false;
- boolean hasMoney = false;
- if(Inventory.getCount(Constants.SOFT_CLAY_ID + 1) > 0) {
- //getMain().println("Has soft clay");
- hasClay = true;
- }
- if(Inventory.getCount(Constants.LAW_RUNE_ID) > 0) {
- //getMain().println("Has law runes.");
- hasLaws = true;
- }
- if(Inventory.getCount(995) > 10000) {
- //getMain().println("Has money");
- hasMoney = true;
- }
- switch(getMain().getTabType()) {
- case VARROCK:
- if(Inventory.getCount(Constants.FIRE_RUNE_ID) > 0 || Inventory.getCount(Constants.AIR_RUNE_ID) > 0) {
- //getMain().println("Has fire runes");
- hasRune = true;
- }
- break;
- case CAMELOT:
- hasRune = true;
- break;
- case FALADOR:
- if(Inventory.getCount(Constants.WATER_RUNE_ID) > 0) {
- //getMain().println("Has water runes");
- hasRune = true;
- }
- break;
- case LUMBRIDGE:
- if(Inventory.getCount(Constants.EARTH_RUNE_ID) > 0) {
- //getMain().println("Has water runes");
- hasRune = true;
- }
- break;
- case HOUSE:
- if(Inventory.getCount(Constants.EARTH_RUNE_ID) > 0) {
- //getMain().println("Has air runes");
- hasRune = true;
- }
- break;
- case ARDOUGNE:
- break;
- case WATCHTOWER:
- break;
- }
- if(hasMoney && hasClay && hasRune && hasLaws) {
- //getMain().println("Has All Resources");
- return true;
- }
- return false;
- }
- public String getPaymentMessage() {
- switch(getMain().getButlerType()) {
- case DEMON_BUTLER:
- return DEMON_MESSAGE;
- case BUTLER:
- return BUTLER_MESSAGE;
- }
- return null;
- }
- public boolean payServant(RSNPC butler) {
- if(NPCChat.getMessage() != null) {
- if(NPCChat.getMessage().equals(getPaymentMessage())) {
- if(NPCChat.clickContinue(true)) {
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(NPCChat.getOptions() != null) {
- if(NPCChat.selectOption(paymentOption(), true)) {
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(hasPayed(3000)) {
- getMain().servantPayment++;
- NPCChat.clickContinue(true);
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- butler.click("Talk-to");
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- getMain().sleep(250, 500);
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
- private String paymentOption() {
- switch(getMain().getButlerType()) {
- case BUTLER:
- return "Pay servant 5000 coins";
- case DEMON_BUTLER:
- return "Pay servant 10000 coins";
- }
- return "";
- }
- private boolean hasPreviousTask() {
- RSNPC butler = getButler();
- ButlerType type = getMain().getButlerType();
- if(butler == null) {
- return false;
- }
- if(NPCChat.getMessage() == null
- && NPCChat.getOptions() == null
- && NPCChat.getClickContinueInterface() == null)
- butler.click("Talk-to");
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- talkedToButler(1000);
- if(Inventory.getCount(Constants.SOFT_CLAY_ID) > 0) {
- getMain().setState(State.MAKING_TABS);
- return true;
- }
- String[] options = NPCChat.getOptions();
- String option = "null";
- if(options != null && options.length > 0) {
- for(int i = 0; i < options.length; i++) {
- if(options[i].contains("Un-note:")) {
- option = options[i];
- break;
- }
- }
- }
- if(!option.contains("null")) {
- if(NPCChat.selectOption(option, true)) {
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- if(NPCChat.getClickContinueInterface() != null) {
- if(NPCChat.clickContinue(true)) {
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- if(receivedClay(20000)) {
- //if(Methods.distanceTo(getMain(), butler.getPosition()) > 3)
- if(NPCChat.getMessage() == null
- && NPCChat.getOptions() == null
- && NPCChat.getClickContinueInterface() == null)
- butler.click("Talk-to");
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- return Inventory.getCount(Constants.SOFT_CLAY_ID) > 0;
- }
- }
- }
- }
- } else {
- if(payServant(butler)) {
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- return false;
- }
- if(Inventory.getCount(Constants.SOFT_CLAY_ID) <= 0) {
- RSItem[] clay = Inventory.find(Constants.SOFT_CLAY_ID + 1);
- if(clay[0].click("Use")) {
- if(butler.click("Use")) {
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- }
- General.sleep(250, 500);
- }
- }
- if(clickedButler(3000)) {
- if(NPCChat.clickContinue(true)) {
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(clickedContinue(1000)) {
- if(Inventory.getCount(Constants.SOFT_CLAY_ID) > 0) {
- getMain().setState(State.MAKING_TABS);
- return false;
- }
- if(NPCChat.selectOption("Yes", true)) {
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- getMain().sleep(250, 500);
- int amt = type.equals(ButlerType.BUTLER) ? 20 : (28 - Inventory.getAll().length);
- Keyboard.typeSend("" + amt);
- if(enteredAmount(3000)) {
- if(NPCChat.clickContinue(true)) {
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- if(receivedClay(14000)) {
- if(NPCChat.getMessage() == null
- && NPCChat.getOptions() == null
- && NPCChat.getClickContinueInterface() == null)
- butler.click("Talk-to");
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- return true;
- }
- }
- }
- }
- }
- }
- }
- }
- return false;
- }
- public boolean giveClay() {
- if(Inventory.getCount(Constants.SOFT_CLAY_ID + 1) <= 0) {
- camelotTeleport();
- return false;
- }
- if(!hasResources()) {
- getMain().println("Out of resources.");
- getMain().setEndScript(true);
- return false;
- }
- if(Inventory.getCount(Constants.SOFT_CLAY_ID) > 1) {
- getMain().setState(State.MAKING_TABS);
- return false;
- }
- if(getButler() == null) {
- return false;
- }
- RSNPC butler = getButler();
- if(Player.getPosition().distanceTo(butler) > 3) {
- if(!butler.isOnScreen()) {
- summon();
- return false;
- }
- }
- getMain().getHouse().makingTabs = false;
- if(!butler.isOnScreen()) {
- Camera.turnToTile(butler);
- }
- if(Player.getPosition().distanceTo(butler) > 3) {
- Walking.walkTo(butler);
- }
- while(Player.isMoving() && Player.getPosition().distanceTo(butler) > 2 && !butler.isOnScreen()) {
- getMain().sleep(50, 150);
- }
- RSItem[] clay = Inventory.find(Constants.SOFT_CLAY_ID + 1);
- if(clay == null || clay.length <= 0) {
- return false;
- }
- if(hasPreviousTask()) {
- getMain().setState(State.MAKING_TABS);
- return true;
- }
- return false;
- }
- private boolean teleported(int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- if(Constants.isAtCamelot()) {
- return true;
- }
- getMain().sleep(40, 80);
- }
- return false;
- }
- private boolean clickedContinue(int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- if(NPCChat.getOptions() != null) {
- return true;
- }
- getMain().sleep(40, 80);
- }
- return false;
- }
- private boolean enteredAmount(int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- if(NPCChat.getMessage() != null) {
- return true;
- }
- getMain().sleep(40, 80);
- }
- return false;
- }
- public boolean hasPayed(int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- if(NPCChat.getMessage() != null) {
- return true;
- }
- getMain().sleep(40, 80);
- }
- return false;
- }
- public boolean isButlerNear(int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- RSNPC butler = getButler();
- if(butler != null) {
- if(Player.getPosition().distanceTo(butler) <= 3) {
- return true;
- }
- }
- if(NPCChat.getMessage() != null) {
- return true;
- }
- getMain().sleep(40, 80);
- }
- return false;
- }
- public boolean talkedToButler(int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- if(NPCChat.getMessage() != null) {
- return true;
- }
- if(NPCChat.getClickContinueInterface() != null) {
- return true;
- }
- if(NPCChat.getOptions() != null) {
- return true;
- }
- getMain().sleep(40, 80);
- }
- return false;
- }
- private boolean receivedClay(int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- Methods.performAntiBan(getMain());
- if(!GameTab.open(TABS.INVENTORY)) {
- GameTab.open(TABS.INVENTORY);
- }
- if(!Player.isMoving() && !getMain().getHouse().isAtLectern()) {
- Walking.walkTo(getMain().getHouse().getLectern());
- }
- if(getButler() != null) {
- if(getButler().getPosition().distanceTo(Player.getPosition()) > 3) {
- Walking.walkTo(getButler());
- }
- }
- if(Inventory.getCount(Constants.SOFT_CLAY_ID) > 0) {
- return true;
- }
- getMain().sleep(40, 80);
- }
- return false;
- }
- private boolean clickedButler(int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- if(NPCChat.getClickContinueInterface() != null) {
- return true;
- }
- if(NPCChat.getMessage() != null) {
- return true;
- }
- if(NPCChat.getOptions() != null) {
- return true;
- }
- getMain().sleep(40, 80);
- }
- return false;
- }
- public void setMain(Main main) {
- this.main = main;
- }
- public Main getMain() {
- return main;
- }
- public void setWithdrawIncrease(int withdrawIncrease) {
- this.withdrawIncrease = withdrawIncrease;
- }
- public int getWithdrawIncrease() {
- return withdrawIncrease;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement