SRL Archive - OSR Help

Confusion over function results


GREEN GIANT

2013-07-26 06:35:12

Hi Guys,

I'm a little stuck on a path walk that i'm actually quite proud of :D (as a novice)

Basically, I use a DTM to find a point on the MM that is on the path and store this color using a function DTMRColor.
I also run a function that finds the percentage of that color at radians between 270-360 (the direction im heading)Function RoadPCent.
I run that through a loop until RoadPCent falls below 5% (path ends) and continue from there.

My problem is that it works fine when i manually input the color of the path into RoadPCent function, but if i declare the color as DTMRCOLOR, it gets confused, as if the DTMRColor is only working once then trying to locate the DTM again or something.

Code is below, is it because everytime i call DTMRColor, it attempts to find the DTM? If so how do i get around it?

At present it finds the color, walks twice then ends. Whereas if i input the color into RoadPCent manually it walks fine.


Function DTMRColor: integer;
var
rDTM, x, y: integer;
begin
rDTM := DTMFromString('mQwAAAHicY2ZgYKhkYmAoBeJGIHYC8o2BOBiIS3NiGEDgzx8mhv8MCMCIhIEAAAHTBno=');
FindDTM(rDTM, x, y, mmx1, mmy1, mmx2, mmy2);
Result := Getcolor(x, y);
freedtm(rDTM);
end;

function RoadPcent: integer;
begin
Result :=PercentColorMMEx(DTMRColor, 0, 270, 360, 5, 60);

end;

begin

repeat;
writeln(roadpcent);
radialwalk(DTMRColor, 280, 340, 60, x, y)
until (RoadPCent < 5)
end;

Kevin

2013-07-26 11:34:04

I do believe it is exactly as you said:

is it because everytime i call DTMRColor, it attempts to find the DTM? If so how do i get around it?
In order to get around that, you will need to store the result from DTMRColor into a variable that is only changed once per login (so once you implement something for the six hour fix, you will need to reset the color there as well).

GREEN GIANT

2013-07-26 12:39:10

From: Kevin
I do believe it is exactly as you said:
In order to get around that, you will need to store the result from DTMRColor into a variable that is only changed once per login (so once you implement something for the six hour fix, you will need to reset the color there as well).


Ahh, yes. I fixed it so it changes only once per trip (using some writeln to debug) but now i have another problem :(

On the path i cross a loading screen and every so often the color changes during the path walk. I'm terrible with loops (can't find any comprehensive guides)So if i wanted to walk as follows how would it go?;

radialwalk…until RoadPCent < 5 then
begin radialwalk(2) if requirements (A) is met or
begin radialwalk(3) if requirements (B) is met then
end;

Sorry its very crude but i am really that bad with looping.

so i basically want it to walk until RoadPcent is less than 5%, if this is because its at the end of the road then……(1)
or if its because the color has changed then start …..(2)

Kevin

2013-07-26 12:54:19

Is this for an 07 script or EOC?

GREEN GIANT

2013-07-26 13:45:52

From: Kevin
Is this for an 07 script or EOC?


Its for an 07 OSR Script.

Kevin

2013-07-26 13:47:59

From: GREEN GIANT
Its for an 07 OSR Script.


Ugh… 07… You could just try using a tolerance on the color you initially grab? Or you could try to walk via dtms entirely.

GREEN GIANT

2013-07-26 13:51:56

Haha, whats with the 07 hate? :P
I've tried radial walking with tolerance but the whole area is a very grey color so it goes AWOL very easily, this applies for the DTM walking as well, due to everything being very similar colors and no features along the path it makes it very difficult.

I'm going to try running until (<5) again, then grabbing the color of the road under my feet and continuing, ill post how it gets on.

GREEN GIANT

2013-07-26 14:24:03

Success :D

Managed a full path walk (multiple times without fail), even after colors changed.

Just did another DTM check and grabbed the color of the path. If the path color changes whilst walking, then RoadPCent will be (< 5) so it grabs the road color using a DTM check (as the load line is always in a similar area). It will then proceed until RoadPCent(< 5). If however the RoadPCent is (<5) because its reached the end of the road then it just ends and continues as always :)

Very happy with that result.