Search in sources :

Example 1 with Widget

use of org.powerbot.script.rt6.Widget in project powerbot by powerbot.

the class TicketDestroy method poll.

@Override
public void poll() {
    if (ctx.properties.getProperty("key.token.disable", "").equals("true")) {
        // TODO: review this random event
        return;
    }
    final Item item = ctx.backpack.select().id(Constants.TICKETDESTROY_ITEMS).poll();
    if (!item.valid() || !ctx.hud.opened(Hud.Window.BACKPACK) || !ctx.players.local().idle()) {
        priority.set(0);
        return;
    }
    priority.set(3);
    if (!ctx.backpack.scroll(item)) {
        return;
    }
    if (((ctx.varpbits.varpbit(1448) & 0xFF00) >>> 8) < (item.id() == Constants.TICKETDESTROY_ITEMS[0] ? 10 : 9)) {
        item.interact("Claim");
        return;
    }
    if (!item.interact("Destroy")) {
        return;
    }
    final Widget widget = ctx.widgets.widget(1183);
    if (!Condition.wait(new Condition.Check() {

        @Override
        public boolean poll() {
            return widget.valid();
        }
    })) {
        return;
    }
    Component component = null;
    for (final Component c : widget.components()) {
        if (c.visible() && c.tooltip().trim().equalsIgnoreCase("destroy")) {
            component = c;
            break;
        }
    }
    if (component != null && component.interact("Destroy")) {
        Condition.wait(new Condition.Check() {

            @Override
            public boolean poll() {
                return item.component().itemId() == -1;
            }
        }, 175);
    }
}
Also used : Condition(org.powerbot.script.Condition) Item(org.powerbot.script.rt6.Item) Widget(org.powerbot.script.rt6.Widget) Component(org.powerbot.script.rt6.Component)

Aggregations

Condition (org.powerbot.script.Condition)1 Component (org.powerbot.script.rt6.Component)1 Item (org.powerbot.script.rt6.Item)1 Widget (org.powerbot.script.rt6.Widget)1