SRL Archive - First Scripts

My First - High Alchr


guyver

2008-10-15 20:34:29

Hi All!!
This is my first script and would like any and all to give comments please.
As you can see its not quite finished. Hopefully this will work anywhere and I will let you all know when done and tested.

CHEERS!!:eek:




//  Just a simple High Alchr//
// Start in a bank. Enter Player Details//
// This will get either a fire staff, lava staff, staff of fire//
// or fire runes and nats out of bank. Sorry doesn't look for lava runes.//
// Make sure u have the items to alch noted and in inv at spot 1//
// Thats the top Left//
// As usual keep an eye on how this goes//
// A progress counter is included//
// ENJOY!!!!!//

program AlchMe;
begin
{.include SRL\SRL.scar}

const
DirrectionR = 'N'; //Which way to run if in fight and so on.
PickSkill = 'Magic';

Var
LavaStaffDTM, FireStaffDTM, StaffFireDTM, FireRuneDTM, NatureRuneDTM, x, y: Integer;
NoLava, NoFireSt, NoStaff, NoFires, NoNats, AllOk, NoneLeft: Integer;

procedure DeclarePlayers; //Only use players you have.Comment out rest
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);

Players[0].Name := 'YourName';
Players[0].Pass := 'LoginPass';
Players[0].Nick := 'our'; //3 letters of your username, example jonno you would choose onn.
Players[0].Pin := 'IfHaveOne';
Players[0].Active := True;

//Players[1].Name := '';
//Players[1].Pass := '';
//Players[1].Nick := ''; //3 letters of your username, example jonno you would choose onn.
//Players[1].Active := True;

Players[CurrentPlayer].NickTPA := CreateTPAFromText(Players[CurrentPlayer].Nick, UpChars);
end;

procedure LoadMyDTMs;
begin
LavaStaffDTM := DTMFromString('78DA63946460608864400189D151609A1188F' +
'F030123484D2CAA9AF88808B81A302D0A24A2709B03A641E68411' +
'50238BDF3D200000097D0BAA'); //change
FireStaffDTM := DTMFromString('78DA63FCC6C8C050C38002624394C0345086E' +
'13F1030BE07B26A71AB01D35F81AC52543591010AA86AFE0059D5' +
'04CCF90E6435E2570300A9E30F58'); //change
StaffFireDTM := DTMFromString('78DA63946460608864400189D151609A1188F' +
'F030123484D2CAA9AF88808B81A302D0A24A2709B03A641E68411' +
'50238BDF3D200000097D0BAA'); //change
FireRuneDTM := DTMFromString('78DA63FCC6C8C050C38002624394C0345086E' +
'13F1030BE07B26A71AB01D35F81AC52543591010AA86AFE0059D5' +
'04CCF90E6435E2570300A9E30F58'); //change
NatureRuneDTM := DTMFromString('78DA63946460608864400189D151609A1188F' +
'F030123484D2CAA9AF88808B81A302D0A24A2709B03A641E68411' +
'50238BDF3D200000097D0BAA'); //change
end;

procedure FindLavaSInBank;
begin
if FindDTM(LavaStaffDTM, x, y, 20, 20, 600, 300) then //Searches Bank Screen
begin
Mouse(x, y, 1, 1, False); // False is Right click
Flag;
ChooseOption('1');
FreeDTM(LavaStaffDTM);
end else
begin
WriteLn('No Lava Staff in Bank');
FreeDTM(LavaStaffDTM);
NoLava := 1;
end;
end;

procedure FindFireSInBank;
begin
if FindDTM(FireStaffDTM, x, y, 20, 20, 600, 300) then //Searches thru whole inventory
begin
Mouse(x, y, 1, 1, False); // False is Right
Flag;
ChooseOption('1');
FreeDTM(FireStaffDTM);
end else
begin
WriteLn('No Fire Staff in Bank');
FreeDTM(FireStaffDTM);
NoFireSt := 1;
end;
end;

procedure FindStaffInBank;
begin
if FindDTM(StaffFireDTM, x, y, 20, 20, 600, 300) then //Searches thru whole inventory
begin
Mouse(x, y, 1, 1, False); // False is Right
Flag;
ChooseOption('1');
FreeDTM(StaffFireDTM);
end else
begin
WriteLn('No Staff of Fire in Bank');
FreeDTM(StaffFireDTM);
NoStaff := 1;
end;
end;

procedure FindFireRInBank;
begin
if FindDTM(FireRuneDTM, x, y, 20, 20, 600, 300) then //Searches thru whole inventory
begin
Mouse(x, y, 1, 1, False); // False is Right
Flag;
ChooseOption('All');
FreeDTM(FireRuneDTM);
end else
begin
WriteLn('No Fire Runes in Bank');
FreeDTM(FireRuneDTM);
NoFires := 1;
end;
end;

procedure FindNatureInBank;
begin
if FindDTM(NatureRuneDTM, x, y, 20, 20, 600, 300) then //Searches thru whole inventory
begin
Mouse(x, y, 1, 1, False); // False is Right
Flag;
ChooseOption('All');
FreeDTM(NatureRuneDTM);
end else
begin
WriteLn('No Nature Runes in Bank');
FreeDTM(NatureRuneDTM);
NoNats := 1;
end;
end;

Procedure BankCheck;
begin
SetRun(True);
wait(700 + Random(150));
if(FindSymbol(x,y,'bank'))then
begin
Writeln('Bank found. Running to Bank');
MMouse(x, y, 5, 5);
wait(100+random(50));
Mouse(x, y, 1, 1, true);
wait(5000+random(1000));
if FindObjCustom(x, y, ['se Ba', 'ank b', 'oth'], [605264, 3685438, 2313826, 6192526], 3) then
begin
MMouse(x,y,5,5);
wait(100+random(50));
Mouse(x,y,1,1,False);
wait(1000+random(500))
if ChooseOption('se-q') then
begin
wait(600 + Random(200));
if (PinScreen) then
begin
InPin(Players[0].Pin);
end;
wait(500 + Random(500));
FixBank;
wait(700 + Random(130));
FindLavaSInBank;
wait(400 + Random(200));
FindFireSInBank;
wait(300 + Random(120));
FindStaffInBank;
wait(800 + Random(330));
FindFireRInBank;
wait(500 + Random(240));
AllOk = NoLava + NoFireSt + NoStaff + NoFires;
if (not (AllOk = 4))
begin
FindNatureInBank;
end else CloseBank;
end;
end else WriteLn('Cannot find the Bank Booth');
end else
begin
writeLn('Cannot Find Bank Icon..Moving Position. Loging out then In');
Mouse(x + 450, y + 170, 10, 10, true); //Moves to another spot to look again West to East//
Flag;
Logout;
LoginPlayer;
end;
end;

procedure MagicAway;
begin
GameTab(4);
//Count number of nature runes
//make noneleft = this amount
if (not (NoneLeft = 0)
repeat
begin
GameTab(7);
//FindText 'Level 55', 'High'
//select 'high alch'
//select item at spot 1 in inv
//wait(3000 + Random(200);
//NoneLeft = NoneLeft - 1;
CheckForAllRandoms;
AntiBanme;
end
until (NoneLeft = 0)
end else Exit;
end;

procedure AntiBanme;
begin
case random(30) of // The larger the number the less AntiBann it does
0: GameTab(5 + Random(12));
1: BoredHuman;
2: begin
SetAngle(False); //Sets camera angle to low view
wait(10+random(10));
SetAngle(True); //Sets camera angle to high view
end;
3: HoverSkill('Magic', False);
4: GameTab(2 + Random(12));
5: RandomMovement;
6: RandomRClick;
7: PickUpMouse;
end;
end;

procedure CheckForAllRandoms;
begin
FindNormalRandoms;
FindInventoryRandoms;
FindNonInventoryRandoms;
FindTalk;
DwarfItem;
if FindFight then
begin
RunAway(DirrectionR, False, 1, 8000); //Runs away in direction 'N'
end; //then runs back after a wait
end;

//MAIN LOOP//
begin
SetupSRL;
ClearDebug;
ActivateClient;
DeclarePlayers;
LampSkill := PickSkill;
NoLava = 0;
NoFireSt = 0;
NoStaff = 0;
NoFires = 0;
NoNats = 0;
AllOk = 0;
if (not (loggedIn)) then
begin
LoginPlayer;
end;
if (RSReady) then
begin
LoadMyDTMs;
MakeCompass('n');
AntiBanme;
CheckForAllRandoms;
BankCheck; //gets items from bank
MagicAway; //start alch
wait(500);
end;
Logout;
end;
end.

joelster134

2008-10-16 01:16:21

put anti randoms+ anti ban into the alching procedure…otherwise therek ind of useless…good attempt for fisrt try keep up good work :)

guyver

2008-10-16 17:27:53

From: joelster134
put anti randoms+ anti ban into the alching procedure…otherwise therek ind of useless…good attempt for fisrt try keep up good work :)


Spot on! You are 100% right..what an oversite. :duh: Thanks for that. Anyone else wish to comment/criticise?

joelster134

2008-10-16 23:30:46

Add me to buddies if you want me to help you update it (if your c\gunna) :) [email]joelster134@hotmail.com…..but[/email] i think all SRL scripts are down atm.

A G E N T

2008-10-17 15:01:26

Good work :) Glad to see you are learning.
A few things to note - you might want to combine all of those staff checking functions into one big function - you could use repeated if..then's.
Second - where you have this (to go into the bank)

Writeln('Bank found. Running to Bank');
MMouse(x, y, 5, 5);
wait(100+random(50));
Mouse(x, y, 1, 1, true);
wait(5000+random(1000));
You shouldn't just wait for 5 or 6 seconds? What if the player lags or something, then the script won't work at all. There is a function in SRL just for this, it is called Flag. You can call Flag and it will wait until your character has reached the destination (marked on the minimap by a flag). So you can put:

Writeln('Bank found. Running to Bank');
MMouse(x, y, 5, 5);
wait(100+random(50));
Mouse(x, y, 1, 1, true);
Flag;

Third, remember that in SCAR, the assignment operator is := and the comparison operator is = .
For example, you have this:

AllOk = NoLava + NoFireSt + NoStaff + NoFires;
Which should be

AllOk := NoLava + NoFireSt + NoStaff + NoFires;
And you've done it a few more times.

Lastly, remember that the main loop has to be well… a loop :)
You have:

begin
SetupSRL;
ClearDebug;
ActivateClient;
DeclarePlayers;
LampSkill := PickSkill;
NoLava = 0;
NoFireSt = 0;
NoStaff = 0;
NoFires = 0;
NoNats = 0;
AllOk = 0;
if (not (loggedIn)) then
begin
LoginPlayer;
end;
if (RSReady) then
begin
LoadMyDTMs;
MakeCompass('n');
AntiBanme;
CheckForAllRandoms;
BankCheck; //gets items from bank
MagicAway; //start alch
wait(500);
end;
Logout;
end;
end.
But it should be more like:

begin
SetupSRL;
ClearDebug;
ActivateClient;
DeclarePlayers;
repeat // this is the main repeat
LampSkill := PickSkill;
NoLava = 0;
NoFireSt = 0;
NoStaff = 0;
NoFires = 0;
NoNats = 0;
AllOk = 0;
if (not (loggedIn)) then
begin
LoginPlayer;
end;
repeat // INSIDE BLOCK HERE
if (RSReady) then
begin
LoadMyDTMs;
MakeCompass('n');
AntiBanme;
CheckForAllRandoms;
BankCheck; //gets items from bank
MagicAway; //start alch
wait(500);
end;
until({ repeat until player has done enough loads, etc});
Logout;
until({ repeat main block until there are no more active players})
end;
end.


Overall good effort, keep trying and you will eventually have a good script. Good luck,

-Agent

A_Guy

2008-10-17 18:05:41

Impressive, might come in handy when I go for 94 mage :P

guyver

2008-10-18 19:46:53

From: A G E N T 83
Good work :) Glad to see you are learning.
A few things to note - you might want to combine all of those staff checking functions into one big function - you could use repeated if..then's.
Second - where you have this (to go into the bank)

Writeln('Bank found. Running to Bank');
MMouse(x, y, 5, 5);
wait(100+random(50));
Mouse(x, y, 1, 1, true);
wait(5000+random(1000));
You shouldn't just wait for 5 or 6 seconds? What if the player lags or something, then the script won't work at all. There is a function in SRL just for this, it is called Flag. You can call Flag and it will wait until your character has reached the destination (marked on the minimap by a flag). So you can put:

Writeln('Bank found. Running to Bank');
MMouse(x, y, 5, 5);
wait(100+random(50));
Mouse(x, y, 1, 1, true);
Flag;

Third, remember that in SCAR, the assignment operator is := and the comparison operator is = .
For example, you have this:

AllOk = NoLava + NoFireSt + NoStaff + NoFires;
Which should be

AllOk := NoLava + NoFireSt + NoStaff + NoFires;
And you've done it a few more times.

Lastly, remember that the main loop has to be well… a loop :)
You have:

begin
SetupSRL;
ClearDebug;
ActivateClient;
DeclarePlayers;
LampSkill := PickSkill;
NoLava = 0;
NoFireSt = 0;
NoStaff = 0;
NoFires = 0;
NoNats = 0;
AllOk = 0;
if (not (loggedIn)) then
begin
LoginPlayer;
end;
if (RSReady) then
begin
LoadMyDTMs;
MakeCompass('n');
AntiBanme;
CheckForAllRandoms;
BankCheck; //gets items from bank
MagicAway; //start alch
wait(500);
end;
Logout;
end;
end.
But it should be more like:

begin
SetupSRL;
ClearDebug;
ActivateClient;
DeclarePlayers;
repeat // this is the main repeat
LampSkill := PickSkill;
NoLava = 0;
NoFireSt = 0;
NoStaff = 0;
NoFires = 0;
NoNats = 0;
AllOk = 0;
if (not (loggedIn)) then
begin
LoginPlayer;
end;
repeat // INSIDE BLOCK HERE
if (RSReady) then
begin
LoadMyDTMs;
MakeCompass('n');
AntiBanme;
CheckForAllRandoms;
BankCheck; //gets items from bank
MagicAway; //start alch
wait(500);
end;
until({ repeat until player has done enough loads, etc});
Logout;
until({ repeat main block until there are no more active players})
end;
end.


Overall good effort, keep trying and you will eventually have a good script. Good luck,

-Agent


Thanks heaps for your input. All great suggestions. Have modified my script and will hopefully post a new version in the next couple of days. Can't wait to test this once new SRL released!!!
And thanks for all the other comments. Really appreciated.

Zego

2009-03-26 17:46:58

I can't copy paste your script in scar how do I use it? =\

ian.

2009-03-26 18:12:32

you highlight it all, press Ctrl C, then open a new SCAR and press Ctrl A then Ctrl V ;)

OR

download this..

boyofblue

2009-03-27 21:38:01

just what i need thanks… i will report back

I B X R

2009-03-28 18:18:57

Oh nice dude

purescar37

2009-05-13 21:20:24

i needed one of these thanks :)

Rich

2009-05-15 19:00:43

Ahem, sorry to be a party p00per, but didn't anyone notice the last post time before Zego posted?

10-19-2008, 12:46 AM

7 months!

EDIT: 600 posts! :norris:

Sir R. M8gic1an

2009-05-15 19:06:46

closed…

~RM