Cazax
2008-12-24 11:37:24
Function FindEnt(X, Y : Integer): Boolean;
Var
tempBmp, Bmp2, I, J, C : Integer;
Canv1, Canv2 : TCanvas;
Begin
tempBmp := BitmapFromString(40, 40, '');
Bmp2 := BitmapFromString(40, 40, '');
CopyClientToBitmap(tempBmp, X - 20, Y - 20, X + 20, Y + 20);
Wait(500);
CopyClientToBitmap(Bmp2, X - 20, Y - 20, X + 20, Y + 20);
Canv1 := GetBitmapCanvas(tempBmp);
Canv2 := GetBitmapCanvas(Bmp2);
For I := 0 To 40 Do
For J := 0 To 40 Do
If Canv1.Pixels[I, J] <> Canv2.Pixels[I, J] Then
Inc(C);
Writeln(IntToStr(Round((C / 1600) * 100)) + '% of different pixels');
If Round((C / 1600) * 100) >= 35 Then
Result := True;
FreeBitmap(tempBmp);
FreeBitmap(Bmp2);
If Result Then
EntsAvoided := EntsAvoided + 1;
End;X and Y are the tree's coordinates.If you are using a TPA function to find the tree then make sure you use MiddleTPA to get the middle of tree.
The function checks if the tree is shaking with canvas check. I have tested the function with real Ents, and it has worked all the time.