SHARE
TWEET

Untitled

a guest Oct 21st, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package org.rspeer;
  2.  
  3. import org.rspeer.runetek.adapter.component.InterfaceComponent;
  4. import org.rspeer.runetek.adapter.scene.Npc;
  5. import org.rspeer.runetek.adapter.scene.Pickable;
  6. import org.rspeer.runetek.adapter.scene.Player;
  7. import org.rspeer.runetek.adapter.scene.SceneObject;
  8. import org.rspeer.runetek.api.commons.Time;
  9. import org.rspeer.runetek.api.component.Bank;
  10. import org.rspeer.runetek.api.component.Dialog;
  11. import org.rspeer.runetek.api.component.Interfaces;
  12. import org.rspeer.runetek.api.component.tab.Inventory;
  13. import org.rspeer.runetek.api.component.tab.Skill;
  14. import org.rspeer.runetek.api.component.tab.Skills;
  15. import org.rspeer.runetek.api.movement.Movement;
  16. import org.rspeer.runetek.api.movement.position.Area;
  17. import org.rspeer.runetek.api.movement.position.Position;
  18. import org.rspeer.runetek.api.scene.Npcs;
  19. import org.rspeer.runetek.api.scene.Pickables;
  20. import org.rspeer.runetek.api.scene.Players;
  21. import org.rspeer.runetek.api.scene.SceneObjects;
  22. import org.rspeer.runetek.event.listeners.ChatMessageListener;
  23. import org.rspeer.runetek.event.listeners.RenderListener;
  24. import org.rspeer.runetek.event.types.ChatMessageEvent;
  25. import org.rspeer.runetek.event.types.ChatMessageType;
  26. import org.rspeer.runetek.event.types.RenderEvent;
  27. import org.rspeer.script.Script;
  28. import org.rspeer.script.ScriptCategory;
  29. import org.rspeer.script.ScriptMeta;
  30. import org.rspeer.ui.Log;
  31.  
  32. import javax.imageio.ImageIO;
  33. import java.awt.*;
  34. import java.awt.image.BufferedImage;
  35. import java.io.File;
  36. import java.io.IOException;
  37. import java.security.SecureRandom;
  38. import java.text.DecimalFormat;
  39. import java.time.Instant;
  40. import java.util.List;
  41.  
  42. @ScriptMeta(name = "1 Den Minigame", desc = "Tries to farm Rogue pieces", developer = "ikiddoi", version = 417, category = ScriptCategory.MINIGAME)
  43. public class Rogue extends Script implements RenderListener, ChatMessageListener {
  44.  
  45.     private boolean takeScreenie = false, completedMaze = false;
  46.     private String status;
  47.     private long startTime, lastAnim;
  48.     private int startThieveXP, startAgilityXP, startThieveLvl, startAgilitylvl, maze = 0, rogueCrates = 0;
  49.     private RandomHandler randomEvent = new RandomHandler();
  50.     private int lastAnimDelay = random(8000, 12000);
  51.  
  52.     @Override
  53.     public void onStart() {
  54.         startTime = System.currentTimeMillis();
  55.         startThieveXP = Skills.getExperience(Skill.THIEVING);
  56.         startThieveLvl = Skills.getLevelAt(startThieveXP);
  57.         startAgilityXP = Skills.getExperience(Skill.AGILITY);
  58.         startAgilitylvl = Skills.getLevelAt(startAgilityXP);
  59.  
  60.         status = "Loading up!";
  61.     }
  62.  
  63.     @Override
  64.     public int loop() {
  65.         Player Local = Players.getLocal();
  66.         Log.info(System.currentTimeMillis());
  67.         if (Local.isAnimating() || Local.isMoving())
  68.             lastAnim = System.currentTimeMillis();
  69.  
  70.         long msSinceAnim = System.currentTimeMillis() - lastAnim;
  71.  
  72.         randomEvent.checkLamp();
  73.         if (randomEvent.findNearbyRandoms()) {
  74.             Time.sleep(1000);
  75.         }
  76.         if (randomEvent.doWeHaveRandom()) {
  77.             takeScreenie = true;
  78.             randomEvent.handleRandom();
  79.         } else if (!Inventory.contains("Mystic jewel") && Movement.getRunEnergy() < 90 && Inventory.contains(item -> item.getName().startsWith("Energy"))) {
  80.             status = "Restoring energy";
  81.             if (Inventory.contains(item -> item.getName().startsWith("Energy"))) {
  82.                 Inventory.getFirst(item -> item.getName().startsWith("Energy")).interact("Drink");
  83.                 Time.sleepUntil(Local::isAnimating, 720, 5000);
  84.                 Time.sleep(random(400, 600));
  85.             }
  86.         } else if (!Inventory.contains("Mystic jewel") && (!Inventory.isEmpty() || Movement.getRunEnergy() < 90)) {
  87.             status = "Banking and restoring energy";
  88.             if (!Bank.isOpen()) {
  89.                 if (SceneObjects.getNearest("Bank chest") != null) {
  90.                     SceneObjects.getNearest("Bank chest").interact("Use");
  91.                     Time.sleepUntil(() -> Bank.isOpen() || Interfaces.isOpen(213), 500, 5000);
  92.                 } else {
  93.                     Area bankArea = Area.rectangular(3043, 4974, 3047, 4969, 1);
  94.                     Movement.walkTo(bankArea.getTiles().get(random(0, bankArea.getTiles().size() - 1)));
  95.                     Time.sleepUntil(() -> bankArea.contains(Local), 200, 5000);
  96.                 }
  97.             }
  98.             if (Interfaces.isOpen(213)) {
  99.                 status = "Waiting for Bank PIN entry";
  100.             }
  101.             if (Bank.isOpen()) {
  102.                 if (Movement.getRunEnergy() < 90) {
  103.                     Bank.withdraw(item -> item.getName().startsWith("Energy"), 1);
  104.                     Time.sleepUntil(() -> Inventory.contains(item -> item.getName().startsWith("Energy")), 200, 5000);
  105.                     Bank.close();
  106.                     Time.sleep(random(300, 400));
  107.                 } else {
  108.                     Bank.depositInventory();
  109.                     Time.sleepUntil(Inventory::isEmpty, 500, 5000);
  110.                     Bank.close();
  111.                     Time.sleep(random(300, 400));
  112.  
  113.                     if (rogueCrates == 5) {
  114.                         Log.info("We have 5 crates! Stopping now");
  115.                         setStopping(false);
  116.                     }
  117.                 }
  118.             }
  119.         } else if (!Inventory.contains("Mystic jewel")) {
  120.             status = "Entering minigame";
  121.             completedMaze = false;
  122.             SceneObject door = SceneObjects.getNearest(7256);//Doorway
  123.             if (door != null) {
  124.                 door.interact("Open");
  125.                 Time.sleepUntil(() -> Inventory.contains("Mystic jewel"), 500, 5000);
  126.             }
  127.         } else if (Local.getPosition().equals(new Position(3056, 4992, 1)) || Local.getPosition().equals(new Position(3056, 4993, 1))) {
  128.             forceRun();
  129.             if (!Local.getPosition().equals(new Position(3056, 4993, 1))) {
  130.                 traverse(new Position(3056, 4993, 1));
  131.                 Time.sleep(random(400, 700));
  132.             } else {
  133.                 traverse(new Position(3056, 4995, 1));
  134.                 Time.sleep(random(400, 700));
  135.             }
  136.         } else if (Local.getPosition().equals(new Position(3056, 4995, 1)) || Local.getPosition().equals(new Position(3050, 4997, 1))) {
  137.             SceneObject contortBars = SceneObjects.getNearest(7251);
  138.             if (contortBars != null) {
  139.                 contortBars.interact("Enter");
  140.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3048, 4997, 1)), 500, 5000);
  141.                 Time.sleep(random(400, 700));
  142.             }
  143.         } else if (Local.getPosition().equals(new Position(3048, 4997, 1))) {
  144.             status = "Trying tricky walk";
  145.             List<Position> walr = Area.rectangular(3040, 4999, 3040, 4997, 1).getTiles();
  146.             Position dis = walr.get(random(0, walr.size() - 1));
  147.  
  148.             Log.info("Trying to walk to " + dis + " Is it walkable? " + dis.isPositionWalkable());
  149.  
  150.             //Bad path
  151.             if (dis.equals(new Position(3040, 4998, 1)))
  152.                 return 100;
  153.  
  154.             Movement.walkTo(dis);
  155.             // Movement.walkTo(dis);
  156.             Time.sleepUntil(() -> Local.getAnimation() == 1115, 500, 5000);
  157.             Time.sleep(random(1500, 2000));
  158.         } else if (Area.rectangular(3038, 4999, 3040, 4997, 1).contains(Local)) {
  159.             status = "Crossing 3";
  160.             traverse(new Position(3037, 4999, 1));
  161.             Time.sleep(random(400, 700));
  162.         } else if (Local.getPosition().equals(new Position(3037, 4999, 1))) {
  163.             status = "Crossing 3 now!";
  164.             traverse(new Position(3033, 4999, 1));
  165.             Time.sleep(random(200, 400));
  166.         } else if (Local.getPosition().equals(new Position(3033, 4999, 1))) {
  167.             status = "Moving up 1 tile";
  168.             traverse(new Position(3032, 4999, 1));
  169.             Time.sleep(random(200, 400));
  170.         } else if (Local.getPosition().equals(new Position(3032, 4999, 1))) {
  171.             status = "Finishing cross 3!";
  172.             traverse(new Position(3027, 4999, 1));
  173.             Time.sleep(random(400, 700));
  174.         } else if (Local.getPosition().equals(new Position(3027, 4999, 1))) {
  175.             SceneObject grill = SceneObjects.getNearest(7255);
  176.             if (grill != null) {
  177.                 grill.interact("Open");
  178.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3023, 5001, 1)), 500, 5000);
  179.                 Time.sleep(random(400, 700));
  180.             }
  181.         } else if (Local.getPosition().equals(new Position(3023, 5001, 1))) {
  182.             status = "Running to diagANAL";
  183.             traverse(new Position(3014, 5003, 1));
  184.             Time.sleep(random(300, 500));
  185.         } else if (Local.getPosition().equals(new Position(3014, 5003, 1))) {
  186.             traverse(new Position(3012, 5001, 1));
  187.             Time.sleep(random(300, 500));
  188.         } else if (Local.getPosition().equals(new Position(3012, 5001, 1))) {
  189.             traverse(new Position(3009, 5003, 1));
  190.             Time.sleep(random(300, 500));
  191.         } else if (Local.getPosition().equals(new Position(3009, 5003, 1))) {
  192.             status = "Getting on edge";
  193.             forceWalk();
  194.  
  195.             SceneObject ledge = SceneObjects.getNearest(7240);
  196.             if (ledge != null) {
  197.                 ledge.interact("Climb");
  198.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(2988, 5004, 1)), 500, 5000);
  199.                 Time.sleep(random(400, 700));
  200.             }
  201.         } else if (Local.getPosition().equals(new Position(2988, 5004, 1))) {
  202.             status = "Getting to blades!";
  203.             Area bladez = Area.rectangular(2970, 5019, 2972, 5016, 1);
  204.             for (int i = 0; i < 5; i++) {
  205.                 Log.info("Loop " + i);
  206.                 Movement.walkTo(bladez.getTiles().get(random(0, bladez.getTiles().size() - 1)));
  207.                 Time.sleep(random(2000, 3000));
  208.                 if (bladez.contains(Local))
  209.                     break;
  210.             }
  211.         } else if (Area.rectangular(2970, 5019, 2972, 5016, 1).contains(Local)) {
  212.             status = "Crossing blades";
  213.             //TODO: LOOKS BOTLIKE
  214.             List<Position> bladez = Area.rectangular(2969, 5019, 2969, 5016, 1).getTiles();
  215.             Position dis = bladez.get(random(0, bladez.size() - 1));
  216.             Log.info("Trying to walk to " + dis + " Is it walkable? " + dis.isPositionWalkable());
  217.             Movement.walkTo(dis);
  218.             Time.sleepUntil(() -> Area.rectangular(2967, 5019, 2967, 5016, 1).contains(Local), 500, 5000);
  219.             // Time.sleep(random(400, 700));
  220.         } else if (Area.rectangular(2967, 5019, 2967, 5016, 1).contains(Local)) {
  221.             status = "Crossing pendulums";
  222.             List<Position> pendulumz = Area.rectangular(2958, 5026, 2964, 5025, 1).getTiles();
  223.             Position dis = pendulumz.get(random(0, pendulumz.size() - 1));
  224.             if (dis.getX() == 2963 || dis.getX() == 2960)
  225.                 return 100;
  226.  
  227.             Log.info("Trying to walk to " + dis + " Is it walkable? " + dis.isPositionWalkable());
  228.             Movement.walkTo(dis);
  229.             Time.sleepUntil(() -> Area.rectangular(2964, 5028, 2954, 5028, 1).contains(Local), 500, 5000);
  230.             Time.sleep(random(400, 700));
  231.         } else if (Area.rectangular(2964, 5028, 2954, 5028, 1).contains(Local)) {
  232.             status = "Crossing ledge";
  233.             SceneObject bridge = SceneObjects.getNearest(7239);
  234.             if (bridge != null) {
  235.                 bridge.interact("Climb");
  236.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(2958, 5035, 1)), 500, 5000);
  237.                 Time.sleep(random(400, 700));
  238.             }
  239.         } else if (Local.getPosition().equals(new Position(2958, 5035, 1))) {
  240.             status = "Walking closer to trap";
  241.             forceRun();
  242.             for (int i = 0; i < 5; i++) {
  243.                 Log.info("Loop " + i);
  244.                 Movement.walkTo(new Position(2963, 5050, 1));
  245.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(2963, 5050, 1)), 500, random(2000, 3000));
  246.                 if (Local.getPosition().equals(new Position(2963, 5050, 1)))
  247.                     break;
  248.             }
  249.             Time.sleep(random(400, 700));
  250.         } else if (Local.getPosition().equals(new Position(2963, 5050, 1))) {
  251.             status = "Disabling trap";
  252.             SceneObject trap = SceneObjects.getNearest(7227);
  253.             if (trap != null) {
  254.                 trap.interact("Search");
  255.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(2963, 5051, 1)), 500, 5000);
  256.                 Time.sleep(random(400, 700));
  257.             }
  258.         } else if (Local.getPosition().equals(new Position(2963, 5051, 1))) {
  259.             status = "Moving plus 3! (NEW SPEED)";
  260.             traverse(new Position(2963, 5055, 1));
  261.             Time.sleep(random(150, 200));
  262.         } else if (Local.getPosition().equals(new Position(2963, 5055, 1))) {
  263.             status = "Entering passageway";
  264.             forceWalk();
  265.             SceneObject passage = SceneObjects.getNearest(7219);
  266.             if (passage != null) {
  267.                 passage.interact("Enter");
  268.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(2957, 5072, 1)), 500, 8000);
  269.                 Time.sleep(random(400, 700));
  270.             }
  271.         } else if (Local.getPosition().equals(new Position(2957, 5072, 1))) {
  272.             status = "Crossing blade";
  273.             Movement.walkTo(new Position(2957, 5074, 1));
  274.             Time.sleepUntil(() -> Local.getPosition().equals(new Position(2957, 5076, 1)), 500, 5000);
  275.             Time.sleep(random(400, 700));
  276.         } else if (Local.getPosition().equals(new Position(2957, 5076, 1))) {
  277.             status = "Getting to next passageway";
  278.             Area beforePassage = Area.rectangular(2954, 5091, 2955, 5089, 1);
  279.             Movement.walkTo(beforePassage.getTiles().get(random(0, beforePassage.getTiles().size() - 1)));
  280.             Time.sleep(random(400, 700));
  281.         } else if (Area.rectangular(2954, 5091, 2955, 5089, 1).contains(Local)) {
  282.             status = "Entering passageway";
  283.             SceneObject passage = SceneObjects.getNearest(7219);
  284.             if (passage != null) {
  285.                 passage.interact("Enter");
  286.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(2955, 5098, 1)), 500, 8000);
  287.                 Time.sleep(random(400, 700));
  288.             }
  289.         } else if (Local.getPosition().equals(new Position(2955, 5098, 1))) {
  290.             status = "Getting to next passageway (LAG?)";
  291.             Area beforePassage = Area.rectangular(2970, 5100, 2971, 5098, 1);
  292.             Movement.walkTo(beforePassage.getTiles().get(random(0, beforePassage.getTiles().size() - 1)));
  293.             Time.sleep(random(400, 700));
  294.         } else if (Area.rectangular(2970, 5100, 2971, 5098, 1).contains(Local)) {
  295.             status = "Entering passageway";
  296.             SceneObject passage = SceneObjects.getNearest(7219);
  297.             if (passage != null) {
  298.                 passage.interact("Enter");
  299.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(2972, 5094, 1)), 500, 8000);
  300.                 Time.sleep(random(400, 700));
  301.             }
  302.         } else if (Local.getPosition().equals(new Position(2972, 5094, 1))) {
  303.             status = "Opening grill";
  304.             SceneObject grl = SceneObjects.getNearest(7255);
  305.             if (grl != null) {
  306.                 grl.interact("Open");
  307.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(2972, 5093, 1)), 500, 8000);
  308.                 Time.sleep(random(400, 700));
  309.             }
  310.         } else if (Local.getPosition().equals(new Position(2972, 5093, 1))) {
  311.             status = "Running away from spinning blades";
  312.             forceRun();
  313.             Area awayFromBlade = Area.rectangular(2972, 5087, 2976, 5086, 1);
  314.             Movement.walkTo(awayFromBlade.getTiles().get(random(0, awayFromBlade.getTiles().size() - 1)));
  315.             Time.sleep(random(400, 700));
  316.         } else if (Area.rectangular(2972, 5087, 2976, 5086, 1).contains(Local)) {
  317.             SceneObject ledge = SceneObjects.getNearest(s -> s.getId() == 7240 && s.getPosition().getY() == 5087);
  318.             if (ledge != null) {
  319.                 ledge.interact("Climb");
  320.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(2991, 5087, 1)), 500, 8000);
  321.                 Time.sleep(random(400, 700));
  322.             }
  323.         } else if (Local.getPosition().equals(new Position(2991, 5087, 1))) {
  324.             status = "Disabling trap";
  325.             SceneObject trap = SceneObjects.getNearest(trp -> trp.getId() == 7249 && trp.getPosition().equals(new Position(2993, 5087, 1)));
  326.             if (trap != null) {
  327.                 Time.sleep(random(300, 400));//TODO: FIXED BROKEN BIT?
  328.                 trap.interact("Search");
  329.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(2993, 5088, 1)), 500, 5000);
  330.                 Time.sleep(random(400, 700));
  331.             }
  332.         } else if (Local.getPosition().equals(new Position(2993, 5088, 1))) {
  333.             status = "Running to blade";
  334.             traverse(new Position(3000, 5087, 1));
  335.             Time.sleep(random(400, 700));
  336.         } else if (Local.getPosition().equals(new Position(3000, 5087, 1))) {
  337.             status = "Crossing blade";
  338.             Movement.walkTo(new Position(3001, 5087, 1));
  339.             Time.sleepUntil(() -> Local.getPosition().equals(new Position(3003, 5087, 1)), 500, 8000);
  340.             Time.sleep(random(400, 700));
  341.         } else if (Local.getPosition().equals(new Position(3003, 5087, 1))) {
  342.             status = "Picking up tile";
  343.             Area tileRoom = Area.rectangular(3019, 5084, 3015, 5082, 1);
  344.             Movement.walkTo(tileRoom.getTiles().get(random(0, tileRoom.getTiles().size() - 1)));
  345.             Time.sleep(random(400, 700));
  346.         } else if (Area.rectangular(3018, 5085, 3015, 5082, 1).contains(Local)) {
  347.             status = "Picking up tile";
  348.             Pickable tile = Pickables.getNearest(5568);
  349.             if (tile != null) {
  350.                 tile.interact("Take");
  351.                 Time.sleepUntil(() -> Inventory.contains(5568), 500, 8000);
  352.             }
  353.             Time.sleep(random(400, 700));
  354.         } else if (Inventory.contains(5568)) {
  355.             status = "Putting tile into door";
  356.             SceneObject door = SceneObjects.getNearest(7234);
  357.             if (door != null && !Interfaces.isOpen(293)) {
  358.                 door.interact("Open");
  359.                 Time.sleepUntil(() -> Interfaces.isOpen(293), 500, 8000);
  360.             }
  361.             if (Interfaces.isOpen(293)) {
  362.                 InterfaceComponent key = Interfaces.getComponent(293, 3);
  363.                 if (key != null) {
  364.                     Time.sleep(random(300, 700));
  365.                     key.interact("Ok");
  366.                     Time.sleepUntil(() -> Local.getPosition().equals(new Position(3024, 5082, 1)), 500, 8000);
  367.                 }
  368.             }
  369.         } else if (Local.getPosition().equals(new Position(3024, 5082, 1))) {
  370.             status = "Time for a maze!";
  371.             //forceWalk();
  372.             SceneObject grill = SceneObjects.getNearest(id -> id.getId() == 7255 && id.getPosition().equals(new Position(3030, 5079, 1)));
  373.             if (grill != null) {
  374.                 grill.interact("Open");
  375.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3031, 5079, 1)), 500, 8000);
  376.                 Time.sleep(random(400, 700));
  377.             }
  378.         } else if (Local.getPosition().equals(new Position(3031, 5079, 1))) {
  379.             status = "Maze 1";//TODO: Make maze more human like
  380.             SceneObject grill = SceneObjects.getNearest(id -> id.getId() == 7255 && id.getPosition().equals(new Position(3032, 5078, 1)));
  381.             if (grill != null) {
  382.                 grill.interact("Open");
  383.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3032, 5077, 1)), 500, 8000);
  384.                 Time.sleep(random(200, 400));
  385.             }
  386.         } else if (Local.getPosition().equals(new Position(3032, 5077, 1))) {
  387.             status = "Maze 2";
  388.             SceneObject grill = SceneObjects.getNearest(id -> id.getId() == 7255 && id.getPosition().equals(new Position(3036, 5076, 1)));
  389.             if (grill != null) {
  390.                 grill.interact("Open");
  391.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3037, 5076, 1)), 500, 8000);
  392.                 Time.sleep(random(200, 400));
  393.             }
  394.         } else if (Local.getPosition().equals(new Position(3037, 5076, 1))) {
  395.             status = "Maze 3";
  396.             SceneObject grill = SceneObjects.getNearest(id -> id.getId() == 7255 && id.getPosition().equals(new Position(3039, 5079, 1)));
  397.             if (grill != null) {
  398.                 grill.interact("Open");
  399.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3040, 5079, 1)), 500, 8000);
  400.                 Time.sleep(random(200, 400));
  401.             }
  402.         } else if (Local.getPosition().equals(new Position(3040, 5079, 1))) {
  403.             status = "Maze 4";
  404.             SceneObject grill = SceneObjects.getNearest(id -> id.getId() == 7255 && id.getPosition().equals(new Position(3042, 5076, 1)));
  405.             if (grill != null) {
  406.                 grill.interact("Open");
  407.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3043, 5076, 1)), 500, 8000);
  408.                 Time.sleep(random(200, 400));
  409.             }
  410.         } else if (Local.getPosition().equals(new Position(3043, 5076, 1))) {
  411.             status = "Maze 5";
  412.             SceneObject grill = SceneObjects.getNearest(id -> id.getId() == 7255 && id.getPosition().equals(new Position(3044, 5069, 1)));
  413.             if (grill != null) {
  414.                 grill.interact("Open");
  415.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3044, 5068, 1)), 500, 8000);
  416.                 Time.sleep(random(200, 400));
  417.             }
  418.         } else if (Local.getPosition().equals(new Position(3044, 5068, 1))) {
  419.             status = "Maze 6";
  420.             SceneObject grill = SceneObjects.getNearest(id -> id.getId() == 7255 && id.getPosition().equals(new Position(3041, 5068, 1)));
  421.             if (grill != null) {
  422.                 grill.interact("Open");
  423.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3041, 5069, 1)), 500, 8000);
  424.                 Time.sleep(random(200, 400));
  425.             }
  426.         } else if (Local.getPosition().equals(new Position(3041, 5069, 1))) {
  427.             status = "Maze 7";
  428.             SceneObject grill = SceneObjects.getNearest(id -> id.getId() == 7255 && id.getPosition().equals(new Position(3040, 5070, 1)));
  429.             if (grill != null) {
  430.                 grill.interact("Open");
  431.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3039, 5070, 1)), 500, 8000);
  432.                 Time.sleep(random(200, 400));
  433.             }
  434.         } else if (Local.getPosition().equals(new Position(3039, 5070, 1))) {
  435.             status = "Maze 9";
  436.             SceneObject grill = SceneObjects.getNearest(id -> id.getId() == 7255 && id.getPosition().equals(new Position(3038, 5069, 1)));
  437.             if (grill != null) {
  438.                 grill.interact("Open");
  439.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3038, 5068, 1)), 500, 8000);
  440.                 Time.sleep(random(200, 400));
  441.             }
  442.         } else if (Local.getPosition().equals(new Position(3038, 5068, 1))) {
  443.             status = "Finished maze, moving on!";
  444.             Area toNextTrap = Area.rectangular(3038, 5039, 3040, 5034, 1);
  445.             for (int i = 0; i < 20; i++) {
  446.                 Movement.walkTo(toNextTrap.getTiles().get(random(0, toNextTrap.getTiles().size() - 1)));
  447.                 Time.sleepUntil(() -> toNextTrap.contains(Local), 200, random(3000, 4000));
  448.                 if (toNextTrap.contains(Local))
  449.                     break;
  450.             }
  451.         } else if (Area.rectangular(3038, 5039, 3040, 5034, 1).contains(Local)) {
  452.             status = "Disabling trap";
  453.             forceRun();
  454.             SceneObject trap = SceneObjects.getNearest(trp -> trp.getId() == 7249 && trp.getPosition().equals(new Position(3027, 5032, 1)));
  455.             if (trap != null) {
  456.                 trap.interact("Search");
  457.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3027, 5033, 1)), 500, 5000);
  458.                 Time.sleep(random(400, 700));
  459.             }
  460.         } else if (Local.getPosition().equals(new Position(3027, 5033, 1))) {
  461.             status = "Opening grill";
  462.             SceneObject grill = SceneObjects.getNearest(d -> d.getId() == 7255 && d.getPosition().equals(new Position(3015, 5033, 1)));
  463.             if (grill != null) {
  464.                 grill.interact("Open");
  465.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3014, 5033, 1)), 500, 8000);
  466.                 Time.sleep(random(400, 700));
  467.             }
  468.         } else if (Local.getPosition().equals(new Position(3014, 5033, 1))) {
  469.             status = "Skipping 3 traps";
  470.             traverse(new Position(3010, 5033, 1));
  471.             Time.sleep(random(400, 700));
  472.         } else if (Local.getPosition().equals(new Position(3010, 5033, 1))) {
  473.             status = "Opening grill";
  474.             SceneObject grill = SceneObjects.getNearest(7255);
  475.             if (grill != null) {
  476.                 grill.interact("Open");
  477.                 Time.sleepUntil(() -> Local.getPosition().equals(new Position(3009, 5033, 1)), 500, 8000);
  478.                 Time.sleep(random(400, 700));
  479.             }
  480.         } else if (Local.getPosition().equals(new Position(3009, 5033, 1))) {
  481.             status = "Getting closer to traps";
  482.             traverse(new Position(3008, 5033, 1));
  483.             Time.sleep(random(400, 700));
  484.         } else if (Local.getPosition().equals(new Position(3008, 5033, 1))) {
  485.             status = "Skipping 3 traps";
  486.             traverse(new Position(3004, 5033, 1));
  487.             Time.sleep(random(400, 700));
  488.         } else if (Local.getPosition().equals(new Position(3004, 5033, 1))) {
  489.             status = "Passing pendulum";
  490.             Movement.walkTo(new Position(3003, 5034, 1));
  491.             Time.sleepUntil(() -> Local.getPosition().equals(new Position(3000, 5034, 1)), 500, 8000);
  492.             Time.sleep(random(400, 700));
  493.         } else if (Local.getPosition().equals(new Position(3000, 5034, 1))) {
  494.             status = "Walking closer to traps";
  495.             Area nearTrap = Area.rectangular(2995, 5044, 2998, 5042, 1);
  496.             Movement.walkTo(nearTrap.getTiles().get(random(0, nearTrap.getTiles().size() - 1)));
  497.             Time.sleepUntil(() -> nearTrap.contains(Local), 500, 8000);
  498.             // Time.sleep(random(200, 500));//TODO FIX BOT LIKE ACTIVITY HERE
  499.         } else if (Area.rectangular(2995, 5044, 2998, 5042, 1).contains(Local)) {
  500.             status = "Walking even closer!";
  501.             traverse(new Position(2992, 5045, 1));
  502.             Time.sleep(random(400, 700));
  503.         } else if (Local.getPosition().equals(new Position(2992, 5045, 1))) {
  504.             status = "Passing through 3";
  505.             traverse(new Position(2992, 5049, 1));
  506.             Time.sleep(random(300, 500));
  507.         } else if (Local.getPosition().equals(new Position(2992, 5049, 1))) {
  508.             status = "Running to next trap";
  509.             Area newTrap = Area.rectangular(2991, 5064, 2992, 5059, 1);
  510.             Movement.walkTo(newTrap.getTiles().get(random(0, newTrap.getTiles().size() - 1)));
  511.             Time.sleepUntil(() -> newTrap.contains(Local), 500, 8000);
  512.             Time.sleep(random(200, 500));
  513.         } else if (Area.rectangular(2991, 5066, 2992, 5059, 1).contains(Local)) {
  514.             status = "Getting into position";
  515.             traverse(new Position(2992, 5067, 1));
  516.             Time.sleep(random(400, 700));
  517.         } else if (Local.getPosition().equals(new Position(2992, 5067, 1))) {
  518.             status = "Skipping 3 traps";
  519.             traverse(new Position(2992, 5071, 1));
  520.             Time.sleep(random(400, 700));
  521.         } else if (Local.getPosition().equals(new Position(2992, 5071, 1))) {
  522.             status = "Skipping 3 traps";
  523.             traverse(new Position(2992, 5075, 1));
  524.             Time.sleep(random(400, 700));
  525.         } else if (Local.getPosition().equals(new Position(2992, 5075, 1))) {
  526.             status = "Running to stun room";
  527.             Area stunner = Area.rectangular(3000, 5068, 3006, 5066, 1);
  528.             Movement.walkTo(stunner.getTiles().get(random(0, stunner.getTiles().size() - 1)));
  529.             Time.sleepUntil(() -> stunner.contains(Local), 500, 8000);
  530.             Time.sleep(random(200, 500));
  531.         } else if (Area.rectangular(3000, 5068, 3006, 5066, 1).contains(Local)) {
  532.             status = "Picking up powder";
  533.             Pickable stunner = Pickables.getNearest(stun -> stun.getId() == 5559 && stun.getPosition().getY() == 5063);
  534.             if (stunner != null) {
  535.                 stunner.interact("Take");
  536.                 Time.sleepUntil(() -> Inventory.contains(5559), 500, 8000);
  537.                 Time.sleep(random(200, 500));
  538.             }
  539.         } else if (Inventory.contains(5559) && Inventory.getCount(true, 5559) == 5) {
  540.             status = "Stunning guard";
  541.             if (!Inventory.isItemSelected()) {
  542.                 Inventory.getFirst(5559).interact("Use");
  543.                 Time.sleepUntil(Inventory::isItemSelected, 300, 8000);
  544.             }
  545.             if (Inventory.isItemSelected()) {
  546.                 Npc guard = Npcs.getNearest(3191);
  547.                 if (guard != null) {
  548.                     guard.interact("Use");
  549.                     Time.sleepUntil(Local::isAnimating, 500, 8000);
  550.                 }
  551.             }
  552.         } else if (Inventory.contains(5559) && Inventory.getCount(true, 5559) == 4 && !completedMaze) {
  553.             status = "Running past guard";
  554.             Area safeZone = Area.rectangular(3028, 5057, 3030, 5055, 1);
  555.             Movement.walkTo(safeZone.getTiles().get(random(0, safeZone.getTiles().size() - 1)));
  556.             Time.sleepUntil(() -> safeZone.contains(Local), 500, random(1000, 2000));
  557.             Time.sleep(random(200, 500));
  558.             if (safeZone.contains(Local)) {
  559.                 completedMaze = true;
  560.             }
  561.         } else if (completedMaze && Area.rectangular(3028, 5057, 3030, 5055, 1).contains(Local)) {
  562.             status = "Getting through pendulum";
  563.             Movement.walkTo(new Position(3028, 5054, 1));
  564.             Time.sleepUntil(() -> Local.getPosition().equals(new Position(3028, 5051, 1)), 500, 8000);
  565.             Time.sleep(random(200, 500));
  566.         } else if (Local.getPosition().equals(new Position(3028, 5051, 1))) {
  567.             status = "Getting through last pendulum";
  568.             Movement.walkTo(new Position(3028, 5050, 1));
  569.             Time.sleepUntil(() -> Local.getPosition().equals(new Position(3028, 5047, 1)), 500, 8000);
  570.             Time.sleep(random(200, 500));
  571.         } else if (Local.getPosition().equals(new Position(3028, 5047, 1))) {
  572.             SceneObject[] safe = SceneObjects.getLoaded(d -> d.getId() == 7237);
  573.             Log.info("There is currently " + safe.length + " safes available for cracking!");
  574.             SceneObject crack = safe[random(0, safe.length - 1)];
  575.             Log.info("Cracking safe at " + crack.getPosition());
  576.             crack.interact("Crack");
  577.             Time.sleepUntil(Dialog::isViewingChat, 500, 8000);
  578.             Time.sleep(random(200, 500));
  579.         } else {
  580.             if (!Local.isAnimating() && msSinceAnim > lastAnimDelay) {
  581.                 Log.info("WE ARE STUCK!");
  582.                 takeScreenie = true;
  583.                 setStopping(false);
  584.             }
  585.         }
  586.         return random(200, 300);
  587.     }
  588.  
  589.     @Override
  590.     public void notify(RenderEvent renderEvent) {
  591.         int nextThieveLvl = Skills.getExperienceToNextLevel(Skill.THIEVING);
  592.         int nextAgilityLvl = Skills.getExperienceToNextLevel(Skill.AGILITY);
  593.         int gainedThieveXP = Skills.getExperience(Skill.THIEVING) - startThieveXP;
  594.         int gainedAgilityXP = Skills.getExperience(Skill.AGILITY) - startAgilityXP;
  595.         double ttl = (nextThieveLvl / (getPerHour(gainedThieveXP) / 60.0 / 60.0 / 1000.0));
  596.         double ttl2 = (nextAgilityLvl / (getPerHour(gainedAgilityXP) / 60.0 / 60.0 / 1000.0));
  597.         if (gainedAgilityXP == 0) {
  598.             ttl = 0;
  599.             ttl2 = 0;
  600.         }
  601.         Graphics g = renderEvent.getSource();
  602.         Graphics2D g2 = (Graphics2D) g;
  603.         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  604.  
  605.         g2.setColor(new Color(0, 0, 0, 128));
  606.         g2.fillRect(20, 220, 235, 125);
  607.         g2.setColor(Color.WHITE);
  608.         g2.drawRect(20, 220, 235, 125);
  609.  
  610.         int x = 25;
  611.         int y = 235;
  612.         DecimalFormat formatter = new DecimalFormat("#,###.##");
  613.         FontMetrics metrics = g2.getFontMetrics();
  614.  
  615.         String thieveLvlGained = (Skills.getLevelAt(Skills.getExperience(Skill.THIEVING)) - startThieveLvl) > 0 ? " (+" + (Skills.getLevelAt(Skills.getExperience(Skill.HUNTER)) - startThieveLvl) + ")" : "";
  616.         String agilityLvlGained = (Skills.getLevelAt(Skills.getExperience(Skill.AGILITY)) - startAgilitylvl) > 0 ? " (+" + (Skills.getLevelAt(Skills.getExperience(Skill.MAGIC)) - startAgilitylvl) + ")" : "";
  617.         String crateString = rogueCrates == 0 ? "None" : String.valueOf(rogueCrates);
  618.  
  619.         g2.setColor(Color.WHITE);
  620.         g2.drawString("Rogue crates: ", x, y);
  621.         int width = metrics.stringWidth("Rogue crates: ");
  622.         g2.setColor(Color.GREEN);
  623.         g2.drawString(crateString, x + width, y);
  624.  
  625.         g2.setColor(Color.WHITE);
  626.         g2.drawString("Laps: ", x, y += 15);
  627.         width = metrics.stringWidth("Laps: ");
  628.         g2.setColor(Color.YELLOW);
  629.         g2.drawString(formatter.format(maze), x + width, y);
  630.         width = metrics.stringWidth("Laps: " + formatter.format(maze));
  631.         g2.setColor(Color.WHITE);
  632.         g2.drawString(" (" + formatter.format(getPerHour(maze)) + "/hr)", x + width, y);
  633.  
  634.         g2.drawString("Agility lvl: ", x, y += 15);
  635.         g2.setColor(Color.YELLOW);
  636.         width = metrics.stringWidth("Agility lvl: ");
  637.         g2.drawString(Skills.getLevelAt(Skills.getExperience(Skill.AGILITY)) + agilityLvlGained, x + width, y);
  638.         g2.setColor(Color.WHITE);
  639.         width = metrics.stringWidth("Agility lvl: " + Skills.getLevelAt(Skills.getExperience(Skill.AGILITY)) + agilityLvlGained);
  640.         g2.drawString(" (TTL: " + formatTime(Double.valueOf(ttl2).longValue()) + ")", x + width, y);
  641.  
  642.         g2.drawString("XP Gained: ", x, y += 15);
  643.         width = metrics.stringWidth("XP Gained: ");
  644.         g2.setColor(Color.YELLOW);
  645.         g2.drawString(formatter.format(gainedAgilityXP), x + width, y);
  646.         width = metrics.stringWidth("XP Gained: " + formatter.format(gainedAgilityXP));
  647.         g2.setColor(Color.WHITE);
  648.         g2.drawString(" (" + formatter.format(getPerHour(gainedAgilityXP)) + "/hr)", x + width, y);
  649.  
  650.         g2.drawString("Thieving lvl: ", x, y += 15);
  651.         g2.setColor(Color.ORANGE);
  652.         width = metrics.stringWidth("Thieving lvl: ");
  653.         g2.drawString(Skills.getLevelAt(Skills.getExperience(Skill.THIEVING)) + thieveLvlGained, x + width, y);
  654.         g2.setColor(Color.WHITE);
  655.         width = metrics.stringWidth("Thieving lvl: " + Skills.getLevelAt(Skills.getExperience(Skill.THIEVING)) + thieveLvlGained);
  656.         g2.drawString(" (TTL: " + formatTime(Double.valueOf(ttl).longValue()) + ")", x + width, y);
  657.  
  658.         g2.drawString("XP Gained: ", x, y += 15);
  659.         width = metrics.stringWidth("XP Gained: ");
  660.         g2.setColor(Color.YELLOW);
  661.         g2.drawString(formatter.format(gainedThieveXP), x + width, y);
  662.         width = metrics.stringWidth("XP Gained: " + formatter.format(gainedThieveXP));
  663.         g2.setColor(Color.WHITE);
  664.         g2.drawString(" (" + formatter.format(getPerHour(gainedThieveXP)) + "/hr)", x + width, y);
  665.  
  666.         g2.setColor(Color.WHITE);
  667.         g2.drawString("Elapsed Time: ", x, y += 15);
  668.         width = metrics.stringWidth("Elapsed Time: ");
  669.         g2.setColor(Color.PINK);
  670.         g2.drawString(formatTime(System.currentTimeMillis() - startTime), x + width, y);
  671.  
  672.         g2.setColor(Color.WHITE);
  673.         g2.drawString("Status: ", x, y += 15);
  674.         width = metrics.stringWidth("Status: ");
  675.         g2.setColor(Color.YELLOW);
  676.         g2.drawString(status, x + width, y);
  677.  
  678.  
  679.         //Hide username
  680.         if (Players.getLocal() != null) {
  681.             Color tanColor = new Color(204, 187, 154);
  682.             g2.setColor(tanColor);
  683.             g2.fillRect(9, 459, 91, 15);
  684.         }
  685.  
  686.         if (takeScreenie) {
  687.             TakeScreenshot(renderEvent.getProvider().getImage());
  688.             takeScreenie = false;
  689.         }
  690.     }
  691.  
  692.     @Override
  693.     public void notify(ChatMessageEvent event) {
  694.         String m = event.getMessage().toLowerCase();
  695.         if (event.getType().equals(ChatMessageType.FILTERED)) {
  696.             if (m.endsWith("cracking the safe."))
  697.                 maze++;
  698.             if (m.endsWith("crate of equipment."))
  699.                 rogueCrates++;
  700.         }
  701.     }
  702.  
  703.     @Override
  704.     public void onStop() {
  705.         Log.info("Hope you had fun at Rogues Den! Gained " + (Skills.getExperience(Skill.THIEVING) - startThieveXP) + " thieving experience and " + (Skills.getExperience(Skill.AGILITY) - startAgilityXP) + " agility experience this session. We also completed the maze " + maze + "x");
  706.     }
  707.  
  708.     private int random(int min, int max) {
  709.         SecureRandom random = new SecureRandom();
  710.         return (random.nextInt(max - min + 1) + min);
  711.     }
  712.  
  713.     private void traverse(Position pos) {
  714.         Movement.walkTo(pos);
  715.         Time.sleepUntil(() -> Players.getLocal().getPosition().equals(pos), 500, 5000);
  716.     }
  717.  
  718.  
  719.     private void TakeScreenshot(Image img) {
  720.         Log.info("Attempting to take a screenshot");
  721.         BufferedImage buffered = (BufferedImage) img;
  722.  
  723.         //Get the current date to save in the screenshot folder
  724.         long now = Instant.now().getEpochSecond();
  725.  
  726.         try {
  727.             //Create a folder with my forum name to tell the user which script created this folder
  728.             if (!new File(getDataDirectory() + "\\ikiddoi\\Rogue\\Screenshots").exists()) {
  729.                 new File(getDataDirectory() + "\\ikiddoi\\Rogue\\Screenshots").mkdirs();
  730.             }
  731.             //save the image to the folder and rename all player spaces with underscores
  732.             try {
  733.                 if (ImageIO.write(
  734.                         buffered,
  735.                         "png",
  736.                         new File(getDataDirectory() + "\\ikiddoi\\Rogue\\Screenshots\\" + now + "-" + Players.getLocal().getName().replaceAll("\\u00a0", "_") + ".png"))) {
  737.                     Log.info("Saved " + getDataDirectory() + "\\ikiddoi\\Rogue\\Screenshots\\" + now + "-" + Players.getLocal().getName().replaceAll("\\u00a0", "_") + ".png");
  738.                 }
  739.             } catch (IOException e) {
  740.                 Log.info("Error! " + e.getMessage());
  741.             }
  742.         } catch (Exception e) {
  743.             Log.info("Error! " + e.getMessage());
  744.         }
  745.     }
  746.  
  747.     private void forceRun() {
  748.         if (!Movement.isRunEnabled())
  749.             Movement.toggleRun(true);
  750.     }
  751.  
  752.     private void forceWalk() {
  753.         if (Movement.isRunEnabled())
  754.             Movement.toggleRun(false);
  755.     }
  756.  
  757.     private String formatTime(final long ms) {
  758.         long s = ms / 1000, m = s / 60, h = m / 60;
  759.         s %= 60;
  760.         m %= 60;
  761.         h %= 24;
  762.         return String.format("%02d:%02d:%02d", h, m, s);
  763.     }
  764.  
  765.     private double getPerHour(double value) {
  766.         if ((System.currentTimeMillis() - startTime) > 0) {
  767.             return value * 3600000d / (System.currentTimeMillis() - startTime);
  768.         } else {
  769.             return 0;
  770.         }
  771.     }
  772. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top