SRL Archive - Help and Support

Help with Woodcutting Script


A G E N T

2008-10-20 17:51:55

Hey all, I'm trying to do a Seer's village magic cutter - I don't think I've seen one and it seems like it would be a useful script.
I'm having a bit of trouble with walking - there's a big field I have to cross with no symbols (a few of the non-rare trees) and for now I'm stuck with blind clicking. If anyone could help me out with this (preferably colour-based, but Reflection is OK too I guess), it would be great. Also if anyone wants to buddy up with me on this one, I'd share credit :)

-Agent

program New;
{.include SRL/SRL.scar}
var
TTP : TPoint;
function AutoColor: Integer; //made by ACA v2, thanks Nielsie
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);

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

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

for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);

if (H >= 13.47) and (H <= 60.44) and (S >= 5.95) and (S <= 84.64) and (L >= 42.73) and (L <= 82.18) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 17.91) and (X <= 78.13) and (Y >= 19.35) and (Y <= 87.02) and (Z >= 12.00) and (Z <= 56.96) then
begin
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;

ColorToleranceSpeed(tmpCTS);

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

function FindBlackBlob(TPA:TPointArray) : TPoint;
var
i, n : integer;
TPA2 : TPointArray;
begin
n := 1;
for i := 0 to High(TPA) do
begin
if(GetColor(TPA[i].x - 1, TPA[i].y - 1) = 65536)then
begin
SetArrayLength(TPA2, n + 1);
TPA2[n].x := TPA[i].x - 1;
TPA2[n].y := TPA[i].y - 1;
Inc(n);
end;
if(GetColor(TPA[i].x + 1, TPA[i].y - 1) = 65536)then
begin
SetArrayLength(TPA2, n + 1);
TPA2[n].x := TPA[i].x + 1;
TPA2[n].y := TPA[i].y - 1;
Inc(n);
end;
if(GetColor(TPA[i].x - 1, TPA[i].y + 1) = 65536)then
begin
SetArrayLength(TPA2, n + 1);
TPA2[n].x := TPA[i].x - 1;
TPA2[n].y := TPA[i].y + 1;
Inc(n);
end;
if(GetColor(TPA[i].x + 1, TPA[i].y + 1) = 65536)then
begin
SetArrayLength(TPA2, n + 1);
TPA2[n].x := TPA[i].x + 1;
TPA2[n].y := TPA[i].y + 1;
Inc(n);
end;
end;
Result := MiddleTPA(TPA2);
end;

procedure ToTrees;
var
tx, ty : integer;
TTPA : TPointArray;
TP : TPoint;
begin
MakeCompass('N');
if(FindSymbolIn(tx, ty, 'tree', MMX1, (MMY1+((MMY2-MMY1)/2)), MMX2, MMY2))then
begin
Mouse(tx, ty, 2, 2, true);
Flag;
end else
begin
Writeln('Could not find tree symbol from bank - are you in the right place?');
NextPlayer(false);
Exit;
end;
Wait(100 + Random(200));
if(FindColorsTolerance(TTPA, 65536, MMX1, (MMY1+((MMY2-MMY1)/2)), MMX2, MMY2, 0))then
begin
TP := FindBlackBlob(TTPA);
Writeln('Black square is at: '+IntToStr(TP.x)+','+IntToStr(TP.y));
Mouse(TP.x-50, TP.y, 2, 2, true);
Flag;
end else
begin
Writeln('Could not find the black blob');
NextPlayer(false);
Exit;
end;
Wait(100 + Random(200));
if(not RadialWalk(GetSymbolColor(tx, ty, 'tree'), 180, 270, 100, 2, 2))then
begin
Writeln('Couldn'#39't find 2nd tree symbol');
NextPlayer(false);
Exit;
end;
if(not RadialWalk(FindRockColor, 180, 270, 100, 2, 2))then
begin
Writeln('Couldn'#39't find rock colour');
NextPlayer(false);
Exit;
end;
Wait(100 + Random(200));
Mouse((MMX1+(MMX2-MMX1)/2), MMY2-5, 2, 2, true); //Blind clicking - sigh.
Flag;
if(not RadialWalk(GetSymbolColor(tx, ty, 'tree'), 180, 280, 150, 2, 2))then
begin
Writeln('Couldn'#39't find 2nd tree symbol');
NextPlayer(false);
Exit;
end;
Wait(100 + Random(200));
end;

procedure ToBank;
var
tx, ty : integer;
begin
if(FindSymbol(tx, ty, 'tree'))then
begin
Mouse(tx, ty, 2, 2, true);
Flag;
end else
begin
Writeln('Couldn'#39'nt find tree symbol at trees... wtf?');
NextPlayer(false);
Exit;
end;
Wait(RandomRange(100, 500));
Mouse((MMX1+(MMX2-MMX1)/2), MMY1+10, 2, 2, true); //Blind clicking - sigh.
Wait(100);
Flag;
if(not RadialWalk(FindRockColor, 0, 90, 150, 2, 2))then
begin
Writeln('Couldn'#9'nt find rocks...');
NextPlayer(false);
Exit;
end;
if(not RadialWalk(GetSymbolColor(tx, ty, 'tree'), 0, 90, 150, 2, 2))then
begin
Writeln('Couldn'#39'nt find tree symbol #1...');
NextPlayer(false);
Exit;
end;
if(FindSymbol(tx, ty, 'spin'))then
begin
Mouse(tx+20, ty, 2, 2, true);
Flag;
end else
begin
Writeln('Couldn'#39'nt find wheel');
NextPlayer(false);
Exit;
end;
if(not RadialWalk(GetSymbolColor(tx, ty, 'tree'), 0, 90, 150, 2,2))then
begin
Writeln('Couldn'#39'nt find tree symbol #2');
NextPlayer(false);
Exit;
end;
if(not RadialWalk(FindLadderColor, 0, 90, 150, 2,2))then
begin
Writeln('Couldn'#39'nt find ladder');
NextPlayer(false);
Exit;
end;
end;

procedure Bank;
begin
OpenBankQuiet('vwb');
DepositAll;
end;
function FindTree : TPoint;
var
TPA : TPointArray;
TP : TPoint;
i : integer;
begin
for i:= 0 to 4 do
begin
FindColorsTolerance(TPA, AutoColor, MSX1, MSY1, MSX2, MSY2, 0);
TP := MiddleTPA(TPA);
MMouse(TP.x, TP.y, 2, 2);
if(IsUpText('agic'))then
begin
Writeln('Found magic tree');
Result := TP;
Exit;
end else
begin
Wait(400 + Random(100));
end;
end;
Result.x := 0;
Result.y := 0;
end;

procedure ChopTree(TP : TPoint);
var
tx, ty : integer;
begin
GetMousePos(tx, ty);
if((TP.x = tx) and (TP.y = ty))then
begin
Mouse(tx, ty, 0, 0, true); //better to not move the mouse if it is already there
end else
begin
Mouse(TP.x, TP.y, 1, 2, true);
end;
end;

begin
SetUpSRL;
ActivateClient;
{ ToTrees;
repeat
repeat
TTP := FindTree;
until(TTP.x > 0);
ChopTree(TTP);
repeat
if(IsUpText('agic'))then
begin
Wait(750 + Random(500));
end;
until(not IsUpText('agic'));
until(InvFull); }
ToBank;
Bank;
end.

Cazax

2008-10-20 18:18:03

Blind Click isn't good for walking. if you have to walk a big field then you should autocolor the grass, or make DDTM's(that would take some time tough). With reflection you should use Tiles. Remember to always use failsafes.

A G E N T

2008-10-20 19:02:17

Yeah, it's just a first draft, if you will…
Any ideas on how to autocolour the grass/trees?

Claymore

2008-10-20 20:51:14

You can use my auto-coloring for normal trees and try to create a dtm. I had a problem with this once (In my Law Runecrafter, so awesome i know) and anyways tarajunky created an auto-color for trees (I just made the code because he is helping me) anyways i used it for making a tree dtm on a bunch of trees. (Only 3 sub-points)

Then you do this.


FindDTMRotated(TreeDTM, X, Y, 500, 65, 580, 115, -5, 5, 0.1, Angle);

I searched for the DDTM on a specific area! And thats how i solved the problem. Could work for you.

EDIT:

You can check out my Seers Yew Whacker.

A G E N T

2008-10-21 16:38:27

Thanks, I'll have a look at it and see what I can do. :)