SRL Archive - SRL-OSR Snippets

Minimap orbs


Flight

2014-01-16 07:47:59

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.

Solar

2014-01-16 07:56:28

Great work, and fast too.

Turpinator

2014-01-16 09:19:30

at first i wasnt sure what you were talking about but then…

well, no more need for orion.

Nice job. :)

Solar

2014-01-16 12:09:40

I'm sure you already know this Flight, but there is an option to turn the orbs off so it's back to how it looked before the update.

Turpinator

2014-01-16 12:11:01

From: Solar
I'm sure you already know this Flight, but there is an option to turn the orbs off so it's back to how it looked before the update.


but meow we can easily and quickly get praypoints, hp and run energy without the need of reflection!

Sk1nyNerd

2014-01-16 15:23:23

From: Turpinator
but meow we can easily and quickly get praypoints, hp and run energy without the need of reflection!

hp wont be such a hassle now!

Flight

2014-01-16 19:46:45

From: Solar
I'm sure you already know this Flight, but there is an option to turn the orbs off so it's back to how it looked before the update.


Yeah I'll need to go ahead and add that toggle in the settings GameTab. Let me finish my cappuccino first.

Edit:
Updated the OP with 3 new functions.

Hoodz

2014-01-17 11:24:42

@Flight if you are going to push this, add a fixed version of SetRun(); too because its broken right now (if you want that ofcourse)

fixed version: only had to change the box

function SetRun(Run: Boolean): Boolean;
var
CCount: Integer;
begin
Result := False;
if (GameTab(tab_Options)) then
begin
CCount := CountColorTolerance(2369440, 647, 413, 682, 448, 20);
if (Run) then
begin
if (CCount<1) then
MouseBox(647, 413, 682, 448, mouse_left);
Result := True;
end else
begin
if (CCount>1) then
MouseBox(647, 413, 682, 448, mouse_left);
Result := True;
end;
end;
end;

SetOrbs:

function SetOrbs(State: Boolean): Boolean;
var
CCount: Integer;
begin
Result := False;
if (GameTab(tab_Options)) then
begin
CCount := CountColorTolerance(2369440, 603, 413, 639, 450, 20);
if (State) then
begin
if (CCount<2) then
MouseBox(603, 413, 639, 450, mouse_left);
Result := True;
end else
begin
if (CCount>2) then
MouseBox(603, 413, 639, 450, mouse_left);
Result := True;
end;
end;
end;

Ashaman88

2014-02-05 01:02:42

Put these in the OSR include - great job guys

https://github.com/SRL/SRL-OSR/commit/148007bac4ad63ae7527c7a91b7d2b27ded3a007

Hoodz

2014-02-05 02:13:27

From: Ashaman88
Put these in the OSR include - great job guys

https://github.com/SRL/SRL-OSR/commit/148007bac4ad63ae7527c7a91b7d2b27ded3a007


Thanks ashaman!

Hoodz

2014-02-06 10:39:06

@Ashaman88; is this alright? (http://services.runescape.com/m=news/quick-prayers--loot-broadcast?oldschool=1)


{returns if you are using quick pray}
Function isUsingQuickPray(): Boolean;
begin
result := CountColorTolerance(10709096, 544, 91, 570, 114, 5) > 1;
end;

{toggles the quick pray icon}
procedure setQuickPray(Pray: Boolean);
begin
if (Pray) then
begin
if (not isUsingQuickPray) then
MouseBox(521, 99, 568, 113, Mouse_Left);
end else
begin
if (isUsingQuickPray) then
MouseBox(521, 99, 568, 113, Mouse_Left);
end;
end;


{toggles the run orb}
procedure setRunOrb(Run: Boolean);
begin
if (Run) then
begin
if (not isUsingRun) then
MouseBox(545, 135, 591, 149, Mouse_Left);
end else
begin
if (isUsingRun) then
MouseBox(545, 135, 591, 149, Mouse_Left);
end;
end;

Flight

2014-02-06 10:53:37

You got me by about 10 minutes. Also, following the normal SRL-OSR format it's better to have these as functions rather than procedures.

I've updated the OP with 3 new functions.

Edit:
Hoodz I suggest you always compile and test your additions before posting them, I see a few mistakes.

Hoodz

2014-02-06 10:57:46

From: Flight
You got me by about 10 minutes. Also, following the normal SRL-OSR format it's better to have these as functions rather than procedures.

I've updated the OP with 3 new functions.

Edit:
Hoodz I suggest you always compile and test your additions before posting them, I see a few mistakes.


yes i edited me post, just noticed it. or is it still wrong?

Ashaman88

2014-02-06 11:19:31

I'll check out those three tonight, good job guys - keep it up

Flight

2014-02-06 20:20:56

From: hoodz
yes i edited me post, just noticed it. or is it still wrong?


Looks good to me. Does SRL-OSR already have a 'isUsingRun' function?

Hoodz

2014-02-07 06:55:51

From: Flight
Looks good to me. Does SRL-OSR already have a 'isUsingRun' function?


yes look at your first post, its already in the srl-osr include on github

Flight

2014-02-07 21:08:57

From: hoodz
yes look at your first post, its already in the srl-osr include on github


Ah very good then, my mistake. :tongue:

Solar

2014-03-07 16:53:29

Sorry if this is a bit of a gravedig (not that old), but did these all get replaced in the official OSR include? If they are then I need to update.

Flight

2014-03-07 20:20:15

From: Solar
Sorry if this is a bit of a gravedig (not that old), but did these all get replaced in the official OSR include? If they are then I need to update.


Yes it is, but for some reason someone put it in "mapwalk.simba"; that's the wrong place… Also whoever committed this didn't document nor give credit. :thumbsdown:

Solar

2014-03-08 08:11:07

Right, so went and updated via github and found that at least SetRun wasn't updated, nor was SetRunOrb added.

Also, what is the purpose of toggleDataOrbs and SetOrbs? The names sound like they might be for the same thing.

Flight

2014-03-08 09:20:13

From: Solar
Right, so went and updated via github and found that at least SetRun wasn't updated, nor was SetRunOrb added.

Also, what is the purpose of toggleDataOrbs and SetOrbs? The names sound like they might be for the same thing.


Beats me. Whoever added them apparently added it twice but as different names.