Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 25.50 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3.  
  4. import org.rsbot.event.events.ServerMessageEvent;
  5. import org.rsbot.event.listeners.PaintListener;
  6. import org.rsbot.event.listeners.ServerMessageListener;
  7. import org.rsbot.script.Script;
  8.  
  9. import org.rsbot.script.ScriptManifest;
  10.  
  11. import java.util.Map; //import java.util.Timer;
  12. //import java.util.TimerTask;
  13.  
  14. import org.rsbot.script.wrappers.RSNPC;
  15.  
  16. import org.rsbot.script.wrappers.RSTile;
  17.  
  18. @ScriptManifest(authors = { "Alden" },
  19.         category = "Money",
  20.         name = "aRuneSuduko",
  21.         version = 1.7,
  22.         description = "<html><body>" +
  23.                 "<B>Rune Suduko Solver </B>By Alden<br>" +
  24.                 "<b>What do to: </b>" +
  25.                 "<p>Have no break handler<br>" +
  26.                 "<p>If it is not working, upen up a suduko puzzle manually and then run the script.<br>" +
  27.                 "<p>The minimum amound of money is 70k, but the more money you have, the more money you make.<br>" +
  28.                 "" +
  29.                 "</body></html>")
  30. public class aRuneSudoku extends Script implements PaintListener,
  31.         ServerMessageListener {
  32.     // Variables
  33.     private int naturePrice;
  34.     private int cosmicPrice;
  35.     private int bloodPrice;
  36.     private int deathPrice;
  37.     private int chaosPrice;
  38.     private int mindPrice;//231 3
  39.     private int soulPrice;
  40.     private int bodyPrice;
  41.     private int lawPrice;
  42.  
  43.     private int natureInvID = 561;//
  44.     private int cosmicInvID = 564;//
  45.     private int bloodInvID = 565;//
  46.     private int deathInvID = 560;//
  47.     private int chaosInvID = 562;//
  48.     private int mindInvID = 558;//
  49.     private int soulInvID = 566;//
  50.     private int bodyInvID = 559;//
  51.     private int lawInvID = 563;//
  52.  
  53.     private int profit = 0;
  54.     private int startMoney = 0;
  55.     private int startCash = 0;
  56.     private int startRunes = 0;
  57.  
  58.     private int currentMoney = 0;
  59.     private int currentCash = 0;
  60.     private int currentRunes = 0;
  61.  
  62.     private int solved = 0;
  63.     private int failed = 0;
  64.  
  65.     // Mouse speed
  66.     boolean messedUp = false;
  67.     boolean sudokuOpen = false;
  68.     boolean sudokuSolved = false;
  69.     boolean talked = false;
  70.  
  71.     private int[][] sudokuGrid = new int[9][9];
  72.  
  73.     private int mindID = 8982; // 1 205
  74.     private int fireID = 8980; // 2 206
  75.     private int airID = 8975; // 3 204
  76.     private int waterID = 8987; // 4 203
  77.     private int earthID = 8979; // 5 202
  78.     private int bodyID = 8976; // 6 207
  79.     private int deathID = 8978; // 7 208
  80.     private int chaosID = 8977;// 8 209
  81.     private int lawID = 8981; // 9 210
  82.  
  83.     long scriptStartTIME = 0;
  84.  
  85.     // Npcs
  86.     int aliID = 1862;
  87.  
  88.     // Items
  89.     int moneyID = 995;
  90.  
  91.     // Objects
  92.  
  93.     // Areas
  94.     private final int[] aliArea = { 3300, 3208, 3308, 3214 };
  95.     private RSTile aliTile = new RSTile(3305, 3211);
  96.  
  97.     // walk
  98.  
  99.     private enum State {
  100.         buyRunes, openSudoku, doSudoku, toAli, end, error;
  101.     }
  102.  
  103.         int mSpeed = 1;
  104.         @Override
  105.         protected int getMouseSpeed() {
  106.                 return mSpeed;
  107.         }
  108.  
  109.  
  110.         @Override
  111.         public void clickMouse(final int x, final int y, final int width,
  112.                         final int height, final boolean leftClick) {
  113.                 moveMouse(x, y, width, height);
  114.                 wait(random(20, 50));
  115.                 clickMouse(leftClick, 0);
  116.         }
  117.         @Override
  118.         public void clickMouse(final boolean leftClick, final int moveAfterDist) {
  119.                 input.clickMouse(leftClick);
  120.         }
  121.  
  122.         public boolean setMouseSpeed(int mouseSpeed) {
  123.                 mSpeed=mouseSpeed;
  124.                 getMouseSpeed();
  125.                 return true;
  126.         }
  127.  
  128.  
  129.  
  130.     private State getState() {
  131.         try {
  132.             if (inArea(aliArea)) {
  133.                 if (getInventoryCount(moneyID) < 70000) {
  134.                     return State.end;
  135.                 }
  136.                 if (getInventoryCount(moneyID) >= 70000) {
  137.                     if (sudokuOpen == false) {
  138.                         sudokuSolved = false;
  139.                         if (getInterface(228).getChild(2).containsText(
  140.                                 "Buy all")) {
  141.                             return State.buyRunes;
  142.                         }
  143.                         if (!getInterface(228).getChild(2).containsText(
  144.                                 "Buy all")) {
  145.                             return State.openSudoku;
  146.                         }
  147.                     }
  148.                     if (sudokuOpen == true) {
  149.                         return State.doSudoku;
  150.                     }
  151.                 }
  152.             }
  153.             if (!inArea(aliArea)) {
  154.                 return State.toAli;
  155.             }
  156.  
  157.         } catch (Exception e) {
  158.         }
  159.         return State.error;
  160.     }
  161.  
  162.     @Override
  163.     public int loop() {
  164.         // log("started");
  165.         // log("startMoney = "+startMoney);
  166.         // log("startCash = "+startCash);
  167.         // log("startRunes = "+startRunes);
  168.  
  169.         // log("currentMoney = "+currentMoney);
  170.         // log("currentCash = "+currentCash);
  171.         // log("currentRunes = "+currentRunes);
  172.  
  173.       //  log("profit = " + profit);
  174.  
  175.         if (getInterface(288).getChild(9).containsText("open casket")) {
  176.             sudokuOpen = true;
  177.         }
  178.         if (!getInterface(288).getChild(9).containsText("open casket")) {
  179.             sudokuOpen = false;
  180.         }
  181.         exitGeneralStore();
  182.         if (messedUp == true) {
  183.        //     log("closing interface");
  184.             talked = false;
  185.             sudokuOpen = false;
  186.             messedUp = false;
  187.             failed++;
  188.             resetGrid();
  189.             atInterface(288, 212);
  190.             wait(random(500, 750));
  191.  
  192.         }
  193.  
  194.         try {
  195.             switch (getState()) {
  196.             case toAli:
  197.  
  198.                 toAli();
  199.                 break;
  200.  
  201.             case openSudoku:
  202.  
  203.                 openSudoku();
  204.  
  205.                 break;
  206.             case doSudoku:
  207.                 doSudoku();
  208.  
  209.                 break;
  210.  
  211.             case buyRunes:
  212.                 buyRunes();
  213.  
  214.                 break;
  215.             case end:
  216.                 stopScript();
  217.                 break;
  218.             }
  219.         } catch (Exception e) {
  220.         }
  221.         calculateProfit();
  222.       //  log("" + getState());
  223.       //  log("sudokuOpen = " + sudokuOpen);
  224.       //  log("sudokuSolved = " + sudokuSolved);
  225.       //  log("messedUp = " + messedUp);
  226.  
  227.         return 200;
  228.     }
  229.  
  230.     private void getPrices() {
  231.         naturePrice = grandExchange.loadItemInfo(natureInvID).getMarketPrice();
  232.         cosmicPrice = grandExchange.loadItemInfo(cosmicInvID).getMarketPrice();
  233.         bloodPrice = grandExchange.loadItemInfo(bloodInvID).getMarketPrice();
  234.         deathPrice = grandExchange.loadItemInfo(deathInvID).getMarketPrice();
  235.         chaosPrice = grandExchange.loadItemInfo(chaosInvID).getMarketPrice();
  236.         mindPrice = grandExchange.loadItemInfo(mindInvID).getMarketPrice();
  237.         soulPrice = grandExchange.loadItemInfo(soulInvID).getMarketPrice();
  238.         bodyPrice = grandExchange.loadItemInfo(bodyInvID).getMarketPrice();
  239.         lawPrice = grandExchange.loadItemInfo(lawInvID).getMarketPrice();
  240.  
  241.         startCash = getInventoryCount(995);
  242.         startRunes = (naturePrice * getInventoryCount(natureInvID)
  243.                 + cosmicPrice * getInventoryCount(cosmicInvID) + bloodPrice
  244.                 * getInventoryCount(bloodInvID) + deathPrice
  245.                 * getInventoryCount(deathInvID) + chaosPrice
  246.                 * getInventoryCount(chaosInvID) + mindPrice
  247.                 * getInventoryCount(mindInvID) + soulPrice
  248.                 * getInventoryCount(soulInvID) + bodyPrice
  249.                 * getInventoryCount(bodyInvID) + lawPrice
  250.                 * getInventoryCount(lawInvID));
  251.         startMoney = startCash + startRunes;
  252.  
  253.     }
  254.  
  255.     private void calculateProfit() {
  256.  
  257.         currentCash = getInventoryCount(995);
  258.         currentRunes = (naturePrice * getInventoryCount(natureInvID)
  259.                 + cosmicPrice * getInventoryCount(cosmicInvID) + bloodPrice
  260.                 * getInventoryCount(bloodInvID) + deathPrice
  261.                 * getInventoryCount(deathInvID) + chaosPrice
  262.                 * getInventoryCount(chaosInvID) + mindPrice
  263.                 * getInventoryCount(mindInvID) + soulPrice
  264.                 * getInventoryCount(soulInvID) + bodyPrice
  265.                 * getInventoryCount(bodyInvID) + lawPrice
  266.                 * getInventoryCount(lawInvID));
  267.  
  268.         currentMoney = currentCash + currentRunes; // actual =
  269.  
  270.         profit = (int) ((currentMoney - startMoney));
  271.  
  272.     }
  273.  
  274.     private void toAli() {
  275.         walkTo(aliTile, 2, 2);
  276.     }
  277.  
  278.     private void openSudoku() {
  279.         while (getNearestNPCByID(aliID) != null && talked == false) {
  280.             RSNPC npc = (getNearestNPCByID(aliID));
  281.                 setMouseSpeed(6);
  282.                 atNPC(npc, "Talk-to");
  283.                 setMouseSpeed(6);
  284.                 talked = true;
  285.             wait(250 + random(500, 750));
  286.         }
  287.         while ((getInterface(241).getChild(4)
  288.                 .containsText("How's the adventuring"))) {
  289.             atInterface(241, 5);
  290.             wait(250+random(250,500));
  291.         }
  292.         while ((getInterface(228).getChild(2).containsText("Hi, Ali. Not bad"))) {
  293.             atInterface(228, 2);
  294.             wait(250+random(250,500));
  295.         }
  296.            
  297.         while ((getInterface(64).getChild(4).containsText("Hi Ali"))) {
  298.             atInterface(64, 5);
  299.             wait(250+random(250,500));
  300.         }
  301.         while ((getInterface(241).getChild(4).containsText("Still selling"))) {
  302.             atInterface(241, 5);
  303.             wait(250+random(250,500));
  304.  
  305.         }
  306.         while ((getInterface(241).getChild(4).containsText("Sigh"))) {
  307.             atInterface(241, 5);
  308.             wait(250+random(250,500));
  309.         }
  310.         while ((getInterface(64).getChild(4).containsText("What's up with you"))) {
  311.             atInterface(64, 5);
  312.             wait(250+random(250,500));
  313.         }
  314.         while ((getInterface(243).getChild(4)
  315.                 .containsText("Well, I always fancied"))) {
  316.             atInterface(243, 7);
  317.             wait(250+random(250,500));
  318.         }
  319.         if ((getInterface(64).getChild(4)
  320.                 .containsText("Is there anything I could do"))) {
  321.             atInterface(64, 5);
  322.             wait(250+random(250,500));
  323.         }
  324.         while ((getInterface(241).getChild(4)
  325.                 .containsText("How's the adventuring"))) {
  326.             atInterface(241, 5);
  327.             wait(250+random(250,500));
  328.         }
  329.         while ((getInterface(244).getChild(4).containsText("I have a friend"))) {
  330.             atInterface(244, 8);
  331.             wait(250+random(250,500));
  332.         }
  333.         while ((getInterface(64).getChild(4)
  334.                 .containsText("Maybe I could give it a look"))) {
  335.             atInterface(64, 5);
  336.             wait(500+random(500,1000));
  337.         }
  338.         while ((getInterface(232).getChild(4)
  339.                 .containsText("selection of runes"))) {
  340.             atInterface(232, 4);
  341.             wait(250+random(250,500));
  342.         }
  343.         while ((getInterface(232).getChild(3)
  344.                 .containsText("selection of runes"))) {
  345.             atInterface(232, 3);
  346.             wait(250+random(250,500));
  347.         }
  348.         while ((getInterface(234).getChild(4)
  349.                 .containsText("selection of runes"))) {
  350.             atInterface(234, 4);
  351.             wait(250+random(250,500));
  352.         }
  353.         while ((getInterface(230).getChild(2)
  354.                 .containsText("selection of runes"))) {
  355.             atInterface(230, 2);
  356.             wait(250 + random(250, 500));
  357.         }
  358.         while ((getInterface(241).getChild(4).containsText("Hang on"))) {
  359.             atInterface(241, 5);
  360.             wait(250+random(250,500));
  361.         }
  362.         while ((getInterface(233).getChild(3)
  363.                 .containsText("large casket of runes"))) {
  364.             atInterface(233, 3);
  365.             wait(250+random(250,500));
  366.  
  367.         }
  368.         while ((getInterface(231).getChild(3)
  369.                 .containsText("large casket of runes"))) {
  370.             atInterface(231, 3);
  371.             wait(250+random(250,500));
  372.  
  373.         }
  374.         while ((getInterface(235).getChild(3)
  375.                 .containsText("large casket of runes"))) {
  376.             atInterface(235, 3);
  377.             wait(250+random(250,500));
  378.         }
  379.         while ((getInterface(64).getChild(4).containsText("On second thoughts"))) {
  380.             talked = false;
  381.             atInterface(64, 5);
  382.             wait(250+random(250,500));
  383.  
  384.         }
  385.         while ((getInterface(65).getChild(4).containsText("I'm feeling lucky"))) {
  386.             atInterface(65, 6);
  387.             wait(250+random(250,500));
  388.         }
  389.         while ((getInterface(230).getChild(4).containsText("Examine lock"))) {
  390.             atInterface(230, 4);
  391.             wait(250+random(250,500));
  392.             sudokuOpen = true;
  393.         }
  394.         while (getInterface(64).getChild(4).containsText("Who did you want me")) {
  395.             talked = false;
  396.             atInterface(64, 5);
  397.             wait(250+random(250,500));
  398.             // sudokuOpen = 0;
  399.         }
  400.  
  401.     }
  402.  
  403.  
  404.  
  405.     public void solveSudoku() {
  406.         setMouseSpeed(0);
  407.         for (int k = 0; k < 9; k++) {
  408.             switch (k) {
  409.             case 0:
  410.                 atInterface(288, 205);
  411.                 for (int r = 0; r < 9; r++) {
  412.                     for (int c = 0; c < 9; c++) {
  413.                         int i = (11 + c * 2 + r * 18);
  414.                         if ((sudokuGrid[r][c] == 1)
  415.                                 && !(getInterface(288).getChild(i).getModelID() == mindID)) {
  416.                             atInterface(288, i);
  417.                             //wait(100 + random(100, 200));
  418.  
  419.                         }
  420.                     }
  421.                 }
  422.                 break;
  423.             case 1:
  424.                 atInterface(288, 206);
  425.                 for (int r = 0; r < 9; r++) {
  426.                     for (int c = 0; c < 9; c++) {
  427.                         int i = (11 + c * 2 + r * 18);
  428.                         if (sudokuGrid[r][c] == 2
  429.                                 && !(getInterface(288).getChild(i).getModelID() == fireID)) {
  430.                             atInterface(288, i);
  431.                             //wait(100 + random(100, 200));
  432.  
  433.                         }
  434.                     }
  435.                 }
  436.                 break;
  437.             case 2:
  438.                 atInterface(288, 204);
  439.                 for (int r = 0; r < 9; r++) {
  440.                     for (int c = 0; c < 9; c++) {
  441.                         int i = (11 + c * 2 + r * 18);
  442.                         if (sudokuGrid[r][c] == 3
  443.                                 && !(getInterface(288).getChild(i).getModelID() == airID)) {
  444.                             atInterface(288, i);
  445.                             //wait(100 + random(100, 200));
  446.  
  447.                         }
  448.                     }
  449.                 }
  450.                 break;
  451.             case 3:
  452.                 atInterface(288, 203);
  453.                 for (int r = 0; r < 9; r++) {
  454.                     for (int c = 0; c < 9; c++) {
  455.                         int i = (11 + c * 2 + r * 18);
  456.                         if (sudokuGrid[r][c] == 4
  457.                                 && !(getInterface(288).getChild(i).getModelID() == waterID)) {
  458.                             atInterface(288, i);
  459.                             //wait(100 + random(100, 200));
  460.  
  461.                         }
  462.                     }
  463.                 }
  464.                 break;
  465.             case 4:
  466.                 atInterface(288, 202);
  467.                 for (int r = 0; r < 9; r++) {
  468.                     for (int c = 0; c < 9; c++) {
  469.                         int i = (11 + c * 2 + r * 18);
  470.                         if (sudokuGrid[r][c] == 5
  471.                                 && !(getInterface(288).getChild(i).getModelID() == earthID)) {
  472.                             atInterface(288, i);
  473.                             //wait(100 + random(100, 200));
  474.  
  475.                         }
  476.                     }
  477.                 }
  478.                 break;
  479.             case 5:
  480.                 atInterface(288, 207);
  481.                 for (int r = 0; r < 9; r++) {
  482.                     for (int c = 0; c < 9; c++) {
  483.                         int i = (11 + c * 2 + r * 18);
  484.                         if (sudokuGrid[r][c] == 6
  485.                                 && !(getInterface(288).getChild(i).getModelID() == bodyID)) {
  486.                             atInterface(288, i);
  487.                             //wait(100 + random(100, 200));
  488.  
  489.                         }
  490.                     }
  491.                 }
  492.                 break;
  493.             case 6:
  494.                 atInterface(288, 208);
  495.                 for (int r = 0; r < 9; r++) {
  496.                     for (int c = 0; c < 9; c++) {
  497.                         int i = (11 + c * 2 + r * 18);
  498.                         if (sudokuGrid[r][c] == 7
  499.                                 && !(getInterface(288).getChild(i).getModelID() == deathID)) {
  500.                             atInterface(288, i);
  501.                             //wait(100 + random(100, 200));
  502.  
  503.                         }
  504.                     }
  505.                 }
  506.                 break;
  507.             case 7:
  508.                 atInterface(288, 209);
  509.                 for (int r = 0; r < 9; r++) {
  510.                     for (int c = 0; c < 9; c++) {
  511.                         int i = (11 + c * 2 + r * 18);
  512.                         if (sudokuGrid[r][c] == 8
  513.                                 && !(getInterface(288).getChild(i).getModelID() == chaosID)) {
  514.                             atInterface(288, i);
  515.                             //wait(100 + random(100, 200));
  516.  
  517.                         }
  518.                     }
  519.                 }
  520.                 break;
  521.             case 8:
  522.                 atInterface(288, 210);
  523.                 for (int r = 0; r < 9; r++) {
  524.                     for (int c = 0; c < 9; c++) {
  525.                         int i = (11 + c * 2 + r * 18);
  526.                         if (sudokuGrid[r][c] == 9
  527.                                 && !(getInterface(288).getChild(i).getModelID() == lawID)) {
  528.                             atInterface(288, i);
  529.                             //wait(100 + random(100, 200));
  530.  
  531.                         }
  532.                     }
  533.                 }
  534.                 break;
  535.             }
  536.  
  537.         }
  538.         setMouseSpeed(6);
  539.     }
  540.  
  541.     private void doSudoku() {
  542.  
  543.         if (sudokuOpen == true && sudokuSolved == false
  544.                 && !getInterface(228).getChild(2).containsText("Buy all")) {
  545.             makeGrid();
  546.             if (solve(0, 0, sudokuGrid)) {
  547.                 //log("solved, waiting 10-20 secs");
  548.                 if (sudokuOpen == true
  549.                         && !getInterface(228).getChild(2).containsText(
  550.                                 "Buy all")) {
  551.                     for (int i = 0; i < 9; i++) {
  552.                         wait(random(100, 200));
  553.                     }
  554.                 }
  555.  
  556.                 solveSudoku();
  557.                 wait(250+ random(250,500));
  558.                 sudokuSolved = true;
  559.                 if (getInterface(288).getChild(9).containsText("open casket")) {
  560.                     atInterface(288, 9);
  561.                     wait(4000+(random(250,500)));
  562.                     sudokuOpen = false;
  563.                     sudokuSolved = false;
  564.                 }
  565.             }
  566.         }
  567.     }
  568.  
  569.     private void buyRunes() {
  570.         atInterface(228, 2);
  571.         resetGrid();
  572.         talked = false;
  573.         sudokuOpen = false;
  574.         sudokuSolved = false;
  575.         wait(500 + random(500, 750));
  576.         resetGrid();
  577.     }
  578.  
  579.     private boolean inArea(final int[] area) {
  580.         final int x = getMyPlayer().getLocation().getX();
  581.         final int y = getMyPlayer().getLocation().getY();
  582.         if (x >= area[0] && x <= area[2] && y >= area[1] && y <= area[3]) {
  583.             return true;
  584.         }
  585.         return false;
  586.  
  587.     }
  588.     private boolean inGeneralStore(){
  589.         if(getInterface(620).getChild(20).containsText("Ali's Discount Wares")){
  590.             return true;
  591.         }
  592.         else{
  593.             return false;
  594.             }
  595.     }
  596.     private void exitGeneralStore(){
  597.         if(inGeneralStore()==true){
  598.             if(getInterface(620).getChild(18).containsAction("Close")){
  599.                 log("missclicked, closing general store");
  600.                 atInterface(620,18);
  601.                 talked = false;
  602.                 sudokuOpen = false;
  603.                
  604.             }
  605.            
  606.         }
  607.     }
  608.  
  609.     static boolean solve(int i, int j, int[][] cells) {
  610.          if (i == 9) {
  611.             i = 0;
  612.             if (++j == 9)
  613.                 return true;
  614.         }
  615.         if (cells[i][j] != 0) // skip filled cells
  616.             return solve(i + 1, j, cells);
  617.  
  618.         for (int val = 1; val <= 9; ++val) {
  619.             if (legal(i, j, val, cells)) {
  620.                 cells[i][j] = val;
  621.                 if (solve(i + 1, j, cells))
  622.                     return true;
  623.             }
  624.         }
  625.         cells[i][j] = 0; // reset on backtrack
  626.         return false;
  627.     }
  628.  
  629.     static boolean legal(int i, int j, int val, int[][] cells) {
  630.         for (int k = 0; k < 9; ++k)
  631.             // row
  632.             if (val == cells[k][j])
  633.                 return false;
  634.  
  635.         for (int k = 0; k < 9; ++k)
  636.             // col
  637.             if (val == cells[i][k])
  638.                 return false;
  639.  
  640.         int boxRowOffset = (i / 3) * 3;
  641.         int boxColOffset = (j / 3) * 3;
  642.         for (int k = 0; k < 3; ++k)
  643.             // box
  644.             for (int m = 0; m < 3; ++m)
  645.                 if (val == cells[boxRowOffset + k][boxColOffset + m])
  646.                     return false;
  647.  
  648.         return true; // no violations, so it's legal
  649.     }
  650.  
  651.     public boolean onStart(Map<String, String> args) {
  652.         scriptStartTIME = System.currentTimeMillis();
  653.         resetGrid();
  654.         getPrices();
  655.         return true;
  656.     }
  657.  
  658.     private void makeGrid() {
  659.  
  660.         for (int r = 0; r < 9; r++) {
  661.             for (int c = 0; c < 9; c++) {
  662.                 int i = (11 + c * 2 + r * 18);
  663.  
  664.                 if (getInterface(288).getChild(i).getModelID() == mindID) {
  665.                     sudokuGrid[r][c] = 1;
  666.                 }
  667.                 if (getInterface(288).getChild(i).getModelID() == fireID) {
  668.                     sudokuGrid[r][c] = 2;
  669.                 }
  670.                 if (getInterface(288).getChild(i).getModelID() == airID) {
  671.                     sudokuGrid[r][c] = 3;
  672.                 }
  673.                 if (getInterface(288).getChild(i).getModelID() == waterID) {
  674.                     sudokuGrid[r][c] = 4;
  675.                 }
  676.                 if (getInterface(288).getChild(i).getModelID() == earthID) {
  677.                     sudokuGrid[r][c] = 5;
  678.                 }
  679.                 if (getInterface(288).getChild(i).getModelID() == bodyID) {
  680.                     sudokuGrid[r][c] = 6;
  681.                 }
  682.                 if (getInterface(288).getChild(i).getModelID() == deathID) {
  683.                     sudokuGrid[r][c] = 7;
  684.                 }
  685.                 if (getInterface(288).getChild(i).getModelID() == chaosID) {
  686.                     sudokuGrid[r][c] = 8;
  687.                 }
  688.                 if (getInterface(288).getChild(i).getModelID() == lawID) {
  689.                     sudokuGrid[r][c] = 9;
  690.                 }
  691.             }
  692.         }
  693.     }
  694.  
  695.     private void resetGrid() {
  696.         for (int r = 0; r < 9; r++) {
  697.             for (int c = 0; c < 9; c++) {
  698.                 sudokuGrid[r][c] = 0;
  699.  
  700.             }
  701.         }
  702.  
  703.     }
  704.  
  705.     @Override
  706.     public void onRepaint(Graphics render) {
  707.         long runTime = 0;
  708.         long seconds = 0;
  709.         long minutes = 0;
  710.         long hours = 0;
  711.         runTime = System.currentTimeMillis() - scriptStartTIME;
  712.         seconds = runTime / 1000;
  713.         if (seconds >= 60) {
  714.             minutes = seconds / 60;
  715.             seconds -= (minutes * 60);
  716.         }
  717.         if (minutes >= 60) {
  718.             hours = minutes / 60;
  719.             minutes -= (hours * 60);
  720.         }
  721.         // variables
  722.         int solvedPerHour = 0;
  723.         int failedPerHour = 0;
  724.         int profitPerHour = 0;
  725.  
  726.         if (runTime / 1000 > 0) {
  727.             solvedPerHour = (int) ((3600000.0 / (double) runTime) * solved);
  728.             failedPerHour = (int) ((3600000.0 / (double) runTime) * failed);
  729.            
  730.             profitPerHour = (int) ((3600000.0 / (double) runTime) * profit);
  731.  
  732.         }
  733.  
  734.         // the paint!
  735.  
  736.         Color background = new Color(0, 0, 0, 115);
  737.         render.setColor(Color.black);
  738.         render.draw3DRect(545, 350, 192, 115, true);
  739.         render.setColor(background);
  740.         render.setColor(Color.white);
  741.         render.drawString("RuneSudokuSolver v 1.1", 560, 365);
  742.         render.drawString("by Alden", 570, 375);
  743.         // render.drawString("Version: " ,390,35);
  744.         render.drawString("Runtime: " + hours + ":" + minutes + ":" + seconds,
  745.                 565, 390);
  746.         render.drawString("solved: " + solved, 565, 405);
  747.         render.drawString("failed: " + failed, 645, 405);
  748.         render.drawString("solved/hr: " + solvedPerHour, 565, 420);
  749.         render.drawString("failed/hr: " + failedPerHour, 645, 420);
  750.  
  751.         render.drawString("profit: " + profit, 565, 440);
  752.         render.drawString("profit/hr: " + profitPerHour, 565, 455);
  753.  
  754.     }
  755.  
  756.     public void serverMessageRecieved(final ServerMessageEvent arg0) {
  757.  
  758.         final String message = arg0.getMessage();
  759.         if (message.contains("remove this rune")) {
  760.             messedUp = true;
  761.         }
  762.         if (message.contains("locked")) {
  763.             messedUp = true;
  764.         }
  765.  
  766.         if (message.contains("hear the locking") && sudokuOpen == true) {
  767.             solved++;
  768.             resetGrid();
  769.             sudokuOpen = false;
  770.             // log("open");
  771.         }
  772.  
  773.     }