SRL Archive - SRL Archives

Woodcutting.scar update


cycrosism

2009-07-12 19:37:03

The current FindBirdsNest is a procedure, could a dev change it to this:


{*******************************************************************************
Function FindBirdsNest: Boolean;
By: Liquid and Starblaster100 with edit by cycrosism
Description: If a birds nest is found, it will pick it up
*******************************************************************************}

Function FindBirdsNest: Boolean;
var
tries, x, y: Integer;
s: string;
begin
if (not (GetLastChatText(s))) then
LastChatter(s);
if (Pos(s, 'A bird') <> 0) then
begin
repeat
if not (FindObj(x, y, 'Take Bird', 3952984, 10)) or
not (FindObj(x, y, 'Take Bird', 1713706, 10)) or
not (FindObj(x, y, 'Take Bird', 1581604, 10)) then
begin
KeyDown(VK_LEFT);
Wait(700 + Random(500));
KeyUp(VK_LEFT);
Wait(400 + Random(300));
end;
if not (FindObj(x, y, 'Take Bird', 3952984, 10)) or
not (FindObj(x, y, 'Take Bird', 1713706, 10)) or
not (FindObj(x, y, 'Take Bird', 1581604, 10)) then
begin
x := 648;
y := 83;
tries := tries + 1;
FindColorSpiral(x, y, 241, 570, 5, 725, 155);
Mouse(x + 3, y + 3, 2, 2, True);
Flag;
Wait(200 + Random(100));
end;
if (FindObj(x, y, 'Take Bird', 3952984, 10)) or
(FindObj(x, y, 'Take Bird', 1713706, 10)) or
(FindObj(x, y, 'Take Bird', 1581604, 10)) then
begin
WriteLn('Birds Nest Found');
Result := True;
Wait(450 + Random(400));
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
Flag;
Wait(500 + Random(300));
if (Screenshots) then
SaveScreenshot('Birds Nest - SRL - ' + IntToStr(GetTimeRunning) + '.bmp');
tries := tries + 100;
// Birdsnest := Birdsnest + 1;
Mouse(583, 226, 2, 2, False);
Wait(100 + Random(100));
ChooseOption('Examine');
Exit;
end;
until (FindObj(x, y, 'Take Bird', 3952984, 10)) or
(FindObj(x, y, 'Take Bird', 1713706, 10)) or
(FindObj(x, y, 'Take Bird', 1581604, 10)) or (tries > 5)
end;
end;

It is just easier to use and better when it returns something :)

noidea

2009-07-12 19:41:27

I believe that other people have made better birdnest functions.

cycrosism

2009-07-12 19:42:24

I didn't make it i just made it a function and added Result := True; to it

ZephyrsFury

2009-07-12 19:48:03

Done and done although I don't even think this works.

Floor66

2009-07-12 19:51:51

Try this:

Function SearchBirdsNest: Boolean;
Var
CTS, i, x, y : Integer;
NestATPA : T2DPointArray;
NestTPA : TPointArray;
Nest : TPoint;
Timer : LongInt;
Begin
If (FindText(x, y, 'nest falls', SmallChars, 0, 400, 495, 460)) then
Begin
MarkTime(Timer);
Repeat
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
x := MSCX;
y := MSCY;
FindColorsSpiralTolerance(x, y, NestTPA, 3952984, MSCX - 100, MSCY - 100, MSCX + 100, MSCY + 100, 15);
NestATPA := TPAtoATPAEx(NestTPA, 5, 5);
For i := 0 to (Length(NestATPA) - 1) Do
Begin
If (TimeFromMark(Timer) >= (10000)) Then
Exit;
Nest := MIddleTPA(NestATPA[I]);
MMouse(Nest.x, Nest.y, 5, 5);
Wait(50 + Random(100));
If IsUpText('ird') Then
Begin
Mouse(Nest.X, Nest.Y, 5, 5, True);
Result := True;
Inc(User[CurrentPlayer].Nests);
Wait(250 + Random(150));
Write('Birds nest found.');
Exit;
End;
End;
Until((TimeFromMark(Timer) >= (10000)) Or Result);
Exit;
End;
End;

Worked last time I checked in my private wcer.

Sir R. M8gic1an

2009-07-13 01:19:48

yeah… that function definitely nees a re-write.

~RM

ZephyrsFury

2009-07-13 06:02:59

From: Rasta Magician
yeah… that function definitely nees a re-write.

~RM


Hehe, 12 FindObjs to find one thing… I lol'd. No offence to Star and Liquid.

Nava2

2009-07-13 07:21:45

I believe mine works, I could have swore I committed it.

It is really fast.

I will commit tomorrow, check the pub svn for it if you like.