SRL Archive - Help and Support

Tips on my script, pl0x


maxzzz

2006-03-18 12:19:58

Hi, I made a string script and I tested it and it most the time it works for atleast 3-4 hours with no problem. Sometimes it misses (not often) the Strings in the bank.
I would like if some people can give me some tips to make it better, and I also tried to make a Writeln(''); with the average of bows per hour but I couldn't finish that.
And I don't know how to make a progressreport that reports every 10 minutes and not every loop, :p .
Every tip is welcome.

Here is the script:


program Stringing;
{.include SRL/SRL.scar}
var
Stringed, StringedReport, Banked, Loops, AverageMultiplier, BowsMade, AverageBows : Integer;
InvString, InvBow : Tpoint;

//+-**********|***********-************|**********-+\\
//| |+ Setup Instructions +| |\\
//+***********|***********-************|**********-+\\
//+ Set Amount to make sure you don't want to make +\\
//+ more bows then you can make. Also set your +\\
//+ bankpin if you have one. +\\
//+ Be sure you start with 14 bs and 14 +\\
//+ unstrung bows in Inventory. +\\
//+-**********|***********-************|**********-+\\

const
Amount = 5000;
BankPin = ;


procedure DragBs;
begin
CMMouse(628, 337, 4, 5);
wait(50+random(50));
GetMousePos(x, y);
HoldMouse(x, y, true);
Wait(20+random(10));
CMMouse(671, 453, 4, 5);
Wait(20+random(10));
GetMousePos(x, y);
ReleaseMouse(x, y, true);
wait(30+random(20));
end;

procedure StringsInBows;
begin
Stringed:=0;
DragBs;
if(InvFull)then
begin
repeat
InvString := ItemCoords(27); // returns coords of string
CMouse(InvString.X, InvString.Y, 4, 6, true); // Moves mouse to string and clicks left
wait(10+random(5)); // wait 10-15 ms
InvBow := ItemCoords(28); // returns coords of bow
CMouse(InvBow.X, InvBow.Y, 4, 6, true); // Moves mouse to pos and clicks left
wait(10+random(5)); // wait 10-15 ms
StringedReport:=StringedReport+1; // obvious
Stringed:=Stringed+1; // obvious
until(Stringed=14+random(1));
end;
end;

procedure FindRandoms;
begin
CloseWindow;
wait(10);
FindLamp('Runecrafting');
wait(10);
TalkToRand;
wait(10);
FindDead;
wait(10);
FindTalk;
wait(10);
FindMod;
wait(10);
FindMime;
wait(10);
FindMaze;
wait(10);
FindPlant;
wait(10);
FindQuiz;
wait(10);
FindFrog;
wait(10);
FindDoctor;
wait(10);
FindDemon;
wait(10);
if(FindFight)then RunAwayDirection('N');
wait(10);
if Findname Then FindTalk;
wait(10);
if FindNewBox then Logout;
wait(10);
end;

procedure WaitWhileString;
begin
repeat
FindRandoms;
until(not(ExistsItem(27)));
end;

procedure CloseWindowBank;
begin
CMouse(454, 41, 10, 3, true);
end;

procedure BankAndWithdraw;
begin
CMMouse(281, 178, 4, 4);
OpenBank2((BankPin));
wait(100+random(50));
if(BankScreen)then
begin
CMMouse(586, 229, 4, 4);
DepositArea(572, 214, 722, 457);
FixBank;
wait(50+random(50));
CMMouse(375, 74, 6, 6);
repeat
PopUp2(375, 74, 4, 4, 'Withdraw X');
repeat
wait(1+random(1));
until(FindText(x, y, 'Enter amount:', 0, 206, 381, 306, 401));
until(FindText(x, y, 'Enter amount:', 0, 206, 381, 306, 401));
wait(20+random(20));
TypeSend('14');
wait(50+random(20));
CMMouse(425, 72, 6, 6);
PopUp2(424, 73, 4, 4, 'Withdraw All');
wait(10+random(5));
CloseWindowBank;
wait(10+random(5));
Banked:=Banked+1;
end;
end;

procedure WaitWhileClosingBank;
begin
repeat
wait(500+random(100));
until(not(BankScreen));
end;

procedure Average;
begin
AverageMultiplier := 3600000/TimeRunning;
BowsMade := Banked*14;
AverageBows := BowsMade*AverageMUltiplier;
end;

procedure ProgresReport;
begin
Writeln('****************************************************');
Writeln('* The script has ran for ' +(TimeRunning));
Writeln('* You have stringed ' +Inttostr(StringedReport) + ' bows and banked ' +Inttostr(Banked) + ' times');
Writeln('* You are making ' +Inttostr(AverageBows) +'bows per hour');
Writeln('****************************************************');
end;

begin
SetupSRL;
DisguiseScar('MSN Messenger');
FixChat;
repeat
Loops:=0;
StringsInBows;
WaitWhileString;
BankAndWithdraw;
WaitWhileClosingBank;
Loops:=Loops+1;
if(Loops=1)then
begin
ProgresReport;
end;
until(Banked*14=Amount);
end.

inferno

2006-03-18 12:28:07

I guess the average thing per hour would be something like

Var
AverageMultiplier, AverageBowsEx : Extended;
AverageBows : Integer;

AverageMultiplier := 3600000/TimeRunning;
AverageBowsEx:= StringedReport*AverageMultiplier;
AverageBows := Round(AverageBowsEx);

Writeln('Blah blah blah '+IntToStr(AverageBows)+' blah');
This will divide one hour by the time the script has been run and time it by the ammount strung already.

maxzzz

2006-03-18 12:37:51

Thnx vm, btw I need to change that piece of StringedReport because StringedReport is not always the number of Strung Bows made, because of the Until(Stringed=14+random(1));.
So I better could doe something like this:


var AverageMultiplier, BowsMade, AverageBows : Integer;

AverageMultiplier := 3600000/TimeRunning;
BowsMade := Banked*14;
AverageBows := BowsMade*AverageMUltiplier;

That would be accurater :p,

Thnx, any further tips are welcome.

EDIT:*

procedure Average;
begin
AverageMultiplier := 3600000/TimeRunning; ----> [Error] (9143:41): Type mismatch in script C:\Program Files....
BowsMade := Banked*14;
AverageBows := BowsMade*AverageMultiplier;
end;

Please help with this Type mismatch.

inferno

2006-03-18 13:28:05

Have you got the variables defined as the correct type? (Look at my example)

maxzzz

2006-03-18 13:32:27

Offcourse I did, but I put them as global variables.

EDIT:* Sorry, didn't see your edit.


EDIT2:* How do I make a ProgresReport that reports every 10 minutes?

inferno

2006-03-18 13:40:51

MarkTime(Mark);
Repeat
// Procedures here
If(TimeFromMark(Mark)>=600000)Then
Begin
ProgressReport;
MarkTime(Mark);
End;
Until(something);

phantombmx

2006-03-22 12:00:55

this is what i am currently using for my progress report, it is extremely accurate… down to the decimal point.. lol

procedure ProgressReport;
var ProgCounter, Hours, Minutes, Seconds, TSeconds :Integer;
Rate :Extended;
Time :String;
begin
If(ProgCounter = 40)Then //If debug gets too full, clear
begin
ClearDebug;
ProgCounter:= 0
end;
Hours:= ScriptTime(1) // SRL times
Minutes:= ScriptTime(2)
Seconds:= ScriptTime(3)
If(Hours>0)Then
begin
TSeconds:=TSeconds + (Hours*3600)
end;
If(Minutes>0)Then
begin
TSeconds:=TSeconds + (Minutes*60)
end;
If(Seconds>0)Then
begin
TSeconds:=TSeconds + Seconds
end;
Time:= inttostr(Hours)+ ' Hours, ' +inttostr(Minutes)+ ' Minutes, and ' +inttostr(Seconds)+ ' Seconds.'
If(AmountStrung>0)Then
begin
Rate:= (AmountStrung/TSeconds)*3600
end;
WriteLn('')
WriteLn('<<----------------Progress-Report---------------->>')
WriteLn('Worked For ' +Time)
WriteLn('Strung ' +inttostr(AmountStrung)+ ' Bows So Far.')
WriteLn('Averaging About ' +floattostr(Rate)+ ' Bows Per Hour.')
WriteLn('<<---------------------------------------------------->>')
ProgCounter:= ProgCounter + 1
end;

it will output something like this

<<—————-Progress-Report—————->>
Worked For 0 Hours, 2 Minutes, and 23 Seconds.
Strung 30 Bows So Far.
Averaging About 755.24472 Bows Per Hour.
<<———————————————–>>


hope you like its accuracy

maxzzz

2006-03-22 13:41:34

Thnx vm, I'll try to use it.

inferno

2006-03-22 14:01:56

From: phantombmx
this is what i am currently using for my progress report, it is extremely accurate… down to the decimal point.. lol

procedure ProgressReport;
var ProgCounter, Hours, Minutes, Seconds, TSeconds :Integer;
Rate :Extended;
Time :String;
begin
If(ProgCounter = 40)Then //If debug gets too full, clear
begin
ClearDebug;
ProgCounter:= 0
end;
Hours:= ScriptTime(1) // SRL times
Minutes:= ScriptTime(2)
Seconds:= ScriptTime(3)
If(Hours>0)Then
begin
TSeconds:=TSeconds + (Hours*3600)
end;
If(Minutes>0)Then
begin
TSeconds:=TSeconds + (Minutes*60)
end;
If(Seconds>0)Then
begin
TSeconds:=TSeconds + Seconds
end;
Time:= inttostr(Hours)+ ' Hours, ' +inttostr(Minutes)+ ' Minutes, and ' +inttostr(Seconds)+ ' Seconds.'
If(AmountStrung>0)Then
begin
Rate:= (AmountStrung/TSeconds)*3600
end;
WriteLn('')
WriteLn('<<----------------Progress-Report---------------->>')
WriteLn('Worked For ' +Time)
WriteLn('Strung ' +inttostr(AmountStrung)+ ' Bows So Far.')
WriteLn('Averaging About ' +floattostr(Rate)+ ' Bows Per Hour.')
WriteLn('<<---------------------------------------------------->>')
ProgCounter:= ProgCounter + 1
end;

it will output something like this

<<—————-Progress-Report—————->>
Worked For 0 Hours, 2 Minutes, and 23 Seconds.
Strung 30 Bows So Far.
Averaging About 755.24472 Bows Per Hour.
<<———————————————–>>


hope you like its accuracy


That could just be done with the code I posted but leaving out the Round bit and using
+FloatToStrEx(AverageBowsEx)+

maxzzz

2006-03-22 14:05:08

I just saw that too :p

phantombmx

2006-03-22 14:58:45

eh its cool.. i am just usin this cuz its more understandable to me :p