Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.GroupLayout.*;
- import javax.swing.LayoutStyle.*;
- import javax.swing.border.*;
- import org.powerbot.concurrent.strategy.*;
- import org.powerbot.concurrent.*;
- import org.powerbot.game.api.*;
- import org.powerbot.game.api.methods.Game;
- import org.powerbot.game.api.methods.Tabs;
- import org.powerbot.game.api.methods.Walking;
- import org.powerbot.game.api.methods.Widgets;
- import org.powerbot.game.api.methods.input.Keyboard;
- import org.powerbot.game.api.methods.input.Mouse;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.node.SceneEntities;
- import org.powerbot.game.api.methods.tab.Inventory;
- import org.powerbot.game.api.methods.widget.Bank;
- import org.powerbot.game.api.methods.widget.Camera;
- import org.powerbot.game.api.util.Random;
- import org.powerbot.game.api.util.Time;
- import org.powerbot.game.api.wrappers.Area;
- import org.powerbot.game.api.wrappers.Tile;
- import org.powerbot.game.api.wrappers.widget.WidgetChild;
- import org.powerbot.game.bot.event.MessageEvent;
- import org.powerbot.game.bot.event.listener.*;
- @Manifest(name = "DarkPrayer", description = "Prayer training at Player Owned Houses", version = 1.1d, authors = { "Dark``" })
- public class DarkPrayerAIO extends ActiveScript implements MessageListener,
- PaintListener {
- WidgetChild chatBox = null;
- String[] invalidNames = { "" };
- String entryAttempt = "";
- String bankMethod = "";
- String familiar = "";
- String friendName = "";
- String houseOption = "";
- boolean attemptingToEnter = false;
- boolean hasUsedYanilleTeleport = false;
- boolean isYanilleTeleportUnlocked = true;
- boolean listeningForHost = false;
- boolean idle = false;
- boolean setup = false;
- boolean isUsingFriendFirst = false;
- final int[] gildedAltarId = { 13197, 13199, 13198 };
- final int wallGloryId = 13523;
- final int yanillePortalId = 15482;
- final int housePortalId = 13405;
- final int dragonBoneId = 536;
- final int frostBoneId = 3;
- final int normalBoneId = 526;
- final int animationTeleport = 16385;
- int selectedBoneId = dragonBoneId;
- int xpGained = 0;
- int bonesSacrificed = 0;
- final Rectangle displayPaint = new Rectangle(418, 458, 50, 16);
- final Area edgevilleBank = new Area(new Tile(3087, 3502, 0), new Tile(3101,
- 3486, 0));
- final Area yanillePortalArea = new Area(new Tile(2540, 3099, 0), new Tile(
- 2547, 3094, 0));
- Area j = new Area();
- org.powerbot.game.api.util.Timer startTime = new org.powerbot.game.api.util.Timer(
- 0);
- WidgetChild magicTab = null;
- @Override
- protected void setup() {
- log.info("Started DarkPrayer. Setting up the script..");
- magicTab = Widgets.get(548).getChild(96);
- chatBox = Widgets.get(752).getChild(11);
- final OpenEdgevilleBank openBank = new OpenEdgevilleBank();
- final Strategy bankAction = new Strategy(openBank, openBank);
- final TeleportToYanille teleport = new TeleportToYanille();
- final Strategy teleportAction = new Strategy(teleport, teleport);
- final WaitAtPortal waitAtPortal = new WaitAtPortal();
- final Strategy waitPortalAction = new Strategy(waitAtPortal,
- waitAtPortal);
- final UseBonesOnAltar offerBones = new UseBonesOnAltar();
- final Strategy offerBonesAction = new Strategy(offerBones, offerBones);
- final TeleportToEdgeville teleportBack = new TeleportToEdgeville();
- final Strategy teleBackAction = new Strategy(teleportBack, teleportBack);
- final Antiban antiban = new Antiban();
- final Strategy antibanAction = new Strategy(antiban, antiban);
- provide(bankAction);
- provide(teleportAction);
- provide(waitPortalAction);
- provide(offerBonesAction);
- provide(teleBackAction);
- provide(antibanAction);
- }
- private class OpenEdgevilleBank implements Task, Condition {
- @Override
- public boolean validate() {
- if (Tabs.getCurrent() != Tabs.INVENTORY)
- Tabs.INVENTORY.open();
- return Inventory.getCount() == 0;
- }
- @Override
- public void run() {
- idle = false;
- if (SceneEntities.getNearest(42217) != null) {
- if (SceneEntities.getNearest(42217).isOnScreen()) {
- Bank.open();
- Time.sleep(604, 2583);
- Bank.withdraw(selectedBoneId, 28);
- Time.sleep(405, 1337);
- Bank.close();
- } else {
- Walking.findPath(
- SceneEntities.getNearest(42217).getLocation())
- .traverse();
- }
- }
- }
- }
- private class TeleportToYanille implements Task, Condition {
- @Override
- public void run() {
- Tabs.MAGIC.open();
- WidgetChild homeTeleport = Widgets.get(193).getChild(48);
- idle = false;
- if (hasUsedYanilleTeleport) {
- homeTeleport.interact("Previous-destination");
- Time.sleep(1374, 3847);
- } else {
- homeTeleport.interact("Cast");
- Time.sleep(639, 2484);
- if (Widgets.get(1092).validate()) {
- Widgets.get(1092).getChild(52).interact("Teleport");
- Time.sleep(964, 1485);
- hasUsedYanilleTeleport = true;
- }
- }
- }
- @Override
- public boolean validate() {
- return edgevilleBank.contains(Players.getLocal().getLocation())
- && Inventory.getCount(selectedBoneId) == 28
- && Players.getLocal().getAnimation() != animationTeleport;
- }
- }
- private class WaitAtPortal implements Task, Condition {
- @Override
- public void run() {
- if (!yanillePortalArea.contains(Players.getLocal().getLocation())) {
- log.info("NOT THERE");
- Walking.walk(yanillePortalArea.getTileArray()[Random.nextInt(0,
- yanillePortalArea.getTileArray().length)]);
- Time.sleep(3357, 6947);
- } else {
- idle = true;
- listeningForHost = true;
- if (!entryAttempt.isEmpty()) {
- Time.sleep(1243, 3975);
- SceneEntities.getNearest(yanillePortalId).interact("Enter");
- for (int i = 0; i < 10; i++) {
- if (Widgets.get(1188).validate()) {
- Time.sleep(725, 1583);
- break;
- } else {
- Time.sleep(1000);
- }
- }
- Keyboard.sendKey('3');
- Time.sleep(2449, 4286);
- Keyboard.sendText(entryAttempt, true);
- }
- }
- }
- @Override
- public boolean validate() {
- return SceneEntities.getNearest(yanillePortalId) != null;
- }
- }
- private class UseBonesOnAltar implements Task, Condition {
- @Override
- public void run() {
- idle = false;
- listeningForHost = false;
- Area altarArea = new Area(new Tile(SceneEntities
- .getNearest(gildedAltarId).getLocation().getX() - 3,
- SceneEntities.getNearest(gildedAltarId).getLocation()
- .getY() - 3, Players.getLocal().getPlane()),
- new Tile(SceneEntities.getNearest(gildedAltarId)
- .getLocation().getX() + 3,
- SceneEntities.getNearest(gildedAltarId)
- .getLocation().getY() + 3, Players
- .getLocal().getPlane()));
- j = altarArea;
- if (!altarArea.contains(Players.getLocal().getLocation())) {
- Walking.walk(SceneEntities.getNearest(gildedAltarId)
- .getLocation());
- }
- Time.sleep(3173, 4826);
- Inventory.getItem(selectedBoneId).getWidgetChild().interact("Use");
- Time.sleep(488, 1274);
- SceneEntities.getNearest(gildedAltarId).interact("Use");
- for (int i = 0; i < 10; i++) {
- if (Widgets.get(905).validate()) {
- Time.sleep(243, 953);
- break;
- } else {
- Time.sleep(200);
- }
- }
- Time.sleep(500, 1350);
- Widgets.get(905).getChild(14).interact("Offer all");
- idle = true;
- Time.sleep(2462, 4027);
- if (Inventory.getCount(selectedBoneId) == 0) {
- if (SceneEntities.getNearest(wallGloryId) != null) {
- SceneEntities.getNearest(wallGloryId).interact("Rub");
- }
- }
- }
- @Override
- public boolean validate() {
- if (Tabs.getCurrent() != Tabs.INVENTORY)
- Tabs.INVENTORY.open();
- return SceneEntities.getNearest(gildedAltarId) != null
- && Players.getLocal().getAnimation() != 3705
- && Inventory.getCount() != 0;
- }
- }
- private class TeleportToEdgeville implements Task, Condition {
- @Override
- public void run() {
- // TODO Auto-generated method stub
- if (!SceneEntities.getNearest(wallGloryId).isOnScreen()) {
- Walking.walk(SceneEntities.getNearest(wallGloryId)
- .getLocation());
- } else {
- idle = false;
- SceneEntities.getNearest(wallGloryId).interact("Rub");
- // Time.sleep(1354, 2749);
- for (int i = 0; i < 10; i++) {
- if (Widgets.get(1188).validate()) {
- Time.sleep(725, 1583);
- break;
- } else {
- Time.sleep(300);
- }
- }
- if (Widgets.get(1188).validate()) {
- Keyboard.sendKey('1');
- }
- // org.powerbot.game.api.methods.node.Menu.
- }
- }
- @Override
- public boolean validate() {
- // TODO Auto-generated method stub
- return SceneEntities.getNearest(wallGloryId) != null
- && Inventory.getCount(selectedBoneId) == 0 && !Players.getLocal().isMoving();
- }
- }
- private class Antiban implements Task, Condition {
- @Override
- public void run() {
- if (Random.nextInt(1, 100) == 2)
- Camera.setAngle(Random.nextInt(1, 360));
- if (Random.nextInt(1, 100) == 7)
- Mouse.move(Random.nextInt(1, Game.getDimensions().width),
- Random.nextInt(1, Game.getDimensions().height));
- }
- @Override
- public boolean validate() {
- return Players.getLocal().getAnimation() != -1 || idle == true;
- }
- }
- public boolean isInvalidName(String name) {
- for (String entry : invalidNames) {
- if (name.contains("[")) {
- if (entry.equals(name.substring(name.lastIndexOf("[") + 1,
- name.lastIndexOf("]")).toLowerCase())) {
- return true;
- }
- } else {
- if (entry.equalsIgnoreCase(name)) {
- return true;
- }
- }
- }
- return false;
- }
- @Override
- public void messageReceived(MessageEvent e) {
- if (e.getId() == 2) {
- if (listeningForHost) {
- String message = e.getMessage().toLowerCase();
- if (message.contains("at")) {
- if (message.substring(message.lastIndexOf("at") + 3)
- .replaceAll(String.valueOf(' '), "_")
- .replaceAll("-", "_").matches("\\w{1,12}")) {
- if (entryAttempt.isEmpty()) {
- if (!isInvalidName(message.substring(
- message.lastIndexOf("at") + 3).trim())) {
- attemptingToEnter = true;
- entryAttempt = message.substring(
- message.lastIndexOf("at") + 3).trim();
- }
- }
- }
- }
- if (message.contains("for") && message.contains("altar")) {
- if (message.substring(0, message.indexOf("for"))
- .replaceAll(String.valueOf(' '), "_")
- .replaceAll("-", "_").matches("\\w{1,12}")) {
- if (entryAttempt.isEmpty()) {
- if (!isInvalidName(message.substring(0,
- message.indexOf("for")).trim())) {
- attemptingToEnter = true;
- entryAttempt = message.substring(0,
- message.indexOf("for")).trim();
- }
- }
- }
- }
- if (message.contains("[") && message.contains("]")
- && message.lastIndexOf("]") > message.lastIndexOf("[")) {
- if (message
- .substring(message.lastIndexOf("[") + 1,
- message.lastIndexOf("]"))
- .replaceAll(String.valueOf(' '), "_")
- .replaceAll("-", "_").matches("\\w{1,12}")) {
- if (entryAttempt.isEmpty()) {
- if (!isInvalidName(message.substring(
- message.lastIndexOf("[") + 1,
- message.lastIndexOf("]")))) {
- attemptingToEnter = true;
- entryAttempt = message.substring(
- message.lastIndexOf("[") + 1,
- message.lastIndexOf("]"));
- }
- }
- }
- }
- }
- }
- if (e.getId() == 4) {
- if (e.getMessage().contains(
- "That player is offline, or has privacy mode enabled.")) {
- log.info("Player invalid");
- invalidNames[invalidNames.length] = entryAttempt;
- entryAttempt = "";
- listeningForHost = true;
- }
- }
- if (e.getId() == 109) {
- if (e.getMessage().contains(
- "The gods are very pleased with your offering.")) {
- if (selectedBoneId == dragonBoneId) {
- xpGained = xpGained + 252;
- bonesSacrificed++;
- }
- if (selectedBoneId == frostBoneId) {
- xpGained = xpGained + 630;
- bonesSacrificed++;
- }
- if (selectedBoneId == normalBoneId) {
- xpGained = xpGained + 16;
- bonesSacrificed++;
- }
- }
- if (e.getMessage().contains(
- "The gods are pleased with your offering.")) {
- if (selectedBoneId == dragonBoneId) {
- xpGained = xpGained + 216;
- bonesSacrificed++;
- }
- if (selectedBoneId == frostBoneId) {
- xpGained = xpGained + 540;
- bonesSacrificed++;
- }
- if (selectedBoneId == normalBoneId) {
- xpGained = xpGained + 7;
- bonesSacrificed++;
- }
- }
- }
- if (e.getId() == 0) {
- if (e.getMessage()
- .equals("You'll need to activate the Yanille lodestone before you can Home Teleport there.")) {
- isYanilleTeleportUnlocked = false;
- }
- if (e.getMessage().contains(
- "They have locked their house to visitors.")) {
- entryAttempt = "";
- listeningForHost = true;
- }
- }
- }
- @Override
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.drawString("Animation: " + Players.getLocal().getAnimation(), 30, 30);
- for (Tile t : j.getTileArray()) {
- for (Polygon p : t.getBounds()) {
- g.drawPolygon(p);
- }
- }
- g.setColor(Color.WHITE);
- g.fill(displayPaint);
- g.setColor(Color.cyan);
- g.drawLine(Mouse.getX() - 5, Mouse.getY() - 5, Mouse.getX() + 5,
- Mouse.getY() + 5);
- g.drawLine(Mouse.getX() - 5, Mouse.getY() + 5, Mouse.getX() + 5,
- Mouse.getY() - 5);
- g.setColor(new Color(0, 0, 0, 230));
- g.fill(chatBox.getBoundingRectangle());
- g.setColor(new Color(255, 0, 0));
- g.draw(chatBox.getBoundingRectangle());
- g.setColor(new Color(255, 0, 0));
- g.setFont(new Font("Calibri", Font.BOLD, 20));
- g.drawString("DarkPrayerAIO", chatBox.getAbsoluteX() + 10,
- chatBox.getAbsoluteY() + 10 + 20);
- g.setFont(new Font("Calibri", Font.PLAIN, 15));
- g.drawString("Run time: " + (startTime.toElapsedString()),
- chatBox.getAbsoluteX() + 10, chatBox.getAbsoluteY() + 10 + 20
- + 10 + 15);
- g.drawString("XP Gained: " + xpGained + " [Sacrificed "
- + bonesSacrificed + " bones]", chatBox.getAbsoluteX() + 10,
- chatBox.getAbsoluteY() + 10 + 20 + 10 + 15 + 10 + 15);
- }
- }
Add Comment
Please, Sign In to add comment