Everything posted by Brainfree
-
Slayer or Farming?
It's looking like slayer.
-
Slayer or Farming?
If you could have one of those in the SDN, which one would it be, and why?
-
A method for interacting with items on tables.
Hello, Being that the models for items that are elevated are broken(there heights are wrong), I have come up with a method to advert this pesky problem, it simply builds a Prism around were the model should be, and collides its corner vertices to derive it's midpoint, which in most cases, is were exactly the models center point is. Cool stuff. Example: And the src code: package rdpv2; import org.osbot.script.Script; import org.osbot.script.ScriptManifest; import org.osbot.script.rs2.utility.Utilities; import java.awt.*; @ScriptManifest( author = "Brainfree", version = 1.00, info = "Generates a point of elevation were a item on table should be, roughly", name = "Elevated Point Grabber" ) public class TableGrabbing extends Script { public Point[] getLid(int x, int y, int height, double compression) { Point A = getScreenPoint(x, y, 0, 0, height); if (A.x == -1) return null; Point B = getScreenPoint(x, y, 0, 1, height); if (B.x == -1) return null; Point C = getScreenPoint(x, y, 1, 1, height); if (C.x == -1) return null; Point D = getScreenPoint(x, y, 1, 0, height); if (D.x == -1) return null; Point c = getInterceptionPoint(A.x, A.y, C.x, C.y, B.x, B.y, D.x, D.y); Point Ac = getPointOnLineAtDistance(A.x, A.y, c.x, c.y, compression); Point Bc = getPointOnLineAtDistance(B.x, B.y, c.x, c.y, compression); Point Cc = getPointOnLineAtDistance(C.x, C.y, c.x, c.y, compression); Point Dc = getPointOnLineAtDistance(D.x, D.y, c.x, c.y, compression); return new Point[]{Ac, Bc, Cc, Dc}; } private Point getScreenPoint(int x, int y, int sx, int sy, int height) { return Utilities.getScreenCoordinates(bot, (x - client.getMapBaseX() + sx) << 7, (y - client.getMapBaseY() + sy) << 7, height); } public static Point getInterceptionPoint(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { double dot = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4); if (dot == 0) new Point(-1, -1); double X = ((x3 - x4) * (x1 * y2 - y1 * x2) - (x1 - x2) * (x3 * y4 - y3 * x4)) / dot; double Y = ((y3 - y4) * (x1 * y2 - y1 * x2) - (y1 - y2) * (x3 * y4 - y3 * x4)) / dot; return new Point((int) X, (int) Y); } public static Point getPointOnLineAtDistance( double OriginX, double OriginY, double EndLocationX, double EndLocationY, double scale) { final double LegXLength = (EndLocationX - OriginX); final double LegYLength = (EndLocationY - OriginY); double HypotenuseLength = Math.sqrt(LegXLength * LegXLength + LegYLength * LegYLength); double InverseX = HypotenuseLength * scale * LegXLength / HypotenuseLength; double InverseY = (HypotenuseLength * scale * LegYLength) / HypotenuseLength; return new Point( (int) (InverseX + OriginX), (int) (InverseY + OriginY) ); } /** * * Builds a 3D prism around were the ground items model should be in cases * of were the model in a elevated height, and is client failed to interpret it. * * @param tileX The Position X for which the ground item is located. * @param tileY The Position Y for which the ground item is located. * @param heightMin The lower elevation height of the prism. * @param heightMax The upper elevation height of the prism. * @param compression 1.0 = Full Tile bounds length, .75 = 3/4 of the side bounds length * @return The midpoint of the prism. */ public Point getElevatedPoint(int tileX, int tileY, int heightMin, int heightMax, double compression) { Point[] bottom = getLid(tileX, tileX, heightMin, compression); if (bottom == null) return null; Point[] top = getLid(tileX, tileY, heightMax, compression); if (top == null) return null; return getInterceptionPoint( top[0].x, top[0].y, bottom[2].x, bottom[2].y, top[1].x, top[1].y, bottom[3].x, bottom[3].y ); } public int onLoop() { Point wereTheMidPointOfTheModelOfThisItemShouldBe = getElevatedPoint(3232, 3399, 80, 120, .75); return 45; } private void drawLid(Point[] lid, Graphics graphics) { for (int i = 0; i < 4; i++) { graphics.drawLine( lid[i].x, lid[i].y, lid[i == 3 ? 0 : i + 1].x, lid[i == 3 ? 0 : i + 1].y); } } public void drawBounds(int tileX, int tileY, int heightMin, int heightMax, double compression, Graphics g) { Point[] bottom = getLid(tileX, tileY, heightMin, compression); if (bottom == null) return; Point[] top = getLid(tileX, tileY, heightMax, compression); if (top == null) return; for (int i = 0; i < 4; i++) { g.drawLine(bottom[i].x, bottom[i].y, top[i].x, top[i].y); } drawLid(bottom, g); drawLid(top, g); Point center = getInterceptionPoint( top[0].x, top[0].y, bottom[2].x, bottom[2].y, top[1].x, top[1].y, bottom[3].x, bottom[3].y ); g.setColor(Color.red); g.drawString(".", center.x, center.y); } public void onPaint(Graphics graphics) { drawBounds(3232, 3399, 80, 120, .75, graphics); } } Hope you can find great use of it.
-
Telling all facing Entities by distance and Entity type.
Updated to show all facing entities within a given distance.
-
Alternative to Area's
I must note that this will not work for irregular shaped area.
-
Telling all facing Entities by distance and Entity type.
This piece of software will tell you all Entity by a selected set of types, at a given distance, that you are facing. This has uses to tell what Entity's you can interact with (without changing positions, or direction), or are about to interact with. You could also pair it with animations to tell if a player is interacting with it, or yourself (ex. prioritizing ores by filtering 'currently being mined' ore, same with trees). By mainly this was made to tell what tree your were facing, and decide if it's a evil tree, or not (Wiz). Real use example: Example of use is within the code. import org.osbot.script.Script; import org.osbot.script.rs2.Client; import org.osbot.script.rs2.map.Position; import org.osbot.script.rs2.model.Entity; import org.osbot.script.rs2.model.Player; import java.util.ArrayDeque; import java.util.EnumSet; import java.util.List; /** * @author Brainfree */ public class FacingEntities extends Script { public enum DirectionalOrientation { NORTH_WEST(-1, 1, 135), NORTH(0, 1, 90), NORTH_EAST(1, 1, 45), EAST(1, 0, 0), SOUTH_EAST(1, -1, 315), SOUTH(0, -1, 270), SOUTH_WEST(-1, -1, 225), WEST(-1, 0, 180); public final int x_shift, y_shift, angle; DirectionalOrientation(int x_shift, int y_shift, int angle) { this.x_shift = x_shift; this.y_shift = y_shift; this.angle = angle; } } public Position getFacingPosition(Player player, int distance) { int angle_shift = (player.getRotation() / 0x100) * 45; angle_shift -= 270; if (angle_shift > 0) angle_shift += 270; angle_shift = Math.abs(angle_shift); for (DirectionalOrientation orientation : DirectionalOrientation.values()) { if (orientation.angle == angle_shift) { return new Position( player.getX() + (distance * orientation.x_shift), player.getY() + (distance * orientation.y_shift), player.getZ() ); } } return null; } public enum EntityType { OBJECT { @Override public List<? extends Entity> getType(Client client) { return client.getCurrentRegion().getObjects(); } }, NPC { @Override public List<? extends Entity> getType(Client client) { return client.getLocalNPCs(); } }, PLAYER { @Override public List<? extends Entity> getType(Client client) { return client.getLocalPlayers(); } }, GROUND_ITEM { @Override public List<? extends Entity> getType(Client client) { return client.getCurrentRegion().getItems(); } }; public abstract List<? extends Entity> getType(Client client); } public Entity[] getFacingEntities(Client client, Player player, int distanceInTiles, EnumSet<EntityType> checkFor) { if (checkFor == null || checkFor.size() == 0) return new Entity[0]; final Position facing = getFacingPosition(player, distanceInTiles); if (facing == null) return new Entity[0]; ArrayDeque<Entity> pool = new ArrayDeque<Entity>(); for (EntityType type : checkFor) { for (Entity node : type.getType(client)) { if (node != null && node.getX() == facing.getX() && node.getY() == facing.getY() && node.getZ() == facing.getZ()) { pool.add(node); } } } return pool.toArray(new Entity[pool.size()]); } public int onLoop() { Entity[] entitiesImFacingByMySelectedDistance = getFacingEntities( client, myPlayer(), 1, EnumSet.of(EntityType.NPC)); for(Entity cur : entitiesImFacingByMySelectedDistance) { if(cur.getName() != null && cur.getName() == "Tree") { System.out.println("I'm facing a tree, but possibly not interacting with it."); } } return 200; } } This part will tell ALL entities at a given distance away from player, so if the entities was less than, or equal to the distance you desired, and your facing it, it'll be added into the return. import org.osbot.script.Script; import org.osbot.script.ScriptManifest; import org.osbot.script.rs2.Client; import org.osbot.script.rs2.map.Position; import org.osbot.script.rs2.model.Entity; import org.osbot.script.rs2.model.NPC; import org.osbot.script.rs2.model.Player; import java.awt.*; import java.util.ArrayDeque; import java.util.EnumSet; import java.util.List; /** * @author Brainfree */ @ScriptManifest(author = "Brainfree", version = 1.0, info = "Tells all entities you're facing, within a given distance.", name = "FutureViewer") public class AllFacingEntities extends Script { public enum DirectionalOrientation { NORTH_WEST(-1, 1, 135), NORTH(0, 1, 90), NORTH_EAST(1, 1, 45), EAST(1, 0, 0), SOUTH_EAST(1, -1, 315), SOUTH(0, -1, 270), SOUTH_WEST(-1, -1, 225), WEST(-1, 0, 180); public final int x_shift, y_shift, angle; DirectionalOrientation(int x_shift, int y_shift, int angle) { this.x_shift = x_shift; this.y_shift = y_shift; this.angle = angle; } } enum EntityType { OBJECT { @Override public List<? extends Entity> getType(Client client) { return client.getCurrentRegion().getObjects(); } }, NPC { @Override public List<? extends Entity> getType(Client client) { return client.getLocalNPCs(); } }, PLAYER { @Override public List<? extends Entity> getType(Client client) { return client.getLocalPlayers(); } }, GROUND_ITEM { @Override public List<? extends Entity> getType(Client client) { return client.getCurrentRegion().getItems(); } }; public abstract List<? extends Entity> getType(Client client); } public Position getFacingPosition(Player player) { int angle_shift = (player.getRotation() / 0x100) * 45; angle_shift -= 270; if (angle_shift > 0) angle_shift += 270; angle_shift = Math.abs(angle_shift) + 180; if(angle_shift >= 360) angle_shift-= 360; for (DirectionalOrientation orientation : DirectionalOrientation.values()) { if (orientation.angle == angle_shift) { return new Position( player.getX() + orientation.x_shift, player.getY() + orientation.y_shift, player.getZ() ); } } return null; } public static boolean lineContainsPoint(double Ax, double Ay, double Bx, double By, double Px, double Py) { double cross_product = (Py - Ay) * (Bx - Ax) - (Px - Ax) * (By - Ay); double dotproduct = (Px - Ax) * (Bx - Ax) + (Py - Ay) * (By - Ay); return Math.abs((cross_product)) == 0 && dotproduct < 0; } public Entity[] getFacingEntities(Client client, Player player, int distanceInTiles, EnumSet<EntityType> checkFor) { if (checkFor == null || checkFor.size() == 0) return new Entity[0]; final Position facing = getFacingPosition(player); final Position me = client.getMyPlayer().getPosition(); if (facing == null) return new Entity[0]; ArrayDeque<Entity> pool = new ArrayDeque<Entity>(); for (EntityType type : checkFor) { for (Entity node : type.getType(client)) { if (node != null && lineContainsPoint( me.getX(), me.getY(), facing.getX(), facing.getY(), node.getX(), node.getY()) && Math.hypot(node.getX() - me.getX(), node.getY() - me.getY() ) <= distanceInTiles) { pool.add(node); } } } return pool.toArray(new Entity[pool.size()]); } public int onLoop() { Entity[] AllEntitiesImFacingWithinADistanceOf3 = getFacingEntities(client, myPlayer(), 3, EnumSet.of( EntityType.OBJECT, EntityType.NPC)); for(Entity whatImFacing : AllEntitiesImFacingWithinADistanceOf3) { if(whatImFacing instanceof NPC && whatImFacing.getName() == "Banker tutor") { System.out.println("I'm facing a banker tutor :}, she could be 3 tiles away, or even less >_>"); } } return 500; } public void onPaint(Graphics graphics) { Entity[] AllEntitiesImFacingWithinADistanceOf3 = getFacingEntities(client, myPlayer(), 3, EnumSet.of( EntityType.OBJECT, EntityType.NPC)); for(Entity whatImFacing : AllEntitiesImFacingWithinADistanceOf3) { ((Graphics2D) graphics).draw(whatImFacing.getMouseDestination().getArea()); } } } Hope this helps. /Updated, forgot to implement the distance into it. /Updated, as requested by wiz, added code for all facing entities, within a given distance.
-
Does anyone have RC'ing pouches?
If you're willing to let me barrow your account, so I can make a open source RuneCrafter (most likely AIO), please PM me. Please try to have the following: -Decent RuneCrafting level. -Nearly, if not all, the pouches. Thank you.
-
How cool is this?
Does anyone have a account with some seeds, and farming supplies they'll let me barrow? Please PM me.
-
How cool is this?
Has the ability to determine Bushes, Flowers, Herbs, Patches, Plants, Allotments, and Trees. Some notable characteristics: public static enum State { GROWING, WATERED, DISEASED, EMPTY, DEAD, READY, UNKNOWN, BRANCHES, CHECK_HEALTH, CHOPPED };
- Settings?
-
Getting Script Source-Code
Also if its obfuscated, and you don't know how to reverse engineer it, demand a private meeting, or simply ask a buddy who can read past the cluster.
-
So Um?
It might be, but who bothered to even take the time to check? They have clarified that it's not by there actions that it was distributed to seemingly every user. And if they have not notified previously of any given updated, like they have for basically every update they've done; then it's worth suspicion. And I'm sure they'll never personally PM every given user to notify them of an update, that's just silly and a waste of resources. Also you may note it's an executable program, which is a dead give away that's it's fake.
-
Picking Up Items
Look over scripts on the forms, it's how I first started out. Even if it's honest Copy and Pasting, if it works, it works. But I'm sure you're more for the knowledge, so I would suggest studying multiple implementations of your desired methods, and see how there used, and how they are structured into any given script.
-
Picking Up Items
When the API (located on the top banner) is seemingly fixed, look over it. It has documentation on how each method within the API works, along with the required parameters. You could also import it into your IDE if you so wished, but that's a little extreme for your situation. But right now that's all I have to to suggest to you before I pass out on my bed. -Night all.
-
Is Osbot Stable
If you're that worried, then you should be using a proxy sir. But you have every right to be concerned about your 'private' data.
-
Is Osbot Stable
Only thing that matters is that it has been taken care of, and everything is back in near running order. I'm sure they've taken actions to ensure the security of its users.
-
Site Downtime
Alright, at least this is not as bad as I thought have had happened.
-
Model Convexhaulgorithm
This algorithm will extract the bounding points of a given Entities model. This could be used for a more precise interacting, Triangulation, Notification, and just plain looking cool. :^) Disclaimers: The utilities methods for model to points is not working perfectly right now, and it'll cause some weird issues, but its stable. Example: The Code: import org.osbot.script.Script;import org.osbot.script.ScriptManifest;import org.osbot.script.rs2.model.Entity;import org.osbot.script.rs2.model.Model;import org.osbot.script.rs2.model.Player;import org.osbot.script.rs2.utility.Utilities;import java.awt.*;import java.util.Arrays;import java.util.HashSet;import java.util.Iterator;@ScriptManifest(author = "Brainfree", version = 1.0D, name = "OSModelHaulgorithm", info = "Constructs a Convex Haul around a Entities model.")public class OSModelHaulgorithm extends Script { public void onPaint(Graphics g) { for (Player current_player : client.getLocalPlayers()) { Polygon haul = buildEntityConvexPolygon(current_player); if(haul == null) return; ((Graphics2D) g).draw(haul); } } public Polygon buildEntityConvexPolygon(Entity gameObject) { PointSeries structure = buildModelConvexHaul( gameObject.getModel(), gameObject.getGridX(), gameObject.getGridY() ); if (structure == null) return null; return new Polygon(structure.x_points, structure.y_points, structure.num_points); } public PointSeries buildModelConvexHaul(Model model, int gridX, int gridY) { try { Point[] points = Utilities.getModelScreenPoints(this.getBot(), gridX, gridY, model); if (points == null || points.length <= 2) return null; //can't do much with a line. int[][] data = reflectClean(points); int[] x_cluster = new int[data.length], y_cluster = new int[data.length]; for (int i = 0; i < data.length; i++) { x_cluster[i] = data[i][0]; y_cluster[i] = data[i][1]; } PointSeries data_destination = new PointSeries(); reflectHaul(x_cluster, y_cluster, data.length, data_destination); data_destination.filter(0); //empty element slots. return data_destination; } catch (Exception ignored) {} //Utility errors. return null; } public int[][] reflectClean(Point[] points) { HashSet<Point> nodes = new HashSet<Point>(Arrays.asList(points)); //cheaper then clear. int[][] data_matrix = new int[nodes.size()][2]; Iterator<Point> data = nodes.iterator(); Point cur; for (int i = 0; i < nodes.size(); i++) { cur = data.next(); data_matrix[i][0] = cur.x; data_matrix[i][1] = cur.y; } return data_matrix; } public static class PointSeries { private int[] x_points; private int[] y_points; private int num_points = 0; public PointSeries(int initialCapacity) { this.x_points = new int[initialCapacity]; this.y_points = new int[initialCapacity]; } public PointSeries() { this(10); } public void filter(int invalid) { int valid_size = 0; for (int i = 0; i < num_points; i++) if (x_points[i] != invalid && y_points[i] != invalid) valid_size++; int[] x_dest = new int[valid_size], y_dest = new int[valid_size]; int x, y; for (int i = 0; i < num_points; i++) { if ((x = x_points[i]) != invalid && (y = y_points[i]) != invalid) { x_dest[i] = x; y_dest[i] = y; } } x_points = x_dest; y_points = y_dest; num_points = valid_size; } private void expand(int newCapacity) { x_points = Arrays.copyOf(x_points, newCapacity); y_points = Arrays.copyOf(y_points, newCapacity); } public void addPoint(int x, int y) { if (num_points + 1 > x_points.length) expand(((num_points * 3) / 2) + 1); x_points[num_points] = x; y_points[num_points] = y; num_points++; } } public boolean small(int[] xPoints, int[] yPoints, int current, int smallest, int i) { int xa, ya, xb, yb, val; xa = xPoints[smallest] - xPoints[current]; xb = xPoints[i] - xPoints[current]; ya = yPoints[smallest] - yPoints[current]; yb = yPoints[i] - yPoints[current]; val = xa * yb - xb * ya; if (val > 0) return true; else if (val < 0) return false; else { if (xa * xb + ya * yb < 0) return false; else { if (xa * xa + ya * ya > xb * xb + yb * yb) return true; else return false; } } } public void reflectHaul( int[] x_cluster, int[] y_cluster, int numPoints, PointSeries destination) { int min = 0, smallest; for (int i = 1; i < numPoints; i++) { if (y_cluster[i] == y_cluster[min]) { if (x_cluster[i] < x_cluster[min]) min = i; } else if (y_cluster[i] < y_cluster[min]) min = i; } int current = min; do { destination.addPoint(x_cluster[current], y_cluster[current]); smallest = 0; if (smallest == current) smallest = 1; for (int i = 0; i < numPoints; i++) { if ((current == i) || (smallest == i)) continue; if (small(x_cluster, y_cluster, current, smallest, i)) smallest = i; } current = smallest; } while (current != min); }} Have fun!