Guest User

Untitled

a guest
Jun 22nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.86 KB | None | 0 0
  1. package com.scripts;
  2.  
  3. import com.kbot2.scriptable.methods.Calculations;
  4. import com.kbot2.scriptable.Script;
  5. import com.kbot2.scriptable.methods.data.Skills;
  6. import com.kbot2.scriptable.methods.data.GameScreen;
  7. import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
  8. import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
  9. import com.kbot2.scriptable.methods.wrappers.GroundItem;
  10. import com.kbot2.scriptable.methods.wrappers.NPC;
  11. import com.kbot2.scriptable.methods.wrappers.Interface;
  12. import com.kbot2.scriptable.methods.wrappers.Tile;
  13. import com.kbot2.scriptable.methods.data.Settings;
  14.  
  15. import java.awt.*;
  16.  
  17. /**
  18. * Created by IntelliJ IDEA.
  19. * User: Koh-Koh
  20. * Date: 12/06/2009
  21. * Time: 9:25:03 AM
  22. * To change this template use File | Settings | File Templates.
  23. */
  24. public class KohtaOgreRanger extends Script implements PaintListener, ServerMessageListener {
  25.  
  26. int hitpointStartExp = 0;
  27. int rangeStartExp = 0;
  28. final int[] OGRE_ID = new int[]{2801};
  29. int snappy = 0;
  30. int ranarry = 0;
  31. int watery = 0;
  32. int strawy = 0;
  33. int dwarfey = 0;
  34. int kwuarmy = 0;
  35. int latadymey = 0;
  36. int state=1;
  37. int prev=0;
  38. private long nextABTime = 0;
  39. private NPC currentNPC = null;
  40. int [] itemIDs = new int[] {5300, 5321, 5303, 5299, 5302, 5295, 5304};
  41. private final static Rectangle trainingArea = new Rectangle(2523, 3371, 10, 4);
  42. Tile walkToCage = new Tile(2525 + random(0,5), 3372 + random(0,0));
  43. int specialCost = 0;
  44. int lastSpecialValue = 0;
  45. long nextSpecialTime = 0;
  46.  
  47. long startTime = System.currentTimeMillis();
  48.  
  49. public boolean itemsOnFloor() {
  50. Interface i;
  51. GroundItem itemTile = groundItems.getClosestItem(25, itemIDs);
  52. if (itemTile != null) {
  53. final Point itemScreen = itemTile.getScreenPos();
  54. if (Calculations.onScreen(itemScreen)) {
  55. Point magTab = new Point(random(730, 751), random(173, 194));
  56. clickMouse(magTab, true);
  57. i = interfaces.getInterface(192, 19);
  58. if (i != null) {
  59. i.doClick();
  60. }
  61. itemTile.doAction("Telekinetic Grab");
  62. try {
  63. Thread.sleep(random(3000,4500));
  64. }
  65. catch (InterruptedException ie) { }
  66.  
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72.  
  73. private boolean canUseSpecial() {
  74. final int SPECIAL_BAR_VAL = botEnv.settings.getSetting(300);
  75. final int SPECIAL_IS_ON = botEnv.settings.getSetting(Settings.SETTING_SPECIAL_ATTACK_ENABLED);
  76. switch (SPECIAL_IS_ON) {
  77. case 0:
  78. if (specialCost == 0) {
  79. if (SPECIAL_BAR_VAL < lastSpecialValue) {
  80. specialCost = lastSpecialValue - SPECIAL_BAR_VAL;
  81. return false;
  82. }
  83. }
  84. if (SPECIAL_BAR_VAL >= specialCost && System.currentTimeMillis() >= nextSpecialTime) {
  85. nextSpecialTime = System.currentTimeMillis() + random(5000, 45000);
  86. return true;
  87. }
  88. case 1:
  89. lastSpecialValue = SPECIAL_BAR_VAL;
  90. return false;
  91. }
  92. return false;
  93. }
  94. public int loop() {
  95. NPC Ogre = getClosestFree(50, OGRE_ID);
  96. GroundItem itemTile = groundItems.getClosestItem(25, itemIDs);
  97. interfaces.clickContinue();
  98. if(!trainingArea.contains(new Point(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY())) && !getMyPlayer().isInCombat()) {
  99. walking.walkToMM(walkToCage);
  100. return random (100, 200); }
  101. if (System.currentTimeMillis() >= nextABTime)
  102. antiBan();
  103. if(itemTile != null && inventory.getCount(true, 563) > 0) {
  104. Interface i;
  105. final Point itemScreen = itemTile.getScreenPos();
  106. if (Calculations.onScreen(itemScreen)) {
  107. Point magTab = new Point(random(730, 751), random(173, 194));
  108. clickMouse(magTab, true);
  109. i = interfaces.getInterface(192, 19);
  110. if (i != null) {
  111. i.doClick();
  112. }
  113. itemTile.doAction("Telekinetic Grab");
  114. sleep(2000, 2590);
  115. Ogre.doAction("Attack");
  116. return random (350,550);
  117. }
  118. return random(200, 300);
  119. }
  120. if(Ogre != null && Ogre.getInteracting() == null && getMyPlayer().getInteracting() == null && Ogre.getAnimation() != 8576) {
  121. if(Ogre.doAction("Attack")) {
  122. try {
  123. Thread.sleep(random(700,900));
  124. }
  125. catch (InterruptedException ie) { }
  126. currentNPC = Ogre;
  127. }
  128. return random(25, 50);
  129. }
  130. if(getMyPlayer().getInteracting() != null) {
  131. if(canUseSpecial() && random(0,2) == 1) {
  132. if (gameScreen.getCurrentTab() != GameScreen.TAB_ATTACK) {
  133. gameScreen.openTab(GameScreen.TAB_ATTACK);
  134. sleep(random(300, 900));
  135. }
  136. Point specPoint = new Point(random(578, 705), random(414, 426));
  137. clickMouse(specPoint, true);
  138. return random(200, 1300);
  139. }
  140. return random(100, 200);
  141. }
  142. return random (25, 50);
  143. }
  144.  
  145.  
  146. public NPC getClosestFree(int range, int... ids) {
  147. Tile myLoc = players.getMyPlayer().getLocation();
  148. double closestDist = 256;
  149. NPC[] allNPCs = npcs.getNPCs();
  150. NPC closestNPC = null;
  151. try {
  152. mainLoop: for(NPC tempNPC : allNPCs) {
  153. for(int i : ids) {
  154. if (tempNPC.isInCombat())
  155. continue;
  156. int tempDist = tempNPC.getLocation().distanceTo(myLoc);
  157. if(i == tempNPC.getID() && tempDist <= range && tempDist < closestDist) {
  158. closestNPC = tempNPC;
  159. closestDist = tempDist;
  160. continue mainLoop;
  161. }
  162. }
  163. }
  164. } catch (Exception betterSafeThanSorry) {
  165. return null;
  166. }
  167. return closestNPC;
  168. }
  169.  
  170. private int antiBan() {
  171. nextABTime = System.currentTimeMillis() + (1000 * random(2, 40) + random(0, 1000));
  172. final int randomAction = random(0, 5);
  173. if(getMyPlayer().getInteracting() != null) {
  174. switch (randomAction) {
  175. case 0:
  176. if (gameScreen.getCurrentTab() != GameScreen.TAB_INVENTORY) {
  177. gameScreen.openTab(GameScreen.TAB_INVENTORY);
  178. sleep(random(310, 610));
  179. final Point invPoint = new Point(random(558, 723), random(215, 440));
  180. moveMouse(invPoint);
  181. return random(510, 1300);
  182. } else {
  183. final int random = random(0, 10);
  184. final Point rndPoint = new Point(random(558, 723), random(215, 440));
  185. if (random == 0) {
  186. if (gameScreen.getCurrentTab() != GameScreen.TAB_STATS) {
  187. gameScreen.openTab(GameScreen.TAB_STATS);
  188. sleep(random(310, 610));
  189. }
  190. moveMouse(rndPoint);
  191. return random(200, 2300);
  192. } else if (random >= 1 && random <= 6) {
  193. final int randomTab = random(0, 13);
  194. if (randomTab != gameScreen.getCurrentTab()) {
  195. gameScreen.openTab(random(0, 13));
  196. sleep(random(310, 610));
  197. }
  198. moveMouse(rndPoint);
  199. return random(300, 1200);
  200. } else {
  201. final int randomTab = random(0, 13);
  202. if (randomTab != gameScreen.getCurrentTab()) {
  203. gameScreen.openTab(random(0, 13));
  204. return random(310, 1200);
  205. }
  206. }
  207. }
  208.  
  209. case 1:
  210. Point randomMouse = null;
  211. final int rndMovement = random(1, 5);
  212. for (int a = 0; a < rndMovement; a++) {
  213. randomMouse = new Point(random(15, 730), random(15, 465));
  214. moveMouse(randomMouse);
  215. sleep(random(50, 800));
  216. }
  217. return random(130, 810);
  218.  
  219. case 2:
  220. final int currentAngle = botEnv.camera.getAngle();
  221. switch (random(0, 1)) {
  222. case 0:
  223. botEnv.camera.setAngle(currentAngle + random(0, 650));
  224. return random(710, 1100);
  225. case 1:
  226. botEnv.camera.setAngle(currentAngle - random(0, 650));
  227. return random(710, 1100);
  228. }
  229.  
  230. case 3:
  231. int currentAngle2 = botEnv.camera.getAngle();
  232. switch (random(0, 1)) {
  233. case 0:
  234. botEnv.camera.setAngle(currentAngle2 + random(0, 650));
  235. return random(410, 1130);
  236. case 1:
  237. botEnv.camera.setAngle(currentAngle2 - random(0, 650));
  238. return random(410, 1130);
  239. }
  240.  
  241. case 4:
  242. return random(310, 1400);
  243.  
  244. case 5:
  245. if (currentNPC != null && getMyPlayer().getInteracting() != null) {
  246. botEnv.camera.setAngleTo(currentNPC.getLocation());
  247. return random(120, 1300);
  248. } else {
  249. currentAngle2 = botEnv.camera.getAngle();
  250. switch (random(0, 1)) {
  251. case 0:
  252. botEnv.camera.setAngle(currentAngle2 + random(0, 650));
  253. return random(410, 1130);
  254. case 1:
  255. botEnv.camera.setAngle(currentAngle2 - random(0, 650));
  256. return random(410, 1130);
  257. }
  258. }
  259.  
  260. }
  261. return random(100, 200);
  262. }
  263. return random(100, 200);
  264. }
  265.  
  266.  
  267. public boolean onStart() {
  268. rangeStartExp = skills.getExperience(Skills.SKILL_RANGE);
  269. hitpointStartExp = skills.getExperience(Skills.SKILL_HITPOINTS);
  270. return true;
  271. }
  272.  
  273. public String getName() {
  274. return "King Lathas Orge Ranger";
  275. }
  276.  
  277. public String getAuthor() {
  278. return "Kohta && Fatality";
  279. }
  280.  
  281. public String getDescription() {
  282. return "Kills Orges using range at the training camp.";
  283. }
  284.  
  285. public int getRealLevel(int skill) {
  286. int exp = skills.getExperience(skill);
  287. for(int i = 0; i < expTable.length; i++)
  288. if(exp < expTable[i])
  289. return i-1;
  290. return 99;
  291. }
  292.  
  293. public int getRealExperienceToNextLevel(int skill) {
  294. int level = getRealLevel(skill);
  295.  
  296. if(level == -1)
  297. return -1;
  298.  
  299. if(level == 99)
  300. return 0;
  301.  
  302. int experience = skills.getExperience(skill);
  303. int needed = expTable[level+1];
  304.  
  305. return needed - experience;
  306. }
  307.  
  308. private static final int[] expTable = {
  309. 0 , 0, 83, 174, 276, 388, 512, 650, 801,
  310. 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973,
  311. 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031,
  312. 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408,
  313. 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127,
  314. 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636,
  315. 184040, 203254, 224466, 247886, 273742, 302288, 333804, 368599,
  316. 407015, 449428, 496254, 547953, 605032, 668051, 737627, 814445,
  317. 899257, 992895, 1096278, 1210421, 1336443, 1475581, 1629200,
  318. 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594,
  319. 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253,
  320. 7195629, 7944614, 8771558, 9684577, 10692629, 11805606, 13034431
  321. };
  322.  
  323. public int getPercentageToNextLevel2(int skill){
  324. int level = skills.getLevel(skill);
  325. if(level == -1)
  326. return -1;
  327.  
  328. if(level == 99)
  329. return 0;
  330.  
  331. int experience = skills.getExperience(skill);
  332. int needed = expTable[level+1];
  333. int lastLvl = expTable[level];
  334. double notYet = (double)(needed - experience) / (double)(experience - lastLvl)* (double)100;
  335.  
  336. return (int)notYet;
  337. }
  338.  
  339. public void onRepaint(Graphics g) {
  340. long runTime = System.currentTimeMillis() - startTime;
  341.  
  342. int secs = ((int) ((runTime / 1000) % 60));
  343. int mins = ((int) (((runTime / 1000) / 60) % 60));
  344. int hours = ((int) ((((runTime / 1000) / 60) / 60) % 60));
  345.  
  346.  
  347.  
  348. int RANGE_CUR_LEVEL = skills.getLevel(Skills.SKILL_RANGE);
  349. int rangeNegativeExp = skills.getExperience(Skills.SKILL_RANGE);
  350. int RNGXP_TO_LVL = skills.getExperienceToNextLevel(Skills.SKILL_RANGE);
  351. int RANGE_GAINED_XP = rangeNegativeExp - rangeStartExp;
  352.  
  353. if (rangeStartExp == 0)
  354. rangeStartExp = skills.getExperience(Skills.SKILL_RANGE);
  355.  
  356. int hpNegativeExp = skills.getExperience(Skills.SKILL_HITPOINTS);
  357. int HITPOINT_CUR_LEVEL = skills.getLevel(Skills.SKILL_HITPOINTS);
  358. int HITPOINT_XP_TO_LVL = skills.getExperienceToNextLevel(Skills.SKILL_HITPOINTS);
  359. int HITPOINT_XP_GAINED = hpNegativeExp - hitpointStartExp;
  360.  
  361. if (hitpointStartExp == 0)
  362. hitpointStartExp = skills.getExperience(Skills.SKILL_HITPOINTS);
  363.  
  364. int x = 13;
  365. int y = 13;
  366. //g.setColor(new Color(222, 64, 64, 100));
  367. //g.fill3DRect(x, y, 246, 230, true);
  368. x += 5;
  369. y += 15;
  370. g.setColor(Color.white);
  371. g.setFont(new Font("Lucida Grande", Font.BOLD, 11));
  372. y += 11;
  373. g.drawString("Kohta's Private Orge Ranger v2.0", x, y);
  374. y += 11;
  375. g.setColor(Color.black);
  376. y += 11;
  377. g.drawString("Run time: " + (hours < 10 ? "0" : "") + hours + ":" + (mins < 10 ? "0" : "") + mins + ":" + (secs < 10 ? "0" : "") + secs, x, y);
  378. y += 11;
  379. g.setColor(Color.blue);
  380. y += 11;
  381. g.drawString("Current Hitpoint level: " + HITPOINT_CUR_LEVEL, x, y);
  382. y += 11;
  383. g.drawString("Experience till next Hitpoint level: " + HITPOINT_XP_TO_LVL, x, y);
  384. y += 11;
  385. g.drawString("Hitpoint experience gained: " + HITPOINT_XP_GAINED, x, y);
  386. y += 11;
  387. g.setColor(Color.green);
  388. y += 11;
  389. g.drawString("Current Range level: " + RANGE_CUR_LEVEL, x, y);
  390. y += 11;
  391. g.drawString("Experience till next Range level: " + RNGXP_TO_LVL, x, y);
  392. y += 11;
  393. g.drawString("Range experience gained: " + RANGE_GAINED_XP, x, y);
  394. y += 11;
  395. g.drawString ((getRealExperienceToNextLevel(Skills.SKILL_RANGE)/240) + " Ogres Till Level: " + (getRealLevel(Skills.SKILL_RANGE) + 1), x, y);
  396. y += 11;
  397.  
  398. int Rangepercentage = getPercentageToNextLevel2(Skills.SKILL_RANGE);
  399. int barsize = 15;
  400. int barheight = 100;
  401. int transparancy = 160;
  402. int xBar = 20;
  403. int yBar = 368;
  404. g.setColor(new Color(0, 255, 0, transparancy));
  405. g.fillRect(xBar, yBar, barsize, barheight);
  406. g.setColor(new Color(255, 0, 0, transparancy));
  407. g.fillRect(xBar, yBar, barsize, barheight/100*Rangepercentage);
  408. g.setColor(new Color(255, 255, 255, transparancy));
  409. g.drawRect(xBar, yBar, barsize, barheight);
  410.  
  411. }
  412.  
  413. public void onServerMessage(String e) {
  414. if (e.contains("There is no ammo left in your quiver.")) {
  415. log("Oh shi-! No ammo logging out!");
  416. gameScreen.logout();
  417. stopAllScripts();
  418. } else if (e.contains("You do not have enough law runes to cast this spell.")) {
  419. log("Oh shi-! Out of runes, logging out!");
  420. gameScreen.logout();
  421. stopAllScripts();
  422. } else if (e.contains("I can't reach that!")) {
  423. log("We are lost. Logging out.");
  424. gameScreen.logout();
  425. stopAllScripts();
  426. }
  427. }
  428. }
Add Comment
Please, Sign In to add comment