Advertisement
Guest User

Darks POH Curser v 0.8

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