Advertisement
Guest User

Darks POH Curser V0.85

a guest
Jul 26th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 19.48 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.Image;
  7. import java.awt.Point;
  8. import java.awt.Polygon;
  9. import java.io.IOException;
  10. import java.net.MalformedURLException;
  11. import java.net.URL;
  12. import java.util.Arrays;
  13.  
  14. import javax.imageio.ImageIO;
  15. import javax.swing.JOptionPane;
  16.  
  17. import org.Magic;
  18. import org.RSArea;
  19. import org.SPELL;
  20. import org.tribot.api2007.NPCChat;
  21. import org.tribot.api.General;
  22. import org.tribot.api.Timing;
  23. import org.tribot.api.input.Keyboard;
  24. import org.tribot.api.input.Mouse;
  25. import org.tribot.api.types.generic.Condition;
  26. import org.tribot.api2007.Camera;
  27. import org.tribot.api2007.Game;
  28. import org.tribot.api2007.GameTab;
  29. import org.tribot.api2007.GameTab.TABS;
  30. import org.tribot.api2007.ChooseOption;
  31. import org.tribot.api2007.Interfaces;
  32. import org.tribot.api2007.Inventory;
  33. import org.tribot.api2007.Login;
  34. import org.tribot.api2007.Objects;
  35. import org.tribot.api2007.Player;
  36. import org.tribot.api2007.Players;
  37. import org.tribot.api2007.Projection;
  38. import org.tribot.api2007.Skills;
  39. import org.tribot.api2007.Walking;
  40. import org.tribot.api2007.types.RSItem;
  41. import org.tribot.api2007.types.RSModel;
  42. import org.tribot.api2007.types.RSObject;
  43. import org.tribot.api2007.types.RSPlayer;
  44. import org.tribot.api2007.types.RSTile;
  45. import org.tribot.script.Script;
  46. import org.tribot.script.ScriptManifest;
  47. import org.tribot.script.interfaces.Ending;
  48. import org.tribot.script.interfaces.Painting;
  49. @ScriptManifest(authors = { "Dark" }, description = "The Requirements are lvl 19 magic and a POH in the same location as the Host.", category = "Magic", name = "Dark's POH Curser")
  50. public class Darks_POH_Curser extends Script implements Painting, Ending{
  51.     enum STATE {
  52.         STARTING, OPENING_DOOR, CREATING_COMBAT_RING_AREA, WALKING_TO_RING, GETTING_IN_RING, CURSING_PLAYER, OUTSIDE_HOUSE, LOGGING_OUT, FAILSAFE, ERROR, LOADING_HOUSE;
  53.     }
  54.    
  55.     private Image paint = getImage("http://puu.sh/3MmcB.png");
  56.     //http://puu.sh/3L453.png
  57.     private boolean started = false;
  58.     private RSArea combatRingArea;
  59.     private RSArea currentDoorArea;
  60.     private RSObject currentDoor;
  61.     private RSTile maxTile;
  62.     private RSTile minTile;
  63.     private String debug = "DEBUG HERE";
  64.     private RSObject[] combatRing;
  65.     private RSObject combatRingRope;
  66.     private STATE currentState;
  67.     private String state;
  68.     private String playerName = "";
  69.     public long startTime = 0;
  70.     public long millis = 0;
  71.     public long hours = 0;
  72.     public long minutes = 0;
  73.     public long seconds = 0;
  74.     public long last = 0;
  75.     public int expGained = 0;
  76.     public int expPerHour = 0;
  77.     private final int startXp = Skills.getXP("MAGIC");
  78.     public int expToLevel;
  79.     public int curseTNL;
  80.     public int curseCount;
  81.     public int startLevel;
  82.     public int currentLevel;
  83.     public int levelsGained;
  84.     // public final int startHealth = Player.getRSPlayer().getHealth();
  85.     public long sTNL;
  86.     public long mTNL;
  87.     public long hTNL;
  88.     private boolean isDoorOpen = false;
  89.     private boolean isYourHouse = true;
  90.     public static final int COMBAT_RING_ROPE = 13137;
  91.     public static final int POH_TAB = 8013;
  92.     public static final int PORTAL = 15478;
  93.     public static final int[] INHOME_PORTAL = {4525,13405};
  94.     // DEBUG
  95.     RSModel currentModel;
  96.     private int countPerHour;
  97.     private boolean usedTab = false;
  98.     private boolean failsafe = false;
  99.  
  100.     @Override
  101.     public void run() {
  102.  
  103.         while (true) {
  104.             currentState = getState();
  105.             switch (currentState) {
  106.             case CURSING_PLAYER:
  107.                 cursePlayer();
  108.                 break;
  109.             case GETTING_IN_RING:
  110.                 getInRing();
  111.                 break;
  112.             case OUTSIDE_HOUSE:
  113.                 getBackIntoHouse();
  114.                 break;
  115.             case STARTING:
  116.                 onStart();
  117.                 break;
  118.             case WALKING_TO_RING:
  119.                 walkToRing();
  120.                 break;
  121.             case OPENING_DOOR:
  122.                 while(!isDoorOpen){
  123.                     sleep(186,250);
  124.                 }
  125.                 break;
  126.             case CREATING_COMBAT_RING_AREA:
  127.                 while(combatRingArea == null){
  128.                     sleep(186,250);
  129.                 }
  130.                 break;
  131.             case LOGGING_OUT:
  132.                 Login.logout();
  133.                 this.stopScript();
  134.                 break;
  135.             case FAILSAFE:
  136.                 failSafe();
  137.                 break;
  138.             case LOADING_HOUSE:
  139.                 Timing.waitCondition(new Condition(){
  140.                     @Override
  141.                     public boolean active() {
  142.                        return Interfaces.get(399, 1) == null;
  143.                     }
  144.                 },2500);break;
  145.             default:
  146.                 break;
  147.  
  148.             }
  149.         }
  150.  
  151.     }
  152.  
  153.     public boolean openDoor() {
  154.         debug = " GETTING DOOR...";
  155.         if (getDoor() == null) {
  156.             isDoorOpen = true;
  157.         }
  158.         if (!isDoorOpen && currentDoor == null) {
  159.             currentDoor = getDoor();
  160.             currentModel = currentDoor.getModel();
  161.             currentDoorArea = RSArea.createRSArea(currentDoor.getPosition(), 1);
  162.         } else {
  163.             if (!isDoorOpen) {
  164.                 clickModel(currentModel,"",false);
  165.             }
  166.             debug = " DEBUG:IS Door Open? " + isDoorOpen;
  167.             sleep(750);
  168.  
  169.             return isDoorOpen;
  170.         }
  171.         /**
  172.          * if(Walking.blindWalkTo(currentDoorArea.getMaxTile())){
  173.          * currentDoor.click();
  174.          * while(Game.getDestination().distanceTo(Player.getPosition())!=0){
  175.          * Walking.blindWalkTo(currentDoorArea.getMaxTile());
  176.          * currentDoor.click(); return; } }
  177.          */
  178.         return isDoorOpen;
  179.     }
  180.  
  181.     private RSObject getDoor() {
  182.         debug = " GETTING DOOR OBJECT...";
  183.         // First part checks to see if door is open.
  184.         if (isDoorOpen && currentDoor != null) {
  185.             return currentDoor;
  186.         }
  187.         if (!isDoorOpen) {
  188.             debug = " DOOR ISNT OPEN!";
  189.             for (RSObject o : Objects.findNearest(15, 13100)) {
  190.                 debug = " Found Something";
  191.                 if (o != null) {
  192.                     debug = " It's not Null "
  193.                             + (combatRingArea.getDistanceFrom(o.getPosition()) < 15);
  194.                     if (combatRingArea.getDistanceFrom(o.getPosition()) < 8) {
  195.                         debug = " It's on screen and less than 8 tiles away from ring.";
  196.                         if (Player.getPosition().distanceTo(o.getPosition()) <= 4) {
  197.                             debug = " It's less than 5 tiles away from me.";
  198.                             currentDoorArea = RSArea.createRSArea(
  199.                                     o.getPosition(), 1);
  200.                             debug = " Distance To Area: "
  201.                                     + currentDoorArea.getDistanceFrom(Player
  202.                                             .getPosition());
  203.                             debug = "MAX TILE?: ";// +currentDoorArea.getMaxTile().toString();
  204.                             return o;
  205.  
  206.                         }
  207.                     }
  208.                 }
  209.             }
  210.         }
  211.         return null;
  212.     }
  213.  
  214.     /**
  215.      * This Method will use a tele tab to get back to their house, then if it
  216.      * isn't their house it will leave their house and hand over control back to
  217.      * the script. The script will continue on. Otherwise it will just continue
  218.      * on after it is back in their house.If you have no tele tabs it will log
  219.      * out and end the script.
  220.      */
  221.     private boolean failSafe() {
  222.         failsafe = true;
  223.     if(!usedTab){
  224.         if(useTeleTab()){
  225.             usedTab = true;
  226.         if (!isYourHouse) {
  227.             sleep(1000,1500);
  228.             Timing.waitCondition(new Condition(){
  229.                 @Override
  230.                 public boolean active() {
  231.                    return Interfaces.get(399, 1) == null;
  232.                 }
  233.             },2500);
  234.             sleep(1000,1500);
  235.          if(getNearestObject(INHOME_PORTAL, 25) !=null)
  236.             Timing.waitCondition(new Condition() {
  237.                 @Override
  238.                 public boolean active() {
  239.                     return getNearestObject("Portal", 25).click("Enter");
  240.                 }
  241.             }, 650);
  242.              failsafe = false;
  243.             return true;
  244.         }
  245.     }
  246.     }
  247.         failsafe = false;
  248.         return usedTab;
  249.     }
  250.  
  251.     private boolean useTeleTab() {
  252.         if (Inventory.getCount(POH_TAB) > 0) {
  253.             Timing.waitCondition(new Condition() {
  254.                 @Override
  255.                 public boolean active() {
  256.                     return Inventory.find(POH_TAB)[0].hover();
  257.                 }
  258.             }, 650);
  259.              RSItem i=Inventory.find(POH_TAB)[0];
  260.             int x = (int)i.getArea().getCenterX();
  261.             int y = (int)i.getArea().getCenterY();
  262.             Mouse.click(x, y, 3);
  263.             ChooseOption.select("Break");
  264.             General.println("USED TAB");
  265.             Timing.waitCondition(new Condition(){
  266.                 @Override
  267.                 public boolean active() {
  268.                    return Interfaces.get(399, 1) != null;
  269.                 }
  270.             },2500);
  271.             Timing.waitCondition(new Condition() {
  272.                 @Override
  273.                 // Sleep while That interface is up.
  274.                 public boolean active() {
  275.                     return Interfaces.get(399, 1) == null;
  276.                 }
  277.             }, 4500);
  278.             usedTab = false;
  279.             return true; // Return true after your player is at their house.
  280.         } else if (Inventory.getCount(POH_TAB) == 0) {
  281.             General.println("You were lost or lured away or something happened, and you had no tele tabs so this script logged you out and ended.");
  282.             Login.logout();
  283.             stopScript();
  284.             // If you have no tabs it will stop the script.
  285.             // So really this method can only return true.
  286.         }
  287.         return false;
  288.     }
  289.  
  290.     private boolean hasRunes() {
  291.         return Inventory.getCount(559) > 0;
  292.     }
  293.  
  294.     private void cursePlayer() {
  295.  
  296.         for (final RSPlayer p : Players.getAll()) {
  297.             if (p == null) {
  298.                 break;
  299.             }
  300.             if (p.getName() != Player.getRSPlayer().getName()) {
  301.                 if (GameTab.getOpen() != TABS.MAGIC) {
  302.                     GameTab.open(TABS.MAGIC);
  303.                 }
  304.                 while (hasRunes() && p.isOnScreen()
  305.                         && combatRingArea.isInArea(p.getPosition())
  306.                         && combatRingArea.isInArea(Player.getPosition())) {
  307.                     if (Magic.cast(SPELL.CURSE)) {
  308.                         curseCount++;
  309.                         Camera.turnToTile(p.getPosition());
  310.                         currentModel = p.getModel();
  311.                         Timing.waitCondition(new Condition() {
  312.                             @Override
  313.                             public boolean active() {
  314.                                 return p.click();
  315.                             }
  316.                         }, 650);
  317.                     }
  318.                 }
  319.             }
  320.         }
  321.     }
  322.  
  323.     private void getBackIntoHouse() {
  324.         currentDoorArea = null;
  325.         if (isYourHouse) {
  326.             if (Objects.findNearest(20, PORTAL).length > 0) {
  327.                 currentModel = Objects.findNearest(20, PORTAL)[0].getModel();
  328.                 if (clickModel(currentModel, "Enter", true)) {
  329.                     if (NPCChat.selectOption("Go to your house", true)) {
  330.                         currentModel = null;
  331.                         Timing.waitCondition(new Condition() {
  332.                             @Override
  333.                             public boolean active() {
  334.                                 return Interfaces.get(399, 1) == null;
  335.                             }
  336.                         }, 3500);
  337.                     }
  338.                 }
  339.             }
  340.         } else {
  341.             if (Objects.findNearest(20, PORTAL).length > 0) {
  342.                 currentModel = Objects.findNearest(20, PORTAL)[0].getModel();
  343.                 if (clickModel(currentModel, "Enter", true)) {
  344.                     if (NPCChat.selectOption("Go to a friend's house", true)) {
  345.                         typeString(playerName);
  346.                         currentModel = null;
  347.                         Timing.waitCondition(new Condition() {
  348.                             @Override
  349.                             public boolean active() {
  350.                                 return Interfaces.get(399, 1) == null;
  351.                             }
  352.                         }, 3500);
  353.                     }
  354.                 }
  355.             }
  356.         }
  357.  
  358.     }
  359.  
  360.     private void getInRing() {
  361.         if (combatRingRope == null) {
  362.             combatRingRope = Objects.find(50, COMBAT_RING_ROPE)[General.random(0,Objects.find(50, COMBAT_RING_ROPE).length-1)];
  363.         }
  364.         else{
  365.         currentModel = combatRingRope.getModel();
  366.         clickModel(currentModel, "", false);
  367.         Timing.waitCondition(new Condition() {
  368.             @Override
  369.             public boolean active() {
  370.                 return Player.getAnimation() == -1;
  371.             }
  372.         }, 800);}
  373.         currentDoorArea = null;
  374.         currentDoor = null;
  375.         currentModel = null;
  376.         return;
  377.     }
  378.  
  379.     private STATE getState() {
  380.         if (!started) {
  381.             return STATE.STARTING;
  382.         }
  383.         if(Interfaces.get(399, 1) != null){
  384.             return STATE.LOADING_HOUSE;
  385.         }
  386.         if (!failsafe&&!isInsideHouse() && Objects.findNearest(20, PORTAL).length == 0) {
  387.             return STATE.FAILSAFE;
  388.         }
  389.         if (!hasRunes()) {
  390.             return STATE.LOGGING_OUT;
  391.         }
  392.         if (!failsafe&&isInsideHouse() && combatRingArea == null
  393.                 && determineCombatRingArea()) {
  394.             return STATE.CREATING_COMBAT_RING_AREA;
  395.         }
  396.         if (!failsafe&&isInsideHouse() && !isDoorOpen) {
  397.             if (combatRingArea != null
  398.                     && combatRingArea.isInArea(Player.getPosition())) {
  399.                 return STATE.CURSING_PLAYER;
  400.             } else if (openDoor()) {
  401.                 return STATE.OPENING_DOOR;
  402.             }
  403.         }
  404.         if (!failsafe&&isInsideHouse() &&combatRingArea != null&& !combatRingArea.isInArea(Player.getPosition())) {
  405.             if (combatRingArea.getDistanceFrom(Player.getPosition()) > 2) {
  406.                 return STATE.WALKING_TO_RING;
  407.             }
  408.             return STATE.GETTING_IN_RING;
  409.         }
  410.         if (!failsafe&&isInsideHouse() && combatRingArea != null
  411.                 && combatRingArea.isInArea(Player.getPosition())) {
  412.             return STATE.CURSING_PLAYER;
  413.         }
  414.         if (getNearestObject(PORTAL,35) != null) {
  415.             return STATE.OUTSIDE_HOUSE;
  416.         }
  417.         return STATE.ERROR;
  418.     }
  419.  
  420.     private void walkToRing() {
  421.         if (isDoorOpen) {
  422.             if (combatRingRope == null) {
  423.                 combatRingRope = Objects.find(50, COMBAT_RING_ROPE)[General.random(0,Objects.find(50, COMBAT_RING_ROPE).length-1)];
  424.             }
  425.             Walking.walkTo(combatRingRope.getPosition());
  426.             while (Player.isMoving()) {
  427.                 Camera.turnToTile(combatRingRope.getPosition());
  428.             }
  429.         } else {
  430.             if (combatRingArea.getDistanceFrom(Player.getPosition()) > 8) {
  431.                 openDoor();
  432.             }
  433.         }
  434.     }
  435.  
  436.     private boolean isInsideHouse() {
  437.         return Objects.find(25, INHOME_PORTAL) != null
  438.                 && Objects.find(25, INHOME_PORTAL).length > 0;
  439.     }
  440.  
  441.     private void onStart() {
  442.         // currentState = STATE.STARTING;
  443.         startTime = System.currentTimeMillis();
  444.         startLevel = Skills.getActualLevel("MAGIC");
  445.         playerName += JOptionPane.showInputDialog(
  446.                 "Enter Player's name if it's not your house. Otherwise hit enter.", Player
  447.                         .getRSPlayer().getName());
  448.         if (!Player.getRSPlayer().getName().equalsIgnoreCase(playerName)) {
  449.             isYourHouse = false;
  450.             General.println("This isn't your house@");
  451.         }
  452.         if(playerName.length() >1){
  453.             started = true;
  454.         }
  455.     }
  456.  
  457.     @Override
  458.     public void onPaint(Graphics g) {
  459.         // MATH
  460.         millis = System.currentTimeMillis() - startTime;
  461.         hours = millis / (1000 * 60 * 60);
  462.         millis -= hours * (1000 * 60 * 60);
  463.         minutes = millis / (1000 * 60);
  464.         millis -= minutes * (1000 * 60);
  465.         seconds = millis / 1000;
  466.         int CurrentExp = Skills.getXP("Magic");
  467.         curseCount = (CurrentExp - startXp) / 29;
  468.         countPerHour = (int) ((curseCount) * 3600000D / (System
  469.                 .currentTimeMillis() - startTime));
  470.         expPerHour = (int) ((expGained) * 3600000D / (System
  471.                 .currentTimeMillis() - startTime));
  472.         expGained = Skills.getXP("MAGIC") - startXp;
  473.         curseTNL = Skills.getXPToLevel("MAGIC", currentLevel + 1) / 29;
  474.         currentLevel = Skills.getCurrentLevel("MAGIC");
  475.         levelsGained = currentLevel - startLevel;
  476.         expToLevel = Skills.getXPToNextLevel("MAGIC");
  477.         // DEBUG
  478.         if (currentModel != null) {
  479.             paintRSModel(g, currentModel);
  480.         }
  481.         if (currentDoorArea != null) {
  482.             currentDoorArea.paintRSArea(g);
  483.         }
  484.         if (combatRingArea != null) {
  485.             combatRingArea.paintRSArea(g);
  486.             g.drawString(debug, 250, 300);
  487.         }
  488.  
  489.         g.drawString(debug, 250, 300);
  490.  
  491.         if (minTile != null && maxTile != null) {
  492.             g.setColor(Color.RED);
  493.             drawTile(minTile, (Graphics2D) g, false);
  494.             drawTile(maxTile, (Graphics2D) g, false);
  495.  
  496.         }
  497.         g.setColor(Color.BLUE);
  498.         drawTile(Player.getPosition(), (Graphics2D) g, false);
  499.         g.setColor(Color.ORANGE);
  500.         if (Game.getDestination() != null) {
  501.             drawTile(Game.getDestination(), (Graphics2D) g, false);
  502.         }
  503.         // ACTUAL Paint - old y 300
  504.         g.drawImage(paint, 0, 225, null);
  505.         // Status
  506.         g.setColor(Color.WHITE);
  507.         if (currentState != null) {
  508.             state = currentState.toString();
  509.             g.drawString(state, 300, 375);
  510.         }
  511.         // Time
  512.         g.drawString(hours + ":" + minutes + ":" + seconds, 418, 400);
  513.         g.drawString(formatTime(millis / curseTNL), 381, 415);
  514.         // Level
  515.         g.drawString(currentLevel + " (" + levelsGained + ")", 390, 435);
  516.         // XP
  517.         g.drawString("" + expGained, 430, 452);
  518.         g.drawString("" + expPerHour, 400, 470);
  519.  
  520.     }
  521.  
  522.     private boolean determineCombatRingArea() {
  523.         if (getNearestObject("Combat ring", 50) != null) {
  524.             int[] xCoords;
  525.             int[] yCoords;
  526.             combatRing = Objects.find(50, "Combat ring");
  527.             xCoords = new int[combatRing.length];
  528.             yCoords = new int[combatRing.length];
  529.             for (int x = 0; x <= combatRing.length - 1; x++) {
  530.                     RSTile pos = combatRing[x].getPosition();
  531.                     xCoords[x] = pos.getX();
  532.                     yCoords[x] = pos.getY();
  533.             }
  534.            
  535.             Arrays.sort(xCoords);
  536.             Arrays.sort(yCoords);
  537.             minTile = new RSTile(xCoords[8], yCoords[8]);
  538.             maxTile = new RSTile(xCoords[xCoords.length - 8],
  539.                             yCoords[yCoords.length - 8]);
  540.            
  541.                            
  542.            
  543.             combatRingArea = new RSArea(minTile, maxTile);
  544.            
  545.             return true;
  546.     } else {
  547.            
  548.     }
  549.     return false;
  550.     }
  551.  
  552.     public void createDoorArea() {
  553.         if (currentDoor != null && currentDoorArea == null) {
  554.             int x = currentDoor.getPosition().getX();
  555.             int y = currentDoor.getPosition().getY();
  556.             currentDoorArea = new RSArea(x - 1, y + 1, x + 1, y - 1);
  557.         }
  558.     }
  559.  
  560.     private void drawTile(RSTile tile, Graphics2D g, boolean fill) {
  561.         if (tile.isOnScreen()) {
  562.             if (fill) {
  563.                 g.fillPolygon(Projection.getTileBoundsPoly(tile, 0));
  564.             } else {
  565.                 g.drawPolygon(Projection.getTileBoundsPoly(tile, 0));
  566.             }
  567.         }
  568.     }
  569.  
  570.     private Image getImage(String url) {
  571.         try {
  572.             return ImageIO.read(new URL(url));
  573.         } catch (MalformedURLException e) {
  574.         } catch (IOException e) {
  575.         }
  576.         return null;
  577.     }
  578.  
  579.     private RSObject getNearestObject(String id, int dist) {
  580.         for (RSObject o : Objects.find(dist, id)) {
  581.             if (o != null) {
  582.                 return o;
  583.             }
  584.         }
  585.         return null;
  586.     }
  587.  
  588.     private RSObject getNearestObject(int id, int dist) {
  589.         for (RSObject o : Objects.find(dist, id)) {
  590.             if (o != null) {
  591.                 return o;
  592.             }
  593.         }
  594.         return null;
  595.     }
  596.  
  597.     private Object getNearestObject(int[] inhomePortal, int dist) {
  598.         for(RSObject o : Objects.find(dist, INHOME_PORTAL)){
  599.             if(o != null){
  600.                 return o;
  601.             }
  602.         }
  603.         return null;
  604.     }
  605.  
  606.     public Point getBestPoint(Point[] points) {
  607.         int sumX = 0, sumY = 0;
  608.         int averageX, averageY;
  609.         int count = 0;
  610.  
  611.         for (Point p : points) {
  612.             sumX += p.getX();
  613.             sumY += p.getY();
  614.             count++;
  615.         }
  616.         averageX = sumX / count;
  617.         averageY = sumY / count;
  618.         return averageX > 0 && averageY > 0 ? new Point(averageX, averageY)
  619.                 : null;
  620.     }
  621.  
  622.     public boolean clickModel(RSModel model, String option, boolean rightClick) {
  623.         Camera.turnToTile(model.getAnimableTile());
  624.         Camera.setCameraAngle(General.random(60,70));
  625.         Point[] points = model.getAllVisiblePoints();
  626.         int length = points.length;
  627.         if (length != 0) {
  628.             Point p = getBestPoint(points);
  629.             Mouse.move(p);
  630.             {
  631.                 String top = Game.getUptext();
  632.                 if (top.contains(option)) {
  633.                     Mouse.click(p, 0);
  634.                      while(Player.isMoving()){
  635.                          sleep(200,250);
  636.                      }
  637.                     return true;
  638.                 } else if (rightClick) {
  639.                     Mouse.click(3);
  640.                     Timing.waitChooseOption(option,1300);
  641.                     if (!ChooseOption.isOpen())
  642.                         return false;
  643.                     if (ChooseOption.select(option))
  644.                         return true;
  645.                 }
  646.             }
  647.         }
  648.         return false;
  649.     }
  650.  
  651.     public void paintRSModel(Graphics g, RSModel m) {
  652.         g.setColor(Color.GREEN);
  653.         for (Polygon p : m.getTriangles()) {
  654.             g.drawPolygon(p);
  655.         }
  656.     }
  657.  
  658.     private boolean typeString(final String s) {       
  659.         if (s.length() > 0) {
  660.            
  661.             Timing.waitCondition(new Condition() {
  662.                 @Override
  663.                 public boolean active() {
  664.                     return Interfaces.get(548, 94) != null;
  665.                 }
  666.             }, 3000);
  667.             sleep(924,1250);
  668.             Keyboard.typeString(s);
  669.             Timing.waitCondition(new Condition() {
  670.                 @Override
  671.                 public boolean active() {
  672.                     return Interfaces.get(548, 94) != null&&Interfaces.get(548, 94).getText().equals(playerName);
  673.                 }
  674.             }, 3000);
  675.             Keyboard.pressEnter();
  676.             General.println("SENT :"+playerName);
  677.            
  678.             return true;
  679.         }
  680.        
  681.         return false;
  682.     }
  683.  
  684.     private String formatTime(long time) {
  685.         return (time / (1000 * 60 * 60) + ":" + (time / (1000 * 60)) + ":" + (time / 1000));
  686.     }
  687.  
  688.     @Override
  689.     public void onEnd() {
  690.         String output = "Script Ended....."+"\n"
  691.                          +"::Script Stats::"
  692.                          +"\n"+"Time Ran : "+formatTime(System.currentTimeMillis() - startTime)+"\n"
  693.                          +"XP Gained : "+expGained+"\n"
  694.                          +"Xp/Hr: "+expPerHour;
  695.         General.println(output);
  696.     }
  697.  
  698. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement