SRL Archive - Jr. Member General Help and Discussion

Finding bird's nests


IROC-Z

2014-12-05 00:09:51

I am looking to implement a nest/geode finder into an ivy script. This is what I have so far:


function findNest(): boolean;
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if not isLoggedIn then
exit;

if chatbox.findAnyText(['falls out of the iv']) then
begin
if findColorsSpiralTolerance(x, y, TPA, 3099216, mainScreen.getBounds(), 7, colorSetting(2, 0.34, 1.21)) //Bird's Nest color
or
findColorsSpiralTolerance(x, y, TPA, 15774489, mainScreen.getBounds(), 10, colorSetting(2, 0.02, 1.23)) //Geode Color
then

begin
if (Length(TPA) < 1) then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.filterBetween(0,250);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA)

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Take Bird']) or isMouseOverText(['Take Crystal'], 1000} then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;
end;
end else
exit;

I put it in the script in the ivy script and I watched two nests come and go.

I changed where it is in the script because it may have not been looking for it when it should be. Any suggestions on how the findNest function looks would be great!

bonsai

2014-12-05 03:53:52

I'm going to take a wild guess that chatbox.findanytext() is returning a messy string.

Tricky one to test since they are few and random.

fastler

2014-12-05 07:30:20

Everything looks good code-wise, as I've never used findAnyText() I wonder if that's the culprit.
Otherwise the only other problem could be the colors. Maybe they just need more tolerance and less bigotry. ^_^
It will be especially annoying to capture the several variants since these drops are such rare occurrences. Save your color profiles in ACA.
I looked at the bird nest color in PhotoShop and it might simply need a bump in tolerance to 9 or 10, but nothing beats having a solid color profile in ACA.

Ross

2014-12-05 08:50:52

From: IROC-Z
…


Try maybe:

if chatbox.findAnyText(['falls', 'out', 'iv']) then

IROC-Z

2014-12-05 11:16:25

From: Ross
Try maybe:

if chatbox.findAnyText(['falls', 'out', 'iv']) then


I tried using the chatbox.findAnyText but the script wouldn't compile, I must have messed something up. I'll try it again though.

Ross

2014-12-05 11:20:09

From: IROC-Z
I tried using the chatbox.findAnyText but the script wouldn't compile, I must have messed something up. I'll try it again though.


Maybe it doesn't look for an array of string then. Also I don't think that's what you're going to want to use because it's going to keep running that procedure constantly(since the message stays in your chatbox).

IROC-Z

2014-12-05 12:20:04

The message goes away if I don't have the game chat filter on. It will say "You successfully chopped the ivy" every time you chop some so the message saying "A bird's nest has fallen out of the ivy" will dissapear after not too long.I set it to check the four lines in case it doesn't run the check right away and the notification moves up a line. I noticed in a different ivy script the user just set it to check for the color of the nest. I figured looking out for the notification would be best so that if the color finder sees the same color it doesn't get stuck looking.

The Mayor

2014-12-05 15:35:24

You could make a DTM of the text. Add in some debug too, so you know where it is failing


function findNest(): Boolean;
var
x, y, i: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if not isLoggedIn() then
exit();

if findDTM(nextTextDTM, x, y, chatBox.getBounds()) then //could use a DTM of the text instead
begin
if findColorsSpiralTolerance(x, y, TPA, 3099216, mainScreen.getBounds(), 7, colorSetting(2, 0.34, 1.21)) or //Bird's Nest color
findColorsSpiralTolerance(x, y, TPA, 15774489, mainScreen.getBounds(), 10, colorSetting(2, 0.02, 1.23)) then //Geode Color
begin
if (length(TPA) < 1) then
exit();

ATPA := TPA.toATPA(30, 30);
ATPA.filterBetween(0,250); // that is quite large, I thought nest were tiny?

if length(ATPA) < 1 then
exit();

ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA)

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Take Bird', 'Take Crystal'], 1000) then
begin
fastClick(MOUSE_LEFT);
break();
end;
end;
end else
writeLn('Found text but didn''t find any colours');
end else
writeLn('Didn''t find any nest text');

end;

IROC-Z

2014-12-05 16:04:03

From: The Mayor
You could make a DTM of the text. Add in some debug too, so you know where it is failing


function findNest(): Boolean;
var
x, y, i: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if not isLoggedIn() then
exit();

if findDTM(nextTextDTM, x, y, chatBox.getBounds()) then //could use a DTM of the text instead
begin
if findColorsSpiralTolerance(x, y, TPA, 3099216, mainScreen.getBounds(), 7, colorSetting(2, 0.34, 1.21)) or //Bird's Nest color
findColorsSpiralTolerance(x, y, TPA, 15774489, mainScreen.getBounds(), 10, colorSetting(2, 0.02, 1.23)) then //Geode Color
begin
if (length(TPA) < 1) then
exit();

ATPA := TPA.toATPA(30, 30);
ATPA.filterBetween(0,250); // that is quite large, I thought nest were tiny?

if length(ATPA) < 1 then
exit();

ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA)

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Take Bird', 'Take Crystal'], 1000) then
begin
fastClick(MOUSE_LEFT);
break();
end;
end;
end else
writeLn('Found text but didn''t find any colours');
end else
writeLn('Didn''t find any nest text');

end;


I can look into that stuff and try it. And the reason why the ATPA.filterBetween is large is because while cutting ivys you are zoomed in all the way. And I got that number based off of a previous ivy cutter that had this type of function in it already.

I planned on adding debugs in so I can see if it actually calls the find nest procedure and where it stops in the function if it gets into it.

edit:
How would I make a DTM of the text? I've only done it for objects. I am not that familiar with it, of course. haha

The Mayor

2014-12-05 17:21:38

From: IROC-Z
I can look into that stuff and try it. And the reason why the ATPA.filterBetween is large is because while cutting ivys you are zoomed in all the way. And I got that number based off of a previous ivy cutter that had this type of function in it already.

I planned on adding debugs in so I can see if it actually calls the find nest procedure and where it stops in the function if it gets into it.

edit:
How would I make a DTM of the text? I've only done it for objects. I am not that familiar with it, of course. haha


To make your DTM, just select a bunch of points that make up the text. You don't need to select points from all the words, just enough to make the DTM unique to that string of text, so you don't get any false positives (you can check for any false matches in the DTM editor). I do it in GAO when I check for 'you've just gained a level'.

xtrapsp

2014-12-08 04:57:11

This is my out of date script:
https://villavu.com/forum/showthread.php?t=75528&page=10

It still works, not sure on the nests. But have a look :) Maybe it'l help you

IROC-Z

2014-12-08 14:00:01

From: The Mayor
To make your DTM, just select a bunch of points that make up the text. You don't need to select points from all the words, just enough to make the DTM unique to that string of text, so you don't get any false positives (you can check for any false matches in the DTM editor). I do it in GAO when I check for 'you've just gained a level'.


In between exams I found a little time to mess around with this. I created the DTM for the text and in the DTM editor it will pick up the text, but when I run the script it does not. I selected points on the words "fall out of the ivy". At first it was because the script wasn't calling the function when it should have been, so I moved it to a different place and it now continuously calls it but I cannot get it to find the text when it pops up. Do you have any suggestions?

Also, in regards to DTMs, when I stop the script it will say "The following DTMs were not freed:" and there will be a lot of numbers. Is this because I set up the DTM in the function itself? Will this cause a problem and what shall I do?

What I currently have is this:

Function findNest(): Boolean;
var
nestTextDTM, x, y, i: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
if not isLoggedIn() then
exit();

nestTextDTM := DTMFromString('m6wAAAHic42ZgYFjAzMCwAYh3APF+ID4DxBeAuBuIW4G4CYjrgbgSiKczMTDMYkLQ04B4BhDPBOI5UP4cqPx/oNkfGZnA9CcgrS4uz7AZyJblEWFYwc3L8ImJmeEnIyNYnhTASAJGAgCFShau');

if findDTM(nestTextDTM, x, y, chatBox.getBounds()) then
begin
if findColorsSpiralTolerance(x, y, TPA, 3099216, mainScreen.getBounds(), 7, colorSetting(2, 0.34, 1.21)) or //Bird's Nest color
findColorsSpiralTolerance(x, y, TPA, 15774489, mainScreen.getBounds(), 10, colorSetting(2, 0.02, 1.23)) then //Geode Color
begin
if (length(TPA) < 1) then
exit();

ATPA := TPA.toATPA(30, 30);
ATPA.filterBetween(0,250);

if length(ATPA) < 1 then
exit();

ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA)

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Take Bird', 'Take Crystal'], 1000) then
begin
fastClick(MOUSE_LEFT);
break();
end;
end;
end else
writeLn('Found text but didn''t find any colours');
end;

end;

I removed your "didn't find text" at the end because it kept spamming the debug.

3Garrett3

2014-12-08 14:36:41

From: IROC-Z
Also, in regards to DTMs, when I stop the script it will say "The following DTMs were not freed:" and there will be a lot of numbers. Is this because I set up the DTM in the function itself? Will this cause a problem and what shall I do?


Yes, the reason it has a bunch of numbers is because you're creating the DTM every time you call the function but never freeing it. You can either create a global DTM and create it once and free it at the end, or you can create the DTM every time and free it every time. Otherwise you'll notice the memory usage for Simba will increase the longer you run it.

As for why it doesn't work, it's hard to say from your code. Does it find the DTM and no colours or just never find the DTM? If that's the case then you're probably going to need some tolerance on the DTM or something, because there's not much you can do if the DTM doesn't work.

IROC-Z

2014-12-08 14:56:31

From: 3Garrett3
Yes, the reason it has a bunch of numbers is because you're creating the DTM every time you call the function but never freeing it. You can either create a global DTM and create it once and free it at the end, or you can create the DTM every time and free it every time. Otherwise you'll notice the memory usage for Simba will increase the longer you run it.

As for why it doesn't work, it's hard to say from your code. Does it find the DTM and no colours or just never find the DTM? If that's the case then you're probably going to need some tolerance on the DTM or something, because there's not much you can do if the DTM doesn't work.


That is what I thought about freeing the dtm but couldn't find the literature I read before.

In the DTM editor it will correctly find the DTM of the text I just made. But when applied to the script it won't find it. To change the tolerance would that be in the editor? I would change the tolerance for each point or is there a universal way to do it?

bonsai

2014-12-08 15:40:44

From: IROC-Z
That is what I thought about freeing the dtm but couldn't find the literature I read before.

In the DTM editor it will correctly find the DTM of the text I just made. But when applied to the script it won't find it. To change the tolerance would that be in the editor? I would change the tolerance for each point or is there a universal way to do it?


Yes, you need to click each point and edit the tolerance.

Here's a function if you want to alter all the points in a DTM from within a script.


// mod from bixby says post
procedure setDTMTol(var d: integer; tol: integer)

var
ts: TSDTM;
i: integer;
s: string;

begin
if not DTMExists(d) then exit;

ts := MDTMToSDTM(GetDTM(d));
for i := 0 to high(ts.subpoints) do
ts.subpoints[i].tolerance := tol;

s:= GetDTMName(d);
FreeDTM(d);
d := AddSDTM(ts);
SetDTMName(d, s);
end;

3Garrett3

2014-12-08 16:05:18

From: IROC-Z
That is what I thought about freeing the dtm but couldn't find the literature I read before.

In the DTM editor it will correctly find the DTM of the text I just made. But when applied to the script it won't find it. To change the tolerance would that be in the editor? I would change the tolerance for each point or is there a universal way to do it?


What bonsai said applies for tolerance. But if it's recognizing in the editor then it confuses me why it isn't recognizing in your script. It should in theory.

The Mayor

2014-12-08 17:52:36

Yea you should add some tolerance to each DTM point (maybe about 15 - 20 tol). Also add in a write line after if does find the DTM so you know if it is the mainScreen findColours that is failing.

IROC-Z

2014-12-08 18:20:54

From: The Mayor
Yea you should add some tolerance to each DTM point (maybe about 15 - 20 tol). Also add in a write line after if does find the DTM so you know if it is the mainScreen findColours that is failing.


I do have the "Found text but no colours" that you added. I'll get this working Wednesday after noon once I get these next three exams out of the way.