This script is for guiding a helicopter from one point to another using the setpos command... effectively bypassing the AI's control. It has room for improvement... I plan on adding in somewhat dynamic directional movement and pitch... among other things.
';Call Using [unitname,startobject,endobject,duration,groupincargo,landtrue]
;For landtrue, 1 is considered true (not the word true!)
;For landings, I recommend an invisible H being the end object
;The objects (I recommend game logics for objects) must have their height set by setpos or other.
;Duration is in seconds (Duh! :-p)
;Amos Scott(Homefry)
;Retrieve starting values
_unit = _this select 0
_startObj = _this select 1
_endObj = _this select 2
_duration = _this select 3
_cargogrp = _this select 4
_landtrue = _this select 5
_i = 0
;Set Correct Helo Direction
_unit setdir getdir _endObj
;Calculate movement/decent rates
_ratex = ((getpos _startObj select 0)-(getpos _endObj select 0))/(_duration / .01)
_ratey = ((getpos _startObj select 1)-(getpos _endObj select 1))/(_duration / .01)
_ratez = ((getpos _startObj select 2)-(getpos _endObj select 2))/(_duration / .01)
;Set Starting Coords
_currx = getpos _startObj select 0
hint format ["%1",_currx]
_curry = getpos _startObj select 1
_currz = getpos _startObj select 2
;Start Movement Loop
#move
_currx = _currx - _ratex
_curry = _curry - _ratey
_currz = _currz - _ratez
;_newpos = [_currx, _curry, _currz]
_unit setpos [_currx, _curry, _currz]
_unit setdir getdir _endObj
_i = _i + 1
?(_i >= (_duration / .01)):goto "landers"
~.01
goto "move"
;Begins the disembarking of troops
#landers
?(_landtrue == 0):exit
_aunits = units _cargogrp
_i = 0
_j = count _aunits
goto "lander"
;Disembarks units
#lander
?(count crew _unit == 2):exit
_unit setpos [_currx, _curry, _currz]
~.01
(_aunits select _i) action ["EJECT",_vehicle]
unassignvehicle (_aunits select _i)
_i=_i+1
?_j>_i:goto "lander"
exit
DO NOTE:
This script relies on the first object to be placed in the air... I recommend a game logic. I am planning on making this easier... for example allowing the player to just place a marker... then having the starting height of the chopper settable when calling the script.
Also... I would try to estimate the distance of the objects when considering a duration. Just take the estimated distance... then divide by a duration. I recommend you aim for around 30-45 to be your result (speed in meters/second).
Any and all feedback would be great.