Search in sources :

Example 41 with Client

use of org.powerbot.bot.rt6.client.Client in project powerbot by powerbot.

the class Game method tileHeight.

/**
 * Returns the tile height of the relative 2-dimensional tile. The
 * 3-dimensional axis is flipped to represent the X axis being horizontal,
 * Y axis being Vertical, and Z axis to be depth.
 *
 * @param relativeX The x-axis value relative to the origin
 * @param relativeZ The z-axis value relative to the origin
 * @return The tile height
 */
public int tileHeight(final int relativeX, final int relativeZ) {
    final Client client = ctx.client();
    if (client == null) {
        return 0;
    }
    int floor = client.getFloor();
    int x = relativeX >> 7;
    int y = relativeZ >> 7;
    if (x < 0 || y < 0 || x > 103 || y > 103 || floor < 0 || floor > 3) {
        return 0;
    }
    final byte[][][] meta = client.getLandscapeMeta();
    final int[][][] heights = client.getTileHeights();
    if (meta == null) {
        return 0;
    }
    if (floor < 3 && (meta[1][x][y] & 0x2) == 2) {
        floor++;
    }
    x &= 0x7f;
    y &= 0x7f;
    final int heightStart = x * heights[floor][1 + x][y] + heights[floor][x][y] * (128 - x) >> 7;
    final int heightEnd = (128 - x) * heights[floor][x][1 + y] + x * heights[floor][1 + x][y + 1] >> 7;
    return y * heightEnd + heightStart * (128 - y) >> 7;
}
Also used : Client(org.powerbot.bot.rt4.client.Client)

Example 42 with Client

use of org.powerbot.bot.rt6.client.Client in project powerbot by powerbot.

the class Game method tileToMap.

/**
 * Converts the 3-dimensional tile to a 2-dimensional point on the mini-map component.
 *
 * @param tile The tile to convert
 * @return The point on screen of where the tile would be.
 */
public Point tileToMap(final Tile tile) {
    final Client client = ctx.client();
    if (client == null) {
        return new Point(-1, -1);
    }
    final int rel = ctx.players.local().relative();
    final int angle = client.getMinimapAngle() & 0x7ff;
    final int[] d = { tile.x(), tile.y(), ARRAY_SIN[angle], ARRAY_COS[angle], -1, -1 };
    d[0] = (d[0] - client.getOffsetX()) * 4 + 2 - (rel >> 16) / 32;
    d[1] = (d[1] - client.getOffsetY()) * 4 + 2 - (rel & 0xffff) / 32;
    d[4] = d[1] * d[2] + d[3] * d[0] >> 16;
    d[5] = d[2] * d[0] - d[1] * d[3] >> 16;
    final Point centre = mapComponent().centerPoint();
    return new Point(centre.x + d[4], centre.y + d[5]);
}
Also used : Client(org.powerbot.bot.rt4.client.Client)

Example 43 with Client

use of org.powerbot.bot.rt6.client.Client in project powerbot by powerbot.

the class Game method worldToScreen.

/**
 * Converts a 3-dimensional point within the overworld to a 2-dimensional point on the
 * screen. The 3-dimensional axis is flipped to represent the X axis being horizontal,
 * Y axis being vertical, and Z axis to be depth.
 *
 * @param relativeX The x-axis value relative to the origin
 * @param relativeY The y-axis value relative to the origin
 * @param relativeZ The z-axis value relative to the origin
 * @param h         The y-axis value, otherwise known as height
 * @return The 2-dimensional point on screen.
 */
public Point worldToScreen(final int relativeX, final int relativeY, final int relativeZ, final int h) {
    final Client client = ctx.client();
    final Point r = new Point(-1, -1);
    if (relativeX < 128 || relativeX > 13056 || relativeZ < 128 || relativeZ > 13056) {
        return r;
    }
    final int floor = client.getFloor();
    if (floor < 0) {
        return r;
    }
    final int height = relativeY - h;
    final int projectedX = relativeX - client.getCameraX(), projectedZ = relativeZ - client.getCameraZ(), projectedY = height - client.getCameraY();
    final int pitch = client.getCameraPitch(), yaw = client.getCameraYaw();
    final int[] c = { ARRAY_SIN[yaw], ARRAY_COS[yaw], ARRAY_SIN[pitch], ARRAY_COS[pitch] };
    final int rotatedX = c[0] * projectedZ + c[1] * projectedX >> 16;
    final int rotatedZ = c[1] * projectedZ - c[0] * projectedX >> 16;
    final int rolledY = c[3] * projectedY - c[2] * rotatedZ >> 16;
    final int rolledZ = c[3] * rotatedZ + c[2] * projectedY >> 16;
    if (rolledZ >= 50) {
        int mx = 256, my = 167;
        if (ctx.widgets.widget(Constants.VIEWPORT_WIDGET >> 16).component(Constants.VIEWPORT_WIDGET & 0xffff).screenPoint().x != 4) {
            final Dimension d = dimensions();
            mx = d.width / 2;
            my = d.height / 2;
        }
        final int proj = client.getTileSize();
        return new Point((rotatedX * proj) / rolledZ + mx, (rolledY * proj) / rolledZ + my);
    }
    return r;
}
Also used : Client(org.powerbot.bot.rt4.client.Client)

Example 44 with Client

use of org.powerbot.bot.rt6.client.Client in project hpcourse by cscenter.

the class SimpleTests method subscribeTask.

public void subscribeTask() {
    new Thread(new Runnable() {

        @Override
        public void run() {
            Client client = new Client("localhost", 1500);
            client.subscribe(5);
        }
    }).start();
}
Also used : Client(client.Client)

Example 45 with Client

use of org.powerbot.bot.rt6.client.Client in project hpcourse by cscenter.

the class Main method main.

public static void main(String[] args) {
    int serverPort = 4242;
    try {
        new Server(serverPort);
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    }
    try {
        Client client1 = new Client("localhost", serverPort, "#1");
        client1.sendSubmitTaskRequest(42, 20, 30, 0, 0);
        client1.sendSubscribeRequest(1);
        client1.sendSubscribeRequest(2);
        client1.sendSubscribeRequest(1);
        Client client2 = new Client("localhost", serverPort, "#2");
        client2.sendSubmitTaskRequest(10, 20, 40, 1, 1000000000);
        client2.sendSubscribeRequest(2);
        client2.sendSubscribeRequest(1);
        client2.sendSubscribeRequest(2);
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(2);
    }
}
Also used : Server(ru.compscicenter.hpc2016.ha1.server.Server) IOException(java.io.IOException) Client(ru.compscicenter.hpc2016.ha1.client.Client)

Aggregations

Client (org.powerbot.bot.rt4.client.Client)36 Client (org.powerbot.bot.rt6.client.Client)33 Point (java.awt.Point)26 ArrayList (java.util.ArrayList)13 Client (org.orcid.jaxb.model.v3.dev1.client.Client)11 Test (org.junit.Test)8 Tile (org.powerbot.script.Tile)8 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)6 HashSet (java.util.HashSet)5 Rectangle (java.awt.Rectangle)4 Reflector (org.powerbot.bot.Reflector)4 Condition (org.powerbot.script.Condition)4 Client (client.Client)3 LinkedList (java.util.LinkedList)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 ClientRedirectUri (org.orcid.jaxb.model.v3.dev1.client.ClientRedirectUri)3 Graphics (java.awt.Graphics)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)2