Search in sources :

Example 1 with Component

use of org.sbolstandard.core2.Component in project powerbot by powerbot.

the class DrawAbilities method repaint.

@Override
public void repaint(final Graphics render) {
    if (!ctx.game.loggedIn()) {
        return;
    }
    render.setFont(new Font("Arial", 0, 10));
    render.setColor(Color.green);
    for (final Action action : ctx.combatBar.actions()) {
        final Component c = action.component();
        final Point p = c.screenPoint();
        render.drawString(action.id() + " (" + action.bind() + ")", p.x, p.y);
    }
}
Also used : Action(org.powerbot.script.rt6.Action) Point(java.awt.Point) Component(org.powerbot.script.rt6.Component) Font(java.awt.Font)

Example 2 with Component

use of org.sbolstandard.core2.Component in project powerbot by powerbot.

the class DrawBoundaries method repaint.

@Override
public void repaint(final Graphics render) {
    if (!ctx.game.loggedIn()) {
        return;
    }
    final Client client = ctx.client();
    final RelativeLocation r = ctx.players.local().relative();
    final float rx = r.x();
    final float ry = r.z();
    final Component component = ctx.game.mapComponent();
    final int w = component.scrollWidth();
    final int h = component.scrollHeight();
    final int radius = Math.max(w / 2, h / 2) + 10;
    final boolean f = client.getMinimapSettings() == client.reflector.getConstant("V_MINIMAP_SCALE_ON_VALUE");
    final double a = ctx.camera.rotation() * 16384d / (Math.PI * 2d);
    int i = 0x3fff & (int) a;
    if (!f) {
        i = 0x3fff & client.getMinimapOffset() + (int) a;
    }
    int sin = Game.SIN_TABLE[i], cos = Game.COS_TABLE[i];
    if (!f) {
        final int scale = 256 + client.getMinimapScale();
        sin = 256 * sin / scale;
        cos = 256 * cos / scale;
    }
    final CollisionMap map = ctx.movement.collisionMap();
    final int mapWidth = map.width() - 6;
    final int mapHeight = map.height() - 6;
    final Point[][] points = new Point[mapWidth][mapHeight];
    final Point sp = component.screenPoint();
    for (int x = 0; x < mapWidth; ++x) {
        for (int y = 0; y < mapHeight; ++y) {
            Point p = map(x, y, rx, ry, w, h, radius, sin, cos, sp);
            if (p.x == -1 || p.y == -1) {
                p = null;
            }
            points[x][y] = p;
        }
    }
    final CollisionFlag collisionFlag = CollisionFlag.DEAD_BLOCK.mark(CollisionFlag.OBJECT_BLOCK);
    for (int x = 1; x < mapWidth - 1; ++x) {
        for (int y = 1; y < mapHeight - 1; ++y) {
            final Point tl = points[x][y];
            final Point tr = points[x + 1][y];
            final Point br = points[x + 1][y + 1];
            final Point bl = points[x][y + 1];
            if (tl != null && tr != null && br != null && bl != null) {
                render.setColor(map.flagAt(x, y).contains(collisionFlag) ? new Color(255, 0, 0, 50) : new Color(0, 255, 0, 50));
                render.fillPolygon(new int[] { tl.x, tr.x, br.x, bl.x }, new int[] { tl.y, tr.y, br.y, bl.y }, 4);
            }
        }
    }
}
Also used : RelativeLocation(org.powerbot.script.rt6.RelativeLocation) CollisionFlag(org.powerbot.script.rt6.CollisionFlag) Color(java.awt.Color) Point(java.awt.Point) Client(org.powerbot.bot.rt6.client.Client) Component(org.powerbot.script.rt6.Component) CollisionMap(org.powerbot.script.rt6.CollisionMap) Point(java.awt.Point)

Example 3 with Component

use of org.sbolstandard.core2.Component in project powerbot by powerbot.

the class DrawItems method repaint.

public void repaint(final Graphics render) {
    if (!ctx.game.loggedIn()) {
        return;
    }
    render.setFont(new Font("Arial", 0, 10));
    render.setColor(Color.green);
    if (ctx.bank.opened()) {
        final Component container = ctx.widgets.component(Constants.BANK_WIDGET, Constants.BANK_ITEMS);
        final Rectangle r = container.viewportRect();
        if (r != null) {
            for (final Item item : ctx.bank.select()) {
                final Component c = item.component();
                if (c == null) {
                    continue;
                }
                final Rectangle r2 = c.boundingRect();
                if (r2 == null) {
                    continue;
                }
                if (c.relativePoint().y == 0 || !r.contains(r2)) {
                    continue;
                }
                final Point p = c.screenPoint();
                render.drawString(c.itemId() + "", p.x, p.y + c.height());
            }
        }
    }
    if (ctx.backpack.component().visible()) {
        for (final Item item : ctx.backpack.select()) {
            final Component c = item.component();
            if (c == null) {
                continue;
            }
            final Point p = c.screenPoint();
            render.drawString(c.itemId() + "", p.x, p.y + c.height());
        }
    }
    if (ctx.equipment.component().visible()) {
        for (final Item item : ctx.equipment.select()) {
            if (item == null) {
                continue;
            }
            final Component c = item.component();
            if (c == null) {
                continue;
            }
            final Point p = c.screenPoint();
            render.drawString(c.itemId() + "", p.x, p.y + c.height());
        }
    }
}
Also used : Item(org.powerbot.script.rt6.Item) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Component(org.powerbot.script.rt6.Component) Font(java.awt.Font)

Example 4 with Component

use of org.sbolstandard.core2.Component in project powerbot by powerbot.

the class BankPin method poll.

@Override
public void poll() {
    if (!ctx.widgets.widget(Constants.BANKPIN_WIDGET).valid()) {
        if (threshold.contains(this)) {
            threshold.remove(this);
        }
        return;
    }
    if (!threshold.contains(this)) {
        threshold.add(this);
    }
    final String pin = getPin();
    if (pin == null) {
        ctx.controller.stop();
        return;
    }
    for (final Component c : ctx.widgets.widget(Constants.BANKPIN_WIDGET).components()) {
        if (c.textColor() != 0 || c.width() != 64 || c.height() != 64 || c.componentCount() != 2 || !c.visible()) {
            continue;
        }
        final Component child = c.component(1);
        if (!child.visible()) {
            continue;
        }
        // TODO: re-evaluate this to get rid of count; or fail out
        final String text = child.text();
        if (text.equals("" + pin.charAt(count % 4))) {
            if (c.click()) {
                count++;
                Condition.wait(new Condition.Check() {

                    public boolean poll() {
                        return !child.text().equals(text);
                    }
                }, 100, 20);
            }
        }
    }
}
Also used : Condition(org.powerbot.script.Condition) Component(org.powerbot.script.rt4.Component)

Example 5 with Component

use of org.sbolstandard.core2.Component 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

URI (java.net.URI)25 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)22 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)7 QName (javax.xml.namespace.QName)6 Point (java.awt.Point)5 Component (org.powerbot.script.rt6.Component)5 SBOLDocument (org.sbolstandard.core2.SBOLDocument)5 Condition (org.powerbot.script.Condition)4 Literal (org.sbolstandard.core.datatree.Literal)4 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)4 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)4 Component (org.sbolstandard.core2.Component)4 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)3 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)3 Sequence (org.sbolstandard.core2.Sequence)3 SequenceAnnotation (org.sbolstandard.core2.SequenceAnnotation)3 Font (java.awt.Font)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2