SRL Archive - OSR Help

Power Chopper


Alek000

2010-02-23 05:14:35

Well I started working on my power chopper, but I can't seem to get it to stop clicking on the tree. It will just keep clicking every second or so and I can't for the life of me figure it out. I am following Coh3n's all in one guide so this probably looks really familiar lol. Any suggestions?

function CutWillows: Boolean;
var
x, y : Integer;
begin
if not LoggedIn then exit;
x := MSCX;
y := MSCY;
repeat
if FindColorSpiral(x, y, 2508087, MSX1, MSY1, MSX2, MSY2) then
begin
FindNormalRandoms;
Wait(500 + Random(100));
Writeln('Found tree!');
MMouse(x, y, 4, 4);
Wait(200 + Random(100));
if IsUpText('illow') then
begin
Wait(200 + Random(100));
Mouse(x, y, 0, 0, True);
Result := True;
end else
Writeln('Could not find Uptext!');
end else
Writeln('Could no find color!');
until(InvFull)
end;

Runescapian321

2010-02-23 05:31:27

It keeps clicking because you don't actually have anything to keep it from clicking. As it is now, you basically have

repeat
if FindColor then ClickTree;
until(InvFull);
So it'll keep clicking trees until inventory is full. You want to figure out some sort of way to detect whether or not it is still chopping, and make it

repeat
if FindColor then ClickTree;
while IsCutting do wait(300+random(200));
until

Alek000

2010-02-23 06:26:30

Would the "IsCutting" be a different procedure?

Runescapian321

2010-02-23 06:32:05

Yes, you have to figure out a way to create one (unless there's something you could use in SRL, but I don't think so) that would return whether or not your character is cutting the tree. I hear people usually either try to detect if the tree is still there and/or if the character is animating.

Alek000

2010-02-23 06:36:11

Ok, thanks Tad I will try that.

Camaro'

2010-02-23 06:43:19

From: Alek000
Ok, thanks Tad I will try that.


What beginners sometimes do, is the just do


repeat
FindTree;
Wait(4000+random(4000));
until false

Which is okay for beginners but I dont recommend doing that. Maybe you could do an inventory check every few seconds or so, and if in 8 seconds it doesn't get a log, then you can move on to the next tree. You understand?

Frement

2010-02-23 07:37:18

[QUOTE=Camaro';687484]What beginners sometimes do, is the just do

[scar]
repeat
FindTree;
Wait(4000+random(4000));
until false
[/scar]
Which is okay for beginners but I dont recommend doing that. Maybe you could do an inventory check every few seconds or so, and if in 8 seconds it doesn't get a log, then you can move on to the next tree. You understand?

Or try searching the tree color in the area you previosly searched it, and while it does that you can check for randoms etc.

function TreeCut( TCX, TCY, Color, Tolerance: Integer ): Boolean;
var x, y: Integer;
begin
if ( FindColorTolerance( x, y, Color, TCX - 2, TCY - 2, TCX + 2, TCY + 2, Tolerance ) ) then
Result := True
else
Result := False
end;

procedure CutTree;
begin
while not TreeCut( the variables ) begin
cut procedures
end;
end;

Be sure to update the x and y when ever you find the new position for them, as the screen rotates slowly, and if you check the same spot, the color might not be there anymore.

Alek000

2010-02-23 09:13:31

Wow you guys lost me :confused:. Sorry, I'm kind of slow at learning stuff, I'm the kind of person that needs a video pretty much for me to learn something lol

Camaro'

2010-02-23 14:50:36

From: Alek000
Wow you guys lost me :confused:. Sorry, I'm kind of slow at learning stuff, I'm the kind of person that needs a video pretty much for me to learn something lol


Ok, well you're problem was having it wait until the tree was chopped down correct? (It would constantly click the tree). It was because your function had no waiting in it. To make it wait efficiently, you need a function to find out if you are chopping or not. To do that you can try either what Frement said, or what i said in my last post(which is an Okay way to do it), or when you do CutTree, don't move the mouse and the mouse should be on tree still, so therefor you could do a


while (isUpText('hop')) do
begin
FindNormalRandoms;
wait(random(2000));
SomeAntiBan;// Moving the compass, changing the angle etc..
etc etc
end;

Or you can find another way to do it, such as just waiting X number of seconds(random seconds) every time you click a tree. That is the easiest way.

If you still don't understand, don't worry, you can add me on MSN for further help.

[email]air_mc_roberts@hotmail.com[/email]

I have been a bit busy lately, so I may not be on often.

Bionicle

2010-02-23 15:30:58

In my woodcutting script I used two methods for checking to see if the tree was cut.
The first was simply an Animate procedure with the box around the character with a pixel shift of…400 i think. (If you don't know that procedure you can find it in Animation.scar :p)

The second one was if your character was not moving to the tree (If Not (IsMoving) Then), it clicked one right infront of it, it would save the color at the x, y coordinates, then check every so seconds to see if that color changed (the tree would be chopped).

Good luck!

Camaro'

2010-02-23 16:12:44

From: bionicle1800
In my woodcutting script I used two methods for checking to see if the tree was cut.
The first was simply an Animate procedure with the box around the character with a pixel shift of…400 i think. (If you don't know that procedure you can find it in Animation.scar :p)

The second one was if your character was not moving to the tree (If Not (IsMoving) Then), it clicked one right infront of it, it would save the color at the x, y coordinates, then check every so seconds to see if that color changed (the tree would be chopped).

Good luck!


I was thinking that, but when people play legit, do they honestly move the mouse back to the tree after an anti ban(or a mouse move?) Doesn't sound too human like to me.

Bionicle

2010-02-23 16:19:13

[QUOTE=Camaro';687649]I was thinking that, but when people play legit, do the honestly move the mouse back to the tree after an anti ban(or a mouse move?) Looks like a bot is playing. :p[/QUOTE]

You don't need to move the mouse back to the tree to check the color ;)

Procedure TreeWhateverThing;

Var
TheColor, TreeTime: Integer;

Begin
If FindTree Then
Begin
Mouse(X, Y, 3, 3, true);
If Not (IsMoving) Then
Begin
TheColor := GetColor(X, Y);
MarkTime(TreeTime);
Repeat
Wait(1000+Random(500));
If FindColor(X, Y, TheColor, MSX1, MSY1, MSX2, MSY2) Then
Break;
Until(TimeFromMark(TreeTime) > 30000);
End;
End;
End;

Alek000

2010-02-23 20:20:08

Thanks Camaro, I used

while (isUpText('hop')) do
begin
FindNormalRandoms;
wait(random(2000));
SomeAntiBan;// Moving the compass, changing the angle etc..
etc etc
end;

and now it doesn't constantly click the tree. But now it doesn't reclick it when it comes back or click any other trees. Man this writing scripts stuff is a lot harder than what I thought it would be lol

Camaro'

2010-02-23 22:17:34

From: bionicle1800
You don't need to move the mouse back to the tree to check the color ;)

Procedure TreeWhateverThing;

Var
TheColor, TreeTime: Integer;

Begin
If FindTree Then
Begin
Mouse(X, Y, 3, 3, true);
If Not (IsMoving) Then
Begin
TheColor := GetColor(X, Y);
MarkTime(TreeTime);
Repeat
Wait(1000+Random(500));
If FindColor(X, Y, TheColor, MSX1, MSY1, MSX2, MSY2) Then
Break;
Until(TimeFromMark(TreeTime) > 30000);
End;
End;
End;


A) Don't Color's shift?
B) That doesn't look like it would work at all? Maybe i'm wrong.

@ThreadMaker, please post the script. Thanks.

Alek000

2010-02-24 00:58:37

program WillowPowerChopper;
{.include SRL\SRL\misc\Smart.scar}
{.include SRL\SRL.scar}

const
World = 152;
Members = False;
SignedClient = True;
HighDetail = False;

Logs_To_Cut = 0;
H_Equipped = 0;
Lamp_Skill = 0;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Active := True;
Integers[Logs_To_Cut] := 10;
Booleans[H_Equipped] := True;
Strings[Lamp_Skill] := 'woodcutting';
end;
end;

procedure AntiBan;
var
i, x, y: Integer;
begin
case Random(40) of

0: begin // Boredhuman without camera movement.
Writeln('Performing Antiban - Boredhuman.');
if not LoggedIn then Exit;
for i := 1 to (1 + Random(5)) do
begin
MMouse(Random(MSX2), Random(MSY2), 0, 0);
if IsUpText('opti') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
ChooseOption('Examine');
end;
end;
end;

10: begin
Writeln('Performing Antiban - HoverSkill[Random].');
HoverSkill('random', False);
end;

20: begin
Writeln('Performing Antiban - RandomRClick.');
RandomRClick;
end;

30: begin
Writeln('Performing Antiban - HoverSkill[Woodcutting].');
HoverSkill('woodcutting', False);
end;

40: begin
Writeln('Performing Antiban - PickUpMouse.');
PickUpMouse;
end;
end;
end;

function CutWillows: Boolean;
var
x, y : Integer;
begin
if not LoggedIn then exit;
x := MSCX;
y := MSCY;
if FindColorSpiral(x, y, 2508087, MSX1, MSY1, MSX2, MSY2) then
begin
FindNormalRandoms;
Wait(500 + Random(100));
Writeln('Found tree!');
MMouse(x, y, 4, 4);
Wait(200 + Random(100));
if IsUpText('illow') then
begin
Wait(200 + Random(100));
Mouse(x, y, 0, 0, True);
Result := True;
end else
Writeln('Could not find Uptext!');
end else
Writeln('Could no find color!');
end;

procedure IsChopping;
begin
if not LoggedIn then exit;
while (IsUpText('illow')) do
begin
FindNormalRandoms;
Wait(60000 + Random (10000));
AntiBan;
end;
end;

begin
Smart_Server := World;
Smart_Members := Members;
Smart_Signed := SignedClient;
Smart_SuperDetail := HighDetail;
SetupSRL;
DeclarePlayers;
LoginPlayer;
SetAngle(True);
repeat
CutWillows;
IsChopping;
until(InvFull);
end.

Edit: You will see AntiBan from Coh3n's Draynor Chop N' Bank. I'm not going to keep it in there, I just needed something real quick so I could test out is IsChopping procedure.

Camaro'

2010-02-24 07:09:34

Thank you. I edited a some things such as

  • IsChopping now is a function
  • It checks in the beginning of the function to see if the upText is on a willow.
  • If anti-ban moves the mouse now, it will check the color the mouse was at(before the move), with a tolerance of two. If they aren't the same, it will return false(Saying to the script " I am not chopping" ).


program WillowPowerChopper;
{.include SRL\SRL\misc\Smart.scar}
{.include SRL\SRL.scar}

const
World = 152;
Members = False;
SignedClient = True;
HighDetail = False;

Logs_To_Cut = 0;
H_Equipped = 0;
Lamp_Skill = 0;

Var Cx,Cy,color:Integer;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Active := True;
Integers[Logs_To_Cut] := 10;
Booleans[H_Equipped] := True;
Strings[Lamp_Skill] := 'woodcutting';
end;
end;

procedure AntiBan;
var
i, x, y: Integer;
begin
if (isUpText('illow')) then
begin
GetMousePos(cx,cy);
Color := GetColor(cx,cy);
end;
case Random(40) of

0: begin // Boredhuman without camera movement.
Writeln('Performing Antiban - Boredhuman.');
if not LoggedIn then Exit;
for i := 1 to (1 + Random(5)) do
begin
MMouse(Random(MSX2), Random(MSY2), 0, 0);
if IsUpText('opti') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, False);
ChooseOption('Examine');
end;
end;
end;

10: begin
Writeln('Performing Antiban - HoverSkill[Random].');
HoverSkill('random', False);
end;

20: begin
Writeln('Performing Antiban - RandomRClick.');
RandomRClick;
end;

30: begin
Writeln('Performing Antiban - HoverSkill[Woodcutting].');
HoverSkill('woodcutting', False);
end;

40: begin
Writeln('Performing Antiban - PickUpMouse.');
PickUpMouse;
end;
end;
end;

function CutWillows: Boolean;
var
x, y : Integer;
begin
if not LoggedIn then exit;
x := MSCX;
y := MSCY;
if FindColorSpiral(x, y, 2508087, MSX1, MSY1, MSX2, MSY2) then
begin
FindNormalRandoms;
Wait(500 + Random(100));
Writeln('Found tree!');
MMouse(x, y, 4, 4);
Wait(200 + Random(100));
if IsUpText('illow') then
begin
Wait(200 + Random(100));
Mouse(x, y, 0, 0, True);
Result := True;
while (isMoving) do
wait(100+random(100));
end else
Writeln('Could not find Uptext!');
end else
Writeln('Could no find color!');
end;

function IsChopping:boolean;
var t:integer;
begin
if not LoggedIn then exit;
if not (IsUpText('illow')) then
begin
Result := false;//un-needed
writeln('Not Cutting');
exit;
end;
marktime(t);
repeat
FindNormalRandoms;
Wait(60000 + Random (10000));
AntiBan;
if not (IsUpText('illow')) then
begin
if not FindColorTolerance(cx,cy,Color,MSX1,MSY1,MSX1,MSY2, 3) then
begin
Result := false;//un-needed
writeln('Not Cutting');
exit;
end;
end;
until (timefrommark(t) > 40000)
result := true;
end;

begin
Smart_Server := World;
Smart_Members := Members;
Smart_Signed := SignedClient;
Smart_SuperDetail := HighDetail;
SetupSRL;
DeclarePlayers;
LoginPlayer;
SetAngle(True);
repeat
if (not(isChopping)) then
CutWillows;
until(InvFull);
end.

I don't have time to test, I would if I did, Please test it and get back to me on this thread to see if that does the job. :spot:

Alek000

2010-02-24 07:17:07

Thanks Camaro, it's finally not spam clicking :)

Camaro'

2010-02-24 17:39:39

From: Alek000
Thanks Camaro, it's finally not spam clicking :)


Your welcome ;)

Bionicle

2010-02-24 17:52:16

[QUOTE=Camaro';687778]A) Don't Color's shift?
B) That doesn't look like it would work at all? Maybe i'm wrong.

@ThreadMaker, please post the script. Thanks.

Yea, i kind of threw that togeather quickly, what i actualy did is saved the x, y coords to a tpoint, got the color at the x, y coords, then did a find colors tolerance within a box specified by the tpoint (like tpoint.x-15, etc), then repeated that, then if the tpointarray had a length below 10 or 15 i made the script assume the tree was chopped.