- Index: src/org/rsbot/event/impl/DrawNPCs.java
- ===================================================================
- --- src/org/rsbot/event/impl/DrawNPCs.java (revision 56)
- +++ src/org/rsbot/event/impl/DrawNPCs.java (working copy)
- @@ -31,7 +31,7 @@
- continue;
- }
- final RSNPC npc = new RSNPC(ctx, ((RSNPCNode) node).getRSNPC());
- - final Point location = npc.getScreenLocation();
- + final Point location = npc.getModel().getCenterPoint();
- if (!ctx.calc.pointOnScreen(location)) {
- continue;
- }
- Index: src/org/rsbot/event/impl/DrawPlayers.java
- ===================================================================
- --- src/org/rsbot/event/impl/DrawPlayers.java (revision 56)
- +++ src/org/rsbot/event/impl/DrawPlayers.java (working copy)
- @@ -30,7 +30,7 @@
- continue;
- }
- final RSPlayer player = new RSPlayer(ctx, element);
- - final Point location = player.getScreenLocation();
- + final Point location = player.getModel().getCenterPoint();
- if (!ctx.calc.pointOnScreen(location)) {
- continue;
- }
- Index: src/org/rsbot/script/wrappers/RSModel.java
- ===================================================================
- --- src/org/rsbot/script/wrappers/RSModel.java (revision 56)
- +++ src/org/rsbot/script/wrappers/RSModel.java (working copy)
- @@ -2,6 +2,7 @@
- import java.awt.Point;
- import java.awt.Polygon;
- +import java.lang.Math;
- import java.util.Arrays;
- import java.util.LinkedList;
- @@ -60,6 +61,34 @@
- }
- /**
- + * Returns a point based on the sum of all the triangles (Medium)
- + *
- + * @return The medium (Presumed center, at least a fixed point) of the RSModel
- + * */
- +
- + public Point getCenterPoint() {
- + float x = 0;
- + float y = 0; //float because float is to int as double is to long
- + Polygon[] polygons = getTriangles();
- + for (Polygon p : polygons) {
- + float tmp_x = 0;
- + float tmp_y = 0;
- + for (int i : p.xpoints) {
- + tmp_x += i;
- + }
- + for (int i : p.ypoints) {
- + tmp_y += i;
- + }
- + x += tmp_x / p.npoints;
- + y += tmp_y / p.npoints;
- + }
- + x = x / polygons.length;
- + y = y / polygons.length;
- + //finally
- + return new Point(Math.round(x), Math.round(y));
- + }
- +
- + /**
- * Returns an array of triangles containing
- * the screen points of this model.
- *