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.

Trying to cast crumble undead

Featured Replies

Im new to scripting and i made my first script, the point is to make my character continuosly cast crumble undead from the spellbook (without a staff) on the nearest skeleton (i will add Ghosts later). The bot is opening the magic tab, then doing nothing. I have no idea what might cause this issue.


import org.osbot.rs07.api.ui.Spells;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
 
 
import java.awt.*;
 
@ScriptManifest(author = "Dema", info = "Fast magic and hitpoints exp", name = "Crumble Undead", version = 0.13, logo = "")
public class main extends Script {
 
    @Override
    public void onStart() {
        log("Get money, Fuck bitches");
    }
    
    private enum State {
KILL, WAIT
};
 
private State getState() {
NPC skeleton = npcs.closest("Skeleton");
if (skeleton != null)
return State.KILL;
return State.WAIT;
 
}
    @Override
    public int onLoop() throws InterruptedException {
    switch(getState()){
        case KILL:
        NPC skeleton = npcs.closest("Skeleton");
        if (skeleton.isVisible() && getTabs().getOpen().equals(magic)){
        getMagic().castSpellOnEntity(Spells.NormalSpells.CRUMBLE_UNDEAD, skeleton);
        } else sleep(random(100,250));
        getTabs().open(Tab.MAGIC);
        break;
    case WAIT:
    sleep(random(500,700));
    break;
    }
    return random(150, 350);
    onLoop();
    }
    
    @Override
    public void onExit() {
        log("Thanks for running my CRUMBLAH!");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}

The problemo is here:


    switch(getState()){
        case KILL:
        NPC skeleton = npcs.closest("Skeleton");
        if (skeleton.isVisible() && getTabs().getOpen().equals(magic)){
        getMagic().castSpellOnEntity(Spells.NormalSpells.CRUMBLE_UNDEAD, skeleton);
        } else sleep(random(100,250));
        getTabs().open(Tab.MAGIC);
        break;

more importantly:

 if (skeleton.isVisible() && getTabs().getOpen().equals(magic)){

Firstly, nullcheck for the skeleton. Secondly, it would have to be 

getTabs().getOpen().equals(Tab.MAGIC);

(not sure why you had just magic there, but i would expect it to give you an error for that). The reason it opens the magic tab then does nothing is because that if statement returns false every time as you just wrote magic in there. that means it always goes to the else part which says open the magic tab (which already checks if it is open or not before performing). So ye, replace all that with this:

        case KILL:
        NPC skeleton = npcs.closest("Skeleton");
        if (skeleton != null && skeleton.exists() && skeleton.isVisible() && getTabs().getOpen().equals(Tab.MAGIC)){
        getMagic().castSpellOnEntity(Spells.NormalSpells.CRUMBLE_UNDEAD, skeleton);
sleep(3000L);
        } else {
sleep(random(100,250));
        getTabs().open(Tab.MAGIC);
}
        break;

Let me know if anything is unclear

 

Apaec

  • Author

The problemo is here:


    switch(getState()){
        case KILL:
        NPC skeleton = npcs.closest("Skeleton");
        if (skeleton.isVisible() && getTabs().getOpen().equals(magic)){
        getMagic().castSpellOnEntity(Spells.NormalSpells.CRUMBLE_UNDEAD, skeleton);
        } else sleep(random(100,250));
        getTabs().open(Tab.MAGIC);
        break;

more importantly:

 if (skeleton.isVisible() && getTabs().getOpen().equals(magic)){

Firstly, nullcheck for the skeleton. Secondly, it would have to be 

getTabs().getOpen().equals(Tab.MAGIC);

(not sure why you had just magic there, but i would expect it to give you an error for that). The reason it opens the magic tab then does nothing is because that if statement returns false every time as you just wrote magic in there. that means it always goes to the else part which says open the magic tab (which already checks if it is open or not before performing). So ye, replace all that with this:

        case KILL:
        NPC skeleton = npcs.closest("Skeleton");
        if (skeleton != null && skeleton.exists() && skeleton.isVisible() && getTabs().getOpen().equals(Tab.MAGIC)){
        getMagic().castSpellOnEntity(Spells.NormalSpells.CRUMBLE_UNDEAD, skeleton);
sleep(3000L);
        } else {
sleep(random(100,250));
        getTabs().open(Tab.MAGIC);
}
        break;

Let me know if anything is unclear

 

Apaec

Oh hot damn, that was a pretty stupid mistake. Thanks man, its working now.

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.