nearestobject command needs a classname to go to
Code (at simplest) would be something like :
this move getpos (nearestobject "bush1")
But that's limited to one type of bush/tree etc, so it'd be something like this..
; [this
_unit=_this select 0
;arrayOfClassNames]
_type=_this select 1
;Counter
_i=0
;Ammount of class names suplied
_e=count _type
#loop
;Get nearest object of the current classname in array
_current = nearestobject (_type select _i)
;Find distance to nearest object
_dis = _unit distance _current
;If the unit is under 20m, go there, and quit script
?(_dis < 20):_unit move getpos _current;exit
;Prod counter up
_i=_i+1
;If done for each classname, exit
?(_i > _e):exit
; Still not done all array things, do next
goto "loop"
;if no cover found, unit does the following
; unit goes prone
_unit setUnitPos "DOWN"
exit
Run like : [this,[bush1,bush2,bush3,tree1,tree2]] exec "script.sqs"
I've not used nearestobject command much, but I think that should work..
Nearestobject is limited to 50m remeber. If the unit is over 20m away, he wont go to it.
I've commented the code, hopefully you can follow it
- Ben