Guest User

Untitled

a guest
Jun 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.70 KB | None | 0 0
  1. package com.scripts;
  2.  
  3. import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
  4. import com.kbot2.scriptable.Script;
  5. import com.kbot2.scriptable.methods.Calculations;
  6. import com.kbot2.scriptable.methods.data.Walking;
  7. import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
  8. import com.kbot2.scriptable.methods.*;
  9. import com.kbot2.scriptable.methods.data.Bank;
  10. import com.kbot2.scriptable.methods.data.Inventory;
  11. import com.kbot2.scriptable.methods.data.Skills;
  12. import com.kbot2.scriptable.methods.data.GameScreen;
  13. import com.kbot2.scriptable.methods.wrappers.Obj;
  14. import com.kbot2.scriptable.HTMLDescription;
  15. import com.kbot2.scriptable.methods.wrappers.Tile;
  16. import com.kbot2.scriptable.methods.data.*;
  17. import com.kbot2.scriptable.methods.wrappers.*;
  18. import com.kbot2.scriptable.methods.data.Skills;
  19. import com.kbot2.scriptable.methods.wrappers.NPC;
  20. import com.kbot2.scriptable.methods.wrappers.Character;
  21.  
  22. import java.awt.*;
  23. import java.util.*;
  24.  
  25. public class MonkR extends Script implements PaintListener, HTMLDescription{
  26. public String trainStat;
  27. public int theSkill;
  28. public int monk = 7727;
  29. public String State;
  30. public Tile loca;
  31. public long startTime;
  32. public boolean b;
  33. public boolean needToHeal;
  34. public boolean FAttempt = false;
  35. public Tile[] healTile = new Tile []{ (new Tile (3058,3486))};
  36. public int healAt;
  37. int origLevel = 0;
  38. int origExp = 0;
  39. int origLevelHp = 0;
  40. int origExpHp = 0;
  41.  
  42. Tile[] DeathWalk = new Tile[]{new Tile(3221,3216), new Tile(3226,3217), new Tile(3231,3218),
  43. new Tile(3235,3221), new Tile(3238,3225), new Tile(3243,3225), new Tile(3248,3225), new Tile(3253,3225),
  44. new Tile(3257,3229), new Tile(3258,3234), new Tile(3259,3239), new Tile(3259,3244), new Tile(3256,3248),
  45. new Tile(3253,3253), new Tile(3250,3257), new Tile(3246,3260), new Tile(3242,3263), new Tile(3240,3269),
  46. new Tile(3241,3274), new Tile(3241,3279), new Tile(3239,3284), new Tile(3239,3289), new Tile(3239,3294),
  47. new Tile(3239,3299), new Tile(3237,3304), new Tile(3232,3307), new Tile(3228,3310), new Tile(3226,3315),
  48. new Tile(3222,3318), new Tile(3221,3323), new Tile(3218,3328), new Tile(3214,3332), new Tile(3210,3336),
  49. new Tile(3206,3340), new Tile(3206,3345), new Tile(3206,3350), new Tile(3203,3355), new Tile(3200,3359),
  50. new Tile(3196,3362), new Tile(3192,3365), new Tile(3187,3367), new Tile(3182,3364), new Tile(3177,3362),
  51. new Tile(3172,3364), new Tile(3169,3369), new Tile(3167,3374), new Tile(3164,3378), new Tile(3162,3383),
  52. new Tile(3159,3388), new Tile(3155,3392), new Tile(3153,3397), new Tile(3149,3400), new Tile(3148,3395),
  53. new Tile(3143,3393), new Tile(3139,3396), new Tile(3136,3400), new Tile(3131,3401), new Tile(3127,3404),
  54. new Tile(3122,3406), new Tile(3120,3411), new Tile(3116,3414), new Tile(3113,3418), new Tile(3108,3420),
  55. new Tile(3101,3420), new Tile(3094,3420), new Tile(3089,3420), new Tile(3083,3419), new Tile(3078,3418),
  56. new Tile(3072,3418), new Tile(3067,3419), new Tile(3063,3422), new Tile(3058,3422), new Tile(3055,3427),
  57. new Tile(3054,3433), new Tile(3051,3437), new Tile(3051,3442), new Tile(3051,3447), new Tile(3049,3452),
  58. new Tile(3044,3454), new Tile(3047,3460), new Tile(3050,3464), new Tile(3050,3469), new Tile(3051,3474),
  59. new Tile(3051,3479), new Tile(3051,3484), new Tile(3051,3489), };
  60.  
  61. // -------------------------------------------------------------------------------------\\
  62.  
  63. @Override
  64. public boolean onStart() {
  65. startTime = System.currentTimeMillis();
  66.  
  67. origLevelHp = skills.getLevel(Skills.SKILL_HITPOINTS) ;
  68. origExpHp = skills.getExperience(Skills.SKILL_HITPOINTS);
  69.  
  70.  
  71. if (trainStat.equals("Attack")) {
  72. origLevel = skills.getLevel(Skills.SKILL_ATTACK) ;
  73. origExp = skills.getExperience(Skills.SKILL_ATTACK);
  74. theSkill =0;
  75. } else if (trainStat.equals("Strength")) {
  76. origLevel = skills.getLevel(Skills.SKILL_STRENGTH) ;
  77. origExp = skills.getExperience(Skills.SKILL_STRENGTH);
  78. theSkill =2;
  79. } else if (trainStat.equals("Defence")) {
  80. origLevel = skills.getLevel(Skills.SKILL_DEFENSE) ;
  81. origExp = skills.getExperience(Skills.SKILL_DEFENSE);
  82. theSkill =1;
  83. }
  84.  
  85. return true;
  86. }
  87.  
  88. // -------------------------------------------------------------------------------------\\
  89.  
  90. @Override
  91. public void onStop(){
  92. gameScreen.takeScreenshot("Monk Slayer - " +Integer.toString(random(1,3000000)), true);
  93.  
  94. }
  95. // -------------------------------------------------------------------------------------\\
  96.  
  97.  
  98. public void setArguments(Map<String, String> args) {
  99. healAt = Integer.parseInt(args.get("amount"));
  100. trainStat = args.get("train");
  101. }
  102. // -------------------------------------------------------------------------------------\\
  103.  
  104. public void onRepaint(Graphics g){
  105. long millis = System.currentTimeMillis() - startTime;
  106. long hours = millis / (1000 * 60 * 60);
  107. millis -= hours * (1000 * 60 * 60);
  108. long minutes = millis / (1000 * 60);
  109. millis -= minutes * (1000 * 60);
  110. long seconds = millis / 1000;
  111.  
  112.  
  113. g.setColor(new Color(0, 0, 0, 75));
  114. g.fill3DRect(553, 216, 660, 330, true);
  115.  
  116.  
  117. int x = 556;
  118. int y = 230;
  119.  
  120. x += 5;
  121. y += 15;
  122. g.setColor(Color.CYAN);
  123. g.drawString("Monk Rapist v." + getVersion(), x, y);
  124. g.setColor(Color.CYAN);
  125. y += 20;
  126. g.drawString("Run time: " + (hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds, x, y);
  127. y += 15;
  128. g.drawString("Current State: " + State, x, y);
  129. y += 15;
  130. g.drawString(trainStat+ " levels gained: " + (skills.getLevel(theSkill) - origLevel), x, y);
  131. y += 15;
  132. g.drawString(trainStat+ " experience gained: " + (skills.getExperience(theSkill) - origExp), x, y);
  133. y += 15;
  134. g.drawString("Experience til "+trainStat+ " lvl: " + skills.getExperienceToNextLevel(theSkill), x, y);
  135. y += 15;
  136. g.drawString("Hp levels gained: " + (getRealLevel(3) - origLevelHp), x, y);
  137. y += 15;
  138. g.drawString("Hp Experience gained: " + (skills.getExperience(Skills.SKILL_HITPOINTS) - origExpHp), x, y);
  139.  
  140. y += 15;
  141. y += 20;
  142. g.drawString("Made by nibuS", x, y);
  143. }
  144.  
  145.  
  146.  
  147. // -------------------------------------------------------------------------------------\\
  148.  
  149. private void deathwalk() {
  150. sleep(50,100);
  151. walking.randomizePath(DeathWalk, 2, 2);
  152. walking.walkPath(DeathWalk);
  153. State = ("Deathwalk has been initiated");
  154.  
  155. }
  156.  
  157. // -------------------------------------------------------------------------------------\\
  158.  
  159. public boolean healthCheck() {
  160. if (skills.getLevel(Skills.SKILL_HITPOINTS) <= random(healAt + 2,
  161. healAt - 2)) {
  162.  
  163. State = ("Healing | Hp Is Currently @ "
  164. + skills.getLevel(Skills.SKILL_HITPOINTS));
  165.  
  166. return true;
  167. }
  168. return false;
  169. }
  170.  
  171. // -------------------------------------------------------------------------------------\\
  172.  
  173. public boolean attackNpc() {
  174. if (getMyPlayer().isInCombat()) {
  175. State = "In Fight";
  176. sleep(500, 1000);
  177. return true;
  178. }
  179.  
  180. if (getMyPlayer().isMoving()){
  181. sleep(random(0,3000));
  182. }
  183.  
  184. if (!getMyPlayer().isInCombat()) {
  185. State = "Attacking";
  186. NPC monster = npcs.getClosest(17, monk);
  187. if (monster != null && !monster.isInCombat()) {
  188. if (walking.atTile(monster.getLocation(), Calculations.random(0.1, 0.9), Calculations.random(0.1, 0.9), random(60, 128), "Attack")){
  189. FAttempt = true;
  190. sleep(random(300,3000));
  191. return true;
  192. }
  193. }
  194. if (monster == null) {
  195. return false;
  196. }
  197. }
  198. return false;
  199. }
  200.  
  201. // -------------------------------------------------------------------------------------\\
  202.  
  203. public boolean checkNpc() {
  204.  
  205. if (!getMyPlayer().isInCombat()) {
  206. NPC monks = npcs.getClosest(17, monk);
  207. if (monks != null && !monks.isInCombat()) {
  208. return false;
  209. }
  210. }
  211. return true;
  212. }
  213.  
  214. // -------------------------------------------------------------------------------------\\
  215.  
  216. private Tile randomTile(Tile location) {
  217. return randomTile(location, 2);
  218. }
  219. // -------------------------------------------------------------------------------------\\
  220. private Tile randomTile(Tile location, int rand) {
  221. return randomTile(location, rand, rand);
  222. }
  223. // -------------------------------------------------------------------------------------\\
  224. private Tile randomTile(Tile location, int xRand, int yRand) {
  225. int x = location.getX(), y = location.getY();
  226. return new Tile(x + random((-1 * xRand), xRand), y
  227. + random((-1 * yRand), yRand));
  228. }
  229.  
  230.  
  231. // -------------------------------------------------------------------------------------\\
  232.  
  233. public void walking(){
  234. Tile[] monktiles= new Tile[] {new Tile(3046,3497), new Tile(3047,3490), new Tile(3047,3484), new Tile(3052,3491), new Tile(3057,3491), new Tile(3052,3496)};
  235. if (!getMyPlayer().isInCombat()) {
  236. int randomsno = random(0, 5);
  237. State = ("Walking to Tile "+randomsno);
  238. // int distancetoLoc = getMyPlayer().getLocation().distanceTo( monktiles[randomsno]);
  239. if(getMyPlayer().getAnimation() == -1 && (!getMyPlayer().isMoving())){
  240. walking.walkToMM(randomTile(monktiles[randomsno].getLocation(), 2, 1));
  241. sleep(random(1000,3200));
  242. }
  243.  
  244. }
  245. }
  246.  
  247.  
  248. /**
  249. By Pauwelz - thnx
  250. */
  251. public int getRealLevel(int skill) {
  252. int[] skillss = getClient().getMaxLevels();
  253. if (skillss == null || skillss.length == 0 || skill < 0 || skill >= skillss.length) {
  254. return -1;
  255. }
  256. return skillss[skill];
  257. }
  258.  
  259. // -------------------------------------------------------------------------------------\\
  260.  
  261. public void heal(){
  262. walking.randomizePath(healTile, 2, 2);
  263. walking.walkPath(healTile);
  264. sleep(random(500,3000));
  265. if (!getMyPlayer().isMoving()) {
  266. State = ("Talking to Healer");
  267. NPC monka = npcs.getClosest(7, 801);
  268. if (monka != null){
  269. while (getRealLevel(3) != skills.getLevel(Skills.SKILL_HITPOINTS )){
  270. if (monka.doAction("Talk-to")){
  271. sleep(random(3000,5000));
  272. clickInterface();
  273. }
  274. }
  275. }
  276. }
  277. }
  278. // -------------------------------------------------------------------------------------\\
  279.  
  280. public void checkDeath(){
  281. int distancetoLumby = getMyPlayer().getLocation().distanceTo(new Tile(3221, 3217));
  282. if(getMyPlayer().getAnimation() == -1 && distancetoLumby < 5){
  283. State = ("Died?");
  284. sleep(50,100);
  285. deathwalk();
  286. }
  287. }
  288.  
  289. // -------------------------------------------------------------------------------------\\
  290.  
  291. public boolean clickInterface(){
  292. if(interfaces.interfaceExists(241, 5)) {
  293. try{
  294. log("interface 1");
  295. interfaces.getInterface(241, 5).doClick();
  296. sleep(random(500,1500));
  297. } catch ( Exception e ) {
  298. log("interface fail 1");
  299. return false;
  300. }
  301. }
  302. if(interfaces.interfaceExists(230, 2)) {
  303. try{
  304. log("interface 2");
  305. interfaces.getInterface(230, 2).doClick();
  306. sleep(random(500,1500));
  307. } catch ( Exception e ) {
  308. log("interface fail 2");
  309. return false;
  310. }
  311. }
  312. if(interfaces.interfaceExists(64, 5)) {
  313. try {
  314. log("interface 3");
  315. interfaces.getInterface(64, 5).doClick();
  316. sleep(random(500,1500));
  317. } catch ( Exception e ) {
  318. log("interface fail 3");
  319. return false;
  320. }
  321. }
  322. if(interfaces.interfaceExists(241, 5)) {
  323. try {
  324. log("interface 4");
  325. interfaces.getInterface(241, 5).doClick();
  326. sleep(random(500,1500));
  327. } catch ( Exception e ) {
  328. log("interface fail 4");
  329. return false;
  330. }
  331. }
  332. if(interfaces.interfaceExists(210, 2)) {
  333. try {
  334. log("interface 5");
  335. interfaces.getInterface(210, 2).doClick();
  336. sleep(random(500,1500));
  337. } catch ( Exception e ) {
  338. log("interface fail 5");
  339. return false;
  340. }
  341. }
  342. return true;
  343. }
  344.  
  345. // -------------------------------------------------------------------------------------\\
  346.  
  347. public int loop() {
  348. camera.setAltitude(true);
  349.  
  350. setMouseSpeed(random(0,3));
  351.  
  352. checkDeath();
  353.  
  354. if(healthCheck()){
  355. heal();
  356. }
  357.  
  358.  
  359. if (!attackNpc()) {
  360. walking();
  361. }
  362.  
  363. if (walking.getEnergy() > random(60,80)){
  364. walking.setRunning(true);
  365. }
  366. return random(0,3000);
  367. }
  368. // -------------------------------------------------------------------------------------\\
  369.  
  370. public boolean tileOnScreen(final Tile t) {
  371. final Point p = botEnv.calculations.tileToScreen(t);
  372. return p.getX() > 0 && p.getY() > 0;
  373. }
  374. // -------------------------------------------------------------------------------------\\
  375. @Override
  376. public boolean active() {
  377. return true;
  378. }
  379. // -------------------------------------------------------------------------------------\\
  380. public String getName() {
  381. return "Monk Rapist";
  382. }
  383.  
  384. // -------------------------------------------------------------------------------------\\
  385.  
  386. public double getVersion() {
  387. { return 1.5; }
  388. }
  389.  
  390. // -------------------------------------------------------------------------------------\\
  391.  
  392. public String getAuthor() {
  393. return "Subin";
  394. }
  395. // -------------------------------------------------------------------------------------\\
  396.  
  397. public String getDescription() {
  398. return "Kills monks and heals from the monks when it reaches the set hp or below ";
  399. }
  400.  
  401.  
  402. public String getDocument(){
  403. String html = "<html>";
  404. html += "<head>";
  405. html += "<style type=\"text/css\"> hr {color: white} p {margin-left: 20px}</style>";
  406. html += "</head>";
  407. html += "<body>";
  408. html += "<center>";
  409. html += "<b><font size=\"4\" color=\"red\">" + getName() + " v" + getVersion() + "</font></b><br>";
  410. html += "</center>";
  411. html += "<center><table border=\"0\"><tr><td colspan=\"2\"><font size=\"4\" color=\"blue\">This script will kill Monks at the Monsantry<BR>" +
  412. " Heals from the monk at the set amout.<BR>" +
  413. " Just stand in Monsantry and start.<BR>" +
  414. " </font></center></td></tr>";
  415.  
  416. html += "<tr><td><b>What shall we train : </b></td><td><center><select name=\"train\">";
  417. html += "<option>Strength";
  418. html += "<option>Attack";
  419. html += "<option>Defence";
  420. // html += "<option>Range";
  421. // html += "<option>Magic";
  422. html += "</select></center></td></tr>";
  423. html += "<tr><td><b>At what hp shall we heal?</b><tr><td><center>";
  424. html += "<input type=\"text\" name=\"amount\" value=\"30\"></center><br>";
  425. html += "</table>";
  426. html += "</center></body>";
  427. html += "</html>";
  428.  
  429. return html;
  430. }
  431. }
  432. // -------------------------------------------------------------------------------------\\
Add Comment
Please, Sign In to add comment