SRL Archive - OSR Help

Need some help with this script (loop not right?)


FiLow

2012-02-21 12:23:52

Hello,

Currently I'm making a WillowPowerChopper. I worked pretty good unless I changed some things. Everytime I start the script, It does the job: Searching for a log an chop it. But now when I start it, it keeps searching for the tree and keeps clicking.I think something is wrong with the loop, but I can't find out, Heres the script so you can see what it does:

program WillowPowerChopper;
{$DEFINE SMART}
{$i SRL/srl.simba}
{$i sps/sps.simba}

Procedure DeclarePlayers;
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
End;

Var
x, y: Integer;

Function ChoppingWillows: Boolean;
Var
PBox: TBox;
begin
PBox := IntToBox(206, 92, 339, 208);
Result := (AveragePixelShift(PBox, 200, 350) > 250);
end;

Function WillowColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.29, 0.90);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 3957842, MSX1, MSY1, MSX2, MSY2, 8);
if (Length(arP) = 0) then
begin
Writeln('No Willows found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 4.87) and (X <= 12.91) and (Y >= 6.07) and (Y <= 16.27) and (Z >= 3.59) and (Z <= 10.23) then
begin
Result := arC[i];
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('Willow tree not found.');
End;

Procedure AntiBan;

Begin
Case Random(250) of

10:Begin
HoverSkill('Woodcutting', False);
Wait(1000+Random(500));
Mouse(659, 189, 0, 0, True);
End;
0..5:
Begin
HoverSkill('Random', False);
Wait(500 + Random(500));
Mouse(658, 190, 0, 0, True);
End;
0..5:
Begin;
Mouse(689, 188, 0, 0, True);
Wait(1200 + Random(300));
Mouse(660, 188, 0, 0, True);
End;
0..5:
Begin;
SleepAndMoveMouse(200 + Random(100));
End;
0..5:
Begin;
ExamineInv
End;
End;
End;

Procedure Chopping;

Begin
FindNormalRandoms;
Writeln('Searching for Willows...');
RandomMovement;
MakeCompass('Random');

If FindObjCustom(x, y, ['op', 'wn'], [WillowColor], 10) Then
Begin
Writeln('Willow founded.');
Wait(300 + Random(100));
Mouse( x, y, 2, 2, True);
Writeln('Chopping.');

if (ChoppingWillows) then
Antiban;

end;
repeat
AntiBan;
Until(Not ChoppingWillows)
End;

Procedure DropLogs;
Var I: integer;
Begin
for I:= 0 To 2 Do
Begin
Writeln('Dropping logs.')
DropAll
End;
End;

Begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
Repeat
Chopping;
If (InvFull) then
DropLogs;
Until(False)
End.

The script will for now only work with the old Willow look.

x[Warrior]x3500

2012-02-21 12:38:25

1. update your willow color
2. use a little more specific upText
3.dont use a tol of 10, since its an autocolor, use 0 or 1. (in your findobjcustom)

FiLow

2012-02-21 13:07:44

Ok, thanks for the tips, but the I think the loop in Chopping is not good.

x[Warrior]x3500

2012-02-21 13:15:06

well from what i see, if you are using findobjcustom, then that loop is fine. and what do u mean by "keeps clicking"

FiLow

2012-02-21 13:22:22

I fixed the 'keep clicking' problem. What I mean with it: The script will wait till you stop chopping the tree and will click on the tree again but my script keeps clicking on tree even when it's chopping. <— Fixed. The problem now is: it drop logs when you chopped a willow.

Script:

program WillowPowerChopper;
{$DEFINE SMART}
{$i SRL/srl.simba}
{$i sps/sps.simba}

Procedure DeclarePlayers;
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
End;

Var
x, y: Integer;

Function ChoppingWillows: Boolean;
Var
PBox: TBox;
begin
PBox := IntToBox(206, 92, 339, 208);
Result := (AveragePixelShift(PBox, 200, 350) > 250);
end;

Function WillowColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.29, 0.90);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 3957842, MSX1, MSY1, MSX2, MSY2, 8);
if (Length(arP) = 0) then
begin
Writeln('No Willows found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 4.87) and (X <= 12.91) and (Y >= 6.07) and (Y <= 16.27) and (Z >= 3.59) and (Z <= 10.23) then
begin
Result := arC[i];
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('Willow tree not found.');
End;

Procedure AntiBan;

Begin
Case Random(250) of

0..5: Begin
HoverSkill('Woodcutting', False);
Wait(1000+Random(500));
Mouse(659, 189, 0, 0, True);
End;
0..5:
Begin
HoverSkill('Random', False);
Wait(500 + Random(500));
Mouse(658, 190, 0, 0, True);
End;
0..5:
Begin;
Mouse(689, 188, 0, 0, True);
Wait(1200 + Random(300));
Mouse(660, 188, 0, 0, True);
End;
0..5:
Begin;
SleepAndMoveMouse(200 + Random(100));
End;
0..5:
Begin;
ExamineInv
End;
End;
End;

Procedure Chopping;

Begin
FindNormalRandoms;
Writeln('Searching for Willows...');
RandomMovement;
MakeCompass('Random');
Begin;
If FindObjCustom(x, y, ['hop', 'own'], [WillowColor], 0) Then
Writeln('Willow founded.');
Mouse( x, y, 2, 2, True);
Writeln('Chopping.');
Repeat
AntiBan;
Until not (ChoppingWillows) or (InvFull)
End;
End;


Procedure DropLogs;
Var I: integer;
Begin
for I:= 0 To 2 Do
Begin
Writeln('Dropping logs.')
DropAll
End;
End;

Begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
Repeat
Chopping;
AntiBan;
If (InvFull) then
DropLogs;
Until(False)
End.

x[Warrior]x3500

2012-02-21 13:44:51

well when i run it, the droppin procedure works fine, but the detecting of the willow barely works

FiLow

2012-02-21 13:49:44

Have you tested it at the new or old willow trees?

x[Warrior]x3500

2012-02-21 13:53:36

only the new ones because i simply dont know where to find the old ones

FiLow

2012-02-21 13:54:37

Thats the problem. I haven't added the new ones yet.

x[Warrior]x3500

2012-02-21 13:56:08

ok well as far as i was able to test, the dropping procedure worked for me. ( i changed colors to help detect new trees)

FiLow

2012-02-21 13:58:52

Weird because my script is dropping my inventory every time I chopped a willow tree down.

program WillowPowerChopper;
{$DEFINE SMART}
{$i SRL/srl.simba}
{$i sps/sps.simba}

Procedure DeclarePlayers;
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
End;

Var
x, y: Integer;

Function ChoppingWillows: Boolean;
Var
PBox: TBox;
begin
PBox := IntToBox(206, 92, 339, 208);
Result := (AveragePixelShift(PBox, 200, 350) > 250);
end;

Function WillowColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.29, 0.90);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 3957842 //ONLY CHANGE IF YOU HAVE PROBLEMS WITH FINDING A WILLOW!
, MSX1, MSY1, MSX2, MSY2, 8);
if (Length(arP) = 0) then
begin
Writeln('No Willows found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

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

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 4.87) and (X <= 12.91) and (Y >= 6.07) and (Y <= 16.27) and (Z >= 3.59) and (Z <= 10.23) then
begin
Result := arC[i];
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('Willow tree not found.');
End;

Procedure AntiBan;

Begin
Case Random(200) of

0: Begin
HoverSkill('Woodcutting', False);
Wait(1000+Random(500));
Mouse(659, 189, 0, 0, True);
End;
1:
Begin
HoverSkill('Random', False);
Wait(500 + Random(500));
Mouse(658, 190, 0, 0, True);
End;
2:
Begin;
Mouse(689, 188, 0, 0, True);
Wait(1200 + Random(300));
Mouse(660, 188, 0, 0, True);
End;
3:
Begin;
SleepAndMoveMouse(200 + Random(100));
End;
4:
Begin;
ExamineInv
End;
End;
End;

Procedure Chopping;

Begin
FindNormalRandoms;
Writeln('Searching for Willows...');
RandomMovement;
MakeCompass('Random');
Begin;
If FindObjCustom(x, y, ['hop', 'own'], [WillowColor], 0) Then
Writeln('Willow founded.');
Begin
Mouse( x, y, 2, 2, True)
Writeln('Chopping.');
End;
End;
Repeat
AntiBan;
Until not (ChoppingWillows)
End;



Procedure DropLogs;
Var I: integer;
Begin
for I:= 0 To 2 Do
Begin
Writeln('Dropping logs.')
DropAll
End;
End;

Begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
Repeat
Chopping;
AntiBan;
If (InvFull) then
Begin
DropLogs;
End;
Until(False)
End.

FiLow

2012-02-21 14:10:21

Drop problem fixed, solution: had to restart Simba due update.

x[Warrior]x3500

2012-02-21 15:12:38

that makes more sense. i was really confused on how u were gettin that bug. :) glad u got it solved