Jagg3d

BlessMySymbol - Source code

Jun 30th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.98 KB | None | 0 0
  1. package main;
  2.  
  3. import org.dreambot.api.methods.Calculations;
  4. import org.dreambot.api.methods.container.impl.bank.BankLocation;
  5. import org.dreambot.api.methods.map.Area;
  6. import org.dreambot.api.script.AbstractScript;
  7. import org.dreambot.api.script.Category;
  8. import org.dreambot.api.script.ScriptManifest;
  9. import org.dreambot.api.wrappers.interactive.GameObject;
  10. import org.dreambot.api.wrappers.interactive.NPC;
  11.  
  12. /**
  13.  * Created by Yorrick on 30/06/2016.
  14.  */
  15. @ScriptManifest(category = Category.MONEYMAKING, name = "Bless My Symbols", author = "Jagg3d", version = 1.0)
  16.  
  17. public class Main extends AbstractScript {
  18.     Area JeredArea = new Area(3044,3491,3058,3482,1);
  19.     Area DownStairArea = new Area(3045,3484,3047,3482,0);
  20.     Area UpStairArea = new Area(3045,3484,3047,3482,1);
  21.     String state;
  22.  
  23.     @Override
  24.     public void onStart() {
  25.         log("Bless My Symbols started.");
  26.         state = "Detecting";
  27.         log("Current state - " + state);
  28.     }
  29.  
  30.     @Override
  31.     public int onLoop() {
  32.         log("Current state - " + state);
  33.         if (state == "Detecting"){
  34.             if (!getInventory().isEmpty()){
  35.                 for (int i = 0; i<28;i++){
  36.                     if (!getInventory().getNameForSlot(i).contains("Unblessed symbol")){
  37.                         state = "Walking to bank";
  38.                     }
  39.                 }
  40.                 if (state == "Detecting"){
  41.                     state = "Walking to monastery";
  42.                 }
  43.             }
  44.             else {
  45.                 state = "Walking to bank";
  46.             }
  47.         }
  48.         if (state == "Walking to bank"){
  49.             GoBank();
  50.         }
  51.         if (state == "Banking..."){
  52.                 BankItems();
  53.         }
  54.         if (state == "Walking to monastery"){
  55.             GoStairs("up");
  56.         }
  57.         if (state == "Going up"){
  58.             if (JeredArea.contains(getNpcs().closest(npc -> npc != null && npc.getName().equals("Brother Jered")))){
  59.                 GameObject door = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Door") && gameObject.hasAction("Open") && gameObject.getID() == 1535);
  60.                 if (door.interact("Open")){
  61.                     sleep(1000);
  62.                     state = "Blessing Symbols";
  63.                 }
  64.             }
  65.         }
  66.         if (state == "Blessing Symbols"){
  67.             BlessSymbols();
  68.         }
  69.  
  70.         return 800;
  71.     }
  72.  
  73.     private void GoBank() {
  74.         if (!BankLocation.EDGEVILLE.getArea(1).contains(getLocalPlayer())) {
  75.             if (getWalking().walk(BankLocation.EDGEVILLE.getCenter())) {
  76.                 sleep(Calculations.random(2000, 4000));
  77.                 state = "Walking to bank";
  78.             }
  79.         }else {
  80.             state = "Banking...";
  81.         }
  82.     }
  83.     private void BankItems() {
  84.         GameObject banker = getGameObjects().closest(gameObject -> gameObject != null && gameObject.hasAction("Bank"));
  85.         if (sleepUntil(() -> banker.interact("Bank"),2000)){
  86.             if (sleepUntil(() -> getBank().isOpen(),7500)){
  87.                 if (!getInventory().isEmpty()){
  88.                     if (getBank().depositAllItems()){
  89.                         if (sleepUntil(()->getInventory().isEmpty(),7500)) {
  90.                             WithDraw();
  91.                         }
  92.                     }
  93.                 }
  94.                 else {
  95.                     WithDraw();
  96.                 }
  97.             }
  98.         }
  99.     }
  100.     private void WithDraw(){
  101.         if (getBank().contains(item -> item != null && item.getName().equals("Unblessed symbol"))){
  102.             if (sleepUntil(() ->getBank().withdrawAll(item -> item != null && item.getName().equals("Unblessed symbol")),5000)){
  103.                 if (getBank().close()){
  104.                     sleepUntil(() -> !getBank().isOpen(),5000);
  105.                     if (getInventory().contains(item->item.getName().equals("Unblessed symbol"))) {
  106.                         state = "Walking to monastery";
  107.                     }
  108.                 }
  109.             }
  110.         }
  111.     }
  112.     private void GoStairs(String dir) {
  113.         GameObject ladder;
  114.         if (dir=="up"){
  115.             if (!DownStairArea.contains(getLocalPlayer())) {
  116.                 if (getWalking().walk(DownStairArea.getTiles()[0])) {
  117.                     sleep(Calculations.random(2000, 4000));
  118.                 }
  119.             }else {
  120.                 ladder = getGameObjects().closest(gameObject -> gameObject != null && gameObject.hasAction("Climb-up"));
  121.                 if (ladder.interact("Climb-up")){
  122.                     state = "Going up";
  123.                 }
  124.             }
  125.         }
  126.         else {
  127.             if (!UpStairArea.contains(getLocalPlayer())) {
  128.                 if (getWalking().walk(UpStairArea.getRandomTile())) {
  129.                     sleep(Calculations.random(2000, 4000));
  130.                 }
  131.             }else {
  132.                 ladder = getGameObjects().closest(gameObject -> gameObject != null && gameObject.hasAction("Climb-down"));
  133.                 if (ladder.interact("Climb-down")){
  134.                     state = "Walking to bank";
  135.                 }
  136.             }
  137.         }
  138.     }
  139.     private void BlessSymbols() {
  140.         NPC brother = getNpcs().closest(npc -> npc != null && npc.getName().equals("Brother Jered"));
  141.         if (getInventory().contains(item -> item.getName().equals("Unblessed symbol"))) {
  142.             int invCount = getInventory().size() - 1;
  143.             for (int i = 0;i<=invCount;i++){
  144.                 if (!getDialogues().inDialogue()) {
  145.                     if(brother.interact("Talk-to")) {
  146.                         sleepUntil(getDialogues()::inDialogue, 5000);
  147.                     }
  148.                 }
  149.                 try {
  150.                     InDialogue : while (getDialogues().inDialogue()) {
  151.                         sleep(750);
  152.                         if (getDialogues().canContinue()) {
  153.                             getDialogues().continueDialogue();
  154.                         } else {
  155.                             for (String s : getDialogues().getOptions()) {
  156.                                 if (s.contains("What can you do to help a bold adventurer like myself?") || s.contains("Bless star, please.")) {
  157.                                     getDialogues().clickOption(s);
  158.                                 } else if (s.contains("Tell me about holy symbols.")) {
  159.                                     break InDialogue;
  160.                                 }
  161.                             }
  162.                         }
  163.                     }
  164.                 log("Blessed symbol #" + String.valueOf(i) + " of " + invCount);
  165.                 sleep(300);
  166.                 }
  167.                 catch (Exception e){ }
  168.             }
  169.         }
  170.         else {
  171.             GameObject door = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Door") && gameObject.hasAction("Open") && gameObject.getID() == 1535);
  172.             sleepUntil(() -> door.interact("Open"), 5000);
  173.             GoStairs("down");
  174.         }
  175.     }
  176. }
Add Comment
Please, Sign In to add comment