Due to time constraints placed upon me by real life, I can't work on this much more (not until winter break). We have 8 furlough days this year in my school district (8 less school days, teachers don't get payed, no one attends school, etc.) so some of my teachers are trying to cram in these last 2 weeks before winter break with as much work as possible. I'm going to post the code if anyone wants to work on this. The banking procedure could be refined a bit, it still needs a proggy, and nothing having to do with the spiders themselves has been complete. However, if i may say so myself, all the other procedures are quite nice :D
here's the code, do as you wish:
program GiantSpiderKiller;
{$i SRL\SRL.scar}
{$i SRL\SRL\misc\debug.scar}
const
DebugTPAs = True; //Show TPA Debugging? *NOTE*: must check the box under View -> Debug Image!!
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Pin := '';
Active := true;
Strings[0] := ''; //food
end;
end;
const
BSX1 = 26;
BSY1 = 85;
BSX2 = 478;
BSY2 = 290;
function CP: Byte;
begin
Result := CurrentPlayer;
end;
procedure Die(Reason: string);
begin
if FindNormalRandoms then
Exit;
Writeln('logging out player ' + Players[CP].Nick + ' because ' + Reason);
if BankScreen then
WaitFunc(@CloseBank, 10 + Random(25), 2000);
Logout;
Players[CP].Active := False;
end;
function LoadAttackTypes: TStringArray; //xs,ys,xe,ye's need to be redone.
var
T: Integer;
begin
if not LoggedIn then
Exit;
SetLength(Result, 4);
GameTab(tab_Combat);
MMouse(602, 273, 20, 20);
MarkTime(T);
repeat
Wait(10 + Random(15));
until(CountColorTolerance(10551295, 610, 326, 620, 336, 4) > 40) or (TimeFromMark(T) > 3000);
if FindTextTpa(0, 4, 570, 336, 640, 352, 'ttack', 'StatChars', Nothing) then
Result[0] := 'attack';
if FindTextTpa(0, 4, 570, 336, 640, 352, 'rength', 'StatChars', Nothing) then
Result[0] := 'strength';
if FindTextTpa(0, 4, 570, 336, 640, 352, 'fenc', 'StatChars', Nothing) then
Result[0] := 'defence';
if FindTextTpa(0, 4, 570, 336, 640, 352, 'hared', 'StatChars', Nothing) then
Result[0] := 'shared';
Wait(600 + Random(60));
MMouse(685, 273, 20, 20);
MarkTime(T);
repeat
Wait(10 + Random(15));
until(CountColorTolerance(10551295, 695, 320, 705, 330, 4) > 40) or (TimeFromMark(T) > 3000);
if FindTextTpa(0, 4, 520, 434, 598, 450, 'ttack', 'StatChars', Nothing) then
Result[1] := 'attack';
if FindTextTpa(0, 4, 520, 434, 598, 450, 'rength', 'StatChars', Nothing) then
Result[1] := 'strength';
if FindTextTpa(0, 4, 520, 434, 598, 450, 'fenc', 'StatChars', Nothing) then
Result[1] := 'defence';
if FindTextTpa(0, 4, 520, 434, 598, 450, 'hared', 'StatChars', Nothing) then
Result[1] := 'shared';
Wait(600 + Random(60));
MMouse(574, 311, 30, 50);
MarkTime(T);
repeat
Wait(10 + Random(15));
until(CountColorTolerance(10551295, 605, 375, 615, 385, 4) > 40) or (TimeFromMark(T) > 3000);
if FindTextTpa(0, 4, 570, 385, 643, 404, 'ttack', 'StatChars', Nothing) then
Result[2] := 'attack';
if FindTextTpa(0, 4, 570, 385, 643, 404, 'rength', 'StatChars', Nothing) then
Result[2] := 'strength';
if FindTextTpa(0, 4, 570, 385, 643, 404, 'fenc', 'StatChars', Nothing) then
Result[2] := 'defence';
if FindTextTpa(0, 4, 570, 385, 643, 404, 'hared', 'StatChars', Nothing) then
Result[2] := 'shared';
Wait(600 + Random(60));
MMouse(657, 310, 30, 40);
MarkTime(T);
repeat
Wait(10 + Random(15));
until(CountColorTolerance(10551295, 695, 370, 705, 380, 4) > 40) or (TimeFromMark(T) > 3000);
if FindTextTpa(0, 4, 652, 388, 595, 502, 'ttack', 'StatChars', Nothing) then
Result[3] := 'attack';
if FindTextTpa(0, 4, 652, 388, 595, 502, 'rength', 'StatChars', Nothing) then
Result[3] := 'strength';
if FindTextTpa(0, 4, 652, 388, 595, 502, 'fenc', 'StatChars', Nothing) then
Result[3] := 'defence';
if FindTextTpa(0, 4, 652, 388, 595, 502, 'hared', 'StatChars', Nothing) then
Result[3] := 'shared';
if (Result[3] = '') then
Result[3] := 'null';
Wait(600 + Random(60));
end;
function WalkToPortal1: Boolean;
begin
Result := RadialWalk(3553595, 120, 135, 30, 1, 1);
end;
function WalkToPortal2: Boolean;
begin
Result := RadialWalk(6065304, 200, 230, 30, 1, 1);
end;
function OpenBanker: Boolean;
var
x, y, i, CTS, h: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
if BankScreen then
Exit;
SetAngle(true);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.1476, 1.6836);
if not FindColorsTolerance(TPA, 3809322, MSX1, MSY1, MSX2, MSY2, 10) then
Exit;
ATPA := TPAtoATPAEx(TPA, 20, 30);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if DebugTPAs then
DebugATPABounds(ATPA);
H := High(ATPA);
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 5);
if WaitUptext('anker', 600) then
begin
ClickMouse2(False);
WaitOption('ank Ba', 600);
Result := WaitFunc(@BankScreen, 10 + Random(15), 6000);
end;
if Result then
Break;
end;
end;
function WithdrawRunes: Boolean;
var
TPA: TPointArray;
x, y, i, c: Integer;
ATPA: Array of TPointArray;
begin
if not LoggedIn then Exit;
if not BankScreen then
if not Openbanker then
Exit;
if not FindColorsTolerance(TPA, 13882589, BSX1, BSY1, BSX2, BSY2, 3) then
Logout;
if not LoggedIn then
Exit;
ATPA := SplitTPAEx(TPA, 10, 10);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 5, 5);
if WaitUptext('ir run', 600) then
begin
case Random(2) of
0, 2:
begin
repeat
GetMousePos(x, y);
Mouse(x, y, 1, 1, true);
Wait(300 + Random(30));
inc(c);
until(c = 3);
Result := True;
end;
1:
begin
ClickMouse2(False);
if not WaitOption('draw-3', 600) then
begin
MMouse(x, y, 50, 50);
MMouse(x, y, 5, 5);
ClickMouse2(False);
if WaitOption('draw-X', 600) then
begin
Wait(800 + Random(80));
TypeSend('3');
end;
end;
Result := True;
end;
end;
end;
if Result then
Break;
end;
if not FindColorsTolerance(TPA, 14033951, BSX1, BSY1, BSX2, BSY2, 3) then
Logout;
if not LoggedIn then
Exit;
ATPA := SplitTPAEx(TPA, 10, 10);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 5, 5);
if WaitUptext('aw run', 600) then
begin
case Random(2) of
0, 2:
begin
ClickMouse2(True);
Result := True;
end;
1:
begin
ClickMouse2(False);
Result := WaitOption('draw-1', 600);
end;
end;
end;
if Result then
Break;
end;
if not FindColorsTolerance(TPA, 1450140, BSX1, BSY1, BSX2, BSY2, 3) then
Logout;
if not LoggedIn then
Exit;
ATPA := SplitTPAEx(TPA, 10, 10);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 5, 5);
if WaitUptext('re run', 600) then
begin
case Random(2) of
0, 2:
begin
ClickMouse2(True);
Result := True;
end;
1:
begin
ClickMouse2(False);
Result := WaitOption('draw-1', 600);
end;
end;
end;
if Result then
Break;
end;
end;
function WithdrawFood: Boolean;
var
FoodColor, x, y, i: Integer;
FoodUptext: string;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
case lowercase(Players[CP].Strings[0]) of
'monkfish':
begin
FoodColor := 8027295;
FoodUptext := 'kf';
end;
'shark':
begin
FoodColor := 3162454;
FoodUptext := 'har';
end;
'lobster':
begin
FoodColor := 1993428;
FoodUptext := 'obst';
end;
'swordfish':
begin
FoodColor := 8804991;
FoodUptext := 'rdfi';
end;
end;
if not FindColorsTolerance(TPA, FoodColor, BSX1, BSY1, BSX2, BSY2, 2) then
Logout;
if not loggedIn then
Exit;
ATPA := SplitTPAEx(TPA, 10, 10);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUptext(FoodUptext, 600) then
begin
ClickMouse2(False);
Result := WaitOption('draw-All', 600);
end;
if Result then
Exit;
end;
end;
function SpellsSortedByLevel: Boolean;
begin
if not LoggedIn then
Exit;
if not GameTab(TAB_MAGIC) then
logout;
if not LoggedIn then
Exit;
Result := (CountColorTolerance(16711422, 670, 438, 695, 461, 4) > 70);
end;
function SortByLevel: Boolean;
var
x, y, T: Integer; //x and y are just filler for FindTextTpaEx
begin
if not LoggedIn then
Exit;
if not GameTab(tab_Magic) then
Logout;
if not LoggedIn then
Exit;
if SpellsSortedByLevel then
Exit;
MouseBox(677, 444, 689, 458, 3);
MarkTime(T);
repeat
Result := FindTextTpaEx(0, 4, 614, 396, 735, 425, x, y, 'ort by lev', 'StatChars' , nothing);
if Result then
Break;
Wait(10 + Random(15));
until(TimeFromMark(T) >= 2000) or Result;
ClickMouse2(True);
Result := WaitFunc(@SpellsSortedByLevel, 10 + Random(25), 1300);
end;
function ScrolledUp: Boolean; //Tells if the scroll bar on the magic screen is scrolled all the way up
begin
if not LoggedIn then
Exit;
if not GameTab(TAB_MAGIC) then
Logout;
if not LoggedIn then
Exit;
Result := (CountColorTolerance(2041131, 722, 240, 724, 248, 4) < 10);
end;
function ScrollUp: Boolean;
var x, y: Integer;
begin
if not LoggedIn then
Exit;
if not GameTab(tab_Magic) then
Logout;
if not LoggedIn or ScrolledUp then
Exit;
MouseBox(723, 210, 731, 220, 3);
GetMousePos(x, y);
HoldMouse(x, y, mouse_Left);
repeat Wait(10 + Random(15)) until WaitFunc(@ScrolledUp, 10 + Random(25), 2000);
ReleaseMouse(x, y, mouse_Left);
Result := ScrolledUp;
end;
function TeleportToVarrock: Boolean;
var
x, y, i: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
if not GameTab(TAB_MAGIC) then
Logout;
if not LoggedIn then
Exit;
if not SpellsSortedByLevel then
if not SortByLevel then
Logout;
if not ScrolledUp then
if not ScrollUp then
Logout;
if not FindColorsTolerance(TPA, 7221328, MIX1, MIY1, MIX2, MIY2, 4) then
Logout;
if not LoggedIn then
Exit;
ATPA := SplitTPAEx(TPA, 19, 19);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUpText('rock', 800) then
begin
ClickMouse2(True);
Result := True;//need better method here; no crosshairs after clicking teleport
end;
if Result then
Break;
end;
end;
function WarnScreen: Boolean;
begin
Result := FindTextTPA(2070783, 3, 233, 44, 302, 66, 'rning', 'UpChars', Nothing);
end;
function AbleToDisable: Boolean; //checks if you can tell it not to warn you about entering dungeons again
begin
Result := FindTextTPA(2070783, 3, 199, 222, 338, 243, 'on''t ask me this again', 'SmallChars', Nothing);
end;
function BoxChecked: Boolean;
begin
if not LoggedIn then
Exit;
Result := (CountColorTolerance(1052924, 111, 222, 132, 241, 4) > 9);
end;
function CheckDisableBox: Boolean;
var
TPA: TPointArray;
x, y: Integer;
begin
if not LoggedIn or not WarnScreen or not AbleToDisable or BoxChecked then
Logout;
if not LoggedIn then
Exit;
if not FindColorsTolerance(TPA, 4414313, 110, 222, 131, 243, 4) then
Logout;
if not LoggedIn then
Exit;
MiddleTPAEx(TPA, x, y);
MMouse(x, y, 3, 3);
if WaitUptext('ff', 660) then
begin
ClickMouse2(True);
Result := WaitFunc(@BoxChecked, 10 + Random(25), 4000);
end else
Result := False;
end;
function ExitWarnScreen: Boolean;
var
x, y: Integer;
TPA: TPointArray;
begin
if not LoggedIn or not WarnScreen then
Exit;
if not FindColorsTolerance(TPA, 1383457, 405, 43, 429, 66, 4) then
Logout;
if not LoggedIn then
Exit;
MiddleTPAEx(TPA, x, y);
MMouse(x, y, 3, 3);
if WaitUptext('lose', 660) then
begin
ClickMouse2(True);
Result := True;
end else
Result := False;
end;
function HandleWarnScreen: Boolean;
begin
if WarnScreen then
begin
if AbleToDisable then
begin
CheckDisableBox;
WaitFunc(@BoxChecked, 10 + Random(15), 8000);
end;
ExitWarnScreen;
end;
Result := not(WarnScreen);
end;
function EnteredFirstFloor: Boolean;
begin
if not LoggedIn then
Exit;
MakeCompass('n');
SetAngle(true);
Result := (CountColorTolerance(4144962, 254, 213, 264, 220, 12) > 50);
end;
function EnterEntrance: Boolean;
var
x, y, i, CTS, H: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.0084, 0.0817);
if not FindColorsTolerance(TPA, 6650498, MSX1, MSY1, MSX2, MSY2, 20) then
Logout;
ColorToleranceSpeed(CTS);
if not LoggedIn then
Exit;
ATPA := TPAtoATPAEx(TPA, 50, 50);
if DebugTPAs then
DebugATPABounds(ATPA);
H := High(ATPA)
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUpText('down', 600) then
begin
case Random(2) of
0, 2:
begin
ClickMouse2(True);
Result := True;
end;
1:
begin
ClickMouse2(False);
Result := WaitOption('imb-down', 600);
end;
end;
end;
if Result then
Break;
end;
Result := WaitFunc(@EnteredFirstFloor, 10 + Random(15), 12000);
end;
function EnteredPortal1: Boolean; //EnteredPortal1/EnteredPortal2 are ~seperate~ for ease of use in WaitFunc
begin
if not LoggedIn then
Exit;
MakeCompass('n');
SetAngle(True);
Result := (CountColorTolerance(5592921, 248, 195, 266, 209, 5) > 50);
end;
function EnteredPortal2: Boolean; //EnteredPortal1/EnteredPortal2 are ~seperate~ for ease of use in WaitFunc
begin
if not LoggedIn then
Exit;
MakeCompass('n');
SetAngle(True);
Result := (CountColorTolerance(6465968, 248, 195, 266, 209, 5) > 50);
end;
function EnterPortal(which: Integer): Boolean;
var
x, y, i, c, PortalColor, CTS: Integer;
Hue, Sat: Extended;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
case which of
1:
begin
PortalColor := 7639186;
Hue := 0.0215;
Sat := 1.0040;
end;
2:
begin
PortalColor := 10409947;
Hue := 0.0806;
Sat := 0.9318;
end;
end;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue, Sat);
repeat
Result := FindColorsTolerance(TPA, PortalColor, MSX1, MSY1, MSX2, MSY2, 10);
if Result then
Break;
Wait(200 + Random(20));
inc(c);
until(C >= 6);
ColorToleranceSpeed(CTS);
if not Result then
Logout;
if not LoggedIn then
Exit;
ATPA := TPAtoATPAEx(TPA, 40, 50);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if DebugTPAs then
DebugATPABounds(ATPA);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 4, 4);
if WaitUpText('nter', 600) then
begin
case Random(2) of
0, 2:
begin
ClickMouse2(True);
Result := True;
end;
1:
begin
ClickMouse2(False);
Result := WaitOption('nter', 600);
end;
end;
end;
if Result then
Break;
end;
case Which of
1: Result := WaitFunc(@EnteredPortal1, 10 + Random(15), 6000);
2: Result := WaitFunc(@EnteredPortal2, 10 + Random(15), 6000);
end;
end;
function EnteredSecondFloor: Boolean;
begin
if not LoggedIn then
Exit;
MakeCompass('n');
SetAngle(True);
Result := (CountColorTolerance(5408917, 248, 195, 266, 209, 5) > 30);
end;
function EnteredThirdFloor: Boolean;
begin
if not LoggedIn then
Exit;
MakeCompass('n');
SetAngle(True);
Result := (CountColorTolerance(2655335, 282, 157, 306, 174, 1) > 80);
end;
function GoDownLadder1: Boolean;
var
x, y, i, H: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
if not FindColorsTolerance(TPA, 3552824, MSX1, MSY1, MSX2, MSY2, 10) then
Exit;
ATPA := TPAToATPAEx(TPA, 40, 40);
//DebugATPA(ATPA, '');
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
//DebugATPABounds(ATPA);
H := High(ATPA);
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUptext('limb-down', 600) then
begin
case Random(6) of
1, 3, 5:
begin
ClickMouse2(True);
Result := True;
end;
0, 2, 4, 6:
begin
ClickMouse2(False);
Result := WaitOption('limb-down', 600);
end;
end;
end;
if Result then
Break;
end;
if not Result then
Logout;
Result := WaitFunc(@EnteredSecondFloor, 10 + random(15), 6000);
end;
function GoDownLadder2: Boolean;
var
x, y, i, H: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
if not FindColorsTolerance(TPA, 4818341, MSX1, MSY1, MSX2, MSY2, 10) then
Exit;
ATPA := TPAToATPAEx(TPA, 40, 40);
//DebugATPA(ATPA, '');
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if DebugTPAs then
DebugATPABounds(ATPA);
H := High(ATPA);
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUptext('limb-down', 600) then
begin
case Random(6) of
1, 3, 5:
begin
ClickMouse2(True);
Result := True;
end;
0, 2, 4, 6:
begin
ClickMouse2(False);
Result := WaitOption('limb-down', 600);
end;
end;
end;
if Result then
Break;
end;
if not Result then
Logout;
Result := WaitFunc(@EnteredThirdFloor, 10 + random(15), 6000);
end;
function WalkToLadder1: Boolean;
var
TPA: TPointArray;
x, y: Integer;
begin
if not LoggedIn then
Exit;
MakeCompass('n');
Result := FindColorsTolerance(TPA, 340312, 569, 77, 587, 98, 6);
if not Result then
Logout;
if not LoggedIn then
Exit;
MiddleTPAEx(TPA, x, y);
Mouse(x, y, 3, 3, true);
FFlag(0);
end;
function WalkToLadder2: Boolean;
var
TPA: TPointArray;
x, y: Integer;
begin
if not LoggedIn then
Exit;
MakeCompass('n');
Result := FindColorsTolerance(TPA, 797789, 641, 100, 655, 115, 45);
DebugTPA(TPA, '');
if not Result then
Logout;
if not LoggedIn then
Exit;
MiddleTPAEx(TPA, x, y);
Mouse(x, y, 3, 3, true);
FFlag(0);
end;
function EatFood: Boolean;
var i: Integer;
begin
for i := 4 to 28 do
begin
if ExistsItem(i) then
MouseItem(i, false);
if WaitUptext('Eat', 600) then
begin
ClickMouse2(True);
Result := True;
end;
if Result then
Break;
end;
end;
function OpenDoor: Boolean;
var
x, y, H, i, CTS: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
if not LoggedIn then
Exit;
MakeCompass('s');
SetAngle(True);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(1.2313, 8.6071);
Result := FindColorsTolerance(TPA, 1533821, MSX1, MSY1, MSX2, 200, 5);
ColorToleranceSpeed(CTS);
if not Result then
Logout;
if not(LoggedIn) then
Exit;
ATPA := TPAtoATPAEx(TPA, 40, 40);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if DebugTPAs then
//DebugATPABounds(ATPA);
DebugATPABounds(ATPA);
H := High(ATPA);
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 3, 3);
if WaitUptext('ozing barr', 600) then
begin
ClickMouse2(False);
Result := WaitOption('pen', 600);
end else
Result := False;
if Result then
Break;
end;
end;
begin
SetupSRL;
DeclarePlayers;
ActivateClient;
LoginPlayer;
OpenDoor;
end.