Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.container.impl.Inventory;
- import org.dreambot.api.methods.container.impl.bank.Bank;
- import org.dreambot.api.methods.interactive.GameObjects;
- import org.dreambot.api.methods.map.Area;
- import org.dreambot.api.script.AbstractScript;
- import org.dreambot.api.script.Category;
- import org.dreambot.api.script.ScriptManifest;
- import org.dreambot.api.wrappers.interactive.GameObject;
- import org.dreambot.api.wrappers.interactive.Player;
- import org.dreambot.api.wrappers.widgets.WidgetChild;
- @ScriptManifest(author = "Pug", name = "Pug POH Altar", version = 1.01, description = "Gives bones to the god at the Gilded altar - V1.01", category = Category.PRAYER)
- public class PrayerAltar extends AbstractScript
- {
- // change this to the persons name, who owns the house with the altar.
- private String hostName = "w330 host";
- // change this to which type of bone you are using
- private String bone = "Big bones";
- private int bonesgiven;
- private String statePrint = "WALK_TO_PORTAL";
- private Area portalArea = new Area(2541,3099,2547,3095);
- private Area bankArea = new Area(2610,3097,2613,3088);
- public enum State {
- BANK, WALK_TO_PORTAL, ENTER_PORTAL, WALK_TO_ALTAR, GIVE_BONES, LEAVE_HOUSE, WALK_TO_BANK;
- @Override
- public String toString() {
- return name().substring(0, 1) + name().toLowerCase().replaceAll("_", " ").substring(1);
- }
- }
- public State currentState = State.WALK_TO_PORTAL;
- public void onStart()
- {
- log("starting script");
- }
- @Override
- public int onLoop()
- {
- if(getClient().isLoggedIn())
- {
- switch (currentState)
- {
- case BANK:
- bank();
- break;
- case WALK_TO_PORTAL:
- walkToPortal();
- break;
- case ENTER_PORTAL:
- enterPortal();
- break;
- case WALK_TO_ALTAR:
- walkToAltar();
- break;
- case GIVE_BONES:
- giveBones();
- break;
- case LEAVE_HOUSE:
- leaveHouse();
- break;
- case WALK_TO_BANK:
- walkToBank();
- break;
- }
- }
- else
- {
- log("not logged in, wait");
- sleep(5000);
- }
- return Calculations.random(150, 300);
- }
- private void bank()
- {
- log("void bank");
- statePrint = "BANK";
- Player me = getLocalPlayer();
- GameObjects objects = getGameObjects();
- Inventory inv = getInventory();
- Bank bank = getBank();
- if(bank.isOpen())
- {
- if(bank.contains(bone))
- {
- if(inv.contains(bone))
- {
- currentState = State.WALK_TO_PORTAL;
- }
- else
- {
- if(inv.isEmpty())
- {
- if(bank.withdrawAll(bone))
- {
- sleepUntil(() -> inv.contains(bone), 2000);
- }
- }
- if(!inv.isEmpty() && !inv.contains(bone))
- {
- bank.depositAllItems();
- }
- }
- }
- else
- {
- stop();
- log("no bones left, stopping");
- }
- }
- else
- {
- GameObject booth = objects.closest("Bank booth");
- if(booth != null)
- {
- if(booth.distance(me) <= 3)
- {
- if(booth.hasAction("Bank"))
- {
- int randRightClick = Calculations.random(1,100);
- if(randRightClick >= 98)
- {
- if(booth.interactForceRight("Bank"))
- {
- sleepUntil(() -> bank.isOpen(), 2000);
- }
- }
- else
- {
- if(booth.interact("Bank"))
- {
- sleepUntil(() -> bank.isOpen(), 2000);
- }
- }
- }
- else
- {
- log("banking action change #001");
- }
- }
- else
- {
- if(getWalking().walk(booth))
- {
- while(me.isMoving())
- {
- sleep(200,500);
- }
- }
- }
- }
- else
- {
- log("booth is null #002");
- }
- }
- }
- private void walkToPortal()
- {
- log("void walkToPortal");
- statePrint = "WALK_TO_PORTAL";
- Player me = getLocalPlayer();
- if(portalArea.contains(me))
- {
- currentState = State.ENTER_PORTAL;
- }
- else
- {
- if(getWalking().walk(portalArea.getCenter()))
- {
- sleep(663,1150);
- }
- }
- }
- private void enterPortal()
- {
- log(" void enterPortal");
- statePrint = "ENTER_PORTAL";
- GameObjects objects = getGameObjects();
- GameObject portal = objects.closest("Portal");
- if(portal != null)
- {
- if(!getDialogues().inDialogue())
- {
- if(portal.interact("Enter"))
- {
- sleepUntil(() -> getDialogues().inDialogue(), 2000);
- }
- }
- else
- {
- if(getWidgets().getWidget(219) != null)
- {
- WidgetChild one = getWidgets().getChildWidget(219, 0).getChild(3);
- WidgetChild two = getWidgets().getChildWidget(162,32);
- if(one != null)
- {
- one.interact("Continue");
- sleep(721,934);
- }
- if(two != null)
- {
- getKeyboard().type(hostName);
- sleep(3421,3651);
- currentState = State.WALK_TO_ALTAR;
- }
- }
- }
- }
- }
- private void walkToAltar()
- {
- log("void walkToAltar");
- statePrint = "WALK_TO_ALTAR";
- Player me = getLocalPlayer();
- GameObjects objects = getGameObjects();
- GameObject altar = objects.closest("Altar");
- if(altar != null)
- {
- if(altar.distance(me) >= 3)
- {
- if(getWalking().walk(altar))
- {
- sleep(663,1150);
- }
- }
- if(altar.distance(altar) <= 2)
- {
- currentState = State.GIVE_BONES;
- }
- }
- }
- private void giveBones()
- {
- log("void giveBones");
- statePrint = "GIVE_BONES";
- Player me = getLocalPlayer();
- GameObjects objects = getGameObjects();
- Inventory inv = getInventory();
- GameObject altar = objects.closest("Altar");
- if(altar != null)
- {
- if(inv.contains(bone))
- {
- if(me.getAnimation() == -1)
- {
- inv.interact(bone, "Use");
- sleep(660,701);
- altar.interact("Use");
- sleep(1760,1980);
- }
- else
- {
- sleep(2000);
- }
- }
- else
- {
- currentState = State.LEAVE_HOUSE;
- bonesgiven += 27;
- }
- }
- else
- {
- log("altar null?");
- }
- }
- private void leaveHouse()
- {
- GameObjects objects = getGameObjects();
- log("void leaveHouse");
- statePrint = "LEAVE_HOUSE";
- GameObject portal = objects.closest(4525);
- if(portal != null)
- {
- log("portal != null");
- if(portal.hasAction("Enter"))
- {
- log("has action");
- if(portal.interact("Enter"))
- {
- log("entering");
- sleep(3000,3643);
- currentState = State.WALK_TO_BANK;
- }
- }
- }
- else
- {
- log("portal null?");
- }
- }
- private void walkToBank()
- {
- log("void walkToBank");
- statePrint = "WALK_TO_BANK";
- Player me = getLocalPlayer();
- if(bankArea.contains(me))
- {
- currentState = State.BANK;
- }
- else
- {
- if(getWalking().walk(bankArea.getCenter()))
- {
- sleep(663,1150);
- }
- }
- }
- public void onPaint(Graphics g)
- {
- g.drawString("Pug Prayer Altar - Version: " + getVersion(), 15, 40);
- g.drawString("State: " + statePrint, 15, 60);
- g.drawString("Bones given: " + bonesgiven, 15, 80);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement