Pug 130 Share Posted May 3, 2016 needed a script to give bones at a gilded altar owned by someone else. releasing it for public use. feel free to mess with it / change it to fit your needs. Start script in Yanille bank with bones in inventory. Pastebin: http://pastebin.com/cGeinUqa Source: 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(me) <= 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); } } works pretty decent for me. Could add way more to it. This script will not be maintained unless I need it, then i may remember to update it here also. (3rd May 16) Link to comment Share on other sites More sharing options...
RsMikeeyPs 6 Share Posted May 3, 2016 very nice! Link to comment Share on other sites More sharing options...
Hashtag 8671 Share Posted May 3, 2016 Sweet! Link to comment Share on other sites More sharing options...
Constuck 13 Share Posted May 4, 2016 Awesome, thanks for releasing the source, as a new scripter I cannot tell you how much open source scripts help me learn the API and common practices. One quick question: Is there any difference between... altar.distance(); and altar.distance(me); Link to comment Share on other sites More sharing options...
Pug 130 Author Share Posted May 4, 2016 Awesome, thanks for releasing the source, as a new scripter I cannot tell you how much open source scripts help me learn the API and common practices. One quick question: Is there any difference between... altar.distance(); and altar.distance(me); tbh ive never used object.distance() on its own so idk. i always use it like i have out of habit lol. You should also have a look at the shortcuts i use there super helpful rather than typing out getLocalPlayer() and shitlike that. gets annoying as fuck. Link to comment Share on other sites More sharing options...
Koschei 147 Share Posted May 9, 2016 Is Yanille still worth it? Isn't the unnoter at the first house more effective? Link to comment Share on other sites More sharing options...
Cardozz 46 Share Posted May 9, 2016 would be cool if theres a GUI built around it, but for a local script it'll do. Nice one mate Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.