silentwolf
2010-01-29 09:40:03
InFight seems to be broken. Anyone else having trouble?
2010-01-29 09:40:03
2010-01-29 10:28:41
type
THPBar = Record
X1, Y1, X2, Y2: Integer;
HPPercent: Integer;
End;
THPBarArray = Array of THPBar;
Function GetAllHPBars: THPBarArray;
Var
I, Hi: Integer;
TPA, G, R: TPointArray;
ATPA: T2DPointArray;
tmp_HP: Extended;
B: TBox;
Begin
If (Not LoggedIn) Then Exit;
FindColors(G, 10496, MSX1, MSY1, MSX2, MSY2);
FindColors(R, 198716, MSX1, MSY1, MSX2, MSY2);
TPA := CombineTPA(G, R);
ATPA := TPAtoATPAEx(TPA, 55, 8);
SortATPAFrom(ATPA, Point(262, 146));
Hi := High(ATPA);
SetLength(Result, Hi + 1);
For I := 0 To Hi Do
Begin
B := GetTPABounds(ATPA[I]);
With Result[I] Do
Begin
X1 := B.X1;
Y1 := B.Y1;
X2 := B.X2;
Y2 := B.Y2;
//WriteLn('X1, Y1 = '+IntToStr(X1)+', '+IntToStr(Y1));
FindColors(G, 10496, X1 - 3, Y1, X2, Y1);
FindColors(R, 198716, X1 - 3, Y1, X2, Y1);
Try
tmp_HP := Length(G) / (Length(G) + Length(R));
Except
tmp_HP := -0.01;
End;
//WriteLn(FloatToStr(tmp_HP));
HPPercent := Round(tmp_HP * 100);
End;
End;
End;
Function InFight(X, Y, MaxDist: Integer): Boolean;
Var
I, H, bX, bY: Integer;
Bars: THPBarArray;
Begin
If (Not LoggedIn) Then Exit;
Bars := GetAllHPBars;
H := High(Bars);
For I := 0 To H Do
Begin
bX := (Bars[I].X1 + Bars[I].X2) shr 1;
bY := (Bars[I].Y1 + Bars[I].Y2) shr 1;
If (Distance(bX, bY, X, Y) <= MaxDist) Then
Begin
Result := True;
Exit;
End;
End;
End;
Function IamFighting: Boolean;
Var
X, Y: Integer;
Bars: THPBarArray;
Begin
If (Not LoggedIn) Then Exit;
Bars := GetAllHPBars;
Result := Length(Bars) > 1;
If Not Result Then Exit;
X := (Bars[0].X1 + Bars[0].X2) shr 1;
Y := (Bars[0].Y1 + Bars[0].Y2) shr 1;
Result := (Distance(X, Y, 262, 146) <= 35) And (Bars[1].HPPercent <> 0);
//WriteLn('Bars='+IntToStr(Length(Bars))+', Bar[0]='+IntToStr(Bars[0].HPPercent)+', Bar[1]='+IntToStr(Bars[1].HPPercent));
End;