Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Judge my first script

Featured Replies

SO... i decided i want to make bots for osrs because it looked fun, so far it has been exactly that, that and gold. I'm a greedy beach. 

I made a separate botting account because i'm not going to risk my 10 year old account. And i wanted to lvl up my cooking, so i did the first thing that popped into my mind - cook fish. I made a script so that i fished (actually it was shrimps because you don't need bait or anything with shrimp) until my inventory was full, then i ran to the closest trees, chopped it down, made a fire and cooked it all. Dropped it all and ran back to cast my net once more. I wanted to add a banking part to the script but then the account got banned, because this technically wasn't my first script. Before this one i made one that killed goblins and then cows to get food to kill more goblins, but that one is a complete mess (that worked) and i don't want another living soul to see that.

It worked but i know there can be optimizations and i just wanted to know what you kind people might suggest. (i most likely will skill cooking with a different method but still)

Quote

import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.utility.ConditionalSleep;
import org.osbot.rs07.api.Walking;

import java.awt.*;

import java.awt.Graphics2D;
import java.util.Arrays;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "Ma dick", info = "pizza", name = "Cooking trainer + bank", version = 69, logo = "")
public class ass extends Script {



    public int fish_flag = 0;



    @Override
    public void onStart() {
        log("Now we becomin cuc");

    }

    @Override
    public int onLoop() throws InterruptedException {

        Position[] path_to_trees = {
                new Position(3237, 3159, 0), new Position(3239, 3168, 0),
                new Position(3241, 3179, 0), new Position(3244, 3190, 0),
                new Position(3241, 3195, 0), new Position(3238, 3201, 0),
                new Position(3234, 3211, 0), new Position(3235, 3223, 0),
                new Position(3232, 3230, 0),
                new Position(3224, 3236, 0), new Position(3220, 3244, 0)
        };

        Position[] path_to_shrimp = {
                new Position(3220, 3244, 0), new Position(3224, 3236, 0),
                new Position(3232, 3230, 0),
                new Position(3235, 3223, 0), new Position(3234, 3211, 0),
                new Position(3238, 3201, 0), new Position(3241, 3195, 0),
                new Position(3244, 3190, 0), new Position(3241, 3179, 0),
                new Position(3239, 3168, 0), new Position(3237, 3159, 0)
        };

        String raw_food = "Raw shrimps";

        switch (fish_flag){
            case 0:
                log("fish flag 0");
                if(getInventory().getEmptySlots() > 2) {
                    if (getNpcs().closest("Fishing spot") == null) {
                        if (!getNpcs().closest("Fishing spot").hasAction("Net")) {
                            getWalking().webWalk(new Position(3240, 3153, 0));
                        }
                    } else {
                        if (!myPlayer().isAnimating()) {
                            getNpcs().closest("Fishing spot").interact("Net");
                            sleep(random(1000, 5000));
                        } else {
                            sleep(10000);
                        }
                    }
                } else if (getInventory().getEmptySlots() == 0){
                    getInventory().drop(raw_food);
                } else {
                    fish_flag = 1;
                }
                break;
            case 1:
                log("fish flag 1");
                getWalking().walkPath(Arrays.asList(path_to_trees));
                if(getObjects().closest("Tree") != null) {
                    fish_flag = 2;
                }
                break;
            case 2:
                log("fish flag 2");
                if (getInventory().contains(raw_food)) {
                    if (getObjects().closest("Fire") == null) {
                        if (getInventory().contains("Logs")) {
                            getInventory().getItem("Logs").interact("Use");
                            sleep(random(600, 1200));
                            getInventory().getItem("Tinderbox").interact("Use");
                            sleep(20000);
                        } else {
                            getObjects().closest("Tree").interact("Chop down");
                            sleep(10000);
                        }
                    } else {
                        getInventory().getItem(raw_food).interact("Use");
                        sleep(random(800, 1500));
                        getObjects().closest("Fire").interact("Use");
                        sleep(random(800, 1500));
                        getMouse().click(255, 431, false);
                        sleep(30000);
                    }
                } else if (getInventory().contains("Burnt shrimp")){
                    getInventory().drop("Burnt shrimp");
                    sleep(random(1200, 2000));
                } else if (getInventory().contains("Shrimps")){
                    getInventory().drop("Shrimps");
                    sleep(random(1200, 2000));
                } else {
                    getWalking().walkPath(Arrays.asList(path_to_shrimp));
                    if (getNpcs().closest("Fishing spot") != null){
                        fish_flag = 0;
                    }
                }
                break;
        }



        return random(200, 300);
    }

    @Override
    public void onExit() {
        log("I hope you learnt cookn/fishn skills");
    }

    @Override
    public void onPaint(Graphics2D g) {

    }

}

 

  • Author

Oh and the script requires the bot to have a tinderbox, net and an axe in its inventory.

Few general thing,

1. Look into conditional sleeps

2. Look into task based scripts, this will help you in the future to save time on new scripts

3. You are going to get a LOT of null pointers because you are basically running no checks.

Something like:
getInventory().getItem("Tinderbox").interact("Use");

Should actualy look like:

Item tinderbox = getInventory().getItem("Tinderbox");

if (tinderbox != null) {
    tinderbox.interact("Use")

(TBH, you should also add a conditional sleep that checks that the tinderbox was selected successfully.)

4. Look into webwalking

 

Other than that, pretty nice script structer for a first script, keep it going and keep improving :) 

Edited by HunterRS

  • Author

@HunterRS, @Gunman Thanks for the tips!!

The conditional sleep will sure make it more efficient, i was actually wondering if something like that exists.

I thought that webwalking was less reliable, but ill look more into it. I had used it in my very first script and sometimes it did weird stuff.

Ill write some of this down actually :D thanks!!!

Pretty good for a first script. Do a couple more null checks and work on conditional sleeps. 

I did much worse on my first script :) Cheers!

 

Take a look at this. I religiously implement this in every script as if it was part of the API

 

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.