Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.RenderingHints;
- import org.powerbot.concurrent.Task;
- import org.powerbot.concurrent.strategy.Condition;
- import org.powerbot.concurrent.strategy.Strategy;
- import org.powerbot.game.api.ActiveScript;
- import org.powerbot.game.api.Manifest;
- import org.powerbot.game.api.methods.Tabs;
- import org.powerbot.game.api.methods.Widgets;
- import org.powerbot.game.api.methods.input.Mouse;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.node.Locations;
- import org.powerbot.game.api.methods.node.Menu;
- import org.powerbot.game.api.methods.tab.Inventory;
- import org.powerbot.game.api.methods.tab.Skills;
- 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.interactive.Player;
- import org.powerbot.game.api.wrappers.node.Item;
- import org.powerbot.game.api.wrappers.node.Location;
- import org.powerbot.game.api.wrappers.widget.WidgetChild;
- import org.powerbot.game.bot.event.MessageEvent;
- import org.powerbot.game.bot.event.listener.MessageListener;
- import org.powerbot.game.bot.event.listener.PaintListener;
- @Manifest(
- name = "xScott's Lunar Planks",
- version = 2.01,
- description = "Makes planks with the PLank Make Spell",
- authors = { "xScott" }
- )
- public class xScottsLunarPlanker extends ActiveScript implements PaintListener, MessageListener
- {
- //private final static int[] BankIDsNpcs =
- // {
- //3293, /*GE(SW/NE)*/ 3416, /*GE(NE/SW)*/
- //3418, /*GE(NW/SW)*/ 553, /*VarrockWest/East/Edgevile*/
- //2718, /*GE(NW)*/ 494, /*Catherby/Lumbridge/Yanille/Ardy(S/N)*/
- //6200, /*Falador(W/E)*/ 7605, /*Fist of guthix*/
- //14924, /*Burthrope(S)*/ 497, /*Al-Kharid Banker*/
- //4457, /*Drayer banker*/ 2759, /*Edgevile*/
- //4519 /*Moonclan*/
- //};
- private final static int[] BankIDsLocs =
- {
- 2738, /*Soulwars chest*/ 25808, /*Seers village bank booths*/
- 2213, /*Catherby/Yanille*/ 782, /*Varrock west/east bankbooth*/
- 36786, /*Lumb bankbooth*/ 11758, /*Falador booth (W/E)*/
- 4483, /*Castle wars chest*/ 27663, /*Duel areana chest*/
- 42192, /*Burthope(N) Chest*/ 66665, /*Burthrope(S) Table*/
- 35647, /*Al-Kharid Booth*/ 2012, /*Draynor booth*/
- 42373, /*Edgevile booth*/ 34752, /*Ardy(N/S)*/
- 16700, /*Moonclan booth*/ 2738 /*soulwars*/
- };
- //Variables
- private static int BankID;
- private static String Status = "Starting up";
- private static int startExp;
- private static long startTime;
- //Widgets
- private static WidgetChild PlankMakeSpell;
- private static WidgetChild[] InventoryItems;
- private static WidgetChild CloseBank;
- private static WidgetChild MagicStats;
- private final RenderingHints antialiasing = new RenderingHints(
- RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- //private final Color color2 = new Color(0, 102, 51);
- private final Color color3 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 12);
- private final Font font2 = new Font("Arial", 1, 16);
- @Override
- protected void setup()
- {
- InventoryItems = Widgets.get(679,0).getChildren();
- PlankMakeSpell = Widgets.get(430, 33);
- CloseBank = Widgets.get(762, 45);
- MagicStats = Widgets.get(320, 66);
- startExp = Skills.getExperiences()[6];
- startTime = System.currentTimeMillis();
- LocateNearestBanker();
- Tabs.INVENTORY.open();
- provide(new MakePlanks());
- provide(new Bank());
- provide(new AntiBan());
- }
- private class Bank extends Strategy implements Task, Condition
- {
- public boolean withdraw(int id) {
- WidgetChild[] bank = Widgets.get(762, 95).getChildren();
- for (WidgetChild child : bank) {
- if (child.getChildId() == id) {
- Mouse.click(child.getRelativeX() + 40,
- child.getRelativeY() + 105, false);
- return Menu.select("Withdraw-All");
- }
- }
- return false;
- }
- private void Deposit()
- {
- if(InventoryItems[24] != null && InventoryItems[24].getChildName().contains("plank"))
- {
- InventoryItems[24].interact("Deposit-All");
- }
- else
- {
- for(Item I : Inventory.getItems())
- {
- if(I.getName().contains("plank"))
- {
- I.getWidgetChild().interact("Deposit-All");
- break;
- }
- }
- }
- }
- @Override
- public void run()
- {
- Location bank_ = Locations.getNearest(BankID);
- Status = "Interacting with bank...";
- if(!bank_.interact("Use")) { bank_.interact("Bank"); }
- Time.sleep(500);
- Status = "Depositing";
- Deposit();
- //InventoryItems[Random.nextInt(2, 27)].interact("Deposit-All");
- Time.sleep(600);
- Status = "Withdrawing";
- withdraw(6332);//Mahogany log ID.
- Time.sleep(Random.nextInt(100,200));
- CloseBank.click(true);
- Tabs.INVENTORY.open();
- }
- @Override
- public boolean validate()
- {
- for(Item I : Inventory.getItems())
- {
- if(I.getName().contains("logs"))
- {
- return false;
- }
- }
- return true;
- }
- }
- private class MakePlanks extends Strategy implements Task, Condition
- {
- //checks if magic tab is open, if not open it.
- private void CheckMagicTabIsOpen()
- {
- if(!Tabs.MAGIC.open()) { Tabs.MAGIC.open(); }
- }
- @Override
- public void run()
- {
- Status = "Checking...";
- CheckMagicTabIsOpen();//checks
- Status = "Casting spell";
- for(Item I : Inventory.getItems())
- {
- if(I.getName().contains("logs"))
- {
- PlankMakeSpell.click(true);
- I.getWidgetChild().click(true);
- Time.sleep(Random.nextInt(1100, 1300));
- break;
- //CheckMagicTabIsOpen();
- }
- }
- }
- @Override
- public boolean validate()
- {
- for(Item I : Inventory.getItems())
- {
- if(I.getName().contains("logs"))
- {
- return true;
- }
- }
- return false;
- }
- }
- private class AntiBan extends Strategy implements Task, Condition
- {
- @Override
- public void run()
- {
- Antiban(Random.nextInt(0,160));
- }
- @Override
- public boolean validate()
- {
- return true;
- }
- void Antiban(int randomNumber)
- {
- if(randomNumber % 2 == 0)
- {
- Status = "Anti-ban";
- switch(randomNumber)
- {
- case 0:
- case 2:
- case 4:
- case 6:
- case 8:
- {
- Camera.setAngle(Random.nextInt(43, 311));
- break;
- }
- case 10:
- {
- for(Player P : Players.getLoaded())
- {
- if(P.isOnScreen())
- {
- P.click(false);
- Time.sleep(Random.nextInt(400,700));
- break;
- }
- }
- }
- case 14:
- {
- Tabs.STATS.open();
- MagicStats.hover();
- Time.sleep(700);
- break;
- }
- case 16:
- {
- Time.sleep(Random.nextInt(500, 2100));
- break;
- }
- }
- }
- }
- }
- private boolean LocateNearestBanker()
- {
- Status = "Locating nearest banker...";
- for(Location Loc : Locations.getLoaded())
- {
- for(final int I : BankIDsLocs)
- {
- if(Loc.getId() == I)
- {
- if(Loc.isOnScreen())
- {
- BankID = I;
- return true;
- }
- }
- }
- }
- return false;
- }
- private String formatTime(final long milliseconds)
- {
- final long t_seconds = milliseconds / 1000;
- final long t_minutes = t_seconds / 60;
- final long t_hours = t_minutes / 60;
- final long seconds = t_seconds % 60;
- final long minutes = t_minutes % 60;
- final long hours = t_hours % 500;
- return hours + ":" + minutes + ":" + seconds;
- }
- @Override
- public void onRepaint(Graphics g1)
- {
- int ExpGained = (Skills.getExperiences()[6] - startExp);
- int ExpPerHour = (int)Math.floor((ExpGained * 3600000D) / (System.currentTimeMillis() - startTime) / 1000);
- String exphr = ExpPerHour + "k";
- String timeElapsed = formatTime(System.currentTimeMillis() - startTime);
- //Mouse
- //g1.setColor(Color.DARK_GRAY);
- //g1.drawLine(mLoc.x, 0, mLoc.x, 505);
- //g1.drawLine(0, mLoc.y, 765, mLoc.y);
- Graphics2D g = (Graphics2D)g1;
- g.setRenderingHints(antialiasing);
- g.setColor(new Color(0,0,0,120));
- g.fillRoundRect(4, 227, 229, 109, 16, 16);
- g.setColor(Color.BLACK);
- g.setStroke(stroke1);
- g.drawRoundRect(4, 227, 229, 109, 16, 16);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("Time elapsed: " + timeElapsed, 22, 266);
- g.drawString("Experience gained: " + ExpGained, 22, 283);
- g.drawString("Exp/hr: " + exphr, 22, 301);
- g.drawString("Status: " + Status, 22, 319);
- g.setFont(font2);
- g.setColor(Color.GRAY);
- g.drawString("xScotts Lunar Planker ", 37, 248);
- g.setColor(new Color(0, 0, 0));
- g.fillOval(Mouse.getX(), Mouse.getY(), 7, 7);
- g.setColor(new Color(153, 153, 153));
- g.fillOval(Mouse.getX() + 1, Mouse.getY() + 1, 5, 5);
- }
- @Override
- public void messageReceived(MessageEvent arg0)
- {
- if(arg0.getMessage().contains("You do not have enough astral")) { stop(); }
- else if(arg0.getMessage().contains("You do not have enough nature")) { stop(); }
- else if(arg0.getMessage().contains("You do not have enough earth")) { stop(); }
- else if(arg0.getMessage().contains("You need")) { stop(); }
- }
- }
Add Comment
Please, Sign In to add comment