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
  • Try asking for help in the chatbox
  • [QUESTING SCRIPT] Cooks Assistant Assistant!


    Before
     Share

    Recommended Posts

    Yes, I know @Pug has one too, but I made this to learn; and it's open source too!

     

    Start the script anywhere that webwalking works (Lummy). Have a pot and a bucket in your inventory [Tutorial island starter kit has this!]

     

    Code!

     

     

    package main;
    
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.methods.quest.Quest;
    import org.dreambot.api.methods.tabs.Tab;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import org.dreambot.api.wrappers.interactive.NPC;
    import org.dreambot.api.wrappers.items.GroundItem;
    
    import java.util.Random;
    
    @ScriptManifest(category = Category.QUEST, name = "Cooks Assistant Assistant", author = "B4", version = 1.78)
    public class Main extends AbstractScript
    {
    
        public Random Rand = new Random();
        public Area cookArea = new Area(3207,3217,3210,3212,0);
        public Area wheatFieldFailsafe = new Area(3162,3289,3166,3285,0);
        public Area largeDoorFailSafe = new Area(3165,3300,3168,3302,0);
        public Area flourMill = new Area(3165,3307,3167,3304);
        public Area cowPenFailsafe = new Area(3250,3268,3251,3264,0);
        public Area milkCow = new Area(3254,3277,3256,3272,0);
        public Area chickenPenFailsafe = new Area(3237,3296,3239,3294,0);
        public Tile eggTile = new Tile(3229,3299,0);
    
        @Override
        public void onStart()
        {
            getTabs().openWithMouse(Tab.QUEST);
            if (getQuests().isFinished(Quest.COOKS_ASSISTANT))
            {
                log("Quest is already done!");
                stop();
            }
        }
    
        @Override
        public int onLoop()
        {
            getTabs().openWithMouse(Tab.QUEST);
            if (!getQuests().isStarted(Quest.COOKS_ASSISTANT))
            {
                getTabs().openWithMouse(Tab.INVENTORY);
                log("Starting script.");
                while (!cookArea.contains(getLocalPlayer()) && !largeDoorFailSafe.contains(getWalking().getDestination()))
                {
                    getWalking().walk(cookArea.getRandomTile());
                    sleep(2000+Rand.nextInt(1000));
                    sleepUntil(() -> getLocalPlayer().isStandingStill(), Rand.nextInt(6000));
                }
                log("We should now be at the cook.");
                NPC cook = getNpcs().closest("Cook");
                while (!getDialogues().canContinue())
                {
                    cook.interact("Talk-to");
                    sleep(800+Rand.nextInt(200));
                    sleepUntil(() -> getDialogues().canContinue(), 300+Rand.nextInt(50));
                    log("in loop 2");
                }
                getDialogues().continueDialogue();
                sleep(600+Rand.nextInt(600));
                getDialogues().chooseOption(getDialogues().getOptionIndexContaining("What's wrong?"));
                sleep(600+Rand.nextInt(600));
                getDialogues().continueDialogue();//"What's wrong?"
                sleep(600+Rand.nextInt(600));
                getDialogues().continueDialogue();//"Oh dear, oh dear, oh dear.."
                sleep(600+Rand.nextInt(600));
                getDialogues().continueDialogue();//I've forgotten to buy the ingredients...
                sleep(600+Rand.nextInt(600));
                getDialogues().chooseOption(getDialogues().getOptionIndexContaining("I'm always happy to"));
                sleep(600+Rand.nextInt(600));
                getDialogues().continueDialogue();//Yes I'll help you..
                sleep(600+Rand.nextInt(600));
                getDialogues().continueDialogue();//Oh thank you, thank you..
                sleep(600+Rand.nextInt(600));
                getDialogues().continueDialogue();//So where do I find these ingredients?
                sleep(600+Rand.nextInt(600));
                log("We should have finished starting the quest");
            }
    
            getTabs().openWithMouse(Tab.INVENTORY);
    
            /*
    
            PART TWOOOOO
    
            */
    
            switch(Rand.nextInt(3))
            {
                case 1:
                    log("Going to get milk, then egg, then flour");
                    getMilk();
                    getEgg();
                    getFlour();
                    break;
                default:
                    log("Going to get flour, then egg, then milk");
                    getFlour();
                    getEgg();
                    getMilk();
                    break;
            }
            //return to cook
    
            /*
    
            PART THREEEE
    
             */
    
            finishUp();
    
            return 200;
        }
    
        public void finishUp()
        {
            log("We got all our shit!");
    
            while (!cookArea.contains(getLocalPlayer()) && !cookArea.contains(getWalking().getDestination()))
            {
                getWalking().walk(cookArea.getRandomTile());
                sleep(2000+Rand.nextInt(1000));
                sleepUntil(() -> getLocalPlayer().isStandingStill(), Rand.nextInt(6000));
            }
    
            NPC cook = getNpcs().closest("Cook");
            cook.interact("Talk-to");
            sleep(1000+Rand.nextInt(500));
            sleepUntil(() -> getDialogues().canContinue(), 5000+Rand.nextInt(500));
            while (getDialogues().canContinue())
            {
                getKeyboard().type(" ");
                sleep(600+Rand.nextInt(500));
            }
            log("DONE THIS SH--");
            stop();
        }
    
        public int getFlour()
        {
            if (getInventory().contains("Flour"))
            {
                log("We got flour");
                return 0;
            }
            else
            {
                if (!getInventory().contains("Pot"))
                {
                    log("YOU MUST START WITH TUTORIAL STARTING ITEMS! Missing: Pot");
                    stop();
                }
                else
                {
                    if (!getInventory().contains("Wheat"))
                    {
                        while (!wheatFieldFailsafe.contains(getLocalPlayer()) && !wheatFieldFailsafe.contains(getWalking().getDestination()))
                        {
                            getWalking().walk(wheatFieldFailsafe.getRandomTile());
                            sleep(2000+Rand.nextInt(1000));
                            sleepUntil(() -> getLocalPlayer().isStandingStill(), Rand.nextInt(6000));
                        }
    
                        GameObject fence = getGameObjects().closest("Gate");
                        if (fence.hasAction("Open") && fence != null)
                        {
                            fence.interact("Open");
                            sleepUntil(() -> getLocalPlayer().isMoving(), 6000 + Rand.nextInt(3000));
                            log("Opening gate");
                        }
    
                        while (!getInventory().contains("Grain"))
                        {
                            GameObject wheat = getGameObjects().closest("Wheat");
                            if (wheat.hasAction("Pick") && wheat != null)
                            {
                                wheat.interact("Pick");
                                sleep(1000+Rand.nextInt(500));
                            }
                        }
    
                        if (fence.hasAction("Open") && fence != null)
                        {
                            fence.interact("Open");
                            sleep(2000+Rand.nextInt(500));
                        }
                    }
    
                    while (!largeDoorFailSafe.contains(getLocalPlayer()) && !largeDoorFailSafe.contains(getWalking().getDestination()))
                    {
                        getWalking().walk(largeDoorFailSafe.getRandomTile());
                        sleep(2000+Rand.nextInt(1000));
                        sleepUntil(() -> getLocalPlayer().isStandingStill(), Rand.nextInt(6000));
                    }
    
    
                    GameObject bigDoor = getGameObjects().closest("Large Door");
                    if (bigDoor != null && bigDoor.hasAction("Open"))
                    {
                        bigDoor.interact("Open");
                        sleep(2000+Rand.nextInt(600));
                    }
    
                    while (!flourMill.contains(getLocalPlayer()) && !flourMill.contains(getWalking().getDestination()))
                    {
                        getWalking().walk(flourMill.getRandomTile());
                        sleep(2000+Rand.nextInt(1000));
                        sleepUntil(() -> getLocalPlayer().isStandingStill(), Rand.nextInt(6000));
                    }
    
                    while (getLocalPlayer().getZ() == 0)
                    {
                        GameObject ladder = getGameObjects().closest("Ladder");
                        if (ladder != null)
                        {
                            ladder.interact("Climb-up");
                        }
                        sleep(300+Rand.nextInt(200));
                        sleepUntil(() -> getLocalPlayer().isMoving(), 2000 + Rand.nextInt(500));
                        sleepUntil(() -> getLocalPlayer().getZ() == 1, 3000 + Rand.nextInt(600));
                    }
    
    
                    while (getLocalPlayer().getZ() == 1)
                    {
                        GameObject ladder = getGameObjects().closest("Ladder");
                        if (ladder != null)
                        {
                            ladder.interact("Climb-up");
                        }
                        sleep(300+Rand.nextInt(200));
                        sleepUntil(() -> getLocalPlayer().isMoving(), 2000 + Rand.nextInt(500));
                        sleepUntil(() -> getLocalPlayer().getZ() == 2, 3000 + Rand.nextInt(600));
                    }
    
    
                    GameObject hopper = getGameObjects().closest("Hopper");
                    getInventory().get("Grain").useOn(hopper);
                    log("Put grain in hopper");
                    sleep(1000+Rand.nextInt(500));
                    sleepUntil(() -> getLocalPlayer().isStandingStill(), 1000+Rand.nextInt(500));
                    GameObject controls = getGameObjects().closest("Hopper controls");
                    sleep(2000+Rand.nextInt(1000));
                    controls.interact("Operate");
                    sleep(Rand.nextInt(600)+1000);
                    sleepUntil(() -> getLocalPlayer().isStandingStill(), 1000+Rand.nextInt(500));
                    sleep(600+Rand.nextInt(300));
    
                    while (getLocalPlayer().getZ() == 2)
                    {
                        GameObject ladder = getGameObjects().closest("Ladder");
                        if (ladder != null)
                        {
                            ladder.interact("Climb-down");
                        }
                        sleep(300+Rand.nextInt(200));
                        sleepUntil(() -> getLocalPlayer().isMoving(), 2000 + Rand.nextInt(500));
                        sleepUntil(() -> getLocalPlayer().getZ() == 1, 3000 + Rand.nextInt(600));
                    }
    
                    while (getLocalPlayer().getZ() == 1)
                    {
                        GameObject ladder = getGameObjects().closest("Ladder");
                        if (ladder != null)
                        {
                            ladder.interact("Climb-down");
                        }
                        sleep(300+Rand.nextInt(200));
                        sleepUntil(() -> getLocalPlayer().isMoving(), 2000 + Rand.nextInt(500));
                        sleepUntil(() -> getLocalPlayer().getZ() == 0, 3000 + Rand.nextInt(600));
                    }
    
                    GameObject flourBin = getGameObjects().closest("Flour bin");
                    while (flourBin == null)
                    {
                        flourBin = getGameObjects().closest("Flour bin");
                    }
                    flourBin.interact("Empty");
                    sleep(Rand.nextInt(600) + 1000);
                }
            }
            log("We got flour");
            return 0;
        }
        public int getMilk()
        {
            if (getInventory().contains("Bucket of milk"))
            {
                log("We got the milk!");
                return 0;
            }
            else if (!getInventory().contains("Bucket"))
            {
                log ("YOU NEED A BUCKET TO GET MILK!!!!");
                stop();
            }
            while (!cowPenFailsafe.contains(getLocalPlayer()) && !cowPenFailsafe.contains(getWalking().getDestination()))
            {
                getWalking().walk(cowPenFailsafe.getRandomTile());
                sleep(2000+Rand.nextInt(1000));
                sleepUntil(() -> getLocalPlayer().isStandingStill(), Rand.nextInt(6000));
            }
            GameObject gate = getGameObjects().closest("Gate");
            if (gate != null && gate.hasAction("Open"));
            {
                gate.interact("Open");
                sleep(6000+Rand.nextInt(500));
            }
            while (!milkCow.contains(getLocalPlayer()) && !milkCow.contains(getWalking().getDestination()))
            {
                getWalking().walk(milkCow.getRandomTile());
                sleep(2000+Rand.nextInt(1000));
                sleepUntil(() -> getLocalPlayer().isStandingStill(), Rand.nextInt(6000));
            }
            while (!getInventory().contains("Bucket of milk"))
            {
                GameObject cow = getGameObjects().closest("Dairy cow");
                cow.interact("Milk");
                sleep(3000+Rand.nextInt(600));
            }
    
            log("We got the milk!");
            return 0;
    
        }
        public int getEgg()
        {
            if (getInventory().contains("egg"))
            {
                log("We got an egg!!");
                return 0;
            }
            while (!chickenPenFailsafe.contains(getLocalPlayer()) && !chickenPenFailsafe.contains(getWalking().getDestination()))
            {
                getWalking().walk(chickenPenFailsafe.getRandomTile());
                sleep(2000+Rand.nextInt(1000));
                sleepUntil(() -> getLocalPlayer().isStandingStill(), Rand.nextInt(6000));
            }
            sleepUntil(() -> getLocalPlayer().isStandingStill(), 3000+Rand.nextInt(500));
            GameObject gate = getGameObjects().closest("Gate");
            if (gate != null && gate.hasAction("Open"))
            {
                gate.interact("Open");
            }
            GroundItem egg = getGroundItems().closest("Egg");
            if (egg != null)
            {
                egg.interact("Take");
            }
            sleep(600 + Rand.nextInt(300));
            sleepUntil(() -> getInventory().contains("Egg"), 3000 + Rand.nextInt(600));
            if (!getInventory().contains("Egg"))
            {
                getWalking().walk(eggTile);
                while (!getInventory().contains("Egg"))
                {
                    if (egg != null)
                    {
                        egg = getGroundItems().closest("Egg");
                        egg.interact("Take");
                    }
                    sleep(6000+Rand.nextInt(6000));
                }
            }
            return 0;
        }
    }
    
    

     

     

     

    Virus Scan!

     

    Download!

     

    Script has been thoroughly tested on multiple accounts, but submit any issues you may have!


    It could also be noted that the structure of the script allows for a different order for completing the quest parts, meaning lower ban rate! (Right!?)! Yay!!

     

    edit: Fixed download

    Edited by Before
    Link to comment
    Share on other sites

            switch(Rand.nextInt(3))
            {
                case 1:
                    log("Going to get milk, then egg, then flour");
                    getMilk();
                    getEgg();
                    getFlour();
                    break;
                default:
                    log("Going to get flour, then egg, then milk");
                    getFlour();
                    getEgg();
                    getMilk();
                    break;
            }
    

    This one, I don't really understand. But great code overall i guess!

     

    edit:

    Oh and why not use a random number generator for your cases and make case 1 getMilk(), case 2 getEgg() and case 3 getFlour()? By doing this you have the random order of completing the quest AND you save lines of code.

    Edited by Cardozz
    Link to comment
    Share on other sites

    wtf is up with all those while loops

     

    also you could just do if cant continue chat, select option, else continue chat? Woulda saved you like 30 lines

    I had my friend peer-evaluate my code and he said the same thing, along with "I think you're using about 6 million times the processing power"

     

    did ido guud?

    Link to comment
    Share on other sites

    I had my friend peer-evaluate my code and he said the same thing, along with "I think you're using about 6 million times the processing power"

     

    did ido guud?

    Its not so much the processing power that's the issue, since that can be fixed w/ adding thread sleeps to the loops.

    But due to these while loops, you cant really start the script at any point.

    Link to comment
    Share on other sites

    wtf is up with all those while loops

     

    also you could just do if cant continue chat, select option, else continue chat? Woulda saved you like 30 lines

    The other reason you want to do it that way is imagine what happens to your code when you misclick an option. Your code would break badly.

    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
     Share

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