SRL Archive - OSR Help

DTM Can't Be Found On Minimap


SomeGuyFromHere

2013-02-18 11:29:56

Hey,

for a failsafe I need my script to check if the character is on the right floor of a building. I got the idea to simply check if there is a block of black on the minimap which is a tell-tail sign for that.

RightFloor:= DTMFromString('mWAAAAHicY2FgYJjGxMCwBIjnA/FEIJYAiikDsQYQywMxMyMLCkYHjGgYBADlsAMd');

if FindDTM(RightFloor, x, y, 520, 0, 740, 169) then

begin
Writeln('Walked the stairs successfully, I am on floor #2 now');
end else

begin
Writeln('Something went wrong, the stairs were not clicked correctly. Trying again…');
end;


Well, it simply doesn't work. I had problems with DTMs not being detected due to unknown reasons and it somehow always worked out when playing with the coordinates in which the FindDTM procedure searches, this time I can't make it work. The cordinates you see in this example are the minimap, and the DTM is composed only of black points, so I don't see the problem.

Any ideas, fellow scripters? :)

King

2013-02-18 11:33:55

From: SomeGuyFromHere
Hey,

for a failsafe I need my script to check if the character is on the right floor of a building. I got the idea to simply check if there is a block of black on the minimap which is a tell-tail sign for that.



Well, it simply doesn't work. I had problems with DTMs not being detected due to unknown reasons and it somehow always worked out when playing with the coordinates in which the FindDTM procedure searches, this time I can't make it work. The cordinates you see in this example are the minimap, and the DTM is composed only of black points, so I don't see the problem.

Any ideas, fellow scripters? :)


Why not just search a specific section of the minimap that always contains black for the color?

FindColorsTolerance(x, y, ColorForBlackHere, MMX1, MMY1, MMX2, MMY2, 100)
You can replace {MMX1, MMY1, MMX2, MMY2} with the coordinates.

SomeGuyFromHere

2013-02-18 12:06:40

Tried it, it doesn't work either! Don't really know what's up here. Here is a screenshot:



and the part of the procedure responsible for the whole thing looks like this:

if FindColor(x, y, 394243, 672, 36, 672, 36) then
begin
Writeln('Walked the stairs successfully, I am on floor #2 now');
StairTries:= 10;
StairSuccess1:= True;
end else
begin
Writeln('Something went wrong, the stairs were not clicked correctly. Trying again...');
StairTries:= (StairTries + 1);
SPS_WalkPath(GirlToSummoningGuy);
StairSuccess1:= False;
end;

King

2013-02-18 12:14:20

Isnt the color for black 0?

Ian

2013-02-18 12:16:54

I don't think the black color on the minimap is 0

King

2013-02-18 12:25:31

Are you using ACA?

SomeGuyFromHere

2013-02-18 12:34:38

From: SRLKing
Are you using ACA?


Correct, that is how I got the color.

EDIT: Seems the color is changing massively all the time, from 394243 to 198407 to 1284, all on the "same" black area. Hell, I'm gonna need a massive tolance to account for that, and then the whole failsafe might get really unreliable…

King

2013-02-18 12:46:22

From: SomeGuyFromHere
Correct, that is how I got the color.

EDIT: Seems the color is changing massively all the time, from 394243 to 198407 to 1284, all on the "same" black area. Hell, I'm gonna need a massive tolance to account for that, and then the whole failsafe might get really unreliable…


Hmmm it shouldnt be changing that much, try looking for something else unique?

rj

2013-02-18 12:52:19

Try counting colors like:

function IsInSpot(): boolean;
Var
BlackCount,WhiteCount,RedCount:Integer;
begin
BlackCount := CountColorTolerance(196609, x1, y1, x2, y2, 3);
WhiteCount := CountColorTolerance(14472413, x1, y1, x2, y2, 5);
RedCount := CountColorTolerance(4215405, x1, y1, x2, y2, 8);
Result := false;
if (BlackCount >= 10) and (WhiteCount >= 5) and (RedCount >= 10)then
begin
Result := true;
end;
end;

Count the colors in the area, and if it's not in the spot then do something

SomeGuyFromHere

2013-02-18 13:27:11

From: rjj95
Count the colors in the area, and if it's not in the spot then do something


The problem I see with that is that the "black" color varies greatly each time I start the game. What would be interesting would be to pic the color from one spot and compare it to a few other spots; if the color is the same on all spots then it's the right place.
Hmmm it shouldnt be changing that much, try looking for something else unique?

Difficult, even the shapes of another unique object on the minimap differs depending on the angle because of pixelation. The most unique feature changing on the second floor is part of the minimap becoming black, period.

rj

2013-02-18 13:29:17

From: SomeGuyFromHere
The problem I see with that is that the "black" color varies greatly each time I start the game. What would be interesting would be to pic the color from one spot and compare it to a few other spots; if the color is the same on all spots then it's the right place.

Difficult, even the shapes of another unique object on the minimap differs depending on the angle because of pixelation. The most unique feature changing on the second floor is part of the minimap becoming black, period.


Is it waaaay different like 196609 sometimes and like 0 others?

SomeGuyFromHere

2013-02-18 13:36:34

As I wrote above, 3 tries resulted in the colors 394243, 198407 and 1284.

SomeGuyFromHere

2013-02-19 08:02:59

Found another object to use as DTM, the bridge connecting the two homes. The edges never change, not even when somebody walks the bridge. Still this black-is-not-black-thing annoys the hell out of me.

Runehack123

2013-02-19 09:32:42

There is a function in the SRL include that calculates the percentage of black colour on the minimap.
I use that in my script to check that I'm on the right floor:

Function PercentBlackMM: Integer;

It's very accurate. Use Writeln(IntToStr(PercentBlackMM… to debug the %Black on all the levels and then go from there. :)

SomeGuyFromHere

2013-02-19 10:49:12

It's on my list of things I'm going to try sometimes now. Thanks Runehack123 :)

SomeGuyFromHere

2013-02-19 17:28:38

THX again, this is most helpful when checking if the second stair walking procedure got me to the ground floor again.

Sjoe

2013-02-19 17:32:53

From: SomeGuyFromHere
THX again, this is most helpful when checking if the second stair walking procedure got me to the ground floor again.


DTM's aren't 100% accurate on MM
And better to use FindDTMRotated instead of FindDTM
If using DTM's on minimap, try making multiple dtm's as a failsafe.