Guest User

Untitled

a guest
Apr 20th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. program New;
  2. {$DEFINE RS2}
  3.  
  4. {$I OSI\OSI.scar}
  5. {$I OSI\Divi\Misc\Debug.scar}
  6.  
  7. function AreaToBoxArray(const AreaX1, AreaY1, AreaX2, AreaY2, Width, Height: Integer): TBoxArray;
  8. var
  9. AreaW, AreaH: Integer;
  10. BoxX, BoxY: Integer;
  11. x, y, i: Integer;
  12. begin
  13. // Calculate the area dimensions
  14. AreaW := AreaX2 - AreaX1 + 1;
  15. AreaH := AreaY2 - AreaY1 + 1;
  16.  
  17. // Calculate the number of boxes in each dimension
  18. BoxX := AreaW div Width;
  19. if AreaW mod Width <> 0 then Inc(BoxX);
  20. BoxY := AreaH div Height;
  21. if AreaH mod Height <> 0 then Inc(BoxY);
  22.  
  23. // Set the number of boxes
  24. SetLength(Result, BoxX * BoxY);
  25.  
  26. // Calculate the boxes
  27. i := 0;
  28. for y := 0 to BoxY - 1 do
  29. for x := 0 to BoxX - 1 do
  30. begin
  31. Result[i] := Box(AreaX1 + x * Width,
  32. AreaY1 + y * Height,
  33. Min(AreaX2, AreaX1 + (x + 1) * Width - 1),
  34. Min(AreaY2, AreaY1 + (y + 1) * Height - 1));
  35. Inc(i);
  36. end;
  37. end;
  38.  
  39.  
  40.  
  41. function MMToMSEx(MM :TPoint; Height :Extended) :TPoint;
  42. Var
  43. X, Y :Extended;
  44. begin
  45. X := (((MM.X - MMCXE) * 9.81119354838709677419354838709677) + 258.531);
  46. Y := (((MM.Y - MMCYE) * 8.84193548387096774193548387096777) + 175.341);
  47. Result := Point(Round(X), Round(Y - Height));
  48. end;
  49.  
  50.  
  51. function MMToMSH(MM :TPoint) :TPoint;
  52. begin
  53. Result := MMToMSEx(MM, 14.5);
  54. end;
  55.  
  56.  
  57.  
  58. function GetDot :TPointArray;
  59. var
  60. TPA :TPointArray;
  61. begin
  62. FindColorsSpiralTolerance(MMCX, MMCY, TPA, 61937, MMX1, MMY1, MMX2, MMY2, 0);
  63. Result:= TPA;
  64. //Writeln(IntToStr(Result.X) + ', ' + IntToStr(Result.Y));
  65. end;
  66.  
  67.  
  68.  
  69. procedure DeleteTBA(var TBA: TBoxArray; const Index: Integer);
  70. var
  71. i, l: Integer;
  72. begin
  73. l := Length(TBA);
  74. if l = 0 then Exit;
  75. for i := Index to l - 2 do
  76. TBA[i] := TBA[i + 1];
  77. SetLength(TBA, l - 1);
  78. end;
  79.  
  80.  
  81.  
  82. procedure Test;
  83. Var
  84. TBAEx, TBA: TBoxArray;
  85. TPA :TPointArray;
  86. L, LL, Del, i :Integer;
  87. TP :TPoint;
  88. begin
  89. TPA:= GetDot; // Get NPC Dot;
  90. TBA := AreaToBoxArray(MSX1, MSY1, MSX2, MSY2, 50, 50); // Creates Arrays W 50 H 50
  91. L := Length(TBA) - 1; // L = Length TBA - 1
  92.  
  93. for I:= 0 to L do // IMPORTANT. Now it will try loop TBA
  94. begin
  95. try
  96. If PointInBox(MMToMSH(TPA[i]), TBA[i]) then begin // It can't loop for more than NPC's are found
  97. Writeln(Inttostr(i)); //
  98. DeleteTBA(TBA, i);
  99. end;
  100. except end;
  101. end;
  102. DebugTBA(TBA);
  103. end;
  104.  
  105.  
  106.  
  107. begin
  108. SetupOSI;
  109. Test;
  110. end.
Add Comment
Please, Sign In to add comment