SRL Archive - Help and Support

Help with my script


Shuttleu

2008-08-31 08:55:59

okay so i am making a new script but i seem to have a problem but i dont know what it is

im not too sure wether the autocoloring is working but that isnt the problem
here is the script

program FlourBuyer;
{.include srl/srl/misc/smart.scar}
{.include srl/srl.scar}
{.include srl/srl/misc/users.scar}
{.include srl/srl/misc/newautocolor.scar}

const
LoadsWanted= 25;
SRL_ID= '';
SRL_PASS= '';
SMARTWorld= 23;

var
x, y, i, T, c, Flour, Loads, Pots, NewPots: integer;

Function OpenShop : Boolean;
var
i:integer;
begin
If(not(LoggedIn)) then exit;
begin
FindNormalRandoms;
if FindObjTPA(x, y, 12568519, 10, -1, 30, 30, 1, ['hop']) then
begin
Mouse(x, y, 5, 5, False);
Wait(400+random(400));
ChooseOption('rade');
i:=0
repeat
Inc(i);
Wait(500+random(500));
until (ShopScreen) or (i>=30);
Result:= True;
end else
Writeln('Coluld not find the shop keeper');
end;
end;

Function DepositBox(i :Integer): TBox;
var
row, col: Integer;

begin
If(not(LoggedIn)) then exit;
if (i < 1) or (i > 28) then exit;
row :=i mod 7;
if row = 0 then row := 7;
col := i / 7 ;
if i mod 7 <> 0 then Inc(col);
Result.x1 := 48 + (row * 48); // First X coord - 42 - 5 for proper Tbox
Result.y1 := 13 + (col * 50); // First Y coord - 36 - 5 for proper Tbox
Result.x2 := 96 + (row * 48);
Result.y2 := 63 + (col * 50);
end;

function ItemExists(i: Integer): Boolean;
var
x, y:Integer;
TB: TBox;
begin
If(not(LoggedIn)) then exit;
TB := DepositBox(i);
Result := FindColor(x, y, 65536, TB.x1 + 5, TB.y1 + 5, TB.x2 - 5, TB.y2 - 5);
end;

Procedure BankDeposit(i:integer);
var
Item: TPointArray;
T: integer;
begin
If(not(LoggedIn)) then exit;
if (i < 1) or (i > 28) then exit;
SetLength(Item, 29);
Item[1]:= Point(109+(0 * 48), 78+(0 * 50));
Item[2]:= Point(109+(1 * 48), 78+(0 * 50));
Item[3]:= Point(109+(2 * 48), 78+(0 * 50));
Item[4]:= Point(109+(3 * 48), 78+(0 * 50));
Item[5]:= Point(109+(4 * 48), 78+(0 * 50));
Item[6]:= Point(109+(5 * 48), 78+(0 * 50));
Item[7]:= Point(109+(6 * 48), 78+(0 * 50));
Item[8]:= Point(109+(0 * 48), 78+(1 * 50));
Item[9]:= Point(109+(1 * 48), 78+(1 * 50));
Item[10]:= Point(109+(2 * 48), 78+(1 * 50));
Item[11]:= Point(109+(3 * 48), 78+(1 * 50));
Item[12]:= Point(109+(4 * 48), 78+(1 * 50));
Item[13]:= Point(109+(5 * 48), 78+(1 * 50));
Item[14]:= Point(109+(6 * 48), 78+(1 * 50));
Item[15]:= Point(109+(0 * 48), 78+(2 * 50));
Item[16]:= Point(109+(1 * 48), 78+(2 * 50));
Item[17]:= Point(109+(2 * 48), 78+(2 * 50));
Item[18]:= Point(109+(3 * 48), 78+(2 * 50));
Item[19]:= Point(109+(4 * 48), 78+(2 * 50));
Item[20]:= Point(109+(5 * 48), 78+(2 * 50));
Item[21]:= Point(109+(6 * 48), 78+(2 * 50));
Item[22]:= Point(109+(0 * 48), 78+(3 * 50));
Item[23]:= Point(109+(1 * 48), 78+(3 * 50));
Item[24]:= Point(109+(2 * 48), 78+(3 * 50));
Item[25]:= Point(109+(3 * 48), 78+(3 * 50));
Item[26]:= Point(109+(4 * 48), 78+(3 * 50));
Item[27]:= Point(109+(5 * 48), 78+(3 * 50));
Item[28]:= Point(109+(6 * 48), 78+(3 * 50));
if ItemExists(i) then
begin
Mouse(Item[i].x, Item[i].y, 20, 20, False);
Wait(400+random(400));
if ChooseOption('sit-All') then
begin
T:=0
repeat
Inc(T);
Wait(500+random(500));
until (not(ItemExists(i))) or (T>=30);
end;
end;
end;

function DepositScreen: Boolean;
begin
If(not(LoggedIn)) then exit;
Result := FindText(x, y, 'Bank', upchars, 92, 29, 396, 54);
end;

Function OpenDeposit : Boolean;
var
T:integer;
begin
If(not(LoggedIn)) then exit;
begin
FindNormalRandoms;
if FindObjTPA(x, y, 739167, 10, -1, 30, 30, 1, ['ank', 'epos', 'sit']) then
begin
Mouse(x, y, 5, 5, True);
Result:= True;
T:=0
repeat
Inc(T);
Wait(500+random(500));
until (DepositScreen) or (T>=30);
end else
Writeln('Coluld not find the shop keeper');
end;
end;

Function FindShop: Boolean;

Var
x, y: Integer;
Begin
If(not(LoggedIn)) then exit;
FindNormalRandoms;
If FindColor(x, y, srl_AutoGetColor('general store'), MMX1, MMY1, MMX2, MMY2) Then
Begin
Result := True;
WriteLn('Succesfully used NewAutoColor for FindShop');
End;
If Not Result Then
If FindSymbol(x, y, 'shop') Then
begin
Writeln('found shop using bitmap');
Result := True;
end;
If Result Then
Begin
T:=0;
repeat
Mouse(x, y, 5, 5, True);
Wait(1000+random(500));
until(T=10)or(FlagPresent);
Wait(1000);
Flag;
Wait(1000);
End;
End;

Function FindDeposit: Boolean;

Var
x, y: Integer;
Begin
If(not(LoggedIn)) then exit;
FindNormalRandoms;
If FindColor(x, y, srl_AutoGetColor('bank'), MMX1, MMY1, MMX2, MMY2) Then
Begin
Result := True;
WriteLn('Succesfully used NewAutoColor for FindDeposit');
End;
If Not Result Then
If FindSymbol(x, y, 'bank') Then
begin
Writeln('Found deposit box using bitmap');
Result := True;
end;
If Result Then
Begin
T:=0;
repeat
Mouse(x, y, 5, 5, True);
Wait(1000+random(500));
until(T=10)or(FlagPresent);
Wait(1000);
Flag;
Wait(1000);
End;
End;

Function BuyFlour : Boolean;
begin
if (not(LoggedIn)) then exit;
if ShopScreen then
begin
MouseBox(420, 104, 443, 129, 2);
Wait(400+Random(400));
if ChooseOption('uy X') then
begin
i:=0;
repeat
Wait(30+Random(20));
Inc(i);
if GetColor(262, 403)=0 then break;
until(i>=100);
Wait(500+random(500));
Case Random(5) of
0:TypeSend('27');
1:TypeSend('30');
2:TypeSend('28');
3:TypeSend('56');
4:TypeSend('46');
end;
i:=0;
repeat
Wait(30+Random(20));
Inc(i);
if FindDTM(Flour, x, y, MIX1, MIY1, MIX2, MIY2) then break;
until(i>=100);
Wait(500+random(500));
Mouse(478, 34, 15, 15, True);
if (not(i>=100)) then Result:= True;
end;
end else
Writeln('Could not find the shop screen :(');
end;

Procedure BankEverything(from, upto:integer);
begin
If(not(LoggedIn)) then exit;
for i:=from to upto do
if itemExists(i) then BankDeposit(i);
Mouse(426, 34, 15, 15, True);
end;

procedure Proggy;
begin
Pots:= Pots+NewPots;
Writeln('========================================');
Writeln(' $$$ Shuttleu''s Flour Buyer $$$ ');
Writeln('========================================');
Writeln('Worked for : '+TimeRunning);
Writeln('Done '+inttostr(Loads)+' loads');
Writeln('Bought '+inttostr(Pots)+' Pots of flour');
Writeln('========================================');
ReportVars[0] := ReportVars[0]+NewPots;
ReportVars[1] := ReportVars[1]+1;
SRLRandomsReport;
end;

begin
SmartsetupEx(SmartWorld, true, true, false);
Settargetdc(smartgetdc);
SetupSRL;
ScriptID := '982';
SRLID:=SRL_ID;
SRLPassword:=SRL_PASS;
SRLPlayerForm(True, [], [], [], []);
LoginPlayer;
SetupNewAutoColor;
Loads:=0;
SetAngle(True);
c := FindRockColor;
If c > 0 Then
Begin
SetAutoColorReference('grey rock', c);
WriteLn('Got the color using the grey rock');
End;
Flour:=DTMFromString('78DA6374616260E0666440067D89C60C72401' +
'A24FA1F08189D806A1851D55C3A7D1AAE060418CD806AD850D5C0' +
'6451D4081250E308542341408D37508D0801357E40350204D4F80' +
'0D5B01050E30E54F38F01BF1A6BC26A008EFD0CF4');
repeat
T:=0;
repeat
Wait(50+random(50));
if FindShop then break;
until(T=10);
T:=0;
repeat
OpenShop;
until(T=10)or(ShopScreen);
BuyFlour;
T:=0;
repeat
Wait(50+random(50));
if FindDeposit then break;
until(T=10);
NewPots:=CountItemsIn('inv', 'dtm', Flour, []);
OpenDeposit;
BankEverything(2, 28);
Inc(Loads);
Proggy;
until(Loads>=LoadsWanted);
FreeDTM(Flour);
end.
so it will run fine until about 10-15 loads which it will miss a click on the minimap and wont go into the shop
which then means that it cant find the shopkeeper which screws up the script

now this is really annoying because some times it will work all the way to the end
others it will work for about 10-15 loads
and other thimes it will work for about 5 loads

i have set it to try and walk to the shop 5 times or until it has foundthe shop and clicked on it
and it says that it has found the shop but it wont click on it

Please help

~shut

Nava2

2008-08-31 10:46:36

I don't understand your problem, but I can't see it. Since I can't, I figured I would help you clean up that deposit procedure.

Here is what I have:

{*******************************************************************************
Function BankIndexToMSPoint(Index: Integer): TPoint;
by: Wizzup? modified by Nava2 for Deposit Box.
Description: Converts the Bank Index (spot in bank) to a Mainscreen TPoint of
the Index. (Top Left)
*******************************************************************************}
function SlotToPoint(i : Integer) : TPoint;
begin
Dec(I);
Result := Point(109 + Floor(I Div 10) * 48, 78 + (I Mod 10) * 50);
end;



Procedure BankDeposit(i:integer);
var
Item: TPoint;
T: integer;
begin
If(not(LoggedIn)) then exit;
if (i < 1) or (i > 28) then exit;
Item := SlotToPoint(i);
if ItemExists(i) then
begin
Mouse(Item.x, Item.y, 30, 30, False);
Wait(400+random(400));
if ChooseOption('sit-All') then
begin
T:=0
repeat
Inc(T);
Wait(500+random(500));
until (not(ItemExists(i))) or (T>=30);
end;
end;
end;

May or may not work, but you should do it that way. Much cleaner.

P.S. You should use IncEx(var X: integer, i: integer); Its faster than doing Variable := Variable + Number. :)

Shuttleu

2008-08-31 10:51:02

From: Nava2
I don't understand your problem, but I can't see it. Since I can't, I figured I would help you clean up that deposit procedure.

Here is what I have:

{*******************************************************************************
Function BankIndexToMSPoint(Index: Integer): TPoint;
by: Wizzup? modified by Nava2 for Deposit Box.
Description: Converts the Bank Index (spot in bank) to a Mainscreen TPoint of
the Index. (Top Left)
*******************************************************************************}
function SlotToPoint(i : Integer) : TPoint;
begin
Dec(I);
Result := Point(109 + Floor(I Div 10) * 48, 78 + (I Mod 10) * 50);
end;



Procedure BankDeposit(i:integer);
var
Item: TPoint;
T: integer;
begin
If(not(LoggedIn)) then exit;
if (i < 1) or (i > 28) then exit;
Item := SlotToPoint(i);
if ItemExists(i) then
begin
Mouse(Item.x, Item.y, 30, 30, False);
Wait(400+random(400));
if ChooseOption('sit-All') then
begin
T:=0
repeat
Inc(T);
Wait(500+random(500));
until (not(ItemExists(i))) or (T>=30);
end;
end;
end;

May or may not work, but you should do it that way. Much cleaner.

well i have been told that the banking works perfectly

the problem is that it sometimes doesnt click on the shop even though it says that it has

~shut

HyperSecret

2008-09-01 16:48:20


Function FindShop: Boolean;

Var
x, y: Integer;
Begin
If(not(LoggedIn)) then exit;
FindNormalRandoms;
If FindColor(x, y, srl_AutoGetColor('general store'), MMX1, MMY1, MMX2, MMY2) Then
Begin
GetMousePos(x, y);
Result := True;
WriteLn('Succesfully used NewAutoColor for FindShop');
End;
If Not Result Then
If FindSymbol(x, y, 'shop') Then
begin
GetMousePos(x, y);
Writeln('found shop using bitmap');
Result := True;
end;
If Result Then
Begin
T:=0;
repeat
Mouse(x, y, 5, 5, True);
Wait(1000+random(500));
Inc(T);
until(T=10)or(FlagPresent);
Wait(1000);
FFlag(0);
Wait(1000);
End;
End;


try that? GetMousePos sometimes fixes things of this sort for me, and also you didn't have variable T increasing at all so it could have (probably did) got stuck in the repeat until loop and that may have been the problem…

Shuttleu

2008-09-01 19:51:04

From: HyperSecret

Function FindShop: Boolean;

Var
x, y: Integer;
Begin
If(not(LoggedIn)) then exit;
FindNormalRandoms;
If FindColor(x, y, srl_AutoGetColor('general store'), MMX1, MMY1, MMX2, MMY2) Then
Begin
GetMousePos(x, y);
Result := True;
WriteLn('Succesfully used NewAutoColor for FindShop');
End;
If Not Result Then
If FindSymbol(x, y, 'shop') Then
begin
GetMousePos(x, y);
Writeln('found shop using bitmap');
Result := True;
end;
If Result Then
Begin
T:=0;
repeat
Mouse(x, y, 5, 5, True);
Wait(1000+random(500));
Inc(T);
until(T=10)or(FlagPresent);
Wait(1000);
FFlag(0);
Wait(1000);
End;
End;


try that? GetMousePos sometimes fixes things of this sort for me, and also you didn't have variable T increasing at all so it could have (probably did) got stuck in the repeat until loop and that may have been the problem…

i noticed that i didnt include T so i did and that still didnt solve the problem :(
but i have managed to solve the problem by changing the procedure around
before:
Function FindShop: Boolean;

Var
x, y: Integer;
Begin
If(not(LoggedIn)) then exit;
FindNormalRandoms;
If FindColor(x, y, srl_AutoGetColor('general store'), MMX1, MMY1, MMX2, MMY2) Then
Begin
Result := True;
WriteLn('Succesfully used NewAutoColor for FindShop');
End;
If Not Result Then
If FindSymbol(x, y, 'shop') Then
begin
Writeln('found shop using bitmap');
Result := True;
end;
If Result Then
Begin
T:=0;
repeat
Mouse(x, y, 5, 5, True);
Wait(1000+random(500));
until(T=10)or(FlagPresent);
Wait(1000);
Flag;
Wait(1000);
End;
End;
after:
Function FindShop: Boolean;

Var
x, y: Integer;
Begin
If(not(LoggedIn)) then exit;
FindNormalRandoms;
If FindColor(x, y, srl_AutoGetColor('general store'), MMX1, MMY1, MMX2, MMY2) Then
Begin
Result := True;
WriteLn('Succesfully used NewAutoColor for FindShop');
T:=0;
repeat
Mouse(x, y, 5, 5, True);
Wait(1000+random(500));
until(T=10)or(FlagPresent);
Flag;
Wait(1000+random(1000));
end else
If FindSymbol(x, y, 'shop') Then
begin
Writeln('found shop using bitmap');
Result := True;
T:=0;
repeat
Mouse(x, y, 5, 5, True);
Wait(1000+random(500));
until(T=10)or(FlagPresent);
Flag;
Wait(1000+random(1000));
end;
End;
thank you to everyone who tried to help
it was very much appreciated :D

~shut

Gu3st...

2008-09-02 05:24:15

wtf is this:
repeat
mouse(x, y, 5, 5, True);
Wait(1000+random(500));
until(Y=10)or(FlagPresent);

Nava2

2008-09-02 07:58:25

From: Zytex!
wtf is this:
repeat
mouse(x, y, 5, 5, True);
Wait(1000+random(500));
until(Y=10)or(FlagPresent);


Shouldn't the mouse be on the outside of the loop? :)

Gu3st...

2008-09-02 08:05:24

Idk, but Y will never be 10 in that loop :p

Shuttleu

2008-09-02 09:22:50

i have noted that i for got the Y before
the reason for the loop is because sometimes the script wouldnt click so i made it like that so if it didnt click the first time then it would try again

~shut