Sir R. M8gic1an
2008-06-07 08:30:00
well earlier today (at about 1am for me) i posted this in SRL New Functions.
i now finished it.
~RM
i now finished it.
{*******************************************************************************
function FindBankTPA(TheBank: String): Boolean;
By: Rasta Magician
Description: Finds and opens any given bank in the free world.
Uses TPAs to find the bankers.
Valid arguments are:
'feb' (Falador East Bank)
'fwb' (Falador West Bank)
'veb' (Varrock East Bank)
'vwb' (Varrock West Bank)
'db' (Draynor Bank)
'akb' (Al-Kharid Bank)
'eb' (Edgevile Bank)
*******************************************************************************}
Function FindBankTPA(TheBank:string):boolean;
var
TPA:TPointArray;
ATPA: T2DPointArray;
TP: TPoint;
i, rx, ry, ExtraAngle:integer;
TempCTS, k:integer;
TPASize:integer;
begin
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.13);
Result:=False;
try
FindColorsTolerance(TPA, 125931, MMX1, MMY1, MMX2, MMY2, 7)
if Length(TPA) = 0 then
begin
Writeln('Failed to find the color, no result.');
Exit;
end;
ATPA:=TPAToATPA(TPA, 3); //to find out how many bankers
if Length(ATPA) < 3 then
begin
writeln('could not find bankers');
exit;
end;
TPASize := Length(ATPA[0]); //to know how big the banker dots are
for i:=0 to High(ATPA) do //re joining the tpa, smaller split
TPA := CombineTPA(TPA, ATPA[i]);
ATPA := SplitTPA(TPA, 6); //seprating the bankers from any other npcs around
k:=0;
for i:=0 to High(ATPA) do //checking where there are 4+ npcs together
if (Length(ATPA[i]) > (3*TPASize))then
begin
TPA[k] := MiddleTPA(ATPA[i]);
inc(k);
end;
SetLength(TPA, k);
//SortTPAFrom(TPA, Point(MMCX, MMCY));
if Length(TPA) > 1 then
TP := MiddleTPA(TPA)
else
TP:=TPA[0];
rx := 0; ry:=0; ExtraAngle:=0;
case lowercase(TheBank) of
'eb' : begin rx := -11; ry := -3; ExtraAngle := -90; end;
'veb': begin rx := 3; ry := 11; ExtraAngle := 0; end;
'fwb': begin rx := 10; ry := 8; ExtraAngle := 0; end;
'feb': begin rx := 3; ry := 8; ExtraAngle := 0; end;
'akb' : begin rx := 7; ry := 5; ExtraAngle := -90; end;
'db' : begin rx := 9; ry := 10; ExtraAngle := 0; end;
'vwb':
begin
ExtraAngle:=0;
if rs_GetCompassAngleDegrees < 180.0 then
begin
if TP.x > MMCX then
rx:=+10
else
rx:=-10;
if TP.y < MMCY then
ry:= -15
else
ry:= +15;
end else begin
if TP.x > MMCX then
rx:=-10
else
rx:=+10;
if TP.y < MMCY then
ry:= +15
else
ry:= -15;
end
end;
end;
IncEx(TP.x, Round(rx * Cos(Radians(rs_GetCompassAngleDegrees + ExtraAngle))));
IncEx(TP.y, Round(ry * Sin(Radians(rs_GetCompassAngleDegrees + ExtraAngle))));
Mouse(TP.x, TP.y, 0, 0, True);
FFLag(0);
if OpenBankQuiet(lowercase(TheBank)) then
begin
FixBank;
Result := True;
exit;
end;
finally
ColorToleranceSpeed(tempCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
end;
~RM