Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/15/13 in all areas

  1. 1 point
  2. 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!
    1 point
  3. Dear community, Over the coming days I'll be focusing on writing all the randoms I can get my hands on. There have been other community members who have been writing anti random scripts too, I want to encourage this as it would lift work load of my shoulders. However, I will try and get most if not all randoms. Randoms are important and will be the key to our community thriving. Those randoms will have to distributed and version controlled through the SDN we are currently developing. This way you will never have to update your randoms by yourself, the client will automatically take care of this for you. We hope to have the SDN finished in time so we can deploy this system for the ease of use. Also this will mean premium scripts can be made available in the future in a secure way for both developer and user. ETA on full randoms and SDN: Friday April 19'th 8 - 10 PM EDT (GMT - 4) Also please note, any donation this week would help us out a lot. We are low on cash and the development of the SDN involves money! Sincerely, Maxi
    1 point
  4. Very nice work, i'll might donate a nice amout when i get paid, this bot does the work ;) and the staff is doing what the users want!
    1 point
  5. This offers a neat little interface to load and reload (yes, no more restarting the bot over and over to test scripts!) scripts written in pure java and provided in class or jar format. It is run as a normal script, but will load classes from a jar for the actual components of the loader (script and the jar are provided in the linked zip). Writing scripts in pure Java allows for much easier script conversion and more reliable code, not to mention that the Eclipse Groovy plugin is depressingly terrible. http://www.mediafire.com/?wdu4euq2rhple3r Have fun! Extract the .groovy file and .jar file into the OSBot/scripts directory. Post bugs you find on this thread. EDIT: As requested by GoldenGates, virustotal scan: https://www.virustotal.com/en/file/c258964ff359537cd8b9a3101eb04d8326423f9593ce89e7998c4d974d5b9b4a/analysis/1365276512/ EDIT: Updated once, left out script.provideBot(Bot), meaning that scripts will not start in the old version. EDIT: Update again, resource loading was not functioning. Works perfectly now. EDIT: Wow, I'm an idiot... I uploaded only the jar.
    1 point
×
×
  • Create New...