Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Insets;
- import java.awt.LayoutManager;
- import java.awt.Point;
- import java.awt.event.ActionEvent;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JLabel;
- import javax.swing.JTextField;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Game;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.wrappers.RSGroundItem;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors = { "Petje123" }, name = "Ghoulkiller", version = 1.0, description = "Kills ghouls at the north place")
- public class Ghoulkiller extends Script implements PaintListener {
- RSTile[] bankToGhoul = { new RSTile(3512, 3479), new RSTile(3500, 3483),
- new RSTile(3485, 3479), new RSTile(3451, 3487),
- new RSTile(3470, 3474), new RSTile(3455, 3481),
- new RSTile(3441, 3486), new RSTile(3429, 3496),
- new RSTile(3419, 3505), new RSTile(3417, 3509) };
- RSTile[] ghoulToBank = { new RSTile(3417, 3509), new RSTile(3426, 3501),
- new RSTile(3438, 3494), new RSTile(3451, 3487),
- new RSTile(3462, 3478), new RSTile(3477, 3478),
- new RSTile(3491, 3483), new RSTile(3505, 3482),
- new RSTile(3512, 3479) };
- RSTile ghoulTile = new RSTile(3415, 3513);
- RSTile bankTile = new RSTile(3512, 3479);;
- RSGroundItem itegr;
- volatile RSGroundItem ite;
- int foodb = 0;
- int ghoul = 1218;
- int food;
- int[] items = { 12158, 12163, 12160, 12159, 10266, 10264, 10265, 10263 };
- boolean inFight = false;
- boolean walkToBank = false;
- boolean walkToghoul = false;
- public String status;
- int trainStatran;
- int startStatLvlran;
- int startXpran;
- int trainStatdef;
- int startStatLvldef;
- int startXpdef;
- int trainStatatt;
- int startStatLvlatt;
- int startXpatt;
- int trainStatstr;
- int startStatLvlstr;
- int startXpstr;
- int htrainStat;
- int hstartStatLvl;
- int hstartXp;
- long startTime = System.currentTimeMillis();
- boolean pickup = true;
- boolean eat = true;
- private gui gui;
- JLabel label_1;
- JLabel label_2;
- JComboBox combobox_1;
- JTextField textfield_1;
- JLabel label_3;
- JLabel label_4;
- JComboBox combobox_2;
- JLabel label_5;
- JComboBox combobox_3;
- JLabel label_6;
- JComboBox combobox_4;
- JButton button_1;
- public boolean start = false;
- public boolean paint = true;
- public String Style;
- public int loop() {
- try {
- if (start == true) {
- gui.setVisible(false);
- }
- if (gui.isVisible() == false) {
- if (textfield_1.getText().length() == 0) {
- if (eat == true) {
- log("You need to enter Food ID, if eating is true!");
- stopScript();
- }
- }
- if (textfield_1.getText().length() != 0) {
- try {
- food = Integer.parseInt(textfield_1.getText());
- } catch (NumberFormatException e) {
- log("Food ID = number!");
- stopScript();
- }
- }
- if (walkToghoul == true) {
- status = "Walking to ghouls";
- if (!getMyPlayer().isMoving()) {
- walking.walkPathMM(bankToGhoul, 2, 2);
- walkToghoul = false;
- }
- }
- if (walkToBank == true) {
- status = "Walking to bank";
- if (!getMyPlayer().isMoving()) {
- walking.walkPathMM(ghoulToBank, 2, 2);
- walkToBank = false;
- }
- }
- if (getMyPlayer().isMoving()) {
- antiban();
- sleep(180, 220);
- }
- if (inFight == true) {
- antiban();
- sleep(180, 220);
- }
- if (!walking.isRunEnabled()
- && (walking.getEnergy() > random(55, 95))) {
- walking.setRun(true);
- status = "Setting run";
- sleep(800, 1000);
- } else if (calc.distanceTo(ghoulTile) < 15) {
- if (eat == true) {
- if (!inventory.contains(food)) {
- walkToBank = true;
- }
- if (combat.getLifePoints() < (skills.getRealLevel(3) * 10) / 2) {
- if (inventory.getItem(food).doAction("Eat")) {
- status = "Eating...";
- sleep(300, 600);
- }
- }
- }
- if (inventory.isFull() && eat == false) {
- walkToBank = true;
- }
- if (pickup == true) {
- itegr = groundItems.getNearest(items);
- if (itegr != null) {
- if (itegr != ite) {
- if (itegr.isOnScreen()) {
- ite = itegr;
- if (!inventory.isFull()
- && (ite != null)
- && getMyPlayer().getInteracting() == null) {
- if (ite.doAction("Take")) {
- status = "Picking up item..";
- sleep(1800, 2300);
- }
- }
- if (inventory.isFull()
- && (ite != null)
- && getMyPlayer().getInteracting() == null) {
- inventory.getItem(food).doAction("Eat");
- status = "Eating for space";
- sleep(1300, 1600);
- if (!inventory.isFull()
- && (ite != null)) {
- if (ite.doAction("Take")) {
- status = "Picking up item..";
- sleep(1800, 2300);
- }
- }
- }
- } else {
- ite = null;
- }
- }
- } else if (ite != null) {
- ite = null;
- }
- }
- if (getMyPlayer().getAnimation() != -1
- && getMyPlayer().getInteracting() != null) {
- status = "Fighting...";
- inFight = true;
- }
- if (getMyPlayer().getAnimation() == -1
- && getMyPlayer().getInteracting() == null) {
- inFight = false;
- }
- if (inFight == false) {
- attack();
- }
- } else if (calc.distanceTo(bankTile) < 5) {
- if (eat == true) {
- if (!inventory.contains(food)) {
- status = "No food, taking some...";
- useBank();
- }
- if (inventory.contains(food)) {
- walkToghoul = true;
- }
- }
- if (eat == false) {
- if (inventory.getCount() != 0) {
- useBank();
- }
- if (inventory.getCount() == 0) {
- walkToghoul = true;
- }
- }
- }
- }
- } catch (Exception e) {
- }
- return 0;
- }
- public int useBank() {
- try {
- if (!bank.isOpen()) {
- bank.open();
- sleep(700, 1400);
- } else if (bank.isOpen()) {
- status = "Banking";
- sleep(500, 1200);
- if (inventory.getCount() != 0) {
- bank.depositAll();
- sleep(500, 700);
- }
- if (eat == false && inventory.getCount() == 0) {
- bank.close();
- }
- if (eat == true) {
- if (bank.getCount(food) == 0) {
- bank.close();
- sleep(1000, 2000);
- foodb++;
- log("Out of food +1 time(s)");
- if (foodb > 5) {
- log("Out of food, more than 5 times. stopScript();");
- stopScript();
- }
- } else {
- bank.withdraw(food, 0);
- sleep(1000, 1300);
- foodb = 0;
- }
- }
- }
- } catch (Exception e) {
- }
- return 1200;
- }
- public boolean onStart() {
- if (!game.isLoggedIn()) {
- log("Please log in before starting the script!");
- return false;
- }
- gui = new gui();
- gui.setVisible(true);
- mouse.setSpeed(random(4, 5));
- log("Starting Ghoulkiller");
- trainStatran = Skills.RANGE;
- startStatLvlran = skills.getCurrentLevel(trainStatatt);
- startXpran = skills.getCurrentExp(trainStatatt);
- trainStatatt = Skills.ATTACK;
- startStatLvlatt = skills.getCurrentLevel(trainStatatt);
- startXpatt = skills.getCurrentExp(trainStatatt);
- trainStatdef = Skills.DEFENSE;
- startStatLvldef = skills.getCurrentLevel(trainStatdef);
- startXpdef = skills.getCurrentExp(trainStatdef);
- trainStatstr = Skills.STRENGTH;
- startStatLvlstr = skills.getCurrentLevel(trainStatstr);
- startXpstr = skills.getCurrentExp(trainStatstr);
- htrainStat = Skills.CONSTITUTION;
- hstartStatLvl = skills.getCurrentLevel(Skills.CONSTITUTION);
- hstartXp = skills.getCurrentExp(Skills.CONSTITUTION);
- return true;
- }
- public void onRepaint(Graphics g) {
- if (game.isLoggedIn()) {
- if (start == true && paint == true) {
- Point m = mouse.getLocation();
- g.setColor(Color.red);
- g.drawRoundRect(m.x - 6, m.y, 14, 2, 5, 5);
- g.drawRoundRect(m.x, m.y - 6, 2, 14, 5, 5);
- g.setColor(Color.red);
- g.fillRoundRect(m.x - 6, m.y, 14, 2, 5, 5);
- g.fillRoundRect(m.x, m.y - 6, 2, 14, 5, 5);
- double millis = System.currentTimeMillis() - startTime;
- int hlevelChange = skills.getCurrentLevel(htrainStat)
- - hstartStatLvl;
- int hxpChange = skills.getCurrentExp(htrainStat) - hstartXp;
- int hclvl = skills.getCurrentLevel(htrainStat);
- int hxpPerHour = (int) ((hxpChange / millis) * (1000 * 3600));
- int alevelChange = skills.getCurrentLevel(trainStatatt)
- - startStatLvlatt;
- int axpChange = skills.getCurrentExp(trainStatatt) - startXpatt;
- int aclvl = skills.getCurrentLevel(trainStatatt);
- int axpPerHour = (int) ((axpChange / millis) * (1000 * 3600));
- int slevelChange = skills.getCurrentLevel(trainStatstr)
- - startStatLvlstr;
- int sxpChange = skills.getCurrentExp(trainStatstr) - startXpstr;
- int sclvl = skills.getCurrentLevel(trainStatstr);
- int sxpPerHour = (int) ((sxpChange / millis) * (1000 * 3600));
- int dlevelChange = skills.getCurrentLevel(trainStatdef)
- - startStatLvldef;
- int dxpChange = skills.getCurrentExp(trainStatdef) - startXpdef;
- int dclvl = skills.getCurrentLevel(trainStatdef);
- int dxpPerHour = (int) ((dxpChange / millis) * (1000 * 3600));
- int rlevelChange = skills.getCurrentLevel(trainStatran)
- - startStatLvlran;
- int rxpChange = skills.getCurrentExp(trainStatran) - startXpran;
- int rclvl = skills.getCurrentLevel(trainStatran);
- int rxpPerHour = (int) ((rxpChange / millis) * (1000 * 3600));
- String time = formatTime((int) (millis / 1000));
- g.setColor(new Color(0, 0, 0, 150));
- g.draw3DRect(5, 30, 210, 150, true);
- g.fill3DRect(5, 30, 210, 150, true);
- g.setColor(Color.red);
- g.setFont(new Font("Comic Sans MS", Font.PLAIN, 11));
- g.drawString("Ghoulkiller, by petje", 8, 30);
- g.setFont(new Font("Comic Sans MS", Font.PLAIN, 11));
- g.setColor(Color.white);
- g.drawString("Version 1.0", 8, 40);
- g.setColor(Color.white);
- g.setFont(new Font("Comic Sans MS", Font.PLAIN, 11));
- g.drawString("Status: " + status, 8, 55);
- g.setColor(Color.cyan);
- if (combobox_4.getSelectedItem().toString().contains("Attack")) {
- g.drawString("Attack lvl: " + aclvl + " (" + alevelChange
- + ")", 8, 80);
- g.drawString("Attack XP Gained: " + axpChange, 8, 90);
- g.drawString("Attack XP/H: " + axpPerHour, 8, 100);
- }
- if (combobox_4.getSelectedItem().toString()
- .contains("Strength")) {
- g.drawString("Strength lvl: " + sclvl + " (" + slevelChange
- + ")", 8, 80);
- g.drawString("Strength XP Gained: " + sxpChange, 8, 90);
- g.drawString("Strength XP/H: " + sxpPerHour, 8, 100);
- }
- if (combobox_4.getSelectedItem().toString().contains("Defense")) {
- g.drawString("Defense lvl: " + dclvl + " (" + dlevelChange
- + ")", 8, 80);
- g.drawString("Defense XP Gained: " + dxpChange, 8, 90);
- g.drawString("Defense XP/H: " + dxpPerHour, 8, 100);
- }
- if (combobox_4.getSelectedItem().toString().contains("Ranged")) {
- g.drawString("Ranged lvl: " + rclvl + " (" + rlevelChange
- + ")", 8, 80);
- g.drawString("Ranged XP Gained: " + rxpChange, 8, 90);
- g.drawString("Ranged XP/H: " + rxpPerHour, 8, 100);
- }
- g.setColor(Color.red);
- g.drawString("Hitpoints lvl: " + hclvl + " (" + hlevelChange
- + ")", 8, 125);
- g.drawString("Hitpoints XP Gained: " + hxpChange, 8, 135);
- g.drawString("Hitpoints XP/H: " + hxpPerHour, 8, 145);
- g.setColor(Color.white);
- g.drawString("Runtime: " + time, 8, 165);
- }
- }
- }
- String formatTime(int seconds) {
- return (((int) seconds / 3600 < 10 ? "0" : "") + (int) seconds / 3600
- + ":" + ((int) seconds / 60 % 60 < 10 ? "0" : "")
- + (int) seconds / 60 % 60 + ":"
- + ((int) seconds % 60 < 10 ? "0" : "") + (int) seconds % 60);
- }
- public void serverMessageRecieved(ServerMessageEvent e) {
- final String serverString = e.getMessage();
- if (serverString.contains("You've just advanced")) {
- log("Congrats on level up, Screenshot taken!");
- sleep(random(1500, 2500));
- if (interfaces.canContinue()) {
- interfaces.clickContinue();
- }
- }
- }
- public void antiban() {
- try {
- if (getMyPlayer().getInteracting() != null) {
- int rndm;
- rndm = random(1, 10000);
- if (rndm <= 10) {
- if (!(game.getCurrentTab() == Game.TAB_STATS)) {
- game.openTab(Game.TAB_STATS);
- sleep(300, 500);
- }
- mouse.move(642, 222, 28, 9);
- sleep(500, 700);
- } else if (rndm <= 40) {
- if (!(game.getCurrentTab() == Game.TAB_STATS)) {
- sleep(200, 300);
- game.openTab(Game.TAB_STATS);
- sleep(200, 300);
- }
- if (Style == "Attack") {
- mouse.move(580, 222, 28, 9);
- sleep(500, 700);
- } else if (Style == "Strength") {
- mouse.move(580, 248, 28, 9);
- sleep(500, 700);
- } else if (Style == "Defence") {
- mouse.move(580, 280, 28, 9);
- sleep(500, 700);
- } else if (Style == "Range") {
- mouse.move(580, 306, 28, 9);
- sleep(500, 700);
- }
- } else if (rndm <= 425) {
- mouse.moveRandomly(500);
- } else if (rndm <= 650) {
- camera.setAngle(random(1, 360));
- } else if (rndm <= 850) {
- mouse.setSpeed(random(4, 5));
- } else if (rndm <= 860) {
- if (!(game.getCurrentTab() == Game.TAB_STATS)) {
- sleep(200, 300);
- game.openTab(Game.TAB_STATS);
- sleep(200, 300);
- }
- mouse.move(580, 336, 27, 9);
- sleep(500, 700);
- } else if (rndm <= 880) {
- mouse.moveOffScreen();
- }
- sleep(100, 200);
- } else {
- int rndm;
- rndm = random(1, 10000);
- if (rndm == 10) {
- if (!(game.getCurrentTab() == Game.TAB_STATS)) {
- game.openTab(Game.TAB_STATS);
- sleep(300, 500);
- }
- mouse.move(642, 222, 28, 9);
- sleep(500, 700);
- } else if (rndm <= 40) {
- if (!(game.getCurrentTab() == Game.TAB_STATS)) {
- sleep(200, 300);
- game.openTab(Game.TAB_STATS);
- sleep(200, 300);
- }
- if (Style == "Attack") {
- mouse.move(580, 222, 28, 9);
- sleep(500, 700);
- } else if (Style == "Strength") {
- mouse.move(580, 248, 28, 9);
- sleep(500, 700);
- } else if (Style == "Defence") {
- mouse.move(580, 280, 28, 9);
- sleep(500, 700);
- } else if (Style == "Range") {
- mouse.move(580, 306, 28, 9);
- sleep(500, 700);
- }
- } else if (rndm <= 425) {
- mouse.moveRandomly(500);
- } else if (rndm <= 650) {
- camera.setAngle(random(1, 360));
- } else if (rndm <= 850) {
- mouse.setSpeed(random(4, 5));
- } else if (rndm <= 950) {
- if (!(game.getCurrentTab() == Game.TAB_STATS)) {
- sleep(200, 300);
- game.openTab(Game.TAB_STATS);
- sleep(200, 300);
- }
- mouse.move(580, 336, 27, 9);
- sleep(500, 700);
- } else if (rndm <= 980) {
- mouse.moveOffScreen();
- }
- sleep(100, 200);
- }
- } catch (Exception e) {
- }
- }
- public int attack() {
- try {
- if (!npcs.getNearest(ghoul).isOnScreen()) {
- if (npcs.getNearest(ghoul).getHPPercent() != 0) {
- if (!getMyPlayer().isMoving()) {
- if (walkToBank == false) {
- if (walkToghoul == false) {
- if (walking.walkTileMM(npcs.getNearest(ghoul,
- 2, 2).getLocation())) {
- status = ("Walking to nearest ghoul");
- attack();
- }
- }
- }
- }
- }
- } else {
- if (npcs.getNearest(ghoul).isOnScreen()) {
- if (npcs.getNearest(ghoul).getHPPercent() != 0) {
- if (getMyPlayer().getInteracting() == null) {
- if (walkToBank == false) {
- if (walkToghoul == false) {
- if (npcs.getNearest(ghoul).doAction(
- "Attack")) {
- status = "Attacking ghouls";
- sleep(1500, 2000);
- }
- }
- }
- }
- }
- }
- }
- } catch (Exception e) {
- }
- return 0;
- }
- public class gui extends javax.swing.JFrame {
- private static final long serialVersionUID = 1L;
- public gui() {
- initComponents();
- }
- private void initComponents() {
- aLayout customLayout = new aLayout();
- getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 12));
- getContentPane().setLayout(customLayout);
- label_1 = new JLabel("Ghoulkiller - Petje123");
- getContentPane().add(label_1);
- label_2 = new JLabel("Food ID:");
- getContentPane().add(label_2);
- textfield_1 = new JTextField("");
- getContentPane().add(textfield_1);
- label_3 = new JLabel("Pickup:");
- getContentPane().add(label_3);
- combobox_1 = new JComboBox();
- combobox_1.setModel(new javax.swing.DefaultComboBoxModel(
- new String[] { "Yes", "No" }));
- getContentPane().add(combobox_1);
- label_4 = new JLabel("Eat food:");
- getContentPane().add(label_4);
- combobox_2 = new JComboBox();
- combobox_2.setModel(new javax.swing.DefaultComboBoxModel(
- new String[] { "Yes", "No" }));
- getContentPane().add(combobox_2);
- label_5 = new JLabel("Paint:");
- getContentPane().add(label_5);
- combobox_3 = new JComboBox();
- combobox_3.setModel(new javax.swing.DefaultComboBoxModel(
- new String[] { "Yes", "No" }));
- getContentPane().add(combobox_3);
- label_6 = new JLabel("Paint skill:");
- getContentPane().add(label_6);
- combobox_4 = new JComboBox();
- combobox_4
- .setModel(new javax.swing.DefaultComboBoxModel(
- new String[] { "Attack", "Strength", "Defense",
- "Ranged" }));
- getContentPane().add(combobox_4);
- button_1 = new JButton("Start!");
- getContentPane().add(button_1);
- button_1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- button_1actionPerformed(evt);
- }
- });
- setSize(getPreferredSize());
- }
- public void button_1actionPerformed(ActionEvent evt) {
- if (combobox_1.getSelectedItem().toString().contains("Yes")) {
- pickup = true;
- }
- if (combobox_1.getSelectedItem().toString().contains("No")) {
- pickup = false;
- }
- if (combobox_2.getSelectedItem().toString().contains("Yes")) {
- eat = true;
- }
- if (combobox_2.getSelectedItem().toString().contains("No")) {
- eat = false;
- }
- if (combobox_3.getSelectedItem().toString().contains("No")) {
- paint = false;
- }
- if (combobox_3.getSelectedItem().toString().contains("Yes")) {
- paint = true;
- }
- if (combobox_4.getSelectedItem().toString().contains("Attack")) {
- Style = "Attack";
- }
- if (combobox_4.getSelectedItem().toString().contains("Strength")) {
- Style = "Strength";
- }
- if (combobox_4.getSelectedItem().toString().contains("Defense")) {
- Style = "Defense";
- }
- if (combobox_4.getSelectedItem().toString().contains("Ranged")) {
- Style = "Range";
- }
- start = true;
- }
- @SuppressWarnings("deprecation")
- public void main(String args[]) {
- gui window = new gui();
- window.setTitle("Ghoulkiller");
- window.pack();
- window.show();
- }
- class aLayout implements LayoutManager {
- public aLayout() {
- }
- public void addLayoutComponent(String name, Component comp) {
- }
- public void removeLayoutComponent(Component comp) {
- }
- public Dimension preferredLayoutSize(Container parent) {
- Dimension dim = new Dimension(0, 0);
- Insets insets = parent.getInsets();
- dim.width = 110 + insets.left + insets.right;
- dim.height = 365 + insets.top + insets.bottom;
- return dim;
- }
- public Dimension minimumLayoutSize(Container parent) {
- Dimension dim = new Dimension(0, 0);
- return dim;
- }
- public void layoutContainer(Container parent) {
- Insets insets = parent.getInsets();
- Component c;
- c = parent.getComponent(0);
- if (c.isVisible()) {
- c.setBounds(insets.left + 8, insets.top + 8, 88, 24);
- }
- c = parent.getComponent(1);
- if (c.isVisible()) {
- c.setBounds(insets.left + 8, insets.top + 40, 88, 24);
- }
- c = parent.getComponent(2);
- if (c.isVisible()) {
- c.setBounds(insets.left + 8, insets.top + 64, 88, 24);
- }
- c = parent.getComponent(3);
- if (c.isVisible()) {
- c.setBounds(insets.left + 8, insets.top + 88, 88, 24);
- }
- c = parent.getComponent(4);
- if (c.isVisible()) {
- c.setBounds(insets.left + 8, insets.top + 112, 88, 24);
- }
- c = parent.getComponent(5);
- if (c.isVisible()) {
- c.setBounds(insets.left + 8, insets.top + 136, 88, 24);
- }
- c = parent.getComponent(6);
- if (c.isVisible()) {
- c.setBounds(insets.left + 8, insets.top + 160, 88, 24);
- }
- c = parent.getComponent(7);
- if (c.isVisible()) {
- c.setBounds(insets.left + 8, insets.top + 184, 88, 24);
- }
- c = parent.getComponent(8);
- if (c.isVisible()) {
- c.setBounds(insets.left + 8, insets.top + 208, 88, 24);
- }
- c = parent.getComponent(9);
- if (c.isVisible()) {
- c.setBounds(insets.left + 8, insets.top + 232, 88, 24);
- }
- c = parent.getComponent(10);
- if (c.isVisible()) {
- c.setBounds(insets.left + 8, insets.top + 256, 88, 24);
- }
- c = parent.getComponent(11);
- if (c.isVisible()) {
- c.setBounds(insets.left + 16, insets.top + 288, 72, 24);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement