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.

[SNIPPET] Attack Option Switcher [SNIPPET]

Featured Replies

The Code:

import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.script.Script;

public class CombatSwitcher {
	private Script si;

	private final int parent = 261;
	
	private final int topColumn = 1;
	
	private final int playerSettingBox = 60;
	private final int npcSettingBox = 61;
	
	private final int playerOptionBox = 76;
	private final int npcOptionBox = 77;

	private final int openButton = 7;
	
	private final int mainBox = 4;
	
	private final static int depends = 1;
	private final static int rightClick = 2;
	private final static int leftClick = 3;
	private final static int hidden = 4;
	
	public CombatSwitcher(Script si) {
		this.si = si;
	}

	public static enum Setting {
		DEPENDS_ON_COMBAT_LEVELS("Depends on combat levels", depends), 
		LEFT_CLICK_WHERE_AVAILABLE("Left-click where available", leftClick), 
		ALWAYS_RIGHT_CLICK("Always right-click", rightClick), 
		HIDDEN("Hidden", hidden);

		private final String s;
		private final int id;
		
		Setting(String s, int id) {
			this.s = s;
			this.id = id;
		}
		
		public String toString() {
			return s;
		}
		
		public int getId() {
			return id;
		}
		
		public static Setting toSetting(String s1) {
			for(Setting s: Setting.values()) {
				if(s.toString().equals(s1)) {
					return s;
				}
			}
			return null;
		}
	}

	public boolean isOpen() {
		return si.widgets.getWidgetContainingText("Player 'Attack' Options") != null;
	}

	public boolean open() throws InterruptedException {
		if(isOpen()) {
			return true;
		}
		if (si.tabs.getOpen() != Tab.SETTINGS) {
			if (si.tabs.open(Tab.SETTINGS)) {
				Script.sleep(MethodProvider.random(500, 1000));
				if(!isOpen())  {
					return si.widgets.get(parent, topColumn, openButton).interact();
				}
				return true;
			}
		}
		return si.widgets.get(parent, topColumn, openButton).interact();
	}

	public boolean close() {
		return si.tabs.open(Tab.INVENTORY);
	}
	
	public boolean setPlayerOption(Setting s) throws InterruptedException {
		if (isOpen() || open()) {
			if (s == getCurrentPlayerOption()) 
				return true;
			if(si.widgets.get(parent, playerSettingBox, mainBox).interact() && s != null) {
				Script.sleep(MethodProvider.random(500, 800));
				return si.widgets.get(parent, playerOptionBox, s.getId()).interact();
			}
		}
		return false;
	}

	public boolean setNPCOption(Setting s) throws InterruptedException {
		if (isOpen() || open()) {
			if (s == getCurrentNPCOption()) {
				return true;
			}
			if(si.widgets.get(parent, npcSettingBox, mainBox).interact() && s != null) {
				Script.sleep(MethodProvider.random(500, 800));
				return si.widgets.get(parent, npcOptionBox, s.getId()).interact();
			}
		}
		return false;
	}

	public Setting getCurrentNPCOption() {
		if (isOpen()) {
			return Setting.toSetting(si.widgets.get(parent, npcSettingBox, mainBox).getMessage());
		}
		return null;
	}
	
	public Setting getCurrentPlayerOption() {
		if (isOpen()) {
			return Setting.toSetting(si.widgets.get(parent, playerSettingBox, mainBox).getMessage());
		}
		return null;
	}
}

 

What It Does:

Changes the NPC / Player attack options. Occasionally, the client was misclicking for me and attacking characters that it shouldn't have (both NPCs and Players), so I ended up needing this. Was thinking someone else might need this as well. Should work perfectly. Also always looking for constructive criticism if you want to give some smile.png

 

 

Usage:

public class Main extends Script {
	private CombatSwitcher cs;

    @ Override
    public void onStart() {
    	cs = new CombatSwitcher(this);
    }

    @ Override
    public int onLoop() {
    	cs.setNPCOption(CombatSwitcher.Setting.ALWAYS_RIGHT_CLICK);
        return 100;
    }
}

Edited by Imateamcape

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.