


;this addeventhandler ["AnimChanged", {if (not alive (_this select 0)) then {[_this select 0,_this select1] exec {init_deletebodies1.sqs}}}]  

_Unit = _this select 0
_animplayed = _this select 1
_maxbodies = 0
_noflies = false
_noskel = false
_maxflies = 7


_pos = getpos _unit

~random 10

? (_unit in deadlist) : exit

deadlist = deadlist + [_unit]

#firstloop

~random 50

? count deadlist < _maxbodies:goto "firstloop"

deadlist = deadlist - [_unit]

? vehicle _unit != driver _unit : goto "delete"

~300

_obj = "logic" createvehicle getpos _unit


_x = getPos _unit select 0
_y = getPos _unit select 1
_z = getPos _unit select 2

? _noflies : goto "next"

_n = 0

#loopflies
~random 30

drop ["\FPW_obj\FPW_fly", "", "Billboard", 1,   5, [(_x + (random 0.6)) , (_y + (random 0.1)), _z +0.1], [0,0,(random 0.4)],  0,     1.275,  1,  0.02, [0.03,0.03], [[1,1,1,0.9], [1,1,1,0.9], [1,1,1,0.6], [1,1,1,0]], [0],   0.1,   0.6,   "",    "",     "_unit"]
_obj say "FPW_fly"

~0.1

_n = _n + 1
? (_n <= _maxflies) : goto "loopflies"

#next

~0.1

? _noskel : goto "skipskel"


? ("soldier" counttype [_unit]== 1):_skel = "FPW_skel" camcreate [0,0,0]
? ("FPW_horM" counttype [_unit]== 1):_skel = "FPW_Hskel" camcreate [0,0,0]

~2
_skel switchmove _animplayed
~1
_skel setdir getdir _unit
~1
_skel setdammage 1

~10
_skel setpos getpos _unit
~0.1
_skel setdir getdir _unit



#skipskel

~3
_x = getPos _unit select 0
_y = getPos _unit select 1
_z = getPos _unit select 2

#sinkbody

_unit setPos [(_x),(_y),(_z)]
_z = _z -.001
~.001
? _z > -.5 : goTo "sinkbody"

deletevehicle _unit
deletevehicle _obj

Exit

#delete

~300
deletevehicle _unit
deletevehicle _obj
Exit

