fnc_emp_hitVehicle.sqf 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. params["_ammo", "_vehicle"];
  2. if!(local _vehicle) exitWith {
  3. diag_log format["[RD501][Vehicle EMP] '%1' is REMOTE", _vehicle];
  4. };
  5. private _config = configFile >> "CfgAmmo" >> _ammo;
  6. private _empEnabled = 0;
  7. if(isNumber (_config >> "rd501_emp_vehicle_enabled")) then {
  8. _empEnabled = getNumber (_config >> "rd501_emp_vehicle_enabled");
  9. };
  10. if(_empEnabled != 1) exitWith { };
  11. private _empDuration = 10;
  12. if(isNumber (_config >> "rd501_emp_vehicle_duration")) then {
  13. _empDuration = getNumber (_config >> "rd501_emp_vehicle_duration");
  14. };
  15. _config = configFile >> "CfgVehicles" >> (typeOf _vehicle);
  16. private _empResistancePercent = 0;
  17. if(isNumber (_config >> "rd501_emp_vehicle_resistance_percent")) then {
  18. _empResistancePercent = getNumber (_config >> "rd501_emp_vehicle_resistance_percent");
  19. _empResistancePercent = _empResistancePercent max 100;
  20. };
  21. private _effectiveDuration = _empDuration * (1 + ((-_empResistancePercent)/100));
  22. diag_log format["[RD501][Vehicle EMP] Effective Duration = %1 seconds", _effectiveDuration];
  23. if(_effectiveDuration <= 1) exitWith { diag_log "[RD501][Vehicle EMP] Effective EMP Duration too low, not worth setting. Skipped." };
  24. diag_log format["[RD501][Vehicle EMP] Enabling %1", _vehicle];
  25. [_vehicle] call rd501_fnc_emp_disableVehicle;
  26. [
  27. {
  28. params["_vehicle"];
  29. if(alive _vehicle) then {
  30. [_vehicle] call rd501_fnc_emp_enableVehicle;
  31. };
  32. },
  33. [_vehicle],
  34. _effectiveDuration
  35. ] call CBA_fnc_waitAndExecute;