Jump to content

PolishCivil

Members
  • Posts

    669
  • Joined

  • Last visited

  • Days Won

    3
  • Feedback

    100%

Everything posted by PolishCivil

  1. org.osbot.rs07.event.Event execute = execute(new ClickMouseEvent(new RectangleDestination(bot, x, y, w, h))); clicked = execute.hasFinished(); I just use sth like ^, and actually you ca override RectDestination class and you can mae it polygon or whatever you want.
  2. But the point is b = true; for (; b;) { System.out.println(b = false); } Its same as boolean b = true; while (b) { System.out.println(b = false); } This is only matter of clean readable code. Generally we use for's when we know number of iteractions, we use while when we doesnt. Anyways I'd rather use while(true) vs for(;;) etc. So they will never mess up cuz u can do same thing with them
  3. Wuts wrong with while loops? Anyways @OT Yo code is really weird, can't really say much, but one thing It doesnt really make sense because your mine pos is len = 1, so you will never have i > 0 so you can search only for one area(0) i think you messed up everything lol Here you probably have race condition. Maybe osbot store objects in cache and update them each tick aka 600ms ? I had this situations too.
  4. Got objects, they need a little alignment too
  5. Actually I always wanted to make this. This will help me to make flaweless tool for webwalker. And it will work for every new rscache I maybe release it when I'm done :P
  6. Not object yet, but might be already usefull, all planes. https://www.dropbox.com/sh/6gsibmo35ena4tf/AAA_yTgpKY50ZsA00FBe3_zCa
  7. Fixed up blending a little. Still no objects yet ;/ You guys can download TRUE rsmap (256x256 blocks)
  8. Now time for object, this will be hard as f
  9. XD this is the thing i want to avoid cuz they are hiding the tiles, but yh this is cool because we know ever bank position Textures ! (Lol, jagex really seems to be packing everything to cache.)
  10. Na, red are textured ones, i need dump textures then it will looks fine Its like jagex making lava texture and on minimap it fills tile with average color on this texture.
  11. Ye probably, its same as OSBot's thing, but my has proper color calculation XD
  12. I need to finish this shit. Atm got simple overlay, underlay color calcs. (They should be fixed too) Pics ;3 Imma update when i add something cool to it.
  13. Possible solutions: Mulit area: A filter all npcs that are interacting with you, when you're not interacting any and you're under attack. A result - the npc you want to attack first. B filter all npcs that are interacting you, when you're attacking npc. B result - now you have npc that you want to attack next (after killing the current one) Single area A simply filter all npcs that are interacting with you when you're not interacting any and you're under attack. A result - the npc you want to attack, or run away from it. You want to make such things in other thread.
  14. @Proryan thing: /** * Checks if we are hovering this entity. * * @param atMethodProvider - the atMethodProvider instance. * @param entity - the entity. * @return whether we are. */ public static boolean isHovering(ATMethodProvider atMethodProvider, Entity entity) { Model model = entity.getModel(); short[][] screenCoordinates = GraphicUtilities.getScreenCoordinates(atMethodProvider.bot, entity.getGridX(), entity.getGridY(), entity.getZ(), model); for (int triangleId = 0; triangleId < model.getTriangleCount(); triangleId++) { int triangleA = model.getVertexXIndices()[triangleId]; int triangleB = model.getVertexYIndices()[triangleId]; int triangleC = model.getVertexZIndices()[triangleId]; short[] pointA = screenCoordinates[triangleA]; short[] pointB = screenCoordinates[triangleB]; short[] pointC = screenCoordinates[triangleC]; short[][] points = new short[][]{pointA, pointB, pointC}; Point position = atMethodProvider.mouse.getPosition(); if (Calculations.contains(points, position.x, position.y)) { return true; } } return false; } @Contains is from Polygon.contains /** * Checks if point is inside polygon. * * @param points - the polygon points. * @param x - the point x to check. * @param y - the point y to check. * @return whether it is. */ public static boolean contains(short[][] points, double x, double y) { int hits = 0; int npoints = points.length; int lastx = points[npoints - 1][0]; int lasty = points[npoints - 1][1]; int curx, cury; // Walk the edges of the polygon for (int i = 0; i < npoints; lastx = curx, lasty = cury, i++) { curx = points[i][0]; cury = points[i][1]; if (cury == lasty) { continue; } int leftx; if (curx < lastx) { if (x >= lastx) { continue; } leftx = curx; } else { if (x >= curx) { continue; } leftx = lastx; } double test1, test2; if (cury < lasty) { if (y < cury || y >= lasty) { continue; } if (x < leftx) { hits++; continue; } test1 = x - curx; test2 = y - cury; } else { if (y < lasty || y >= cury) { continue; } if (x < leftx) { hits++; continue; } test1 = x - lastx; test2 = y - lasty; } if (test1 < (test2 / (lasty - cury) * (lastx - curx))) { hits++; } } return ((hits & 1) != 0); }
  15. Ye, but with just rect u can fail some times cuz mouse will not be on any triangle, this thing reduces such thing, but yh making it checking for triangles should be less pain and more precise. Actually tbh i just wanted to show ppl that this thing exists and can be used
  16. Ye, something like class PolygonDest extends RectangleDestination { private Polygon polygon; public PolygonDest(Bot bot, Polygon polygon) { super(bot, polygon.getBounds()); this.polygon = polygon; } @Override public Area getArea() { return new Area(polygon); } } It will work cuz they are actually using area to check if mouse position is inside it. @Override public int execute() throws InterruptedException { if (!this.destination.isVisible()) { final boolean b = false; this.setFailed(); return b ? 1 : 0; } final Point position = this.mouse.getPosition(); int n = 0; if ((((this.interactionEvent == null) ? this.destination.getArea().contains(position) : this.destination.evaluate(this.interactionEvent, this.destination.getBoundingBox())) ? (n = 1) : n) == 0 && MethodProvider.gRandom(3, 2.0) == 0) { n = 1; }
  17. Hey, before i start I've seen this one already on forums, as i remember our BrainFree mentioned it. Because my engrish is really bad, i will try to provide links instead writing how it works. So here it is one more time: Convex hull is generally tightest area of point set. So what we want to do is to calculate 2D points of our object, entity and make convex hull for it for perfect bounding polygon, it will be really helpfull on fighter scripts or any script that needs to interact alot, it will fail less time. Bounding box you were using: What we want to accomplish: As you see we have some blind spots on basic rect bounding box: Red - hulling will reduce them. Yellow - hulling will not reduce them (actually the one i want to show) It is not really necessary to remove yellow ones so w/e. The thing is we want to shink area a little bit to be more precise when interacting. So the algorithm is like this: /** * Making convex hull around points. * * @param points - the points * @return - the convex hull points points. */ public static short[][] hull(short[][] points) { int upperSize = 2; int lowerSize = 2; int pointsSize = points.length; short[][] lUpper = new short[pointsSize][2]; short[][] lLower = new short[pointsSize][2]; short[][] xSorted = points.clone(); Arrays.sort(xSorted, new Comparator<short[]>() { @Override public int compare(short[] o1, short[] o2) { return Integer.compare(o1[0], o2[0]); } }); lUpper[0] = xSorted[0]; lUpper[1] = xSorted[1]; lLower[0] = xSorted[pointsSize - 1]; lLower[1] = xSorted[pointsSize - 2]; for (int i = 2; i < pointsSize; i++) { lUpper[upperSize] = xSorted[i]; upperSize++; while (upperSize > 2 && !rightTurn(lUpper[upperSize - 3], lUpper[upperSize - 2], lUpper[upperSize - 1])) { lUpper[upperSize - 2] = lUpper[upperSize - 1]; upperSize--; } } for (int i = pointsSize - 3; i >= 0; i--) { lLower[lowerSize] = xSorted[i]; lowerSize++; while (lowerSize > 2 && !rightTurn(lLower[lowerSize - 3], lLower[lowerSize - 2], lLower[lowerSize - 1])) { lLower[lowerSize - 2] = lLower[lowerSize - 1]; lowerSize--; } } short[][] result = new short[upperSize + lowerSize - 1][2]; System.arraycopy(lUpper, 0, result, 0, upperSize); System.arraycopy(lLower, 0, result, upperSize, lowerSize - 1); return result; } /** * Checks if points turns right. * * @param a - the 'a' point. * @param b - the 'b' point. * @param c - the 'c' point. * @return */ private static boolean rightTurn(short[] a, short[] b, short[] c) { return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]) > 0; } (I ddnt made it as i remember but i cant find real author) What do you need to read to understand this algorithm: http://en.wikipedia.org/wiki/Convex_hull en.wikipedia.org/wiki/Graham_scan /** * Converting points to polygon. * * @param points - the - the points. * @return the polygon based on points. */ public static Polygon toPolygon(short[][] points) { Polygon result = new Polygon(); for (short[] point : points) { result.addPoint(point[0], point[1]); } return result; } How to implement : First we need to get screen coords: http://osbot.org/osbot2_api/org/osbot/rs07/api/util/GraphicUtilities.html#getScreenCoordinates%28org.osbot.rs07.Bot,%20int,%20int,%20int,%20org.osbot.rs07.api.model.Model%29 Then we make hull based on points: hull(screenCoordinates); Example for dumbs: Entity litara = npcs.closest("Litara"); short[][] screenCoordinates = Calculations.getScreenCoordinates(this, litara.getGridX(), litara.getGridY(), litara.getZ(), litara.getModel()); short[][] hull = Calculations.hull(screenCoordinates); g.draw(Calculations.toPolygon(hull));
  18. You can be my galaxy padawan.
  19. U need to loop neighbours, thats all. Idk why u need it.
  20. World's end no underscores in usernames ;(
×
×
  • Create New...