Advertisement
Guest User

Untitled

a guest
Jan 28th, 2019
85
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Random;
  2.  
  3. import org.dreambot.api.input.event.impl.InteractionEvent;
  4. import org.dreambot.api.input.event.impl.InteractionSetting;
  5. import org.dreambot.api.input.mouse.destination.impl.EntityDestination;
  6. import org.dreambot.api.methods.Calculations;
  7. import org.dreambot.api.methods.map.Area;
  8. import org.dreambot.api.methods.map.Tile;
  9. import org.dreambot.api.methods.walking.pathfinding.impl.obstacle.impl.PassableObstacle;
  10. import org.dreambot.api.methods.walking.pathfinding.impl.web.WebFinder;
  11. import org.dreambot.api.methods.walking.web.node.AbstractWebNode;
  12. import org.dreambot.api.methods.walking.web.node.impl.BasicWebNode;
  13. import org.dreambot.api.script.AbstractScript;
  14. import org.dreambot.api.script.ScriptManifest;
  15. import org.dreambot.api.script.Category;
  16. import org.dreambot.api.wrappers.interactive.Entity;
  17. import org.dreambot.api.wrappers.interactive.GameObject;
  18.  
  19. @ScriptManifest(author = "Zappy", name = "Stronghold", version = 1.0, description = "A Stronghold of Security Bot.", category = Category.MINIGAME)
  20. public class main extends AbstractScript {
  21.  
  22.     public void onStart() {
  23.  
  24.     }
  25.  
  26.     public void onExit() {
  27.  
  28.     }
  29.  
  30.     public Area stronghold = new Area(3077, 3425, 3088, 3416, 0);
  31.     public Random Rand = new Random();
  32.     int timeout = 0;
  33.  
  34.     public void walkToStrongHold() {
  35.         if (getLocalPlayer().getY() < 4000) {
  36.             TravelTo(stronghold);
  37.         }
  38.     }
  39.  
  40.     public void walkDownHole() {
  41.         GameObject hole = getGameObjects().closest("Entrance");
  42.         if (hole != null) {
  43.             hole.interact("Climb-down");
  44.         }
  45.     }
  46.    
  47.     public void opengate(Tile tile) {
  48.         GameObject gate = getGameObjects().getTopObjectOnTile(tile);
  49.         interact("Open", gate);
  50.         sleep(15000 + Rand.nextInt(1000));
  51.         if (getDialogues().inDialogue()) {
  52.             doDialogue("Decline the offer and report that player.", "Don't give them my password.",
  53.                     "Authenticator and two-step login on my registered email.",
  54.                     "Don't give them the information and send an 'Abuse Report'.", "Report the player for phishing.",
  55.                     "No.", "No, you should never buy an account.",
  56.                     "Don't give out your password to anyone. Not even close friends.",
  57.                     "Set up 2 step authentication with my email provider.",
  58.                     "Don't type in my password backwards and report the player.",
  59.                     "Do not visit the website and report the player who messaged you.",
  60.                     "Use the Account Recovery System.",
  61.                     "Don't click any links, forward the email to reportphishing@jagex.com.",
  62.                     "Virus scan my device then change my password.",
  63.                     "Through account settings on oldshcool.runescape.com.", "No, you should never buy an account.",
  64.                     "Report the incident and do not click any links.", "Me.", "No.",
  65.                     "No, you should never allow anyone to level your account.",
  66.                     "No way! You'll just take my gold for your own! Reported!",
  67.                     "Inform Jagex by emailing reportphishing@jagex.com.",
  68.                     "Don't tell them anything and click the Report Abuse button.",
  69.                     "Don't tell them anything and click the 'Report Abuse' button.", "Nobody.",
  70.                     "Read the text and follow the advice given.", "No way! I'm reporting you to Jagex!",
  71.                     "Only on the Old School Runescape website.");
  72.         }
  73.         sleep(600 + Rand.nextInt(600));
  74.         if (getDialogues().inDialogue()) {
  75.             doDialogue("Decline the offer and report that player.", "Don't give them my password.",
  76.                     "Authenticator and two-step login on my registered email.",
  77.                     "Don't give them the information and send an 'Abuse Report'.", "Report the player for phishing.",
  78.                     "No.", "No, you should never buy an account.",
  79.                     "Don't give out your password to anyone. Not even close friends.",
  80.                     "Set up 2 step authentication with my email provider.",
  81.                     "Don't type in my password backwards and report the player.",
  82.                     "Do not visit the website and report the player who messaged you.",
  83.                     "Use the Account Recovery System.",
  84.                     "Don't click any links, forward the email to reportphishing@jagex.com.",
  85.                     "Virus scan my device then change my password.",
  86.                     "Through account settings on oldshcool.runescape.com.", "No, you should never buy an account.",
  87.                     "Report the incident and do not click any links.", "Me.", "No.",
  88.                     "No, you should never allow anyone to level your account.",
  89.                     "No way! You'll just take my gold for your own! Reported!",
  90.                     "Inform Jagex by emailing reportphishing@jagex.com.",
  91.                     "Don't tell them anything and click the Report Abuse button.",
  92.                     "Don't tell them anything and click the 'Report Abuse' button.", "Nobody.",
  93.                     "Read the text and follow the advice given.", "No way! I'm reporting you to Jagex!",
  94.                     "Only on the Old School Runescape website.");
  95.         }
  96.         sleep(600 + Rand.nextInt(600));
  97.         if (getDialogues().inDialogue()) {
  98.             doDialogue("Decline the offer and report that player.", "Don't give them my password.",
  99.                     "Authenticator and two-step login on my registered email.",
  100.                     "Don't give them the information and send an 'Abuse Report'.", "Report the player for phishing.",
  101.                     "No.", "No, you should never buy an account.",
  102.                     "Don't give out your password to anyone. Not even close friends.",
  103.                     "Set up 2 step authentication with my email provider.",
  104.                     "Don't type in my password backwards and report the player.",
  105.                     "Do not visit the website and report the player who messaged you.",
  106.                     "Use the Account Recovery System.",
  107.                     "Don't click any links, forward the email to reportphishing@jagex.com.",
  108.                     "Virus scan my device then change my password.",
  109.                     "Through account settings on oldshcool.runescape.com.", "No, you should never buy an account.",
  110.                     "Report the incident and do not click any links.", "Me.", "No.",
  111.                     "No, you should never allow anyone to level your account.",
  112.                     "No way! You'll just take my gold for your own! Reported!",
  113.                     "Inform Jagex by emailing reportphishing@jagex.com.",
  114.                     "Don't tell them anything and click the Report Abuse button.",
  115.                     "Don't tell them anything and click the 'Report Abuse' button.", "Nobody.",
  116.                     "Read the text and follow the advice given.", "No way! I'm reporting you to Jagex!",
  117.                     "Only on the Old School Runescape website.");
  118.         }
  119.         sleep(600 + Rand.nextInt(600));
  120.         if (getDialogues().inDialogue()) {
  121.             doDialogue("Decline the offer and report that player.", "Don't give them my password.",
  122.                     "Authenticator and two-step login on my registered email.",
  123.                     "Don't give them the information and send an 'Abuse Report'.", "Report the player for phishing.",
  124.                     "No.", "No, you should never buy an account.",
  125.                     "Don't give out your password to anyone. Not even close friends.",
  126.                     "Set up 2 step authentication with my email provider.",
  127.                     "Don't type in my password backwards and report the player.",
  128.                     "Do not visit the website and report the player who messaged you.",
  129.                     "Use the Account Recovery System.",
  130.                     "Don't click any links, forward the email to reportphishing@jagex.com.",
  131.                     "Virus scan my device then change my password.",
  132.                     "Through account settings on oldshcool.runescape.com.", "No, you should never buy an account.",
  133.                     "Report the incident and do not click any links.", "Me.", "No.",
  134.                     "No, you should never allow anyone to level your account.",
  135.                     "No way! You'll just take my gold for your own! Reported!",
  136.                     "Inform Jagex by emailing reportphishing@jagex.com.",
  137.                     "Don't tell them anything and click the Report Abuse button.",
  138.                     "Don't tell them anything and click the 'Report Abuse' button.", "Nobody.",
  139.                     "Read the text and follow the advice given.", "No way! I'm reporting you to Jagex!",
  140.                     "Only on the Old School Runescape website.");
  141.         }
  142.         sleep(600 + Rand.nextInt(600));
  143.     }
  144.  
  145.     //This is just some more doors i changed how the code runs a bit and I didn't delete this part.
  146.     public void work() {
  147.         opengate(new Tile(1879, 5240, 0));
  148.         sleep(600 + Rand.nextInt(600));
  149.         opengate(new Tile(1884, 5244, 0));
  150.         sleep(600 + Rand.nextInt(600));
  151.         opengate(new Tile(1887, 5244, 0));
  152.         sleep(600 + Rand.nextInt(600));
  153.         opengate(new Tile(1904, 5243, 0));
  154.         sleep(600 + Rand.nextInt(600));
  155.         opengate(new Tile(1908, 5243, 0));
  156.         sleep(600 + Rand.nextInt(600));
  157.         opengate(new Tile(1905, 5233, 0));
  158.         sleep(600 + Rand.nextInt(600));
  159.         opengate(new Tile(1905, 5230, 0));
  160.         sleep(600 + Rand.nextInt(600));
  161.         GameObject giftopeace = getGameObjects().closest("Gift of Peace");
  162.         giftopeace.interact("Open");
  163.     }
  164.    
  165.     private boolean inArea(Area area) {
  166.         if(area.contains(getLocalPlayer().getTile())){
  167.             return true;
  168.         }return false;
  169.     }
  170.    
  171.     private enum State {
  172.         WALKTOAREA, CLIMBDOWNHOLE, DOOR1, DOOR2, DOOR3, DOOR4, DOOR5, WAIT
  173.     };
  174.    
  175.     Area door1 = new Area(1865, 5244, 1858, 5239, 0);
  176.     Area door2 = new Area(1859, 5238, 1858, 5236, 0);
  177.     Area door3 = new Area(1864, 5235, 1858, 5213, 0);
  178.     Area door4 = new Area(1867, 5227, 1865, 5226, 0);
  179.     Area door5 = new Area(1875, 5243, 1868, 5226, 0);
  180.    
  181.     private State getState() {
  182.         if(!inArea(stronghold) & !inArea(door1) & !inArea(door2) & !inArea(door3) & !inArea(door4) & !inArea(door5)) {
  183.             return State.WALKTOAREA;
  184.         }
  185.        
  186.         if(inArea(stronghold)) {
  187.             return State.CLIMBDOWNHOLE;
  188.         }
  189.        
  190.         if(inArea(door1)) {
  191.             return State.DOOR1;
  192.         }
  193.        
  194.         if(inArea(door2)) {
  195.             return State.DOOR2;
  196.         }
  197.        
  198.         if(inArea(door3)) {
  199.             return State.DOOR3;
  200.         }
  201.        
  202.         if(inArea(door4)) {
  203.             return State.DOOR4;
  204.         }
  205.        
  206.         if(inArea(door5)) {
  207.             return State.DOOR5;
  208.         }
  209.        
  210.         return State.WAIT;
  211.     }
  212.    
  213.     @Override
  214.     public int onLoop() {
  215.         switch (getState()){
  216.             case WALKTOAREA:
  217.                 walkToStrongHold();
  218.                 break;
  219.             case CLIMBDOWNHOLE:
  220.                 walkDownHole();
  221.                 break;
  222.             case DOOR1:
  223.                 if (getWalking().isRunEnabled()) {
  224.                     getWalking().toggleRun();
  225.                 }
  226.                 opengate(new Tile(1859, 5239, 0));
  227.                 sleep(600 + Rand.nextInt(600));
  228.                 break;
  229.             case DOOR2:
  230.                 opengate(new Tile(1859, 5235, 0));
  231.                 sleep(600 + Rand.nextInt(600));
  232.                 break;
  233.             case DOOR3:
  234.                 addNode1();
  235.                 Tile door3tile = new Tile(1865, 5227, 0);
  236.                 getWalking().walkOnScreen(door3tile.getRandomizedTile(1));
  237.                 opengate(new Tile(1865, 5227, 0));
  238.                 sleep(600 + Rand.nextInt(600));
  239.                 break;
  240.             case DOOR4:
  241.                 opengate(new Tile(1868, 5226, 0));
  242.                 sleep(600 + Rand.nextInt(600));
  243.                 break;
  244.             case DOOR5:
  245.                 addNode2();
  246.                 Tile door5tile = new Tile(1875, 5240, 0);
  247.                 getWalking().walkOnScreen(door5tile.getRandomizedTile(1));
  248.                 opengate(new Tile(1875, 5240, 0));
  249.                 sleep(600 + Rand.nextInt(600));
  250.                 break;
  251.             case WAIT:
  252.                 sleep(300);
  253.                 break;
  254.         }
  255.         return Calculations.random(500, 600);
  256.     }
  257.    
  258.     //These im not really sure if there doing anything I heard the dungeon might not be mapped so I added web nodes from a tutorial with a script.
  259.     public void addNode1() {
  260.         AbstractWebNode webNode0 = new BasicWebNode(1858, 5235);
  261.         AbstractWebNode webNode1 = new BasicWebNode(1864, 5226);
  262.         AbstractWebNode webNode2 = new BasicWebNode(1864, 5227);
  263.         webNode0.addConnections(webNode1);
  264.         webNode0.addConnections(webNode2);
  265.         webNode1.addConnections(webNode0);
  266.         webNode2.addConnections(webNode0);
  267.         WebFinder webFinder = getWalking().getWebPathFinder();
  268.         AbstractWebNode[] webNodes = {webNode2, webNode1, webNode0};
  269.         for (AbstractWebNode webNode : webNodes) {
  270.         webFinder.addWebNode(webNode);
  271.         }
  272.     }
  273.    
  274.     public void addNode2() {
  275.         AbstractWebNode webNode0 = new BasicWebNode(1868, 5226);
  276.         AbstractWebNode webNode1 = new BasicWebNode(1875, 5240);
  277.         AbstractWebNode webNode2 = new BasicWebNode(1875, 5239);
  278.         webNode0.addConnections(webNode1);
  279.         webNode0.addConnections(webNode2);
  280.         webNode1.addConnections(webNode0);
  281.         webNode2.addConnections(webNode0);
  282.         WebFinder webFinder = getWalking().getWebPathFinder();
  283.         AbstractWebNode[] webNodes = {webNode2, webNode1, webNode0};
  284.         for (AbstractWebNode webNode : webNodes) {
  285.         webFinder.addWebNode(webNode);
  286.         }
  287.  
  288.     }
  289.  
  290.     public boolean interact(String action, Entity target) {
  291.         if (target.isOnScreen()) {
  292.             EntityDestination ed = new EntityDestination(getClient(), target);
  293.             InteractionEvent ie = new InteractionEvent(ed);
  294.             return ie.interactForceRight(action);
  295.         } else {
  296.             return target.interactForceRight(action);
  297.         }
  298.     }
  299.  
  300.     public boolean doDialogue(String... chooseOptions) {
  301.         if (getDialogues().canContinue()) {
  302.             getDialogues().continueDialogue();
  303.             return true;
  304.         }
  305.  
  306.         String options[] = getDialogues().getOptions();
  307.  
  308.         if (options == null) {
  309.             return false;
  310.         }
  311.  
  312.         for (int i = 0; i < options.length; i++) {
  313.             for (String chooseOption : chooseOptions) {
  314.                 if (options[i].contains(chooseOption)) {
  315.                     getDialogues().chooseOption(i + 1);
  316.                     return true;
  317.                 }
  318.             }
  319.         }
  320.         return false;
  321.     }
  322.  
  323.     public void TravelTo(Area destination) {
  324.         // clicks really frequently when close to location
  325.         // think i fixed this by changing this
  326.         // getWalking().walk(destination.getCenter()); from getRandom()
  327.         // https://dreambot.org/forums/index.php?/topic/4512-walking-a-path-with-doors/
  328.  
  329.         /*
  330.          * while (!destination.contains(getLocalPlayer())) {
  331.          * getWalking().walk(destination.getCenter()); sleepUntil(() ->
  332.          * getWalking().getDestination().distance() < Calculations.random(5, 7) ,
  333.          * Calculations.random(3400, 4250)); sleep(Calculations.random(300, 600));
  334.          * sleepUntil( () -> !getLocalPlayer().isMoving() || getLocalPlayer().distance(
  335.          * getClient().getDestination()) < Calculations.random( 7, 12),
  336.          * Calculations.random(5000, 6666));
  337.          *
  338.          * }
  339.          */
  340.  
  341.         // Walking algorithm modified from Before's Cooks Assistant quest bot
  342.         // issues: since this will sleep until the user has stopped moving + some random
  343.         // time there is a lot of standing around
  344.         // however it does not have the issue of spam clicking once you get close to the
  345.         // destination
  346.         while (!destination.contains(getLocalPlayer()) && !destination.contains(getWalking().getDestination())) {
  347.             getWalking().walk(destination.getRandomTile());
  348.             getWalking().getAStarPathFinder().addObstacle(new PassableObstacle("Door", "Open", null, null, null));
  349.             // sleep(2000+Rand.nextInt(1000));
  350.             if (getWalking().isRunEnabled()) {
  351.                 getWalking().toggleRun();
  352.             }
  353.             sleepUntil(() -> getLocalPlayer().isStandingStill(), Rand.nextInt(6000));
  354.         }
  355.     }
  356. }
Advertisement
RAW Paste Data Copied
Advertisement