This is a script
and not a function
......
I wrote it yesterday as i got the idea just yesterday......i found it quite useful with my mission
Not sure it will serve you good or bad.......
As this is OFP,,i think you don't have much to worry about lag....no lag occured for me.........
Just beta testing...................
?(_follower==player) or not (alive follower) : exit
_follower=_this select 0;
_target=_this select 1;
_meters=_this select 2;
_behaviour=_this select 3;
_mode=_this select 4;
_duration=_this select 5;
_unlimited=_this select 6;
;_follower follows _target
;_meters determine the distance at which _follower will stop from _target
;if _meters is +5 ("+" not needed),_follower will stop at 5 meters ;behind _target when _target is ;stopped,and _follower should follow ;_targetfrom 5 meters behind it.....
;when _unlimited is set to 1,_duration is NOT considered
;_unlimited must not exceed 1 or the script will exit and any number lower than 1 is considered 0
;the script exits if _unlimited is set to -1/-2 or so...
;if _duration is 60,the car will follow _target for 60 seconds
;behaviour is either "safe","aware","combat",or "stealth"
;mode is either "limited","normal",or "full" (don't forget to put quotes!)
_follower setbehaviour _behaviour
_follower setspeedmode _mode
_seconds=0
#checker
;----------------------
?_duration < 0 : exit
? _unlimited < 0 : exit
? _unlimited > 1 : exit
? _unlimited == 1 : goto "startfollowing"
? ! (alive _follower) : exit
? (_follower==player) : exit
?(_seconds > _duration) : goto "stopfollowing"
_seconds=_seconds + 1
;-------------------------------------------------------------------------------------
#startfollowing
;---------------------------
_follower domove [(getpos _target select 0)+(_meters),(getpos _target select 1),0]
~1
goto "checker"
;checker checks all the conditions to make follower follow,if one of them gone wrong,the follower no ;longer follows the target
;------------------------------------------------------------------------------
#stopfollowing
;--------------
_follower domove getpos _follower
exit
This script works perfect for me,especially when making a chopper follow another chopper.....
Syntax = [name of follower, name of to be followed, meters to follow behind or infront of target, behaviour of follower, speedmode of follower, seconds to follow, permenantly follow ]
NOTE : The script will exit immediately if the follower is PLAYER or the follower is not alive.....
The script don't count on _duration if _unlimited is set to 1,but you still need to type a number to _duration (like 0 or something).........NOT < 0