Guest User

Untitled

a guest
Jun 22nd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.34 KB | None | 0 0
  1. package com.scripts;
  2.  
  3.  
  4. import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
  5. import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
  6. import com.kbot2.scriptable.Script;
  7. import com.kbot2.scriptable.methods.Calculations;
  8. import com.kbot2.scriptable.methods.data.Skills;
  9. import com.kbot2.scriptable.methods.wrappers.Obj;
  10.  
  11. import java.awt.*;
  12.  
  13.  
  14. /**
  15. * Created by IntelliJ IDEA.
  16. * User: Koh-Koh
  17. * Date: 08/06/2009
  18. * Time: 11:37:54 AM
  19. * To change this template use File | Settings | File Templates.
  20. */
  21. public class KohtaGraniteMiner extends Script implements PaintListener, ServerMessageListener {
  22.  
  23.  
  24. int NUMMINED = 0;
  25. int miningStartXp = 0;
  26. final int[] WATER_SKIN_IDS = new int[] {1823, 1825, 1827, 1829, 1831};
  27. long startTime = System.currentTimeMillis();
  28.  
  29. public int loop() {
  30. if (getMyPlayer().getAnimation() != -1) return 100;
  31. if (!inventory.contains(WATER_SKIN_IDS))
  32. stopAllScripts();
  33. {
  34. if (inventory.getCount() == 28) {
  35. inventory.dropAllExcept(WATER_SKIN_IDS);
  36. }
  37. Obj rock = objects.getClosestObject(15, 10947);
  38. if (rock != null) {
  39. if (Calculations.onScreen(rock.getScreenPos())) {
  40. rock.doAction("mine");
  41. } else
  42. walking.walkToMM(rock.getLocation());
  43. }
  44. }
  45. return random(1000, 1500);
  46. }
  47.  
  48. public boolean onStart() {
  49. miningStartXp = skills.getExperience(Skills.SKILL_MINING);
  50.  
  51. return true;
  52. }
  53.  
  54. public String getName() {
  55. return "Granite Smasher";
  56. }
  57.  
  58. public String getAuthor() {
  59. return "Kohta";
  60. }
  61.  
  62. public String getDescription() {
  63. return "Mines Granite in the desert.";
  64. }
  65.  
  66. public double getVersion() { return 1.6; }
  67.  
  68.  
  69. public void onServerMessage(String e) {
  70. if (e.contains("You manage to quarry some granite.")) {
  71. NUMMINED++;
  72. }
  73. else if (e.contains("Blah blah blah")) {
  74. log("Oh noes we are dying! Logging out!");
  75. gameScreen.logout();
  76. stopAllScripts();
  77. }
  78. }
  79. public int getRealLevel(int skill) {
  80. int exp = skills.getExperience(skill);
  81. for(int i = 0; i < expTable.length; i++)
  82. if(exp < expTable[i])
  83. return i-1;
  84. return 99;
  85. }
  86.  
  87. public int getRealExperienceToNextLevel(int skill) {
  88. int level = getRealLevel(skill);
  89.  
  90. if(level == -1)
  91. return -1;
  92.  
  93. if(level == 99)
  94. return 0;
  95.  
  96. int experience = skills.getExperience(skill);
  97. int needed = expTable[level+1];
  98.  
  99. return needed - experience;
  100. }
  101.  
  102. private static final int[] expTable = {
  103. 0 , 0, 83, 174, 276, 388, 512, 650, 801,
  104. 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973,
  105. 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031,
  106. 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408,
  107. 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127,
  108. 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636,
  109. 184040, 203254, 224466, 247886, 273742, 302288, 333804, 368599,
  110. 407015, 449428, 496254, 547953, 605032, 668051, 737627, 814445,
  111. 899257, 992895, 1096278, 1210421, 1336443, 1475581, 1629200,
  112. 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594,
  113. 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253,
  114. 7195629, 7944614, 8771558, 9684577, 10692629, 11805606, 13034431
  115. };
  116.  
  117. public int getPercentageToNextLevel2(int skill){
  118. int level = skills.getLevel(skill);
  119. if(level == -1)
  120. return -1;
  121.  
  122. if(level == 99)
  123. return 0;
  124.  
  125. int experience = skills.getExperience(skill);
  126. int needed = expTable[level+1];
  127. int lastLvl = expTable[level];
  128. double notYet = (double)(experience - lastLvl) / (double)(needed - experience)* (double)100;
  129. log(" " +(int)notYet);
  130. return (int)notYet;
  131. }
  132.  
  133.  
  134.  
  135. public void onRepaint(Graphics g) {
  136. if (isLoggedIn()) {
  137.  
  138. }
  139. long runTime = System.currentTimeMillis() - startTime;
  140.  
  141. int secs = ((int) ((runTime / 1000) % 60));
  142. int mins = ((int) (((runTime / 1000) / 60) % 60));
  143. int hours = ((int) ((((runTime / 1000) / 60) / 60) % 60));
  144.  
  145.  
  146.  
  147. int miningNegativeXp = skills.getExperience(Skills.SKILL_MINING);
  148. int CUR_LVL = skills.getLevel(Skills.SKILL_MINING);
  149. int XP_TO_LVL = skills.getExperienceToNextLevel(Skills.SKILL_MINING);
  150. int GAINED_XP = miningStartXp - miningNegativeXp;
  151.  
  152.  
  153. int x = 13;
  154. int y = 210;
  155. //g.setColor (new Color(222, 64, 64, 100));
  156. //g.fill3DRect(x, y, 246, 102, true);
  157. x += 5;
  158. y += 15;
  159. g.setColor(Color.white);
  160. g.setFont(new Font("Comic Sans", Font.BOLD, 11));
  161. y += 11;
  162. g.drawString("Granite Smasher by Kohta v1.6", x, y);
  163. y +=11;
  164. g.setColor(Color.black);
  165. y +=11;
  166. g.drawString("Run time: " + (hours < 10 ? "0" : "") + hours + ":" + (mins < 10 ? "0" : "") + mins + ":" + (secs < 10 ? "0" : "") + secs, x , y);
  167. y += 11;
  168. g.drawString("Granite mined: " + NUMMINED, x, y);
  169. y += 11;
  170. g.drawString("Current level: " + CUR_LVL, x, y);
  171. y += 11;
  172. g.drawString("Experience till next level: " + XP_TO_LVL, x, y);
  173. y += 12;
  174. g.drawString("Experience gained: " + GAINED_XP, x, y);
  175. y += 12;
  176. g.drawString ((getRealExperienceToNextLevel(Skills.SKILL_MINING)/240) + " Granite till next level: " + (getRealLevel(Skills.SKILL_MINING) + 1), x, y);
  177. y += 11;
  178.  
  179. int Rangepercentage = getPercentageToNextLevel2(Skills.SKILL_MINING);
  180. int barsize = 15;
  181. int barheight = 100;
  182. int transparancy = 160;
  183. int xBar = 25;
  184. int yBar = 70;
  185. g.setColor(new Color(0, 255, 0, transparancy));
  186. g.fillRect(xBar, yBar, barsize, barheight);
  187. g.setColor(new Color(255, 0, 0, transparancy));
  188. g.fillRect(xBar, yBar, barsize, Rangepercentage);
  189. g.setColor(new Color(255, 255, 255, transparancy));
  190. g.drawRect(xBar, yBar, barsize, barheight);
  191.  
  192. }
  193. }
Add Comment
Please, Sign In to add comment