- import java.awt.*;
- import javax.swing.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import org.powerbot.concurrent.Task;
- import org.powerbot.concurrent.strategy.Strategy;
- import org.powerbot.game.api.ActiveScript;
- import org.powerbot.game.api.Manifest;
- import org.powerbot.game.api.methods.Calculations;
- 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.Mouse;
- import org.powerbot.game.api.methods.interactive.NPCs;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.node.GroundItems;
- 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.NPC;
- import org.powerbot.game.api.wrappers.node.GroundItem;
- import org.powerbot.game.api.wrappers.node.Item;
- import org.powerbot.game.bot.event.listener.PaintListener;
- @Manifest(authors = { "3G_Connection" }, name = "ConnectMonks", description = "Kills and heals, all at Monks. :)", version = 0.01)
- public class ConnectMonks extends ActiveScript implements PaintListener,
- MouseListener {
- private int MONK_ID = 7727;
- private int HEAD_MONK_ID = 801;
- private int TICKET_ID = 24154;
- private int BONES_ID = 526;
- private boolean bury = false;
- public boolean GuiIsDone = false;
- public JFrame Gui;
- private int kills;
- private int heals;
- private int healsHour;
- String Status = "Starting up";
- private int expGained;
- private int expHour;
- private int expTNL;
- private String training;
- private String SkillNames[] = { "Attack", "Strength", "Defense", "Ranged" };
- private int SkillConstants[] = { Skills.ATTACK, Skills.STRENGTH,
- Skills.DEFENSE, Skills.RANGE };
- private int startxp[] = { 0, 0, 0, 0 };
- private int startlvl[] = { 0, 0, 0, 0 };
- private int lvlGained;
- private int killsHour;
- private int hpExpGained;
- private int hpLvlGained;
- private int hpExpStart;
- private int hpLvlStart;
- private int hpExpHour;
- private int hpExpTNL;
- private int hpLvl;
- public long startTime = System.currentTimeMillis();
- @Override
- protected void setup() {
- startTime = System.currentTimeMillis();
- hpLvlStart = Skills.getRealLevel(Skills.CONSTITUTION);
- hpExpStart = Skills.getExperience(Skills.CONSTITUTION);
- Skills.getExperience(getTrainingSkill());
- hpLevel = Skills.getLevel(Skills.CONSTITUTION);
- hpStartExp = Skills.getExperienceRequired(hpLevel);
- hpNextExp = Skills.getExperienceRequired(hpLevel + 1);
- hpRangeExp = hpNextExp - hpStartExp;
- hpExpToLevel = Skills.getExperienceToLevel(Skills.CONSTITUTION,
- hpLevel + 1);
- hpExpInLevel = hpRangeExp - hpExpToLevel;
- hpPercent = (hpExpInLevel * 100) / hpRangeExp;
- Level = Skills.getLevel(getTrainingSkill());
- StartExp = Skills.getExperienceRequired(Level);
- NextExp = Skills.getExperienceRequired(Level + 1);
- RangeExp = NextExp - StartExp;
- ExpToLevel = Skills.getExperienceToLevel(getTrainingSkill(), Level + 1);
- ExpInLevel = RangeExp - ExpToLevel;
- percent = (ExpInLevel * 100) / RangeExp;
- try {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- GUI gui = new GUI();
- gui.setVisible(true);
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- provide(new Strategy(new Attack(), new Attack()));
- provide(new Strategy(new Heal(), new Heal()));
- provide(new Strategy(new Bury(), new Bury()));
- provide(new Strategy(new Loot(), new Loot()));
- provide(new Strategy(new Antiban(), new Antiban()));
- }
- public class Attack extends Strategy implements Task {
- @Override
- public void run() {
- if (Players.getLocal().getHpPercent() >= 85) {
- NPC monk = NPCs.getNearest(MONK_ID);
- if (monk != null) {
- if (!monk.isOnScreen()) {
- Camera.turnTo(monk.getLocation());
- if (!monk.isOnScreen()) {
- Walking.walk(monk.getLocation());
- Time.sleep(Random.nextInt(3000, 3500));
- }
- }
- }
- if (!monk.isInCombat()
- && Players.getLocal().getAnimation() != -1) {
- monk.hover();
- } else {
- if (!monk.isInCombat()
- && Players.getLocal().getAnimation() == -1) {
- monk.interact("Attack");
- Status = "Attacking";
- Time.sleep(Random.nextInt(400, 500));
- if (Players.getLocal().getInteracting().getHpPercent() == 0);
- kills++;
- }
- }
- }
- }
- @Override
- public boolean validate() {
- return Players.getLocal().getAnimation() == -1 && GuiIsDone;
- }
- }
- public class Heal extends Strategy implements Task {
- @Override
- public void run() {
- Status = "Healing";
- NPC headMonk = NPCs.getNearest(HEAD_MONK_ID);
- if (headMonk != null) {
- if (!headMonk.isOnScreen()) {
- Walking.walk(headMonk.getLocation());
- Time.sleep(Random.nextInt(4500, 5500));
- Camera.turnTo(headMonk);
- headMonk.click(true);
- if (!headMonk.isOnScreen()) {
- Walking.walk(headMonk.getLocation());
- } else {
- headMonk.interact("Talk-to");
- Time.sleep(Random.nextInt(2500, 3000));
- if (Widgets.canContinue()) {
- Widgets.clickContinue();
- Time.sleep(Random.nextInt(500, 1250));
- Widgets.get(1188, 3).click(true);
- Time.sleep(Random.nextInt(550, 1000));
- Widgets.clickContinue();
- Time.sleep(Random.nextInt(650, 950));
- Widgets.clickContinue();
- Time.sleep(Random.nextInt(600, 1100));
- if (Widgets.canContinue()) {
- Widgets.clickContinue();
- Time.sleep(Random.nextInt(1000, 2000));
- heals++;
- }
- }
- }
- }
- }
- }
- @Override
- public boolean validate() {
- return Players.getLocal().getHpPercent() <= 40 && GuiIsDone;
- }
- }
- public class Bury extends Strategy implements Task {
- @Override
- public void run() {
- for (final Item bones : Inventory.getItems()) {
- if (bones.getId() == BONES_ID
- && bones.getWidgetChild().interact("Bury")) {
- Time.sleep(Random.nextInt(750, 1000));
- }
- }
- }
- @Override
- public boolean validate() {
- return Inventory.getCount() == 28 && GuiIsDone
- && bury == true;
- }
- }
- private class Loot extends Strategy implements Task {
- @Override
- public void run() {
- Status = "Getting Ticket";
- if (GroundItems.getNearest(TICKET_ID) != null) {
- GroundItem ticket = GroundItems.getNearest(TICKET_ID);
- if (ticket != null) {
- ticket.interact("Take");
- if (Tabs.getCurrent() != Tabs.INVENTORY) {
- Tabs.INVENTORY.open();
- } else {
- if (Tabs.getCurrent() == Tabs.INVENTORY) {
- ticket.interact("Claim");
- }
- }
- }
- }
- if (bury = true) {
- GroundItem bones = GroundItems.getNearest(BONES_ID);
- if (bones != null) {
- if (Calculations.distanceTo(bones) < 5) {
- bones.interact("Take");
- Time.sleep(Random.nextInt(1500, 3000));
- }
- }
- }
- }
- @Override
- public boolean validate() {
- return !Players.getLocal().isInCombat() && GuiIsDone
- && Inventory.getCount() != 28;
- }
- }
- private class Antiban extends Strategy implements Task {
- @Override
- public void run() {
- Status = "Antiban";
- switch (Random.nextInt(1, 20)) {
- case 1:
- Camera.setAngle(Random.nextInt(1, 360));
- break;
- case 2:
- Camera.setPitch(Random.nextInt(1, 360));
- break;
- case 3:
- Camera.setAngle(Random.nextInt(350, 500));
- break;
- case 4:
- Camera.setPitch(Random.nextInt(350, 500));
- break;
- case 5:
- Mouse.move(Random.nextInt(0, 250), Random.nextInt(0, 250));
- break;
- case 6:
- Mouse.move(Random.nextInt(250, 500), Random.nextInt(250, 500));
- break;
- case 7:
- Tabs.STATS.open();
- break;
- case 8:
- Tabs.INVENTORY.open();
- break;
- case 9:
- Widgets.get(548).getChild(14).click(true);
- break;
- case 10:
- case 11:
- if (Tabs.getCurrent() != Tabs.STATS)
- Tabs.STATS.open();
- Widgets.get(320).getChild(2).hover();
- break;
- case 12:
- case 13:
- if (Tabs.getCurrent() != Tabs.STATS)
- Tabs.STATS.open();
- Widgets.get(320).getChild(4).hover();
- break;
- }
- }
- @Override
- public boolean validate() {
- return Players.getLocal().getAnimation() != -1 && GuiIsDone;
- }
- }
- private int getTrainingSkill() {
- for (int i = 0; i < SkillConstants.length; i++) {
- if (Skills.getExperience(SkillConstants[i]) > startxp[i]) {
- training = SkillNames[i];
- return SkillConstants[i];
- }
- }
- return -1;
- }
- private int getStartxp(int i) {
- for (int g = 0; g < SkillConstants.length; g++) {
- if (i == SkillConstants[g]) {
- return startxp[g];
- }
- }
- return -1;
- }
- private int getStartLvl(int i) {
- for (int g = 0; g < SkillConstants.length; g++) {
- if (i == SkillConstants[g]) {
- return startlvl[g];
- }
- }
- return -1;
- }
- int hpLevel;
- int hpStartExp;
- int hpNextExp;
- int hpRangeExp;
- int hpExpToLevel;
- int hpExpInLevel;
- int hpPercent;
- int Level;
- int StartExp;
- int NextExp;
- int RangeExp;
- int ExpToLevel;
- int ExpInLevel;
- int percent;
- private double getXpHour(double expGained) {
- return ((3600000.0 / (System.currentTimeMillis() - startTime)) * expGained);
- }
- private double getKillsHour(double kills) {
- return ((3600000.0 / (System.currentTimeMillis() - startTime)) * kills);
- }
- private double getHealsHour(double heals) {
- return ((3600000.0 / (System.currentTimeMillis() - startTime)) * heals);
- }
- private double getHpExpHour(double hpExpGained) {
- return ((3600000.0 / (System.currentTimeMillis() - startTime)) * hpExpGained);
- }
- /*
- * ---------------------------------PAINT-----------------------------------
- */
- private final Color color1 = new Color(0, 0, 0, 179);
- private final Color color2 = new Color(255, 255, 255);
- private final Color color3 = new Color(204, 0, 0);
- private final Color color4 = new Color(0, 0, 0);
- private final Color color5 = new Color(51, 153, 0);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 1, 12);
- private final Font font2 = new Font("Arial", 0, 9);
- @Override
- public void onRepaint(Graphics g1) {
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- expGained = (Skills.getExperience(getTrainingSkill()) - getStartxp(getTrainingSkill()));
- expHour = (int) getXpHour(expGained);
- lvlGained = (Skills.getLevel(getTrainingSkill()) - getStartLvl(getTrainingSkill()));
- killsHour = (int) getKillsHour(kills);
- hpExpGained = (Skills.getExperience(Skills.CONSTITUTION) - hpExpStart);
- hpLvlGained = (Skills.getLevel(Skills.CONSTITUTION) - hpLvlStart);
- hpExpHour = (int) getHpExpHour(hpExpGained);
- hpExpTNL = Skills.getExperienceToLevel(Skills.CONSTITUTION,
- (Skills.getRealLevel(Skills.CONSTITUTION) + 1));
- expTNL = Skills.getExperienceToLevel(getTrainingSkill(),
- (Skills.getRealLevel(getTrainingSkill()) + 1));
- hpPercent = (int) ((double) Skills.getExperienceToLevel(
- Skills.CONSTITUTION,
- (Skills.getRealLevel(Skills.CONSTITUTION) + 1))
- / Skills.getExperience(Skills.CONSTITUTION) * 100);
- hpLvl = Skills.getLevel(Skills.CONSTITUTION);
- hpLvlGained = (Skills.getLevel(Skills.CONSTITUTION) - hpLvlStart);
- percent = (int) ((double) Skills.getExperienceToLevel(
- getTrainingSkill(),
- (Skills.getRealLevel(getTrainingSkill()) + 1))
- / Skills.getExperience(getTrainingSkill()) * 100);
- healsHour = (int) getHealsHour(heals);
- // START: Code generated using Enfilade's Easel
- Graphics2D g = (Graphics2D) g1;
- g.setColor(color1);
- g.fillRoundRect(363, 168, 153, 169, 16, 16);
- g.setFont(font1);
- g.setColor(color2);
- g.drawString("ConnectMonks", 401, 185);
- g.setFont(font2);
- g.drawString("Runtime: " + hours + ":" + minutes + ":" + seconds, 370,
- 210);
- g.drawString("Training: " + training, 370, 230);
- g.drawString("Kills: " + kills, 370, 250);
- g.drawString("Kills/Hr: " + killsHour, 370, 270);
- g.drawString("Heals: " + heals, 370, 290);
- g.drawString("Heals/Hr: " + healsHour, 370, 310);
- g.drawString("Status: " + Status, 370, 330);
- g.drawString("HP: " + hpExpGained + " Exp " + hpExpHour + "/Hr" + "|| "
- + hpPercent + "% " + hpExpTNL + " TNL" + "|| Lvl: " + hpLvl
- + " Gained: " + hpLvlGained, 13, 305);
- g.drawString("" + training + ": " + expGained + "Exp " + expHour
- + "/Hr" + "|| " + percent + "% " + expTNL + " TNL" + "|| Lvl: "
- + getTrainingSkill() + " Gained: " + lvlGained, 13, 330);
- g.setColor(color3);
- g.fillRoundRect(4, 315, 350, 22, 16, 16);
- g.setColor(color4);
- g.setStroke(stroke1);
- g.drawRoundRect(4, 315, 350, 22, 16, 16);
- g.setColor(color5);
- g.fillRoundRect(4, 315, (30 * (hpPercent / 10)), 22, 16, 16);
- g.setColor(color4);
- g.drawRoundRect(4, 315, 300, 22, 16, 16);
- g.setColor(color3);
- g.fillRoundRect(4, 290, 350, 22, 16, 16);
- g.setColor(color4);
- g.drawRoundRect(4, 290, 350, 22, 16, 16);
- g.setColor(color5);
- g.fillRoundRect(4, 290, (35 * (percent / 10)), 22, 16, 16);
- g.setColor(color4);
- g.drawRoundRect(4, 290, 295, 22, 16, 16);
- // END: Code generated using Enfilade's Easel
- }
- @Override
- public void mouseClicked(MouseEvent e) {
- }
- @Override
- public void mouseEntered(MouseEvent arg0) {
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- }
- @Override
- public void mousePressed(MouseEvent arg0) {
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- }
- public class GUI extends JFrame {
- private static final long serialVersionUID = 1L;
- public GUI() {
- this.setVisible(true);
- initComponents();
- }
- private void initComponents() {
- // JFormDesigner - Component initialization - DO NOT MODIFY
- // //GEN-BEGIN:initComponents
- startButton = new JButton();
- optionSelect = new JComboBox();
- title = new JLabel();
- // ======== this ========
- Container contentPane = getContentPane();
- // ---- button1 ----
- startButton.setText("Start!");
- startButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- startButtonClick(e);
- }
- });
- // ---- comboBox1 ----
- optionSelect.setModel(new DefaultComboBoxModel(new String[] {
- "Leave Bones", "Burying Bones" }));
- // ---- label1 ----
- title.setText("ConnectMonks");
- title.setHorizontalAlignment(SwingConstants.CENTER);
- title.setFont(new Font("Malayalam MN", Font.PLAIN, 28));
- GroupLayout contentPaneLayout = new GroupLayout(contentPane);
- contentPane.setLayout(contentPaneLayout);
- contentPaneLayout
- .setHorizontalGroup(contentPaneLayout
- .createParallelGroup()
- .addGroup(
- contentPaneLayout
- .createSequentialGroup()
- .addContainerGap()
- .addGroup(
- contentPaneLayout
- .createParallelGroup()
- .addComponent(
- optionSelect,
- GroupLayout.DEFAULT_SIZE,
- 203,
- Short.MAX_VALUE)
- .addComponent(
- title,
- GroupLayout.DEFAULT_SIZE,
- GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)
- .addComponent(
- startButton,
- GroupLayout.DEFAULT_SIZE,
- 203,
- Short.MAX_VALUE))
- .addContainerGap()));
- contentPaneLayout.setVerticalGroup(contentPaneLayout
- .createParallelGroup().addGroup(
- GroupLayout.Alignment.TRAILING,
- contentPaneLayout
- .createSequentialGroup()
- .addGap(10, 10, 10)
- .addComponent(title,
- GroupLayout.PREFERRED_SIZE, 24,
- GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(optionSelect,
- GroupLayout.PREFERRED_SIZE,
- GroupLayout.DEFAULT_SIZE,
- GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(startButton,
- GroupLayout.PREFERRED_SIZE, 37,
- GroupLayout.PREFERRED_SIZE)
- .addContainerGap(12, Short.MAX_VALUE)));
- pack();
- setLocationRelativeTo(getOwner());
- // JFormDesigner - End of component initialization
- // //GEN-END:initComponents
- }
- // JFormDesigner - Variables declaration - DO NOT MODIFY
- // //GEN-BEGIN:variables
- private JButton startButton;
- private JComboBox optionSelect;
- private JLabel title;
- // JFormDesigner - End of variables declaration //GEN-END:variables
- private void startButtonClick(ActionEvent e) {
- if (e.getActionCommand() == "Start") {
- Gui.setVisible(false);
- GuiIsDone = true;
- }
- String option = optionSelect.getSelectedItem().toString(); {
- if (option.equals("Burying Bones")) {
- bury = true;
- } else {
- bury = false;
- }
- }
- }
- }
- }
- ------------------------------------------------------------------------------------------------------------
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.net.URL;
- import java.net.URLConnection;
- import org.powerbot.concurrent.Task;
- import org.powerbot.concurrent.strategy.Strategy;
- import org.powerbot.game.api.ActiveScript;
- import org.powerbot.game.api.Manifest;
- import org.powerbot.game.api.methods.Calculations;
- 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.Mouse;
- import org.powerbot.game.api.methods.interactive.NPCs;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.node.GroundItems;
- import org.powerbot.game.api.methods.node.SceneEntities;
- 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.Area;
- import org.powerbot.game.api.wrappers.Tile;
- import org.powerbot.game.api.wrappers.interactive.NPC;
- import org.powerbot.game.api.wrappers.node.GroundItem;
- import org.powerbot.game.api.wrappers.node.Item;
- import org.powerbot.game.api.wrappers.node.SceneObject;
- import org.powerbot.game.bot.event.MessageEvent;
- import org.powerbot.game.bot.event.listener.MessageListener;
- import org.powerbot.game.bot.event.listener.PaintListener;
- @Manifest(authors = { "3G Connection" }, name = "SpeedHillies", description = "Kills Hillies at Edgeville Dungeon & banks")
- public class ConnectHillies extends ActiveScript implements PaintListener,
- MouseListener, MessageListener {
- String Status = "Starting up";
- private int[] GIANT_ID = { 0 };
- private int[] LOOT_ID = { 225, 5321, 207, 209, 211, 213, 215, 217, 2485,
- 554, 564, 563, 561, 560, 1119, 12163, 12160, 12159, 12158 };
- private int BONES_ID = 532;
- private int LADDER_ID = 0;
- private int DOOR_ID = 0;
- private int BANK_ID = 0;
- private int TRAPDOOR_ID = 0;
- private int KEY_ID = 983;
- private int FOOD_ID = 0;
- private int TICKET_ID = 24154;
- private int MUSICIAN_ID = 0;
- private int LIMP_ID = 225;
- private int FIRE_ID = 554;
- private int COSMIC_ID = 564;
- private int LAW_ID = 563;
- private int DEATH_ID = 560;
- private int NATURE_ID = 561;
- private int STEEL_PLATE_ID = 1119;
- private int WATER_SEED_ID = 5321;
- private int LANTADYME_ID = 2485;
- private int CADANTINE_ID = 215;
- private int DWARF_WEED_ID = 217;
- private int KWUARM_ID = 213;
- private int AVANTOE_ID = 211;
- private int IRIT_ID = 209;
- private int RANARR_ID = 207;
- private int bonesPrice, limpPrice, firePrice, cosmicPrice, lawPrice,
- deathPrice, naturePrice, steelPlatePrice, watermelonSeedPrice,
- lantadymePrice, cadantinePrice, dwarfWeedPrice, kwuarmPrice,
- avantoePrice, iritPrice, ranarrPrice;
- private int money;
- private int moneyHour;
- private int expHour;
- private int expGained;
- private int expTNL;
- private int hpExpHour;
- private int hpExpGained;
- private int hpExpTNL;
- private int hpLvlStart;
- private int hpExpStart;
- private int hpLvlGained;
- private int hpLvl;
- private int lvlGained;
- private String training;
- private String SkillNames[] = { "Attack", "Strength", "Defense", "Ranged" };
- private int SkillConstants[] = { Skills.ATTACK, Skills.STRENGTH,
- Skills.DEFENSE, Skills.RANGE };
- private int startxp[] = { 0, 0, 0, 0 };
- private int startlvl[] = { 0, 0, 0, 0 };
- private int kills;
- private int killsHour;
- public long startTime = System.currentTimeMillis();
- int before;
- int count = Inventory.getCount(BONES_ID);
- Area BANK_AREA = new Area(new Tile[] { new Tile(3178, 3446, 0),
- new Tile(3178, 3431, 0), new Tile(3193, 3431, 0),
- new Tile(3193, 3446, 0) });
- Area ROOM_AREA = new Area(new Tile[] { new Tile(3112, 3453, 0),
- new Tile(3112, 3450, 0), new Tile(3117, 3450, 0),
- new Tile(3117, 3453, 0) });
- private final Area HILLY_AREA = new Area(new Tile[] { new Tile(1, 2, 0) });
- @Override
- protected void setup() {
- startTime = System.currentTimeMillis();
- hpLvlStart = Skills.getRealLevel(Skills.CONSTITUTION);
- hpExpStart = Skills.getExperience(Skills.CONSTITUTION);
- Skills.getExperience(getTrainingSkill());
- bonesPrice = getPrice(BONES_ID);
- limpPrice = getPrice(LIMP_ID);
- firePrice = getPrice(FIRE_ID);
- cosmicPrice = getPrice(COSMIC_ID);
- lawPrice = getPrice(LAW_ID);
- deathPrice = getPrice(DEATH_ID);
- naturePrice = getPrice(NATURE_ID);
- steelPlatePrice = getPrice(STEEL_PLATE_ID);
- watermelonSeedPrice = getPrice(WATER_SEED_ID);
- lantadymePrice = getPrice(LANTADYME_ID);
- cadantinePrice = getPrice(CADANTINE_ID);
- dwarfWeedPrice = getPrice(DWARF_WEED_ID);
- kwuarmPrice = getPrice(KWUARM_ID);
- avantoePrice = getPrice(AVANTOE_ID);
- iritPrice = getPrice(IRIT_ID);
- ranarrPrice = getPrice(RANARR_ID);
- hpLevel = Skills.getLevel(Skills.CONSTITUTION);
- hpStartExp = Skills.getExperienceRequired(hpLevel);
- hpNextExp = Skills.getExperienceRequired(hpLevel + 1);
- hpRangeExp = hpNextExp - hpStartExp;
- hpExpToLevel = Skills.getExperienceToLevel(Skills.CONSTITUTION,
- hpLevel + 1);
- hpExpInLevel = hpRangeExp - hpExpToLevel;
- hpPercent = (hpExpInLevel * 100) / hpRangeExp;
- Level = Skills.getLevel(getTrainingSkill());
- StartExp = Skills.getExperienceRequired(Level);
- NextExp = Skills.getExperienceRequired(Level + 1);
- RangeExp = NextExp - StartExp;
- ExpToLevel = Skills.getExperienceToLevel(getTrainingSkill(), Level + 1);
- ExpInLevel = RangeExp - ExpToLevel;
- percent = (ExpInLevel * 100) / RangeExp;
- provide(new WalkingPath());
- provide(new Attack());
- provide(new Loot());
- provide(new Bank());
- provide(new Antiban());
- }
- public int getPrice(int id) {
- try {
- String price;
- URL url = new URL(
- "http://services.runescape.com/m=itemdb_rs/viewitem.ws?obj="
- + id);
- URLConnection con = url.openConnection();
- BufferedReader in = new BufferedReader(new InputStreamReader(
- con.getInputStream()));
- String line;
- while ((line = in.readLine()) != null) {
- if (line.contains("<td>")) {
- price = line.substring(line.indexOf(">") + 1,
- line.indexOf("/") - 1);
- try {
- return Integer.parseInt(price);
- } catch (NumberFormatException e) {
- return 0;
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return 0;
- }
- public class WalkingPath extends Strategy implements Task {
- @Override
- public void run() {
- Status = "Walking";
- if (Inventory.getCount() == 28
- && HILLY_AREA.contains(Players.getLocal())) {
- SceneObject ladder = SceneEntities.getNearest(LADDER_ID);
- if (ladder != null) {
- Walking.walk(ladder);
- if (Inventory.getCount() == 28
- && ROOM_AREA.contains(Players.getLocal())) {
- SceneObject door = SceneEntities.getNearest(DOOR_ID);
- Walking.walk(door);
- if (door != null) {
- if (door.isOnScreen()) {
- door.interact("Open");
- if (!door.isOnScreen()
- && ROOM_AREA.contains(Players
- .getLocal())) {
- Camera.turnTo(door);
- }
- }
- }
- }
- if (Inventory.getCount() != 28
- && ROOM_AREA.contains(Players.getLocal())) {
- SceneObject trapdoor = SceneEntities
- .getNearest(TRAPDOOR_ID);
- if (trapdoor != null) {
- trapdoor.interact("Go down");
- }
- }
- if (Inventory.getCount() != 28
- && BANK_AREA.contains(Players.getLocal())) {
- NPC musician = NPCs.getNearest(MUSICIAN_ID);
- if (Calculations.distanceTo(musician) >= 5) {
- Walking.findPath(musician).traverse();
- musician.interact("Rest");
- }
- }
- if (Inventory.getCount() != 28) {
- NPC musician = NPCs.getNearest(MUSICIAN_ID);
- SceneObject door = SceneEntities.getNearest(DOOR_ID);
- if (musician.isOnScreen() && Walking.getEnergy() == 100) {
- Walking.findPath(door).traverse();
- door.interact("Open");
- }
- }
- }
- }
- }
- }
- public class Attack extends Strategy implements Task {
- @Override
- public void run() {
- if (Inventory.getCount() != 28) {
- NPC hilly = NPCs.getNearest(GIANT_ID);
- if (hilly != null) {
- if (hilly.isOnScreen() && !hilly.isInCombat()
- && Calculations.distanceTo(hilly) <= 8) {
- hilly.interact("Attack");
- Status = "Fighting";
- } else {
- if (!hilly.isOnScreen()
- && HILLY_AREA.contains(Players.getLocal())) {
- Camera.turnTo(hilly);
- }
- }
- } else {
- if (Players.getLocal().isInCombat()) {
- Time.sleep(Random.nextInt(2000, 4000));
- if (Players.getLocal().getInteracting().getHpPercent() == 0) {
- kills++;
- }
- }
- }
- }
- }
- }
- public class Loot extends Strategy implements Task {
- @Override
- public void run() {
- Status = "Looting";
- GroundItem ticket = GroundItems.getNearest(TICKET_ID);
- if (ticket != null) {
- if (ticket.isOnScreen()) {
- ticket.interact("Take");
- Time.sleep(Random.nextInt(500, 750));
- if (!Tabs.INVENTORY.isOpen()) {
- Tabs.INVENTORY.open();
- ticket.interact("Claim");
- }
- }
- }
- if (Players.getLocal().isInCombat()) {
- Time.sleep(Random.nextInt(1500, 2500));
- if (!Players.getLocal().isInCombat()) {
- GroundItem loot = GroundItems.getNearest(LOOT_ID);
- GroundItem bone = GroundItems.getNearest(BONES_ID);
- if (loot != null)
- ;
- if (bone != null)
- ;
- if (Calculations.distanceTo(bone.getLocation()) < 5) {
- if (Calculations.distanceTo(loot.getLocation()) < 5) {
- bone.interact("Take");
- loot.interact("Take");
- Time.sleep(Random.nextInt(2000, 2500));
- }
- }
- }
- }
- }
- }
- public class Bank extends Strategy implements Task {
- @Override
- public void run() {
- SceneObject bank = SceneEntities.getNearest(BANK_ID);
- bank.interact("Bank");
- Status = "Banking";
- if (org.powerbot.game.api.methods.widget.Bank.isOpen()) {
- if (Inventory.getCount() == 28) {
- org.powerbot.game.api.methods.widget.Bank
- .depositInventory();
- org.powerbot.game.api.methods.widget.Bank.withdraw(KEY_ID,
- 1);
- }
- if (Players.getLocal().getHpPercent() <= 45) {
- org.powerbot.game.api.methods.widget.Bank.withdraw(FOOD_ID,
- 6);
- org.powerbot.game.api.methods.widget.Bank.close();
- if (Tabs.getCurrent() != Tabs.INVENTORY) {
- if (Tabs.INVENTORY.open(true)) {
- Time.sleep(250, 500);
- for (Item i : Inventory.getItems()) {
- if (i.getId() == 0) {
- i.getWidgetChild().interact("Eat");
- if (Inventory.getCount(KEY_ID) == 0) {
- org.powerbot.game.api.methods.widget.Bank
- .withdraw(KEY_ID, 1);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- public class Antiban extends Strategy implements Task {
- @Override
- public void run() {
- int random = Random.nextInt(1, 20);
- switch (random) {
- case 2:
- if (!Tabs.STATS.isOpen()) {
- Tabs.STATS.open();
- Widgets.get(320).getChild(2).hover();
- Time.sleep(Random.nextInt(250, 500));
- }
- case 5:
- if (Tabs.STATS.isOpen()) {
- Tabs.STATS.open();
- Widgets.get(320).getChild(getTrainingSkill()).hover();
- Time.sleep(Random.nextInt(250, 500));
- }
- case 8:
- Camera.setAngle(Random.nextInt(50, 300));
- Time.sleep(Random.nextInt(250, 350));
- case 11:
- Camera.setPitch(Random.nextInt(75, 225));
- case 14:
- Mouse.move(Random.nextInt(150, 225), 0);
- Time.sleep(Random.nextInt(750, 1250));
- case 16:
- Mouse.move(Random.nextInt(250, 350), 0);
- Time.sleep(Random.nextInt(500, 1000));
- case 19:
- if (Tabs.INVENTORY.isOpen()) {
- Tabs.INVENTORY.open();
- Time.sleep(Random.nextInt(750, 1250));
- }
- }
- }
- }
- private int getTrainingSkill() {
- for (int i = 0; i < SkillConstants.length; i++) {
- if (Skills.getExperience(SkillConstants[i]) > startxp[i]) {
- training = SkillNames[i];
- return SkillConstants[i];
- }
- }
- return -1;
- }
- private int getStartxp(int i) {
- for (int g = 0; g < SkillConstants.length; g++) {
- if (i == SkillConstants[g]) {
- return startxp[g];
- }
- }
- return -1;
- }
- private int getStartLvl(int i) {
- for (int g = 0; g < SkillConstants.length; g++) {
- if (i == SkillConstants[g]) {
- return startlvl[g];
- }
- }
- return -1;
- }
- int hpLevel;
- int hpStartExp;
- int hpNextExp;
- int hpRangeExp;
- int hpExpToLevel;
- int hpExpInLevel;
- int hpPercent;
- int Level;
- int StartExp;
- int NextExp;
- int RangeExp;
- int ExpToLevel;
- int ExpInLevel;
- int percent;
- private double getXpHour(double expGained) {
- return ((3600000.0 / (System.currentTimeMillis() - startTime)) * expGained);
- }
- private double getKillsHour(double kills) {
- return ((3600000.0 / (System.currentTimeMillis() - startTime)) * kills);
- }
- private double getHpExpHour(double hpExpGained) {
- return ((3600000.0 / (System.currentTimeMillis() - startTime)) * hpExpGained);
- }
- private double getMoneyHour(double money) {
- return ((3600000.0 / (System.currentTimeMillis() - startTime)) * money);
- }
- // ----------------------------------- PAINT
- // ---------------------------------------- //
- private final Color color1 = new Color(0, 0, 0, 179);
- private final Color color2 = new Color(255, 255, 255);
- private final Color color3 = new Color(204, 0, 0);
- private final Color color4 = new Color(0, 0, 0);
- private final Color color5 = new Color(51, 153, 0);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 1, 12);
- private final Font font2 = new Font("Arial", 0, 9);
- public void onRepaint(Graphics g1) {
- money = bonesPrice + limpPrice + firePrice + cosmicPrice + lawPrice
- + deathPrice + naturePrice + steelPlatePrice
- + watermelonSeedPrice + lantadymePrice + cadantinePrice
- + dwarfWeedPrice + kwuarmPrice + avantoePrice + iritPrice
- + ranarrPrice;
- moneyHour = (int) getMoneyHour(money);
- expGained = (Skills.getExperience(getTrainingSkill()) - getStartxp(getTrainingSkill()));
- expHour = (int) getXpHour(expGained);
- lvlGained = (Skills.getLevel(getTrainingSkill()) - getStartLvl(getTrainingSkill()));
- killsHour = (int) getKillsHour(kills);
- hpExpGained = (Skills.getExperience(Skills.CONSTITUTION) - hpExpStart);
- hpLvlGained = (Skills.getLevel(Skills.CONSTITUTION) - hpLvlStart);
- hpExpHour = (int) getHpExpHour(hpExpGained);
- hpExpTNL = Skills.getExperienceToLevel(Skills.CONSTITUTION,
- (Skills.getRealLevel(Skills.CONSTITUTION) + 1));
- expTNL = Skills.getExperienceToLevel(getTrainingSkill(),
- (Skills.getRealLevel(getTrainingSkill()) + 1));
- hpPercent = (int) ((double) Skills.getExperienceToLevel(
- Skills.CONSTITUTION,
- (Skills.getRealLevel(Skills.CONSTITUTION) + 1))
- / Skills.getExperience(Skills.CONSTITUTION) * 100);
- hpLvl = Skills.getLevel(Skills.CONSTITUTION);
- hpLvlGained = (Skills.getLevel(Skills.CONSTITUTION) - hpLvlStart);
- percent = (int) ((double) Skills.getExperienceToLevel(
- getTrainingSkill(),
- (Skills.getRealLevel(getTrainingSkill()) + 1))
- / Skills.getExperience(getTrainingSkill()) * 100);
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- // START: Code generated using Enfilade's Easel
- Graphics2D g = (Graphics2D) g1;
- g.setColor(color1);
- g.fillRoundRect(363, 168, 153, 169, 16, 16);
- g.setFont(font1);
- g.setColor(color2);
- g.drawString("ConnectHillies", 401, 185);
- g.setFont(font2);
- g.drawString("Runtime: " + hours + ":" + minutes + ":" + seconds, 370,
- 210);
- g.drawString("Training: " + training, 370, 230);
- g.drawString("Kills: " + kills, 370, 250);
- g.drawString("Kills/Hr: " + killsHour, 370, 270);
- g.drawString("Money: " + money, 370, 290);
- g.drawString("Money/Hr: " + moneyHour, 370, 310);
- g.drawString("Status: " + Status, 370, 330);
- g.drawString("HP: " + hpExpGained + " Exp " + hpExpHour + "/Hr" + "|| "
- + hpPercent + "% " + hpExpTNL + " TNL" + "|| Lvl: " + hpLvl
- + " Gained: " + hpLvlGained, 13, 305);
- g.drawString("" + training + ": " + expGained + "Exp " + expHour
- + "/Hr" + "|| " + percent + "% " + expTNL + " TNL" + "|| Lvl: "
- + getTrainingSkill() + " Gained: " + lvlGained, 13, 330);
- g.setColor(color3);
- g.fillRoundRect(4, 315, 350, 22, 16, 16);
- g.setColor(color4);
- g.setStroke(stroke1);
- g.drawRoundRect(4, 315, 350, 22, 16, 16);
- g.setColor(color5);
- g.fillRoundRect(4, 315, (30 * (hpPercent / 10)), 22, 16, 16);
- g.setColor(color4);
- g.drawRoundRect(4, 315, 300, 22, 16, 16);
- g.setColor(color3);
- g.fillRoundRect(4, 290, 350, 22, 16, 16);
- g.setColor(color4);
- g.drawRoundRect(4, 290, 350, 22, 16, 16);
- g.setColor(color5);
- g.fillRoundRect(4, 290, (35 * (percent / 10)), 22, 16, 16);
- g.setColor(color4);
- g.drawRoundRect(4, 290, 295, 22, 16, 16);
- // END: Code generated using Enfilade's Easel
- /*
- * Graphics2D g = (Graphics2D)g1;g.setColor(color);g.setFont(font);
- * g.drawString("" + hours + ":" + minutes + ":" + seconds, 67, 408); //
- * Timeg.drawString("" + expGained, 57, 430); // Expg.drawString("" +
- * expHour, 77, 453); // Exp/Hrg.drawString("" + bones, 197, 408); //
- * Bonesg.drawString("" + bonesHour, 215, 430); // Bones/Hr
- * g.drawString("" + kills, 196, 453); // Killsg.drawString("" +
- * killsHour, 315, 453); // Kills/Hrg.drawString("" + trips, 432, 408);
- * // Tripsg.drawString("" + tripsHour, 450, 430); // Trips/Hr
- * g.drawString("" + Status, 439, 453); // Statusg.drawString("" +
- * training, 280, 378); // Training
- */
- }
- @Override
- public void messageReceived(MessageEvent arg0) {
- }
- @Override
- public void mouseClicked(MouseEvent arg0) {
- }
- @Override
- public void mouseEntered(MouseEvent arg0) {
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- }
- @Override
- public void mousePressed(MouseEvent arg0) {
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- }
- }