Macros
2008-11-08 14:47:34
::SEE POST 22 FOR THE MOST RECENT SCRIPT VERSION::
::script works well, but is not the most updated version by far, (SRL Jr script soon)::
Hey, this is my first ever script, it works great, (I've made over 400 bars just debugging it etc), but I have a few questions to help make it better:
1. Is there a difference between "terminatescript" and "exit"?
2. I have two methods of withdrawing stuff from the bank, (in the script-lines 144-184), which one is better?
3. When I raise the PlayerSuperheats, (number of superheats to cast before exiting), above to 10, the script never stops, but at 5, it only does 5 Superheats, (as expected), and then stops… What's wrong?!
4. The compass directioning stuff doesn't seem to work for any direction besides North, (if you put it on East, it goes to almost North)?!
5. The mouse speeds seems to vary a lot, some of which seem dangerously fast, how can I fix this?
6. The progress report always says that it only banked once?! How can I fix this?
7. After the desired amount of superheats are done, the script should log you out and terminate, only it skips the logout stage for some reason!
Of course if you see anything else wrong with it, or even just weird, (ie, odd place meant of var declarations, or procedures etc), please tell me! After all, this is my first script…
Thanks, Macros
PS, the forum formats code weirdly, this script looks nicer in SCAR…
::script works well, but is not the most updated version by far, (SRL Jr script soon)::
Hey, this is my first ever script, it works great, (I've made over 400 bars just debugging it etc), but I have a few questions to help make it better:
1. Is there a difference between "terminatescript" and "exit"?
2. I have two methods of withdrawing stuff from the bank, (in the script-lines 144-184), which one is better?
3. When I raise the PlayerSuperheats, (number of superheats to cast before exiting), above to 10, the script never stops, but at 5, it only does 5 Superheats, (as expected), and then stops… What's wrong?!
4. The compass directioning stuff doesn't seem to work for any direction besides North, (if you put it on East, it goes to almost North)?!
5. The mouse speeds seems to vary a lot, some of which seem dangerously fast, how can I fix this?
6. The progress report always says that it only banked once?! How can I fix this?
7. After the desired amount of superheats are done, the script should log you out and terminate, only it skips the logout stage for some reason!
Of course if you see anything else wrong with it, or even just weird, (ie, odd place meant of var declarations, or procedures etc), please tell me! After all, this is my first script…
Thanks, Macros
PS, the forum formats code weirdly, this script looks nicer in SCAR…
program SuperheatMithril;
{.include SRL/SRL.scar}
{.include SRL/SRL/skill/magic.scar}
{---------------------------------------------------------------------------]
[ d[-_-]b :: Mithril Superheater :: d[-_-]b ]
[---------------------------------------------------------------------------]
[ Created by: Macros, for Scar 3.15+ and SRL 28+ ]
[ Last Update : 11/8/2008 ]
[ ]
[ 1. Customize the basic setup, and player array. ]
[ 2. Use with Low Detail, Very Bright. ]
[ 3. Equip a Fire Staff. ]
[ 4. Position player in desired bank, (see basic setup). ]
[ 5. Have an adequate amount of Nature Runes in the last inventory space. ]
[ 6. Put any item in the first bank space, mithril ore in the second ]
[ and coal in third, (in the first, (infinity symbol), tab). ]
[ 7. Strongly suggested that you place one Mithril Ore in the twelfth ]
[ inventory spot, (right on top of the Superheat spell). ]
[---------------------------------------------------------------------------}
{------------------------------------------------------------------------------]
Basic script setup.
-------------------------------------------------------------------------------}
var
MithrilBarDTM, SuperheatDTM, MithrilOreDTM, CoalDTM,
l, loads, x, y: integer;
const
StartPlayer = 0; //Determines who will play first.
MSpeed = 50; //Speed of the mouse, (higher=faster, recommended 40-60).
DropRandomItems = False; //Drop the items you get from random events, such as gems and coins?
BankName = 'veb'; //Search for "OpenBankQuiet" in the SRL Manual for a list of valid abbreviations.
RandomSkill = 'Prayer'; //Which skill would you like to use Genie Lamps on, (if any are recieved).
CompassDirection = 'N'; //Insert a direction that will show lots of bank windows in your desired bank, (first letter only).
PlayerSuperheats = 10; //How many Mithril Bars would you like to superheat?
Version = '0.2'; //Script version, (don't change).
//YourSRLID = 'Username'; //Your SRL User ID. (for when the script is done)
//YourSRLPass = 'Password'; //Your SRL User Pass. (for when the script is done)
{------------------------------------------------------------------------------]
Declare Players
-------------------------------------------------------------------------------}
procedure DeclarePlayers; //More arrays when script is done...
begin
HowManyPlayers := 1; //Set Number of Players here.
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := StartPlayer;
Players[0].Name := 'Username'; //Username
Players[0].Pass := 'Password'; //Password
Players[0].Nick := 'Nickname'; //3-4 consecutive letters of your user name, (ex: "Nickname" -> "ick").
Players[0].Strings[0] := 'mithril'; //Type of bar, (only use with mithril at the moment).
Players[0].Active := True; //Say, are you going to use this player?
end;
{------------------------------------------------------------------------------]
NO NEED TO CHANGE ANYTHING BELOW THIS LINE... Hit run and post proggies!
[------------------------------------------------------------------------------}
{------------------------------------------------------------------------------]
AntiBan!
[------------------------------------------------------------------------------}
procedure AntiBan;
begin
if not LoggedIn then Exit;
case Random(10) of
1: HoverSkill('Smithing', False);
2: HoverSkill('Magic', False);
end;
end;
{------------------------------------------------------------------------------]
"Find" the ore!
[------------------------------------------------------------------------------}
function FindOre(oreType: string; var rx, ry: integer; x1, y1, x2, y2: integer):
boolean;
var
ore, oreColor: integer;
oreMP: TDTMPointDef;
oreSP: array of TDTMPointDef;
oreSkel: TDTM;
begin
case lowercase(oreType) of
'coal': oreColor := 2570553;
'mithril': oreColor := 7425357;
else
begin
writeln('Desired ore type(s) not found!');
exit;
end;
end;
setarraylength(oreSP, 4);
oreMP.x := 580;
oreMP.y := 229;
oreMP.areasize := 1;
oreMP.areashape := 0;
oreMP.color := oreColor;
oreMP.tolerance := 15;
oreSP[0].x := 576;
oreSP[0].y := 227;
oreSP[0].areasize := 1;
oreSP[0].areashape := 0;
oreSP[0].color := 65536;
oreSP[0].tolerance := 0;
oreSP[1].x := 574;
oreSP[1].y := 229;
oreSP[1].areasize := 1;
oreSP[1].areashape := 0;
oreSP[1].color := 65536;
oreSP[1].tolerance := 0;
oreSP[2].x := 563;
oreSP[2].y := 230;
oreSP[2].areasize := 1;
oreSP[2].areashape := 0;
oreSP[2].color := 65536;
oreSP[2].tolerance := 0;
oreSP[3].x := 592;
oreSP[3].y := 227;
oreSP[3].areasize := 1;
oreSP[3].areashape := 0;
oreSP[3].color := 65536;
oreSP[3].tolerance := 0;
oreSkel.MainPoint := oreMP;
oreSkel.SubPoints := oreSP;
ore := AddDTM(oreSkel);
result := findDTM(ore, rx, ry, x1, y1, x2, y2);
freeDTM(ore);
end;
{------------------------------------------------------------------------------]
Withdraw ores from the bank.
[------------------------------------------------------------------------------}
procedure WithdrawOres;
begin;
l := 0
if (not (Loggedin)) then exit;
if (not (bankscreen)) then exit;
case lowercase(players[currentplayer].Strings[0]) of
'mithril':
begin
if findOre('mithril', x, y, msx1, msy1, msx2, msy2) then
else
begin
writeln('Can not find Mithril Ore!');
terminatescript;
end;
begin
Withdraw(2,1,5);
end;
wait(100 + random(50));
begin
if FindDTM(CoalDTM, x, y, 120, 85, 160, 125) then
else
begin
writeln('Can not find Coal!');
terminatescript;
end;
begin
ClickMouseSpline(x, y, 5, 5, False);
ChooseOption('All');
end;
Wait(75 + random(50));
CloseBank;
Wait(50 + random(50));
end;
end;
end;
end;
{------------------------------------------------------------------------------]
Cast the spell: Superheat, (five times).
[------------------------------------------------------------------------------}
procedure CastSuperheat;
var
i: Integer;
begin
i:= 0;
Wait(25 + random(50));
ClickMouseSpline(740, 180, 5, 5, True);
repeat
if (not (Loggedin)) then exit;
if FindDTM(SuperheatDTM, x, y, 670, 285, 710, 315) then
begin
ClickMouseSpline(x, y, 3, 3, True);
end;
Wait(25 + random(50));
if findOre(players[currentplayer].Strings[0], x, y, MIX1, MIY1, MIX2, MiY2) then
else
begin
writeln('Can not find ore.');
exit;
end;
begin
MoveMouseSpline(x, y, 5, 5);
wait(25 + random(50));
if IsUpText('ith') then
else
begin
Writeln('Incorret uptext.');
exit;
end;
begin
ClickMouseSpline(x, y, 5, 5, True);
Wait(25 + random(50));
i:= i + 1;
end;
end;
until(i >= 5);
AntiBan;
end;
{------------------------------------------------------------------------------]
Load the DTMs.
[------------------------------------------------------------------------------}
procedure LoadDTMs;
begin
MithrilBarDTM := DTMFromString('78DA6394606060106540018E8EF10C3C409A1' +
'188FF0301238823C18006189148200D32839F801A5922D4280109' +
'21026A5488700FC82E7922DCAC845F0D00D9240685');
SuperheatDTM := DTMFromString('78DA639460606090614001BF2245197880342' +
'310FF0702461C6A18A06AC0B40090906640038CA86A0481841001' +
'359244A85104126204D428010979026A40F24A04D40813560300F' +
'88F08C1');
MithrilOreDTM := DTMFromString('78DA6394626060906040017EFEC50C3C409A1' +
'188FF030123279021CE8006189148202D06243809A8510012DC04' +
'D4A8030901026A948184141176C913502344580D00094106B0');
CoalDTM := DTMFromString('78DA639461606010634001D6561A0C3C409A1' +
'188FF03012337A61A882C8C04D222404280801A0920C149408D3A' +
'90E025420D21F728020979026A2481840A0135203FC9E15703007' +
'76E0674');
end;
{------------------------------------------------------------------------------]
Bank the Mithil Bars.
[------------------------------------------------------------------------------}
procedure Bank;
var
time: Integer;
begin
MarkTime(time);
repeat
if (not (Loggedin)) then break;
OpenBankQuiet(BankName)
until (BankScreen or (TimeFromMark(time) > 100000));
Wait(150 + random(100));
if Bankscreen then
else
begin
terminatescript;
end;
begin
if FindDTM(MithrilBarDTM, x, y, 550, 200, 600, 250) then
begin
ClickMouseSpline(x, y, 3, 3, False);
ChooseOption('All');
end;
loads := + 1
end;
end;
{------------------------------------------------------------------------------]
Progress Report.
[------------------------------------------------------------------------------}
procedure ProgressReport;
begin
ClearDebug;
Writeln('Version 0.2 by: Macros, (LOTS of help from wtfwtfwtf).');
Writeln('Worked for ' + TimeRunning + '.');
Writeln('Banked ' + inttostr(Loads) + ' time(s).');
end;
{------------------------------------------------------------------------------]
Setup!
[------------------------------------------------------------------------------}
procedure Setup;
begin;
ClearDebug;
SetupSRL;
LoadDTMs;
ActivateClient;
Mousespeed := Mspeed;
DeclarePlayers;
LoginPlayer;
//SRLID := YourSRLId; (for when the script is done)
//SRLPassword := YourSRLPass; (for when the script is done)
MakeCompass('CompassDirection');
SetAngle(true);
end;
begin
setup;
repeat
OpenBankQuiet(BankName);
WithdrawOres;
CastSuperheat;
LampSkill := RandomSkill;
FindNormalRandoms;
Bank;
ProgressReport;
until (Loads = (PlayerSuperheats/5));
Logout;
if (Players[CurrentPlayer].Active = false) then
terminatescript;
end.