Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 26th, 2012  |  syntax: None  |  size: 2.42 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Index: src/org/rsbot/event/impl/DrawNPCs.java
  2. ===================================================================
  3. --- src/org/rsbot/event/impl/DrawNPCs.java      (revision 56)
  4. +++ src/org/rsbot/event/impl/DrawNPCs.java      (working copy)
  5. @@ -31,7 +31,7 @@
  6.                  continue;
  7.              }
  8.              final RSNPC npc = new RSNPC(ctx, ((RSNPCNode) node).getRSNPC());
  9. -            final Point location = npc.getScreenLocation();
  10. +            final Point location = npc.getModel().getCenterPoint();
  11.              if (!ctx.calc.pointOnScreen(location)) {
  12.                  continue;
  13.              }
  14. Index: src/org/rsbot/event/impl/DrawPlayers.java
  15. ===================================================================
  16. --- src/org/rsbot/event/impl/DrawPlayers.java   (revision 56)
  17. +++ src/org/rsbot/event/impl/DrawPlayers.java   (working copy)
  18. @@ -30,7 +30,7 @@
  19.                  continue;
  20.              }
  21.              final RSPlayer player = new RSPlayer(ctx, element);
  22. -            final Point location = player.getScreenLocation();
  23. +            final Point location = player.getModel().getCenterPoint();
  24.              if (!ctx.calc.pointOnScreen(location)) {
  25.                  continue;
  26.              }
  27. Index: src/org/rsbot/script/wrappers/RSModel.java
  28. ===================================================================
  29. --- src/org/rsbot/script/wrappers/RSModel.java  (revision 56)
  30. +++ src/org/rsbot/script/wrappers/RSModel.java  (working copy)
  31. @@ -2,6 +2,7 @@
  32.  
  33.  import java.awt.Point;
  34.  import java.awt.Polygon;
  35. +import java.lang.Math;
  36.  import java.util.Arrays;
  37.  import java.util.LinkedList;
  38.  
  39. @@ -60,6 +61,34 @@
  40.         }
  41.        
  42.         /**
  43. +        * Returns a point based on the sum of all the triangles (Medium)
  44. +        *
  45. +        * @return The medium (Presumed center, at least a fixed point) of the RSModel
  46. +        * */
  47. +      
  48. +       public Point getCenterPoint() {
  49. +               float x = 0;
  50. +               float y = 0; //float because float is to int as double is to long
  51. +               Polygon[] polygons = getTriangles();
  52. +               for (Polygon p : polygons) {
  53. +                       float tmp_x = 0;
  54. +                       float tmp_y = 0;
  55. +                       for (int i : p.xpoints) {
  56. +                               tmp_x += i;
  57. +                       }
  58. +                       for (int i : p.ypoints) {
  59. +                               tmp_y += i;
  60. +                       }
  61. +                       x += tmp_x / p.npoints;
  62. +                       y += tmp_y / p.npoints;
  63. +               }
  64. +               x = x / polygons.length;
  65. +               y = y / polygons.length;
  66. +               //finally
  67. +               return new Point(Math.round(x), Math.round(y));
  68. +       }
  69. +      
  70. +       /**
  71.          * Returns an array of triangles containing
  72.          * the screen points of this model.
  73.          *