SRL Archive - OSR Help

Ambiguous Colors


elpreda

2012-05-09 06:26:03

Hello,
I tried creating my first script after finding this forum yesterday. I've never used Pascal or Simba before but I have some experience in C, Java, Racket, Clips and Prolog.
I wanted to make a simple script for collecting and burying bones at the Chaos Temple in the wilderness, but I run into a rather nasty problem: the bone and the enviorment have pretty much the same color and it's almost impossible to make the difference. The basic find color with tolerance was just clicking around the place randomly, SmartColors was just clicking around the bones for a while then stopping, ACA v2 was unable to distinguish between just the bone and the ground, although it did collect some bones at first it would just run like crazy somewhere else in the wild after some time. I could make a condition to not go too far away from the starting point, but the efficiency would still be terrible. I didn't try DTMs because i thought they would be useless for the main screen. The burying part works well btw. I do not yet know many functions in Simba, so this is why I am asking for help: is there anything that could be used for color recognition in this case or should I just click on coordinates with some random waiting in between?

Narcle

2012-05-09 06:30:31

If the bones show up on MiniMap you can narrow your search area down using MMtoMS.

Abu

2012-05-09 11:17:12

From: elpreda
I didn't try DTMs because i thought they would be useless for the main screen.


Who told you that? I've never had problems using DTM's to recognise items/objects on the main screen.

footballjds

2012-05-09 11:19:32

is TPA's, possible multiple TPA's with different colors and ensure they're within x pixels of each other.

elpreda

2012-05-09 12:55:14

Thanks for the quick replies.
I tried to narrow the search area using the minimap. I searched for red spot on the minimap, translated them with MMtoMS, used ACA on bones and searched with FindObjectEx in an 40 pixel radius of the point returned by MMtoMS. The problem however is that MMtoMS always returns (-1,-1). I checked the coordinates transmited and they were valid. I looked at GridCoords16Ex but I don't know the way how the map is built so I couldn't really make anythinig of it.

footballjds

2012-05-09 13:22:01

From: elpreda
Thanks for the quick replies.
I tried to narrow the search area using the minimap. I searched for red spot on the minimap, translated them with MMtoMS, used ACA on bones and searched with FindObjectEx in an 40 pixel radius of the point returned by MMtoMS. The problem however is that MMtoMS always returns (-1,-1). I checked the coordinates transmited and they were valid. I looked at GridCoords16Ex but I don't know the way how the map is built so I couldn't really make anythinig of it.


mind posting the code you're using? I'm sure we can all help you much better if we can see into your mind(code).

elpreda

2012-05-09 13:27:49

 procedure main;
var x,y,auto,ox,oy: Integer;
first :boolean;
spoint :Tpoint;
begin
while (true) do
begin
Antiban;
AntiRandoms;
if FindColorSpiralTolerance(x, y, 12369349, MIX1, MIY1, MIX2, MIY2, 10) then
begin
Mouse(x, y, 4, 4, True);
Wait(700);
end;

auto := ColorBone;
if FindColorSpiralTolerance(x, y, 1840372, MMX1, MMY1, MMX2, MMY2, 70) then
begin
spoint:=MMtoMS(Point(x,y));
writeln(IntToStr(spoint.x)+' '+IntToStr(spoint.y));
writeln(IntToStr(max(spoint.x - 40,0))+' '+IntToStr(max(0,spoint.y - 40))+' '+IntToStr(max(0,spoint.x + 40))+' '+IntToStr(max(0,spoint.y + 40)));
FindObjEx(ox,oy,['on','es'],[auto],10,50,max(spoint.x - 40,0),max(0,spoint.y - 40),max(0,spoint.x + 40) ,max(0,spoint.y + 40));
writeln(IntToStr(ox)+' '+ IntToStr(oy));
Mouse(ox, oy, 4, 4, True);
Wait(6000);
end;
end;
end;

footballjds

2012-05-09 13:33:44

function FindEleBal(var x, y: integer): boolean;
var
YelDots: TPointArray;
MSdot: TPoint;
begin
YelDots := GetMiniMapDots('y');
if Length(YelDots) < 1 then EXIT;

SortTPAFrom(YelDots, Point(MMCX, MMCY));

MSdot := MMtoMS(YelDots[0]);
result := FindColorTolerance(x, y, 11580598, MSdot.x-45, MSdot.y-45, MSdot.x+45, MSdot.y+45, 27);

end;

That is how I find the elemental balance in a POH by searching first for the yellow dot on the MM and converting that point into a main screen point.

Try using something similar except obviously red dots as opposed to yellow. If you need info on what params getMinimapDots accepts look in the include :)

elpreda

2012-05-09 14:19:31

I used the GetMiniMapDots function and it seems to work, though it still finds and clicks spots far away from any red dots on the minimap. Still, it does collect bones this way.
However there seems to be a new problem, i am getting an error about DTM's. I haven't used any DTMs in this script so I asume it's some function.
I am getting the error on this line:
spoint:=MMtoMS(reds[i]);

the error message is:

Error: Out Of Range at line 115
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]

footballjds

2012-05-09 14:21:36

From: elpreda
I used the GetMiniMapDots function and it seems to work, though it still finds and clicks spots far away from any red dots on the minimap. Still, it does collect bones this way.
However there seems to be a new problem, i am getting an error about DTM's. I haven't used any DTMs in this script so I asume it's some function. I am getting the error on this line:
spoint:=MMtoMS(reds[i]);

the error message is:

Error: Out Of Range at line 115
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap]


the dtm thing isn't an error, it's just letting you know that the script crashed and those dtms were not freed so it freed them for you.

Your error is an out of range error, you're trying to access something in the array that isn't there.
If you post your code i can point it out.

elpreda

2012-05-09 14:42:29

I see, so it's basically a segmentation fault. I checked the code and found the problem, fixed it and it seems to be running well. Thank you for your help.
Now I need to figure out how to check when the inventory is full so I don't have to bury every bone when I find it, make a progress report and tidy up the code a bit.

footballjds

2012-05-09 15:51:42

From: elpreda
I see, so it's basically a segmentation fault. I checked the code and found the problem, fixed it and it seems to be running well. Thank you for your help.
Now I need to figure out how to check when the inventory is full so I don't have to bury every bone when I find it, make a progress report and tidy up the code a bit.


there is a function in the include for to see if your inventory is full.
Actually. the function is simply: InvFull

so you could is it like so:


if InvFull then BuryBones;
where BuryBones is your procedure to bury bones.

cause

2012-05-09 17:39:07

I find InvFull to not always be accurate, I'd suggest

If finddtm(bonedtm, etc…) then Bury

And just have it search for the bonedtm in the last inv spot.
Or, just have it search the whole inv and bury every time you pick one up, both ways are probably as efficient.

footballjds

2012-05-09 17:57:40

From: cause
I find InvFull to not always be accurate, I'd suggest

If finddtm(bonedtm, etc…) then Bury

And just have it search for the bonedtm in the last inv spot.
Or, just have it search the whole inv and bury every time you pick one up, both ways are probably as efficient.


invfull just loops through each inv slot and runs an itemexists on it.
I don't see how it could possibly fail… and if it EVER does we have a huge issue meaning itemexists isn't working…

invfull has never failed me.

elpreda

2012-05-09 20:45:22

Ok, I finished the bury function, I made some failsafes in case it wanders away from the Chaos Temple making it return if it's not too far away and I made the report progress too. I'm going to let it run for the night and tomorrow, if everything goes alright, i am going to post it.

footballjds

2012-05-10 09:30:09

From: elpreda
Ok, I finished the bury function, I made some failsafes in case it wanders away from the Chaos Temple making it return if it's not too far away and I made the report progress too. I'm going to let it run for the night and tomorrow, if everything goes alright, i am going to post it.


awesome man!
make sure to post a link here I wanna see/critique :)