Code:
program DaiRuneCrafter;
{$DEFINE SMART}
{$i srl/srl/misc/smart.simba}
{$i srl/srl.simba}
{$i ObjectDTM\ObjDTMInclude.simba}
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := ''; // Username
Pass := ''; // Password
Nick := ''; // 3-4 lowercase letters from username; used for random event detection
Pin := ''; // Leave blank if the player doesn't have a bank pin
Active := True;
end;
end;
Const
ScriptVersion = '0.10';
ScriptName = 'DaiRuneCrafter';
Var
EssUsed,RunesCrafted,TotalCrafted:Integer;
function CountRunes:Integer;
var
Box: TBox;
begin
Box := InvBox(1);
Result:=GetAmountBox(Box);
end;
procedure Setup; // Setup Smart, SRL and DTM. Logs the player in if he's not.
begin
Smart_Server := 10;
Smart_Members := false;
Smart_Signed := True;
ClearDebug;
SetupSRL;
DeclarePlayers;
if not (LoggedIn) then
LoginPlayer;
FindNormalRandoms;
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);
SetRun(True);
ObjDTM_Setup;
ObjDTM_Debug := False;
end;
procedure Antiban; // Mostly Daazndagger's Fletcher anti-ban which I liked a lot.
var
x: Integer;
begin;
if not (LoggedIn) then Exit;
Writeln('Perfoming antiban');
x:= Random(100);
case x of
10, 20, 30, 40: HoverSkill('runecrafting', false);
//20, 25: RandomMovement;
//30, 40: RandomAngle(SRL_ANGLE_HIGH);
50: PickUpMouse;
60: RandomRClick;
70: ExamineInv;
//80: BoredHuman;
end;
case x of
10, 15, 20, 25, 30, 40, 50, 60, 70:
begin
Wait(RandomRange(250, 1000));
GameTab(Tab_Inv);
end;
end;
end;
procedure Banking; // Deposits everything if player has anything in inventory, then withdraws everything from first bank slot.
var
i: Integer;
begin;
if not LoggedIn then Exit;
Antiban;
if OpenBankFast('vwb') then
if InvCount>0 then // If the player's inventory is not empty, deposits all
begin
DepositAll;
end else
FixBank;
for i:=1 to 5 do // Tries to withdraw essences from the first bank slot 5 times before giving up.
begin
if Withdraw(0, 0, 0) then
Break;
if i>=5 then
begin
Writeln('Could not withdraw essences.'+IntToStr(i));
Exit;
end;
end;
end;
procedure Resting; // Checks if rest is needed then listen to the musician if needed. Used parts of Deadly's procedure.
var
x,y: Integer;
begin
if not loggedin then exit;
FindNormalRandoms;
DidRedClick;
begin
if (Not runenergy(30)) then // If the player doesn't have a minimum of 30 energy, rest at the musician.
begin
writeln('Need rest!')
wait(500+Random(500));
If FindObjCustom(x, y, ['Talk', 'alk'], [14464635, 9469760, 4297607], 10) then
begin
Getmousepos(x, y)
begin;
MMouse(x, y, 3, 3);
ClickMouse2(False);
Waitoption('isten', 3000);
Writeln('Resting...')
Antiban;
Wait(8000+Random(5000));
Antiban;
RestUntil(95)
SetRun(True);
end;
end;
end else;
writeln('Player does not need rest');
end;
end;
procedure WalkToAltar; // Walks to the altar, stops at the musician for rest if needed.
var
Path: TStringArray;
I: Integer;
begin
writeln('Adjusting the view...')
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH)
writeln('Checking if run is on...')
SetRun(True);
Path := ['80:80:6:0:7:83:37:1:7:49:96:10:7:69:53:10:7:116:49:10:7:116:74:10:7:69:70:4:76:51:74:95:103:95:106:50',
'79:109:6:1:7:48:96:10:7:116:74:10:7:116:57:10:7:69:79:0:7:83:37:10:7:69:61:4:72:103:72:112:89:111:85:103',
'45:79:5:1:7:53:66:10:7:73:61:10:7:73:40:10:7:120:53:0:7:53:118:4:40:76:39:85:52:85:51:76',
'43:97:3:0:7:92:118:1:7:57:108:1:7:91:67:4:38:94:49:93:46:104:37:105',
'43:92:4:10:7:36:91:1:7:70:108:1:7:95:91:1:7:107:112:5:45:87:39:88:38:95:49:95:50:87',
'46:112:4:1:7:45:91:1:7:107:99:10:7:73:83:1:7:94:112:4:43:107:42:116:52:115:49:106',
'40:104:6:10:7:109:55:1:7:62:67:1:7:82:63:1:7:58:99:1:7:46:63:1:7:42:83:4:34:100:34:107:46:109:49:100',
'61:100:5:1:7:74:87:1:7:102:115:1:7:86:63:1:7:102:79:3:7:80:111:4:60:91:63:116:67:109:64:88']
WriteLn('Checking if player is in Varrock West Bank...');
if ObjDTM_InArea(Path[0], True) then
begin
WriteLn('Player is in Varrock West Bank.');
if InvCount<28 then // If the player is not full (of essences), start the banking procedure to get essences.
begin
Banking;
end;
for I := 1 to 4 do // Walk to the musician then stops.
begin
ObjDTM_Walk(Path[i], 0, 100, 80, True);
end;
begin
writeln('Checking if player needs rest...')
Resting;
end;
for I := 5 to 7 do // Resume path to the altar.
begin
ObjDTM_Walk(Path[i], 0, 100, 80, True);
end;
if ObjDTM_InArea(Path[High(Path)], True) then
WriteLn('Reached altar.');
end else
begin
WriteLn('Player not in bank');
Exit;
end;
end;
procedure EnterRuins; // Finds and enter the Mysterious Ruins.
var
x,y: Integer;
begin
if not loggedin then exit;
FindNormalRandoms;
Antiban;
DidRedClick;
if InvCount>1 then // Enter the ruins if the player has not yet crafted any runes (has something other than air runes in inventory).
begin
If FindObjCustom(x, y, ['Ent', 'er My'], [16631951, 16629135, 16171659, 14925721, 16499851], 15) then
begin
Writeln('Entered the ruins.');
Getmousepos(x, y);
if IsUpText('nter') then
begin
MMouse(x, y, 8, 8);
ClickMouse2(True);
Wait(2000+random(500));
end else
begin
Writeln('Could not find the ruins.');
Exit;
end;
end;
end;
end;
function CraftRunes:Boolean;
Var
x,y,Altar,i: integer;
begin
if not loggedin then exit;
FindNormalRandoms;
DidRedClick;
if InvCount>1 then // Crafts runes if the player has not yet done so (has something other than air runes in inventory).
for i:=1 to 5 do // Since this function is a little buggy at the moment, I have it try 5 times.
begin
Altar:=DTMFromString('mrAAAAHic42BgYGhlYmCoA+IaIF4MxEuAOBWI24H4FBA3AtXkAPEMIK4H4sVA3A7EZ4H4AhCnpCQwhAWHM2TmZDDExEQwtHe3MqRmpDCUlOQzNDXVMGgA1UiiYQ0kzEgAwwAAsqoUgA==');
Result:=False;
if i>=5 then
begin
FreeDTM(Altar);
Writeln('Could not find the altar.');
Exit;
end;
if FindDTM(Altar,x,y,MSX1,MSY1,MSX2,MSY2) then
begin
Mouse(x,y,2,2,mouse_Left);
Result:=True;
FreeDTM(Altar);
Antiban;
Writeln('Crafted Air runes.');
EssUsed:= EssUsed + 28; // Adds a full inventory of essence to the variable to calculate to total amount of essences used.
Wait(4500+random(500));
RunesCrafted:= CountRunes; // Counts the number of runes in the first inventory slot and put it in RunesCrafted.
TotalCrafted:= TotalCrafted + RunesCrafted; // Takes the Current total of crafted air runes and adds up the amount of runes you just crafted.
RunesCrafted:= 0; // Resets the variable after having used its number.
Exit;
end;
end;
end;
procedure LeaveRuins; // Leave Ruins procedure almost entirely taken from Deadly's, I'm not familiar with TPA. It seems to be quite buggy also.
var
X,Y,I: Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
Begin
if not loggedin then exit;
FindNormalRandoms;
Antiban;
DidRedClick;
begin
FindColorsTolerance(TPA, 5081226, MSX1, MSY1, MSX2, MSY2, 10);
ATPA := TPAToATPAEx(TPA, 28, 28);
For I := 0 To High(ATPA) Do
Begin
If MiddleTPAEx(ATPA[I], X, Y) Then
begin
MMouse(X, Y, 2, 2);
ClickMouse2(True);
Writeln('Leaving the ruins.');
Wait(2500+random(500));
End;
End;
End;
End;
procedure WalkToBank; // Running back to the bank after having crafted some runes. Rests if needed.
var
Path: TStringArray;
I: Integer;
begin
writeln('Adjusting the view...')
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH)
writeln('Checking if run is on...')
SetRun(True);
Path := ['80:80:6:1:7:102:55:1:7:98:98:1:7:58:90:1:7:54:38:3:7:108:79:3:7:44:55:11:50:50:51:80:63:93:93:97:114:92:120:80:125:63:122:46:104:35:82:22:58:29',
'116:76:6:1:7:49:102:1:7:46:49:1:7:94:67:1:7:89:111:3:7:36:66:3:7:100:92:4:103:74:109:86:125:79:123:73',
'104:51:5:3:7:63:95:1:7:58:70:1:7:110:104:1:7:86:100:1:7:74:71:4:98:55:98:46:116:46:119:50',
'111:48:5:10:7:114:45:1:7:87:54:1:7:69:115:1:7:66:58:1:7:49:99:4:107:41:104:55:113:51:113:45',
'127:74:5:10:7:86:78:1:7:57:87:1:7:120:96:1:7:107:109:1:7:58:37:4:116:73:118:86:133:79:130:67',
'106:56:5:10:7:40:83:1:7:74:100:1:7:61:112:1:7:90:120:1:7:73:125:4:99:58:112:52:112:63:97:62',
'132:76:4:1:7:109:62:1:7:74:104:0:7:108:114:1:7:86:126:4:122:73:122:83:140:80:137:71',
'90:50:5:0:7:57:118:10:7:77:49:10:7:77:40:10:7:77:31:1:7:57:66:4:87:49:100:47:100:60:87:58']
WriteLn('Checking if player is outside Air Altar...');
if ObjDTM_InArea(Path[0], True) then
begin
WriteLn('Player is outside Air Altar.');
for I := 1 to 3 do
begin
ObjDTM_Walk(Path[i], 0, 100, 80, True);
end;
begin
writeln('Checking if player needs rest...') // Stops on the way back too except it's after 3 steps this time.
Resting;
end;
for I := 4 to 7 do
begin
ObjDTM_Walk(Path[i], 0, 100, 80, True);
end;
if ObjDTM_InArea(Path[High(Path)], True) then
WriteLn('Reached bank.');
end else
begin
WriteLn('Player not outside Air Altar.');
Exit;
end;
end;
procedure ProgressReport; // Reports the current stats. Template mostly taken from Daazndagger.
var
exp:Integer;
begin
exp:=EssUsed*5;
ClearDebug;
Writeln('/-------------------------------------------------------------\');
Writeln('|-------------------------------------------------------------|');
Writeln(PadR('| DaiRuneCrafter', 62) + '|');
Writeln(PadR('| Version ' + ScriptVersion, 62) + '|');
Writeln('|-------------------------------------------------------------|');
Writeln(PadR('| Time Running : ' +MsToTime(GetTimeRunning, Time_Abbrev), 62) + '|');
Writeln(PadR('| Airs Made: ' +IntToStr(TotalCrafted), 62) + '|');
Writeln(PadR('| Exp Gained: '+IntToStr(exp), 62) + '|');
Writeln(PadR('| Exp/Hour: '+IntToStr((exp*60/((GetTimeRunning/60000)+1))), 62) + '|');
Writeln(PadR('| ', 62) + '|');
Writeln('|-------------------------------------------------------------|');
Writeln('\-------------------------------------------------------------/');
//Stats_IncVariable('Crafted', TotalCrafted + 'Air Runes); //These will be useful if I eventually implement SRL Stats
//Stats_IncVariable('Runecrafting EXP (Gained)',exp);
//Stats_Commit;
end;
begin // Begins the procedures and repeats.
Setup;
DeclarePlayers;
repeat
WalkToAltar;
EnterRuins;
CraftRunes;
ProgressReport;
LeaveRuins;
WalkToBank;
until(false)
ProgressReport;
FreeSRL;
end.
And... That's pretty much it. You can be pretty much wherever in Varrock's bank, it should detect it anyway, it will use any bank booth it finds. It will detect if you need rune essence or if you need to deposit your runes.