SRL Archive - OSR Help

DDTM walking help


westkevin12

2013-05-03 04:00:20

I'm trying to add DDTM walking to my iron mining script and i'm stuck not sure what is wrong, it compiles and runs but doesn't move the mouse or click. mouse stays in top left of the screen. and honestly i don't see how the mouse would know were to move anyways. idk i've never done anything with DDTMs before was following a guide to get the functions made.


program ddtmwalking;
{$DEFINE SMART8}
{$i srl-osr/srl.simba}
{$i sps/sps-osr.simba}
{$I SRL-OSR/SRL/misc/SmartGraphics.Simba}


var
x,y : integer;


function bankMP: Integer;
var
TPA : TPointArray;
begin
SMART_DrawDots(TPA);
if FindColorsTolerance(TPA, 7369340, MMX1, MMY1, MMX2, MMY2, 10) then
Result:= GetColor(TPA[0].X, TPA[0].Y);
end;

function bankSP1: Integer;
var
TPA : TPointArray;
begin
SMART_DrawDots(TPA);
if FindColorsTolerance(TPA, 195836, MMX1, MMY1, MMX2, MMY2, 10) then
Result:= GetColor(TPA[0].X, TPA[0].Y);
end;

function bankSP2: Integer;
var
TPA : TPointArray;
begin
SMART_DrawDots(TPA);
if FindColorsTolerance(TPA, 195836, MMX1, MMY1, MMX2, MMY2, 10) then
Result:= GetColor(TPA[0].X, TPA[0].Y);
end;
function bankSP3: Integer;
var
TPA : TPointArray;
begin
SMART_DrawDots(TPA);
if FindColorsTolerance(TPA, 62965, MMX1, MMY1, MMX2, MMY2, 10) then
Result:= GetColor(TPA[0].X, TPA[0].Y);
end;
function bankSP4: Integer;
var
TPA : TPointArray;
begin
SMART_DrawDots(TPA);
if FindColorsTolerance(TPA, 15003621, MMX1, MMY1, MMX2, MMY2, 10) then
Result:= GetColor(TPA[0].X, TPA[0].Y);
end;

function DDTMWalk(WalkNumber: Integer): Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: array[0..4] of TDTMPointDef;
TempTDTM: TDTM;
begin

case WalkNumber of
1: begin
dtmMainPoint.x := 919;
dtmMainPoint.y := 183;
dtmMainPoint.AreaSize := 4;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := bankMP;
dtmMainPoint.Tolerance := 10;

dtmSubPoints[0].x := 919;
dtmSubPoints[0].y := 183;
dtmSubPoints[0].AreaSize := 4;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := bankMP;
dtmSubPoints[0].Tolerance := 10;

dtmSubPoints[1].x := 918;
dtmSubPoints[1].y := 177;
dtmSubPoints[1].AreaSize := 4;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := bankSP1;
dtmSubPoints[1].Tolerance := 10;

dtmSubPoints[2].x := 926;
dtmSubPoints[2].y := 177;
dtmSubPoints[2].AreaSize := 4;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := bankSP2;
dtmSubPoints[2].Tolerance := 10;

dtmSubPoints[3].x := 931;
dtmSubPoints[3].y := 178;
dtmSubPoints[3].AreaSize := 4;
dtmSubPoints[3].AreaShape := 0;
dtmSubPoints[3].Color := bankSP3;
dtmSubPoints[3].Tolerance := 10;

dtmSubPoints[4].x := 906;
dtmSubPoints[4].y := 185;
dtmSubPoints[4].AreaSize := 4;
dtmSubPoints[4].AreaShape := 0;
dtmSubPoints[4].Color := bankSP4;
dtmSubPoints[4].Tolerance := 0;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

end;
end;
function walktopit: boolean;
var
WalkDTM: integer;
aFound: Extended;
begin
WalkDTM := DDTMWalk(1);
if FindDTMRotatedAlternating(WalkDTM, X, Y, MMx1,MMy1,MMx2,MMy2, - 35, 35, 1, aFound) then
begin
MMouse(x,y,5,5);
ClickMouse2(MOUSE_LEFT);
FFlag(0);
Result := True;
end;
end;




begin
setupSRL;
makecompass('E');
walktopit;

end.

King

2013-05-03 08:09:05

Well if it doesn't move, it didn't find them(: Add a if then statement to your walking, if findDTMRotatedalternating then blah blah blah else can't find DTM.

I would write it in, but I'm on my ipad :p

DDTM's are very accurate when made right, also you can just use FindDTMRotated, look on Demise sythe's tutorial on DTMs, it gives a very good setup for the DTM finding that works well for my DDTM walking. It finds it by creati it every time it is run off the MM using your auto color. Hence the Dynamic part. What tutorial did you follow? Everything looks fine to me, however if it is not moving, it can't find them. Make your area to 5 and try adding a slightly higher tolerance, make sure the colors are relatively unique/ a good combination. I also find that 3 sub points work better than 4 for me.

You can also use a better coloring function, such as a TPA splitting into multiple parts from the MM center, or wherever your color is located. It may be finding colors that are far apart, making the DDTM to inaccurate to walk with? I'll look into this more when I get home if you like.

litoris

2013-05-03 10:27:09

The syntax is correct, it might be a problem with your colors/points. Try searching for it rotated, or picking your colors better.
PS: Is there a reason why your first sub point and main point are the same? Or is that actually required? (haven't used DDTM's in a while, kind rusty)

King

2013-05-03 10:31:22

From: litoris
The syntax is correct, it might be a problem with your colors/points. Try searching for it rotated, or picking your colors better.
PS: Is there a reason why your first sub point and main point are the same? Or is that actually required? (haven't used DDTM's in a while, kind rusty)


Shouldn't be required. It might just be he copy and pasted? I don't have mine the same and they work fine.

I'll post my function when I get on the computer if you like OP

Mind posting where you are trying to walk? Like Luis the MM of e area and we can help you make one

Sjoe

2013-05-03 10:33:40

From: King
Shouldn't be required. It might just be he copy and pasted? I don't have mine the same and they work fine.

I'll post my function when I get on the computer if you like OP

Mind posting where you are trying to walk? Like Luis the MM of e area and we can help you make one


Make a DDTM Mapwalking tutorial King, ty

King

2013-05-03 10:35:59

From: Sjoe
Make a DDTM Mapwalking tutorial King, ty



There are a few already, but I didn't understand them very well, took a lot of tinkering to get good ones, so I'll make a video of them possibly of me actually making a walking path to show how to choose the right points ect.

Haxz

2013-05-03 10:37:16

From: King
There are a few already, but I didn't understand them very well, took a lot of tinkering to get good ones, so I'll make a video of them possibly of me actually making a walking pan to show how to choose the ect.


Same to me, I couldn't understand the tutorials very well. Would appreciate a video tutorial from you! :D

King

2013-05-03 10:38:39

From: Haxz
Same to me, I couldn't understand the tutorials very well. Would appreciate a video tutorial from you! :D


Seems there is a lot of interest in them, I'll make one tonight of me actually making a path. I have to make one anyway and is will show how as well, two birds with one stone!

Sjoe

2013-05-03 10:38:44

From: King
There are a few already, but I didn't understand them very well, took a lot of tinkering to get good ones, so I'll make a video of them possibly of me actually making a walking path to show how to choose the right points ect.


Yessss, do it :)

Haxz

2013-05-03 10:44:25

From: King
Seems there is a lot of interest in them, I'll make one tonight of me actually making a path. I have to make one anyway and is will show how as well, two birds with one stone!


Great! I'll give you a cookie rep! :D

King

2013-05-03 10:48:45

Will post it tonight :D

Sk1nyNerd

2013-05-03 14:11:40

I second the tut :)

westkevin12

2013-05-03 17:28:10

From: litoris
The syntax is correct, it might be a problem with your colors/points. Try searching for it rotated, or picking your colors better.
PS: Is there a reason why your first sub point and main point are the same? Or is that actually required? (haven't used DDTM's in a while, kind rusty)


i used the ddtm editor to pick my points and clicked file ddtm to text and it gave me that part of the function with the first subpoint beeing the same as the mainpoint.

westkevin12

2013-05-03 17:31:17

From: King
Well if it doesn't move, it didn't find them(: Add a if then statement to your walking, if findDTMRotatedalternating then blah blah blah else can't find DTM.

I would write it in, but I'm on my ipad :p

DDTM's are very accurate when made right, also you can just use FindDTMRotated, look on Demise sythe's tutorial on DTMs, it gives a very good setup for the DTM finding that works well for my DDTM walking. It finds it by creati it every time it is run off the MM using your auto color. Hence the Dynamic part. What tutorial did you follow? Everything looks fine to me, however if it is not moving, it can't find them. Make your area to 5 and try adding a slightly higher tolerance, make sure the colors are relatively unique/ a good combination. I also find that 3 sub points work better than 4 for me.

You can also use a better coloring function, such as a TPA splitting into multiple parts from the MM center, or wherever your color is located. It may be finding colors that are far apart, making the DDTM to inaccurate to walk with? I'll look into this more when I get home if you like.

kk i'll try adding if then writeln to see if it found the colours lol *facepalms for not thinking of that*

King

2013-05-03 17:43:12

From: westkevin12
kk i'll try adding if then writeln to see if it found the colours lol *facepalms for not thinking of that*


Im having issues with auto color atm, dont worry bout iut :D