SRL Archive - OSR Help

FindDTMRotated


Yanhua

2011-12-16 22:05:29

What is wrong with my line? It gives me the error "[Error] (28:76): Type mismatch at line 27
Compiling failed."

I'm using a DTM on the MiniMap for walking


FindDTMRotated(Path1, X, Y, MMX1, MMY1, MMX2, MMY2, -180, 360, 50, C);

Thanks in advance.

Wizzup?

2011-12-17 09:27:50

What is Path1? Can you post more code?

DemiseScythe

2011-12-17 19:56:30

I know exactly what your problem is, the start and end angles must be in radians. Besides that, path 1 must be declared as an integer at the beginning of your script and C has to be declared like this:

var
C: Extended;

in your var section because C is an extended integer, use one of my DTMs as an example:

if FindDTMRotated(P1, x, y, MMX1, MMY1, MMX2, MMY2, -Pi/2, Pi/2, Pi/30, aFound) then  

I use my DTMs in if..then statements. It is like asking the client: "Do you see this DTM" if it sees, then you can proceed to do what you want and the coordinates of this DTM are stored in (x, y). P1 is just the name of your DTM, I used aFound instead of C but either works as long as you define either of them with the correct type, x and y also must be definted as integers so that they can be used throughout your script. This is how they are defined:

var
P1, x, y: Integer;
aFound: Extended;

Good luck pal, I am going to script solely on DTMs and already know plenty about them, so if you need extra help with them, send me private message with the link to the post with the question and I'll be more than happy to go on it and post an answer as soon as possible. =)

P.S. Use 15 Tolerance for all your points in your DTM to adjust with the color changes. 15 works just perfect in my opinion: both flexible and accurate!

Yanhua

2011-12-17 20:05:52

From: DemiseScythe
I know exactly what your problem is, the start and end angles must be in radians. Besides that, path 1 must be declared as an integer at the beginning of your script and C has to be declared like this:

var
C: Extended;

in your var section because C is an extended integer, use one of my DTMs as an example:

if FindDTMRotated(P1, x, y, MMX1, MMY1, MMX2, MMY2, -Pi/2, Pi/2, Pi/30, aFound) then  

I use my DTMs in if..then statements. It is like asking the client: "Do you see this DTM" if it sees, then you can proceed to do what you want and the coordinates of this DTM are stored in (x, y). P1 is just the name of your DTM, I used aFound instead of C but either works as long as you define either of them with the correct type, x and y also must be definted as integers so that they can be used throughout your script. This is how they are defined:

var
P1, x, y: Integer;
aFound: Extended;

Good luck pal, I am going to script solely on DTMs and already know plenty about them, so if you need extra help with them, send me private message with the link to the post with the question and I'll be more than happy to go on it and post an answer as soon as possible. =)

P.S. Use 15 Tolerance for all your points in your DTM to adjust with the color changes. 15 works just perfect in my opinion: both flexible and accurate!


Thanks for that!

Didn't really understand what radians were, I just used numbers.

Now I know Radians must be Pi/x.

Cheers! :D :D :)

DemiseScythe

2011-12-17 20:33:18

Glad it was of help and I agree, it took me a while to figure out what the client was asking for with regards to RotatedDTM, mainly the radians part.

If you have time, check my script:

http://villavu.com/forum/showthread.php?t=69351

It walks solely on DTMs, no color or anything else. It is fast, accurate and human-like except for like the gate part, it pauses for a few seconds. I am still working on it but it has progress a lot and might help you understand walking with DTMs. =)

WT-Fakawi

2011-12-18 07:39:34

This is how I track a red-line door dtm on the minimap.
 
WhichAngle: Extended;

if FindDtmRotated(DoorDTM, x, y, MMx1, MMy1, MMx2, MMy2, rs_GetCompassAngleRadians-pi/2, rs_GetCompassAngleRadians+pi/2, 0.05,
WhichAngle) then
begin
Mouse(x + Ox, y + Oy, 0, 0, True);
FFlag(0);
FTWait(1);
Result := True;
If FawkiDebug then writeln('Callibrate succesful');
Exit;
end
else
begin
Result := False;
writeln('Door DTMnot found');
end;


I usually use:

between rs_GetCompassAngleRadians-pi/2 and rs_GetCompassAngleRadians+pi/2. Pi = 180, so it scans for the dtm -90 to +90 degrees,

but also

between rs_GetCompassAngleRadians-pi/4 and rs_GetCompassAngleRadians+pi/4, which scans it -45 til +45 degrees.

WhichAngle returns the angle in radians iirc, I hardly ever use that. X and Y obviously contain the coordinates of the Hotspot of the DDTM, the DTMMainPoint.

The function itself return either true or false.

Finddtmrotated is a pretty neat tool to track small objects regardless of a compass angle.

DemiseScythe

2011-12-18 10:19:49

When I tried using DTM to find the door, it would sometimes click the fence next to it instead, I will try this code when I release a new version of my script. Thank you.

infamousnightmar

2012-04-06 14:16:21

I'm having a similar issue if someone could help
http://villavu.com/forum/showthread.php?p=981761