SRL Archive - SRL Archives

RestUntil Broken


Runescapian321

2009-08-16 18:38:29

It doesn't work because GetMMLevels('run', S) always returns -1 when Resting.

Here it is (Not a fix, I would try making a fix but I fail with color :p):

{*******************************************************************************
function RestUntil(Energy: Integer): Boolean;
By: ZephyrsFury
Description: Rests until your Run energy is above Energy. Results True if
successful.
*******************************************************************************}

function RestUntil(Energy: Integer): Boolean;
var
S: string;
begin
Result := (GetMMLevels('run', S) >= Energy);
if (Result) then exit;
SetRest;
while (GetMMLevels('run', S) < Energy) do
begin
Result := (CountColor(3777879, 713, 107, 732, 115) > 10);
if (CountColor(3777879, 713, 107, 732, 115) < 11) then exit;
if (SRL_Procs[srl_AntiBan] <> nil) then
SRL_Procs[srl_AntiBan]();
Wait(100 + Random(50));
end;
end;

Sabzi

2009-08-16 19:57:21

In theory this should work:
http://www.villavu.com/forum/showthread.php?t=48934

I just changed one number and it works for me XD(It gets the right energy but I did not try RestUntil).

I just read your post more carefully. So while it resting it returns -1? That's not what I got. So it won't work but I can't delete my post?

Runescapian321

2009-08-16 20:13:26

From: Sabzi
In theory this should work:
http://www.villavu.com/forum/showthread.php?t=48934

I just changed one number and it works for me XD(It gets the right energy but I did not try RestUntil).

I just read your post more carefully. So while it resting it returns -1? That's not what I got. So it won't work but I can't delete my post?


So it doesn't return -1 for you while resting? :confused:

R_GetMMLevels does the same for me.

Sabzi

2009-08-16 20:21:53

From: Tad
So it doesn't return -1 for you while resting? :confused:

R_GetMMLevels does the same for me.


Yeah I wanted do delete that post because it's confusing and doesn't solve anything. I did not use RestUntil because it's broken. I got a custom resting function but GetMMLevels returned 0 when we got 100 energy. So that's what I get and not the -1 while resting. Because I don't even use the number while resting. Just the color. But it returns -1 to me too while resting, sometimes just the last digit. I tested it now with full armour lots of weight in my inventory XD
The stupid glowing messes it up.

EDIT: I was trying very hard in the past hours(or just one) but I failed totally in fixing GetMMLevels. But I want to share my ideas maybe someone can do something with theme. Or it just gives other ideas. So this is what I was trying:
program New;
{.include SRL/SRL.scar}

var
c: string;

function IsResting: Boolean;

begin
Result := (GetColor(728, 114) = 1919769);
end;

function GetMMLevelss(LevelType: string; var ColorSign: string): Integer;
var
Colors : TIntegerArray;
Signs: TStringArray;
P: TPointArray;
TP: TPoint;
I: Integer;
B: TBox;
T, x, y: Integer;
Run: Boolean;
begin;
Result := -1;
ColorSign := '';
case LowerCase(Leveltype) of
'health', 'hp', 'hitpoints': TP := Point(729,29);
'prayer', 'pray' : TP := Point(746,68);
'run','energy' :
begin
TP := Point(740,107);
Run := True;
end;
else
begin;
srl_Warn('GetMMLevels', 'Invalid LevelType: ''' + LevelType + '', warn_AllVersions);
Exit;
end;
end;
Colors := [65280, 65535, 2070783, 255];
Signs := ['Green', 'Yellow', 'Orange', 'Red'];
for I := 0 to 3 do
begin
FindColors(P, Colors[i], TP.X - 5, TP.Y - 5, TP.X + 40, TP.Y + 20);
if (Length(P) < 1) then continue;
B := GetTPABounds(P);
MarkTime(T);
if Run then
begin
repeat
begin
if not IsResting then Break;
if not FindColorComp(x, y, clYellow, ccBlue, 736, 107, 746, 108, 120) then Break;
end;
until (TimeFromMark(T) >= 5000);
end;
Result := StrToIntDef(GetNumbers(GetTextAtEx(B.X1 - 1 , B.Y1 - 1, 0, statChars,
False, False, 0, 0, Colors[I], 20, False, tr_Digits)), -1);
if (Result > 0) then
begin
ColorSign := Signs[i];
Exit;
end;
end;
end;

begin
SetupSRL;
repeat
begin
while not IsFKEyDown(12) do Wait(200);
WriteLn(IntToStr(GetMMLevelss('run', c)));
Wait(300);
end;
until False;
end.

My idea is to wait until that yellow glowing is around and get the numbers when it's not around.

IsResting is working.
And the function FindColorComp(x, y, clYellow, ccBlue, 736, 107, 746, 108, 120) is working itself too. It returns False when the glowing thing is at it's minimal state. But still after that, GetMMLevels returns 0 or -1 or the last digit of the energy(that's the best case :().
I really hope that this helps somebody because I did not want to post this fail try first :redface:.

Sabzi

2009-08-20 20:43:06

Okay I have an idea for this.
http://runescape.wikia.com/wiki/Rest
So we know we regenerate 2.8 energy/sec while resting with 1 agility. So before starting to rest we get our energy level, calculate how much to wait, wait and then exit.
But I don't know how to calculate with higher agility. That's the problem with this. Damn, I really fail with this.

ZephyrsFury

2009-08-21 13:50:36

Its probably due to the flashing rest button covering the percentage.

Sabzi

2009-08-21 13:54:36

From: ZephyrsFury
Its probably due to the flashing rest button covering the percentage.


Yeah my first attempt was checking the energy when the glow is at it's minimum state. It checks at the best-time-to-check but still fails.

ZephyrsFury

2009-08-21 14:00:50

I tried making RestUntil only wait 150 ms between each check but that still fails apparently. So perhaps make it check even closer together. Then if its 100% make the function wait a bit more for randomness.

Sabzi

2009-09-14 20:45:14

I got a (flawless?) fix for this:

function IsResting: Boolean;

begin
Result := (GetColor(728, 114) = 1919769);
end;

function GetMMLevelss(LevelType: string; var ColorSign: string): Integer;
var
Colors : TIntegerArray;
Signs: TStringArray;
P: TPointArray;
TP: TPoint;
I: Integer;
B: TBox;
T, x, y: Integer;
Run: Boolean;
begin;
Result := -1;
ColorSign := '';
case LowerCase(Leveltype) of
'health', 'hp', 'hitpoints': TP := Point(729,29);
'prayer', 'pray' : TP := Point(746,68);
'run','energy' :
begin
TP := Point(740,107);
Run := True;
end;
else
begin;
srl_Warn('GetMMLevels', 'Invalid LevelType: ''' + LevelType + '', warn_AllVersions);
Exit;
end;
end;
Colors := [65280, 65535, 2070783, 255];
Signs := ['Green', 'Yellow', 'Orange', 'Red'];
for I := 0 to 3 do
begin
if Run then
begin
MarkTime(T);
repeat
begin
if not IsResting then Break;
if not FindColorComp(x, y, clYellow, ccBlue, 737, 107, 742, 108, 130) then Break;
end;
until (TimeFromMark(T) >= 5000);
end;
FindColorsTolerance(P, Colors[i], TP.X - 5, TP.Y - 5, TP.X + 40, TP.Y + 20, 30);
if (Length(P) < 1) then continue;
B := GetTPABounds(P);
Result := StrToIntDef(GetNumbers(GetTextAtEx(B.X1 - 1 , B.Y1 - 1, 30, statChars,
False, False, 0, 0, Colors[i], 20, False, tr_Digits)), -1);
if (Result > 0) then
begin
ColorSign := Signs[i];
Exit;
end;
end;
end;

Using this will tell you your energy after waiting a bit for the glowing to disappear. So RestUntil should be fine with this.
Can somebody try this?