Advertisement
KBWebb1994

Untitled

Sep 23rd, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. /*
  2. File: fn_handleDamage.sqf
  3. Author: Bryan "Tonic" Boardwine
  4.  
  5. Description:
  6. Master damage handling system for Stratis / Altis Life
  7. */
  8. private["_unit","_damage","_source","_projectile","_sel","_curWep"];
  9. _unit = _this select 0;
  10. _sel = _this select 1;
  11. _damage = _this select 2;
  12. _source = _this select 3;
  13. _projectile = _this select 4;
  14. _curWep = "";
  15.  
  16. if(isPlayer _source && _source isKindOf "Man") then {_curWep = currentWeapon _source;};
  17.  
  18. // Stun grenades
  19. if (_projectile in ["mini_Grenade"]) then{
  20. _damage = 0;
  21. [] spawn life_fnc_handleFlashbang;
  22. };
  23.  
  24. if(_source != _unit && isPlayer _source && _curWep in ["hgun_P07_snds_F","arifle_SDAR_F"]) then
  25. {
  26. if(side _source == west || _source getVariable "bountyHunter") then
  27. {
  28. _unit allowDamage false;
  29. _damage = 0;
  30. if(_projectile in ["B_9x21_Ball","B_556x45_dual"]) then
  31. {
  32. _damage = 0;
  33. if(_curwep == "arifle_SDAR_F") then
  34. {
  35. if(!life_istazed && !(player getVariable["restrained",false]) && player distance _source < 100) then
  36. {
  37. _damage = 0;
  38. if(typeOf (vehicle player) == "B_Quadbike_01_F") then
  39. {
  40. player action ["Eject",vehicle player];
  41. [_unit,_source] spawn life_fnc_tazed;
  42. };
  43.  
  44. if(vehicle player == player) then
  45. {
  46. [_unit,_source] spawn life_fnc_tazed;
  47. };
  48. };
  49. }
  50. else
  51. {
  52. _damage = 0;
  53. if(!life_istazed && !(player getVariable["restrained",false]) && player distance _source < 100) then
  54. {
  55. _damage = 0;
  56. if(typeOf (vehicle player) == "B_Quadbike_01_F") then
  57. {
  58. player action ["Eject",vehicle player];
  59. [_unit,_source] spawn life_fnc_tazed;
  60. };
  61.  
  62. if(vehicle player == player) then
  63. {
  64. [_unit,_source] spawn life_fnc_tazed;
  65. };
  66. };
  67. };
  68. }
  69. else
  70. {
  71. _damage = 0;
  72. if(_projectile == "") then
  73. {
  74. _damage = 0;
  75. };
  76. };
  77.  
  78. };
  79. };
  80.  
  81. _unit allowDamage true;
  82.  
  83. if((player getVariable["restrained",false])) then
  84. {
  85. _damage = 0;
  86. };
  87.  
  88.  
  89. if(_sel == "") then
  90. {
  91. if ((damage _unit + _damage) > 0.99) then
  92. {
  93. _unit playMove "AinjPpneMstpSnonWrflDnon_rolltoback";
  94. _unit setDamage 0;
  95. _unit allowDamage false;
  96.  
  97. life_abort_enabled = true;
  98.  
  99. _damage = 0;
  100. if(!(_unit getVariable ["unconscious", false])) then
  101. {
  102. _unit setVariable["unconscious",true,true];
  103. if(isNull _source && alive _unit) then
  104. {
  105. [[0,format["%1 was critically wounded by an environmental collision.", name _unit]],"life_fnc_broadcast",true,false] spawn life_fnc_MP;
  106. }
  107. else
  108. {
  109. [[0,format["%1 was critically wounded by %2", name _unit, name _source]],"life_fnc_broadcast",true,false] spawn life_fnc_MP;
  110. if(vehicle _source isKindOf "LandVehicle") then
  111. {
  112. if(side _source == civilian && _source != player) then {[[getPlayerUID _source,name _source,"481"],"life_fnc_wantedAdd",false,false] spawn life_fnc_MP;};
  113. }
  114. else
  115. {
  116. if(side _source == civilian && _source != player) then {[[getPlayerUID _source,name _source,"245"],"life_fnc_wantedAdd",false,false] spawn life_fnc_MP;};
  117. [_unit] spawn life_fnc_dropItems;
  118. life_carryWeight = 0;
  119. };
  120. };
  121. [_unit, _source] spawn life_fnc_unconscious;
  122. }
  123. };
  124. }
  125. else
  126. {
  127.  
  128. _ghp = switch (_sel) do
  129. {
  130. case "body": { "HitBody" };
  131. case "head": { "HitHead" };
  132. case "hand_l": { "HitHands" };
  133. case "leg_l": { "HitLegs" };
  134. };
  135. if (((_unit getHitPointDamage _ghp) + _damage) > 0.99) then
  136. {
  137. _unit setHitPointDamage [_ghp,0.99];
  138. _damage = 0;
  139. };
  140. };
  141.  
  142. [] call life_fnc_hudUpdate;
  143. //systemChat format ["Hitbox: %1 | Overall health: %2 | Hitbox health: %3 | Damage taken: %4",_sel,damage _unit,_unit getHitPointDamage _ghp,_damage];
  144. _damage;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement