Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Basic Hill Giant Script


    Deep Slayer

    Recommended Posts

    import org.dreambot.api.Client;
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.container.impl.Inventory;
    import org.dreambot.api.methods.container.impl.bank.Bank;
    import org.dreambot.api.methods.container.impl.equipment.Equipment;
    import org.dreambot.api.methods.interactive.NPCs;
    import org.dreambot.api.methods.interactive.Players;
    import org.dreambot.api.methods.item.GroundItems;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.walking.impl.Walking;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.utilities.Sleep;
    import org.dreambot.api.wrappers.interactive.NPC;
    import org.dreambot.api.wrappers.items.GroundItem;
    import org.dreambot.api.wrappers.items.Item;
    
    import java.awt.*;
    
    
    import static org.dreambot.api.methods.Calculations.random;
    
    @ScriptManifest(author = "Deep Slayer", name = "F2P Hill Giant Killer", version = 1.0, description = "Kills and loots Hill Giants", category = Category.COMBAT)
    public class GiantBoneCollector extends AbstractScript {
    
    
        private final Area hillGiantArea = new Area(3102, 9823, 3124, 9854, 0);
    
        private final Area bankArea = new Area(3159, 3487, 3168, 3484, 0);
    
        
        String food = "Tuna";
        int foodAmount = 15;
        String weapon = "Mithril Scimitar";
    
        private enum State {
            EATING,
            CHECK_GEAR,
            GET_KEY,
            TRAVEL_TO_HILL_GIANTS,
            FIGHT_HILL_GIANTS,
            LOOTING,
            BANKING,
            IDLE
        }
    
        private State getState() {
            if (shouldEat()) {
                return State.EATING;
            }
            if (!hasRequiredGear() || !hasBrassKey()) {
                return State.CHECK_GEAR;
            }
    
            if (shouldTravelToHillGiants()) {
                return State.TRAVEL_TO_HILL_GIANTS;
            }
    
            if (shouldFightHillGiants()) {
                return State.FIGHT_HILL_GIANTS;
            }
    
            if (shouldLoot()) {
                return State.LOOTING;
            }
    
            if (shouldBank()) {
                return State.BANKING;
            }
    
            return State.IDLE;
        }
        
    
        public void onStart() {
          
        }
    
        @Override
        public int onLoop() {
            switch (getState()) {
                case EATING:
                    eatFood();
                    break;
                case CHECK_GEAR:
                    checkGear();
                    break;
                case GET_KEY:
                    getKey();
                    break;
                case TRAVEL_TO_HILL_GIANTS:
                    travelToHillGiants();
                    break;
                case FIGHT_HILL_GIANTS:
                    fightHillGiants();
                    break;
                case LOOTING:
                    lootItems();
                    break;
                case BANKING:
                    bankItems();
                    break;
                case IDLE:
                    idle();
                    break;
            }
    
            return random(200, 300);
        }
    
    
        private boolean checkGear() {
    
    
            // Check if the Scimitar is in the player's inventory
            if (Inventory.contains(weapon)) {
                log("cimitar is in the inventory.");
    
                // Attempt to equip the Scimitar
                Item scimitar = Inventory.get(weapon);
                if (scimitar != null && scimitar.interact("Wield")) {
                    log("Equipped Scimitar.");
                    return true;
                }
            }
    
            // Check if the Scimitar is equipped
            if (Equipment.contains(weapon)) {
                log(" Scimitar is already equipped.");
                return true;
            }
    
            // Check if the Scimitar is in the bank
            if (Bank.isOpen() || Bank.open()) {
                if (Bank.contains(weapon)) {
                    log("Scimitar is in the bank. Withdrawing and equipping...");
    
                    // Ensure there's enough space in the inventory
                    if (!Inventory.isFull() || Inventory.contains("Coins")) {
                        if (Bank.withdraw(weapon, 1)) {
                            Bank.close();
                            Sleep.sleepUntil(() -> !Bank.isOpen(), 5000); // Wait for the bank to close
    
                            Item scimitarInInv = Inventory.get(weapon);
                            if (scimitarInInv != null && scimitarInInv.interact("Wield")) {
                                log("Equipped Scimitar from bank.");
                                return true;
                            }
                        } else {
                            log("Failed to withdraw Scimitar. Ensure inventory space.");
                        }
                    } else {
                        log("Not enough space in inventory to withdraw  Scimitar.");
                    }
                }
            }
    
            // If Scimitar is not found in inventory, equipment, or bank
            log(" Scimitar not found. Stopping script.");
            this.stop();
            return false;
        }
    
        private void getKey() {
            String brassKey = "Brass key";
    
            // Check if the Brass Key is in the player's inventory
            if (Inventory.contains(brassKey)) {
                log("Brass Key is in the inventory.");
                return;
            }
    
            // Check if the Brass Key is in the bank
            if (Bank.isOpen() || Bank.open()) {
                if (Bank.contains(brassKey)) {
                    log("Brass Key is in the bank. Withdrawing...");
    
                    if (Bank.withdraw(brassKey, 1)) {
                        log("Brass Key withdrawn from the bank.");
                        // Optional: Close the bank after withdrawing the key
                        Bank.close();
                        return;
                    } else {
                        log("Failed to withdraw Brass Key. Ensure inventory space.");
                        this.stop();
                        return;
                    }
                }
            }
    
            // If Brass Key is not found in inventory or bank
            log("Brass Key not found. Stopping script.");
            this.stop();
        }
    
        private void travelToHillGiants() {
            log("Traveling to the Hill Giants location...");
    
            // Check if we are already in the Hill Giants area
            if (hillGiantArea.contains(Players.getLocal())) {
                log("Arrived at the Hill Giants area.");
                return;
            }
    
            // Walking to the Hill Giants area
            if (Walking.shouldWalk()) {
                Walking.walk(hillGiantArea.getRandomTile());
            }
    
    
        }
    
    
        private void fightHillGiants() {
            NPC hillGiant = NPCs.closest(giant -> giant != null && giant.getName().equals("Hill Giant") && giant.canAttack());
    
            if (hillGiant != null && !Players.getLocal().isInCombat()) {
                if (hillGiant.interact("Attack")) {
                    log("Engaging with Hill Giant.");
                    Sleep.sleepUntil(() -> !hillGiant.isHealthBarVisible() || hillGiant.exists(), random(1200, 2000));
                }
            } else {
                log("No Hill Giants available to attack or already in combat.");
                sleep(random(600, 800));
            }
        }
    
        private void lootItems() {
            // Define the items you want to loot
            String[] lootableItems = {"Big bones", "Uncut sapphire", "Limpwurt root", "Cosmic rune", "Chaos rune","Nature rune", "Law rune"}; // Replace with actual items
    
            for (String itemName : lootableItems) {
                GroundItem item = GroundItems.closest(itemName);
                if (item != null && item.isOnScreen()) {
                    if (Inventory.isFull()) {
                        eatFoodToMakeSpace();  // Call method to eat food to make space
                    }
    
                    if (item.interact("Take")) {
                        log("Looting: " + itemName);
                        Sleep.sleepUntil(() -> !item.exists(), Calculations.random(5000, 8000));
                    }
                }
            }
        }
        private void eatFoodToMakeSpace() {
    
            if (Inventory.contains(food)) {
                Inventory.interact(food, "Eat");
                log("Eating food to make space for loot.");
                Sleep.sleepUntil(() -> !Inventory.isFull(), Calculations.random(800, 1200));
            } else {
                log("No food available to eat for making space.");
            }
        }
    
        private void bankItems() {
            log("Banking items...");
    
            // Navigate to the bank
            if (!bankArea.contains(Players.getLocal())) {
                log("Traveling to the bank...");
                if (Walking.shouldWalk()) {
                    Walking.walk(bankArea.getRandomTile());
                }
            }
    
            // Interact with the bank
            if (bankArea.contains(Players.getLocal())) {
                if (Bank.open()) {
                    log("Bank opened. Depositing items...");
                    Bank.depositAllItems();
                    Sleep.sleepUntil(Inventory::isEmpty, random(1000, 2000));
                    // Retrieve necessary items like food and gear here, if needed
                    Bank.withdraw("Brass key");;
                    sleep(500,1000);
                    Bank.withdraw(food,foodAmount);
                }
            }
    
        }
    
        private void eatFood() {
    
            if (Inventory.contains(food)) {
                Inventory.interact(food,"Eat");
                log("Eating food for health.");
                Sleep.sleepUntil(() -> Players.getLocal().getHealthPercent() > random(50,60), random(1000, 2000));
            }
        }
    
        private void idle() {
            // Implement idle behavior / antiban stuff
    
        }
        private boolean shouldEat() {
            // Example condition: eat if health is below 50%
            return Players.getLocal().getHealthPercent() < 50 && Inventory.contains(food);
        }
        private boolean hasRequiredGear() {
    
    
            // Check if the Scimitar is equipped
            if (Equipment.contains(weapon)) {
                log("Player has the required gear: " + weapon);
                return true;
            } else {
                log("Player does not have the required gear: "+ weapon);
                return false;
            }
        }
    
        private boolean hasBrassKey() {
            String brassKey = "Brass key";
    
            // Check if the Brass Key is in the player's inventory
            if (Inventory.contains(brassKey)) {
                log("Player has the Brass Key.");
                return true;
            } else {
                log("Player does not have the Brass Key.");
                return false;
            }
        }
    
        private boolean shouldTravelToHillGiants() {
            // Check if already in the Hill Giants area
            if (hillGiantArea.contains(Players.getLocal())) {
                log("Already in the Hill Giants area.");
                return false;
            }
    
            // Check if the inventory contains the Brass Key
            if (!Inventory.contains("Brass key")) {
                log("Brass key is missing. Cannot travel to Hill Giants.");
                return false;
            }
    
            // Check if the inventory contains food
             if (!Inventory.contains(food)) {
                log("Food is missing. Cannot safely travel to Hill Giants.");
                return false;
            }
    
            // All conditions met, should travel to Hill Giants
            return true;
        }
    
        private boolean shouldFightHillGiants() {
            // Ensure we are in the Hill Giants area
            if (!hillGiantArea.contains(Players.getLocal())) {
                log("Not in the Hill Giants area.");
                return false;
            }
    
            // Check if there are Hill Giants available to fight
            NPC hillGiant = NPCs.closest(giant -> giant != null && giant.getName().equals("Hill Giant") && giant.canAttack());
            if (hillGiant == null) {
                log("No Hill Giants available to fight.");
                return false;
            }
    
            // Check if the player is already in combat
            if (Players.getLocal().isInCombat()) {
                log("Already in combat.");
                return false;
            }
    
            // Check if the player has enough health
            if (Players.getLocal().getHealthPercent() < 50) {
                log("Health too low to safely engage in combat.");
                return false;
            }
    
            // Check if the player has enough food
            if (!Inventory.contains(food)) { // Replace "food" with your actual food item
                log("Not enough food to continue fighting.");
                return false;
            }
    
            // All conditions met to fight Hill Giants
            return true;
        }
    
        private boolean shouldLoot() {
            // Define the items you consider valuable for looting
            String[] valuableItems = {"Big bones", "Item2", "Item3"}; // Replace with actual valuable items from Hill Giants
    
    
            // Check if lootable items exist and i have food
            if(Inventory.contains(food)) {
                for (String itemName : valuableItems) {
                    GroundItem item = GroundItems.closest(itemName);
                    if (item != null && item.isOnScreen()) {
                        log("Valuable item found on the ground. Time to loot: " + itemName);
                        return true;
                    }
                }
            }
    
    
    
    
            log("No items to loot");
            return false;
        }
    
        private boolean shouldBank() {
            // Check if the player is out of food
            if (!Inventory.contains(food)) {
                log("Out of food, time to bank.");
                return true;
            }
    
            // Other conditions can be added here if needed, like checking the inventory for loot space
    
            return false;
        }
    
    }
    
    Edited by Deep Slayer
    Link to comment
    Share on other sites

    Quick points:

    Start with a brass key and a scimitar.

    Customize food and weapon in global variables.

    You can define lootable items in the lootItems method.

    Recommended to have some armor for lower levels.

    Note: This script has no anti-ban features.  You can implement your own in the idle() method. Use at your own risk.

    Let me know your thoughts or suggestions!

    Thanks!

     

    Edited by Deep Slayer
    Link to comment
    Share on other sites

    • 1 month later...

    nice man! :) kinda kicking myself, wish i saw this sooner! t would of been great to learn from

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.