Advertisement
Rafael09ED

Untitled

Apr 24th, 2016
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. _unit = _this select 0;
  2.  
  3. //_unit removeAllEventHandlers "HandleDamage";
  4. _unit setVariable ["NotShotDown", true];
  5. _unit addEventHandler ["HandleDamage", {
  6. private ["_targ","_dmg"];
  7. _targ = _this select 0;
  8. _part = _this select 1;
  9. _dmg = _this select 2;
  10. _index = _this select 5;
  11. _isCrash = false;
  12. _returnVal = _dmg;
  13. _health = 0;
  14.  
  15. if(_index == -1) then {
  16. _health = damage _targ;
  17. } else {
  18. _health = _targ getHit _part;
  19. };
  20. if (_health + _dmg > 0.88) then {
  21. if (_index == -1) then {
  22. _returnVal = 0;
  23. _targ setDamage .88;
  24. _isCrash = true;
  25. };
  26. if(_isCrash) then {
  27. if (_targ getVariable "NotShotDown") then {
  28. _targ setVariable ["NotShotDown", false];
  29. [_targ] execVM "f\util\fn_onHeliCrash.sqf";
  30. };
  31. };
  32. };
  33. _returnVal
  34. }];
  35.  
  36.  
  37. ===============================================================================fn_onHeliCrash.sqf =====================================
  38.  
  39. _targ = _this select 0;
  40. _targ setFuel 0;
  41. _targ setHitPointDamage ["HitHRotor",.88];
  42. _targ setHitPointDamage ["HitVRotor",.88];
  43. _targ setHitPointDamage ["HitEngine",.88];
  44. _fire = createvehicle ["test_EmptyObjectForFireBig", position _targ,[],0,"CAN_COLLIDE"];
  45. _fire attachTo [_targ,[0,0.0,0.0],"motor"];
  46. _targ allowDamage false;
  47. {
  48. [_x, true, 15 + random 10] call ace_medical_fnc_setUnconscious;
  49. [_x, 0.5] call ace_medical_fnc_adjustPainLevel;
  50. _x allowDamage false;
  51. } forEach crew _targ;
  52.  
  53. _targ spawn {
  54. _targ = _this;
  55. _soundLoop = _targ spawn {
  56. for "_i" from 1 to 60 do {
  57. _this say3D ["AutorotationWarn", 3, 1];
  58. sleep 1.105;
  59. };
  60. };
  61. waitUntil {
  62. sleep 1; _totalSpeed = 0;
  63. _alt = (getPosATL _targ) select 2;
  64. {_totalSpeed = _totalSpeed + _x} forEach velocity _targ;
  65. (_totalSpeed < 20 && _alt < 3) or !alive _targ;
  66. };
  67. terminate _soundLoop;
  68. sleep 40 + random 20;
  69. _targ removeAllEventHandlers "HandleDamage";
  70. _targ allowDamage true;
  71. _targ setDamage 1;
  72. };
  73. {
  74. [_x] spawn {
  75. _unit = _this select 0;
  76. _eventIndex = _unit addEventHandler ["HandleDamage", {0}];
  77. _unit allowDamage false;
  78. waitUntil {
  79. sleep .5 + random 2; _alt = (getPosATL _unit) select 2;
  80. _alt < 1.5;
  81. };
  82. sleep random 1;
  83. _unit action ["eject", vehicle _unit];
  84. if (local _unit) then {
  85. // ragdoll
  86. _unit spawn {
  87. private "_rag";
  88. _unit = _this;
  89. sleep .5;
  90. _rag = "Steel_Plate_L_F" createVehicleLocal [0, 0, 0];
  91. _rag setObjectTexture [0, ""];
  92. _rag setMass 500;
  93. _dir = (direction _unit) + 45 - random 90;
  94. _rag setDir _dir;
  95. _bbr = boundingBoxReal _unit;
  96. _unitPos = getPos _unit;
  97. _rag setPosATL [
  98. (_unitPos select 0) + sin(_dir + 180), (_unitPos select 1) + cos(_dir + 180),
  99. (abs (((_bbr select 1) select 2) - ((_bbr select 0) select 2)))/2];
  100. _unit setVelocity [0,0,0];
  101. _rag setVelocity [(sin(_dir)) * 12, (cos(_dir)) * 12, .7 - random 1];
  102. _rag spawn {
  103. sleep 0.5;
  104. deleteVehicle _this;
  105. };
  106. };
  107. };
  108. sleep 7;
  109. _unit removeEventHandler ["HandleDamage", _eventIndex];
  110. _unit allowDamage true;
  111. [_unit,_unit] call ACE_medical_fnc_treatmentAdvanced_fullHealLocal;
  112. {
  113. _cause = ["vehiclecrash", "explosive"] select (round random 1);
  114. [_unit, random 1, _x, _cause] call ace_medical_fnc_addDamageToUnit;
  115. sleep .2;
  116. } forEach ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"];
  117. sleep .5;
  118. [_unit, false] call ace_medical_fnc_setUnconscious;
  119.  
  120. };
  121. } forEach crew _targ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement