SRL Archive - SRL Archives

FindEnt


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.

noidea

2008-12-24 11:50:56

THis is exactlly like Piv's gas checker. I was just having the same idea earlier. Nice one Cazax :)


Edit: I have just got a question about this
For I := 0 To 40 Do
For J := 0 To 40 Do
If Canv1.Pixels[I, J] <> Canv2.Pixels[I, J] Then

Why 2 for to do loops?

Cazax

2008-12-24 12:02:04

I is X and J is Y, so Canv1.Pixels[X, Y] would start searching in X as 1 first and Y to 40, it's like searching every pixel in a box.

noidea

2008-12-24 12:03:54

ooohh alright. Sorry :)

Smarter Child

2008-12-25 21:20:46

What would a tree's coordinates be, if there is a range of trees in the area?

TViYH

2008-12-25 23:05:16

Use a tree color, turn it to a TPA, split to an ATPA, use middletpa to get the middle of that tpa, then use those coordinates.

Smarter Child

2008-12-27 13:34:53

How do you split to an ATPA?
Edit: Thanks, Timer your a genius for a 12/13-year old, man i wish i had the knowledge you *have :p

Timer

2008-12-27 15:08:11

SplitTPA()
TPAtoATPA()