Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$I SRL/OSR.simba}
- function FindColorsEx(const colors:TIntegerArray; B:TBox): TPointArray;
- var
- TPA:TPointArray;
- i:Int32;
- begin
- for i:=0 to High(colors) do
- begin
- FindColors(TPA,colors[i], B.x1,B.y1,B.x2,B.y2);
- Result := CombineTPA(TPA,Result);
- end;
- end;
- function __FixHPBars(var bars:T2DIntArray; TPA:TPointArray): TPointArray;
- var i:Int32;
- begin
- FilterPointsBox(TPA,1,0,high(bars[0]),high(bars));
- SortTPAByX(TPA,True);
- for i:=0 to High(TPA) do
- if (Bars[TPA[i].y][TPA[i].x-1] <> 0) then
- Bars[TPA[i].y][TPA[i].x] := 255;
- end;
- procedure __FindHPBars(var bars:T2DIntArray; var Result:TBoxArray);
- const
- W = 29;
- H = 4;
- var
- wid,hei,y,x,yy:Int32;
- bad:Boolean;
- begin
- wid := Length(bars[0])-W-1;
- hei := Length(bars)-5;
- for y:=1 to hei do
- for x:=1 to wid do
- if (bars[y][x] <> 0) and (bars[y][x+w] <> 0) then
- bars[y][x] := 254;
- for y:=1 to hei do
- for x:=1 to wid do
- if (bars[y][x] = 254) and ((bars[y][x-1] = 0) or (bars[y][x+1] = 255)) then
- begin
- bad := False;
- for yy:=max(y-h,0) to y do
- if bars[yy][x] = $00FF00 then
- begin
- bad := True;
- break;
- end;
- if not bad then
- begin
- bars[y][x] := $00FF00;
- Result += TBox([x,y,x+W,y+H]);
- end;
- end;
- end;
- function FindHPBars(area:TBox): TBoxArray;
- var
- i,j:Int32;
- TPA,splats:TPointArray;
- mat:T2DIntArray;
- B:TBox;
- begin
- freeze();
- TPA := FindColorsEx([$00FF00,$0000FF], area);
- splats := FindColorsEx([16728128,11339523,5571843,
- 192,197503,65889,
- $FFFFFF,0], area);
- unfreeze();
- B := GetTPABounds(TPA);
- OffsetTPA(splats, Point(-B.x1+1,-B.y1+1));
- SetLength(mat, B.height()+2, B.width()+2);
- for i:=0 to High(TPA) do
- mat[(TPA[i].y-B.y1)+1][(TPA[i].x-B.x1)+1] := 255;
- __FixHPBars(mat, splats);
- __FindHPBars(mat, result);
- for i:=High(Result) downto 0 do
- begin
- if (mat[Result[i].y1,Result[i].x1] = 0) or
- (mat[Result[i].y1,Result[i].x2] = 0) or
- (mat[Result[i].y2,Result[i].x2] = 0) or
- (mat[Result[i].y2,Result[i].x1] = 0) then
- Result.Del(i)
- else
- Result[i].Offset([B.x1-1,B.y1-1]);
- end;
- end;
- var
- BMP:Integer;
- TBA:TBoxArray;
- i:Int32;
- begin
- while True do
- begin
- TBA := FindHPBars(IntToBox(0,0,515,335));
- BMP := BitmapFromClient(IntToBox(0,0,515,335));
- for i:=0 to High(TBA) do
- DrawTPABitmap(BMP, EdgeFromBox(TBA[i]), $00FFFF);
- ShowBitmap(bmp);
- FreeBitmap(bmp);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement