Joseph Posted March 25, 2015 Share Posted March 25, 2015 seeing as there isnt much prayer script. I use to have one in OSB1 but there isnt much demands. I was looking through my old code and was looking for prayer data and stuff to release to the community. ps. i was looking for ecto funtus but i lost that data. i found house altar. pps. its older data so check it out and stuff. Plus im sure some methods have changed. ppps. it isnt complete i was porting it over but it has enough data. Data package main; import org.osbot.rs07.script.Script; import dependencies.web.Action; import dependencies.web.Actions.GloryAction; import dependencies.web.Actions.POVPortalAction; import dependencies.web.Actions.RODAction; public class Data { private static Script s; public Data(Script script) { s = script; } public static enum DMode { BUCKET_BUYER, BONE_BURIER, ECTOFUNTUS, HOUSE_ALTAR, SLIME_COLLECTER; } public static enum Bone { BONES, BIG_BONES, BABY_DRAGON_BONES, DRAGON_BONES, ; @Override public String toString() { return super.name().toLowerCase().replace("_", " "); } } public static enum Transport { WALKING(null), ROD(new GloryAction(s)), //tabs ; private Action action; Transport(Action action){ this.action = action; } public boolean canUse() { return action == null ? true: action.canUse(); } public boolean traverse() { return action == null ? true: action.traverse(); } } public static enum ToBank { ROD(new RODAction(s)), GLORY_ON_WALL(new GloryAction(s)), POV_PORTAL(new POVPortalAction(s)), WALKING(null), //tabs/runes ; private Action action; ToBank(Action action){ this.action = action; } public boolean canUse() { return action == null ? true: action.canUse(); } public boolean traverse() { return action == null ? true: action.traverse(); } } } sub-Script class package sub.scripts; import java.awt.Color; import java.awt.Graphics2D; import java.util.List; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.Item; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.EquipmentSlot; import org.osbot.rs07.api.ui.Message; import org.osbot.rs07.api.ui.Message.MessageType; import org.osbot.rs07.api.ui.Spell; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.MethodProvider; import org.osbot.rs07.script.Script; import core.AIOPrayer; import core.Data.Bone; import core.Data.DMode; import core.Data.ToBank; import dependencies.DMethods; import dependencies.manager.MagicManager.RuneSupply; import dependencies.manager.MagicManager.Standard; import dependencies.node.BaseScript; import dependencies.node.Node; import dependencies.wrapper.Timer; public class DsHouseAltar implements BaseScript { public final String ALTAR = "altar", BURNER = "incense burner", PORTAL = "portal"; public Script script; public DMethods dMethods; public boolean imHost, enterName; public Bone bone; public List<String> hostList; public ToBank transport; public String status; public int total, removeAmount; public DsHouseAltar(Script script, boolean imHost, Bone bone, List<String> hostList, ToBank transport) { this.script = script; this.dMethods = new DMethods(script); this.imHost = imHost; this.bone = bone; this.hostList = hostList; this.transport = transport; } @Override public String Manifest() { return DMode.HOUSE_ALTAR.toString()+" (" +bone.toString() +")"; } @Override public void onExit() throws InterruptedException {} @Override public void onMessage(Message message) { if (message.getType().equals(MessageType.GAME)) { if (message != null) { if (message.getMessage().toLowerCase().startsWith("the gods are")) total++; else if (message.getMessage().toLowerCase().startsWith("that player is")) this.removeHost(); } } } @Override public void onPaint(Graphics2D g) throws InterruptedException { g.setColor(Color.BLUE.brighter()); g.drawString("" +Manifest(), 180, 400); g.drawString("Status: " +status, 180, 412); g.drawString("Timer: " +Timer.format(AIOPrayer.timer.getElapsed()), 180, 424); g.drawString("Total: " +dMethods.format(total), 180, 436); if (!hostList.isEmpty()) g.drawString("Host List: " +hostList , 180, 448); g.drawString("" +enterName, 180, 600); } public enum State { BANK, TRANPORT, ENTER_PORTAL, EXIT, PRAY, } @Override public int onLoop() throws InterruptedException { if (!hostList.isEmpty() || imHost) { switch (getState()) { case BANK: status = "Banking"; banking(false); break; case ENTER_PORTAL: status = "Entering portal"; enterPortal(); break; case EXIT: status = "Exit house"; exitHouse(); break; case PRAY: status = "Praying bone"; prayBone(); break; case TRANPORT: status = "Transport: " +transport.toString(); transport(); break; default: break; } }else{ script.log("No more host left in your list"); //script.stop(); } return MethodProvider.gRandom(700, 50); } public State getState() { Entity bank = dMethods.getBank(); return State.ENTER_PORTAL; else if (this.script.map.isInHouse() && script.inventory.contains(bone.toString())) return State.PRAY; else return State.TRANPORT; } public class Bank implements Node { @Override public String status() { // TODO Auto-generated method stub return null; } @Override public boolean activate() throws InterruptedException { Entity bank = dMethods.getBank(); if (!script.inventory.contains(bone.toString()) && bank != null && dMethods.isNear(bank, 6)) return true; else if (!script.inventory.contains(bone.toString()) && bank != null && !transport.equals(ToBank.WALKING)) return true; return false; } @Override public int run() throws InterruptedException { // TODO Auto-generated method stub return 0; } } public void removeHost() { removeAmount++; script.log("Failed: " +removeAmount); if (removeAmount >= 3) { hostList.remove(0); removeAmount = 0; } } public void enterPortal() throws InterruptedException { RS2Object portal = script.objects.closest(PORTAL); if (portal != null) { if (!portal.isVisible()) script.camera.toEntity(portal); else{ if (script.interfaces.getChild(232, 0) != null) { if (imHost) { if (script.interfaces.getChild(232, 1).interact()) MethodProvider.sleep(MethodProvider.gRandom(300, 50)); }else{ if (script.interfaces.getChild(232, 3).interact()) { enterName = true; MethodProvider.sleep(MethodProvider.gRandom(300, 50)); } } } else if (enterName) enterName(); else{ portal.interact(); MethodProvider.sleep(MethodProvider.gRandom(500, 100)); } } } } public void enterName() throws IllegalArgumentException, InterruptedException { if (dMethods.isInterfaceOverChat()) { script.keyboard.typeString(hostList.get(0), true); this.enterName = false; MethodProvider.sleep(MethodProvider.gRandom(1000, 200)); }else{ while(AIOPrayer.keyboardTimer.getElapsed() > 3000) { this.enterName = false; break; } } } public void prayBone() throws InterruptedException { RS2Object altar = script.objects.closest(ALTAR); if (altar != null) { if (!dMethods.isNear(altar, 6)) { script.log("trying to walk"); script.localWalker.walk(altar); }else{ if (!burnerIsBurning() && !imIdle()) { altar.interact(); MethodProvider.sleep(MethodProvider.gRandom(1000, 200)); } else if (imHost && !burnerIsBurning()) { script.log("not yet supported"); } else if (burnerIsBurning() && !script.myPlayer().isMoving()) { if (script.myPlayer().isAnimating()){ script.log("animating"); waitingTask(this.transport, MethodProvider.random(2, 10)); } else{ script.log("interact with it"); if (script.inventory.isItemSelected()) { if (script.inventory.getSelectedItemName().equalsIgnoreCase(bone.toString())) { altar.interact("use"); MethodProvider.sleep(MethodProvider.gRandom(300, 200)); }else script.inventory.deselectItem(); }else script.inventory.interact("use", bone.toString()); } } } } } public void waitingTask(ToBank transport, int amount) throws InterruptedException { Timer timer = new Timer(0); if (script.inventory.getAmount(bone.toString()) > amount) { if (script.mouse.isWithinCanvas()) script.mouse.moveOutsideScreen(); }else if (transport.equals(ToBank.WALKING)) openHouseOption(); while (timer.getElapsed() < 1000) { MethodProvider.sleep(50); if (script.myPlayer().isAnimating()) timer.reset(); } } public void exitHouse() throws InterruptedException { if (isInHouse()) { if (script.interfaces.getChild(370, 12) != null) script.interfaces.getChild(370, 12).interact(); else openHouseOption(); }else{ RS2Object portal = script.objects.closest(PORTAL); if (portal != null) dMethods.interactEntity(portal); } } public void transport() throws InterruptedException { if (transport != null) { if (script.bank.isOpen()) script.bank.close(); else{ if (!dMethods.checkInterface(399, 0)) { switch (transport) { case CASTLE_WARS_1_ROD: case CLAN_WARS_1_ROD: if (dMethods.getBank() != null) { if (!script.myPlayer().isAnimating()) { if (dMethods.magicManager.contains(null, Standard.HOUSE_TELEPORT)) script.magic.castSpell(Spell.HOUSE_TELEPORT); else script.localWalker.walk(dMethods.getBank()); } }else{ if (!script.myPlayer().isAnimating()) script.equipment.interact(EquipmentSlot.RING.slot, transport.toString()); } break; case WALKING: if (script.map.isInHouse()) this.exitHouse(); else walkToBank(); break; default: RS2Object object = script.objects.closest(transport.getName()); if (isInHouse()) { if (object != null) { if (!dMethods.isNear(object, 3)) { script.localWalker.walk(object, true); MethodProvider.sleep(MethodProvider.gRandom(600, 150)); }else{ if (!object.isVisible()) script.camera.toEntity(object); else if (imIdle()) dMethods.interactEntity(object, transport.action()); } }else{ script.log("object is null"); } }else{ if (dMethods.magicManager.contains(null, Standard.HOUSE_TELEPORT)) script.magic.castSpell(Spell.HOUSE_TELEPORT); else script.localWalker.walk(dMethods.getBank()); } break; } } } } } public void openHouseOption() { if (!script.tabs.getOpen().equals(Tab.SETTINGS)) script.tabs.open(Tab.SETTINGS); else{ if (script.interfaces.getChild(261, 56) != null) script.interfaces.getChild(261, 56).interact(); } } public void setRunning() { int amount = MethodProvider.gRandom(70, 10); if (!script.settings.isRunning() && script.settings.getRunEnergy() > amount) { dMethods.walker.turnRunOn(); } } public void walkToBank() throws InterruptedException { Position[] pathToBank = new Position[] {new Position(2544,3095,0), new Position(2548,3091,0), new Position(2556,3090,0), new Position(2565,3089,0), new Position(2575,3090,0), new Position(2581,3096,0), new Position(2592,3097,0), new Position(2600,3096,0), new Position(2605,3093,0), new Position(2611,3092,0), }; Position[] pathToPortal = dMethods.walker.reversePath(pathToBank); setRunning(); if (!script.inventory.contains(bone.toString())) dMethods.walker.walkPathMM(false, pathToBank); else dMethods.walker.walkPathMM(false, pathToPortal); } public void openBank() throws IllegalArgumentException, InterruptedException { Entity bank = dMethods.getBank(); if (!dMethods.isNear(bank, 5)) { script.localWalker.walk(bank); }else{ if (bank != null && !script.myPlayer().isMoving()) { bank.interact(dMethods.bankActions); MethodProvider.sleep(MethodProvider.gRandom(400, 200)); } } } public void banking(boolean debug) throws IllegalArgumentException, InterruptedException { if (!script.bank.isOpen() && !invContainsRing()) openBank(); else{ if (!isWearingRing() && !transport.equals(ToBank.WALKING)) withdrawAndEquiptRing(); else if (!dMethods.magicManager.contains(null, Standard.HOUSE_TELEPORT) && !transport.equals(ToBank.WALKING)) withdrawRune(); else if (imHost && !dMethods.containsAll("tinderbox")) withdrawMandatory(); else{ if (script.bank.contains(bone.toString())) { if (debug) script.bank.withdraw(bone.toString(), 1); else script.bank.withdrawAll(bone.toString()); }else{ script.log("You ran out of " +bone.toString()); script.stop(); } } } } public void withdrawAndEquiptRing() { String ring = "ring of dueling(8)"; if (script.bank.isOpen() && !invContainsRing()) { if (script.bank.contains(ring)) { script.bank.withdraw(ring, 1); }else{ script.log("you ran out of " +ring); script.stop(); } } else if (script.bank.isOpen() && invContainsRing()) { script.bank.close(); } else if (!script.bank.isOpen() && invContainsRing()) { script.inventory.getItem(ring).interact(); } } public void withdrawRune() { for (RuneSupply supply: Standard.HOUSE_TELEPORT.runeSupply()) { if (supply != null && !script.inventory.contains(supply.toString())) { if (!script.inventory.contains(supply.rune().toString())) { if (script.bank.contains(supply.rune().toString())) { script.bank.withdraw(supply.rune().toString(), 10); }else{ script.log("ran out of " +supply.rune().toString()); script.stop(); } } } } } public void withdrawMandatory() { script.log("not yet supported, withdrawing tinderbox and herbs"); } public boolean isWearingRing() { Item item = script.equipment.getItemInSlot(EquipmentSlot.RING.slot); if (item != null) return item.getName().toLowerCase().startsWith("ring of dueling"); return false; } public boolean invContainsRing() { return script.inventory.contains("ring of dueling(8)"); } public boolean imIdle() { Player player = script.myPlayer(); return player != null && !player.isAnimating() && !player.isMoving(); } public boolean isInHouse() { if (script.map.isInHouse()) return script.objects.closest(ALTAR) != null; return false; } public boolean burnerIsBurning() { RS2Object burner = script.objects.closest(BURNER); return burner != null && burner.getModel().getHeight() > 200; } public boolean outsideOfHouse() { return script.objects.closest("portal") != null && !script.map.isInHouse(); } } this is osbot 1 data so youll need to convert it to osbot 2 Quote Link to comment Share on other sites More sharing options...