SRL Archive - OSR Help

Mainloop help


Element17

2012-04-14 21:09:47

I need help with making a Mainloop procedure.

program Onion;
//{$DEFINE SMART}
{$i srl/srl.simba}
{$i ObjectDTM\ObjDTMInclude.simba}


Const
SERVER = 61; // Enter "0" to pick a random server.
MEMBERS = False; // Set to True if using a RS-Members account. False if F2P.
SRLStats_Username = ''; // Your SRL Stats Username
SRLStats_Password = ''; // Your SRL Stats Password
NumbOfPlayers= 1; //How many players are you using
StartPlayer= 0; //Player to start auoting with! (0 means first char)
Version= '.7';

Var
TooLong: Integer;
X, Y: Integer;
Q: Array [0..1] of Integer;//DTM Declaring procedure.
aFound: Extended;


procedure DeclarePlayers;
var i:integer;
begin
NumberOfPlayers(NumbOfPlayers);
CurrentPlayer := StartPlayer;
for i := 0 to NumbOfPlayers-1 do
Players[i].BoxRewards := ['mote', 'ostume', 'XP', 'Gem', 'ithril', 'oal', 'une', 'oins'];

with Players[0] do
begin
Name := ''; //Player username.
Pass := ''; //Player password.
Nick := ''; //Player nickname - 3-4 letters of Player username.
Active := True;
end;

end;

Procedure StatsGuise(wat:String);
Begin
Status(wat);
Disguise(wat);
End;

Procedure Antiban;
Begin
Case Random(255) Of
0: HoverSkill('Mining', False);
1: Begin PickUpMouse; SleepAndMoveMouse(3000 + Random(500)); End;
2: ExamineInv;
3: RandomAngle(1);
4: Begin GameTab(Tab_Stats); Wait(3000 + Random(500)); GameTab(Tab_Inv); End;
5: HoverSkill('random', False);
End;
End;

Procedure FailSafe(Reason:String);
Begin
Players[CurrentPlayer].Loc:=Reason;
Logout;
Stats_commit;
Terminatescript;
End;

Procedure Bankit; //Credits to Trickyy and Marpis for the Tut
Var
i : Integer;
Begin
If (Not(LoggedIn)) Then Exit;
For i:=1 To 4 Do
If OpenBank('db', True, True) Then
Break;
End;

Function DepoAll: Boolean;
Begin
If (InvEmpty) Then
Begin
Result := True;
Exit;
End;

QuickDeposit(SRL_DEPOSIT_ALL);
Result := WaitFunc(@InvEmpty, 50, 3000);
End;

function OnionColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.08, 0.11);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 4742480, MSX1, MSY1, MSX2, MSY2, 8);
if (Length(arP) = 0) then
begin
//Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
//Writeln('AutoColor failed in finding the color.');
end;

Function PickOnion: Boolean;
Var
X, Y, PlusOne, OnionCounter: Integer;
Begin
If Not LoggedIn then
Exit;
MarkTime(TooLong);
FindNormalRandoms;
PlusOne:= InvCount +1;
X:=MSCX;
Y:=MSCY;
If (FindObjCustom(X, Y, ['Pick', 'ick'], [OnionColor, OnionColor], 7))Then
Begin
StatsGuise('We found Onion');
GetMousePos(X, Y);

Case Random(2) of
0: Mouse(X, Y, 3, 3, True);
1: Begin
Mouse(X, Y, 3, 3, False);
WaitOption('Pick', 500);
End;
End;

Flag;
MarkTime(OnionCounter);
If (TimeFromMark(Toolong) > 25000) Then
FailSafe('Could not find Onion');
Repeat;
If (TimeFromMark(Toolong) > 25000) Then
FailSafe('Could not find Onion');
FindNormalRandoms;
StatsGuise('AntiBan and Waiting');
Antiban;
Wait(100);
If InvCount=PlusOne Then
Writeln('Onion Picked');
Until (InvCount=PlusOne) or (TimeFromMark(OnionCounter) > 5000)
End;
End;

Procedure ToBank;
Var
cx, cy: Integer;
Begin
If ObjDTM_Find('63:55:6:0:7:55:22:1:7:93:20:1:7:20:76:1:7:110:113:1:7:93:44:10:7:52:61:4:46:45:74:45:78:65:43:65', cx, cy, True) Then
Begin
Writeln('We found it, now lets walk it!');
ObjDTM_Walk('63:55:6:0:7:55:22:1:7:93:20:1:7:20:76:1:7:110:113:1:7:93:44:10:7:52:61:4:46:45:74:45:78:65:43:65', 2, 100, 5, True);
End Else
Writeln('We could not walk here, what a shame');
End;

Procedure SetDTM;//DTM Defining procedure.
Begin
Q[0] := DTMFromString('mlwAAAHicY2dgYNjJxMBwFIjPAPEeIF4JxFOAeAYQMzEyMLwEquEF0vJQzAbEt4FiOUlGDJ8+fWTISfZkWDq1giHSU5Ph439OhmgDDob/QHl+HJgRD4YCAOaQEmM=');
Q[1] := DTMFromString('mlwAAAHicY2dgYNjMxMBwHIjPAvEiIJ4CxDOA+BwQSzMyMLwGquED0sZAzArEd4F8bSC9dGoFw6dPHxlykj0ZlMOFGD7/F2KINuBgsDXnYPgPVMOPAzPiwVAAANxoEfA=');
End;

Procedure FrDTM;//DTM Freeing procedure.
Begin
FreeDTM(Q[0]);
FreeDTM(Q[1]);
End;

begin
Smart_Server := 30;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
ObjDTM_Setup;
ClearDebug;
SetupSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
SetDTM;
SetupSRLStats(439, SRLStats_Username, SRLStats_Password);
MouseSpeed := RandomRange(15, 25);

If FindDTMRotated(Q[0], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) Then
Begin
Mouse(x, y, 3, 3, True);
StatsGuise('Walking to point');
FFlag(6);
Repeat
Wait(50 + Random(25));

Until FindDTMRotated(Q[1], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound);
End;
If FindDTMRotated(Q[1], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) Then
Begin
Mouse(x, y, 3, 3, True);
StatsGuise('Walking to point');
FFlag(6);
End;
FrDTM;
ToBank;
end.

If FindDTMRotated(Q[0], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) Then
Begin
Mouse(x, y, 3, 3, True);
StatsGuise('Walking to point');
FFlag(6);
Repeat
Wait(50 + Random(25));

Until FindDTMRotated(Q[1], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound);
End;
If FindDTMRotated(Q[1], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) Then
Begin
Mouse(x, y, 3, 3, True);
StatsGuise('Walking to point');
FFlag(6);
End;

I want to this in a procedure.

I want to do this:


Mainloop: DTM thing above
If InvEmpty then do dtm above
If InvEmpty(False) then
Exit.
If do dtm above pick onions
Until InvFull Then
Bank


I want to do that but I want it to repeat until false. I'm not sure how to put all that into a mainloop procedure. I've spent a few hours with no luck and when I put that finddtmrotated in a procedure it seems to not work anymore.

riwu

2012-04-14 21:14:40

first make a loop procedure like
procedure Loop;
begin
repeat
if FindDTM blabla (the dtm procedure above)
until (InvFull);
Bank;
end;

then just include it in ur mainloop.
eg.
after smartsetup,declare/login player etc then put
repeat
loop;
until(false);

Total

2012-04-14 21:20:19


procedure MainLoop;
begin
if InvCount < 28 then
begin
If FindDTMRotated(Q[0], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) Then
Begin
Mouse(x, y, 3, 3, True);
StatsGuise('Walking to point');
FFlag(6);
Repeat
Wait(50 + Random(25));
Until FindDTMRotated(Q[1], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound);
End;
If FindDTMRotated(Q[1], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) Then
Begin
Mouse(x, y, 3, 3, True);
StatsGuise('Walking to point');
FFlag(6);
End;
repeat
PickOnion;
until InvFull;
end;
if InvFull then
begin
//Whatever your banking procedure is here
end;
end;

I'm not sure if this is what you want, but what it will do is walk to the point through DTMs if your invy count is less than 28, pick onions until your inv is full, then if your inv is full it will go bank(not sure what your banking procedure is). And you can put it all between a repeat until false if you want to repeat it.

Element17

2012-04-14 21:21:35

….

Element17

2012-04-14 21:23:33

From: TotalKillz

procedure MainLoop;
begin
if InvCount < 28 then
begin
If FindDTMRotated(Q[0], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) Then
Begin
Mouse(x, y, 3, 3, True);
StatsGuise('Walking to point');
FFlag(6);
Repeat
Wait(50 + Random(25));
Until FindDTMRotated(Q[1], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound);
End;
If FindDTMRotated(Q[1], X, Y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) Then
Begin
Mouse(x, y, 3, 3, True);
StatsGuise('Walking to point');
FFlag(6);
End;
repeat
PickOnion;
until InvFull;
end;
if InvFull then
begin
//Whatever your banking procedure is here
end;
end;

I'm not sure if this is what you want, but what it will do is walk to the point through DTMs if your invy count is less than 28, pick onions until your inv is full, then if your inv is full it will go bank(not sure what your banking procedure is). And you can put it all between a repeat until false if you want to repeat it.



I think that is what I'm looking for! I will have to test it tomorrow but thank you in advance I hope it works!

Total

2012-04-14 21:32:36

No problem, lemme know if it doesn't do what you want. You could also put your DTM patch into a procedure to make your main loop look better. Like


procedure MainLoop;
begin
if InvCount < 28 then
begin
WalkToOnions; //What I named the walking procedure :p
repeat
PickOnion;
until InvFull;
end;
if InvFull then
begin
//Whatever your banking procedure is here
end;
end;

Gucci

2012-04-14 22:30:36

If your going to add the InvFull part to the collecting procedure then you need to add it in before the if InvCount<28 then, not at the end of the procedure