;;Only execute on Server, requires gamelogic named server in mission
;;?!(local Server): exit
;;Variables
;;Name of Downed Pilot
_track = leader f_GrpBLU11A
;;Helicopter Name as read in from function param
_Chopper = _this select 0
;;Name of onboard squad
_Squad = _this select 1
;;Distance nearest East Infantry starts from Downed Pilot
_Distance = 3000
@time>1
~60
_Chopper setfuel 1
_Chopper doMove (getpos Wreck)
_Chopper flyinheight 50
@unitready _Chopper
#B1
;;Get Random Distances of Waypoint from Wreck Site
;;***************************************************************************************************
;;Get Random Distance Horizontal
_RandX = Random _Distance
;;Get Random Distance Vertical
_RandY = Random _Distance
;;Determine Random Bearing of waypoint from Wreckage (1 of 4 quadrants)
;;***************************************************************************************************
_Select = Random 4
? (_Select >= 0) AND (_Select < 1): goto "B1A"
? (_Select >= 1) AND (_Select < 2): goto "B1B"
? (_Select >= 2) AND (_Select < 3): goto "B1C"
? (_Select >= 3) AND (_Select < 4): goto "B1D"
;;***************************************************************************************************
;;North East Quadrant
#B1A
_Chopper doMove[(getpos Wreck select 0)+_RandX,(getpos Wreck select 1)+_RandY,getpos Wreck select 2]
goto "B2"
;;***************************************************************************************************
;;South East Quadrant
#B1B
_Chopper doMove[(getpos Wreck select 0)+_RandX,(getpos Wreck select 1)-_RandY,getpos Wreck select 2]
goto "B2"
;;***************************************************************************************************
;;North West Quadrant
#B1C
_Chopper doMove[(getpos Wreck select 0)-_RandX,(getpos Wreck select 1)+_RandY,getpos Wreck select 2]
goto "B2"
;;***************************************************************************************************
;;South West Quadrant
#B1D
_Chopper doMove[(getpos Wreck select 0)-_RandX,(getpos Wreck select 1)-_RandY,getpos Wreck select 2]
goto "B2"
#B2
;;Helicopter at waypoint?
?(unitready _Chopper): goto "B1"
;;Check if Heli saw RescueSquad/Pilot, if so skip to B3...if not get next waypoint
?(((_Chopper Knowsabout Pilot) > 0) AND (Alive Pilot)): _track = Pilot; goto "B3"
?(((_Chopper Knowsabout W1) > 0) AND (Alive W1)): _track = W1; goto "B3"
?(((_Chopper Knowsabout W2) > 0) AND (Alive W2)): _track = W2; goto "B3"
?(((_Chopper Knowsabout W3) > 0) AND (Alive W3)): _track = W3; goto "B3"
?(((_Chopper Knowsabout W4) > 0) AND (Alive W4)): _track = W4; goto "B3"
?(((_Chopper Knowsabout W5) > 0) AND (Alive W5)): _track = W5; goto "B3"
?(((_Chopper Knowsabout W6) > 0) AND (Alive W6)): _track = W6; goto "B3"
?(((_Chopper Knowsabout W7) > 0) AND (Alive W7)): _track = W7; goto "B3"
?(((_Chopper Knowsabout W8) > 0) AND (Alive W8)): _track = W8; goto "B3"
?(((_Chopper Knowsabout W9) > 0) AND (Alive W9)): _track = W9; goto "B3"
?(((_Chopper Knowsabout W10) > 0) AND (Alive W10)): _track = W10; goto "B3"
?(((_Chopper Knowsabout W11) > 0) AND (Alive W11)): _track = W11; goto "B3"
?(((_Chopper Knowsabout W12) > 0) AND (Alive W12)): _track = W12; goto "B3"
?(((_Chopper Knowsabout W13) > 0) AND (Alive W13)): _track = W13; goto "B3"
?(((_Chopper Knowsabout W14) > 0) AND (Alive W14)): _track = W14; goto "B3"
?(((_Chopper Knowsabout W15) > 0) AND (Alive W15)): _track = W15; goto "B3"
?(((_Chopper Knowsabout W16) > 0) AND (Alive W16)): _track = W16; goto "B3"
;;If Helicopter has been notified
?(CallHeli==1): _track=Pilot; goto "B3"
~10
goto "B1"
#B3
;;Call script to have squad start monitoring distance to track and get ready for jump
?(!Alive _track): _track = leader f_GrpBLU11A
_Chopper flyinheight 150
~5
[_Chopper,_Squad,_track] exec "MoveAirborne.sqs"
#B3a
?(!Alive _track): _track = leader f_GrpBLU11A
?(GameLoss==1): exit
;;Set Next Waypoint to Track
_Chopper doMove getpos _track
~10
?(Jumped==1): goto "B3b"
goto "B3a"
#B3b
;;Wait 15 seconds to give plenty of time for all troops to disembark
~15
#B4
;;Give the chopper a waypoint at the tracks location, after 10 seconds update waypoint
;;***************************************************************************************************
;;Check if current tracking unit is dead, if so select the present leader of RescueSquad
?(!Alive _track): _track = leader f_GrpBLU11A
?(GameLoss==1): exit
_Chopper doMove getpos _track
~10
?(!Alive driver _Chopper): exit
_Chopper flyinheight 80
goto "B4"
MoveAirborne.sqs
;;This script will eject the airborne screw from the heli and have them start tracking the enemy squad on the ground
;; It is called from Moveheli.sqs
;;Helicopter name
_Chopper = _this select 0
;;Name of onboard squad
_Squad = _this select 1
_track = _this select 2
;;When Chopper is close to tracking object
@((_Chopper distance _track)<400)
;;Eject squad from helicopter at 1 second intervals starting with the officer
E_Heli_1 action["eject", _Chopper]
unassignVehicle E_Heli_1
~1
E_Heli_2 action["eject", _Chopper]
unassignVehicle E_Heli_2
~1
E_Heli_3 action["eject", _Chopper]
unassignVehicle E_Heli_3
~1
E_Heli_4 action["eject", _Chopper]
unassignVehicle E_Heli_4
~1
E_Heli_5 action["eject", _Chopper]
unassignVehicle E_Heli_5
~1
E_Heli_6 action["eject", _Chopper]
unassignVehicle E_Heli_6
~1
E_Heli_7 action["eject", _Chopper]
unassignVehicle E_Heli_7
~1
E_Heli_8 action["eject", _Chopper]
unassignVehicle E_Heli_8
~1
E_Heli_9 action["eject", _Chopper]
unassignVehicle E_Heli_9
~2
;;Notify chopper that squad has jumped
Jumped=1
publicvariable "Jumped"
"[_x] Join GrpNull" forEach units _Squad
#B1
;;Check if current tracking unit is dead, if so select the present leader of RescueSquad
?(!Alive _track): _track = leader f_GrpBLU11A
?(GameLoss==1): exit
?(Alive E_Heli_1): E_Heli_1 domove getpos _track
?(Alive E_Heli_2): E_Heli_2 domove getpos _track
?(Alive E_Heli_3): E_Heli_3 domove getpos _track
?(Alive E_Heli_4): E_Heli_4 domove getpos _track
?(Alive E_Heli_5): E_Heli_5 domove getpos _track
?(Alive E_Heli_6): E_Heli_6 domove getpos _track
?(Alive E_Heli_7): E_Heli_7 domove getpos _track
?(Alive E_Heli_8): E_Heli_8 domove getpos _track
?(Alive E_Heli_9): E_Heli_9 domove getpos _track
~5
?(!Alive _Chopper): goto "B2"
goto "B1"
#B2
?(!Alive _track): _track = leader f_GrpBLU11A
?(GameLoss==1): exit
?(Alive E_Heli_1): E_Heli_1 domove getpos _track
?(Alive E_Heli_2): E_Heli_2 domove getpos _track
?(Alive E_Heli_3): E_Heli_3 domove getpos _track
?(Alive E_Heli_4): E_Heli_4 domove getpos _track
?(Alive E_Heli_5): E_Heli_5 domove getpos _track
?(Alive E_Heli_6): E_Heli_6 domove getpos _track
?(Alive E_Heli_7): E_Heli_7 domove getpos _track
?(Alive E_Heli_8): E_Heli_8 domove getpos _track
?(Alive E_Heli_9): E_Heli_9 domove getpos _track
~20
goto "B2"