; Get the original plane
_array = _this select 0 
_plane = _array select 0
_pilot = _array select 2

; Check if the eject routine is needed
?(speed _plane < 1) : exit

; Move the pilot out of the parachute that the engine puts him/her in
_oldpara = vehicle _pilot
_pilot action ["GETOUT", _oldpara]

; We can kill the old parachute now
deletevehicle _oldpara

; Create the seat
_seat = "BWC_ejectseat" createvehicle [0,0,0]
_seat setobjecttexture [0,"\BWC_MIII\T\mistrail.paa"]
_seat setpos [(getpos _pilot) select 0,(getpos _pilot) select 1, ((getpos _pilot) select 2)+5]

; Direct the seat
_seat setdir direction _plane
_seat engineon true

; And move the pilot into the seat
_pilot moveindriver _seat

_seat say "EJECT"
_plane SideChat "I´m hit, Mayday!!!..Mayday!!! ...Ejecting"

; Set the vel of the seat to that of the plane with a z boost
_vel = velocity _plane
_vx = 0.7*(_vel select 0)
_vy = 0.7*(_vel select 1)
_vz = 40 +(_vel select 2)
_seat setVelocity [_vx, _vy, _vz]

_starttime = time

#SeatFly
; Decrease the velocity
_vx = _vx * .98
_vy = _vy * .98
_vz = _vz - .1

_seat setvelocity [_vx, _vy, _vz]

; If the pilot's dead, get out now
?(!alive _pilot):goto "Exit"

~.01

drop["cl_basic","","Billboard",1,3,[0,0,0],[2-random 4,2-random 4,-2-random 4],0,10,1,1,[1,3,4],[[.9,.9,.9,.3],[.9,.9,.9,.6],[.9,.9,.9,.1]],[0,.02,1],5,5,"","",_seat] 

?((time - _starttime) <=4):goto "SeatFly"

; Create the parachute
_para = "ParachuteWest" createvehicle getpos _pilot
_para setdir getdir _seat
_para setpos getpos _pilot

; Move the pilot into the parachute
_pilot action ["GETOUT", _seat]
_pilot moveindriver _para 

; Speed the seat away
_seat setvelocity [_vx, _vy, -5]
_seat engineon false
_seat setobjecttexture [0,""]

~5

deletevehicle _seat

#Exit
exit