Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. import com.rsbuddy.script.methods.GroundItems;
  2. import com.rsbuddy.script.methods.Objects;
  3. import com.rsbuddy.script.util.Filter;
  4. import com.rsbuddy.script.util.Random;
  5. import com.rsbuddy.script.wrappers.GameObject;
  6. import com.rsbuddy.script.wrappers.GroundItem;
  7. import com.rsbuddy.script.wrappers.Player;
  8.  
  9. import nz.uberdungplugincoder.common.Plugin;
  10. import nz.uberdungplugincoder.dungeon.MyPlayer;
  11. import nz.uberdungplugincoder.dungeon.Room;
  12. import nz.uberdungplugincoder.utils.MyGroundItems;
  13. import nz.uberdungplugincoder.utils.MyInventory;
  14.  
  15.  
  16. public class UnhappyGhost extends Plugin {
  17.  
  18. private Action state = Action.LOOTING;
  19.  
  20. private static final String RING = "Ring";
  21. private static int[] JEWLBOX = {54576, 54587, 54598};
  22. private static int[] BPOT = {54577, 54588, 54599 };
  23. private static int[] DPILLAR = {54580, 54591, 54602};
  24. private static int[] CCOFFIN = {54571, 54582, 54593};
  25. private static int[] OCOFFIN = {54572, 54583, 54594};
  26.  
  27. private enum Action {
  28. LOOTING("Looting"),
  29. FILLING("Filling"),
  30. REPAIRING("Repairing"),
  31. OPENING("Opening"),
  32. MOVING("Moving"),
  33. BLESSING("Blessing");
  34.  
  35. private Action(String name) {
  36. get = name;
  37. }
  38. private final String get;
  39. public String toString() {
  40. return get;
  41. }
  42. }
  43.  
  44. @Override
  45. public String getAuthor() {
  46. return "MarioFan12";
  47. }
  48.  
  49. @Override
  50. public String getName() {
  51. return "Unhappy Ghost";
  52. }
  53.  
  54. @Override
  55. public String getStatus() {
  56. return state.toString();
  57. }
  58.  
  59. private Action getState() {
  60. Player me = MyPlayer.get();
  61. if(me.isMoving() || me.getAnimation() != -1)
  62. return Action.MOVING;
  63. else if(Objects.getNearest(JEWLBOX) != null) {
  64. GroundItem ring = getNearestRing();
  65. if(ring != null)
  66. return Action.LOOTING;
  67. else
  68. return Action.FILLING;
  69. } else if(Objects.getNearest(BPOT) != null || Objects.getNearest(DPILLAR) != null)
  70. return Action.REPAIRING;
  71. else if(Objects.getNearest(CCOFFIN) != null)
  72. return Action.OPENING;
  73. else
  74. return Action.BLESSING;
  75. }
  76.  
  77. @Override
  78. public boolean isValid() {
  79. Room room = new Room();
  80. GameObject box = Objects.getNearest(JEWLBOX);
  81. GameObject pot = Objects.getNearest(BPOT);
  82. GameObject coffin = Objects.getNearest(CCOFFIN);
  83. GameObject oCoffin = Objects.getNearest(OCOFFIN);
  84. return ((box != null && room.contains(box)) || (pot != null && room.contains(pot)) || (coffin != null && room.contains(coffin)) || (oCoffin != null && room.contains(oCoffin)));
  85. }
  86.  
  87. public boolean isPossible() {
  88. return MyInventory.getItem(17883) != null;
  89. }
  90.  
  91. public GroundItem getNearestRing() {
  92. return GroundItems.getNearest(new Filter<GroundItem>() {
  93. public boolean accept(GroundItem obj) {
  94. return obj.getItem().getName().contains(RING);
  95. }
  96. });
  97. }
  98.  
  99. @Override
  100. public int loop() {
  101. state = getState();
  102. switch(state){
  103. case LOOTING:
  104. GroundItem ring = getNearestRing();
  105. if(ring != null && ring.isOnScreen())
  106. MyGroundItems.itemInteract(ring, "Take");
  107. else if(ring != null && !ring.isOnScreen())
  108. ring.getLocation().clickOnMap();
  109. break;
  110. case FILLING:
  111. GameObject box = Objects.getNearest(JEWLBOX);
  112. if(box != null && box.isOnScreen())
  113. box.interact("Fill");
  114. else if(box != null && !box.isOnScreen())
  115. box.getLocation().clickOnMap();
  116. break;
  117. case REPAIRING:
  118. GameObject pot = Objects.getNearest(BPOT);
  119. if(pot != null){
  120. if(pot.isOnScreen())
  121. pot.interact("Repair");
  122. else
  123. pot.getLocation().clickOnMap();
  124. } else {
  125. GameObject pillar = Objects.getNearest(DPILLAR);
  126. if(pillar != null) {
  127. if(pillar.isOnScreen())
  128. pillar.interact("Repair");
  129. else
  130. pillar.getLocation().clickOnMap();
  131. }
  132. }
  133. break;
  134. case OPENING:
  135. GameObject coffin = Objects.getNearest(CCOFFIN);
  136. if(coffin != null) {
  137. if(coffin.isOnScreen())
  138. coffin.interact("Unlock");
  139. else
  140. coffin.getLocation().clickOnMap();
  141. }
  142. break;
  143. case BLESSING:
  144. GameObject oCoffin = Objects.getNearest(OCOFFIN);
  145. if(oCoffin != null) {
  146. if(oCoffin.isOnScreen())
  147. oCoffin.interact("Bless");
  148. else
  149. oCoffin.getLocation().clickOnMap();
  150. }
  151. break;
  152. }
  153. return Random.nextInt(300, 500);
  154. }
  155.  
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement