Ok, found a solution.
Code:
fnc_injured = {
_unit = _this select 0;
_unit removeAllMPEventHandlers "MPHit";
[ _unit ] remoteExec [ "TAG_fnc_setunconscious", 2 ];
sleep 3;
_anim = [
"UnconsciousReviveArms_A","UnconsciousReviveArms_B","UnconsciousReviveArms_C","UnconsciousReviveBody_A",
"UnconsciousReviveBody_B","UnconsciousReviveDefault_A","UnconsciousReviveDefault_B","UnconsciousReviveHead_A",
"UnconsciousReviveHead_B","UnconsciousReviveHead_C","UnconsciousReviveLegs_A","UnconsciousReviveLegs_B"
] call bis_fnc_selectRandom;
[[[_unit,_anim],"animation.sqf"],"BIS_fnc_execVM",true,false] call BIS_fnc_MP;
while {(true)} do {
sleep (30 + random 60);
_ls = lifeState _unit;
if (_ls != "INCAPACITATED") exitWith {};
_sound = [
"pain1", "pain2", "pain3", "pain4", "pain5", "pain6", "pain7", "pain8", "pain9", "pain10", "pain11", "pain12", "pain13"
] call BIS_fnc_selectRandom;
_unit say3D [_sound, 100, 1];
sleep (60 + random 60);
};
};
Code:
TAG_fnc_setunconscious = {
params[ "_unit" ];
[ _unit, true ] remoteExec [ "setUnconscious", _unit ];
};
_null = [] execvm "injured.sqf";
Code:
sleep 3;
{
if (side _x == east) then {
if (_x isKindOf "Man") then
{
_x removeAllMPEventHandlers "MPHit";
call compile format["
%1 addMPEventHandler ['MPHit',{
if (vehicle %1 == %1) then {
_rand = random 100;
if (_rand < 35) then {
[%1] spawn fnc_injured;
};
};
}]
",[_x] call BIS_fnc_objectVar];
};
};
} forEach allUnits;
Code:
_unit = _this select 0;
_anim = _this select 1;
_unit disableAI "TARGET";
_unit disableAI "AUTOTARGET";
_unit disableAI "MOVE";
_unit disableAI "TEAMSWITCH";
_unit disableAI "FSM";
_unit disableAI "AIMINGERROR";
_unit disableAI "SUPPRESSION";
_unit disableAI "COVER";
_unit disableAI "AUTOCOMBAT";
_unit disableAI "PATH";
while {true} do {
_ls = lifeState _unit;
if (_ls != "INCAPACITATED") exitWith {};
_unit playMove _anim;
sleep 5;
};