Share Pastebin
Guest
Public paste!

The Devil's Sent Monk Killer

By: a guest | Mar 22nd, 2010 | Syntax: Java | Size: 19.53 KB | Hits: 82 | Expires: Never
Copy text to clipboard
  1.     import java.text.*;
  2.  
  3.     import java.awt.Color;
  4.  
  5.     import java.awt.Graphics;
  6.  
  7.     import java.awt.Point;
  8.  
  9.     import java.util.Map;
  10.  
  11.  
  12.  
  13.     import org.rsbot.bot.Bot;
  14.  
  15.     import org.rsbot.bot.input.CanvasWrapper;
  16.  
  17.     import org.rsbot.bot.input.Mouse;
  18.  
  19.     import org.rsbot.event.events.ServerMessageEvent;
  20.  
  21.     import org.rsbot.event.listeners.PaintListener;
  22.  
  23.     import org.rsbot.event.listeners.ServerMessageListener;
  24.  
  25.     import org.rsbot.script.Constants;
  26.  
  27.     import org.rsbot.script.Script;
  28.  
  29.     import org.rsbot.script.ScriptManifest;
  30.  
  31.     import org.rsbot.script.wrappers.RSItemTile;
  32.  
  33.     import org.rsbot.script.wrappers.RSTile;
  34.  
  35.     import org.rsbot.script.wrappers.RSInterfaceComponent;
  36.  
  37.     import org.rsbot.script.wrappers.RSNPC;
  38.  
  39.     import org.rsbot.script.Skills;
  40.  
  41.     import org.rsbot.script.wrappers.RSPlayer;
  42.  
  43.     import org.rsbot.script.Methods;
  44.  
  45.  
  46.  
  47.  
  48.  
  49.     @ScriptManifest(authors = { "Coco" }, category = "Combat", name = "The Devil's sent", version = 1.0, description = "<html><body><h2>" +
  50.  
  51.     "The Devil's sent</h2><hr>by Coco<br><input name='bury' type='checkbox' value='1'>Bury the bones<br />"
  52.  
  53.     + "<select name=\"arrowtype\">"
  54.  
  55.     + "<option> Nothing"
  56.  
  57.     + "<option> Bronze"
  58.  
  59.     + "<option> Iron"
  60.  
  61.     + "<option> Steel"
  62.  
  63.     +" </select> What arrows are you going to use? (if any)<p>Just start in the monastery</body></html>")
  64.  
  65.     public class TheDevilssent extends Script implements PaintListener, ServerMessageListener {
  66.  
  67.  
  68.  
  69.         public long startTime = System.currentTimeMillis();
  70.  
  71.         public long lastExpTime;
  72.  
  73.         public int levelup = 0;
  74.  
  75.         public int i = 0;
  76.  
  77.         public int counter = 0;
  78.  
  79.         public int healcount =0;
  80.  
  81.         public int failcount = 0;
  82.  
  83.         public int arrow = 0; //bronze
  84.  
  85.         public final int bronze = 882, iron = 884, steel = 886;
  86.  
  87.         public String arrowtype = "";
  88.  
  89.         public boolean burybones = false;
  90.  
  91.         public RSTile center = new RSTile (3045, 3490);
  92.  
  93.         public RSTile south = new RSTile (3045, 3483);
  94.  
  95.         public RSTile north = new RSTile (3045, 3496);
  96.  
  97.         public RSNPC monk;
  98.  
  99.         public double startExp[] = null;
  100.  
  101.         public double expGained[] = null;
  102.  
  103.         public double expPerHour[] = null;
  104.  
  105.         public int expG, auxExp, noexpcounter;
  106.  
  107.         public float totalSec = 0;
  108.  
  109.         @Override
  110.  
  111.         public int loop() {
  112.  
  113.             if (distanceTo(new RSTile(3050, 3492)) > 25 && !getMyPlayer().isMoving() && isLoggedIn()) {
  114.  
  115.                 walkTo(new RSTile(3050, 3492));
  116.  
  117.                 failcount++;
  118.  
  119.                 return 1;
  120.  
  121.             }
  122.  
  123.             if (failcount >= 5) {
  124.  
  125.                 log("Lost");
  126.  
  127.                 logout();
  128.  
  129.                 return -1;
  130.  
  131.             }
  132.  
  133.  
  134.             final Methods methods = new Methods();
  135.  
  136.             if (methods.getCurrentLifePoints() <= 100) { // get healed, we are dying
  137.  
  138.                 if (getMyPlayer().getInteracting() == null) { //doing nothing
  139.  
  140.                     while (methods.getCurrentLifePoints() < (skills.getRealSkillLevel(STAT_HITPOINTS)*10)) {
  141.  
  142.                         getHealed();
  143.  
  144.                     }
  145.  
  146.                     healcount++;
  147.  
  148.                     if (distanceTo(center) > 5) walkTileMM(center,0,0);
  149.  
  150.                     log("just healed, back to center");
  151.  
  152.                     //here we just got healed
  153.  
  154.                     failcount = 0;
  155.  
  156.                     return 1;
  157.  
  158.                 }
  159.  
  160.             }
  161.  
  162.  
  163.  
  164.             if (getDestination() != null) {
  165.  
  166.                 if ((getDestination().getX() < 3044 || getDestination().getY() > 3498) && monk!=null) { //going outside the monastery?
  167.  
  168.                     if (distanceBetween(getDestination(), north) <= 5) {
  169.  
  170.                         if (!tileOnScreen(north)) {
  171.  
  172.                             walkTileMM(north,0,0);
  173.  
  174.                         } else {
  175.  
  176.                             walkTileOnScreen(north);
  177.  
  178.                         }
  179.  
  180.                         return 450;
  181.  
  182.                     }
  183.  
  184.                     if (distanceBetween(getDestination(), south) <= 5) {
  185.  
  186.                         if (!tileOnScreen(south)) {
  187.  
  188.                             walkTileMM(south,0,0);
  189.  
  190.                         } else {
  191.  
  192.                             walkTileOnScreen(south);
  193.  
  194.                         }
  195.  
  196.                         return 450;
  197.  
  198.                     }
  199.  
  200.                 } else if (monk == null) {
  201.  
  202.                     if (!tileOnScreen(center)) {
  203.  
  204.                         walkTileMM(center,0,0);
  205.  
  206.                     } else {
  207.  
  208.                         walkTileOnScreen(center);
  209.  
  210.                     }
  211.  
  212.                 }
  213.  
  214.             }
  215.  
  216.             if (!isRunning() && getEnergy() > random(60, 75)) {
  217.  
  218.                 setRun(true);
  219.  
  220.                 wait(random(400, 800));
  221.  
  222.             }
  223.  
  224.             if (getMyPlayer().getInteracting() == null && distanceTo(getGroundItemByID(526)) < 5  && burybones && getGroundItemByID(526) != null) {
  225.  
  226.                 //doing nothing, bone near, we are trying to bury, there's a bone.
  227.  
  228.                 atTile(getGroundItemByID(526), "Take");
  229.  
  230.                 return(860);
  231.  
  232.             }
  233.  
  234.            
  235.  
  236.             if (getGroundItemByID(arrow) != null && distanceTo(getGroundItemByID(arrow)) < 7 && getGroundItemByID(arrow).getItem().getStackSize() > 3) { //will pick up arrows if
  237.  
  238.                 while (getMyPlayer().isInCombat() && getMyPlayer().getInteracting() != null)  {
  239.  
  240.                 /* we are close to them and not fighting, AND they are 3 or more*/
  241.  
  242.                     wait(300);
  243.  
  244.                 }
  245.  
  246.                 atTile(getGroundItemByID(arrow), "Take");
  247.  
  248.                 return (1000);
  249.  
  250.             }
  251.  
  252.             monk = getNearestFreeNPCToAttackByID(7727);
  253.  
  254.             if (getDestination() != null && monk != null) { //walking somewhere, but this monks is closer, OM NOM
  255.  
  256.                 if (distanceBetween(monk.getLocation(), getDestination()) > 3) { // we have a monk nearer than the one we are trying to get, probably just respawned
  257.  
  258.                     if (distanceTo(monk.getLocation()) +1 < distanceTo(getDestination())) { //COMPLETELY SURE, the monk is closer
  259.  
  260.                         if (tileOnScreen(monk.getLocation())) {
  261.  
  262.                             atNPC(monk, "Attack");
  263.  
  264.                             return 1500;
  265.  
  266.                         } else {
  267.  
  268.                             walkTileMM(monk.getLocation(),0,0);
  269.  
  270.                             return 1500;
  271.  
  272.                         }
  273.  
  274.                     }
  275.  
  276.                    
  277.  
  278.                 }
  279.  
  280.             }
  281.  
  282.            
  283.  
  284.            
  285.  
  286.             if (getInventoryCount(arrow) > 50) {
  287.  
  288.                 atInventoryItem(arrow, "Wield");
  289.  
  290.                 return 600;
  291.  
  292.             }
  293.  
  294.             if (getInventoryCount(526) > 0 && !burybones) {
  295.  
  296.                 atInventoryItem(526, "Drop");
  297.  
  298.                 return 600;
  299.  
  300.             }
  301.  
  302.            
  303.  
  304.             if (isInventoryFull() && burybones && getInventoryCount(526) > 0) {
  305.  
  306.                 while (getInventoryCount(526) > 0) {
  307.  
  308.                     atInventoryItem(526, "Bury");
  309.  
  310.                     wait(500);
  311.  
  312.                 }
  313.  
  314.             }
  315.  
  316.  
  317.  
  318.             if (getMyPlayer().getInteracting() == null) { // doing nothing .. go attack
  319.  
  320.                 monk = getNearestFreeNPCToAttackByID(7727);
  321.  
  322.                 if (monk == null) {
  323.  
  324.                     if (!getMyPlayer().isMoving() && getMyPlayer().getInteracting() == null) {
  325.  
  326.                         if (burybones && getGroundItemByID(526) != null) { //will bury and there's a bone here
  327.  
  328.                             atTile(getGroundItemByID(526), "Take");
  329.  
  330.                             return 600;
  331.  
  332.                         }
  333.  
  334.                         if(distanceTo(center) > 5) {
  335.  
  336.                             if (!tileOnScreen(center)) {
  337.  
  338.                                 walkTileMM(center,0,2); // no monk, going to the middle so we are near to the three spawnsç
  339.  
  340.                             } else {
  341.  
  342.                                 walkTileOnScreen(center);
  343.  
  344.                             }
  345.  
  346.                             wait(599);
  347.  
  348.                         }
  349.  
  350.                         customRest();
  351.  
  352.                         //} will rest until a monk appears
  353.  
  354.                     }
  355.  
  356.                         return 500;
  357.  
  358.                 }// no monk what the hell
  359.  
  360.                
  361.  
  362.                 if (!tileOnScreen(monk.getLocation()) && !getMyPlayer().isMoving()){
  363.  
  364.                     if (distanceBetween(monk.getLocation(), north) <= 5) {
  365.  
  366.                         if (!tileOnScreen(north)) {
  367.  
  368.                             walkTileMM(north,0,0);
  369.  
  370.                         } else {
  371.  
  372.                             walkTileOnScreen(north);
  373.  
  374.                         }
  375.  
  376.                         return 350;
  377.  
  378.                     }
  379.  
  380.                     if (distanceBetween(monk.getLocation(), south) <= 5) {
  381.  
  382.                         if (!tileOnScreen(south)) {
  383.  
  384.                             walkTileMM(south,0,0);
  385.  
  386.                         } else {
  387.  
  388.                             walkTileOnScreen(south);
  389.  
  390.                         }
  391.  
  392.                         return 350;
  393.  
  394.                     } // center has no troubles so go there :D
  395.  
  396.                     if (!tileOnScreen(monk.getLocation())) {
  397.  
  398.                             walkTileMM(monk.getLocation(),0,0);
  399.  
  400.                         } else {
  401.  
  402.                             walkTileOnScreen(monk.getLocation());
  403.  
  404.                         }
  405.  
  406.                     return 500;
  407.  
  408.                 }// monk is away, go there
  409.  
  410.                 if(monk != null ) clickRSNPC(monk, "Attack"); // we are near the monk, DIE!
  411.  
  412.                 return 800;
  413.  
  414.             }
  415.  
  416.             return (random(100, 200));
  417.  
  418.         }
  419.  
  420.        
  421.  
  422.         public void getHealed() {
  423.  
  424.             /*if (distanceTo(new RSTile(3058, 3484)) > distanceTo(center)) {
  425.  
  426.                 if (!tileOnScreen(new RSTile(3058, 3484))) {
  427.  
  428.                     walkTileMM(new RSTile(3058, 3484),0,0);
  429.  
  430.                     wait(800);
  431.  
  432.                 } else {
  433.  
  434.                     walkTileOnScreen(new RSTile(3058, 3484));
  435.  
  436.                     wait(1500);
  437.  
  438.                 }
  439.  
  440.                 return;
  441.  
  442.             }*/
  443.  
  444.            
  445.  
  446.             if (distanceTo(new RSTile(3058, 3484)) > 5 /*&& !getMyPlayer().isMoving()*/) {
  447.  
  448.                 if (!tileOnScreen(new RSTile(3058, 3484))) {
  449.  
  450.                     walkTileMM(new RSTile(3058, 3484),0,0);
  451.  
  452.                     wait(1500);
  453.  
  454.                 } else {
  455.  
  456.                     walkTileOnScreen(new RSTile(3058, 3484));
  457.  
  458.                     wait(900);
  459.  
  460.                 }
  461.  
  462.             }
  463.  
  464.             if (getInterface(241).isValid()) {
  465.  
  466.                 atInterface(getInterface(241).getChild(5), "Continue"); //twice
  467.  
  468.                 wait(1000);
  469.  
  470.                 return;
  471.  
  472.             }
  473.  
  474.             if (getInterface(230).isValid()) {
  475.  
  476.                 atInterface(getInterface(230).getChild(2), "Continue");
  477.  
  478.                 wait(800);
  479.  
  480.                 return;
  481.  
  482.             }
  483.  
  484.             if (getInterface(64).isValid()) {
  485.  
  486.                 atInterface(getInterface(64).getChild(5), "Continue");
  487.  
  488.                 wait(800);
  489.  
  490.                 return;
  491.  
  492.             }
  493.  
  494.             if (getInterface(210).isValid()) {
  495.  
  496.                 atInterface(getInterface(210).getChild(2), "Continue");
  497.  
  498.                 wait(800);
  499.  
  500.                 return;
  501.  
  502.             }
  503.  
  504.                
  505.  
  506.             atNPC(getNearestNPCByID(801), "Talk");
  507.  
  508.             wait(700);
  509.  
  510.         return;
  511.  
  512.         }
  513.  
  514.         public void onRepaint(final Graphics g) {
  515.  
  516.             if (!isLoggedIn()) return;
  517.  
  518.             long millis = System.currentTimeMillis() - startTime;
  519.  
  520.             long noexpmillis =System.currentTimeMillis();
  521.  
  522.             final long hours = millis / (1000 * 60 * 60);
  523.  
  524.             millis -= hours * 1000 * 60 * 60;
  525.  
  526.             final long minutes = millis / (1000 * 60);
  527.  
  528.             millis -= minutes * 1000 * 60;
  529.  
  530.             final long seconds = millis / 1000;
  531.  
  532.             totalSec = hours * 3600 + minutes * 60 + seconds;
  533.  
  534.            
  535.  
  536.             if (auxExp < expG) { //gained exp, reset counter
  537.  
  538.                 auxExp = expG;
  539.  
  540.                 lastExpTime = System.currentTimeMillis();
  541.  
  542.             }
  543.  
  544.            
  545.  
  546.             if ((noexpmillis - lastExpTime)/ 1000 >= 120 && lastExpTime> 0) { //seconds 120 = 2 mins
  547.  
  548.  
  549.  
  550.                 log("2 minutes without getting exp, logging off");
  551.  
  552.                 stopScript();
  553.  
  554.                 // mb add world swithcing?
  555.  
  556.             }
  557.  
  558.            
  559.  
  560.             g.setColor(Color.black);
  561.  
  562.             g.fillRoundRect(528,281,229,181,10,10);
  563.  
  564.  
  565.  
  566.             g.setColor(Color.white);
  567.  
  568.             g.drawString("Coco's Devil sent", 593,295);
  569.  
  570.  
  571.  
  572.             int counter = 0;
  573.  
  574.             expG = 0;
  575.  
  576.             for ( int i = 0; i < 7; i++ ) {
  577.  
  578.                 if ((startExp != null) && ((skills.getCurrentSkillExp(i) - startExp[i]) > 0)) {
  579.  
  580.                     expGained[i] =skills.getCurrentSkillExp(i) - startExp[i]; // exp gained
  581.  
  582.                     expPerHour[i] = skills.getXPToNextLevel(i) /* xp left */ / (expGained[i] / totalSec );
  583.  
  584.                     expPerHour[i] = expPerHour[i] / 60;
  585.  
  586.                     expG = expG + (int)expGained[i];
  587.  
  588.                     counter++;
  589.  
  590.                    
  591.  
  592.                     g.drawString(skills.statsArray[i],540, 320 + (15*counter));
  593.  
  594.                     g.drawLine(535, 323 + (15*counter), 750,323 + (15*counter)); //separates skills
  595.  
  596.                    
  597.  
  598.                     if (totalSec >=60) {
  599.  
  600.                         if ((double)expPerHour[i] >= 1) {
  601.  
  602.                             g.drawString(""+(int)expGained[i],598, 320 + (15*counter));
  603.  
  604.                             g.drawString(getFormattedNumber((double)expPerHour[i]) + "min", 643, 320 + (15*counter));
  605.  
  606.                             g.drawString(""+ (int) ((expGained[i] *3600/ totalSec)), 700, 320 + (15*counter));
  607.  
  608.                         }
  609.  
  610.                     } else {
  611.  
  612.                         g.drawString(""+(int)expGained[i],598, 320 + (15*counter));
  613.  
  614.                         g.drawString("Wait", 648, 320 + (15*counter));
  615.  
  616.                         g.drawString("till min >= 1", 700, 320 + (15*counter));
  617.  
  618.                     }
  619.  
  620.                 }
  621.  
  622.             }
  623.  
  624.  
  625.  
  626.             g.drawString("Got healed: " + healcount + " times", 540, 440);
  627.  
  628.             g.drawString("Runtime: " + hours + " hs " + minutes + " min " + seconds + " secs.", 540, 455);
  629.  
  630.            
  631.  
  632.             //53 cada parte, ~32 de "SKILL" -> 10 al startx
  633.  
  634.             g.drawLine(535, 300, 750,300); //underlines script name
  635.  
  636.                 g.drawString("SKILL", 545, 315);
  637.  
  638.             g.drawLine(535, 320, 750,320); //underline "SKILL",, etc
  639.  
  640.             g.drawLine(588, 300,588, 410); //second column divider SKILL || EXPG
  641.  
  642.                 g.drawString("EXP G", 598, 315);
  643.  
  644.             g.drawLine(641, 300,641, 410); //third column divider  EXPG || TIME LEFT
  645.  
  646.                 g.drawString("Time L", 648, 315);
  647.  
  648.             g.drawLine(694, 300,694, 410); //foruth column divider TIME LEFT || %
  649.  
  650.                 g.drawString("Exp/Hour", 700, 315);
  651.  
  652.         }
  653.  
  654.  
  655.  
  656.         @Override
  657.  
  658.         protected int getMouseSpeed() {
  659.  
  660.             return 4;
  661.  
  662.         }
  663.  
  664.         @Override
  665.  
  666.         public boolean onStart(final Map<String, String> args) {
  667.  
  668.             burybones = args.get("bury") != null;
  669.  
  670.            
  671.  
  672.             arrowtype = args.get("arrowtype");
  673.  
  674.             if (arrowtype != null) arrowtype = arrowtype.replace("\uc2a0", " ");
  675.  
  676.            
  677.  
  678.             startExp = new double[7];
  679.  
  680.             expGained = new double[7];
  681.  
  682.             expPerHour = new double[7];
  683.  
  684.            
  685.  
  686.             for ( int i = 0; i < 7; i++ ) {
  687.  
  688.                 startExp[i] = skills.getCurrentSkillExp(i);
  689.  
  690.             }
  691.  
  692.            
  693.  
  694.             if (burybones) {
  695.  
  696.                 log("Burying bones");
  697.  
  698.             } else {
  699.  
  700.                 log ("Not burying bones");
  701.  
  702.             }
  703.  
  704.             arrow = 0;
  705.  
  706.             if (arrowtype.equals("Bronze")) arrow = bronze;
  707.  
  708.             if (arrowtype.equals("Iron")) arrow = iron;
  709.  
  710.             if (arrowtype.equals("Steel")) arrow = steel;
  711.  
  712.             //shouldn't check that..
  713.  
  714.             if (getInventoryCount(arrow) > 50) {
  715.  
  716.                 atInventoryItem(arrow, "Wield");
  717.  
  718.                 wait(1500);
  719.  
  720.             }
  721.  
  722.             if (arrow > 0) log("Using : " + arrowtype + " arrows");
  723.  
  724.  
  725.  
  726.             startTime = System.currentTimeMillis();
  727.  
  728.             setCameraAltitude(true);
  729.  
  730.             return true;
  731.  
  732.         }
  733.  
  734.        
  735.  
  736.         public void serverMessageRecieved( ServerMessageEvent arg0 ) {
  737.  
  738.             String serverString = arg0.getMessage();
  739.  
  740.             if (serverString.contains("You've just") || serverString.contains("Congratulations")) {
  741.  
  742.                 log("You just advanced a level, attempting to click continue!");
  743.  
  744.                 levelup++;
  745.  
  746.                 wait(random(1500, 2500));
  747.  
  748.                 if (canContinue()) {
  749.  
  750.                     clickContinue();
  751.  
  752.                 }
  753.  
  754.             }
  755.  
  756.             if (serverString.contains("no ammo left in") || serverString.contains("quiver")) {
  757.  
  758.                 log("no ammo cya");
  759.  
  760.                
  761.  
  762.                 openTab(TAB_EQUIPMENT);
  763.  
  764.                 atInterface(getInterface(387).getChild(17), "Remove");
  765.  
  766.                
  767.  
  768.                 stopScript();
  769.  
  770.             }
  771.  
  772.         }
  773.  
  774.     public void onFinish() {
  775.  
  776.     int i = 0;
  777.  
  778.             log ("After " + getFormattedNumber((double)(totalSec / 60)) + " minutes: ");
  779.  
  780.             for ( i = 0; i < 7; i++ ) {
  781.  
  782.                 if ((startExp != null) && ((skills.getCurrentSkillExp(i) - startExp[i]) > 0)) {
  783.  
  784.                     log("Gained: " + expGained[i] + " exp on " + skills.statsArray[i]);
  785.  
  786.                 }
  787.  
  788.             }
  789.  
  790.             log("and got healed " + healcount + " times. See you next time :) ");
  791.  
  792.            
  793.  
  794.         }
  795.  
  796.     public boolean customRest() {
  797.  
  798.             //int energy = getEnergy();
  799.  
  800.             for (int d = 0; d < 5; d++) {
  801.  
  802.                 atInterface(Constants.INTERFACE_RUN_ORB, 1, "Rest");
  803.  
  804.                 moveMouseSlightly();
  805.  
  806.                 wait(random(400, 600));
  807.  
  808.                 if (getMyPlayer().getAnimation() == 12108
  809.  
  810.                         || getMyPlayer().getAnimation() == 2033
  811.  
  812.                         || getMyPlayer().getAnimation() == 2716
  813.  
  814.                         || getMyPlayer().getAnimation() == 11786
  815.  
  816.                         || getMyPlayer().getAnimation() == 5713) {
  817.  
  818.                     break;
  819.  
  820.                 }
  821.  
  822.                 if (d == 4) {
  823.  
  824.                     log("Rest failed!");
  825.  
  826.                     return false;
  827.  
  828.                 }
  829.  
  830.             }
  831.  
  832.             while (monk == null) {
  833.  
  834.                 monk = getNearestFreeNPCToAttackByID(7727);
  835.  
  836.                 wait(random(250, 500));
  837.  
  838.                 //energy = getEnergy();
  839.  
  840.             }
  841.  
  842.             return true;
  843.  
  844.         }
  845.  
  846.         public String getFormattedNumber(Double p_number) {
  847.  
  848.        NumberFormat l_nf = NumberFormat.getInstance();
  849.  
  850.        String  l_rVal; // Valor de retorno de la función.
  851.  
  852.  
  853.  
  854.        l_nf.setMaximumFractionDigits(1);  // 2 decimales como mucho y como poco
  855.  
  856.        l_nf.setMinimumFractionDigits(1);
  857.  
  858.  
  859.  
  860.        l_rVal = new String ( l_nf.format(p_number.doubleValue()));
  861.  
  862.  
  863.  
  864.        return l_rVal;
  865.  
  866.     }
  867.  
  868.     }