Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program New;
- {$DEFINE RS2}
- {$I OSI\OSI.scar}
- {$I OSI\Divi\Misc\Debug.scar}
- function AreaToBoxArray(const AreaX1, AreaY1, AreaX2, AreaY2, Width, Height: Integer): TBoxArray;
- var
- AreaW, AreaH: Integer;
- BoxX, BoxY: Integer;
- x, y, i: Integer;
- begin
- // Calculate the area dimensions
- AreaW := AreaX2 - AreaX1 + 1;
- AreaH := AreaY2 - AreaY1 + 1;
- // Calculate the number of boxes in each dimension
- BoxX := AreaW div Width;
- if AreaW mod Width <> 0 then Inc(BoxX);
- BoxY := AreaH div Height;
- if AreaH mod Height <> 0 then Inc(BoxY);
- // Set the number of boxes
- SetLength(Result, BoxX * BoxY);
- // Calculate the boxes
- i := 0;
- for y := 0 to BoxY - 1 do
- for x := 0 to BoxX - 1 do
- begin
- Result[i] := Box(AreaX1 + x * Width,
- AreaY1 + y * Height,
- Min(AreaX2, AreaX1 + (x + 1) * Width - 1),
- Min(AreaY2, AreaY1 + (y + 1) * Height - 1));
- Inc(i);
- end;
- end;
- function MMToMSEx(MM :TPoint; Height :Extended) :TPoint;
- Var
- X, Y :Extended;
- begin
- X := (((MM.X - MMCXE) * 9.81119354838709677419354838709677) + 258.531);
- Y := (((MM.Y - MMCYE) * 8.84193548387096774193548387096777) + 175.341);
- Result := Point(Round(X), Round(Y - Height));
- end;
- function MMToMSH(MM :TPoint) :TPoint;
- begin
- Result := MMToMSEx(MM, 14.5);
- end;
- function GetDot :TPointArray;
- var
- TPA :TPointArray;
- begin
- FindColorsSpiralTolerance(MMCX, MMCY, TPA, 61937, MMX1, MMY1, MMX2, MMY2, 0);
- Result:= TPA;
- //Writeln(IntToStr(Result.X) + ', ' + IntToStr(Result.Y));
- end;
- procedure DeleteTBA(var TBA: TBoxArray; const Index: Integer);
- var
- i, l: Integer;
- begin
- l := Length(TBA);
- if l = 0 then Exit;
- for i := Index to l - 2 do
- TBA[i] := TBA[i + 1];
- SetLength(TBA, l - 1);
- end;
- procedure Test;
- Var
- TBAEx, TBA: TBoxArray;
- TPA :TPointArray;
- L, LL, Del, i :Integer;
- TP :TPoint;
- begin
- TPA:= GetDot; // Get NPC Dot;
- TBA := AreaToBoxArray(MSX1, MSY1, MSX2, MSY2, 50, 50); // Creates Arrays W 50 H 50
- L := Length(TBA) - 1; // L = Length TBA - 1
- for I:= 0 to L do // IMPORTANT. Now it will try loop TBA
- begin
- try
- If PointInBox(MMToMSH(TPA[i]), TBA[i]) then begin // It can't loop for more than NPC's are found
- Writeln(Inttostr(i)); //
- DeleteTBA(TBA, i);
- end;
- except end;
- end;
- DebugTBA(TBA);
- end;
- begin
- SetupOSI;
- Test;
- end.
Add Comment
Please, Sign In to add comment