SRL Archive - First Scripts

Al-Karid Smelter


reddevil12312

2009-10-10 22:43:57

Okay, I got really bored, so I threw this little script together. When I say,"I threw this together," I'm talking like within like an hour's worth of work. It needs a lot of work, to be near flawless. I haven't read over it, and I'm sure that I left a few coordinates as 1, or a color as 1234. I do that a lot, because I don't like to switch in and back from coordinate grabbing and color picking, to scripting.Oh, and if you can find what I'm talking about, if the mouse clicks in a weird spot during any parts of the walking, it's just because the mouse functions of the coordinates of the DTM's need to be actually measured. YoHoJo helped with some of the walking.

My main account was banned, along with my other usable account, so I haven't been able to test it very much. I know that the script will at least work from the beginning. If someone could give it just a quick run threw and tell me all the easily seen bugs, I'd fix them. Oh, and I don't think i used the Procedure Smelt(bar, amount: string) right. I'll need to put in a timer for how to wait. If i need to credit people for all of the sections out of the SRL includes, someone tell me, and I will edit. I have Fall Break soon. I'll fix it up a lot better.

I'll probably put in all the extra's pretty soon. I know it's pretty crazy for it to only do iron at the moment, and not support Rings of Forging lol.

I was planning on putting this on the Free-For-All-Scripts Forum, so I planned on leaving it as basic as possible. I forgot about the whole banking thing though, so nope. anyways… Here's my turd:

Program AlKaridSmetler;
//~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
//
// > Al-Karid Ore Smelter <
// ***********************************
//
// INSTRUCTIONS
// *************
// 1. Start at Bank
// 2. Ore First slot in bank
// 3. A empty Inventory is best to start with
//
//
//
// NOTES
// *********
// TO COME, IF PEOPLE ASK FOR IT
// *******************************
// 1. Make MultiPlayer
// 2. Ability to Find ore any where in bank
// 3. Ability to use any ore, that people ask for
// 4. Ability to use rings of forging, if people ask
//
//
//~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
{.include SRL/SRL.scar}
{.include srl/srl/Skill/Smithing.scar}
{.include SRL/SRL/Misc///Reports.scar}
//~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


//~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
// SCRIPT SETUP
//~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*

Const OreCount = 1000; //Amount of ore to smelt
Const TotalTime = 60; //total time to auto. in minutes


//~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
// DECLARE PLAYERS
//~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


procedure DeclarePlayers;
begin
HowManyPlayers:= 1; //how many players
NumberOfPlayers(HowManyPlayers); //Number of players using howmanyplayers as a const
CurrentPlayer := 0; //Current player

Players[0].Name := 'UserName'; //username
Players[0].Pass := 'PassWord'; //password
Players[0].Nick := 'ser'; //3-4 letters of your username, no caps or first letter
Players[0].strings[3] := 'iron'; //iron only at the moment
Players[0].Active := true; //Active or not. Until Multiplayer, leave true
end;





//~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
// DONT TOUCH BELOW THIS
// *****************************
// Unless you know what you're doing
//~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*






Var
FirstInvCheck: Boolean;
BarsMade: integer;
// Quota:boolean;
ShopWalk1,ShopWalk2,BankWalk1, BankWalk2:integer;
// SW1Work, SW2Work, BW1Work, BW2Work:Boolean;
// DTMCheck:Boolean;


Procedure ScriptStart; //I have a lot left to do to this...
Begin
SetupSRL;
WriteLn('Script Setup is Good!');
end;




Procedure PlayerSetup;
begin
If not LoggedIn then
LoginPlayer;
If (InvCount > 0) then
Begin
Writeln('Banking On Start');
FirstInvCheck := False;
End Else
Begin
Writeln('Begining Script')
FirstInvCheck := True;
end;
end;

Procedure DeclareAllPics;
begin
ShopWalk1 := DTMFromString('78DA63DCC3C4C0D0C0C8800C9EBFFDC22002A' +
'461A28CDB88500332A78A809A1D403535A86A16B6E4A0A80100B3A50' +
'F2A');
ShopWalk2 := DTMFromString('78DA634C676260C862644006DE05660C5C401' +
'A26CA9801549347404D0E504D26AA9A43ABF350D52401D5A4E357030' +
'07087091A');
BankWalk1 := DTMFromString('78DA63F46662608861644006CFDF7E61E002D' +
'2305146909A60026AEC816A6209A8F104AA8944555319E38AAAC61DA' +
'8261ABF1A00B0C10DFD');
BankWAlk2 := DTMFromString('78DA63F4676260C8606440064736353370016' +
'99828A327504D26AA9A431B9A50D580CC494655737C6B1BAA9A504C3' +
'5187681CCC9C2AF0600E9450DB9');
End;


procedure AntiBan;
begin
if not LoggedIn then Exit;
case Random(15) of
0: wait(500+random(3000));
1: begin
RandomMovement;
SetAngle(true);
end;
3: PickUpMouse;
end;
end;


Procedure PreBank;
var T: integer;
Begin
If (FirstInvCheck = False) then
Begin
REPEAT
INC(T);
OpenBankFast('akb');
Until Bankscreen or (T=5);
end;
If Bankscreen then
Begin
DepositAll;
WithDraw(1,1,0);
end else
Begin
WriteLn('Could Not Find Bank!!!')
WriteLn('Script Closing');
TerminateScript;
end;
end;



Procedure Report;
Begin
WriteLn(' Al-Karid Auto Smelter' + 'Made By RedDevil');
Writeln('*********************************************');
Writeln('Time Running' + TimeRunning);
Writeln('Bars Made' + IntToStr(BarsMade));
WriteLn('**********************************************');
WriteLn('I was to lazy to make a good progress...sorry');
end;


Procedure Banking;
var TP:TPoint;
Begin
TP := BankIndexToMSPoint(1); //did this cause i was to lazy to find coords
FindNormalRandoms;
Writeln('Atempting to Bank');
If OpenBankFast('akb') then //main If Statement
Begin
WaitFunc(@Bankscreen, 25, 3000);
Wait(1000+random(700));
DepositAll;
AntiBan;
Wait(1000+random(700));
WithDraw(1,1,0);
Wait(1000+random(700));
If not (InvCount= 28) then
begin
If ((InvCount + GetAmount(TP.x,TP.y))< 28) Then //Reason for tpoint above
Begin
WriteLn('Ran Out Of Ore')
CloseBank;
AntiBan;
LogOut;
TerminateScript;
End Else
Begin
wait(1000+random(500));
Withdraw(1,1,0);
WriteLn('Continued After Bank Check');
CloseBank;
FindNormalRandoms;
End;
End;
End Else
Begin
LogOut;
WriteLn('Can Not Find Bank!!!');
WriteLn('Script Terminated!!!')
Report;
TerminateScript;
end;
End;






Procedure SmeltingTime;
var InvTotal:integer;
Begin
InvTotal := InvCount;
If OpenFurnace then
Begin
Wait(1200+Random(600));
Smelt(Players[0].strings[3],'28');
Wait(1200+Random(600));
BarsMade := (BarsMade + InvTotal);
AntiBan;
FindNormalRandoms;
End Else
Begin
WriteLn('Could Not Find Furnace');
WriteLn('Script Terminated')

Report;
TerminateScript;
End;
End;

Function WAlktoFurnace: Boolean;
var x,y,x2,y2:Integer;
Begin
If DTMRotated(ShopWalk1,x,y,MMX1,MMY1,MMX2,MMY2) Then
Begin
Mouse((x+4),(y+5),4,5, true);
FFlag(8);
End Else
Begin
If DTMRotated(ShopWalk2,X,Y, MMX1,MMY1,MMX2,MMY2) Then
Begin
Mouse((x+2),(y+7),3,4,True);
FFlag(5);
End Else
Begin
WriteLn('Shop DTMs dont Work!');
LogOut;
Report;
TerminateScript;
End;
End;
//End of First Step of the Walking
If FindSymbol(X2,Y2,'furnace') Then
Begin
Result := True;
Mouse(X2,(Y2+6),3,3,True);
If FlagPresent Then
Begin
FFlag(0);
WriteLn('Succesfully Made Trip to Furnace');
Wait(0+random(2000));
Exit;
End Else
Begin
MFF(X2, Y2, 1, 1)
WriteLn('Finally Found Symbol');
End;
End Else
Begin
WriteLn('Could Not Find Furnace Symbol');
LogOut;
Report;
TerminateScript;
End;
End;






Function WAlktoBank: Boolean;
var x,y,x2,y2:Integer;
Begin
If DTMRotated(BankWalk1,x,y,MMX1,MMY1,MMX2,MMY2) Then
Begin
Mouse((x+4),(y+5),4,5, true);
FFlag(8);
FreeDTM(BankWalk1);
End Else
Begin
If DTMRotated(BankWalk2,X,Y, MMX1,MMY1,MMX2,MMY2) Then
Begin
Mouse((x+2),(y+7),3,4,True);
FFlag(5);
End Else
Begin
WriteLn('Bank DTMs dont Work!');
LogOut;
Report;
TerminateScript;
End;
End;
//End of First Step of the Walking
If FindSymbol(X2,Y2,'bank') Then
Begin
Result := True;
Mouse(X2,(Y2+6),3,3,True);
If FlagPresent Then
Begin
FFlag(0);
WriteLn('Succesfully Made Trip to Bank');
Wait(0+random(2000));
Exit;
End Else
Begin
MFF(X2, Y2, 1, 1)
WriteLn('Finally Found Symbol');
End;
End Else
Begin
WriteLn('Could Not Find Bank Symbol');
LogOut;
Report;
TerminateScript;
End;
End;










//********Main Operation************\\

Begin
ScriptStart;
DeclarePlayers;
PlayerSetup;
DeclareAllPics;
PreBank;
Repeat
Banking;
WalkToFurnace;
SmeltingTime;
WalkToBank;
Until (BarsMAde>OreCount) or (GetTimeRunning > (TotalTime * 60000));
End.

Standards need fixing. It really hasn't even been tested. I just thought I'd make an early post of it. If someone wants to point something out to me such as a better way to do something, PM me please. If I had time, I wanted to upgrade it to TPA walking, but with school, it's been hard to finish it.

JAD

2009-10-10 23:18:52

In PlayerSetup:


If (InvCount > 0) then
Begin
Writeln('Banking On Start');
FirstInvCheck := False;
End Else
Begin
Writeln('Begining Script')
FirstInvCheck := True;
end;

Could be:


FirstInvCheck := InvCount > 0;
if(FirstInvCheck)then
Writeln('Beginning Script') else
Writeln('Banking On Start');

In PreBank:


If (FirstInvCheck = False) then
Begin
REPEAT
INC(T);
OpenBankFast('akb');
Until Bankscreen or (T=5);
end;

Could take advantage of a for to do loop:


If (FirstInvCheck = False) then
for T := 1 to 5 do
OpenBankFast('akb');
I would also suggest adding a wait in there between checks though, or else it could cause some serious lag. You could also try using some other SRL open bank functions such as OpenBank, OpenBankQuiet, and OpenBankGlass as fail safes.



In PreBank, you also terminate the script if it's not at the bank screen. Why not have it just log out so you can switch players?


You're missing some if not loggedin then Exit;'s in procedures like Banking and PreBank.


In Banking, why do you call OpenBankFast instead of your PreBank procedure to open the bank?


In the walking, when looking for the furnace symbol, you could do something like:

MarkTime(T);
while not findsymbol do
begin
wait(500+random(500));
if(TimeFromMark(T) > 5000+random(2000))then break;
end;

In case it is covered. Or you could keep increasing the symbol accuracy each time too if you want.

I would suggest learning DTM's for your walking instead of static DTM's. Much more reliable in dynamic locations such as the mini map and main screen.



At the end of your main loop, if not loggedin then NextPlayer(False) could be used to switch players.





I like how you have all of those fail safes and make sure not to have any infinite loops. With a little more effort and learning, I think that this script could be good enough for members soon enough. Just keep at it, and if you have any questions, you can feel free to add me on msn: [email]runescapemacro@hotmail.com[/email]

Cheers!
~JAD