Guest User

Untitled

a guest
Jul 16th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.12 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Point;
  5. import java.util.Map;
  6.  
  7. import org.rsbot.bot.Bot;
  8. import org.rsbot.event.listeners.PaintListener;
  9. import org.rsbot.event.listeners.ServerMessageListener;
  10. import org.rsbot.script.Bank;
  11. import org.rsbot.script.Calculations;
  12. import org.rsbot.script.Constants;
  13. import org.rsbot.script.Script;
  14. import org.rsbot.script.ScriptManifest;
  15. import org.rsbot.script.wrappers.RSInterface;
  16. import org.rsbot.script.wrappers.RSItemTile;
  17. import org.rsbot.script.wrappers.RSNPC;
  18. import org.rsbot.script.wrappers.RSTile;
  19. import org.rsbot.script.wrappers.RSObject;
  20. import org.rsbot.event.events.ServerMessageEvent;
  21.  
  22.  
  23.  
  24. @ScriptManifest(authors = { "SpeedWing" }, category = "Runecraft", name = "RuneSpeed", version = 1.0, description = "<html>\n"
  25. + "<body style='font-family: Calibri; color:white; padding: 0px; text-align: center; background-color: black;'>"
  26. + "<h2>"
  27. + "RuneSpeed 1.0"
  28. + "</h2>\n"
  29. + "Author: SpeedWing"
  30. + "<br><br>\n"
  31. + "Start this script in The Bank that belongs to the altar"
  32. + "<br><br>\n"
  33. + "Select the Rune to Craft "
  34. + "<select name=\"type\"><option>Air<option>Mind<option>Water<option>Earth<option>Fire<option>Body</select>")
  35.  
  36.  
  37. public class RuneSpeed extends Script implements PaintListener, ServerMessageListener {
  38.  
  39. private final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
  40.  
  41. /////////
  42. //items//
  43. /////////
  44. //runes
  45. int essence = 1436;
  46. int Air = 556;
  47. int Earth = 557;
  48. int Fire = 554;
  49. int Water = 555;
  50. int Mind = 558;
  51. int Body = 559;
  52. int AllDone;
  53. int Rune;
  54. //Tiara
  55. int Tiara;
  56. int AirTiara = 5527;
  57. int EarthTiara = 5535;
  58. int FireTiara = 5537;
  59. int WaterTiara = 5531;
  60. int MindTiara = 5529;
  61. int BodyTiara = 5533;
  62.  
  63. ///////////
  64. //objects//
  65. ///////////
  66. int CurBank;
  67. int CurOutside;
  68. int CurAltar;
  69. int ExitPortal = 2465;
  70. //air
  71. int AirBankID = 11402;
  72. int AirOutsideID = 2452;
  73. int AirAltarID = 2478;
  74.  
  75.  
  76. //////////
  77. //states//
  78. //////////
  79. boolean banking;
  80. boolean bankwalk;
  81. boolean altarwalk;
  82. boolean crafting;
  83. boolean getessence;
  84. boolean grabitems;
  85. boolean inbank;
  86. boolean exitaltar;
  87.  
  88. /////////
  89. //paths//
  90. /////////
  91. RSTile[] ToAltar;
  92. RSTile[] ToBank;
  93. //air
  94. RSTile[] AirAltar = {new RSTile(3185, 3436), new RSTile(3184, 3429), new RSTile(3174, 3429),
  95. new RSTile(3168, 3429), new RSTile(3164, 3424), new RSTile(3159, 3420), new RSTile(3155, 3417),
  96. new RSTile(3147, 3416), new RSTile(3143, 3412), new RSTile(3136, 3408), new RSTile(3129, 3407)};
  97. RSTile[] AirBank = {new RSTile(3129, 3407), new RSTile(3136, 3408), new RSTile(3143, 3412),
  98. new RSTile(3147, 3416), new RSTile(3155, 3417), new RSTile(3159, 3420), new RSTile(3164, 3424),
  99. new RSTile(3168, 3429), new RSTile(3184, 3429), new RSTile(3185, 3436)};
  100.  
  101. //for paint TODO
  102. long startTime = System.currentTimeMillis();
  103. long expraise;
  104. int startLvl = skills.getCurrentSkillLevel(Constants.STAT_RUNECRAFTING);
  105.  
  106.  
  107.  
  108.  
  109.  
  110. public int loop() {
  111. cameraheight();
  112.  
  113. if (banking == true){
  114. if (openBank(CurBank)){
  115. banking = false;
  116. inbank = true;
  117. return (random(100,150));
  118. }
  119. }
  120.  
  121. if (inbank == true){
  122. if (bank.isOpen() == true){
  123. if (getInventoryCount() > 0 ){
  124. bank.depositAll();
  125. }
  126. inbank = false;
  127. getessence = true;
  128. return (random(200,250));
  129. }
  130.  
  131. }
  132.  
  133. if (getessence == true){
  134. if (getInventoryCount(essence) != 0 ){
  135. getessence = false;
  136. altarwalk = true;//start walking to altar
  137. }
  138. if (getInventoryCount(essence) == 0 && getessence == true){
  139. bank.atItem(essence, "Withdraw-All");
  140. return (random(700,760));
  141. }
  142. return (random(200,250));
  143. }
  144.  
  145.  
  146. if (altarwalk == true){
  147. if (getInventoryCount(essence) == 0){
  148. banking = true;
  149. altarwalk = false;
  150. }
  151. intoAltar();
  152. walkPath(ToAltar,false);
  153. return (random(200,220));
  154. }
  155.  
  156. if (crafting == true && getMyPlayer().getAnimation() == -1){
  157. craftrunes();
  158. return (random(1500,1600));
  159. }
  160.  
  161. if (exitaltar == true && getInventoryCount(essence) == 0 && getMyPlayer().getAnimation() == -1){
  162. if (crafting == true){
  163. crafting = false;
  164. }
  165. leavealtar();
  166. return (random(1500,1600));
  167. }
  168.  
  169.  
  170. if (bankwalk == true && getInventoryCount(Rune) > 0){
  171. if (exitaltar == true){
  172. exitaltar = false;
  173. }
  174. walkPath(ToBank,false);
  175.  
  176. /*RSObject bankObj = getNearestObjectByID(CurBank);
  177. if (bankObj != null && distanceTo(bankObj) <= 7){
  178. bankwalk = false;
  179. banking = true;
  180. }
  181. */
  182. return 500;
  183. }
  184. return random(100,200);
  185.  
  186. }
  187.  
  188.  
  189. //checks the camera
  190. public void cameraheight(){
  191. if (Bot.getClient().getCamPosZ() > -1900 ){
  192. setCameraAltitude(true);
  193. }
  194.  
  195. }
  196.  
  197. //counts the amount of runes in the inventory
  198. public int InvCount(){
  199. return getInventoryCount(Rune);
  200. }
  201.  
  202. //leave the altar
  203. private void leavealtar(){
  204. RSObject ExitPortalObj = getNearestObjectByID(ExitPortal);
  205. if (ExitPortalObj != null) {
  206. atObject(ExitPortalObj,"Enter Portal");
  207. bankwalk = true;
  208. }
  209.  
  210. }
  211.  
  212. //craft the runes
  213. private void craftrunes(){
  214. RSObject InsideAltar = getNearestObjectByID(CurAltar);
  215. if (InsideAltar != null) {
  216. atObject(InsideAltar,"Craft-Rune");
  217. exitaltar = true;
  218. }
  219.  
  220. }
  221.  
  222. //opens the altar
  223. private void intoAltar(){
  224. RSObject TheAltar = getNearestObjectByID(CurOutside);
  225. if (TheAltar != null && distanceTo(TheAltar) <= 4) {
  226. atObject(TheAltar,"Enter Mysterious ruins");
  227. crafting = true;
  228. altarwalk = false;
  229. }
  230. }
  231.  
  232. //opens up bank
  233. private boolean openBank(final int obj) {
  234. final RSTile tile = getNearestObjectByID(obj).getLocation();
  235. final Point location = Calculations.tileToScreen(tile);
  236. if (pointOnScreen(location) && location != null) {
  237. if (!getMyPlayer().isMoving()) {
  238. if (onTile(tile, "Bank booth", "Use-quickly", 0.5, 0.5, 0)) {
  239. return true;
  240. }
  241. wait(random(500, 780));
  242. }
  243. } else {
  244. if (!getMyPlayer().isMoving()) {
  245. walkTile(tile);
  246. return false;
  247. }
  248. }
  249. return false;
  250. }
  251.  
  252. public void serverMessageRecieved(final ServerMessageEvent arg0) {
  253. final String message = arg0.getMessage();
  254.  
  255. /*if someone else already fights the target do not click it again
  256. if (message.contains("Someone else is fighting that."))
  257. {
  258. someonefightsthat = true;
  259. }
  260. */
  261. }
  262.  
  263.  
  264. public void onRepaint(Graphics g) {
  265. if(isLoggedIn())
  266. {
  267.  
  268. if (startTime == 0)
  269. {
  270. startTime = System.currentTimeMillis();
  271. }
  272.  
  273.  
  274. long millis = System.currentTimeMillis() - startTime;
  275. final long hours = millis / (1000 * 60 * 60);
  276. millis -= hours * 1000 * 60 * 60;
  277. final long minutes = millis / (1000 * 60);
  278. millis -= minutes * 1000 * 60;
  279. final long seconds = millis / 1000;
  280. final int x = 294;// upper left x location
  281. int y = 4;// upper left y location
  282. final int xl = 222;// length
  283. final int yl = 53;// height
  284. g.setColor(new Color(0, 0, 0, 175));
  285. g.fillRect(x, y, xl, yl);
  286. g.setColor(new Color(255, 255, 255));
  287. g.drawRect(x, y, xl, yl);
  288. g.setFont(new Font("Calibri", Font.PLAIN, 13));
  289. g.drawString(properties.name()+ " " + properties.version(),x + 10, y += 15);
  290. g.drawString("Running for " + hours + ":" + minutes + ":" + seconds,x + 10, y += 15);
  291. }
  292.  
  293. }
  294.  
  295. public boolean onTile(final RSTile tile, final String search,
  296. final String action, final double dx, final double dy,
  297. final int height) {
  298. if (!tile.isValid()) {
  299. return false;
  300. }
  301. Point checkScreen;
  302. checkScreen = Calculations.tileToScreen(tile, dx, dy, height);
  303. if (!pointOnScreen(checkScreen)) {
  304. walkTile(tile);
  305. wait(random(340, 1310));
  306. }
  307. try {
  308. Point screenLoc;
  309. for (int i = 0; i < 30; i++) {
  310. screenLoc = Calculations.tileToScreen(tile, dx, dy, height);
  311. if (!pointOnScreen(screenLoc)) {
  312. return false;
  313. }
  314. if (getMenuItems().get(0).toLowerCase().contains(
  315. search.toLowerCase())) {
  316. break;
  317. }
  318. if (getMouseLocation().equals(screenLoc)) {
  319. break;
  320. }
  321. moveMouse(screenLoc);
  322. }
  323. if (getMenuItems().get(0).toLowerCase().contains(
  324. action.toLowerCase())) {
  325. clickMouse(true);
  326. return true;
  327. } else {
  328. clickMouse(false);
  329. return atMenu(action);
  330. }
  331. } catch (final Exception e) {
  332. e.printStackTrace();
  333. return false;
  334. }
  335. }
  336.  
  337. private void walkPath(final RSTile[] path, final boolean reverse) {
  338. if (!reverse) {
  339. if (!getMyPlayer().isMoving()
  340. || distanceTo(getDestination()) <= random(4, 7)) {
  341. walkPathMM(randomizePath(path, 2, 2), 17);
  342. }
  343. } else {
  344. if (!getMyPlayer().isMoving()
  345. || distanceTo(getDestination()) <= random(4, 7)) {
  346. walkPathMM(randomizePath(reversePath(path), 2, 2), 17);
  347. }
  348. }
  349. }
  350.  
  351. private void walkTile(final RSTile tile) {
  352. final Point screen = Calculations.tileToScreen(tile);
  353. if (pointOnScreen(screen)) {
  354. moveMouse(screen, 5, 5);
  355. onTile(tile, "here", "Walk", 0.5, 0.5, 0);
  356. } else {
  357. walkTileMM(tile);
  358. }
  359. }
  360.  
  361. public boolean onStart(Map<String, String> args) {
  362. banking = true;
  363. bankwalk = false;
  364. altarwalk = false;
  365. crafting = false;
  366.  
  367. if (args.get("type").equals("Air")) {
  368. ToAltar = AirAltar;
  369. ToBank = AirBank;
  370. Rune = Air;
  371. Tiara = AirTiara;
  372. CurBank = AirBankID;
  373. CurOutside = AirOutsideID;
  374. CurAltar = AirAltarID;
  375. }
  376.  
  377. /*
  378. if (args.get("type").equals("Mind")) {
  379. ToAltar = MindAltar;
  380. ToBank = MindBank;
  381. Rune = Mind;
  382. Tiara = MindTiara;
  383. CurBank = MindBankID;
  384. CurOutside = MindOutsideID;
  385. CurAltar = MindAltarID;
  386. }
  387.  
  388. if (args.get("type").equals("Water")) {
  389. ToAltar = WaterAltar;
  390. ToBank = WaterBank;
  391. Rune = Water;
  392. Tiara = WaterTiara;
  393. CurBank = WaterBankID;
  394. CurOutside = WaterOutsideID;
  395. CurAltar = WaterAltarID;
  396. }
  397.  
  398. if (args.get("type").equals("Earth")) {
  399. ToAltar = EarthAltar;
  400. ToBank = EarthBank;
  401. Rune = Earth;
  402. Tiara = EarthTiara;
  403. CurBank = EarthBankID;
  404. CurOutside = EarthOutsideID;
  405. CurAltar = EarthAltarID;
  406. }
  407.  
  408. if (args.get("type").equals("Fire")) {
  409. ToAltar = FireAltar;
  410. ToBank = FireBank;
  411. Rune = Fire;
  412. Tiara = FireTiara;
  413. CurBank = FireBankID;
  414. CurOutside = FireOutsideID;
  415. CurAltar = FireAltarID;
  416. }
  417.  
  418. if (args.get("type").equals("Body")) {
  419. ToAltar = BodyAltar;
  420. ToBank = BodyBank;
  421. Rune = Body;
  422. Tiara = BodyTiara;
  423. CurBank = BodyBankID;
  424. CurOutside = BodyOutsideID;
  425. CurAltar = BodyAltarID;
  426. }
  427. */
  428. return true;
  429. }
  430.  
  431.  
  432. public void onFinish() {
  433. //onfinish code
  434. }
  435. }
Add Comment
Please, Sign In to add comment