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.

Problems combining overloads with rockcake

Featured Replies

Hello everyone.

In my script I'm trying to combine the use of rock cakes with overloads. It works initially when the bot has started but during combat when it goes to use the overload again it will also use the rock cake as the health is dropping, which leads to me dying.

Any ideas on how I can tweak this code to get it to wait until the overload has finished to then use the rock cake?

Cheers

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.RS2Widget;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.input.mouse.InventorySlotDestination;
import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;


import java.awt.*;

@ScriptManifest(name = "NMZ", author = "Matt", version = 1.0, info = "", logo = "") 

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

        //Code here will execute before the loop is started

    }
    
    private enum State {
		ABSORBPOT, RAPIDHEAL, ROCKCAKE, OVERLOAD, RESTART, WAIT
	};

   
	private State getState() {
		
		if (getSkills().getDynamic(Skill.HITPOINTS) > 50)
		{
			overLoad = true;
			return State.OVERLOAD;
		}
		
		if (getSkills().getDynamic(Skill.HITPOINTS) > 1 && getSkills().getDynamic(Skill.HITPOINTS) < 51 && overLoad == false)
		{
			return State.ROCKCAKE;
		}
		
		if (getCurrentAbsorption() < 200)
		{
			while(getCurrentAbsorption() < 1000)
			{
				return State.ABSORBPOT;
			}
		}
			
		if (getSkills().getDynamic(Skill.HITPOINTS) == 1)
		{
			return State.RAPIDHEAL;
		}
	
		return State.WAIT;
	}
    
	public int onLoop() throws InterruptedException {
		switch (getState()) {
		
		case ROCKCAKE:
			getInventory().interact("Guzzle", "Dwarven rock cake");
			break;
			
		case ABSORBPOT:
			if (getInventory().contains("Absorption (4)"))
			{
				int slot = getInventory().getSlot("Absorption (4)");
		        getMouse().click(new InventorySlotDestination(getBot(), slot));
			}
			else if (getInventory().contains("Absorption (3)"))
			{
				int slot = getInventory().getSlot("Absorption (3)");
		        getMouse().click(new InventorySlotDestination(getBot(), slot));
			}
			else if (getInventory().contains("Absorption (2)"))
			{
				int slot = getInventory().getSlot("Absorption (2)");
		        getMouse().click(new InventorySlotDestination(getBot(), slot));
			}
			else if (getInventory().contains("Absorption (1)"))
			{
				int slot = getInventory().getSlot("Absorption (1)");
		        getMouse().click(new InventorySlotDestination(getBot(), slot));
			}
			break;
			
		case OVERLOAD:
			overLoad = true;
			if (getInventory().contains("Overload (4)"))
			{
				int slot = getInventory().getSlot("Overload (4)");
		        getMouse().click(new InventorySlotDestination(getBot(), slot));
		        sleep(5000);
		        overLoad = false;
			}
			else if (getInventory().contains("Overload (3)"))
			{
				int slot = getInventory().getSlot("Overload (3)");
		        getMouse().click(new InventorySlotDestination(getBot(), slot));
		        sleep(5000);
		        overLoad = false;
			}
			else if (getInventory().contains("Overload (2)"))
			{
				int slot = getInventory().getSlot("Overload (2)");
		        getMouse().click(new InventorySlotDestination(getBot(), slot));
		        sleep(5000);
		        overLoad = false;
			}
			else if (getInventory().contains("Overload (1)"))
			{
				int slot = getInventory().getSlot("Overload (1)");
		        getMouse().click(new InventorySlotDestination(getBot(), slot));
		        sleep(5000);
		        overLoad = false;
			}	
			break;
			
		case RAPIDHEAL:
			RS2Widget quickPrayer = widgets.get(160, 16);
			quickPrayer.interact();
			sleep(500);
			quickPrayer.interact();
			sleep(40000);
			break;
			
		case RESTART:
			sleep(10000);
				
		case WAIT:
			sleep(3000);
			break;
		}
		return random(200, 300);
	}
			
	public int getCurrentAbsorption() {
		RS2Widget widget = widgets.get(202, 1, 9);
		
		if(widget == null || !widget.isVisible() || widget.getMessage().isEmpty())
			return 0;
		
		return Integer.parseInt(widget.getMessage());
	}
		
    @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)

    }

}

 

Edited by uyfgfarOS


You can add a sleep after you eat the rock cake.

You can add a check before you interact with the rock cake (Yes I know you already check with the state thing, but I had this problem too with my script and I added it)

I remember there being 2 options on the rock cake. One to reduce your hp by a larger amount and one option to reduce it by 1. You can use logic here to decide which option the script should use.

It think it would be best to script taking an overload at a specific value (51 for example, or maybe a range. e.g. 51-53)  and then in the part after where you drink the overload put a ConditionalSleep which basically sleeps until your condition is true. So make your condition health >= 1 && health <= 3, for example. That would make the drink absorption part wait until you reached your desired health by absorption. Don't forget to call sleep, use it like this: 

new ConditionalSleep(10000) { //max amount of sleep in constructor
  	//override condition() here
}.sleep();

Otherwise, if you need to do stuff while the health is being dropped (so you can't afford a wait) you would be better of using a timer and then checking the conditions of the timer and health in your guzzle part.

Edit: 
Also, you should post this in Scripting Help

Edited by Reveance

  • 2 weeks later...

I had the same issue a few weeks ago when i first started writing my NMZ script. Personally, I use timers for when to drink an overload since they will ALWAYS last for only 5 minutes, then health is restored. So create a timer after successfully drinking an overload.

 

Only rock cake under a few cases

  • overload timer isn't running and doesn't have overload pots (should have 51 hp but need to bring back down to 1)
  • Health is full at start of dream, rock cake down to 51 for overloads if using them
  • Health is full at start of dream, rock cake down to 1 if not using overloads

Also make sure the timer has been running for at least 5001ms (just a tad over 5 seconds) but i use 5100, otherwise if the script needs to rockcake under a valid condition while the overload is hitting you, it'll rock cake and kill you. Waiting until the overload timer is at least 5001ms into its time will ensure the overload has completed its damage.

Actually, I think I've seen a message when the overload wears off: "The effects of overload have worn off, and you feel normal again." :p. That would actually be the best thing to do; implement a MessageListener in your script and register when the overload has worn off using that message

8 hours ago, Reveance said:

Actually, I think I've seen a message when the overload wears off: "The effects of overload have worn off, and you feel normal again." :p. That would actually be the best thing to do; implement a MessageListener in your script and register when the overload has worn off using that message

Certainly one route you can take, I use a timer so that I can make the script a little more humanlike 

5 hours ago, Polymorphism said:

Certainly one route you can take, I use a timer so that I can make the script a little more humanlike 

Yeah sure, you should add some randomness though...but that applies to both methods. I don't think it actually matters which route you take since I doubt a timer will fail :P 

8 minutes ago, Reveance said:

Yeah sure, you should add some randomness though...but that applies to both methods. I don't think it actually matters which route you take since I doubt a timer will fail :P 

For NMZ, I am building my script around the playing style "afk training in nmz while distracted by other internets" lol

26 minutes ago, Polymorphism said:

For NMZ, I am building my script around the playing style "afk training in nmz while distracted by other internets" lol

haha yeah that does definately work best there :p 

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.