I don't have access to an editor atm, but can answer the method how to do it.
Do you know about memory leaks from thing such as points?
The
Kill Nearest Unit link shows you how to find the closest unit from another unit.
You can check distance (real-typed-variable) between 2 points with:
Set distance = (Distance between temp_position and temp_position_2)
But you want to fins the closest terrain-type.
I believe that you will have to search points until you find the correct terrain-type, then order unit to move to that point.
It is easier to search in a grid from top-left to bottom-right and take note of the closest than to do a more effective search (Breadth-first search).
Something along the line of this should work:
Code:
set unit_pos = position of unit( the unit )
set closest_found_point_distance = 99999
for x_integer from -20 to 20
for y_integer from -20 to 20
set temp_x_offset_real = (integer to real (x_integer) * 75)
set temp_y_offset_real = (integer to real (y_integer) * 75)
set temp_pos = Position with offset (unit_pos) offset by x (temp_x_offset_real), y (temp_y_offset_real )
if (<I need to have access to an editor to know what to do here, but temp_pos is the "correct terrain type"
AND distance between unit_pos and temp_pos is less than closest_found_point_distance )
destroy closest_found_point //This is the "old closest point".
closest_found_point_distance = distance between unit_pos and temp_pos is less than closest_found_point_distance
closest_found_point = temp_pos
else
destroy temp_point
if(closest_found_point_distance is less than 99999)
order <unit> to move to closest_found_point
destroy unit_pos
destroy closest_found_point
This searches every 75 range-units (a fairly short distance) for <the correct terrain type>. It only searches 1000 range-units (About the range of a ballista), but can be increased by changing the "20" in the for-loops.
The "75" might be possible to increase, but I don't know how big the smallest texture-patch is in 100 or 200.