Jump to content

Prayers, coding problem or client?


scriptersteve

Recommended Posts

1 hour ago, scriptersteve said:

image.png.207ecd2b36fb9e28925212b301cfeb88.png

Problem occurs with turning melee on.


if (this.config.containsPrayer("Protect from Melee")) {
    if (!prayer.isActivated(PrayerButton.PROTECT_FROM_MELEE)) {
        prayer.set(PrayerButton.PROTECT_FROM_MELEE, true);
        log("turning on protect from melee");
    }

}

 

The API looks for the protect from melee prayer using the sprite ID 129. The warning is raised when either no widget with that sprite ID is found, or more than 1 widget with that sprite ID is found.

I don't have 43 prayer, so I cannot determine if this sprite ID is correct. I think the sprite ID is different if the prayer is disabled (for me it's 149).

What you should do is debug the widget (541, 18, 1) using the widget debugger in the client (Settings -> Options -> Widget Debugger) and look at the value of Sprite ID 1 (enabled).

If you have 43 prayer, and you are able to toggle protect from melee on and off, and the sprite ID is not 129, then you should file a bug report.

Either way post here what you find.
 

Edited by Explv
  • Like 1
Link to comment
Share on other sites

17 minutes ago, Explv said:

 

The API looks for the protect from melee prayer using the sprite ID 129. The warning is raised when either no widget with that sprite ID is found, or more than 1 widget with that sprite ID is found.

I don't have 43 prayer, so I cannot determine if this sprite ID is correct. I think the sprite ID is different if the prayer is disabled (for me it's 149).

What you should do is debug the widget (541, 18, 1) using the widget debugger in the client (Settings -> Options -> Widget Debugger) and look at the value of Sprite ID 1 (enabled).

If you have 43 prayer, and you are able to toggle protect from melee on and off, and the sprite ID is not 129, then you should file a bug report.

Either way post here what you find.
 

sprite ID is 129 when enables and -1 when disabled. What exactly are sprite IDs- normally i just use the widget hover thing and try the 3 options till one works

Link to comment
Share on other sites

42 minutes ago, scriptersteve said:

sprite ID is 129 when enables and -1 when disabled. What exactly are sprite IDs- normally i just use the widget hover thing and try the 3 options till one works


A sprite is: https://en.wikipedia.org/wiki/Sprite_(computer_graphics)

In this case the sprite is the little sword icon for the prayer, and the sprite ID uniquely identifies that sprite.

Ok so you say the sprite ID is 129, which is correct, there must be another issue here.

Here is (roughly) the OSBot Prayer.set function, with some added debug log statements. Try using this function instead of the OSBot version, and tell me what the output in the log is. Maybe we can figure out what's breaking.


 

private static int prayerRootID = -1;

public boolean set(PrayerButton prayer, boolean activate) {
    if (getPrayer().isActivated(prayer) == activate || !getPrayer().hasLevelFor(prayer)) {
        return false;
    }

    if (!getPrayer().open()) {
        return false;
    }

    if (prayerRootID == -1) {
        Optional<RS2Widget> prayerIconWidget = getWidgets().getAll()
                                                           .stream()
                                                           .filter(w -> w.getSpriteIndex1() == Sprites.PRAYER_ICON_INSIDE_TAB)
                                                           .findFirst();

        if (!prayerIconWidget.isPresent()) {
            return false;
        }

        prayerRootID = prayerIconWidget.get().getRootId();

        log("Found prayer root ID: " + prayerRootID);
    }

    List<RS2Widget> prayerWidgets = getWidgets().containingSprite(prayerRootID, prayer.getSpriteId());

    log("Found prayer button widgets: " + Arrays.toString(prayerWidgets.toArray()));

    if (prayerWidgets.size() == 1) {
        return prayerWidgets.get(0).interact(activate ? "Activate" : "Deactivate");
    } else {
        warn("A problem was encountered with identifying prayer button for " + prayer.toString());
        return false;
    }
}


 

Edited by Explv
  • Like 1
Link to comment
Share on other sites

 https://gyazo.com/3f5544952cb27733738828a52c8bc095

Seems to miss the widget?

Renamed yours to pset and used that and above occured.

Prayer code was working ~~ 3-4 weeks ago when I last tried checking/editing it

if (this.config.containsPrayer("Protect from Melee")) {
    if (!prayer.isActivated(PrayerButton.PROTECT_FROM_MELEE)) {
        pset(PrayerButton.PROTECT_FROM_MELEE, true);
        log("turning on protect from melee");
    }

}
Edited by scriptersteve
Link to comment
Share on other sites

7 minutes ago, scriptersteve said:


Ok, so that indicates that this block of code, is not working for you:
 

if (prayerRootID == -1) {
    Optional<RS2Widget> prayerIconWidget = getWidgets().getAll()
                                                       .stream()
                                                       .filter(w -> w.getSpriteIndex1() == Sprites.PRAYER_ICON_INSIDE_TAB)
                                                       .findFirst();

    if (!prayerIconWidget.isPresent()) {
        return false;
    }

    prayerRootID = prayerIconWidget.get().getRootId();

    log("Found prayer root ID: " + prayerRootID);
}


That's strange because it works just fine for me:

[INFO][Bot #1][09/23 11:35:17 AM]: Found prayer root ID: 541

Are you running mirror mode or injection?

Also I missed the following line from my original snippet: 

private static int prayerRootID = -1

Make sure you have that as a variable if you don't already (refer to my updated snippet in the previous comment)

Edited by Explv
  • Like 1
Link to comment
Share on other sites

15 minutes ago, scriptersteve said:

 https://gyazo.com/3f5544952cb27733738828a52c8bc095

Seems to miss the widget?

Renamed yours to pset and used that and above occured.

Prayer code was working ~~ 3-4 weeks ago when I last tried checking/editing it


if (this.config.containsPrayer("Protect from Melee")) {
    if (!prayer.isActivated(PrayerButton.PROTECT_FROM_MELEE)) {
        pset(PrayerButton.PROTECT_FROM_MELEE, true);
        log("turning on protect from melee");
    }

}


Are you using injection or mirror mode?

Also try the following:

 

public boolean set(PrayerButton prayer, boolean activate) {
    if (getPrayer().isActivated(prayer) == activate || !getPrayer().hasLevelFor(prayer)) {
        return false;
    }

    if (!getPrayer().open()) {
        return false;
    }

    List<RS2Widget> prayerWidgets = getWidgets().containingSprite(541, prayer.getSpriteId());
        
    if (!prayerWidgets.isEmpty() && prayerWidgets.size() <= 1) {
        return prayerWidgets.get(0).interact(activate ? "Activate" : "Deactivate");
    } else {
        warn("A problem was encountered with identifying prayer button for " + prayer.toString());
        return false;
    }
}

 

  • Like 1
Link to comment
Share on other sites

I am using injection and same error message for the 2nd code as well - think i'll just assume it's a client issue as it has always worked fine previously (raised bug report for it yesterday)  (it's not overly the end of the world for me (just need to manually turn on prot melee when starting the script) - Thanks for your help and hopefully it'll be fixed soon :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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