Guest User

Untitled

a guest
Jul 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.11 KB | None | 0 0
  1. import java.util.Map;
  2. import java.awt.*;
  3. import java.util.*;
  4.  
  5. import org.rsbot.script.Constants;
  6. import org.rsbot.script.Script;
  7. import org.rsbot.event.listeners.PaintListener;
  8. import org.rsbot.script.ScriptManifest;
  9. import org.rsbot.script.wrappers.RSInterface;
  10. import org.rsbot.script.wrappers.RSItem;
  11. import org.rsbot.script.wrappers.RSItemTile;
  12. import org.rsbot.script.wrappers.RSNPC;
  13. import java.awt.Graphics;
  14. import org.rsbot.script.wrappers.RSTile;
  15.  
  16.  
  17.  
  18.  
  19. @ScriptManifest(authors = {"Hellxx"}, category = "Combat", name = "AvianKiller", version = 0.1, description = "<html><body><b>Kill every mob you want</b><br /><h3>Thanks for scripters, used some code =]</h3><BR></font></font></body></html>")
  20.  
  21. public class AvianKiller extends Script implements PaintListener {
  22.  
  23. int MID[] = {6241,6242,6244,6234};
  24. int mobdied = 6956;
  25. RSItemTile itemtile1;
  26. RSItemTile itemtile2;
  27. RSItemTile itemtile3;
  28. RSItemTile itemtile4;
  29. RSItemTile itemtile5;
  30. RSItemTile itemtile6;
  31. RSItemTile itemtile7;
  32. RSItemTile itemtile8;
  33. RSItemTile itemtile9;
  34. RSItemTile itemtile;
  35. long startTime = System.currentTimeMillis();
  36. int startexpR, startexpA, startexpS, startexpD, startexpH;
  37. int xpGained;
  38. int xpGained2;
  39. int startexp;
  40. RSTile StartSpot;
  41. final int[] FOOD_IDS = { 1895, 1893, 1891, 4293, 2142, 291, 2140, 3228, 9980,
  42. 7223, 6297, 6293, 6295, 6299, 7521, 9988, 7228, 2878, 7568, 2343,
  43. 1861, 13433, 315, 325, 319, 3144, 347, 355, 333, 339, 351, 329,
  44. 3381, 361, 10136, 5003, 379, 365, 373, 7946, 385, 397, 391, 3369,
  45. 3371, 3373, 2309, 2325, 2333, 2327, 2331, 2323, 2335, 7178, 7180,
  46. 7188, 7190, 7198, 7200, 7208, 7210, 7218, 7220, 2003, 2011, 2289,
  47. 2291, 2293, 2295, 2297, 2299, 2301, 2303, 1891, 1893, 1895, 1897,
  48. 1899, 1901, 7072, 7062, 7078, 7064, 7084, 7082, 7066, 7068, 1942,
  49. 6701, 6703, 7054, 6705, 7056, 7060, 2130, 1985, 1993, 1989, 1978,
  50. 5763, 5765, 1913, 5747, 1905, 5739, 1909, 5743, 1907, 1911, 5745,
  51. 2955, 5749, 5751, 5753, 5755, 5757, 5759, 5761, 2084, 2034, 2048,
  52. 2036, 2217, 2213, 2205, 2209, 2054, 2040, 2080, 2277, 2225, 2255,
  53. 2221, 2253, 2219, 2281, 2227, 2223, 2191, 2233, 2092, 2032, 2074,
  54. 2030, 2281, 2235, 2064, 2028, 2187, 2185, 2229, 6883, 1971, 4608,
  55. 1883, 1885, 1942 };
  56. int peaches = 6883;
  57. final int[] tablet = { 8015 };
  58. final int[] ITEMIDS = { 2362, 561, 526, 565, 5678, 9431, 1249, 373 };
  59. int[] alchItem = {5678, 9431};
  60. String status;
  61.  
  62.  
  63. public int loop() {
  64.  
  65. try {
  66.  
  67. status = "loop";
  68. int curHP = skills.getCurrentSkillLevel(STAT_HITPOINTS);
  69. if (curHP <= 49)
  70. {
  71. wait(1000);
  72. eat();
  73.  
  74. }
  75.  
  76. if (getMyPlayer().isInCombat())
  77. {
  78. return 80;
  79. }
  80. if (getMyPlayer().isMoving())
  81. {
  82. return 80;
  83. }
  84.  
  85. final RSItemTile itemtile = getGroundItemByID(ITEMIDS);
  86. if (itemtile != null)
  87. {
  88. item();
  89. }
  90.  
  91. if(inventoryContainsOneOf(FOOD_IDS))
  92. {
  93. fight();
  94. }
  95. else
  96. {
  97. return 80;
  98. }
  99.  
  100.  
  101. }
  102. catch (final Exception e)
  103. {
  104. log("loop() error, caught.");
  105. e.printStackTrace();
  106. }
  107. return(random(100,200));
  108. }
  109.  
  110. public int item(){
  111.  
  112. status = "item..";
  113. if (getInventoryCount(alchItem) >= 1) {
  114. doAlch();
  115. }
  116. if (getInventoryCount(FOOD_IDS) <= 1)
  117. {
  118. clickInventoryItem(tablet, "Break");
  119. wait(1500);
  120. return 200;
  121. }
  122.  
  123. final RSItemTile itemtile1 = getGroundItemByID(2362);
  124. final RSItemTile itemtile2 = getGroundItemByID(563);
  125. final RSItemTile itemtile3 = getGroundItemByID(561);
  126. final RSItemTile itemtile4 = getGroundItemByID(526);
  127. final RSItemTile itemtile5 = getGroundItemByID(2362);
  128. final RSItemTile itemtile6 = getGroundItemByID(5678);
  129. final RSItemTile itemtile7 = getGroundItemByID(9431);
  130. final RSItemTile itemtile9 = getGroundItemByID(373);
  131.  
  132. if (itemtile1 != null || itemtile2 != null || itemtile3 != null || itemtile4 != null || itemtile5 != null || itemtile6 != null || itemtile7 != null || itemtile8 != null || itemtile9 != null)
  133. {
  134. if (itemtile1 != null &&(getMyPlayer().getAnimation() == -1))
  135. {
  136. atTile(itemtile1, "Take Adamantite bar");
  137. wait(random(2000,2500));
  138. }
  139.  
  140. if (itemtile2 != null &&(getMyPlayer().getAnimation() == -1))
  141. {
  142. atTile(itemtile2, "Take Law rune");
  143. wait(random(2000,2500));
  144. }
  145.  
  146. if (itemtile3 != null &&(getMyPlayer().getAnimation() == -1))
  147. {
  148. atTile(itemtile3, "Take Nature rune");
  149. wait(random(2000,2500));
  150. }
  151.  
  152. if (itemtile4 != null && (getMyPlayer().getAnimation() == -1) && getInventoryCount() < 27)
  153. {
  154. atTile(itemtile4, "Take Bones");
  155. wait(random(2000,2500));
  156. }
  157.  
  158. if (itemtile5 != null && (getMyPlayer().getAnimation() == -1))
  159. {
  160. atTile(itemtile5, "Take Blood rune");
  161. wait(random(2000,2500));
  162. }
  163.  
  164. if (itemtile6 != null && (getMyPlayer().getAnimation() == -1) && !isInventoryFull())
  165. {
  166. atTile(itemtile6, "Take Rune dagger (p+)");
  167. wait(random(2000,2500));
  168. }
  169.  
  170. if (itemtile7 != null && (getMyPlayer().getAnimation() == -1) && !isInventoryFull())
  171. {
  172. atTile(itemtile7, "Take Runite limbs");
  173. wait(random(2000,2500));
  174. }
  175. final RSItemTile itemtile8 = getGroundItemByID(1249);
  176. if (itemtile8 != null && (getMyPlayer().getAnimation() == -1) && !isInventoryFull())
  177. {
  178. atTile(itemtile8, "Take Dragon spear");
  179. wait(random(2000,2500));
  180. }
  181.  
  182. if (itemtile9 != null && (getMyPlayer().getAnimation() == -1) && !isInventoryFull())
  183. {
  184. atTile(itemtile9, "Take Swordfish");
  185. wait(random(2000,2500));
  186. }
  187. return 80;
  188. }
  189. else
  190. {
  191. return 80;
  192. }
  193. }
  194. public int eat()
  195. {
  196. status = "eat";
  197. int curHP = skills.getCurrentSkillLevel(STAT_HITPOINTS);
  198. double eat = random(skills.getRealSkillLevel(STAT_HITPOINTS) * 0.7, skills.getRealSkillLevel(STAT_HITPOINTS)* 0.6);
  199. if (curHP <= eat) {
  200. clickInventoryItem(FOOD_IDS, "Eat");
  201. wait(500);
  202. return 80;
  203. }
  204. status = "eat ended";
  205. return loop();
  206. }
  207.  
  208.  
  209.  
  210.  
  211.  
  212. public Point getAlchItemPos() {
  213. final RSItem[] iItems = getInventoryItems();
  214. for (final int element : alchItem) {
  215. final Point nip = getNearInvItemPoint(element);
  216. if (nip != null) {
  217. return nip;
  218. }
  219. for (int j = 27; j >= 0; j--) {
  220. if (iItems[j].getID() == element) {
  221. final Point aip = getInventoryItemPoint(j);
  222. return new Point(aip.x + random(10, 15), aip.y
  223. + random(10, 15));
  224. }
  225. }
  226. }
  227. return null;
  228. }
  229.  
  230. private Point getNearInvItemPoint(final int itemID) {
  231. final RSItem[] iItems = getInventoryItems();
  232.  
  233. // SPELL_HIGH_LEVEL_ALCHEMY
  234. final int spellX = RSInterface.getInterface(192).getChild(34)
  235. .getAbsoluteX()
  236. + random(7, 16);
  237. final int spellY = RSInterface.getInterface(192).getChild(34)
  238. .getAbsoluteY()
  239. + random(7, 16);
  240.  
  241. final int col = (int) Math.floor((spellX - 559) / 42);
  242. final int row = (int) Math.floor((spellY - 210) / 36);
  243.  
  244. if (col >= 0 && col <= 3 && row >= 0 && row <= 6) {
  245. if (iItems[(row * 4 + col)].getID() == itemID) {
  246. return randomiseInventoryItemPoint(getInventoryItemPoint((row * 4 + col)));
  247. }
  248. }
  249.  
  250. return null;
  251. }
  252.  
  253. public void doAlch() {
  254. openTab(Constants.TAB_MAGIC);
  255. castSpell(Constants.SPELL_HIGH_LEVEL_ALCHEMY);
  256. final Point alchItemPos = getAlchItemPos();
  257. clickMouse(alchItemPos, true);
  258. wait(1000);
  259. }
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270. private boolean clickInventoryItem(final int[] ids, final String command) {
  271. try {
  272. if (getCurrentTab() != Constants.TAB_INVENTORY
  273. && !RSInterface.getInterface(Constants.INTERFACE_BANK)
  274. .isValid()
  275. && !RSInterface.getInterface(Constants.INTERFACE_STORE)
  276. .isValid()) {
  277. openTab(Constants.TAB_INVENTORY);
  278. }
  279. final int[] items = getInventoryArray();
  280. final java.util.List<Integer> possible = new ArrayList<Integer>();
  281. for (int i = 0; i < items.length; i++) {
  282. for (final int item : ids) {
  283. if (items[i] == item) {
  284. possible.add(i);
  285. }
  286. }
  287. }
  288. if (possible.size() == 0) {
  289. return false;
  290. }
  291. final int idx = possible.get(random(0, possible.size()));
  292. final Point t = getInventoryItemPoint(idx);
  293. moveMouse(t, 5, 5);
  294. wait(random(100, 290));
  295. if (getMenuActions().get(0).equals(command)) {
  296. clickMouse(true);
  297. return true;
  298. } else {
  299. // clickMouse(false);
  300. return atMenu(command);
  301. }
  302. } catch (final Exception e) {
  303. log("clickInventoryFood(int...) error");
  304. return false;
  305. }
  306. }
  307.  
  308.  
  309.  
  310. public int fight()
  311. {
  312. status = "fight";
  313. try
  314. {
  315. if (getMyPlayer().getInteracting() == null)
  316. {
  317. RSNPC mob = getNearestFreeNPCToAttackByID(MID);
  318. if (mob != null)
  319. {
  320. if (tileOnScreen(mob.getLocation()) && (!getMyPlayer().isMoving()))
  321. {
  322. atNPC(mob,"Attack");
  323. wait(500);
  324. return random(1000,1200);
  325. }
  326. else
  327. {
  328. walkTileMM(mob.getLocation());
  329. return random(10,20);
  330. }
  331.  
  332. }
  333.  
  334. }
  335.  
  336.  
  337. }
  338. catch (final Exception e)
  339. {
  340. log("fight() error, caught.");
  341. e.printStackTrace();
  342. }
  343. return random(400,600);
  344. }
  345.  
  346. public void onFinish() {
  347. log("Turning off...");
  348. }
  349. public boolean onStart(final Map<String, String> args) {
  350. StartSpot = getMyPlayer().getLocation();
  351. return true;
  352. }
  353.  
  354. public void onRepaint(Graphics g) {
  355. if (isLoggedIn()) {
  356. long millis = System.currentTimeMillis() - startTime;
  357. long hours = millis / (1000 * 60 * 60);
  358. millis -= hours * (1000 * 60 * 60);
  359. long minutes = millis / (1000 * 60);
  360. millis -= minutes * (1000 * 60);
  361. long seconds = millis / 1000;
  362.  
  363.  
  364. if (startexp == 0) {
  365. startexpR = skills.getCurrentSkillExp(STAT_RANGE);
  366. startexpA = skills.getCurrentSkillExp(STAT_ATTACK);
  367. startexpS = skills.getCurrentSkillExp(STAT_STRENGTH);
  368. startexpD = skills.getCurrentSkillExp(STAT_DEFENSE);
  369. startexpH = skills.getCurrentSkillExp(STAT_HITPOINTS);
  370. startexp = 1;
  371. }
  372. xpGained = skills.getCurrentSkillExp(STAT_STRENGTH)
  373. + skills.getCurrentSkillExp(STAT_RANGE)
  374. + skills.getCurrentSkillExp(STAT_ATTACK)
  375. + skills.getCurrentSkillExp(STAT_DEFENSE)
  376. - startexpR
  377. - startexpA - startexpS - startexpD;
  378. xpGained2 = skills.getCurrentSkillExp(STAT_HITPOINTS)
  379. - startexpH;
  380. int x = 300;
  381. int y = 16;
  382.  
  383. g.setFont(new Font("Verdana", Font.BOLD, 12));
  384. g.setColor(new Color(0, 60, 0, 255));
  385. g.fill3DRect(295, 3, 222, 100, true); // 132 if not
  386. g.draw3DRect(295, 3, 222, 100, true);
  387. g.setColor(Color.green);
  388. g.drawString("Combat experience: " + xpGained, x, y + 48);
  389. g.drawString("Time running :" + hours + ":" + minutes + ":"
  390. + seconds + "", x, y + 32);
  391. g.drawString("status: " + status, x, y + 16);
  392.  
  393. }
  394. }
  395. }
Add Comment
Please, Sign In to add comment