SRL Archive - Help and Support

GetHPMS


Dumpin

2008-01-15 14:14:07

program New;
{.include srl/srl.scar}
var
xx, yy, Coord1, Coord2, Bs : integer;
HP : string;
HPnumber : Tstringarray;

Function GetHPMS(Typeit: boolean): boolean;
begin
For Bs := 0 To (GetArrayLength(HPnumber)-1) Do
begin
if IsTextInAreaEx(727, 29, 739, 38, xx, yy, HpNumber[Bs], 12, statchars, False, False, 0, 1, 65280)then
begin
Coord1 := xx;
Coord2 := yy;
Hp:= GetTextAtEx(Coord1, Coord2, 0, statchars, False, False, 0, 1, 65280, 10, false, tr_AlphaNumericChars);
end;
end;
end;

begin
SetupSRL;
ClearDebug;
Wait(3000);
GetHPMS(true);
writeln(HP);
end.

it doesn't work for some reason.. when i run it it just writes an emty line in the debug… does anyone know why it can't find the text?

ooh and it looks for the HP percent on the mainscreen

n3ss3s

2008-01-15 14:27:46

a) Or, just use GetTextAtEx since the new update makes it possible
b)

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;

c) If you find string S at coords X and Y, the text you get at X and Y is S.

R0b0t1

2008-01-15 22:35:39

Rofl, when I saw the title I though:


function GetAIDS: Boolean;
begin
GoTo Vegas;
Sex;
Sex;
Sex;
Gambling;
ReturnHome;
VisitDoctor; //contrary to popular belief, what happens in vegas doesn't stay in vegas!
KnowYouHaveAids;
end;


But since I'm not allowed to spam anymore, I have to come up with something witty to say…. Hmmm, wrong character set, Dr. Watson?

Dumpin

2008-01-16 03:23:45

might be :P it actually stands for: Get Health Points - MainScreen

n3ss3s

2008-01-16 05:32:13

But can you answer my question, if I am correct, if there is a text at X and Y, the X and Y resulted as the IsTextInAreaEx, when you do GetTextAtEx, you return the text you were looking for :p

Also, how is text involved in this any way, ignoring that you can do GetTextAtEx on the health thing right of the mm?


EDIT: I ain't finished:
 For Bs := 0 To (GetArrayLength(HPnumber)-1) Do
begin

What did I see there? Well, the length of the array HPNumber hasn't even been declared anywhere, so, that is For Bs := 0 To -1 Do in other words :)

EDIT EDIT: I still ain't finished - Variable Result is not being used, maybe also return a string instead of a boolean - result '' would be the same as False.

Thank you.