SRL Archive - Reflection Help

Health Detection


Infantry001

2009-08-17 04:20:48

I'm reviving my Monastery Terrorist, and I came across a problem.

My CheckHealth function walks to the bottom-right corner of the Monastery where Abbot Langley resides. This is where players can heal. I've set the healing to stop at 100%, but for some reason, it doesn't work.

Here's the function:
function CheckHealth : boolean;
var
HPRatio, I : integer;
begin
if not LoggedIn then exit;
HPRatio := GetMe.HPRatio;
InfDebug('Hp - ' + IntToStr(HPRatio) + '%');
if HPRatio <= HealPercent then
begin
WalkToTileEx(HealMonk, 3, 0);
Players[CurrentPlayer].Loc := 'Healing';
repeat
if (HPRatio >= 99) then break;
if I > 20 then break;
Inc(I);
if FindNPC(801,Monk) then
begin
Mouse(Monk.MS.X,Monk.MS.Y,2,2,true);
Wait(200 + Random(500));
ClickToContinue;
Wait(500 + Random(500));
FindNPCChatText('heal',ClickLeft);
repeat
Wait(500 + Random(500));
until(not ClickToContinue)
result := true;
Wait(250 + Random(250));
end;
HPRatio := GetMe.HPRatio;
InfDebug('HP healed to ' + IntToStr(HPRatio) + '%');
until(false)
ReportVars[3] := ReportVars[3] + 1;
Players[CurrentPlayer].Integers[2] := Players[CurrentPlayer].Integers[2] + 1;
Calibrate;
end;
end;

And here's the debug:
Hp - 49%
HP healed to 49%
HP healed to 49%
HP healed to 49%
HP healed to 49%
HP healed to 49%

Obviously, HPRatio is not updating, and therefore, my player heals infinitely. Can anyone spot the problem? Or is it possibly a problem with Reflection?

Lance

2009-08-17 04:36:56

im not exactly sure what break does.. (i think it just stops looping) but wouldnt an exit be better in this case than a brake?

if (HPRatio >= 99) then break;

to

if (HPRatio >= 99) then Exit;

Method

2009-08-17 04:43:39

The "hp ratio" field is only set when your health bar is up. Check your skills to have a more reliable way of getting the current hp or use R_GetMMLevels.

Lance

2009-08-17 04:47:23

ohh.. is the HpPercent function the same? ahhh so thats why ive been having those random mass eating fests :S i didnt understand why i kept getting that glich at random xD

Method

2009-08-17 04:58:19

From: lancerawks aka Lance
ohh.. is the HpPercent function the same? ahhh so thats why ive been having those random mass eating fests :S i didnt understand why i kept getting that glich at random xD


HpPercent is an SRL function, not a reflection function.

Infantry001

2009-08-17 05:00:42

From: lancerawks aka Lance
im not exactly sure what break does.. (i think it just stops looping) but wouldnt an exit be better in this case than a brake?

if (HPRatio >= 99) then break;

to

if (HPRatio >= 99) then Exit;


I need to break so I can execute the rest of the code near the end of the function ;)

From: Method
The "hp ratio" field is only set when your health bar is up. Check your skills to have a more reliable way of getting the current hp or use R_GetMMLevels.


Ah, that makes sense. Thanks, I appreciate it!

Infantry001

2009-08-17 05:59:33

Sorry for double post, but I'd rather do this than post a new thread.

Method, R_GetMMLevels('hp') returns -1… =(

mormonman

2009-08-17 06:04:04

You got developers revision of reflection?

Infantry001

2009-08-17 06:13:04

Yeah, but I don't think I've updated in a while. I'll update and see.