fnc_emp_hitVehicle.sqf 1.3 KB

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