SRL Archive - SRL Archives

Reward Box Solver


Nava2

2009-02-26 23:19:57

I wrote some reward box functions:

It now looks for specific text, and will click that option. It will scroll through the scroll bar, if it doesn't find the item you want. It will pick the mystery box! :)

var
SRL_RewardOption: String;

// Finds the option using TPA Text, returns the corresponding box.
function _FindOption(var Box: TBox): Boolean;

var
x, y, I, H: Integer;
Text, TPA, xTPA: TPointArray;
ATPA: T2DPointArray;
Scroll: Boolean;

begin
Scroll := FindTextTPA(2070783, 3, Msx1, msy1, msx2, msy2, 'croll', StatChars, Nothing);
Text := LoadTextTPA(SRL_RewardOption, UpChars, H);
FindColorsTolerance(TPA, 2070783, 35, 69, 362, 311, 3);
Result := FindTextTPAInTPA(H, Text, TPA, xTPA);

if (not Result) and Scroll then
begin
x := RandomRange(371, 384);
y := RandomRange(304, 317);

MMouse(x, y, 0, 0);
Wait(RandomRange(30, 60));

HoldMouse(x, y, True);
while (not FindColorTolerance(x, y, 657930, 374, 295, 380, 302, 3)) and (not Result) do
begin
if not LoggedIn then Exit;
Wait(RandomRange(40, 50));
FindColorsTolerance(TPA, 2070783, 35, 69, 362, 311, 3);
Result := FindTextTPAInTPA(H, Text, TPA, xTPA);
end;
ReleaseMouse(x, y, True);
end;

if not Result then
begin
Text := LoadTextTPA('box', UpChars, H);
Result := FindTextTPAInTPA(H, Text, TPA, xTPA);
end;

if not Result then Exit;

FindColorsTolerance(TPA, 2634297, 35, 69, 362, 311, 3);
ATPA := TPAToATPAEx(TPA, 147 + Integer( Scroll) * 2, 62 + Integer( Scroll) * 2);
SortATPAFrom(ATPA, xTPA[0]);
Result := True;
Box := GetTPABounds(ATPA[0]);
end;

// Waits until the Reward Screen Appears.
function _WaitForRewardScreen: Boolean;

var
Text, TPA: TPointArray;
Height, Time: Integer;

begin
Result := False;
Text := LoadTextTPA('hoose', UpChars, Height);
Time := GetTimeRunning + 2000;
FindColorsTolerance(TPA, 2070783, 185, 34, 327, 50, 3);
while not Result and (GetTimeRunning < Time) do
begin
Wait(RandomRange(80, 100));
FindColorsTolerance(TPA, 2070783, 185, 34, 327, 50, 3);
if Length(TPA) > 10 then
Result := FindTextTPAinTPA(Height, Text, TPA, TPA);
end;
end;

// Finds the box in the inventory using a TPA
function _FindRewardBox(var fx, fy: Integer): Boolean;

var
I, Tol: Integer;
B: TBox;
TPA: TPointArray;

begin
Result := False;
if not LoggedIn then
begin
fx := 0;
fy := 0;
Exit;
end;
GameTab(4);
Tol := GetColorToleranceSpeed;
try
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 0.11);
for I := 1 to 28 do
begin
B := InvBox(I);
if FindColorsTolerance(TPA, 5574780, b.x1, b.y1, b.x2, b.y2, 13) then
Result := High(TPA) >= 250;
if Result then
begin
MiddleTPAEx(TPA, fx, fy);
Exit;
end;
end;
fx := 0;
fy := 0;
finally
ColorToleranceSpeed(Tol);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
end;

// Opens the Box at fx, fy. Gets the reward presented by the global var.
function _UseRewardBox(fx, fy: Integer): Boolean;

var
Time: Integer;
TPA: TPointArray;
B: TBox;

begin
Result := False;
if (fx = 0) or (fy = 0) then Exit;

MMouse(fx, fy, 5, 5);
Wait(RandomRange(80, 100));
if IsUpText('event gift') then
begin
GetMousePos(fx, fy);
Mouse(fx, fy, 0, 0, True);
if not _WaitForRewardScreen then
begin
SRL_Warn('OpenRewardBox', 'Could not open Reward Screen', Warn_AllVersions);
Exit;
end;
Wait(Random(100));
if not _FindOption(B) then
begin
SRL_Warn('UseRewardBox', 'Could not find a usable option.', Warn_AllVersions);
Exit;
end;
MouseBox(B.x1, B.y1, B.x2, B.y2, 1);
Time := GetTimeRunning + 500;
while (not Result) and (GetTimeRunning < Time) do
begin
FindColorsTolerance(TPA, 1317148, B.x1, B.y1, B.x2, B.y2, 3);
Result := Length(TPA) > 50;
end;
if not Result then
begin
CloseWindow;
Exit;
end;
Mouse(393, 166, 77, 39, True);
end;
end;

Use:
var
SRL_RewardOption: String;

SRL_RewardOption := 'XP';

//... Somewhere in SetupSRL ...
if SRL_RewardOption = '' then SRL_RewardOption := 'ystery box';
//...

if _FindRewardBox(fx, fy) then
_UseRewardBox(fx, fy);

Please test this..

Comments tell how it works, I want some feeeeeedback! :)

Capricorn

2009-02-27 02:45:29

If you got the boxes from frog tokens then yeah your prizes suck. But I have seen stuff like 2 grimmy kwuarms being offered which is much much more then 700 odd coins. I have also seen 40 pure ess and the such. I was thinking maybe a system could get all the item names and the amount and find which is the best profit.

Iroki

2009-02-27 05:08:05

http://www.youtube.com/watch?v=OdNu20xqM5Y&feature=related

Baked0420

2009-02-27 05:47:02

wow I didn't know there could be that many options but apparently Nava2 didn't either. So I guess he'll have to update his solver. Nava2, watch that video then see if you can adjust your solver, in the video the person had like 10 choices, there was a scroll bar for when there's more then 6. I forget hwo many they exactly had but it was quite a few.

Smarter Child

2009-02-27 10:10:06

You made those solvers..alone??

Nava2

2009-02-27 20:06:52

Big update, uses Text now.

I need an account with a scroll bar. :)

Help me help you ;)

mormonman

2009-02-28 00:13:59

… i have pics of scroll bar…
1
2
3

ian.

2009-02-28 00:23:46

I'd suggest doing this..
(not gonna do exact coding cuz I'm lazy and watching Talladega Nights xD)

_UseRewardBox(var x, y: integer; item: string);
begin
if(FindItem('sandwhich'))then
Mouse(x, y, 2, 2, true);
end else
if(FindDTM(DownArrowDTM))then
HoldMouse(params?);
Wait(TimeBeforeNextLayer);
ReleaseMouse(params?);
....

hopefully that makes sense.. and then look for the item, then GetColor of scroll bar at the bottom, and if it's not the scroll bar color, go down again, and yeah.. :)

mormonman

2009-02-28 00:28:16

umm… 99 why would you want the sandwich, i personally would like either the exp or the gp… that would be what i would make it choose everytime… if no exp then choose the gp

ian.

2009-02-28 00:44:22

I used sandwich because I was just looking at a sandwich solver :p

Nava2

2009-02-28 06:35:20

Those pics should be enough. :)

I will work on it tomorrow I think.

Capricorn

2009-02-28 12:22:02

From: mormonman
umm… 99 why would you want the sandwich, i personally would like either the exp or the gp… that would be what i would make it choose everytime… if no exp then choose the gp


Why would you ever want the GP is beyond me. The chaos runes, pure essence, coal, mithril ore and sapphires all make you more money. (I would personally pick the EXP every time however)

Nava2

2009-02-28 15:10:23

From: Capricorn
Why would you ever want the GP is beyond me. The chaos runes, pure essence, coal, mithril ore and sapphires all make you more money. (I would personally pick the EXP every time however)


There isn't always xp.

Uhm, using the GE to get the price of certain things would be EXTREMELY slow, and not really worth it.

Naum

2009-02-28 15:51:04

No it wouldn't it only takes 400msec to get the price of something, then multiplying it by the quantity.

Good Job, I made a crappier one a few days ago ;)

Nava2

2009-02-28 21:14:11

That is a lot… :(

Naum

2009-03-02 02:43:24

A human takes around about 1 - 2 seconds to respond and click, he won't do it in 400 msec, unless he isn't thinking.
You have how many, 4 items, 4 * 400msec, just 1.6 seconds. Quite a short bit of time but it would be worth it.

Nava2

2009-03-02 08:07:50

Oh, also. On that note, SRL doesn't use any functions which connect to the RuneScape website.

The idea is nice, but it can also take a few seconds depending on the connection speed, as well, if you wanted it. Just write your own for your scripts.

If it is allowed, I can reverse engineer my bank valuer to use it! :)

noidea

2009-03-02 08:35:23

But isnt the valuer reflection?

Nava2

2009-03-02 15:55:42

From: noidea
But isnt the valuer reflection?


It is, but the price getter is in just scar language.

Here is the functions which get the prices.. :)

function GetMarketValue(var T: TBS) : string;

var
Name : string;
I : Integer;

begin
if (T.Name = 'Members object') and (CheckMembersObjects = True) then
begin
Result := GetPage('http://itemdb-rs.runescape.com/viewitem.ws?obj=' + IntToStr(T.ID));
Delete(Result, 1, 15130);
Name := Copy(Result, 1, PosEx(#10, Result, 2) - 1);
if Pos('not found', Name) = 0 then
T.Name := Name
else
T.Name := '-= ??? =-';
Delete(Result, 1, 270);
Delete(Result, 1, Pos('Mark', Result) + 17);
Delete(Result, Pos('</', Result) - 1, Length(Result));
if Length(Result) > 20 then
begin
Result := '';
Exit;
end;
end else
begin
Name := Replace(T.Name, ' ', '_');
for I := 0 to 2 do
if Pos('_' + IntToStr(100 - 25 * I), Name) <> 0 then
begin
Delete(Name, Pos('_' + IntToStr(100 - 25 * I), Name), Length(Name));
Break;
end;
Result := GetPage('http://rscript.org/lookup.php?type=ge&search=' + Name);
if InIntArray([53, 73], Length(Result)) or ((Pos(IntToStr(T.ID), Result) = 0) and (Pos(IntToStr(T.ID - 1), Result) = 0)) then
begin
Result := '';
Exit;
end;
Result :=Between(Name + ' ', ' ', Result);
end;
Result := Replace(Result, ',', '');
end;

Capricorn

2009-03-03 05:00:40

You could create a database, have it make a .ini. And everytime you start a script setupSRL can take 10-15 seconds at the start of the script to update its prices in the .ini file and only if its been longer then say 24 hours. How many items can these boxes give? Essences, runes and ores, some bars. I believe this idea can go somewhere.

Nava2

2009-03-03 14:55:59

It can, but it wouldn't go into SRL. There was a rule set into place that NOTHING can connect to the RuneScape website.

Edit: Added scroll bar functionality.

Just needs to be tested now ;)

Capricorn

2009-03-03 19:14:19

Oh well, you could always put it on the site - I am sure lots would find it useful for it to pick the most valued option.

Quickmarch

2009-03-04 10:06:28

I don't see the point of this, you could just drop the box…

Anyway, nice solver. :)

Wizzup?

2009-03-04 10:19:43

From: Quickmarch
I don't see the point of this, you could just drop the box…

Anyway, nice solver. :)


That would be a waste, and rather un-human. :)

Nava2

2009-03-04 22:48:53

From: Wizzup?
That would be a waste, and rather un-human. :)


Omg. He posted.

*faps*

Anyways…

lordsaturn

2009-03-08 03:52:09

Works great :)

Set the reward option as xp, and it didn't find it, so it chose the cash.

Punkgi

2009-03-26 00:10:51

how do i use this?