I really, really need to rewrite this stuff and make it better but I'll probably never use it again so I'd rather write new stuff and post that too. With that said, here's a crappy version of the above that alches too. It uses the runelite plugin for the magic menu so no magic constants here
program CannonALCH;
{$I SRL/OSR.simba}
const
LOGIN_NAME = '';
LOGIN_PASS = '';
RS_WORLD = 302;
IS_MEMBER = true;
var
startnats, natslot, ms, StatsDebugTick, ballstart, ball1: Int64;
findnats: TIntArray;
natbox: TBox;
cannontimer: Double;
currstat: String;
TCannon1: TTimeMarker;
var
cannonball := DTMFromString('mbQAAAHicY2VgYDjExMBwCoiPA/FOIN4KxP6MDAw+QBwFxBGMEL6liQlQNSODgYICmIZgEgAAMeMGhg==');
bolts := DTMFromString('mggAAAHicY2NgYDjExMBwHIi3APEBIN4OxGeB+BFQ7jMQvwbit0D8FIgfA3FgbgWQZMSCyQEAaCULRA==');
nats := DTMFromString('mggAAAHicY2NgYMhiYmBIAeIKIK4C4jggLgLi/YwMDCeA+DAQ7wTi3UB8EogFu0WBuhixYHIAAAtMB+Y=');
fires := DTMFromString('mlwAAAHicY2dgYHBmYmCwBmI/IA4AYhMo9gTifYwMDCeB+DAQ7wLi/VAaJLZCSRSomxEHpggAAIeTCBU=');
procedure declarePlayers();
begin
with Players.New()^ do
begin
LoginName := LOGIN_NAME;
Password := LOGIN_PASS;
IsActive := True;
IsMember := IS_MEMBER;
World := RS_WORLD;
end;
Players.SetCurrent(0);
end;
procedure findCannon();
var
TPA, Group, cannon: TPointArray;
ATPA: T2DPointArray;
begin
if (SRL.FindColors(TPA, CTS2(5197653, 10, 3.47, 0.08), MainScreen.GetBounds) > 0) then
begin
ATPA := TPA.Cluster(1);
ATPA.FilterSize(5000,400000);
ATPA.SortByIndex(mainscreen.GetMiddle);
for Group in ATPA do
begin
Mouse.Move( Group[Random(Length(Group))] );
if MainScreen.IsUpText('Alchemy') then
begin
Mouse.Click(mouse_Left);
WaitEx(1000,250);
end;
if MainScreen.IsUpText('multicanno') then
Break;
WaitEx(1000,250);
Mouse.Move( Group[Random(Length(Group))] );
if MainScreen.IsUpText('multicanno') then
Break;
WaitEx(1000,250);
if not MainScreen.IsUpText('multicanno') then
Mouse.Move(IntToBox(220, 210, 275, 150));
WaitEx(1000,250);
if MainScreen.IsUpText('Talk-to') then
if ChooseOption.Select('Dismiss') then
begin
WaitEx(1000,100);
while minimap.isPlayerMoving() do Wait(50);
end;
if MainScreen.IsUpText('multicanno') then
Break;
end;
end;
end;
procedure killCannon();
begin
//Mouse.Move(IntToBox(240, 250, 305, 120));
findcannon();
WaitEx(400,250);
if MainScreen.IsUpText('Alchemy') then
begin
Mouse.Click(mouse_Left);
WaitEx(1000,250);
end;
if ChooseOption.Select('Pick') then
begin
WaitEx(3000,500);
while minimap.isPlayerMoving() do Wait(100);
end;
Logout.ClickLogout();
end;
procedure dtmcheck();
begin
if not Inventory.Contains(cannonball) then
begin
killCannon();
TerminateScript('Out of cannonballs');
end;
if not Inventory.Contains(bolts) then
begin
killCannon();
TerminateScript('Out of bolts');
end;
if not Inventory.Contains(nats) then
begin
killCannon();
TerminateScript('Out of nature runes');
end;
if not Inventory.Contains(fires) then
begin
killCannon();
TerminateScript('Out of fire runes');
end;
end;
procedure Process();
begin
ms:= GetTimeRunning;
if GetTickCount() - StatsDebugTick > 1000 then
begin
//I shamelessly use slacky's progress report function because I learned by reading his stuff. Thanks go to him
ClearDebug();
ClearDebug();
WriteLn('+---| STATS |----------------------------------------');
WriteLn('|- Script Runtime : ', SRL.MsToTime(GetTimeRunning, Time_Short));
WriteLn('|- Items Alched : ', IntToStr(startnats - SRL.GetItemAmount(natbox)));
WriteLn('|- Alches P/H : ', IntToStr(Round(3600*(startnats - SRL.GetItemAmount(natbox))/(ms/1000))));
//WriteLn('|- Magic Exp : ', IntToStr(alchcount*31)); // Low Level
WriteLn('|- Magic Exp : ', IntToStr((startnats - SRL.GetItemAmount(natbox))*65));
WriteLn('|- Magic Exp P/H : ', IntToStr(Round(3600*(65*(startnats - SRL.GetItemAmount(natbox)))/(ms/1000))));
WriteLn('|- Cannonballs Used : ', IntToStr(ball1));
WriteLn('|- Firing Timer : ',TCannon1.GetTime,' of ',Round(cannontimer),' ms');
WriteLn('|- Cannon Status : ', currstat);
// WriteLn('+----------------------------------------------------');
StatsDebugTick := GetTickCount();
end;
end;
procedure spellWaitLoop();
var
T: TTimeMarker;
begin
T.Start;
repeat
WaitEx(200,50);
until((Spells.IsOpen = true)) or (T.GetTime > RandomRange(10000,80000));
end;
procedure invWaitLoop();
var
T: TTimeMarker;
begin
T.Start;
repeat
WaitEx(200,50);
until((Inventory.IsOpen = true)) or (T.GetTime > RandomRange(10000,80000));
end;
procedure cannonFire();
begin
//Mouse.Move(IntToBox(240, 250, 305, 120));
findcannon();
WaitEx(400,250);
if MainScreen.IsUpText('Alchemy') then
begin
Mouse.Click(mouse_Left);
WaitEx(1000,250);
end;
if MainScreen.IsUpText('multicanno') then
Mouse.Click(mouse_Left);
cannontimer := SRL.GaussRand(40000,20000);
WaitEx(1000,400);
end;
procedure safety();
begin
spellWaitLoop();
if MainScreen.IsUpText(['Onyx', 'bolts', '(e)']) then
if MainScreen.IsUpText(['Alchemy', 'Cast']) then
Mouse.Click(mouse_Left);
if not Spells.IsOpen(1000) then
begin
//writeln('spells not open, opening');
Gametabs.Open(tabMagic, 5);
WaitEx(500,100);
spellWaitLoop();
Mouse.Move(IntToBox(705, 245, 715, 225));
end;
if Spells.IsOpen(1000) then
begin
if not MainScreen.IsUpText(['Alchemy', 'Cast'], 1200) then
begin
//writeln('spells open but alch not detected, moving mouse');
Mouse.Move(IntToBox(705, 245, 715, 225));
end;
if not MainScreen.IsUpText(['Alchemy', 'Cast'], 1200) then
begin
//writeln('spells open but still no alch, failsafe');
Gametabs.Open(tabMagic, 5);
Mouse.Move(IntToBox(705, 245, 715, 225));
end;
end;
if not MainScreen.IsUpText('Alchemy', 1200) then
begin
killCannon();
Logout.ClickLogout();
TerminateScript('Alchemy not found');
end;
end;
function setUp(): boolean;
begin
clearDebug;
SRL.Setup([]);
declarePlayers();
if (not SRL.isLoggedIn) then
begin
Players.LoginCurrent();
MainScreen.setAngle(True);
end;
Gametabs.Open(tabInventory, 5);
Inventory.IsOpen(10000);
dtmcheck();
findnats := Inventory.FindDTM(nats);
natslot := findnats[0];
natbox := Inventory.GetSlotBox(natslot);
startnats := SRL.GetItemAmount(natbox);
cannonFire();
cannontimer := SRL.GaussRand(40000,15000);
TCannon1.Start;
ballstart := SRL.GetItemAmount(Inventory.GetSlotBox(15));
WaitEx(1000,400);
Gametabs.Open(tabMagic, 5);
Spells.IsOpen(10000);
WaitEx(1000,400);
Result := True;
end;
begin
if setUp then
begin
while srl.isLoggedIn() do
begin
begin
safety();
WaitEx(500,300);
Mouse.Click(mouse_Left);
invWaitLoop();
WaitEx(500,300);
invWaitLoop();
dtmcheck();
if MainScreen.IsUpText(['Onyx', 'bolts', '(e)'], 10000) then
if MainScreen.IsUpText(['Alchemy', 'Cast'], 1200) then
begin
ball1 := ballstart - SRL.GetItemAmount(Inventory.GetSlotBox(15));
Process();
Mouse.Click(mouse_Left);
end;
end;
if chatbox.FindTextOnLines(['cannon has'], [7]) then
begin
WaitEx(400,250);
cannonFire();
WaitEx(2000,1000);
Gametabs.Open(tabMagic, 5);
Case (Random(2)) of
0:currstat := 'Fixed cannon but not reloading';
1:begin
currstat := 'Fixed and reloaded cannon';
if MainScreen.IsUpText('multicanno') then
begin
cannonFire();
TCannon1.Reset();
TCannon1.Start;
end;
end;
end;
end;
if chatbox.FindTextOnLines(['cannon is out'], [7]) then
begin
Case (Random(2)) of
0:currstat := 'Out of ammo but not reloading';
1:begin
currstat := 'Out of ammo, reloading';
WaitEx(400,250);
cannonFire();
TCannon1.Reset();
TCannon1.Start;
WaitEx(2000,1000);
Gametabs.Open(tabMagic, 5);
end;
end;
end;
if (TCannon1.GetTime > cannontimer) then
begin
currstat := 'Reloaded due to firing timer';
WaitEx(400,250);
cannonFire();
TCannon1.Reset();
TCannon1.Start;
WaitEx(2000,1000);
Gametabs.Open(tabMagic, 5);
safety
end;
end;
end;
writeln('Script finished');
end.