n3ss3s
11-22-2007, 08:17 PM
I know YoHoJo has made this once, but I wanted to make one my way.
I hope there is none in SRL, atleast I haven't seen one.
Works, but sometimes the "hit splats" may come in the way which gives false results.
You are free to use as long as you credit me.
Enjoy ;)
Function GetHealthPoints: TPointArray;
Var
BarPoints: Array of TPointArray;
Green, Red, TPA: TPointArray;
Place, X, Y, I: Integer;
Dists: TIntegerArray;
Begin
FindColorsTolerance(Green, 65280, MSX1, MSY1, MSX2, MSY2, 0);
FindColorsTolerance(Red, 255, MSX1, MSY1, MSX2, MSY2, 0);
TPA := CombineTPA(Green, Red);
BarPoints := SplitTPAEx(TPA, 50, 15);
SetArrayLength(Dists, GetArrayLength(BarPoints));
For I := 0 To High(BarPoints) Do
Begin
MiddleTPAEx(BarPoints[i], X, Y);
Dists[i] := Distance(MSCX, MSCY, X, Y);
End;
InIntArrayEx(Dists, Place, AMin(Dists));
Result := BarPoints[Place];
End;
Function HealthPercent: Integer;
Var
Green, Red, I: Integer;
HPts: TPointArray;
Begin
HPts := GetHealthPoints;
For I := 0 To High(HPts) Do
Case GetColor(HPts[i].x, HPts[i].y) Of
255: Red := Red + 1;
65280: Green := Green + 1;
End;
Result := Round(Green / 150 * 100);
End;
I hope there is none in SRL, atleast I haven't seen one.
Works, but sometimes the "hit splats" may come in the way which gives false results.
You are free to use as long as you credit me.
Enjoy ;)
Function GetHealthPoints: TPointArray;
Var
BarPoints: Array of TPointArray;
Green, Red, TPA: TPointArray;
Place, X, Y, I: Integer;
Dists: TIntegerArray;
Begin
FindColorsTolerance(Green, 65280, MSX1, MSY1, MSX2, MSY2, 0);
FindColorsTolerance(Red, 255, MSX1, MSY1, MSX2, MSY2, 0);
TPA := CombineTPA(Green, Red);
BarPoints := SplitTPAEx(TPA, 50, 15);
SetArrayLength(Dists, GetArrayLength(BarPoints));
For I := 0 To High(BarPoints) Do
Begin
MiddleTPAEx(BarPoints[i], X, Y);
Dists[i] := Distance(MSCX, MSCY, X, Y);
End;
InIntArrayEx(Dists, Place, AMin(Dists));
Result := BarPoints[Place];
End;
Function HealthPercent: Integer;
Var
Green, Red, I: Integer;
HPts: TPointArray;
Begin
HPts := GetHealthPoints;
For I := 0 To High(HPts) Do
Case GetColor(HPts[i].x, HPts[i].y) Of
255: Red := Red + 1;
65280: Green := Green + 1;
End;
Result := Round(Green / 150 * 100);
End;