SCAR Code:
program New;
{.include SRL/SRL.scar}
var MyList:TPointArray;
var blRuneEss,SlotList:array of integer;
{*******************************************************************************
function Create40PercentTPA:TPointArray;
By: Boreas
Note: Purely an internal function, used in setup.
Description: Returns a TPointArray containing the relative (to x1,y1 of a BSlot)
for 385 points (out of 31*31, hence 40%). Only needs to be done once, to create
the list of points to check for 65536. Only takes like 15ms, and I didn't
feel like typing them all out.
*******************************************************************************}
function Create40PercentTPA:TPointArray;
var Counter,hx,hy:integer;
var TPointsToCheck:array [0..384] of TPoint;
begin
repeat
hy:=15;
hx:=hx+1;
repeat
hy:=hy+1;
if (((hx mod 4)=0) or ((hy mod 4)=0)) then
begin
TPointsToCheck[Counter].x:=hx;
TPointsToCheck[Counter].y:=hy;
Counter:=Counter+1;
end;
until hy=31;
until hx=31;
result:=TPointsToCheck;
end;
{*******************************************************************************
function CreateItemBlackList(WhichBankSlot:integer;WhichList:TPointArray):array of integer;
By: Boreas
Description: Looks at the points in the list for an item, and returns an array
contatining the indexes of the points that are black.
Usage: WhichBankSlot-just what it sounds like. WhichList-the TPointArray
containing positions relative to the x1,y1 of a bankslot which you want to check
*******************************************************************************}
function CreateItemBlackList(WhichBankSlot:integer;WhichList:TPointArray):array of integer;
var Counter,Counter2,Tmpx1,Tmpy1,ListLength:integer;
var TmpArray:array of integer;
begin
Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
ListLength:=getarraylength(WhichList)-1;
setarraylength(tmparray,1);
for Counter:= 0 to ListLength do
begin
if GetColor(Tmpx1+WhichList[Counter].x,Tmpy1+WhichList[Counter].y)=65536 then
begin
TmpArray[Counter2]:=Counter;
Counter2:=Counter2+1;
setarraylength(TmpArray,Counter2+1);
end;
end;
result:=TmpArray;
end;
{*******************************************************************************
function CompareIntArrays(FirstIntArray,SecondIntArray:array of integer):boolean;
By: Boreas
Description: Returns true both arrays are the same
******************************************************************************}
function CompareIntArrays(FirstIntArray,SecondIntArray:array of integer):boolean;
var Counter:integer;
begin
if not(getarraylength(FirstIntArray)=getarraylength(SecondIntArray)) then
result:=false;
if (getarraylength(FirstIntArray)=getarraylength(SecondIntArray)) then
begin
result:=true;
repeat
if not(FirstIntArray[Counter]=SecondIntArray[Counter]) then
result:=false;
Counter:=Counter+1;
until ((Counter=getarraylength(FirstIntArray)) or (result=false));
end;
end;
//in misc/arrayloader.scar by moparisthebest
function intArrayToStr(intArray: array of Integer): string;
var
i, arrayLength: Integer;
begin
arrayLength := GetArrayLength(intArray);
repeat
Result := Result + IntToStr(intArray[i]);
if (not (i = (arrayLength - 1))) then
Result := Result + ' ';
i := i + 1;
until (i = arrayLength)
end;
//in misc/arrayloader.scar by moparisthebest
function strToIntArray(intArray: string): array of Integer;
var
i, spacePos: Integer;
begin
repeat
SetArrayLength(Result, i + 1);
spacePos := Pos(' ', intArray);
if (not (spacePos = 0)) then
begin
Result[i] := StrToInt(Copy(intArray, 1, spacePos - 1));
end
else
begin
Result[i] := StrToInt(Copy(intArray, 1, Length(intArray)));
break;
end;
Delete(intArray, 1, spacePos);
i := i + 1;
until (False)
end;
{*******************************************************************************
function InIntArray(TheInt:integer;TheArray:array of integer):boolean;
By: Boreas
Description: Returns true if TheInt is a member of TheArray
******************************************************************************}
function InIntArray(TheInt:integer;TheArray:array of integer):boolean;
var i:integer;
begin
repeat
if TheArray[i]=TheInt then
result:=true;
i:=i+1;
until ((i=getarraylength(TheArray)) or (result));
end;
{*******************************************************************************
function FindAllSlotsBlackListSkip(BlackList:array of integer; PointList:TPointArray; SkipEm:array of integer):array of integer;
By: Boreas
Description: Returns the BankSlots containing the BlackList found with the
PointList. Skips the slots in SkipEm. Use [0] to skip none.
******************************************************************************}
function FindAllSlotsBlackListSkip(BlackList:array of integer; PointList:TPointArray; SkipEm:array of integer):array of integer;
var slot,counter:integer;
tmpBlackList, tmpresult:array of integer;
begin
for slot:=1 to 48 do
begin
if not(InIntArray(slot,SkipEm)) then //is there a better way?
begin
tmpBlackList:=CreateItemBlackList(slot,PointList);
if CompareIntArrays(BlackList,tmpBlackList) then
begin
setarraylength(tmpresult,counter+1);
tmpresult[counter]:=slot;
counter:=counter+1;
end;
end;
end;
result:=tmpresult;
end;
{*******************************************************************************
procedure MouseSlot(SlotNumber,ClickType:integer);
By: Boreas
Description: Clicks give bank slot
ClickType: 0 for no click (just move), 1 for left, 2 for right
******************************************************************************}
procedure MouseSlot(SlotNumber,ClickType:integer);
begin
case ClickType of
0: mmouse(79+(((SlotNumber+7)mod 8)*47)+ random(31),
62+(((SlotNumber-1)/8)*38)+random(31),0,0);
1: mouse(79+(((SlotNumber+7)mod 8)*47)+ random(31),
62+(((SlotNumber-1)/8)*38)+random(31),0,0,true);
2: mouse(79+(((SlotNumber+7)mod 8)*47)+ random(31),
62+(((SlotNumber-1)/8)*38)+random(31),0,0,false);
end;
end;
{*******************************************************************************
procedure WithdrawBankSlot(WhichSlot, Amount: Integer);
By: Boreas
Description: Withdraws specified amount from specified bankslot
To withdraw all, use 0 as amount
Based on Withdraw except it does BankSlots instead of row and column
******************************************************************************}
procedure WithdrawBankSlot(WhichSlot, Amount: Integer);
var
rx, ry: Integer;
begin
if (BankScreen) then
begin
if (Amount = 1) then
begin
MouseSlot(WhichSlot,1);
end
else
begin
MouseSlot(WhichSlot,2);
GetMousePos(rx,ry);
if (Amount = 1) or (Amount = 5) or (Amount = 10) or (Amount = 0) then
begin
if (Amount = 5) then
ChooseOption(rx, ry, 'Withdraw 5');
if (Amount = 10) then
ChooseOption(rx, ry, 'Withdraw 10');
if (Amount = 0) then
ChooseOption(rx, ry, 'Withdraw All');
end
else
begin
ChooseOption(rx, ry, 'Withdraw X');
Wait(1000 + Random(100));
TypeSend(IntToStr(Amount) + Chr(13));
end;
end;
end;
end;
begin
//This sets up srl, duh
setupsrl;
//BlackLists are fast because they don't look at every pixel
//This decides how much they look at
MyList:=Create40PercentTPA;
//This is the BlackList for Ess, because I'm in a good mood
blRuneEss:=strToIntArray('0 5 10 21 52 59 81 109 137 143 147 162 174 184 185 196 0');
//This creates a list of all bankslots with that BlackList
SlotList:=findallslotsblacklistskip(blRuneEss,MyList,[0]);
//Lucky for you, runes don't have the same BlackList as ess
//so there should only be one slot in the list,
//so you don't need to use colors
if getarraylength(SlotList)>1 then
begin
writeln('There are '+inttostr(getarraylength(SlotList))+' possible places where it could be');
writeln('Since we are not using BlackLists with color (the second tut),');
writeln('we will just pick the first one, and hope for the best');
end;
//So SlotList[0] is the first (and only) slot in the list
//and 5 is how many you want to withdraw for example
//use 0 for all
WithDrawBankSlot(SlotList[0],5);
end.