Advertisement
Akaviri13

damageCalc

Jan 7th, 2021
2,469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 5.38 KB | None | 0 0
  1. span class="re5"> APA_fnc_calcDamage = {
  2.     switch (true) do {
  3.         case (_hitbodypart in APA_head): {
  4.             affectedPart = "APA_headArmor";
  5.         };
  6.         case (_hitbodypart in APA_body): {
  7.             affectedPart = "APA_bodyArmor";
  8.         };
  9.         case (_hitbodypart in APA_rightArm): {
  10.             affectedPart = "APA_armArmor_r";
  11.         };
  12.         case (_hitbodypart in APA_leftArm): {
  13.             affectedPart = "APA_armArmor_l";
  14.         };
  15.         case (_hitbodypart in APA_rightLeg): {
  16.             affectedPart = "APA_legArmor_r";
  17.         };
  18.         case (_hitbodypart in APA_leftLeg): {
  19.             affectedPart = "APA_legArmor_l";
  20.         };
  21.     };
  22.     _hitpartArmorLevel = _target getVariable affectedPart;
  23.     if (_hitpartArmorLevel > 0) then {
  24.         if (_damage > _hitpartArmorLevel) then {
  25.             _target setVariable [affectedPart, 0];
  26.             _breaksound = selectRandom[
  27.                 "A3\Sounds_F\vehicles\crashes\armors\tank_coll_armor_1.ogg",
  28.                 "A3\Sounds_F\vehicles\crashes\armors\tank_coll_armor_2.ogg",
  29.                 "A3\Sounds_F\vehicles\crashes\armors\tank_coll_armor_3.ogg",
  30.                 "A3\Sounds_F\vehicles\crashes\armors\tank_coll_armor_4.ogg"
  31.             ];
  32.             playsound3d [_breaksound, _target];
  33.             playsound "ALARM";
  34.             _restDamage = (_damage - _hitpartArmorLevel);
  35.             [_target,_hitbodypart,_selection,_restdamage] call APA_fnc_restDamage;
  36.         } else {
  37.             _target setVariable [affectedPart, _hitpartArmorLevel - _damage];
  38.         };
  39.  
  40.         _hitsound = selectRandom[
  41.         "A3\Sounds_F\weapons\hits\metal_1.wss",
  42.         "A3\Sounds_F\weapons\hits\metal_2.wss",
  43.         "A3\Sounds_F\weapons\hits\metal_3.wss",
  44.         "A3\Sounds_F\weapons\hits\metal_4.wss",
  45.         "A3\Sounds_F\weapons\hits\metal_5.wss",
  46.         "A3\Sounds_F\weapons\hits\metal_6.wss"
  47.         ];
  48.  
  49.         playsound3d [_hitsound, _target];
  50.     } else {
  51.         _restDamage = (_damage - _hitpartArmorLevel);
  52.         [_target,_hitbodypart,_selection,_restDamage] call APA_fnc_restDamage;
  53.     };
  54. };
  55.  
  56. APA_fnc_restDamage = {
  57.  
  58.     if (isClass(configFile >> "CfgPatches" >> "ace_medical")) then {
  59.         if (count _selection == 0) then {
  60.             newSelection = selectRandom ["Head","Body","LeftArm","RightArm","LeftArm","RightArm"];
  61.         };
  62.         if (_hitbodypart in APA_head) then {
  63.             newSelection = "Head";
  64.         };
  65.         if (_hitbodypart in APA_body) then {
  66.             newSelection = "Body";
  67.         };
  68.         if (_hitbodypart in APA_leftArm) then {
  69.             newSelection = "LeftArm";
  70.         };
  71.         if (_hitbodypart in APA_rightArm) then {
  72.             newSelection = "RightArm";
  73.         };
  74.         if (_hitbodypart in APA_leftLeg) then {
  75.             newSelection = "LeftLeg";
  76.         };
  77.         if (_hitbodypart in APA_rightLeg) then {
  78.             newSelection = "RightLeg";
  79.         };
  80.        
  81.         if (_restDamage > 50) then {
  82.  
  83.             [_target, (_restDamage/50), newSelection, "explosion"] call ace_medical_fnc_addDamageToUnit;
  84.  
  85.             _randomSelection = ["Head","Body","LeftArm","RightArm","LeftArm","RightArm"];
  86.             for "_i" from 0 to 5 do {
  87.                 if (selectRandom [true, false]) then {
  88.                     [_target, (_restDamage/50), selectRandom _randomSelection, "explosion"] call ace_medical_fnc_addDamageToUnit;
  89.                 };
  90.             };
  91.         } else {
  92.             [_target, (_restDamage/25), newSelection, "bullet"] call ace_medical_fnc_addDamageToUnit;
  93.         };
  94.         //[format ["%1 %2 %3", _target, (_restDamage/25), newSelection]] remoteexec ['systemchat'];
  95.     } else {
  96.        
  97.         if (count _selection == 0) then {
  98.             newSelection = selectRandom ["hithead","hitbody","hitleftarm","hitrightarm","hitleftleg","hitrightleg"];
  99.         };
  100.        
  101.         if (_hitbodypart in APA_head) then {
  102.             newSelection = "hithead";
  103.         };
  104.         if (_hitbodypart in APA_body) then {
  105.             newSelection = "hitbody";
  106.         };
  107.         if (_hitbodypart in APA_leftArm) then {
  108.             newSelection = "hitleftarm";
  109.         };
  110.         if (_hitbodypart in APA_rightArm) then {
  111.             newSelection = "hitrightarm";
  112.         };
  113.         if (_hitbodypart in APA_leftLeg) then {
  114.             newSelection = "hitleftleg";
  115.         };
  116.         if (_hitbodypart in APA_rightLeg) then {
  117.             newSelection = "hitrightleg";
  118.         };
  119.  
  120.         if (_restDamage > 50) then {
  121.             [_target,_restDamage] spawn {
  122.                 [_this] call {
  123.                     (_this select 0) params ["_target","_restDamage"];
  124.                     sleep 0.05;
  125.                    
  126.                     //[_target, (_restDamage/50), newSelection, "explosion"] call ace_medical_fnc_addDamageToUnit;
  127.                     _hitPointDamage = _target getHitPointDamage newSelection;
  128.                     _target setHitPointDamage [newSelection, _hitPointDamage + _restDamage/500];
  129.                     //[format ["%1 %2 %3", newSelection, _hitPointDamage, _restDamage/500]] remoteexec ['systemchat'];
  130.                     _randomSelection = selectRandom ["hithead","hitbody","hitleftarm","hitrightarm","hitleftleg","hitrightleg"];
  131.                     for "_i" from 0 to 5 do {
  132.                         if (selectRandom [true, false]) then {
  133.                             _hitPointDamage = _target getHitPointDamage _randomSelection;
  134.                             _target setHitPointDamage [_randomSelection, _hitPointDamage + _restDamage/500];
  135.                         };
  136.                     };
  137.                     //[format ["%1", getAllHitPointsDamage _target]] remoteexec ['systemchat'];
  138.                 };
  139.             };
  140.         } else {
  141.             //_hitPointDamage = _target getHitPointDamage newSelection;
  142.             //_target setHitPointDamage [newSelection, _hitPointDamage + _restDamage/25];
  143.             //[format ["%1 %2 %3", newSelection, _hitPointDamage, _restDamage/25]] remoteexec ['systemchat'];
  144.  
  145.             [_target,_restDamage] spawn {
  146.                 [_this] call {
  147.                     (_this select 0) params ["_target","_restDamage"];
  148.                     sleep 0.05;
  149.                     _hitPointDamage = _target getHitPointDamage newSelection;
  150.                     _target setHitPointDamage [newSelection, _hitPointDamage + _restDamage/25];
  151.                     //[format ["%1 %2 %3", newSelection, _hitPointDamage, _restDamage/25]] remoteexec ['systemchat'];
  152.                     //[format ["%1", getAllHitPointsDamage _target]] remoteexec ['systemchat'];
  153.                 };
  154.             };
  155.         };
  156.     };
  157. }; 
  158.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement