SRL Archive - SRL Archives

FindBirdsNest - Replacement Function


PriSoner

2008-02-03 11:51:49

The Current Function is Broken and could never work. :duh: (the logic in the initial if statement is back to front) I suspect at some point it has been deliberately broken as if the initial error is corrected it can end up getting stuck and never ending..

I have written my own function and tested it, after a few revisions it now works for me in my script without a single problem it has never missed a nest drop or failed to pick it up.

It has been tested extensively in EdgeVille, It could do with testing in other tree locations and I would appreciate anyone will to test it and provide feedback.

It can be dropped into SRL as a replacement to the existing non working function and all existing scripts that reference it will still be compatible and actually start picking up nests as intended. :)

It would seem that nearly every woodcutting script uses this function even though it doesn't work, so an update would probably go down well. :)

Please Give it a go and Give me feedback..

Updated 07 Feb 2007 Please read post #17 for changes.
{*******************************************************************************
function: MyFindBirdsNest: Boolean;
By: Prisoner
Description: Attempts to a Find Birds Nest if one is dropped & Pick it up.
If it can't find one within 90 seconds it exits as Fallen Birds Nests do not last that long.
Returns User to Users Last Compass Position when it exits.
*******************************************************************************}
function MyFindBirdsNest;
var OriginalDegrees, NewDegree, StartFBN, x, y, i, ctab: Integer;
b: boolean;
begin
if not LoggedIn then exit;
if Pos('nest falls', GetBlackChatMessage) = 10 then
begin
result := true;
b := false;
writeln('Birds Nest Drop Detected. Attempting To Find It...');
MarkTime(StartFBN);
SetAngle(true);
OriginalDegrees := Round(rs_GetCompassAngleDegrees);
NewDegree := OriginalDegrees;
ctab := GetCurrentTab;
repeat
if (FindObj(x, y, 'Take Bird', 3623505, 6)) then
begin
WriteLn('Birds Nest Found. Picking Up...');
Mouse(x, y, 1, 1, True);
Flag;
Wait(500 + Random(500));
Birdsnest := Birdsnest + 1;
GameTab(4);
SetAngle(true);
MakeCompass(IntToStr(OriginalDegrees));
GameTab(ctab);
for i := 1 to 5 do
begin
Mouse(575, 225, 3, 3, False);
Wait(300 + Random(500));
ChooseOption('xamine');
Wait(1000 + Random(1000));
if Pos('nest falls', GetBlackChatMessage) <> 10 then exit;
end;

exit;
end else
begin
if b then
begin
SetAngle(false);
b := false;
end else
begin
SetAngle(True);
NewDegree := (NewDegree + 25 + Random(30));
MakeCompass(IntToStr(NewDegree));
b := true;
end;
end;
until TimeFromMark(StartFBN) > 90000;
WriteLn('Birds Nest Not Found Within Required Time. Aborting...');
MakeCompass(IntToStr(OriginalDegrees));
SetAngle(True);
GameTab(ctab);

for i := 1 to 28 do
begin
if ExistsItem(i) then
begin
MMouseItem(i);
GetMousePos(x, y);
Mouse(x, y, 5, 5, false);
Wait(300 + Random(500));
ChooseOption('Examine');
Wait(1000 + Random(1000));
if Pos('nest falls', GetBlackChatMessage) <> 10 then exit;
end else
begin
GameTab(5);
Wait(1000 + Random(900));
Mouse(580, 300, 5, 5, false);
Wait(300 + Random(500));
ChooseOption('xamine');
Wait(1000 + Random(1000));
end;
end;
exit;
end;
end;

My original function for comparison
{*******************************************************************************
function: MyFindBirdsNest: Boolean;
By: Prisoner
Description: Attempts to a Find Birds Nest if one is dropped & Pick it up.
If it can't find one within 90 seconds it exits as Fallen Birds Nests do not last that long.
Returns User to Users Last Compass Position when it exits.
*******************************************************************************}

function: MyFindBirdsNest: Boolean;
var OriginalDegrees, NewDegree, StartFBN, x, y: Integer;
b: boolean;
begin
result := false;
if not LoggedIn then exit;
if Pos('nest falls', GetNewChatMsg) = 10 then
begin
result := true;
b := false;
writeln('Birds Nest Drop Detected. Attempting To Find It...');
MarkTime(StartFBN);
SetAngle(true);
OriginalDegrees := Round(rs_GetCompassAngleDegrees);
NewDegree := OriginalDegrees;
repeat
if (FindObj(x, y, 'Take Bird', 3623505, 6)) then
begin
WriteLn('Birds Nest Found. Picking Up...');
Mouse(x, y, 1, 1, True);
Flag;
Wait(500 + Random(500));
Birdsnest := Birdsnest + 1;
GameTab(4);
Mouse(575, 225, 5, 5, False);
ChooseOption('Examine');
Wait(1000 + Random(1000));
SetAngle(true);
MakeCompass(IntToStr(OriginalDegrees));
exit;
end else
begin
if b then
begin
SetAngle(false);
b := false;
end else
begin
SetAngle(True);
NewDegree := (NewDegree + 25 + Random(30));
MakeCompass(IntToStr(NewDegree));
b := true;
end;
end;
until TimeFromMark(StartFBN) > 90000;
WriteLn('Birds Nest Not Found Within Required Time. Aborting...');
GameTab(4);
Mouse(575, 225, 5, 5, False);
ChooseOption('Examine');
MakeCompass(IntToStr(OriginalDegrees));
end;
end;

If You Use and Like it Please Rate This Thread..

n3ss3s

2008-02-03 11:55:55

MakeCompass(IntToStr(NewDegree));


I don't think that it somehow changes a number to n,e,s,w

bullzeye95

2008-02-03 11:58:23

{*******************************************************************************
function MakeCompass(Direction: string): Boolean;
By: Nielsie95
Description: Aligns RS to specified direction
direction: Enter a specific side ('n', 'e', 's', 'w')
or enter a degree(for example: '153' or '23')
*******************************************************************************}
Doesn't have to ;)

You might want to try something other than FindObj… I think it's quite unreliable.

n3ss3s

2008-02-03 12:00:00

Oh, thanks bullzeye, and yeah, use a TPA and then a TPAToATPAEx with 12, 12, should be about the size of the nest.

PriSoner

2008-02-03 12:00:46

MakeCompass requires a string with a direction. That can be n, e, s, w or a degree i.e 0 would be North, 90 would be East or 45 would be Nort East.

MakeCompass(IntToStr(NewDegree)); passes back a degree..

{*******************************************************************************
function MakeCompass(Direction: string): Boolean;
By: Nielsie95
Description: Aligns RS to specified direction
direction: Enter a specific side ('n', 'e', 's', 'w')
or enter a degree(for example: '153' or '23')
*******************************************************************************}

PriSoner

2008-02-03 12:07:12

Lol very quick replies.. :D

I have tried other methods but FindObj has so far been the most reliable as quite often the nest will fall under you or another player.

So far it's caught, found and picked up every nest dropped without a problem.

FindObj usually encounters problems because of conflicting colours and matches. as it is only called when there is a definate match this doesn;t really factor as much of a problem.

I will keep refining it though and trying other methods to macth as I learn them..

n3ss3s

2008-02-03 12:33:18

a) Don't double post
b) I know degrees.
c) TPAs eat FindObjs for breakfast.

PriSoner

2008-02-03 12:48:50

a) Sorry.. I posted when only you had responded by the time I hit submit there were more responses..
b) If you know degrees don't point out degree related errors that don't exist.
c) I will try FindObjTPA but at the moment it is a very simple function that works very quickly and very reliably..

n3ss3s

2008-02-03 13:07:54

b) If you know degrees don't point out degree related errors that don't exist.


I asked, not claimed. I hadn't viewed the source and thus couldn't know it also accepts degrees.


And I didn't mean that you have to use FindObjTPA, make an obj finder yourself. You'll find yourself finding the nest perfectly without uptext checking in under 40ms with tpas.

Negaal

2008-02-04 02:02:45

I had no idea that text appears when nest falls:p
if Pos('nest falls', GetNewChatMsg) = 10 then 
Why it's = 10, It could be > 0?
Don't think it's more accurate :confused:

Think I'm going to add something like that to my willowcutter

n3ss3s

2008-02-04 08:22:32

{*******************************************************************************
function GetLastChatText(var chat: String): Boolean;
By: masquerader / Wizzup?
Description: Returns true if blue chat text was found
*******************************************************************************}


and the game texts are black, player texts are blue.

So, use GetBlackChatMessage.

And if we wouldn't use GetBlackChatMessage, then the pos 10 would increase accuracy, but now we use black, and it is quite unlikely that the chatbox gets pissed at your script and says
"A birds nest falls o.. AHA! R0phl hell no am I goin to drop ma birdies!"…

PriSoner

2008-02-04 17:22:53

From: Negaal
I had no idea that text appears when nest falls:p
if Pos('nest falls', GetNewChatMsg) = 10 then 
Why it's = 10, It could be > 0?
Don't think it's more accurate :confused:

Think I'm going to add something like that to my willowcutter

The actual text that appears in the chatbox is: A bird's nest falls out of the tree. By making it = 10 instead of > 0 I'm decreasing the chance of false possitives.. (There are alll sorts of things that could cuase a match when examined).. It makes very little difference but why not have it spot on?

By all means.. Please try out the function in your Willow Cutter.. the more it gets tested the more we can iron out any possible bugs and conflicts..



From: n3ss3s
So, use GetBlackChatMessage.

And if we wouldn't use GetBlackChatMessage, then the pos 10 would increase accuracy, but now we use black, and it is quite unlikely that the chatbox gets pissed at your script and says
"A birds nest falls o.. AHA! R0phl hell no am I goin to drop ma birdies!"…


I'm trying out GetBlackChatMessage now.. Thanks for the tip off…


It's still working fantastically for me… Please try it out one an all and report back any problems….

Naum

2008-02-05 11:59:16

Maybe use IsUpText? and switch to objcustom :)

Negaal

2008-02-05 14:59:23

From: NaumanAkhlaq
Maybe use IsUpText? and switch to objcustom :)


UpText in chatbox? :confused:

And FindObjCutsom makes really wierd movements…it moves mouse trough every pixel…

FrÕzÑ_§ÕµL

2008-02-05 15:15:23

I look forward to this being released into SRL, I didn't even know the current one was broken lol :p but I have no member accounts so can not test sorry, and I will not include it in a release with so much argument over what is wrong with it lol.

PriSoner

2008-02-05 20:59:49

From: FrÕzÑ_§ÕµL
I look forward to this being released into SRL, I didn't even know the current one was broken lol :p but I have no member accounts so can not test sorry, and I will not include it in a release with so much argument over what is wrong with it lol.

I don't think anyone is arguing about what is wrong with it.. Just sugesting ways it may be improved.. At the end of the day it works perfectly for me now and no-one has come back and said they have any problems with it..

From: NaumanAkhlaq
Maybe use IsUpText? and switch to objcustom :)

IsUpText.. as Negaal said and I did consider FindObjCustom at first and try it but again as Negaal points out it aint that great..

PriSoner

2008-02-07 09:11:21

Updated…

Now uses GetBlackChatMessage instead of GetNewChatMsg minor change which just makes the risk of a false positive even more remote.. Thanks Negaal

Added GetCurrentTab to return the GameTab to it's original position after exit.

Made the routine that changes the Last Black Chat Message after picking up the nest much more robust.. It once failed to update the message due to a small lag.. it should now cope with this.

Added a routine to Change the Last Black Chat Message in the unlikley event that no birds nest is found (This has not happened yet (h) ). It looks for items in your inventory and examines one should one exist. If no items exist in your inventory it examines the item in your hand. (This is based on the fact that a nest can only fall if you are chopping a tree, in order to chop a tree an axe must be present in either hand or inventory).

Please try it out and give me feedback.. This has been working very well & very quickly for me with a 100% record of picking up birds nests.
{*******************************************************************************
function: MyFindBirdsNest: Boolean;
By: Prisoner
Description: Attempts to a Find Birds Nest if one is dropped & Pick it up.
If it can't find one within 90 seconds it exits as Fallen Birds Nests do not last that long.
Returns User to Users Last Compass Position when it exits.
*******************************************************************************}
procedure MyFindBirdsNest;
var OriginalDegrees, NewDegree, StartFBN, x, y, i, ctab: Integer;
b: boolean;
begin
if not LoggedIn then exit;
if Pos('nest falls', GetBlackChatMessage) = 10 then
begin
b := false;
writeln('Birds Nest Drop Detected. Attempting To Find It...');
MarkTime(StartFBN);
SetAngle(true);
OriginalDegrees := Round(rs_GetCompassAngleDegrees);
NewDegree := OriginalDegrees;
ctab := GetCurrentTab;
repeat
if (FindObj(x, y, 'Take Bird', 3623505, 6)) then
begin
WriteLn('Birds Nest Found. Picking Up...');
Mouse(x, y, 1, 1, True);
Flag;
Wait(500 + Random(500));
Birdsnest := Birdsnest + 1;
GameTab(4);
SetAngle(true);
MakeCompass(IntToStr(OriginalDegrees));
GameTab(ctab);
for i := 1 to 5 do
begin
Mouse(575, 225, 3, 3, False);
Wait(300 + Random(500));
ChooseOption('xamine');
Wait(1000 + Random(1000));
if Pos('nest falls', GetBlackChatMessage) <> 10 then exit;
end;

exit;
end else
begin
if b then
begin
SetAngle(false);
b := false;
end else
begin
SetAngle(True);
NewDegree := (NewDegree + 25 + Random(30));
MakeCompass(IntToStr(NewDegree));
b := true;
end;
end;
until TimeFromMark(StartFBN) > 90000;
WriteLn('Birds Nest Not Found Within Required Time. Aborting...');
MakeCompass(IntToStr(OriginalDegrees));
SetAngle(True);
GameTab(ctab);

for i := 1 to 28 do
begin
if ExistsItem(i) then
begin
MMouseItem(i);
GetMousePos(x, y);
Mouse(x, y, 5, 5, false);
Wait(300 + Random(500));
ChooseOption('Examine');
Wait(1000 + Random(1000));
if Pos('nest falls', GetBlackChatMessage) <> 10 then exit;
end else
begin
GameTab(5);
Wait(1000 + Random(900));
Mouse(580, 300, 5, 5, false);
Wait(300 + Random(500));
ChooseOption('xamine');
Wait(1000 + Random(1000));
end;
end;
exit;
end;
end;

FrÕzÑ_§ÕµL

2008-03-04 13:24:06

Thanks pris, have added to my next version of frostbite :)

Edit : Why do you have result := true in a procedure…

PriSoner

2008-03-04 18:53:01

whoops.. tis supposed to be a function :) forgot to rename it back after a test.. Just rename procedure to function as I have above and it will return true if a nest is found… makes no real difference just would allow you to also perform an action of your own if a birds nest is found.

Let me know how it works for you.. It has worked perfectly for me and is very robust..

Just check my script stats.. over 264 nests found and picked up..

Gu3st...

2008-03-05 08:10:56

Made it into function with an option to choose to pick up or not..

{*******************************************************************************
function: MyFindBirdsNest(Pickup : Boolean): Boolean;
By: Prisoner
Description: Attempts to a Find Birds Nest if one is dropped & Pick it up.
If it can't find one within 90 seconds it exits as Fallen Birds Nests do not last that long.
Returns User to Users Last Compass Position when it exits.
*******************************************************************************}
function MyFindBirdsNest(Pickup : Boolean): Boolean;
var OriginalDegrees, NewDegree, StartFBN, x, y, i, ctab: Integer;
b: boolean;
begin
if not LoggedIn then exit;
if Pos('nest falls', GetBlackChatMessage) = 10 then
begin
b := false;
writeln('Birds Nest Drop Detected. Attempting To Find It...');
MarkTime(StartFBN);
SetAngle(true);
OriginalDegrees := Round(rs_GetCompassAngleDegrees);
NewDegree := OriginalDegrees;
ctab := GetCurrentTab;
repeat
if (FindObj(x, y, 'Take Bird', 3623505, 6)) then
begin
WriteLn('Birds Nest Found...');
Result := True;
if (Pickup) then
begin
Mouse(x, y, 1, 1, True);
Flag;
Wait(500 + Random(500));
Birdsnest := Birdsnest + 1;
GameTab(4);
SetAngle(true);
MakeCompass(IntToStr(OriginalDegrees));
GameTab(ctab);
for i := 1 to 5 do
begin
Mouse(575, 225, 3, 3, False);
Wait(300 + Random(500));
ChooseOption('xamine');
Wait(1000 + Random(1000));
if Pos('nest falls', GetBlackChatMessage) <> 10 then exit;
end;
exit;
end;
end;
end else
begin
if b then
begin
SetAngle(false);
b := false;
end else
begin
SetAngle(True);
NewDegree := (NewDegree + 25 + Random(30));
MakeCompass(IntToStr(NewDegree));
b := true;
end;
end;
until TimeFromMark(StartFBN) > 90000;
WriteLn('Birds Nest Not Found Within Required Time. Aborting...');
MakeCompass(IntToStr(OriginalDegrees));
SetAngle(True);
GameTab(ctab);

for i := 1 to 28 do
begin
if ExistsItem(i) then
begin
MMouseItem(i);
GetMousePos(x, y);
Mouse(x, y, 5, 5, false);
Wait(300 + Random(500));
ChooseOption('Examine');
Wait(1000 + Random(1000));
if Pos('nest falls', GetBlackChatMessage) <> 10 then exit;
end else
begin
GameTab(5);
Wait(1000 + Random(900));
Mouse(580, 300, 5, 5, false);
Wait(300 + Random(500));
ChooseOption('xamine');
Wait(1000 + Random(1000));
end;
end;
exit;
end;
end;

I did not test…

PriSoner

2008-03-05 08:33:52

I left it without options purely to keep it compatible with the existing broken SRL function.. That way if it is decided to include it in SRL woodcutting, the existing function can just be overwritten with this.

Also picking the birds nest up works perfectly, efficiently and is the overriding reason for the function.

The reason it returns true or false upon finding and picking up a nest is that you may want to add a routine to deal with a found nest; (drop unwanted nest type's, empty the contents, keep only the highest value seeds etc..)

Feel free to modify it to your needs as you will though… :D