To check how flat is a terrain you may use the following concept:
a grid of moving particles is created, a group moving W->E and a second group moving N->S, covering the selected area.
At fixed intervals, the particles triggers a script with their positions, so it is quite easy to calculate maximum and minimum height over terrain for horizontally moving and vertically moving particles. Note that particles, once moving, will not change their altitude over sea level.
The good point is that particles may be transparent, so you check flatness of terrain without any visible object/effect.
;checkflat by Mandoble
;Arguments:
; Center of the landing area
; Lengh to the square to check
; How may checks per square side
; Marks transparent true/false
;
;Example:
; 100m^2 area-check in squares of 10 by 10
; [getPos logic1, 100, 10, false]exec"checkflat.sqs"
;
_center = _this select 0
_lengh = _this select 1
_cells = _this select 2
_transp = _this select 3
_tr = 1
?_transp:_tr = 0
;Adjust max time to increase accuracy
_maxtime = 5.0
_d = _lengh / (_cells - 1)
_delay = 1.0 / (_cells * 2)
_time = _maxtime / _cells
zinith = true
zinitv = true
maxzhelilandh = 0.0
minzhelilandh = 0.0
maxzhelilandv = 0.0
minzhelilandv = 0.0
_i = 0
_xh = (_center select 0) - _lengh / 2.0
_yh = (_center select 1) + _lengh / 2.0
_xv = (_center select 0) - _lengh / 2.0
_yv = (_center select 1) + _lengh / 2.0
_velh = [_lengh /_maxtime, 0, 0]
_velv = [0, -_lengh /_maxtime,0]
#detectors
_pos = [_xh,_yh,0]
drop["cl_basic","","Billboard",_time,_maxtime,_pos,_velh,0,25.50,20,0,[1],[[1,1,1,_tr]],[1],0,0,"dropposh.sqs","dropposh.sqs",""]
_pos = [_xv,_yv,0]
drop["cl_basic","","Billboard",_time,_maxtime,_pos,_velv,0,25.50,20,0,[1],[[1,1,1,_tr]],[1],0,0,"dropposv.sqs","dropposv.sqs",""]
~_delay
_yh = _yh - _d
_xv = _xv + _d
_i = _i + 1
?_i < _cells:goto "detectors"
~_maxtime
~1
hint format["Max vertical dev W/E:%1, Max vertical dev N/S:%2", abs(maxzhelilandh - minzhelilandh), abs(maxzhelilandv - minzhelilandv)]
exit
;dropposv.sqs
_z = _this select 2
?zinitv:maxzhelilandv=_z;minzhelilandv=_z;zinitv=false;exit
?maxzhelilandv < _z:maxzhelilandv=_z
?minzhelilandv > _z:minzhelilandv=_z
exit
;dropposh.sqs
_z = _this select 2
?zinith:maxzhelilandh=_z;minzhelilandh=_z;zinith=false;exit
?maxzhelilandh < _z:maxzhelilandh=_z
?minzhelilandh > _z:minzhelilandh=_z
exit
EDIT:
added position check script also at end of life of particles.