Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _unit = _this select 0;
- //_unit removeAllEventHandlers "HandleDamage";
- _unit setVariable ["NotShotDown", true];
- _unit addEventHandler ["HandleDamage", {
- private ["_targ","_dmg"];
- _targ = _this select 0;
- _part = _this select 1;
- _dmg = _this select 2;
- _index = _this select 5;
- _isCrash = false;
- _returnVal = _dmg;
- _health = 0;
- if(_index == -1) then {
- _health = damage _targ;
- } else {
- _health = _targ getHit _part;
- };
- if (_health + _dmg > 0.88) then {
- if (_index == -1) then {
- _returnVal = 0;
- _targ setDamage .88;
- _isCrash = true;
- };
- if(_isCrash) then {
- if (_targ getVariable "NotShotDown") then {
- _targ setVariable ["NotShotDown", false];
- [_targ] execVM "f\util\fn_onHeliCrash.sqf";
- };
- };
- };
- _returnVal
- }];
- ===============================================================================fn_onHeliCrash.sqf =====================================
- _targ = _this select 0;
- _targ setFuel 0;
- _targ setHitPointDamage ["HitHRotor",.88];
- _targ setHitPointDamage ["HitVRotor",.88];
- _targ setHitPointDamage ["HitEngine",.88];
- _fire = createvehicle ["test_EmptyObjectForFireBig", position _targ,[],0,"CAN_COLLIDE"];
- _fire attachTo [_targ,[0,0.0,0.0],"motor"];
- _targ allowDamage false;
- {
- [_x, true, 15 + random 10] call ace_medical_fnc_setUnconscious;
- [_x, 0.5] call ace_medical_fnc_adjustPainLevel;
- _x allowDamage false;
- } forEach crew _targ;
- _targ spawn {
- _targ = _this;
- _soundLoop = _targ spawn {
- for "_i" from 1 to 60 do {
- _this say3D ["AutorotationWarn", 3, 1];
- sleep 1.105;
- };
- };
- waitUntil {
- sleep 1; _totalSpeed = 0;
- _alt = (getPosATL _targ) select 2;
- {_totalSpeed = _totalSpeed + _x} forEach velocity _targ;
- (_totalSpeed < 20 && _alt < 3) or !alive _targ;
- };
- terminate _soundLoop;
- sleep 40 + random 20;
- _targ removeAllEventHandlers "HandleDamage";
- _targ allowDamage true;
- _targ setDamage 1;
- };
- {
- [_x] spawn {
- _unit = _this select 0;
- _eventIndex = _unit addEventHandler ["HandleDamage", {0}];
- _unit allowDamage false;
- waitUntil {
- sleep .5 + random 2; _alt = (getPosATL _unit) select 2;
- _alt < 1.5;
- };
- sleep random 1;
- _unit action ["eject", vehicle _unit];
- if (local _unit) then {
- // ragdoll
- _unit spawn {
- private "_rag";
- _unit = _this;
- sleep .5;
- _rag = "Steel_Plate_L_F" createVehicleLocal [0, 0, 0];
- _rag setObjectTexture [0, ""];
- _rag setMass 500;
- _dir = (direction _unit) + 45 - random 90;
- _rag setDir _dir;
- _bbr = boundingBoxReal _unit;
- _unitPos = getPos _unit;
- _rag setPosATL [
- (_unitPos select 0) + sin(_dir + 180), (_unitPos select 1) + cos(_dir + 180),
- (abs (((_bbr select 1) select 2) - ((_bbr select 0) select 2)))/2];
- _unit setVelocity [0,0,0];
- _rag setVelocity [(sin(_dir)) * 12, (cos(_dir)) * 12, .7 - random 1];
- _rag spawn {
- sleep 0.5;
- deleteVehicle _this;
- };
- };
- };
- sleep 7;
- _unit removeEventHandler ["HandleDamage", _eventIndex];
- _unit allowDamage true;
- [_unit,_unit] call ACE_medical_fnc_treatmentAdvanced_fullHealLocal;
- {
- _cause = ["vehiclecrash", "explosive"] select (round random 1);
- [_unit, random 1, _x, _cause] call ace_medical_fnc_addDamageToUnit;
- sleep .2;
- } forEach ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"];
- sleep .5;
- [_unit, false] call ace_medical_fnc_setUnconscious;
- };
- } forEach crew _targ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement