Advertisement
WarPie90

Untitled

Mar 25th, 2017
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.76 KB | None | 0 0
  1. program new;
  2. {$h-}
  3. {$I SRL/OSR.simba}
  4.  
  5. {$R-}
  6. function TRSInventory.GetItemPoints(idx:Int32): TPointArray;
  7. var
  8.   cl: Integer;
  9.   queue: TPointArray;
  10.   muf: TMufasaBitmap;
  11.   face: TPointArray;
  12.   B: TBox;
  13.   procedure GetAdjacent(var adj:TPointArray; n:TPoint);
  14.   begin
  15.     adj[0] := Point(n.x,n.y+1);
  16.     adj[1] := Point(n.x+1,n.y);
  17.     adj[2] := Point(n.x,n.y-1);
  18.     adj[3] := Point(n.x-1,n.y);
  19.   end;
  20.  
  21.   function FF(start:TPoint): TIntegerArray;
  22.   var c,wid,hei,j,x,y:Int32;
  23.   begin
  24.     wid := muf.GetWidth();
  25.     hei := muf.GetHeight();
  26.     SetLength(face, 4);
  27.     queue += start;
  28.     while Length(queue) > 0 do
  29.     begin
  30.       GetAdjacent(face, queue.Pop());
  31.       for j:=0 to 3 do
  32.       begin
  33.         x := face[j].x;
  34.         y := face[j].y;
  35.         if (x >= 0) and (y >= 0) and (x < wid) and (y < hei) then
  36.           if (muf.GetPixel(x,y) <> $010000) then
  37.           begin
  38.             c := muf.GetPixel(x,y);
  39.             if Result.Find(c) = -1 then Result += c;
  40.             muf.SetPixel(x,y, $010000);
  41.             queue += face[j];
  42.           end;
  43.       end;
  44.     end;
  45.   end;
  46.  
  47. begin
  48.   B := Inventory.GetSlotBox(idx);
  49.   muf := GetMufasaBitmap(BitmapFromClient(B));
  50.   for cl in FF(Point(0,0)) do
  51.   begin
  52.     FindColorsTolerance(queue, cl, B, 0); //worst case, some tolerance is needed.
  53.     Result += queue;
  54.   end;
  55.   Result := ReturnPointsNotInTPA(Result, B);
  56.   muf.Free();
  57. end;
  58.  
  59. var
  60.   BMP, i: Integer;
  61.   TPA:TPointArray;
  62. begin
  63.   bmp := LoadBitmap('C:/Simba/Scripts/Harrier/Screen2.png');
  64.   SetTargetBitmap(bmp);
  65.  
  66.   for i:=0 to Inventory.HighSlot do
  67.   begin
  68.     TPA := Inventory.GetItemPoints(i);
  69.     DrawTPABitmap(BMP, TPA, Random($FFFFFF));
  70.   end;
  71.  
  72.   GetMufasaBitmap(bmp).Debug();
  73.   try
  74.     FreeBitmap(bmp);
  75.   except
  76.   end;
  77. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement