PDA

View Full Version : Spin the Wheel



DemiseScythe
03-19-2012, 02:30 AM
The Spin the Wheel widget has been glitching my merching scripts lately causing them to get stuck so I made some code to spin the wheel for us. It should remove the wheel interface if it exists or just proceed as normal. Works as FindNormalRandoms but should only be run once right after login in due to the fact that it actually moves the mouse. At this time it is set to discard all rewards, partially because I found them to be crappy most of the time but because I was unabled to grab or search the text on the reward interphase after trying out all fonts. It is still crude but it works for me, may be it can be incorporated into SRL for people to use.

function Spin: boolean;
var
x, y, i, t: Integer;
begin
MouseBox(397, 275, 414, 293, 3);
Result := WaitUpText('Play', 300);
if Result then
begin
Writeln('Squal of Fortune is Active');
GetMousePos(x, y);
Mouse(x, y, 3, 3, false);
WaitOption('Play', 300);
t := 0;
repeat
Wait(100 + Random(50));
Inc(t);
until FindColorTolerance(x, y, 2425017, 649, 300, 664, 322, 5) or (t > 15);
repeat
i := CountColor(4503538, 372, 80, 409, 112);
//Writeln(IntToStr(i));
// 119 = '2'
// 93 = '1'
case i of
119:
begin
Writeln('We have 2 attempts left');
Writeln('Spinning the Wheel');
FindColorTolerance(x, y, 2307555, 648, 355, 662, 371, 40);
Mouse(x, y, 3, 3, true);
repeat
Wait(100 + Random(50));
until FindColorTolerance(x, y, 9920813, 462, 215, 585, 268, 20);
Writeln('Discarding Loot');
Mouse(527, 258, 3, 3, true);
Wait(1500 + Random(500));
Writeln('Starting next attempt');
if FindColorTolerance(x, y, 2656589, 483, 293, 588, 315, 20) then
Mouse(x, y, 3, 3, true);
t := 0;
repeat
Wait(100 + Random(50));
Inc(t);
until FindColorTolerance(x, y, 2425017, 649, 300, 664, 322, 5) or (t > 15);
end;
93:
begin
Writeln('We have 1 attempt left');
Writeln('Spinning the Wheel');
FindColorTolerance(x, y, 2307555, 648, 355, 662, 371, 40);
Mouse(x, y, 3, 3, true);
repeat
Wait(100 + Random(50));
until FindColorTolerance(x, y, 9920813, 462, 215, 585, 268, 20);
Writeln('Discarding Loot');
Mouse(527, 258, 3, 3, true);
Wait(750 + Random(250));
Writeln('Closing Interphase');
if FindColorTolerance(x, y, 2237137, 483, 326, 588, 350, 20) then
Mouse(x, y, 3, 3, true);
Exit;
end;
end;
until (i = 0);
end;
end;

Fine, this is a revision for those who requested it, it sees if the wheel is active and it clicks the X, so that it disappears until next time you log in. Then you can spin the wheel on your own time if you so wish to and whilest logged in and the script is running, this should not get in the way.


function Spin: Boolean;
begin
MMouse(407, 282, 3, 3);
Result := WaitUpText('Play', 500);
if Result then
begin
Mouse(464, 283, 1, 1, False);
WaitOption('Select', 500);
Wait(500 + Random(250));
end;
end;


I think that is the best solution for this issue.

Sin
03-19-2012, 02:33 AM
Verrrrry nice, and here you were saying you were a burden and not an asset to SRL..

EtherFreak
03-19-2012, 02:38 AM
Implementing into my scripts as soon as I am done typing this.

Ashaman88
03-19-2012, 02:49 AM
Pretty cool! but it would still be nice to have an option to claim rewards

shstiger2009
03-19-2012, 03:24 AM
Pretty cool! but it would still be nice to have an option to claim rewards

Could easily be implemented with points + UpText.

Mushini
03-19-2012, 03:45 AM
This is awesome, and gives me ideas.
Thank you, DemiseScythe.

alexes
03-23-2012, 08:12 AM
:O Awesome, thank you so much Demi :)

Rep for you ^^

Rezozo
03-24-2012, 01:26 PM
There should be a limit to the bosslyness of someone!

putonajonny
03-25-2012, 01:14 AM
if you made sure it accounted properly when f2p players got p2p items and can't claim them and things like that then this could get in the include imo :)

Brandon
03-25-2012, 01:28 AM
Infinite loops in there..

DemiseScythe
03-25-2012, 02:13 AM
Mmh, one of the waits is a bit too short. I got a revised version, here it goes:

function Spin: Boolean;
begin
MouseBox(397, 275, 414, 293, 3);
Result := WaitUpText('Play', 300);
if Result then
begin
Writeln('Squal of Fortune is Active');
GetMousePos(x, y);
Mouse(x, y, 3, 3, False);
WaitOption('Play', 500);
T := 0;
repeat
Wait(100 + Random(50));
Inc(T);
until FindColorTolerance(x, y, 2425017, 649, 300, 664, 322, 5) or (T > 15);
repeat
case CountColor(4503538, 372, 80, 409, 112) of
119:
begin
Writeln('We have 2 attempts left');
Writeln('Spinning the Wheel');
FindColorTolerance(x, y, 2307555, 648, 355, 662, 371, 40);
Mouse(x, y, 3, 3, True);
repeat
Wait(100 + Random(50));
until FindColorTolerance(x, y, 9920813, 462, 215, 585, 268, 20);
Writeln('Discarding Loot');
Mouse(527, 258, 3, 3, True);
Wait(750 + Random(250));
Mouse(328, 279, 3, 3, True);
Wait(750 + Random(250));
Writeln('Starting next attempt');
if FindColorTolerance(x, y, 2656589, 483, 293, 588, 315, 20) then
Mouse(x, y, 3, 3, True);
T := 0;
repeat
Wait(100 + Random(50));
Inc(T);
until FindColorTolerance(x, y, 2425017, 649, 300, 664, 322, 5) or (T > 15);
end;
93:
begin
Writeln('We have 1 attempt left');
Writeln('Spinning the Wheel');
FindColorTolerance(x, y, 2307555, 648, 355, 662, 371, 40);
Mouse(x, y, 3, 3, True);
repeat
Wait(100 + Random(50));
until FindColorTolerance(x, y, 9920813, 462, 215, 585, 268, 20);
Writeln('Discarding Loot');
Mouse(527, 258, 3, 3, True);
Wait(750 + Random(250));
Mouse(328, 279, 3, 3, True);
Wait(750 + Random(250));
Writeln('Closing Interphase');
if FindColorTolerance(x, y, 2237137, 483, 326, 588, 350, 20) then
Mouse(x, y, 3, 3, True);
Exit;
end;
end;
until (CountColor(4503538, 372, 80, 409, 112) = 0) or TabExists(tab_Magic);
end;
end;

F2P is not supported, btw but this one supports the confirmation screen for rare drops, it will comfirm discarding them.

DemiseScythe
03-27-2012, 02:56 AM
Fine, this is a revision for those who requested it, it sees if the wheel is active and it clicks the X, so that it disappears until next time you log in. Then you can spin the wheel on your own time if you so wish to and whilest logged in and the script is running, this should not get in the way.


function Spin: Boolean;
begin
MMouse(407, 282, 3, 3);
Result := WaitUpText('Play', 500);
if Result then
begin
Mouse(464, 283, 1, 1, False);
WaitOption('Select', 500);
Wait(500 + Random(250));
end;
end;


I think that is the best solution for this issue. Added also to OP thread, I think this one is safe enough to be added to SRL ^.^~

Coh3n
03-27-2012, 05:27 AM
I can add this to anitban.simba. I added ExitSquealOfFortune a while ago, so it'll get rid of it on the screen, but I don't see why this can't be added.

WT-Fakawi
03-27-2012, 06:36 AM
I made a very quick and dirty tool that clicks the button the moment the middle prize highlights. I actually did "win" two middle prices with this tool, but not member on those two accounts alas o_0.

cause
03-27-2012, 06:55 AM
Fakawi do you think that clicking at the right moment actually helps your chances?? If so, awesome!

WT-Fakawi
03-27-2012, 07:07 AM
Fakawi do you think that clicking at the right moment actually helps your chances?? If so, awesome!Nah, could be luck, and I guess it is totally random, but it was worth a shot. Kinda conincidential though that two of the accounts I tested it with both hit middle slot :)

DemiseScythe
03-27-2012, 10:53 AM
Sorry, I didn't realised this was already made, apologize.

WT-Fakawi
03-27-2012, 02:11 PM
Sorry, I didn't realised this was already made, apologize.Nah, I've written just four lines of code, not at all as elaborate as you made. Just pointing in the general direction :smile:

Coh3n
04-02-2012, 03:24 AM
Right now, your function assumes the Squeal Of Fortune is always in the same spot on the screen; however, it can be anywhere, the player just has to drag and drop it. You'll need to use some kind of detection before I'm willing to add this to the include. You can check out ExitSquealOfFortune in anitban.simba. ;)