Jump to content

Checking prayer and hp?


Recommended Posts

Posted
27 minutes ago, Chris said:

getSkills.getStatic to get non boosted level

getskills.getDynamic to get a skill that is changing (boosted or stas r weakend etc)

Cheers mate. Just thrown this quick script together but it doesn't interact with anything. Maybe I'm missing something?

 

import org.osbot.rs07.api.GrandExchange;
import org.osbot.rs07.api.Prayer;
import org.osbot.rs07.api.Bank.BankMode;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;


import java.awt.*;

@ScriptManifest(name = "Skeleton", author = "Alek", version = 1.0, info = "", logo = "") 

public class main extends Script {
	
    @Override
  
    public void onStart() {

        //Code here will execute before the loop is started

    }
    
    private enum State {
		PRAYERPOT, OVERLOAD, WAIT
	};

   
	private State getState() {
		
		if (getSkills().getDynamic(Skill.PRAYER) < 20)
		{
			return State.PRAYERPOT;
		}
		if (getSkills().getDynamic(Skill.HITPOINTS) > 51)
		{
			return State.OVERLOAD;
		}	
		return State.WAIT;
	}
    
	public int onLoop() throws InterruptedException {
		switch (getState()) {
		
		case PRAYERPOT:
			if (getInventory().contains("Prayer potion(4)"))
			{
				inventory.getItem("Prayer potion(4)");
				mouse.click(false);
			}
			else if (getInventory().contains("Prayer potion(3)"))
			{
				inventory.getItem("Prayer potion(3)");
				mouse.click(false);
			}
			else if (getInventory().contains("Prayer potion(2)"))
			{
				inventory.getItem("Prayer potion(2)");
				mouse.click(false);
			}
			else if (getInventory().contains("Prayer potion(1)"))
			{
				inventory.getItem("Prayer potion(1)");
				mouse.click(false);
			}
			
			break;
			
		case OVERLOAD:
			if (getInventory().contains("Overload (4)"))
			{
				inventory.getItem("Overload (4)");
				mouse.click(false);
			}
			else if (getInventory().contains("Overload (3)"))
			{
				inventory.getItem("Overload (3)");
				mouse.click(false);
			}
			else if (getInventory().contains("Overload (2)"))
			{
				inventory.getItem("Overload (2)");
				mouse.click(false);
			}
			else if (getInventory().contains("Overload (1)"))
			{
				inventory.getItem("Overload (1)");
				mouse.click(false);
			}
			break;
			
		case WAIT:
			sleep(3000);
			break;
		}
		return random(200, 300);
	}
			

    @Override

    public void onExit() {

        //Code here will execute after the script ends

    }

 

    public void onPaint(Graphics2D g) {

        //This is where you will put your code for paint(s)

    }

}

 

Posted (edited)
4 minutes ago, uyfgfarOS said:

Cheers mate. Just thrown this quick script together but it doesn't interact with anything. Maybe I'm missing something?

 


import org.osbot.rs07.api.GrandExchange;
import org.osbot.rs07.api.Prayer;
import org.osbot.rs07.api.Bank.BankMode;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;


import java.awt.*;

@ScriptManifest(name = "Skeleton", author = "Alek", version = 1.0, info = "", logo = "") 

public class main extends Script {
	
    @Override
  
    public void onStart() {

        //Code here will execute before the loop is started

    }
    
    private enum State {
		PRAYERPOT, OVERLOAD, WAIT
	};

   
	private State getState() {
		
		if (getSkills().getDynamic(Skill.PRAYER) < 20)
		{
			return State.PRAYERPOT;
		}
		if (getSkills().getDynamic(Skill.HITPOINTS) > 51)
		{
			return State.OVERLOAD;
		}	
		return State.WAIT;
	}
    
	public int onLoop() throws InterruptedException {
		switch (getState()) {
		
		case PRAYERPOT:
			if (getInventory().contains("Prayer potion(4)"))
			{
				inventory.getItem("Prayer potion(4)");
				mouse.click(false);
			}
			else if (getInventory().contains("Prayer potion(3)"))
			{
				inventory.getItem("Prayer potion(3)");
				mouse.click(false);
			}
			else if (getInventory().contains("Prayer potion(2)"))
			{
				inventory.getItem("Prayer potion(2)");
				mouse.click(false);
			}
			else if (getInventory().contains("Prayer potion(1)"))
			{
				inventory.getItem("Prayer potion(1)");
				mouse.click(false);
			}
			
			break;
			
		case OVERLOAD:
			if (getInventory().contains("Overload (4)"))
			{
				inventory.getItem("Overload (4)");
				mouse.click(false);
			}
			else if (getInventory().contains("Overload (3)"))
			{
				inventory.getItem("Overload (3)");
				mouse.click(false);
			}
			else if (getInventory().contains("Overload (2)"))
			{
				inventory.getItem("Overload (2)");
				mouse.click(false);
			}
			else if (getInventory().contains("Overload (1)"))
			{
				inventory.getItem("Overload (1)");
				mouse.click(false);
			}
			break;
			
		case WAIT:
			sleep(3000);
			break;
		}
		return random(200, 300);
	}
			

    @Override

    public void onExit() {

        //Code here will execute after the script ends

    }

 

    public void onPaint(Graphics2D g) {

        //This is where you will put your code for paint(s)

    }

}

 

You have to call interact(interaction name) on the item returned by getItem

Edited by Explv
Posted (edited)
7 minutes ago, Explv said:

You have to call interact(interaction name) on the item returned by getItem

Thanks Explv, could you perhaps show me how it's used? I used my above method in a previous herb cleaning script and it worked fine!

 

maybe this?

	
				int slot = getInventory().getSlot("Prayer potion(4)");
		        getMouse().click(new InventorySlotDestination(getBot(), slot));

 

Edited by uyfgfarOS

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
  • Recently Browsing   0 members

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