Jump to content

Scripting help (new to scripting


DarkScuzz

Recommended Posts

I've been messing around with this for hours
after i have done all this
the script will not open in OSbot client
i've had it open before when i was still in the process of making the better
now im clueless

i did add armour ealier but removed it... i need to readd
this is more for testing and learing how to

it will shows up in OSbot client scripts
its listed in the C:\Users\username\OSBot\ScriptsOSbot/
but im lost atm and need sleep




import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "DarkScuzz", info = "Green Dragon Killer", name = "GreenDragonKiller", version = 1.0, logo = "")
class GreenDragonKiller extends Script {

    private boolean shouldBank = false;
    private static final Area GREEN_DRAGON_AREA = new Area(2974, 3618, 3029, 3650);
    private static final String ANTI_FIRE_POTION = "Anti-fire potion"; // Name of the anti-fire potion
    private static final String FOOD_NAME = "Lobster"; // Name of the food you want to eat
    private static int FOOD_AMOUNT = 10; // Change this to the desired amount of food

    @Override
    public int onLoop() {
        if (shouldBank) {
            // Implement banking logic here
            // You can use the closest bank or any preferred method
            bank();
        } else {
            if (getSkills().getDynamic(Skill.HITPOINTS) < 10 || !hasFood()) {
                shouldBank = true;
                return 1000; // Delay before heading to the bank
            }

            // Activate the Protection from Melee prayer
            if (!isPrayerActive()) {
                activatePrayer();
            }

            // Check for and use an anti-fire potion
            if (inventory.contains(ANTI_FIRE_POTION)) {
                inventory.interact("Drink", ANTI_FIRE_POTION);
            }

            // Equip gear and implement combat logic here

            // ... Combat logic ...

            // Eat food if health is low
            if (getSkills().getDynamic(Skill.HITPOINTS) < 10) {
                eatFood();
            }
        }
        return random(1000, 2000); // Delay between loops in milliseconds
    }

    private void activatePrayer() {
        // Implement logic to activate the Protection from Melee prayer
        // For example, you can open the Prayer tab and click on the prayer you want to activate.
        // getTabs().open(Tab.PRAYER);
        // Perform a mouse click on the prayer icon.
    }

    private boolean isPrayerActive() {
        // Implement logic to check if the Protection from Melee prayer is active
        // You'll need to check the color of the prayer icon or its state on the interface
        return false;
    }

    private void eatFood() {
        // Implement logic to eat food from your inventory
        Inventory inventory = getInventory();
        if (inventory.contains(FOOD_NAME) && FOOD_AMOUNT > 0) {
            inventory.interact("Eat", FOOD_NAME);
            FOOD_AMOUNT--;
        }
    }

    private boolean hasFood() {
        // Implement logic to check if you have enough food in your inventory
        Inventory inventory = getInventory();
        return inventory.contains(FOOD_NAME) && FOOD_AMOUNT > 0;
    }

    private void bank() {
        // Implement banking logic here
        // You can use the closest bank or any preferred method
    }

    @Override
    public void onExit() {
        log("GreenDragonKiller stopped.");
    }
}
Link to comment
Share on other sites

23 minutes ago, DarkScuzz said:

the script is oready there in the folder
ive had it run when i was messing with it yesterday
and now it just doesn't

@ScriptManifest(author = "DarkScuzz", info = "Green Dragon Killer", name = "GreenDragonKiller", version = 1.0, logo = "")
class GreenDragonKiller extends Script {

 

I think its because you are missing public maybe

public class GreenDragonKiller extends Script {

Edited by skillerkidos1
Link to comment
Share on other sites

I've been editing the script abit more and im again stuck
I've been able to get to move to edgevill bank
but it gets stuck sometimes at the Yew tree's by the outa wall and says
[INFO][Bot #1][09/14 04:53:59 PM]: WebWalkingEvent; We have reached the final destination!
but its not at the bank

and another thing, i have it opening the bank with a GUI option for gear
i choose gear from the GUI and it opens bank and then trys to webwalk after does not even take gear...
 

import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.Walking;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import javax.swing.*;
import java.awt.*;
import java.util.Random;

@ScriptManifest(author = "DarkScuzz", info = "Green Dragon Killer", name = "GreenDragonKiller", version = 1.0, logo = "")
public class GreenDragonKiller extends Script {

    // User options
    private String foodName = "Lobster";
    private int foodAmount = 15;
    private String gearOption;
    private String amuletOption;
    private String capeOption;
    private String ammoOption;
    private String weaponOption;

    // New options for Ranged and Ammo Type
    private String rangedWeaponOption;
    private String ammoTypeOption;

    private boolean shouldBank = false;
    private final Random random = new Random();

    private static final Area BANK_AREA = new Area(
            new int[][]{
                    {3094,3491},
                    {3072,3456},
                    {21,40}

            }
    );

    private static final Area GREEN_DRAGON_AREA = new Area(
            new int[][]{
                    {2975, 3626},
                    {2944, 3584},
                    {31, 33}
            }
    );

    public GreenDragonKiller() {
        // Initialize your JComboBox variables
    }

    @Override
    public void onStart() {
        log("Welcome to GreenDragonKiller!");
        setupGUI();
    }

    @Override
    public int onLoop() throws InterruptedException {
        if (shouldBank) {
            bank();
        } else {
            if (getSkills().getDynamic(Skill.HITPOINTS) < 50 && !hasFood()) {
                shouldBank = true;
                return 1000; // Delay before heading to the bank
            }

            activateProtectionPrayer();

            if (!GREEN_DRAGON_AREA.contains(myPosition())) {
                walkToGreenDragons();
            } else {
                combat();
            }
        }

        antiban();

        return random(1000, 2000); // Delay between loops in milliseconds
    }

    private void activateProtectionPrayer() {
        // Implement logic to activate the Protection from Melee prayer
    }

    private void walkToGreenDragons() {
        Walking walking = getWalking();
        walking.webWalk(GREEN_DRAGON_AREA.getRandomPosition());
    }

    private void combat() throws InterruptedException {
        NPC greenDragon = getNpcs().closest("Green Dragon");
        if (greenDragon != null) {
            if (!getCombat().isFighting()) {
                greenDragon.interact("Attack");
                sleep(random(800, 1200));
            }
        }
    }

    private void bank() throws InterruptedException {
        if (getBank().isOpen()) {
            depositAndWithdraw();
            shouldBank = false;

            // Implement logic for selecting and equipping gear here
            if (gearOption != null) {
                // Example: Equip gear based on user's gearOption choice
                switch (gearOption) {
                    case "Adamant Armour":
                        // Code to equip adamant armor
                        break;
                    case "Rune Armour":
                        // Code to equip rune armor
                        break;
                    // Add cases for other gear options as needed
                }
            }

            getBank().close(); // Close the bank after gear setup
        } else if (BANK_AREA.contains(myPosition())) {
            if (!getBank().isOpen()) {
                getBank().open();
            }
        } else {
            getWalking().webWalk(BANK_AREA);
        }
    }

    private void depositAndWithdraw() {
        Inventory inventory = getInventory();

        if (inventory.isFull() || !hasEnoughFood()) {
            getBank().withdraw(foodName, foodAmount);
        }

        if (gearOption != null) {
            // Implement withdrawing and equipping gear here
        }

        getBank().close();
    }

    private boolean hasFood() {
        Inventory inventory = getInventory();
        return inventory.contains(foodName) && foodAmount > 0;
    }

    private boolean hasEnoughFood() {
        return getInventory().getAmount(foodName) >= foodAmount;
    }

    private void antiban() throws InterruptedException {
        int action = random.nextInt(4);

        switch (action) {
            case 0:
                getMouse().move(random(50, 750), random(50, 450));
                break;
            case 1:
                getCamera().movePitch(random(0, 100));
                getCamera().moveYaw(random(0, 100));
                break;
            // Add more antiban actions as needed
        }

        sleep(random(2000, 4000));
    }

    private void setupGUI() {
        JFrame frame = new JFrame("Green Dragon Killer Setup");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 400);

        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(12, 2));

        JLabel foodLabel = new JLabel("Food:");
        JComboBox<String> foodDropdown = new JComboBox<>(new String[]{"Trout", "Lobster", "Swordfish", "Monkfish"});
        JLabel gearLabel = new JLabel("Gear:");
        JComboBox<String> gearDropdown = new JComboBox<>(new String[]{"Adamant Armour", "Rune Armour"});
        JLabel amuletLabel = new JLabel("Amulet:");
        JComboBox<String> amuletDropdown = new JComboBox<>(new String[]{"Strength Amulet", "Glory Amulet"});
        JLabel capeLabel = new JLabel("Cape:");
        JComboBox<String> capeDropdown = new JComboBox<>(new String[]{"Obsidian cape", "Skills cape"});
        JLabel ammoLabel = new JLabel("Ammo:");
        JComboBox<String> ammoDropdown = new JComboBox<>(new String[]{"", "", ""});
        JLabel weaponLabel = new JLabel("Weapon:");
        JComboBox<String> weaponDropdown = new JComboBox<>(new String[]{"Adamant Weapon", "Rune Weapon"});
        JButton startButton = new JButton("Start Script");

        // New components for Ranged and Ammo Type options
        JCheckBox rangedCheckbox = new JCheckBox("Ranged:");
        JComboBox<String> rangedWeaponDropdown = new JComboBox<>(new String[]{"Magic Shortbow"});
        JCheckBox ammoTypeCheckbox = new JCheckBox("Ammo Type:");
        JComboBox<String> ammoTypeDropdown = new JComboBox<>(new String[]{"Mithril Arrow", "Rune Arrow"});

        startButton.addActionListener(e -> {
            foodName = (String) foodDropdown.getSelectedItem();
            gearOption = (String) gearDropdown.getSelectedItem();
            amuletOption = (String) amuletDropdown.getSelectedItem();
            capeOption = (String) capeDropdown.getSelectedItem();
            ammoOption = (String) ammoDropdown.getSelectedItem();
            weaponOption = (String) weaponDropdown.getSelectedItem();

            // New options for Ranged and Ammo Type
            if (rangedCheckbox.isSelected()) {
                rangedWeaponOption = (String) rangedWeaponDropdown.getSelectedItem();
            } else {
                rangedWeaponOption = null;
            }

            if (ammoTypeCheckbox.isSelected()) {
                ammoTypeOption = (String) ammoTypeDropdown.getSelectedItem();
            } else {
                ammoTypeOption = null;
            }

            startScript();
            frame.dispose();
        });

        panel.add(foodLabel);
        panel.add(foodDropdown);
        panel.add(gearLabel);
        panel.add(gearDropdown);
        panel.add(amuletLabel);
        panel.add(amuletDropdown);
        panel.add(capeLabel);
        panel.add(capeDropdown);
        panel.add(ammoLabel);
        panel.add(ammoDropdown);
        panel.add(weaponLabel);
        panel.add(weaponDropdown);

        // New components for Ranged and Ammo Type options
        panel.add(rangedCheckbox);
        panel.add(rangedWeaponDropdown);
        panel.add(ammoTypeCheckbox);
        panel.add(ammoTypeDropdown);

        panel.add(startButton);

        frame.add(panel);
        frame.setVisible(true);
    }

    private void startScript() {
        log("Starting GreenDragonKiller with gear setup:");
        log("Food: " + foodName);
        log("Gear: " + gearOption);
        log("Amulet: " + amuletOption);
        log("Cape: " + capeOption);
        log("Ammo: " + ammoOption);
        log("Weapon: " + weaponOption);

        // New options for Ranged and Ammo Type
        if (rangedWeaponOption != null) {
            log("Ranged Weapon: " + rangedWeaponOption);
            // Implement logic to equip the selected ranged weapon
        }

        if (ammoTypeOption != null) {
            log("Ammo Type: " + ammoTypeOption);
            // Implement logic to equip the selected ammo type
        }

        // Implement the logic to start the script with the selected gear setup
    }

    @Override

    public void onExit() {
        log("GreenDragonKiller stopped.");
    }
}

 

Just now, DarkScuzz said:

I've been editing the script abit more and im again stuck
I've been able to get to move to edgevill bank
but it gets stuck sometimes at the Yew tree's by the outa wall and says
[INFO][Bot #1][09/14 04:53:59 PM]: WebWalkingEvent; We have reached the final destination!
but its not at the bank

and another thing, i have it opening the bank with a GUI option for gear
i choose gear from the GUI and it opens bank and then trys to webwalk after does not even take gear...
 

import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.Walking;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import javax.swing.*;
import java.awt.*;
import java.util.Random;

@ScriptManifest(author = "DarkScuzz", info = "Green Dragon Killer", name = "GreenDragonKiller", version = 1.0, logo = "")
public class GreenDragonKiller extends Script {

    // User options
    private String foodName = "Lobster";
    private int foodAmount = 15;
    private String gearOption;
    private String amuletOption;
    private String capeOption;
    private String ammoOption;
    private String weaponOption;

    // New options for Ranged and Ammo Type
    private String rangedWeaponOption;
    private String ammoTypeOption;

    private boolean shouldBank = false;
    private final Random random = new Random();

    private static final Area BANK_AREA = new Area(
            new int[][]{
                    {3094,3491},
                    {3072,3456},
                    {21,40}

            }
    );

    private static final Area GREEN_DRAGON_AREA = new Area(
            new int[][]{
                    {2975, 3626},
                    {2944, 3584},
                    {31, 33}
            }
    );

    public GreenDragonKiller() {
        // Initialize your JComboBox variables
    }

    @Override
    public void onStart() {
        log("Welcome to GreenDragonKiller!");
        setupGUI();
    }

    @Override
    public int onLoop() throws InterruptedException {
        if (shouldBank) {
            bank();
        } else {
            if (getSkills().getDynamic(Skill.HITPOINTS) < 50 && !hasFood()) {
                shouldBank = true;
                return 1000; // Delay before heading to the bank
            }

            activateProtectionPrayer();

            if (!GREEN_DRAGON_AREA.contains(myPosition())) {
                walkToGreenDragons();
            } else {
                combat();
            }
        }

        antiban();

        return random(1000, 2000); // Delay between loops in milliseconds
    }

    private void activateProtectionPrayer() {
        // Implement logic to activate the Protection from Melee prayer
    }

    private void walkToGreenDragons() {
        Walking walking = getWalking();
        walking.webWalk(GREEN_DRAGON_AREA.getRandomPosition());
    }

    private void combat() throws InterruptedException {
        NPC greenDragon = getNpcs().closest("Green Dragon");
        if (greenDragon != null) {
            if (!getCombat().isFighting()) {
                greenDragon.interact("Attack");
                sleep(random(800, 1200));
            }
        }
    }

    private void bank() throws InterruptedException {
        if (getBank().isOpen()) {
            depositAndWithdraw();
            shouldBank = false;

            // Implement logic for selecting and equipping gear here
            if (gearOption != null) {
                // Example: Equip gear based on user's gearOption choice
                switch (gearOption) {
                    case "Adamant Armour":
                        // Code to equip adamant armor
                        break;
                    case "Rune Armour":
                        // Code to equip rune armor
                        break;
                    // Add cases for other gear options as needed
                }
            }

            getBank().close(); // Close the bank after gear setup
        } else if (BANK_AREA.contains(myPosition())) {
            if (!getBank().isOpen()) {
                getBank().open();
            }
        } else {
            getWalking().webWalk(BANK_AREA);
        }
    }

    private void depositAndWithdraw() {
        Inventory inventory = getInventory();

        if (inventory.isFull() || !hasEnoughFood()) {
            getBank().withdraw(foodName, foodAmount);
        }

        if (gearOption != null) {
            // Implement withdrawing and equipping gear here
        }

        getBank().close();
    }

    private boolean hasFood() {
        Inventory inventory = getInventory();
        return inventory.contains(foodName) && foodAmount > 0;
    }

    private boolean hasEnoughFood() {
        return getInventory().getAmount(foodName) >= foodAmount;
    }

    private void antiban() throws InterruptedException {
        int action = random.nextInt(4);

        switch (action) {
            case 0:
                getMouse().move(random(50, 750), random(50, 450));
                break;
            case 1:
                getCamera().movePitch(random(0, 100));
                getCamera().moveYaw(random(0, 100));
                break;
            // Add more antiban actions as needed
        }

        sleep(random(2000, 4000));
    }

    private void setupGUI() {
        JFrame frame = new JFrame("Green Dragon Killer Setup");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 400);

        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(12, 2));

        JLabel foodLabel = new JLabel("Food:");
        JComboBox<String> foodDropdown = new JComboBox<>(new String[]{"Trout", "Lobster", "Swordfish", "Monkfish"});
        JLabel gearLabel = new JLabel("Gear:");
        JComboBox<String> gearDropdown = new JComboBox<>(new String[]{"Adamant Armour", "Rune Armour"});
        JLabel amuletLabel = new JLabel("Amulet:");
        JComboBox<String> amuletDropdown = new JComboBox<>(new String[]{"Strength Amulet", "Glory Amulet"});
        JLabel capeLabel = new JLabel("Cape:");
        JComboBox<String> capeDropdown = new JComboBox<>(new String[]{"Obsidian cape", "Skills cape"});
        JLabel ammoLabel = new JLabel("Ammo:");
        JComboBox<String> ammoDropdown = new JComboBox<>(new String[]{"", "", ""});
        JLabel weaponLabel = new JLabel("Weapon:");
        JComboBox<String> weaponDropdown = new JComboBox<>(new String[]{"Adamant Weapon", "Rune Weapon"});
        JButton startButton = new JButton("Start Script");

        // New components for Ranged and Ammo Type options
        JCheckBox rangedCheckbox = new JCheckBox("Ranged:");
        JComboBox<String> rangedWeaponDropdown = new JComboBox<>(new String[]{"Magic Shortbow"});
        JCheckBox ammoTypeCheckbox = new JCheckBox("Ammo Type:");
        JComboBox<String> ammoTypeDropdown = new JComboBox<>(new String[]{"Mithril Arrow", "Rune Arrow"});

        startButton.addActionListener(e -> {
            foodName = (String) foodDropdown.getSelectedItem();
            gearOption = (String) gearDropdown.getSelectedItem();
            amuletOption = (String) amuletDropdown.getSelectedItem();
            capeOption = (String) capeDropdown.getSelectedItem();
            ammoOption = (String) ammoDropdown.getSelectedItem();
            weaponOption = (String) weaponDropdown.getSelectedItem();

            // New options for Ranged and Ammo Type
            if (rangedCheckbox.isSelected()) {
                rangedWeaponOption = (String) rangedWeaponDropdown.getSelectedItem();
            } else {
                rangedWeaponOption = null;
            }

            if (ammoTypeCheckbox.isSelected()) {
                ammoTypeOption = (String) ammoTypeDropdown.getSelectedItem();
            } else {
                ammoTypeOption = null;
            }

            startScript();
            frame.dispose();
        });

        panel.add(foodLabel);
        panel.add(foodDropdown);
        panel.add(gearLabel);
        panel.add(gearDropdown);
        panel.add(amuletLabel);
        panel.add(amuletDropdown);
        panel.add(capeLabel);
        panel.add(capeDropdown);
        panel.add(ammoLabel);
        panel.add(ammoDropdown);
        panel.add(weaponLabel);
        panel.add(weaponDropdown);

        // New components for Ranged and Ammo Type options
        panel.add(rangedCheckbox);
        panel.add(rangedWeaponDropdown);
        panel.add(ammoTypeCheckbox);
        panel.add(ammoTypeDropdown);

        panel.add(startButton);

        frame.add(panel);
        frame.setVisible(true);
    }

    private void startScript() {
        log("Starting GreenDragonKiller with gear setup:");
        log("Food: " + foodName);
        log("Gear: " + gearOption);
        log("Amulet: " + amuletOption);
        log("Cape: " + capeOption);
        log("Ammo: " + ammoOption);
        log("Weapon: " + weaponOption);

        // New options for Ranged and Ammo Type
        if (rangedWeaponOption != null) {
            log("Ranged Weapon: " + rangedWeaponOption);
            // Implement logic to equip the selected ranged weapon
        }

        if (ammoTypeOption != null) {
            log("Ammo Type: " + ammoTypeOption);
            // Implement logic to equip the selected ammo type
        }

        // Implement the logic to start the script with the selected gear setup
    }

    @Override

    public void onExit() {
        log("GreenDragonKiller stopped.");
    }
}

 

With that .. on top of things

it starts the moving to bank even before i choose what gear to use in the GUI

Link to comment
Share on other sites

31 minutes ago, DarkScuzz said:

I've been editing the script abit more and im again stuck
I've been able to get to move to edgevill bank
but it gets stuck sometimes at the Yew tree's by the outa wall and says
[INFO][Bot #1][09/14 04:53:59 PM]: WebWalkingEvent; We have reached the final destination!
but its not at the bank

and another thing, i have it opening the bank with a GUI option for gear
i choose gear from the GUI and it opens bank and then trys to webwalk after does not even take gear...
 

import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.Walking;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import javax.swing.*;
import java.awt.*;
import java.util.Random;

@ScriptManifest(author = "DarkScuzz", info = "Green Dragon Killer", name = "GreenDragonKiller", version = 1.0, logo = "")
public class GreenDragonKiller extends Script {

    // User options
    private String foodName = "Lobster";
    private int foodAmount = 15;
    private String gearOption;
    private String amuletOption;
    private String capeOption;
    private String ammoOption;
    private String weaponOption;

    // New options for Ranged and Ammo Type
    private String rangedWeaponOption;
    private String ammoTypeOption;

    private boolean shouldBank = false;
    private final Random random = new Random();

    private static final Area BANK_AREA = new Area(
            new int[][]{
                    {3094,3491},
                    {3072,3456},
                    {21,40}

            }
    );

    private static final Area GREEN_DRAGON_AREA = new Area(
            new int[][]{
                    {2975, 3626},
                    {2944, 3584},
                    {31, 33}
            }
    );

    public GreenDragonKiller() {
        // Initialize your JComboBox variables
    }

    @Override
    public void onStart() {
        log("Welcome to GreenDragonKiller!");
        setupGUI();
    }

    @Override
    public int onLoop() throws InterruptedException {
        if (shouldBank) {
            bank();
        } else {
            if (getSkills().getDynamic(Skill.HITPOINTS) < 50 && !hasFood()) {
                shouldBank = true;
                return 1000; // Delay before heading to the bank
            }

            activateProtectionPrayer();

            if (!GREEN_DRAGON_AREA.contains(myPosition())) {
                walkToGreenDragons();
            } else {
                combat();
            }
        }

        antiban();

        return random(1000, 2000); // Delay between loops in milliseconds
    }

    private void activateProtectionPrayer() {
        // Implement logic to activate the Protection from Melee prayer
    }

    private void walkToGreenDragons() {
        Walking walking = getWalking();
        walking.webWalk(GREEN_DRAGON_AREA.getRandomPosition());
    }

    private void combat() throws InterruptedException {
        NPC greenDragon = getNpcs().closest("Green Dragon");
        if (greenDragon != null) {
            if (!getCombat().isFighting()) {
                greenDragon.interact("Attack");
                sleep(random(800, 1200));
            }
        }
    }

    private void bank() throws InterruptedException {
        if (getBank().isOpen()) {
            depositAndWithdraw();
            shouldBank = false;

            // Implement logic for selecting and equipping gear here
            if (gearOption != null) {
                // Example: Equip gear based on user's gearOption choice
                switch (gearOption) {
                    case "Adamant Armour":
                        // Code to equip adamant armor
                        break;
                    case "Rune Armour":
                        // Code to equip rune armor
                        break;
                    // Add cases for other gear options as needed
                }
            }

            getBank().close(); // Close the bank after gear setup
        } else if (BANK_AREA.contains(myPosition())) {
            if (!getBank().isOpen()) {
                getBank().open();
            }
        } else {
            getWalking().webWalk(BANK_AREA);
        }
    }

    private void depositAndWithdraw() {
        Inventory inventory = getInventory();

        if (inventory.isFull() || !hasEnoughFood()) {
            getBank().withdraw(foodName, foodAmount);
        }

        if (gearOption != null) {
            // Implement withdrawing and equipping gear here
        }

        getBank().close();
    }

    private boolean hasFood() {
        Inventory inventory = getInventory();
        return inventory.contains(foodName) && foodAmount > 0;
    }

    private boolean hasEnoughFood() {
        return getInventory().getAmount(foodName) >= foodAmount;
    }

    private void antiban() throws InterruptedException {
        int action = random.nextInt(4);

        switch (action) {
            case 0:
                getMouse().move(random(50, 750), random(50, 450));
                break;
            case 1:
                getCamera().movePitch(random(0, 100));
                getCamera().moveYaw(random(0, 100));
                break;
            // Add more antiban actions as needed
        }

        sleep(random(2000, 4000));
    }

    private void setupGUI() {
        JFrame frame = new JFrame("Green Dragon Killer Setup");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 400);

        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(12, 2));

        JLabel foodLabel = new JLabel("Food:");
        JComboBox<String> foodDropdown = new JComboBox<>(new String[]{"Trout", "Lobster", "Swordfish", "Monkfish"});
        JLabel gearLabel = new JLabel("Gear:");
        JComboBox<String> gearDropdown = new JComboBox<>(new String[]{"Adamant Armour", "Rune Armour"});
        JLabel amuletLabel = new JLabel("Amulet:");
        JComboBox<String> amuletDropdown = new JComboBox<>(new String[]{"Strength Amulet", "Glory Amulet"});
        JLabel capeLabel = new JLabel("Cape:");
        JComboBox<String> capeDropdown = new JComboBox<>(new String[]{"Obsidian cape", "Skills cape"});
        JLabel ammoLabel = new JLabel("Ammo:");
        JComboBox<String> ammoDropdown = new JComboBox<>(new String[]{"", "", ""});
        JLabel weaponLabel = new JLabel("Weapon:");
        JComboBox<String> weaponDropdown = new JComboBox<>(new String[]{"Adamant Weapon", "Rune Weapon"});
        JButton startButton = new JButton("Start Script");

        // New components for Ranged and Ammo Type options
        JCheckBox rangedCheckbox = new JCheckBox("Ranged:");
        JComboBox<String> rangedWeaponDropdown = new JComboBox<>(new String[]{"Magic Shortbow"});
        JCheckBox ammoTypeCheckbox = new JCheckBox("Ammo Type:");
        JComboBox<String> ammoTypeDropdown = new JComboBox<>(new String[]{"Mithril Arrow", "Rune Arrow"});

        startButton.addActionListener(e -> {
            foodName = (String) foodDropdown.getSelectedItem();
            gearOption = (String) gearDropdown.getSelectedItem();
            amuletOption = (String) amuletDropdown.getSelectedItem();
            capeOption = (String) capeDropdown.getSelectedItem();
            ammoOption = (String) ammoDropdown.getSelectedItem();
            weaponOption = (String) weaponDropdown.getSelectedItem();

            // New options for Ranged and Ammo Type
            if (rangedCheckbox.isSelected()) {
                rangedWeaponOption = (String) rangedWeaponDropdown.getSelectedItem();
            } else {
                rangedWeaponOption = null;
            }

            if (ammoTypeCheckbox.isSelected()) {
                ammoTypeOption = (String) ammoTypeDropdown.getSelectedItem();
            } else {
                ammoTypeOption = null;
            }

            startScript();
            frame.dispose();
        });

        panel.add(foodLabel);
        panel.add(foodDropdown);
        panel.add(gearLabel);
        panel.add(gearDropdown);
        panel.add(amuletLabel);
        panel.add(amuletDropdown);
        panel.add(capeLabel);
        panel.add(capeDropdown);
        panel.add(ammoLabel);
        panel.add(ammoDropdown);
        panel.add(weaponLabel);
        panel.add(weaponDropdown);

        // New components for Ranged and Ammo Type options
        panel.add(rangedCheckbox);
        panel.add(rangedWeaponDropdown);
        panel.add(ammoTypeCheckbox);
        panel.add(ammoTypeDropdown);

        panel.add(startButton);

        frame.add(panel);
        frame.setVisible(true);
    }

    private void startScript() {
        log("Starting GreenDragonKiller with gear setup:");
        log("Food: " + foodName);
        log("Gear: " + gearOption);
        log("Amulet: " + amuletOption);
        log("Cape: " + capeOption);
        log("Ammo: " + ammoOption);
        log("Weapon: " + weaponOption);

        // New options for Ranged and Ammo Type
        if (rangedWeaponOption != null) {
            log("Ranged Weapon: " + rangedWeaponOption);
            // Implement logic to equip the selected ranged weapon
        }

        if (ammoTypeOption != null) {
            log("Ammo Type: " + ammoTypeOption);
            // Implement logic to equip the selected ammo type
        }

        // Implement the logic to start the script with the selected gear setup
    }

    @Override

    public void onExit() {
        log("GreenDragonKiller stopped.");
    }
}

 

With that .. on top of things

it starts the moving to bank even before i choose what gear to use in the GUI

by default there is a threshoold that counts as being close enough to the end.
You can create your own Webwalk event and change that

Link to comment
Share on other sites

52 minutes ago, Khaleesi said:

by default there is a threshoold that counts as being close enough to the end.
You can create your own Webwalk event and change that

thanks for the fast reply i've added a webwalk into that as you said, im now adding
At green dragon area auto prayer function

i wont be posted all the script from now dont want others to steal.. xD
i want a private made one for myself

Edited by DarkScuzz
Link to comment
Share on other sites

my script is not working ... i dont understand why
so im next to edgevill bank
in my script the bank has been choose for my script to goto on inventory full and or when starting script

on start the script gets my GUI menu for gear seletion after i click start bot
it just keeps says this on os bot
[INFO][Bot #1][09/15 01:00:24 PM]: Started script : DragonTest
[INFO][Bot #1][09/15 01:00:42 PM]: WebWalkingEvent; No route found! Destinations = [[x=2057, y=2505, z=0]];
[INFO][Bot #1][09/15 01:00:47 PM]: WebWalkingEvent; No route found! Destinations = [[x=1021, y=1241, z=0]];

here is my webwalk part of script

i had this working great yesterday but with more changes it just.. does not work

private static final Area BANK_AREA = new Area(
        new int[][]{
                {3093,3491},
                {3072,3456},
                {21,35}
        }
);

private static final Area GREEN_DRAGON_AREA = new Area(
        new int[][]{
                {2975, 3626},
                {2944, 3584},
                {31, 33}
        }
);
Edited by DarkScuzz
Link to comment
Share on other sites

1 hour ago, DarkScuzz said:

my script is not working ... i dont understand why
so im next to edgevill bank
in my script the bank has been choose for my script to goto on inventory full and or when starting script

on start the script gets my GUI menu for gear seletion after i click start bot
it just keeps says this on os bot
[INFO][Bot #1][09/15 01:00:24 PM]: Started script : DragonTest
[INFO][Bot #1][09/15 01:00:42 PM]: WebWalkingEvent; No route found! Destinations = [[x=2057, y=2505, z=0]];
[INFO][Bot #1][09/15 01:00:47 PM]: WebWalkingEvent; No route found! Destinations = [[x=1021, y=1241, z=0]];

here is my webwalk part of script

i had this working great yesterday but with more changes it just.. does not work

private static final Area BANK_AREA = new Area(
        new int[][]{
                {3093,3491},
                {3072,3456},
                {21,35}
        }
);

private static final Area GREEN_DRAGON_AREA = new Area(
        new int[][]{
                {2975, 3626},
                {2944, 3584},
                {31, 33}
        }
);

I've fix this issue

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...