SCAR Code:
program Ash;
{.include SRL/SRL.scar}
{.include SRL/SRL/Misc/amount.scar}
var
i: integer;
procedure declarePlayers;
begin
HowManyPlayers := 1; //number of players to use
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0; //player# to start with
Players[0].Name := ''; //username
Players[0].Pass := ''; //password
Players[0].Nick := ''; //nick
Players[0].Active := True;
end;
procedure setupScript;
begin
setupSRL;
declarePlayers;
end;
{*******************************************************************************
procedure BuyCoords(x, y, amount: Integer);
By: RSN
Description: Buys the specified amout of the Item at x, y
*******************************************************************************}
procedure BuyCoords(x, y, Amount: Integer); // By RSN
var
ix, iy: Integer;
ToBuy: array[1..3] of Integer;
Done: array[1..3] of Integer;
begin
ix := x;
iy := y;
ToBuy[1] := Amount div 10;
ToBuy[2] := (Amount mod 10) div 5;
ToBuy[3] := (Amount mod 10) mod 5;
while (done[1] < tobuy[1]) do
begin
Mouse(ix, iy, 3, 3, False);
Wait(450);
if (ClickOption('Buy 10', 1)) then
Done[1] := done[1] + 1
else
Exit;
Wait(300);
end;
while (done[2] < tobuy[2]) do
begin
Mouse(ix, iy, 3, 3, False);
Wait(450);
if (ClickOption('Buy 5', 1)) then
Done[2] := done[2] + 1
else
Exit;
Wait(300);
end;
while (done[3] < tobuy[3]) do
begin
Mouse(ix, iy, 3, 3, False);
Wait(450);
if (ClickOption('Buy 1', 1)) then
Done[3] := done[3] + 1
else
Exit;
Wait(300);
end;
end;
{*******************************************************************************
procedure BuyAmount(i, amount: Integer);
By: RSN
Description: Buys the specified amount of the Item at assigned row and column
*******************************************************************************}
procedure BuyAmount(i, Amount: Integer);
var
ix, iy, row, col: Integer;
begin
row := i div 8;
col := i - (row * 8) - 1;
if (col < 0) then
begin
col := 7;
row := row - 1;
end;
ix := 88 + (col * 47) + Random(7);
iy := 76 + (row * 47) + Random(7);
BuyCoords(ix, iy, Amount);
end;
procedure inactive(reason: string);
begin
Writeln(reason);
Logout;
nextPlayer(False);
end;
function walkBetweenSymbols(symbols: array of string): Boolean;
var
i: integer;
x, y: integer;
tx, ty: integer;
begin
result := True;
for i := 0 to length(symbols) - 1 do
begin
if(not (findSymbolIn(x, y, symbols[i], 570, 11, 716, 163))) then
begin
Result := False;
Exit;
end;
tx := tx + x;
ty := ty + y;
end;
x := tx / length(symbols);
y := ty / length(symbols);
mouse(x, y, 2, 2, True);
wait(100 + random(100));
fFlag(5);
wait(500 + random(1000));
end;
procedure walkToDockColor;
var
j, k: integer;
x, y: integer;
Points: array of tPoint;
begin
for j := 0 to 30 do
begin
wait(10);
findColorsTolerance(Points, 2702170, MSX1, MSY1, MSX2, MSY2, j);
for k := 0 to length(Points) - 1 do
begin
wait(10);
x := Points[k].x;
y := Points[k].y;
if(findColoredAreaTolerance(x, y, 2702170, x - 5, y - 5, x + 5, y + 5, 15, 0)) then
begin
mouse(x, y, 2, 2, True);
wait(100 + random(100));
fFlag(5);
wait(500 + random(1000));
Exit;
end;
end;
end;
end;
procedure walkToDock;
var
i: integer;
tempBool: Boolean;
begin
for i := 0 to 3 do
begin
tempBool := False;
if(walkBetweenSymbols(['transportation'])) then
begin
Exit;
end;
if(walkBetweenSymbols(['store', 'anvil', 'archery shop'])) then
begin
tempBool := True;
Break;
end;
if(walkBetweenSymbols(['anvil', 'archery shop'])) then
begin
tempBool := True;
Break;
end;
if(walkBetweenSymbols(['anvil', 'magic shop'])) then
begin
tempBool := True;
break;
end;
walkBetweenSymbols(['magic shop', 'archery shop']);
end;
if(not tempBool) then
inactive('Could not find symbols');
for i := 0 to 3 do
begin
tempBool := False;
if(walkBetweenSymbols(['transportation'])) then
begin
tempBool := True;
Exit;
end;
walkToDockColor;
end;
if(not tempBool) then
inactive('could not find dock!');
end;
procedure removePointsByDistance(arr: tPointArray; dist: integer);
var
a, b, k: integer;
tempTPA: tPointArray;
TPA: tPointArray;
tempBool: Boolean;
begin
setArrayLength(tempTPA, 0);
for a := 0 to length(arr) - 1 do
begin
tempBool := False;
for b := 0 to length(arr) - 1 do
begin
if(a = b) then
Continue;
if(distance(arr[a].x, arr[a].y, arr[b].x, arr[b].y) <= 10) then
begin
tempBool := True;
Break;
end;
end;
if(not tempBool) then
begin
setArrayLength(tempTPA, length(tempTPA) + 1);
tempTPA[Length(TempTPA) - 1] := arr[a];
end
setArrayLength(TPA, 0);
for k := 0 to length(arr)-1 do
begin
if((arr[k].x = arr[a].x ) and (arr[k].y = arr[a].y)) then
Continue;
setArrayLength(TPA, length(TPA) + 1);
TPA[Length(TPA) - 1] := arr[k];
end;
arr := TPA;
end;
arr := TempTPA;
end;
procedure talkToSquire;
var
x, y: integer;
i, j: integer;
Points: array of tPoint;
Arr: array of array of tPoint;
begin
for i := 0 to 20 do
begin
Wait(10);
findColorsTolerance(Points, 1908000, MSX1, MSY1, MSX2, MSY2, i);
//removePointsByDistance(Points, 5);
arr := splitTPA10(Points);
for j := 0 to length(Arr) - 1 do
begin
x := arr[j][0].x;
y := arr[j][0].y;
if(inRange(x, 238, 261) and inRange(y, 173, 203)) then //remove points on player
Continue;
if(findColoredAreaTolerance(x, y, 1908000, x - 5, y - 5, x + 5, y + 5, 8, i)) then
begin
MMouse(x, y, 2, 2);
Wait(100 + random(100));
getMousePos(x, y);
if(isUpText('quire')) then
begin
Mouse(x, y, 0, 0, True);
wait(100 + random(100));
fFlag(0);
wait(1000 + random(1000));
Exit;
end;
end;
end;
end;
end;
procedure say(what: array of string); //ontinue, arrim, ontinue, ontinue
var
i, j: integer;
begin
for i := 0 to length(what) - 2 do
begin
for j := 0 to 30 do
begin
wait(100 + random(100));
if(not clickNpcChatText(what[i])) then
begin
if(findNPCChatText(what[i + 1])) then
begin
Break;
end;
end else
Break;
end;
end;
//clickNPCChatText(what[i + 1]);
end;
procedure waitWhileOnBoat;
begin
repeat
wait(10);
until(CountColor(0, MSX1, MSY1, MSX2, MSY2) >= 75000)
end;
procedure walkOverPlank;
var
i, j: integer;
x, y: integer;
Points: Array of TPoint;
begin
{plank := BitmapFromString(19, 8, 'z78DA73731B18604017306AE3A' +
'88D43CB460006A1BC05'); }
{plank := BitmapFromString2(False, 'a768DF78DAC5CF410EC33008' +
'44D12B0133186F9DD8BEFF9112B78994887555164F482CBE10B92' +
'7B088CF6AFB69095D3BC752B7538CB9CEB3CA9F26E09D1AE20D23' +
'5BE8829AF560B19965A059CDBE8AEE93B8BAC9120EB4AC375620C' +
'B0DDDDA53DB6D3DF42CD6A2E4E50FBA1A4AE9DFD601850');
if(FindDeformedBitmapToleranceIn(plank, x, y, MSX1, MSY1, MSX2, MSY2, 50, 3, True, Accuracy)) then
begin
Writeln('Found!');
MMouse(x + 10, y + 10, 5, 5);
if(isUpText('ross')) then
begin
getMousePos(x, y);
Mouse(x, y, 0, 0, True);
end;
end;
freeBitmap(plank); }
for i := 0 to 30 do
begin
findColorsSpiralTolerance(MSCX, MSCY, Points, 3954025, MSX1, MSY1, MSX2, MSY2, i);
for j := 0 to length(Points) - 1 do
begin
x := Points[j].x;
y := Points[j].y;
if(not (findColor(x, y, 0, x - 7, y - 2, x + 7, y + 2))) then
begin
if(CountColor(0, x - 9, y - 3, x + 9, y + 2) >= 8) then
begin
MMouse(x, y, 5, 5);
Wait(100 + random(100));
if(isUpText('ross')) then
begin
getMousePos(x, y);
Mouse(x, y, 0, 0, True);
repeat
wait(10);
until(CountColor(0, MSX1, MSY1, MSX2, MSY2) <= 75000)
wait(1000 + random(1000));
Exit;
end;
end;
end;
end;
end;
end;
procedure walkToStan;
var
i: integer;
begin
repeat
wait(10);
until(CountColorTolerance(10123368, MSX1, MSY1, MSX2, MSY2, 20) >= 40000)
for i := 20 downto 0 do
begin
if(findSymbolIn(x, y, 'transportation', MMX1, MMCY + i, MMX2, MMY2)) then
begin
mouseFlag(x, y, 5, 5);
fFlag(5);
wait(500 + random(1000));
Exit;
end;
end;
end;
procedure talkToStan;
var
i, j: integer;
x, y: integer;
Points: array of tPoint;
begin
for i := 0 to 30 do
begin
findColorsSpiralTolerance(MSCX, MSCY, Points, 942980, MSX1, MSY1, MSX2, MSY2, i);
for j := 0 to length(Points) - 1 do
begin
x := Points[j].x;
y := Points[j].y;
wait(10);
if(findColoredAreaTolerance(x, y, 942980, x - 5, y - 5, x + 5, y + 5, 8, i)) then
begin
MMouse(x, y, 5, 5);
Wait(100 + random(100));
if(isUpText('rader')) then
begin
getMousePos(x, y);
mouse(x, y, 0, 0, False);
chooseOptionEx('rade');
Exit;
end;
end;
end;
end;
end;
procedure randomExamine;
var
row, col: integer;
x, y: integer;
i: integer;
begin
i := random(20) + 1;
row := i div 8;
col := i - (row * 8) - 1;
if (col < 0) then
begin
col := 7;
row := row - 1;
end;
x := 88 + (col * 47) + Random(7);
y := 76 + (row * 47) + Random(7);
mouse(x, y, 0, 0, False);
chooseOption(x, y, 'xamin');
end;
procedure buyAsh;
var
ash: integer;
begin
ash := BitmapFromString2(False, 'a5197978DA358A4112C0200803' +
'BF8452408E24F5FF5FAAD636879DCCCE8AFCBB6CC1A32D46E9FE7' +
'36CAFDB6BF7376A6865652014CA9B4E3BFED0A787478D64F22B0B' +
'026147225954F6533ED99');
repeat
if(amountBMP('shop', ash, 40) > 0) then
begin
buyAmount(21, random(2) * 5 + 5);
end;
case random(10) of
0: randomExamine;
1: mMouse(0, 0, 764, 502);
2: randomRClick;
3: wait(1000 + random(100000));
end;
until(invFull)
freeBitmap(ash);
repeat
CloseWindow;
wait(100 + random(100));
until(not shopScreen)
end;
procedure walkToBoat;
var
i: integer;
begin
for i := 20 downto 0 do
begin
if(findSymbolIn(x, y, 'transportation', MMX1, MMY1, MMX2, MMCY - i)) then
begin
mouseFlag(x, y, 5, 5);
fFlag(5);
wait(500 + random(1000));
Exit;
end;
end;
end;
begin
setupScript;
if(not LoggedIn) then
loginPlayer;
highestAngle;
walkToDock;
i := 0;
repeat
talkToSquire;
wait(500 + random(1000));
inc(i);
until(clickToContinue or (i >= 3))
say(['arim', 'ontinue', 'ontinue']);
waitWhileOnBoat;
walkOverPlank;
walkToStan;
talkToStan;
buyAsh;
walkToBoat;
i := 0;
repeat
talkToSquire;
wait(500 + random(1000));
inc(i);
until(clickToContinue or (i >= 3))
say(['outpo', 'ontinue', 'ontinue']);
waitWhileOnBoat;
walkOverPlank;
end.