Flight
01-16-2014, 12:47 PM
Sorry this took so long. I wrote these within an hour of the game update but for AeroLib so I needed to convert these back to normal SRL-OSR.
function getCurrentHealth(): Integer;
var
tpa : TPointArray;
begin
tpa := returnTPAExceptColors([4938344, 0], [20, 0], intToBox(522,56,541,69));
result := strToIntDef(getTextATPA(clusterTPAEx(tpa,1,10), 5, 'StatChars07'), 0);
end;
function getPrayerPoints(): Integer;
var
tpa : TPointArray;
begin
tpa := returnTPAExceptColors([4938344, 0], [20, 0], intToBox(522,100,541,112));
result := strToIntDef(getTextATPA(clusterTPAEx(tpa,1,10), 5, 'StatChars07'), 0);
end;
function getRunEnergy(): Integer;
var
tpa : TPointArray;
begin
tpa := returnTPAExceptColors([4938344, 0], [20, 0], intToBox(546,136,566,148));
result := strToIntDef(getTextATPA(clusterTPAEx(tpa,1,10), 5, 'StatChars07'), 0);
end;
function isUsingRun(): Boolean;
var
tpa : TPointArray;
begin
result := findColorsPie(TPA, 6806252, 20, 0, 360, 10, 72, 571, 127, 595, 152, 582, 140);
end;
function isPoisoned(): Boolean;
var
tpa : TPointArray;
begin
result := findColorsPie(TPA, 88587, 30, 0, 360, 10, 72, 544, 46, 567, 69, 582, 140);
end;
If you'd like you could merge those first 3 and use a switcher just for the box areas to search for text, similar to the old "MMLevels" functions we had in SRL-5.
Edit:
Added 3 more functions: getHealthPercent, getPrayerPercent and toggleDataOrbs. The first two are not 100% accurate because of the shape of the orb. Those of you who know how these two functions work will also know why they cannot be 100% accurate. But they'll be very close indeed. The third function just toggles the "data orbs" on the minimap.
function getHealthPercent(): Integer;
var
tpa : TPointArray;
begin
Result := 100;
findColorsPie(tpa, 1184274, 13, 0, 360, 0, 15, 541, 44, 571, 72, 556, 58);
if length(tpa) < 1 then Exit;
sortTPAByY(tpa, False);
result := (((70-tpa[0].y)*4)-2);
if result < 0 then result := 0;
end;
function getPrayerPercent(): Integer;
var
l : Integer;
tpa : TPointArray;
begin
Result := 100;
findColorsPie(TPA, 1184274, 13, 0, 360, 0, 15, 541, 88, 571, 115, 556, 102);
l := (length(tpa)-10);
if l < 0 then l := 0;
result := round((100-(l/316)*100));
end;
function toggleDataOrbs(Enable: Boolean): Boolean;
begin
Result := False;
if not loggedin() then
Exit;
if (not gameTab(TAB_OPTIONS)) then
Exit;
if Enable then
begin
if (countColorTolerance(1777019, 602, 413, 637, 449, 15) > 50) then
begin
Result := True;
Exit;
end else
begin
mouseBox(602, 413, 637, 449, MOUSE_LEFT);
Result := True;
Exit;
end;
end else if not Enable then
if (countColorTolerance(1777019, 602, 413, 637, 449, 15) > 50) then
begin
mouseBox(602, 413, 637, 449, MOUSE_LEFT);
Result := True;
end;
end;
Edit 2: I improved the accuracy of getHealthPercent() by using a different method. It should be at least 95% accurate now.
(*
SetRun
~~~~~~
.. code-block:: pascal
function setRun(Enable: Boolean): Boolean;
Sets running on or off.
.. note::
by Flight
Example:
.. code-block:: pascal
*)
function setRun(Enable: Boolean): Boolean;
var
x,y : Integer;
begin
Result := False;
if not loggedin() then
Exit;
if Enable then
begin
if findColorTolerance(x, y, 28552, 571, 127, 595, 152, 20) then
begin
result := true;
exit;
end else
begin
mouseBox(545, 130, 590, 150, MOUSE_LEFT);
result := true;
exit;
end;
end else if not Enable then
if findColorTolerance(x, y, 28552, 571, 127, 595, 152, 20) then
begin
mouseBox(545, 130, 590, 150, MOUSE_LEFT);
Result := True;
end;
end;
(*
isUsingQP
~~~~~~
.. code-block:: pascal
function isUsingQP(): Boolean;
Results if we're currently using quick-prayers
.. note::
by Flight
Example:
.. code-block:: pascal
*)
function isUsingQP(): Boolean;
begin
result := (countColorTolerance(14610138, 544, 90, 568, 114, 20) < 30);
end;
(*
toggleQP
~~~~~~
.. code-block:: pascal
function toggleQP(Enable: Boolean): Boolean;
Toggles quick-prayers on or off.
.. note::
by Flight
Example:
.. code-block:: pascal
*)
function toggleQP(Enable: Boolean): Boolean;
var
x,y : Integer;
begin
Result := False;
if not loggedin() then
Exit;
if Enable then
begin
if isUsingQP() then
begin
result := true;
exit;
end else
begin
mouseBox(522, 96, 565, 113, MOUSE_LEFT);
result := true;
exit;
end;
end else if not Enable then
if isUsingQP() then
begin
mouseBox(522, 96, 565, 113, MOUSE_LEFT);
Result := True;
end;
end;
Edit 3: Added run-enabling & quick-prayers enabling.
function getCurrentHealth(): Integer;
var
tpa : TPointArray;
begin
tpa := returnTPAExceptColors([4938344, 0], [20, 0], intToBox(522,56,541,69));
result := strToIntDef(getTextATPA(clusterTPAEx(tpa,1,10), 5, 'StatChars07'), 0);
end;
function getPrayerPoints(): Integer;
var
tpa : TPointArray;
begin
tpa := returnTPAExceptColors([4938344, 0], [20, 0], intToBox(522,100,541,112));
result := strToIntDef(getTextATPA(clusterTPAEx(tpa,1,10), 5, 'StatChars07'), 0);
end;
function getRunEnergy(): Integer;
var
tpa : TPointArray;
begin
tpa := returnTPAExceptColors([4938344, 0], [20, 0], intToBox(546,136,566,148));
result := strToIntDef(getTextATPA(clusterTPAEx(tpa,1,10), 5, 'StatChars07'), 0);
end;
function isUsingRun(): Boolean;
var
tpa : TPointArray;
begin
result := findColorsPie(TPA, 6806252, 20, 0, 360, 10, 72, 571, 127, 595, 152, 582, 140);
end;
function isPoisoned(): Boolean;
var
tpa : TPointArray;
begin
result := findColorsPie(TPA, 88587, 30, 0, 360, 10, 72, 544, 46, 567, 69, 582, 140);
end;
If you'd like you could merge those first 3 and use a switcher just for the box areas to search for text, similar to the old "MMLevels" functions we had in SRL-5.
Edit:
Added 3 more functions: getHealthPercent, getPrayerPercent and toggleDataOrbs. The first two are not 100% accurate because of the shape of the orb. Those of you who know how these two functions work will also know why they cannot be 100% accurate. But they'll be very close indeed. The third function just toggles the "data orbs" on the minimap.
function getHealthPercent(): Integer;
var
tpa : TPointArray;
begin
Result := 100;
findColorsPie(tpa, 1184274, 13, 0, 360, 0, 15, 541, 44, 571, 72, 556, 58);
if length(tpa) < 1 then Exit;
sortTPAByY(tpa, False);
result := (((70-tpa[0].y)*4)-2);
if result < 0 then result := 0;
end;
function getPrayerPercent(): Integer;
var
l : Integer;
tpa : TPointArray;
begin
Result := 100;
findColorsPie(TPA, 1184274, 13, 0, 360, 0, 15, 541, 88, 571, 115, 556, 102);
l := (length(tpa)-10);
if l < 0 then l := 0;
result := round((100-(l/316)*100));
end;
function toggleDataOrbs(Enable: Boolean): Boolean;
begin
Result := False;
if not loggedin() then
Exit;
if (not gameTab(TAB_OPTIONS)) then
Exit;
if Enable then
begin
if (countColorTolerance(1777019, 602, 413, 637, 449, 15) > 50) then
begin
Result := True;
Exit;
end else
begin
mouseBox(602, 413, 637, 449, MOUSE_LEFT);
Result := True;
Exit;
end;
end else if not Enable then
if (countColorTolerance(1777019, 602, 413, 637, 449, 15) > 50) then
begin
mouseBox(602, 413, 637, 449, MOUSE_LEFT);
Result := True;
end;
end;
Edit 2: I improved the accuracy of getHealthPercent() by using a different method. It should be at least 95% accurate now.
(*
SetRun
~~~~~~
.. code-block:: pascal
function setRun(Enable: Boolean): Boolean;
Sets running on or off.
.. note::
by Flight
Example:
.. code-block:: pascal
*)
function setRun(Enable: Boolean): Boolean;
var
x,y : Integer;
begin
Result := False;
if not loggedin() then
Exit;
if Enable then
begin
if findColorTolerance(x, y, 28552, 571, 127, 595, 152, 20) then
begin
result := true;
exit;
end else
begin
mouseBox(545, 130, 590, 150, MOUSE_LEFT);
result := true;
exit;
end;
end else if not Enable then
if findColorTolerance(x, y, 28552, 571, 127, 595, 152, 20) then
begin
mouseBox(545, 130, 590, 150, MOUSE_LEFT);
Result := True;
end;
end;
(*
isUsingQP
~~~~~~
.. code-block:: pascal
function isUsingQP(): Boolean;
Results if we're currently using quick-prayers
.. note::
by Flight
Example:
.. code-block:: pascal
*)
function isUsingQP(): Boolean;
begin
result := (countColorTolerance(14610138, 544, 90, 568, 114, 20) < 30);
end;
(*
toggleQP
~~~~~~
.. code-block:: pascal
function toggleQP(Enable: Boolean): Boolean;
Toggles quick-prayers on or off.
.. note::
by Flight
Example:
.. code-block:: pascal
*)
function toggleQP(Enable: Boolean): Boolean;
var
x,y : Integer;
begin
Result := False;
if not loggedin() then
Exit;
if Enable then
begin
if isUsingQP() then
begin
result := true;
exit;
end else
begin
mouseBox(522, 96, 565, 113, MOUSE_LEFT);
result := true;
exit;
end;
end else if not Enable then
if isUsingQP() then
begin
mouseBox(522, 96, 565, 113, MOUSE_LEFT);
Result := True;
end;
end;
Edit 3: Added run-enabling & quick-prayers enabling.