NCDS
2010-03-12 00:14:44
Me and IceFire got together on the IRC and put this together, as requested by Mr. Doctor(Junkj).
Basically what it does is; it searches for both the red and green parts of the HPbar and makes sure it's yours with a distance check.
I tested it a few times and it worked awesome. If you have a problem with it though be sure to let me know.
Basically what it does is; it searches for both the red and green parts of the HPbar and makes sure it's yours with a distance check.
I tested it a few times and it worked awesome. If you have a problem with it though be sure to let me know.
{*******************************************************************************
Function InFight: Boolean;
By: NCDS & IceFire908
Description: Result's true if HP bar is found above characters head.
*******************************************************************************}
function InFight: Boolean;
var
CPointArr: array [0..1] of TPointArray;
TColorInfo: TVariantArray;
MDAr: T2DPointArray;
I, CTS: Integer;
HPbar: TPoint;
begin { Green | Red }
TColorInfo := [0.81, 0.00, 52608, 3, 0.19, 0.45, 465114, 4];
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
for I := 0 to 1 do
begin
SetColorSpeed2Modifiers(TColorInfo[I * 4], TColorInfo[(I * 4) + 1]);
FindColorsSpiralTolerance(MSCx, MSCy, CPointArr[I], TColorInfo[(I * 4) + 2],
MSCx - 100, MSCy - 75, MSCx + 100, MSCy + 75, TColorInfo[(I * 4) + 3]);
if (I = 0) then
if (Length(CPointArr[0]) < 4) then
Break;
end;
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(cts);
if (I = 0) then
Exit;
CPointArr[0] := CombineTPA(CPointArr[0], CPointArr[1]);
MDAr := TPAToATPAEx(CPointArr[0], 55, 7);
if Length(MDAr) < 1 then
Exit;
SortATPAFromFirstPoint(MDAr, Point(MSCx, MSCy));
if Length(MDAr[0]) < 30 then
Exit;
HPbar := MiddleTPA(MDAr[0]);
Result := (Distance(HPbar.x, HPbar.y, MSCx, MSCy) <= 70);
end;