Metagen
2008-04-14 19:04:51
finds hp bars on MS. Returns how many there are, and the midpoints in a TPA. returns false if none found.
little bug i'm working out: it can take up to 7 seconds on my pc to run, but it doesn't lag your screen.
little bug i'm working out: it can take up to 7 seconds on my pc to run, but it doesn't lag your screen.
function FindHPBarsTPA(var Count : Integer; Var Position : TPointArray) : boolean;
var PointsTPA, FinalTPA : TPointArray;
TPAA : T2DPointArray;
i, j, color : integer;
begin
setlength(PointsTPA, 0);
setlength(FinalTPA, 0);
for i := msx1 to msx2 do
begin
for j := msy1 to msy2 do
begin
Color := getcolor(i, j)
if (Color = 255) or (Color = 65280) then
begin
SetLength(PointsTPA, Length(PointsTPA) + 1);
PointsTPA[Length(PointsTPA)-1] := IntToPoint(i,j);
end;
end;
end;
TPAA := TPAtoATPAEx(PointsTPA, 30, 5);
for i := 0 to Length(TPAA) -1 do
begin
if Length(TPAA[i]) = 150 then
begin
SetLength(FinalTPA, Length(FinalTPA) + 1);
FinalTPA[Length(FinalTPA) - 1 ] := MiddleTPA(TPAA[i]);
end;
end;
Count := length(FinalTPA);
Position := FinalTPA;
if count = 0 then
begin
Result := false
exit;
end;
Result := true;
end;