fnc_jammerControlActions.sqf 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. params["_jammer", "_object", ["_useMainActions", true]];
  2. private _fnc_rootCondition = {
  3. params ["_target", "_player", "_params"];
  4. if(!alive _target) exitWith { false };
  5. _params params["_jammer"];
  6. _jammer != objNull && !isNil "_jammer" && alive _jammer && {missionNamespace getVariable ["rd501_jammers", []] findIf {_x select 0 == _jammer} != -1}
  7. };
  8. if(_useMainActions) then {
  9. _action = ["rd501_jammer", "Jammer", "", { }, _fnc_rootCondition, {["ACE_MainActions"]}] call ace_interact_menu_fnc_createAction;
  10. }
  11. else {
  12. _action = ["rd501_jammer", "Jammer", "", { }, _fnc_rootCondition, {[]}] call ace_interact_menu_fnc_createAction;
  13. };
  14. [_object, 0, [], _action] call ace_interact_menu_fnc_addActionToObject;
  15. private _fnc_destroyCondition = {
  16. params ["_target", "_player", "_params"];
  17. if(!alive _target) exitWith { false };
  18. _params params["_jammer"];
  19. _jammer == objNull || isNil "_jammer" || !alive _jammer || {missionNamespace getVariable ["rd501_jammers", []] findIf {_x select 0 == _jammer} == -1}
  20. };
  21. if(_useMainActions) then {
  22. _action = ["rd501_jammer_destroyed", "Jammer (Destroyed)", "", { }, _fnc_destroyCondition, {["ACE_MainActions"]}, [_jammer]] call ace_interact_menu_fnc_createAction;
  23. }
  24. else {
  25. _action = ["rd501_jammer_destroyed", "Jammer (Destroyed)", "", { }, _fnc_destroyCondition, {[]}, [_jammer]] call ace_interact_menu_fnc_createAction;
  26. };
  27. [_object, 0, [], _action] call ace_interact_menu_fnc_addActionToObject;
  28. //Enable Jammer
  29. _fnc_enableCondition = {
  30. params["","","_params"];
  31. _params params["_jammer"];
  32. private _jammers = missionNamespace getVariable ["rd501_jammers", []];
  33. private _index = _jammers findIf {_x select 0 == _jammer};
  34. if(_index == -1) exitWith { false };
  35. (_jammers select _index) params ["","","","","_active"];
  36. !_active
  37. };
  38. private _enableStatement = {
  39. params ["_target", "_player", "_params"];
  40. _params params["_jammer"];
  41. private _jammers = missionNamespace getVariable ["rd501_jammers", []];
  42. private _index = _jammers findIf {_x select 0 == _jammer};
  43. if(_index == -1) exitWith { };
  44. (_jammers select _index) set [4, true];
  45. };
  46. _action = ["rd501_jammer_enable", "Enable Jammer", "", _enableStatement, _fnc_enableCondition, {[]}, [_jammer]] call ace_interact_menu_fnc_createAction;
  47. [_object, 0, ["rd501_jammer"], _action] call ace_interact_menu_fnc_addActionToObject;
  48. // Disable Jammer
  49. private _fnc_disableCondition = {
  50. params["","","_params"];
  51. _params params["_jammer"];
  52. private _jammers = missionNamespace getVariable ["rd501_jammers", []];
  53. private _index = _jammers findIf {_x select 0 == _jammer};
  54. if(_index == -1) exitWith { false };
  55. (_jammers select _index) params ["","","","","_active"];
  56. _active
  57. };
  58. private _fnc_disableStatement = {
  59. params ["_target", "_player", "_params"];
  60. _params params["_jammer"];
  61. private _jammers = missionNamespace getVariable ["rd501_jammers", []];
  62. private _index = _jammers findIf {_x select 0 == _jammer};
  63. if(_index == -1) exitWith { };
  64. (_jammers select _index) set [4, false];
  65. };
  66. _action = ["rd501_jammer_disable", "Disable Jammer", "", _fnc_disableStatement, _fnc_disableCondition, {[]}, [_jammer]] call ace_interact_menu_fnc_createAction;
  67. [_object, 0, ["rd501_jammer"], _action] call ace_interact_menu_fnc_addActionToObject;