Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.rsbuddy.script.methods.GroundItems;
- import com.rsbuddy.script.methods.Objects;
- import com.rsbuddy.script.util.Filter;
- import com.rsbuddy.script.util.Random;
- import com.rsbuddy.script.wrappers.GameObject;
- import com.rsbuddy.script.wrappers.GroundItem;
- import com.rsbuddy.script.wrappers.Player;
- import nz.uberdungplugincoder.common.Plugin;
- import nz.uberdungplugincoder.dungeon.MyPlayer;
- import nz.uberdungplugincoder.dungeon.Room;
- import nz.uberdungplugincoder.utils.MyGroundItems;
- import nz.uberdungplugincoder.utils.MyInventory;
- public class UnhappyGhost extends Plugin {
- private Action state = Action.LOOTING;
- private static final String RING = "Ring";
- private static int[] JEWLBOX = {54576, 54587, 54598};
- private static int[] BPOT = {54577, 54588, 54599 };
- private static int[] DPILLAR = {54580, 54591, 54602};
- private static int[] CCOFFIN = {54571, 54582, 54593};
- private static int[] OCOFFIN = {54572, 54583, 54594};
- private enum Action {
- LOOTING("Looting"),
- FILLING("Filling"),
- REPAIRING("Repairing"),
- OPENING("Opening"),
- MOVING("Moving"),
- BLESSING("Blessing");
- private Action(String name) {
- get = name;
- }
- private final String get;
- public String toString() {
- return get;
- }
- }
- @Override
- public String getAuthor() {
- return "MarioFan12";
- }
- @Override
- public String getName() {
- return "Unhappy Ghost";
- }
- @Override
- public String getStatus() {
- return state.toString();
- }
- private Action getState() {
- Player me = MyPlayer.get();
- if(me.isMoving() || me.getAnimation() != -1)
- return Action.MOVING;
- else if(Objects.getNearest(JEWLBOX) != null) {
- GroundItem ring = getNearestRing();
- if(ring != null)
- return Action.LOOTING;
- else
- return Action.FILLING;
- } else if(Objects.getNearest(BPOT) != null || Objects.getNearest(DPILLAR) != null)
- return Action.REPAIRING;
- else if(Objects.getNearest(CCOFFIN) != null)
- return Action.OPENING;
- else
- return Action.BLESSING;
- }
- @Override
- public boolean isValid() {
- Room room = new Room();
- GameObject box = Objects.getNearest(JEWLBOX);
- GameObject pot = Objects.getNearest(BPOT);
- GameObject coffin = Objects.getNearest(CCOFFIN);
- GameObject oCoffin = Objects.getNearest(OCOFFIN);
- return ((box != null && room.contains(box)) || (pot != null && room.contains(pot)) || (coffin != null && room.contains(coffin)) || (oCoffin != null && room.contains(oCoffin)));
- }
- public boolean isPossible() {
- return MyInventory.getItem(17883) != null;
- }
- public GroundItem getNearestRing() {
- return GroundItems.getNearest(new Filter<GroundItem>() {
- public boolean accept(GroundItem obj) {
- return obj.getItem().getName().contains(RING);
- }
- });
- }
- @Override
- public int loop() {
- state = getState();
- switch(state){
- case LOOTING:
- GroundItem ring = getNearestRing();
- if(ring != null && ring.isOnScreen())
- MyGroundItems.itemInteract(ring, "Take");
- else if(ring != null && !ring.isOnScreen())
- ring.getLocation().clickOnMap();
- break;
- case FILLING:
- GameObject box = Objects.getNearest(JEWLBOX);
- if(box != null && box.isOnScreen())
- box.interact("Fill");
- else if(box != null && !box.isOnScreen())
- box.getLocation().clickOnMap();
- break;
- case REPAIRING:
- GameObject pot = Objects.getNearest(BPOT);
- if(pot != null){
- if(pot.isOnScreen())
- pot.interact("Repair");
- else
- pot.getLocation().clickOnMap();
- } else {
- GameObject pillar = Objects.getNearest(DPILLAR);
- if(pillar != null) {
- if(pillar.isOnScreen())
- pillar.interact("Repair");
- else
- pillar.getLocation().clickOnMap();
- }
- }
- break;
- case OPENING:
- GameObject coffin = Objects.getNearest(CCOFFIN);
- if(coffin != null) {
- if(coffin.isOnScreen())
- coffin.interact("Unlock");
- else
- coffin.getLocation().clickOnMap();
- }
- break;
- case BLESSING:
- GameObject oCoffin = Objects.getNearest(OCOFFIN);
- if(oCoffin != null) {
- if(oCoffin.isOnScreen())
- oCoffin.interact("Bless");
- else
- oCoffin.getLocation().clickOnMap();
- }
- break;
- }
- return Random.nextInt(300, 500);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement