fnc_emp_enableVehicle.sqf 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. params["_vehicle"];
  2. if!(local _vehicle) exitWith { diag_log "[RD501][Vehicle EMP] Exiting enable because not local"; };
  3. diag_log format["[RD501][Vehicle EMP] Enabling Vehicle '%1'", _vehicle];
  4. _vehicle allowCrewInImmobile false;
  5. _vehicle lock 0;
  6. {
  7. _x setBehaviour "AWARE";
  8. _x setCombatMode "YELLOW";
  9. _x enableAI "TARGET";
  10. _x enableAI "AUTOTARGET";
  11. _x enableAI "MOVE";
  12. _x enableAI "FSM";
  13. } forEach crew _vehicle;
  14. (getAllHitPointsDamage _vehicle) params [["_allHitPoints", []]];
  15. _fnc_matchesAnyTurret = {
  16. params["_hitpoint"];
  17. private _found = false;
  18. {
  19. if(_hitpoint find _x != -1) exitWith {
  20. _found = true;
  21. };
  22. } forEach ["turret","Turret","vez","Vez","zbran","Zbran","gun","Gun"];
  23. _found
  24. };
  25. {
  26. private _isEngineLower = (_x find "engine") != -1;
  27. private _isEngineUpper = (_x find "Engine") != -1;
  28. if(_isEngineLower || _isEngineUpper) then {
  29. _vehicle setHitPointDamage [_x, 0];
  30. diag_log format["[RD501][Vehicle EMP] Repairing %1", _x];
  31. };
  32. private _isTurret = [_x] call _fnc_matchesAnyTurret;
  33. if(_isTurret) then {
  34. _vehicle setHitPointDamage [_x, 0];
  35. diag_log format["[RD501][Vehicle EMP] Repairing %1", _x];
  36. };
  37. } forEach _allHitPoints;
  38. _vehicle engineOn true;