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
  • Lumbridge Death walker - First Script source code + download


    o0zeroh0o

    Recommended Posts

    Here's my first attempt at a script. It's a really simple bot, it will go get a training sword and shield then fight monsters behind Lumbridge untill you die, then repeat. Feedback on poor coding is very welcome (first experience in programming). 

     

    So far I've used it for 7 hours without fault. Credit goes to Rickk for his tutorials:

    https://dreambot.org/forums/index.php/topic/13077-videobeginner-to-advanced-scripting-tutorials/

     

    If you use it, please don't do so on an account you care about. It's very repetitive with little attention paid to antiban/humanlike behavior. Please don't use this with items in your inventory that you care about.  

     

    dowload & source: 

     

    https://ufile.io/j87wc

    package Main;
    
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.container.impl.equipment.EquipmentSlot;
    import org.dreambot.api.methods.filter.Filter;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.wrappers.interactive.NPC;
    
    
    @ScriptManifest(version = 0.1, name = "Lumbridge Deathwalker", description = "Grabs a training Sword + Shield from combat tutor and then fights to the death behind lumbridge", category = Category.COMBAT, author = "o0zeroh0o")
    public class Main extends AbstractScript {
    
        //ITEMS
        public static final int SWORD = 9703;
        public static final int TRAININGSHIELD = 9704;
    
        //NPCs
        public static final int GIVER = 3216;
        public static final Filter<NPC> ATTACK_FILTER = (NPC npc) -> npc != null && npc.hasAction("Attack") && !npc.isHealthBarVisible() && !npc.isInCombat();
    
        //AREAs
        public static final Area KILL_AREA = new Area(3195, 3241, 3162, 3252);
        public static final Area SWORD_AREA = new Area(3215, 3236, 3221, 3241);
    
        @Override
        public int onLoop() {
            if (getEquipment().isSlotEmpty(EquipmentSlot.WEAPON.getSlot())) {
                getSword();
            }else  if (getEquipment().isSlotEmpty(EquipmentSlot.SHIELD.getSlot())) {
                getShield();
            } else {
                killShit();
            }
            return Calculations.random(1000, 1400);
        }
    
    
        private void getSword() {
            if (getEquipment().isSlotEmpty(EquipmentSlot.WEAPON.getSlot())) {
                if (getInventory().contains(SWORD)) {
                    getInventory().interact(SWORD, "Wield");
                } else {
                    if (getDialogues().canContinue()) {
                        if (getDialogues().continueDialogue()) {
                            sleepUntil(() -> !getDialogues().canContinue(), 3000);
                        }
                    } else {
                        if (!SWORD_AREA.contains(getLocalPlayer())) {
                            walkToTutor();
                        } else {
                            if (SWORD_AREA.contains(getLocalPlayer()) && !getDialogues().inDialogue()) {
                                getNpcs().closest(GIVER).interact("talk-to");
                                sleep(Calculations.random(2500, 3000));
                            }
                        }
                    }
                }
            }
        }
        private void getShield() {
            if (getEquipment().isSlotEmpty(EquipmentSlot.SHIELD.getSlot())) {
                if (getInventory().contains(TRAININGSHIELD)) {
                    getInventory().interact(TRAININGSHIELD, "Wear");
                } else {
                    if (getDialogues().canContinue()) {
                        if (getDialogues().continueDialogue()) {
                            sleepUntil(() -> !getDialogues().canContinue(), 3000);
                        }
                    } else {
                        if (!SWORD_AREA.contains(getLocalPlayer())) {
                            walkToTutor();
                        } else {
                            if (SWORD_AREA.contains(getLocalPlayer()) && !getDialogues().inDialogue()) {
                                getNpcs().closest(GIVER).interact("talk-to");
                                sleep(Calculations.random(2500, 3000));
                            }
                        }
                    }
                }
            }
        }
        private void walkToTutor() {
            if (getWalking().walk(SWORD_AREA.getRandomTile())) {
                sleepUntil(() -> getLocalPlayer().isMoving()
                        || getLocalPlayer().distance(getClient().getDestination()) < Calculations.random(7, 9), Calculations.random(3500, 5400));
            }
        }
    
        private void killShit() {
            if (getLocalPlayer().isInCombat()) {
    
            } else if (KILL_AREA.contains(getLocalPlayer())) {
                NPC ATTACK = getNpcs().closest(ATTACK_FILTER);
                if (ATTACK != null) {
                    ATTACK.interact("Attack");
                }
            }else {
                getWalking().walk(KILL_AREA.getRandomTile());
            }
        }
    }
    
    
    Link to comment
    Share on other sites

    i overlooked this in my tutorial but 

    1. Area killArea = new Area(3195, 3241, 3162, 3252);
    2. Area swordArea = new Area(3215, 3236, 3221, 3241);

    should be private static final Area KILL_AREA

    Link to comment
    Share on other sites

    Nice work. Havent checked out rickk's recent tuts but iirc he hasnt made a combat one so nice one on reading up other methods in the api.

     

    Things you could work on:

     

    - Your filter doesnt check for NPC name/ID. Im not sure whether the kill area only contains goblins but this is something you could add.

    - Overlapping conditions in the loop and the method for getting sword/shield.

    - Isnt the process the same for getting a sword/shield? You could turn it into one method and pass what you need to equip as a parameter to the method.

    - Instead of using sleep until when you walk, should probably use getWalking.shouldWalk().

    - You have an empty block in your killshit method. No need to check if you dont do anything with it. You can combine boolean expressions using '&&' (and). You can inverse boolean expressions using '!' (Not).

    Link to comment
    Share on other sites

    Nice work. Havent checked out rickk's recent tuts but iirc he hasnt made a combat one so nice one on reading up other methods in the api.

     

    Things you could work on:

     

    - Your filter doesnt check for NPC name/ID. Im not sure whether the kill area only contains goblins but this is something you could add.

    - Overlapping conditions in the loop and the method for getting sword/shield.

    - Isnt the process the same for getting a sword/shield? You could turn it into one method and pass what you need to equip as a parameter to the method.

    - Instead of using sleep until when you walk, should probably use getWalking.shouldWalk().

    - You have an empty block in your killshit method. No need to check if you dont do anything with it. You can combine boolean expressions using '&&' (and). You can inverse boolean expressions using '!' (Not).

    Awesome, I'll give this all a go in the morning, thank you!

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • 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.