use of org.powerbot.bot.rt6.client.Client in project ORCID-Source by ORCID.
the class JpaJaxbClientAdapterTest method toEntity_withExistingEntityTest.
@Test
public void toEntity_withExistingEntityTest() {
Client client = getClient();
ClientDetailsEntity existingEntity = getClientDetailsEntity();
existingEntity = adapter.toEntity(client, existingEntity);
assertEquals(getClientDetailsEntity(), existingEntity);
}
use of org.powerbot.bot.rt6.client.Client in project ORCID-Source by ORCID.
the class JpaJaxbClientAdapterTest method toClientListTest.
@Test
public void toClientListTest() {
ClientDetailsEntity entity1 = getClientDetailsEntity();
List<ClientDetailsEntity> entities = new ArrayList<ClientDetailsEntity>();
entities.add(entity1);
Set<Client> clients = adapter.toClientList(entities);
assertEquals(1, clients.size());
for (Client client : clients) {
assertEquals(getClient(), client);
}
}
use of org.powerbot.bot.rt6.client.Client 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);
}
}
}
}
use of org.powerbot.bot.rt6.client.Client in project powerbot by powerbot.
the class Component method getInternalComponent.
private Widget getInternalComponent() {
if (index < 0 || widget.id() < 1) {
return null;
}
final Object[] components;
if (parent != null) {
final Widget parentComponent = parent.getInternalComponent();
components = parentComponent != null ? parentComponent.getComponents() : null;
} else {
components = widget.getInternalComponents();
}
final Client c = ctx.client();
return c != null && components != null && index < components.length ? new Widget(c.reflector, components[index]) : null;
}
use of org.powerbot.bot.rt6.client.Client in project powerbot by powerbot.
the class Game method tileToMap.
/**
* Calculates a point on the mini-map.
*
* @param locatable the {@link org.powerbot.script.Locatable} to convert to map point
* @return the map {@link Point}
*/
public Point tileToMap(final Locatable locatable) {
final Point bad = new Point(-1, -1);
final Client client = ctx.client();
final Tile b = ctx.game.mapOffset();
final Tile t = locatable.tile().derive(-b.x(), -b.y());
final int tx = t.x();
final int ty = t.y();
if (client == null || tx < 1 || tx > 103 || ty < 1 || ty > 103) {
return bad;
}
final RelativeLocation r = ctx.players.local().relative();
final float offX = (tx * 4 - r.x() / 128) + 2;
final float offY = (ty * 4 - r.z() / 128) + 2;
final int d = (int) Math.round(Math.sqrt(Math.pow(offX, 2) + Math.pow(offY, 2)));
final Component component = mapComponent();
final int w = component.scrollWidth();
final int h = component.scrollHeight();
final int radius = Math.max(w / 2, h / 2) + 10;
if (d >= radius) /*|| component.contentType() != 1338*/
{
return bad;
}
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 = SIN_TABLE[i], cos = COS_TABLE[i];
if (!f) {
final int scale = 256 + client.getMinimapScale();
sin = 256 * sin / scale;
cos = 256 * cos / scale;
}
int rotX = (int) (cos * offX + sin * offY) >> 14;
int rotY = (int) (cos * offY - sin * offX) >> 14;
rotX += w / 2;
rotY *= -1;
rotY += h / 2;
if (rotX > 4 && rotX < w - 4 && rotY > 4 && rotY < h - 4) {
final Point basePoint = component.screenPoint();
final int sX = rotX + (int) basePoint.getX();
final int sY = rotY + (int) basePoint.getY();
final Point p = new Point(sX, sY);
if (ctx.hud.legacy()) {
final Point mid = new Point(basePoint.x + component.width() / 2, basePoint.y + component.height() / 2);
if (Math.pow(mid.x - p.x, 2) + Math.pow(mid.y - p.y, 2) >= Math.pow(68, 2)) {
return bad;
}
} else {
// entire tile and a half sized 'buffer' area
final Rectangle rbuffer = new Rectangle(p.x - 6, p.y - 6, 12, 12);
for (final Component blocking : mapBlockingComponents()) {
if (blocking.viewportRect().intersects(rbuffer)) {
return bad;
}
}
}
return p;
}
return bad;
}
Aggregations