Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {$I srl/osr.simba}
- {$I srl/utils/slacktree.simba}
- type
- TMSTile = record Bottom, Top: TRectangle; end;
- TMSTiles = array of TMSTile;
- var
- BMP: TMufasaBitmap;
- function DrawCuboid(m: TMufasaBitmap; Top, Btm: TRectangle; color: Int32): Boolean;
- begin
- try m.DrawTPA(TRectangle([Top.Left, Top.Btm, Btm.Btm, Btm.Left]).ToTPA.Connect(), color); except end;
- try m.DrawTPA(TRectangle([Top.Top, Top.Right, Btm.Right, Btm.Top]).ToTPA.Connect(), color); except end;
- try m.DrawTPA(TRectangle([Top.Top, Btm.Top, Btm.Left, Top.Left]).ToTPA.Connect(), color); except end;
- try m.DrawTPA(TRectangle([Top.Right, Btm.Right, Btm.Btm, Top.Btm]).ToTPA.Connect(), color); except end;
- m.UpdateDebugImage();
- end;
- function MSToMM(MS: TPoint; Height: Int32): TPoint;
- var
- x,y,i,c: Int32;
- a: Double;
- best, pt: TPoint;
- arr: Vector3Array;
- TPA: TPointArray;
- begin
- a := Minimap.GetCompassAngle(False);
- for x:=MM2MS.MMCX-32 to MM2MS.MMCX+32 do
- for y:=MM2MS.MMCY-32 to MM2MS.MMCY+32 do
- begin
- SetLength(arr, c+1);
- arr[c] := Vector3([x,y,height]);
- arr[c] := arr[c].RotateXY(-a, MM2MS.MMCX,MM2MS.MMCY);
- Inc(c);
- end;
- TPA := Minimap.ArrToMs(Copy(arr), a);
- for i:=0 to High(TPA) do
- if Distance(TPA[i], MS) < Distance(best, MS) then
- begin
- best := TPA[i];
- Result := arr[i].ToVec2.ToPoint;
- end;
- end;
- function FindBestBrickMM(MM,MS: TPoint; Height: Int32): TPoint;
- var
- x,y: Int32;
- best,test: TPoint;
- angle: Double;
- begin
- angle := Minimap.GetCompassAngle(False);
- for x:=MM.x-2 to MM.x+2 do
- for y:=MM.y-2 to MM.y+2 do
- begin
- test := Minimap.VecToMsRect([x,y, height], angle).Partition(2,1)[0].Mean;
- if Distance(test, MS) < Distance(best, MS) then
- begin
- best := test;
- Result := [x,y];
- end;
- end;
- end;
- function FindBrickOwen(out mm: TPoint): Boolean;
- var
- B: TBox;
- TPA,TPA1,TPA2,TPA3: TPointArray;
- pipe: TPoint;
- ATPA: T2DPointArray;
- begin
- B := Mainscreen.GetBounds();
- if (srl.FindColors(TPA1, CTS2(2438740, 10, 0.11, 0.26), B) > 15) and
- (srl.FindColors(TPA2, CTS2(7895169, 15), B) > 5) and
- (srl.FindColors(TPA3, CTS2(986899, 8), B) > 2) then
- begin
- ATPA := TPA3.Cluster(4);
- ATPA.FilterSize(10, __GT__);
- TPA3 := ATPA.Merge();
- TPA := TPAOverlap(TPA2,TPA3,5);
- if Length(TPA) < 5 then Exit();
- TPA := TPAOverlap(TPA,TPA1,4);
- if Length(TPA) < 5 then Exit();
- ATPA := ClusterTPA(TPA, 6);
- SortATPAFromSize(ATPA, 0, False);
- pipe := ATPA[0].Mean();
- mm := FindBestBrickMM(MSToMM(pipe, 7), pipe, 7);
- Result := True;
- end;
- end;
- function GetFurnaceTile(out Tile: TMSTile): Boolean;
- var
- mm: TPoint;
- t: Double;
- begin
- t := PerformanceTimer;
- if FindBrickOwen(mm) then
- begin
- Tile.Bottom := Minimap.VecToMsRect([mm.x,mm.y,-1]);
- Tile.Top := Minimap.VecToMsRect([mm.x,mm.y, 7]);
- Result := True;
- end;
- WriteLn(PerformanceTimer - t);
- end;
- var
- Tile: TMSTile;
- top, btm: TRectangle;
- begin
- while True do
- begin
- BMP := GetMufasaBitmap(BitmapFromClient(GetClientBounds()));
- if GetFurnaceTile(Tile) then
- begin
- top := Tile.Top.Partition(2,1)[0];
- btm := Tile.Bottom.Partition(2,1)[0];
- DrawCuboid(BMP, top, btm, clLime);
- end;
- ShowBitmap(BMP.GetIndex());
- BMP.Free();
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement