1
0

fn_onhitemp.sqf 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * Author: MrClock
  3. * EMP ammo hit handler
  4. *
  5. *
  6. * Arguments:
  7. * 0: Unit <OBJECT>
  8. * 1: Unit <OBJECT>
  9. * 2: Ammo <STRING>
  10. * 3: Projectile <OBJECT>
  11. *
  12. * Example:
  13. * [Bob,Jack,"GrenadeHand",objNull] call JLTS_fnc_onHitEMP;
  14. *
  15. * Return Value:
  16. * None
  17. *
  18. */
  19. #define COOLDOWN 2
  20. params["_target", "_shooter", "_ammo","_projectile"];
  21. if ((getText(configFile >> "CfgAmmo" >> _ammo >> "simulation") != "shotBullet") && ((_projectile distance _target) > getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange"))) exitWith {/*systemChat "Out of range"*/};
  22. private _weaponsTarget = weapons _target;
  23. _fryOnEMP = false;
  24. if (_target getVariable["JLTS_EMPCooldown",CBA_missionTime - 1] < CBA_missionTime) then {
  25. if (JLTS_settings_EMP_EMPEffectScope > 0) then {
  26. {
  27. if (getNumber(configFile >> "CfgWeapons" >> _x >> "JLTS_isFried") == 1) then {} else
  28. {
  29. if (getNumber(configFile >> "CfgWeapons" >> _x >> "JLTS_hasElectronics") == 1 &&
  30. getNumber(configFile >> "CfgWeapons" >> _x >> "JLTS_hasEMPProtection") != 1 &&
  31. getNumber(configFile >> "CfgWeapons" >> _x >> "RD501_fryOnEMP") != 1) then {
  32. private _friedWeapon = getText(configFile >> "CfgWeapons" >> _x >> "JLTS_friedItem");
  33. switch (true) do {
  34. case (_x in uniformItems _target): {
  35. _target removeItemFromUniform _x;
  36. _target addItemToUniform _friedWeapon;
  37. };
  38. case (_x in vestItems _target): {
  39. _target removeItemFromVest _x;
  40. _target addItemToVest _friedWeapon;
  41. };
  42. case (_x in backpackItems _target): {
  43. _target removeItemFromBackpack _x;
  44. _target addItemToBackpack _friedWeapon;
  45. };
  46. default {
  47. switch (true) do {
  48. case (_x in weapons _target): {
  49. [_x,_target,"FRY"] call JLTS_fnc_weaponEMPEffect;
  50. };
  51. default {};
  52. };
  53. };
  54. };
  55. _fryOnEMP = true;
  56. } else {
  57. if (getNumber(configFile >> "CfgWeapons" >> _x >> "JLTS_hasEMPProtection") != 1 &&
  58. getNumber(configFile >> "CfgWeapons" >> _x >> "RD501_fryOnEMP") != 1) then
  59. {
  60. [_target, currentWeapon _target] call ace_overheating_fnc_jamWeapon;
  61. };
  62. };
  63. };
  64. } forEach _weaponsTarget;
  65. if (JLTS_settings_EMP_EMPEffectScope > 1) then {
  66. {
  67. if (getNumber(configFile >> "CfgMagazines" >> _x >> "JLTS_hasElectronics") == 1 && getNumber(configFile >> "CfgMagazines" >> _x >> "JLTS_hasEMPProtection") != 1) then {
  68. _target removeMagazines _x;
  69. };
  70. } forEach magazines _target;
  71. };
  72. if (JLTS_settings_EMP_EMPEffectScope > 2) then {
  73. {
  74. if (getNumber(configFile >> "CfgWeapons" >> _x >> "JLTS_hasElectronics") == 1 && getNumber(configFile >> "CfgWeapons" >> _x >> "JLTS_hasEMPProtection") != 1) then {
  75. _target unassignItem _x;
  76. };
  77. } forEach assignedItems _target;
  78. {
  79. if (getNumber(configFile >> "CfgWeapons" >> _x >> "JLTS_hasElectronics") == 1 && getNumber(configFile >> "CfgWeapons" >> _x >> "JLTS_hasEMPProtection") != 1) then {
  80. _target removeItem _x;
  81. };
  82. } forEach items _target;
  83. };
  84. };
  85. playSound3D[
  86. selectRandom [
  87. "MRC\JLTS\weapons\Core\sounds\fried_weapon\1.wss",
  88. "MRC\JLTS\weapons\Core\sounds\fried_weapon\2.wss",
  89. "MRC\JLTS\weapons\Core\sounds\fried_weapon\3.wss",
  90. "MRC\JLTS\weapons\Core\sounds\fried_weapon\4.wss",
  91. "MRC\JLTS\weapons\Core\sounds\fried_weapon\5.wss"
  92. ],
  93. _target,
  94. false,
  95. getPosASL _target,
  96. 5,
  97. 1,
  98. 0
  99. ];
  100. _target setVariable["JLTS_EMPCooldown",CBA_missionTime + COOLDOWN,true];
  101. private _uniform = uniform _target;
  102. private _isDroid = getNumber(configFile >> "CfgWeapons" >> _uniform >> "JLTS_isDroid");
  103. private _affectedUniforms = missionNamespace getVariable["JLTS_emp_affectedUniforms",[]];
  104. private _protectedUniforms = missionNamespace getVariable["JLTS_emp_protectedUniforms",[]];
  105. private _useConfig = missionNamespace getVariable["JLTS_emp_useConfig",true];
  106. _toFry = false;
  107. if (_useConfig) then {
  108. if ((_isDroid == 1 || _uniform in _affectedUniforms) && {!(_uniform in _protectedUniforms)} && {alive _target}) then {
  109. _toFry = true;
  110. };
  111. } else {
  112. if (_uniform in _affectedUniforms && {alive _target}) then {
  113. _toFry = true;
  114. };
  115. };
  116. if (_toFry) then {
  117. [_target, _fryOnEMP] spawn {
  118. private _timeOfHit = CBA_missionTime;
  119. private _useDefaultSounds = missionNamespace getVariable["JLTS_emp_useDefaultSounds",true];
  120. params ["_target", "_fryOnEMP"];
  121. private _uniform = uniform _target;
  122. _target stop true;
  123. waitUntil {_timeOfHit + 1 < CBA_missionTime};
  124. _target disableAI "all";
  125. if (_fryOnEMP) then {
  126. [_target,"DROID"] remoteExec ["JLTS_fnc_showHintEMP",0,true];
  127. } else {
  128. [_target,"DROID"] remoteExec ["RD501_fnc_showHintEMP",0,true];
  129. };
  130. private _delay = _timeOfHit + random[1,5,10];
  131. waitUntil {_delay < CBA_missionTime};
  132. if (getText(configFile >> "CfgWeapons" >> _uniform >> "JLTS_deathSounds") != "") then {
  133. private _deathSoundClass = getText(configFile >> "CfgWeapons" >> _uniform >> "JLTS_deathSounds");
  134. private _friedSound = selectRandom getArray(configFile >> "CfgJLTSDeathSounds" >> _deathSoundClass >> "emp");
  135. playSound3D[_friedSound,_target,false,getPosASL _target,2,1,0];
  136. } else {
  137. if (_useDefaultSounds) then {
  138. private _friedSound = selectRandom getArray(configFile >> "CfgJLTSDeathSounds" >> "DeathDroid" >> "emp");
  139. playSound3D[_friedSound,_target,false,getPosASL _target,2,1,0];
  140. };
  141. };
  142. if (alive _target) then {
  143. _target setDamage 1;
  144. };
  145. _target setVariable ["JLTS_EMPCooldown",nil, true];
  146. };
  147. } else {
  148. if (_fryOnEMP) then {
  149. [_target,"HUMAN"] remoteExec ["JLTS_fnc_showHintEMP",0,true];
  150. } else {
  151. [_target,"HUMAN"] remoteExec ["RD501_fnc_showHintEMP",0,true];
  152. };
  153. };
  154. } else {
  155. //systemChat "EMP cooldown"
  156. };