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.

Attack Options snippet

Featured Replies

Small API for the new attack option stuff they introduced in the update today.

Usage:

 

AttackOptions.setNPC(this, AttackOptions.Option.HIDDEN);
AttackOptions.setPlayer(this, AttackOptions.Option.HIDDEN);

AttackOptions.getNPC(this)
AttackOptions.getPlayer(this)


 


import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.utility.ConditionalSleep;

import java.util.List;

/**
 * Created by Flamezzz on 12/11/2015.
 */
public class AttackOptions {

    public enum Option {
        DEPENDS_ON_COMBAT("Depends on combat levels"),
        ALWAYS_RIGHT_CLICK("Always right-click"),
        LEFT_CLICK_WHERE_AVAILABLE("Left-click where available"),
        HIDDEN("Hidden");

        String str;

        Option(String str) {
            this.str = str;
        }
    }

    private static boolean DEBUG = true;

    private static int[] CONFIGS = {1107, 1306};

    private static final int CONTROLS_ROOT = 261;

    private static void debug(MethodProvider api, String str) {
        if (DEBUG) api.log(str);
    }

    private static boolean openControls(MethodProvider api) {
        RS2Widget controls = api.widgets.singleFilter(
                CONTROLS_ROOT, w ->
                        w.getInteractActions() != null &&
                                w.getInteractActions().length > 0 &&
                                "Controls".equals(w.getInteractActions()[0]));

        if (controls == null || !controls.isVisible())
            return false;

        return controls.getSpriteIndex1() == 762 || controls.interact("Controls");
    }

    public static Option getNPC(MethodProvider api) {
        return Option.values()[api.configs.get(CONFIGS[1])];
    }

    public static Option getPlayer(MethodProvider api) {
        return Option.values()[api.configs.get(CONFIGS[0])];
    }

    public static boolean setNPC(MethodProvider api, Option o) {
        return getNPC(api).equals(o) ? true : set(api, o, "NPC 'Attack' options:", 1);
    }

    public static boolean setPlayer(MethodProvider api, Option o) {
        return getPlayer(api).equals(o) ? true : set(api, o, "Player 'Attack' options:", 0);
    }

    private static List<RS2Widget> getOptions(MethodProvider api) {
        return api.widgets.filter(
                CONTROLS_ROOT, w -> w.isVisible() &&
                        w.getInteractActions() != null &&
                        w.getInteractActions().length > 0 &&
                        "Select".equals(w.getInteractActions()[0]));
    }

    private static boolean set(MethodProvider api, Option o, String searchStr, int idx) {
        if (api.tabs.open(Tab.SETTINGS) && openControls(api)) {
            debug(api, "Opened controls");

            RS2Widget child = api.widgets.singleFilter(CONTROLS_ROOT, w -> w.getMessage().equalsIgnoreCase(searchStr));
            if (child == null || !child.isVisible())
                return false;

            debug(api, "Found child [" + child.getRootId() + "," + child.getSecondLevelId() + "," + child.getThirdLevelId() + "]");

            RS2Widget openOptions = api.widgets.get(child.getRootId(), child.getSecondLevelId(), 1);

            if(openOptions == null || !openOptions.isVisible()) {
                debug(api, "openoptions can not be found");
                return false;
            }

            List<RS2Widget> options = getOptions(api);

            debug(api, "Found " + options.size() + " options");

            if(options.size() != Option.values().length) {
                openOptions.interact();
                debug(api, "Opening option list");

                if (!new ConditionalSleep(5000) {
                    public boolean condition() throws InterruptedException {
                        return getOptions(api).size() == Option.values().length;
                    }
                }.sleep()) {
                    return false;
                }

            }

            debug(api, "Clicking option");

            RS2Widget selectOption = options.get(o.ordinal());

            return selectOption.interact() && new ConditionalSleep(5000) {
                public boolean condition() throws InterruptedException {
                    return api.configs.get(CONFIGS[idx]) == o.ordinal();
                }
            }.sleep();

        }

        return false;
    }
}

Edited by Flamezzz

Nice :doge:

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.