Jump to content

Quick Prayer


Swizzbeat

Recommended Posts

Implementation for people to use in their scripts to support quick prayer. Probably a more viable option just to have users select using quick prayers instead of manually selecting/having the bot turn on the prayers they need.

import org.osbot.script.Script;
import org.osbot.script.rs2.ui.RS2Interface;
import org.osbot.script.rs2.ui.RS2InterfaceChild;
import org.osbot.script.rs2.ui.Tab;

/**
 * Created with IntelliJ IDEA
 * User: Anthony
 * Date: 5/18/2014
 */

public class QuickPrayerController {

	private final Script sI;

	public QuickPrayerController(final Script sI) {
		this.sI = sI;
	}

	/**
	 * Checks if orbs are currently enabled for the player
	 *
	 * @return whether orbs are enabled or not
	 */
	public boolean areOrbsEnabled() {
		return sI.client.getConfig(1055) == 16;
	}

	/**
	 * Toggles data orbs on or off
	 *
	 * @param off whether to toggle off
	 * @return successful or unable to complete operation
	 * @throws InterruptedException
	 */
	public boolean toggleOrbs(boolean off) throws InterruptedException {
		boolean returnValue = false;
		if (!areOrbsEnabled() == off) {
			returnValue = false;
		}
		else {
			if (!sI.currentTab().equals(Tab.SETTINGS)) {
				sI.openTab(Tab.SETTINGS);
			}
			if (sI.currentTab().equals(Tab.SETTINGS)) {
				final RS2Interface parent = sI.client.getInterface(261);
				if (parent != null) {
					final RS2InterfaceChild child = parent.getChild(9);
					if (child != null && child.isVisible()) {
						returnValue = child.interact();
					}
				}
			}
		}
		return returnValue;
	}

	/**
	 * Checks if quick prayer is turned on
	 *
	 * @return whether quick prayer is activated or not
	 */
	public boolean isQuickPrayerOn() {
		return sI.client.getConfig(83) > 0;
	}

	/**
	 * Toggles quick prayer on or off
	 *
	 * @param off whether to toggle off
	 * @return successful or unable to complete operation
	 * @throws InterruptedException
	 */
	public boolean toggleQuickPrayer(boolean off) throws InterruptedException {
		boolean returnValue = false;
		if (!areOrbsEnabled() || !isQuickPrayerOn() == off) {
			returnValue = false;
		}
		else {
			final RS2Interface parent = sI.client.getInterface(548);
			if (parent != null) {
				final RS2InterfaceChild child = parent.getChild(85);
				if (child != null && child.isVisible()) {
					returnValue = child.interact();
				}
			}
		}
		return returnValue;
	}

}
Edited by Swizzbeat
  • Like 2
Link to comment
Share on other sites

Looks good smile.png

I'd get rid of a lot of unnecessary brackets, and I don't know why you are using returnValue variable, just return that (you aren't doing anything after checking anyways).

I prefer brackets because in my opinion it looks neater as compared to just having an indented block to show scope, and I'm using a variable to hold the return value because apparently it's the conventionally correct thing to do with in the business world. Mine as well start now :p

The final keyword doesn't necessarily make it a constant.

Yeah I've had bad assumptions due to learning Java on my own. cleared it up for me :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...