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
  • Wizards Tower Demon Killer


    archfiend

    Recommended Posts

    I started Scripting with DreamBot a little while ago... I hope i made some progress in learning the API. I have looked at many references. Can some please fact check my code.

    
    import org.dreambot.api.methods.container.impl.Inventory;
    import org.dreambot.api.methods.filter.Filter;
    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.magic.Magic;
    import org.dreambot.api.methods.magic.Normal;
    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.methods.Calculations;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    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;
    import org.dreambot.api.wrappers.interactive.Player;
    import org.dreambot.api.wrappers.items.GroundItem;
    import org.dreambot.api.wrappers.items.Item;
    
    import java.util.Random;
    
    import static org.dreambot.api.methods.magic.Normal.*;
    
    @ScriptManifest(name = "MasterScript", description = "My 1st Script", author = "MasterSemtax",
            version = 1.0, category = Category.MISC, image = "")
    public class ZenithScript extends AbstractScript {
    
        int STAGE = 0;
        // Define Player as LocalPlayer
        Player player = Players.getLocal();
        // Define the Wizard's Tower area
        Area wizardsTower = new Area(3106, 3935, 3115, 3940);
        // Define the top Floor of the Wizards Tower
        Area wizardsTowerTopFloor = new Area(3108, 3929, 3111, 3928, 2);
        Tile TOP_FLOOR_DEMON_ROOM_A = new Tile(3109, 3928, 2);
        Tile TOP_FLOOR_DEMON_ROOM_B = new Tile(3110, 3929, 2);
        Tile TOP_FLOOR_DEMON_ROOM_C = new Tile(3111, 3928, 2);
        Tile TOP_FLOOR_DEMON_ROOM_D = new Tile(3110, 3928, 2);
        Random random = new Random();
        int floor = 0;
    
        public Tile returnRandomTile(){
            STAGE = 1;
            floor = random.nextInt(4);
            if(floor == 0){ return TOP_FLOOR_DEMON_ROOM_A;
            } else if (floor == 1) { return TOP_FLOOR_DEMON_ROOM_B;
            } else if (floor == 2) { return TOP_FLOOR_DEMON_ROOM_C;
            } else {
                return TOP_FLOOR_DEMON_ROOM_D;
            }
        }
    
    
    
        public void walkToWizardsTower(){
            // Check if the player is already at the wizard's tower
            if (wizardsTower.contains(player)) {
                // Than walk to TOP Floor at a random Tile
                STAGE = 3;
                Walking.walk(returnRandomTile());
            } else {
                // Walk to the wizard's tower
                STAGE = 2;
                Walking.walk(wizardsTower);
            }
        }
    
        public boolean isPlayerInRoom(){
            if(wizardsTowerTopFloor.contains(player)){
                STAGE = 4;
                return true;
            }
            return false;
        }
    
        boolean hasAirStaff = false;
        boolean hasMindRunes = false;
    
        int equiped_tick = 0;
        public boolean hasRequirements() {
            log("Checking for Air Staff...");
            for(Item item : player.getEquipment()){
                if(item.getName().contains("Staff of air") || item.getID() == 1381){
                    STAGE = 5;
                    hasAirStaff = true;
                    break;
                }
            }
    
            if(hasAirStaff){
                equiped_tick++;
                if(equiped_tick <= 3){
                    log("Staff of Air is equipped...");
                }
            }else {
                log("Staff of Air is missing...");
            }
    
            if(Inventory.count(558) >= 1){
                STAGE = 6;
                log("Player holds [ " + Inventory.count(558) + " ]");
                hasMindRunes = true;
            }else {
                log("Player holds zero mind runes");
                hasMindRunes = false;
            }
            return hasAirStaff && Inventory.count(558) >= 1;
        }
    
        public void autoCastWindStrike(){
            if(hasRequirements()){
                NPC npc = NPCs.closest("lesser demon");
    
                if (npc != null) {
                    Magic.castSpellOn(WIND_STRIKE, npc);
                }
            }
        }
    
        Area telegrabArea = new Area(3107, 3926, 3113, 3923,2);
        public void autoCastTelegrab(){
            // Check if the player is in the telegrab area
            if (telegrabArea.contains(player)) {
                // Find the closest ground item
                GroundItem item = GroundItems.closest((Filter<GroundItem>) telegrabArea);
                // Check if the item exists and is visible
                if (item != null && item.isOnScreen()) {
                    // Cast telegrab on the item
                    Magic.castSpellOn(TELEKINETIC_GRAB, item);
                }
            }
        }
        @Override
        public void onStart() {
            log("Setting up Zenith Script...");
            walkToWizardsTower();
        }
    
    
        @Override
        public int onLoop() {
            autoCastWindStrike();
    
            //autoCastTelegrab();
            return Calculations.random(542, 1340);
        }
    
        @Override
        public void onExit() {
            log("Stopping Zenith Script...");
        }
    }

     

    Link to comment
    Share on other sites

    You don't need to define each individual tile/area, you could just define the demon room on the top floor of the Wizard's tower and use getRandomTile and also just do a Walking.walk to this area directly. I'm not sure if there's Web nodes at the top, but I know there is in for the basement so I would assume so. I would also not recommend putting your walk method in onStart and instead do everything in onLoop. Generally I try and limit onStart to GUI functions and maybe setting some vars, but the meat of your functionality should be encased in onLoop.

    Also, what's the point of the STAGE integer? It's defined and assigned values, but never used for anything?

    Other than that, it looks OK for your first script. I like that you're checking for nulls almost everywhere. As you continue familiarizing yourself with the API and writing more complex scripts you'll improve :)

    Link to comment
    Share on other sites

    I wasnt sure where to put the functions in. The reason for STAGE is so the onLoop doesnt loop over the walk. So if the player is in AREA than it attacks incrementing what STAGE the bot is at. So now that Im think about it, the int is more like for DEBUG, I could log the stage in console. 

    I think at first i put Player = new Players(getLocal) which was wrong. I know in regular Java you have to initialize the functions as new Object(methods). 

    Thank you for your input. And thank you for the compliment. Since I now know most of the code looks good. Im going to die sect it.

    1st Im going to test walking to Tower from what ever Tile I log in at. Than Im going to if(Area.contains(player)) dont walk than attack. STAGE++.
    2nd Im going to add more rune to use such as Law and Nature runes for Telegrabing loot from the demon on top floor than high alching the loot
    3rd Im going to limit how long the bot runs and add some anti-ban features.

    Thanks again for your input.

    Link to comment
    Share on other sites

    Walking.walk(wizardsTower);
            if(wizardsTower.contains(player)){
                GameObject ladder = getGameObjects().closest("Ladder");
                // Interact with the ladder
                if (ladder != null) {
                    ladder.interact("Climb-up");
    
                }
            }

    The getGameObjects isnt supported. How would I climb up a ladder? This is the hard part for part of the script.. After this is pretty much smooth sailing.

     

    So I just realize.... Im not climbing up ladders im climb up stair cases....

    but if I would to climb up a ladder it would look like something like this ?
     

    if(!wizardsTower.contains(player) ){
                Walking.walk(wizardsTower);
            }
            if(wizardsTower.contains(player)){
                GameObject ladder = closest("ladder");
                // Interact with the ladder
                if (ladder != null) {
                    ladder.interact("Climb-up");
    
                }
            }


    So i think i gotta switch "ladder" with "staircase"....
    ---------------------------------------------------------------------------------------------------------------------------------------

    Since the post of this project there seems to be a pandemic of bots at wizards tower.... sad... cat is out of the bag.... some one beat me to it... Hmmm.

    Edited by archfiend
    Link to comment
    Share on other sites

    2 hours ago, archfiend said:
    Walking.walk(wizardsTower);
            if(wizardsTower.contains(player)){
                GameObject ladder = getGameObjects().closest("Ladder");
                // Interact with the ladder
                if (ladder != null) {
                    ladder.interact("Climb-up");
    
                }
            }

    The getGameObjects isnt supported. How would I climb up a ladder? This is the hard part for part of the script.. After this is pretty much smooth sailing.

     

    So I just realize.... Im not climbing up ladders im climb up stair cases....

    but if I would to climb up a ladder it would look like something like this ?
     

    if(!wizardsTower.contains(player) ){
                Walking.walk(wizardsTower);
            }
            if(wizardsTower.contains(player)){
                GameObject ladder = closest("ladder");
                // Interact with the ladder
                if (ladder != null) {
                    ladder.interact("Climb-up");
    
                }
            }


    So i think i gotta switch "ladder" with "staircase"....
    ---------------------------------------------------------------------------------------------------------------------------------------

    Since the post of this project there seems to be a pandemic of bots at wizards tower.... sad... cat is out of the bag.... some one beat me to it... Hmmm.

    https://dreambot.org/javadocs/org/dreambot/api/methods/interactive/GameObjects.html

    Recommend looking through the docs, lots of useful information in there

    GameObject ladder = GameObjects.closest("Staircase");

     

    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.