SCAR Code:
{*******************************************************************************
procedure UseRewardBox: Boolean;
by: Nava2, Timer
Description: Finds the reward box, and opens it getting the reward.
*******************************************************************************}
function UseRewardBox: Boolean;
var
I, Time, Height, fx, fy, Index, bDTM: Integer;
Text, TPA: TPointArray;
B: TBox;
begin
Result := False;
if (not LoggedIn) then exit;
GameTab(tab_Inv);
if (not(FindColorTolerance(fX, fY, 5510016, MIX1, MIY1, MIX2, MIY2, 20))) then Exit;
{ DTM updated 10th Januray 2010 - marpis }
bDTM := DTMFromString('78DA63CC61626078C68002DA452219FE03694' +
'620FE0F048C9940355719D00013986484F2187388509300E4DF23' +
'A0A69C083520F77C20C2AED704D45400F96FF1AB0100750B108B');
for I := 1 to 28 do
begin
B := InvBox(I);
if FindItemEx(fx, fy, 'dtm', bDTM, B, []) then
begin
InvMouse(I, 3);
Wait(RandomRange(100, 150));
Result := IsUpText('ando');
if (Result) then Break;
end;
end;
FreeDTM(bDTM);
if (not Result) then exit;
GetMousePos(fx, fy);
Mouse(fx, fy, 0, 0, True);
Result := False;
Text := LoadTextTPA('hoose', UpChars, Height);
Time := GetTimeRunning + 10000;
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;
if (not Result) then
begin
SRL_Warn('OpenRewardBox', 'Could not open Reward Screen', Warn_AllVersions);
Exit;
end;
Wait(Random(100));
if (not FindBoxOption(B, Index)) then
begin
SRL_Warn('UseRewardBox', 'Could not find a usable option.', Warn_AllVersions);
Exit;
end;
Mouse(B.X1, B.Y1, 0, 0, True);
Time := GetTimeRunning + 2000;
Result := False;
while (not Result) and (GetTimeRunning < Time) do
begin
FindColorsTolerance(TPA, 1317148, 35, 70, 362, 311, 3);
Result := Length(TPA) > 50;
Wait(50 + Random(50));
end;
if (not Result) then
begin
CloseWindow;
Exit;
end;
MouseBox(413, 171, 469, 200, 1);
Time := GetSystemTime;
while (CountColorTolerance(1317148, B.x1 - 10, B.y1 - 10, B.x1 + 10, B.y1 + 10, 3) > 50) and (GetSystemTime - Time < 5000) do
begin
if (Pos('thing else', GetChatBoxText(8, clBlack)) > 0) then
begin
CloseWindow;
Wait(500 + Random(500));
SetLength(RB_SkipArray, Length(RB_SkipArray) + 1);
RB_SkipArray[High(RB_SkipArray)] := Index;
Result := UseRewardBox;
Break;
end;
Wait(100 + Random(200));
end;
RB_SkipArray := [];
if (CloseWindow) then
Result := False;
end;