SRL Archive - Test corner

Minimap finding using Dynamic Rotated DTM


Markus

2007-04-24 11:09:48

Hello
I've got a testscript to find the position of the Mindaltar on the MM. Please use them right of the mind altar. It uses HSL autocoloring and dynamic DTMs (am I the first one using them :rolleyes: )
If it works it should move the mouse near the Altar on the mm.
If this works, expect a mindcrafter soon….

program New; //Yeah,
{.include srl/srl.scar}
var lol : TDTM;
dtm : integer;
angle : extended; //Am I the first one using dynamic DTMs?

function AutoDarkTreeColor : integer; //Based on my AutoDirtColor
var DaColors : TPointArray;
h, s, l : extended;
i, clr, time : integer;
begin
marktime(time);
FindColorsSpiralTolerance(mmcx, mmcy, DaColors, 11569, mmx1, mmy1, mmx2, mmy2, 50); //Spiral heavily increases peformance.
for i := 0 to GetArrayLength(DaColors) - 1 do //Normal: 400ms Spiral: 15ms!
begin
clr := GetColor(DaColors[i].x, DaColors[i].y); //I know it's slow, but if anyone knows a faster way...
ColortoHSL(clr, h, s, l);
if (round(h) >= 7) then
if (round(h) <= 15) then
if (round(s) >= 40) then
if (round(s) <= 100) then
if (round(l) >= 9) then
if (round(l) <= 19) then
begin
result := clr;
writeln('AutoDarkTreeColor = ' + inttostr(result) + ' found in ' + inttostr(TimeFromMark(time)) + ' ms');
exit;
end;
end;
writeln('Treecolor NOT found! Not finding took ' + inttostr(timefrommark(time)) + ' ms');
end;

begin
setupsrl;
lol.MainPoint.x := 651;
lol.MainPoint.y := 77;
lol.MainPoint.color := 1794923;
lol.MainPoint.tolerance := 50; //The mainpoint doesn't use autocoloring, maybe in another version
lol.MainPoint.areashape := 0;
lol.MainPoint.areasize := 5; //as the MM moves
SetArrayLength(lol.subpoints, 4); //4 subpoints
lol.SubPoints[0].x := 647;
lol.SubPoints[0].y := 58;
lol.SubPoints[0].color := AutoDarkTreeColor; //I wanted to practice my autocolor skills :P
lol.SubPoints[0].tolerance := 0;
lol.SubPoints[0].areashape := 0;
lol.SubPoints[0].areasize := 3;
lol.SubPoints[1].x := 659;
lol.SubPoints[1].y := 45;
lol.SubPoints[1].color := 0; //Black wildy ditch
lol.SubPoints[1].tolerance := 0; //it's a static color
lol.SubPoints[1].areashape := 0;
lol.SubPoints[1].areasize := 0;
lol.SubPoints[2].x := 647;
lol.SubPoints[2].y := 44;
lol.SubPoints[2].color := 0; //Black wildy ditch
lol.SubPoints[2].tolerance := 0; //it's a static color
lol.SubPoints[2].areashape := 0;
lol.SubPoints[2].areasize := 0;
lol.SubPoints[3].x := 664;
lol.SubPoints[3].y := 99;
lol.SubPoints[3].color := AutoDarkTreeColor;
lol.SubPoints[3].tolerance := 0;
lol.SubPoints[3].areashape := 0;
lol.SubPoints[3].areasize := 3;
dtm := AddDTM(lol);
if FindDTMRotated(dtm, x, y, mmx1+40, mmy1, mmx2, mmy2, -1.0, 2.0, 0.1, angle) then
MMouse(x, y, 0, 0) else
begin
MMouse(mscx, mscy, 50, 50);
writeln('noooo! Markus, all your work is for nothing. Screw Divi!!!');
end;
end.
It should work fine if it finds the tree color, but it's a little bit slow. But accuracy is more important then speed, right?

Rune Hacker

2007-04-24 21:57:49

When i look at this, i juts see a bunch of wierd words and numbers lol. Is there a different coding language you know that helped you make this or am I just horrible at thsi stuff lol.

Markus

2007-04-25 01:44:59

From: Rune Hacker
When i look at this, i juts see a bunch of wierd words and numbers lol. Is there a different coding language you know that helped you make this or am I just horrible at thsi stuff lol.


It's created in SCAR Divi and it compiles and runs for me. It's HSL autocoloring combined with dynamic DTM's.
Maybe you're just horible at this stuff :)
It seems to be working good, I only have some small problems with the Autocolor finding the wrong color…
edit: I've updated the first post with a newer (more accurate) version. Please post your results.

Smartzkid

2007-04-25 13:01:55

Ahhh Now I see how dynamic dtm's work.

:) Thanks, I'll try to test soon

Markus

2007-04-25 13:04:41

Thank you.
It took me some time to figure it out, as I couldn't find an example script or something, only they type TDTM and the function AddDTM(dtm : TDTM) : integer;
I've used the crtl-space list and guessed some things, and it seems I guessed them right :)
Maybe Freddy should put some kind of tutorial/howto in the manual?