SRL Archive - Research & Development Lounge

function RestHPUntil(Percent: Integer): Boolean;


Rick

2009-08-18 22:07:48

The rest function restores Hitpoints at twice the normal rate. I couldn't find a rest for Hitpoint healing, so I modded the RestUntil [Run Energy] quite a bit and this is the result.

{*******************************************************************************
function RestHPUntil(Percent: Integer): Boolean;
By: r!ch!e [RestHPUntil]. Based off of ZephyrsFury [RestUntil].
Description: Rests until HP is equal to Percent. Results True if successful.
Modded RestUntil. Restores Hitpoints instead of run.
*******************************************************************************}

function RestHPUntil(Percent: Integer): Boolean;
var
s: string;
i,ii, Mark: integer;
begin
//Result := True;
if Percent > 100 then
begin
WriteLn('Invalid HP Percent');
Exit;
end;
ii:= GetSkillInfo('hp',false)
i := Round(GetMMLevels('hp', s) * 100 / ii)
if (i >= Percent) then Exit;
SetRest;
MarkTime(Mark);
while (i < Percent) do
begin
if (TimeFromMark(Mark) > 600000) then Exit;
wait(2000 + random(300));
i := Round(GetMMLevels('hp', s) * 100 / ii);
end;
case i of
Percent: Result:= True;
end;
if (not(Result)) then Exit;
Wait(100 + Random(50));
end;

This will make the player rest until the Hitpoint percentage is equal to what was defined. Useful for auto-fighters with no food left.
Please comment :)

Naum

2009-08-18 22:19:17

Are you 100% sure that 'rest' also aids healing? If it does then the two functions can simply be merged.

Rick

2009-08-18 22:29:52

I'm positive. The musicians in the game say that hitpoints heal twice as fast when resting and three times as fast when resting next to a musician.
Also from http://runescape.wikia.com/wiki/Rest
(Hitpoints will regenerate twice per minute, alternating between 20 and 40 seconds between each hitpoint gained, as opposed to the normal 1 hitpoint per minute)

Yes, I suppose they could. I'm making an auto-fighter and wanted to utilise the rest function. I hadn't seen anything like it so I made this.
I could merge it, but I want people to test it and see if any improvements can be made.

Infantry001

2009-08-19 05:43:21

Make sure you don't timeout and get logged off =)

But besides that, nice one.

senrath

2009-08-19 05:57:21

From: NaumanAkhlaQ
Are you 100% sure that 'rest' also aids healing? If it does then the two functions can simply be merged.


It would be relatively easy, too. Just add a boolean to determine whether or not the resting is for energy or HP.