Advertisement
joeybots

Untitled

Dec 26th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. package Main;
  2.  
  3. import org.osbot.rs07.api.filter.Filter;
  4. import org.osbot.rs07.api.model.*;
  5. import org.osbot.rs07.script.Script;
  6. import org.osbot.rs07.script.ScriptManifest;
  7. import org.osbot.rs07.utility.ConditionalSleep;
  8. import java.util.concurrent.TimeUnit;
  9. import java.awt.*;
  10.  
  11.  
  12. @ScriptManifest(name = "Guard Killer", author = "Joey", version = 1, info = "", logo = "")
  13.  
  14.  
  15. public class Main extends Script {
  16.  
  17. private long timeBegan;
  18. private long timeRan;
  19. private State state;
  20.  
  21.  
  22. private enum State{
  23. ATTACK_GUARD
  24. }
  25.  
  26.  
  27.  
  28. private State getState() {
  29.  
  30.  
  31.  
  32. return state.ATTACK_GUARD;
  33.  
  34. }
  35.  
  36.  
  37.  
  38.  
  39. @Override
  40. public void onStart() {
  41. timeBegan = System.currentTimeMillis();
  42.  
  43. }
  44.  
  45.  
  46.  
  47.  
  48.  
  49. public void onPaint(Graphics2D g) {
  50.  
  51. Graphics2D gr = g;
  52. timeRan = System.currentTimeMillis() - this.timeBegan;
  53. g.drawString(ft(timeRan), 150, 50);
  54.  
  55. g.drawString("Time:", 10, 50);
  56.  
  57. }
  58.  
  59.  
  60. private String ft(long duration) {
  61. String res = "";
  62. long days = TimeUnit.MILLISECONDS.toDays(duration);
  63. long hours = TimeUnit.MILLISECONDS.toHours(duration)
  64. - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
  65. long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
  66. - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
  67. .toHours(duration));
  68. long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
  69. - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
  70. .toMinutes(duration));
  71. if (days == 0) {
  72. res = (hours + ":" + minutes + ":" + seconds);
  73. } else {
  74. res = (days + ":" + hours + ":" + minutes + ":" + seconds);
  75. }
  76. return res;
  77. }
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. @Override
  85. public int onLoop() throws InterruptedException {
  86.  
  87.  
  88. state = getState();
  89.  
  90. switch(state) {
  91.  
  92.  
  93. case ATTACK_GUARD:
  94.  
  95.  
  96. NPC guard = getNpcs().closest(new Filter<NPC>() {
  97. @Override
  98. public boolean match(NPC npc) {
  99. return npc != null && npc.getName().equals("Guard") && getMap().canReach(npc) && !npc.isUnderAttack() && npc.getHealthPercent() >0;
  100. }
  101. });
  102.  
  103.  
  104. if (guard!=null && !getCombat().isFighting() && !guard.isUnderAttack() && !myPlayer().isUnderAttack() && !guard.isHitBarVisible()) {
  105.  
  106. guard.interact("Attack");
  107.  
  108. new ConditionalSleep(2000) {
  109. @Override
  110. public boolean condition() throws InterruptedException {
  111. return myPlayer().isUnderAttack();
  112. }
  113. }.sleep();
  114.  
  115. }
  116.  
  117.  
  118. break;
  119.  
  120.  
  121. }
  122.  
  123. return random(300,800);
  124.  
  125.  
  126. }
  127.  
  128.  
  129.  
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement