fortify_tool.sqf 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #include "../../config_macros.hpp"
  2. #include "\z\acex\addons\main\script_macros.hpp"
  3. #define AMMOITEM "RD501_fortify_nanobots"
  4. macro_grp_fnc_name(fortify,handleObjectPlaced) = {
  5. params ["_player", "_side", "_objectPlaced"];
  6. if (RD501_Fortify_useAmmo) then
  7. {
  8. ["RD501_fortify_remove_ammo", _player, _player] call CBA_fnc_targetEvent;
  9. };
  10. };
  11. macro_grp_fnc_name(fortify,handleObjectDeleted) = {
  12. params ["_player", "_side", "_objectDeleted"];
  13. if (RD501_Fortify_useAmmo) then
  14. {
  15. ["RD501_fortify_add_ammo", _player, _player] call CBA_fnc_targetEvent;
  16. };
  17. };
  18. macro_grp_fnc_name(fortify,deployHandler) = {
  19. params ["_unit", "_object", "_cost"];
  20. if (RD501_Fortify_useAmmo) then
  21. {
  22. private _can_fortify = AMMOITEM in (_unit call ACEFUNC(common,uniqueItems));
  23. if (!_can_fortify) then
  24. {
  25. private _item_name = (configFile >> "CfgWeapons" >> AMMOITEM >> "displayName") call BIS_fnc_getCfgData;
  26. systemChat format ["You need at least 1 %1 to use the Fortify Tool!", _item_name];
  27. };
  28. _can_fortify;
  29. }else
  30. {
  31. true;
  32. };
  33. };
  34. // Eventhandlers to be executed for acting player only
  35. ["RD501_fortify_add_ammo", {
  36. _player addItem AMMOITEM;
  37. }, [_player]] call CBA_fnc_addEventHandlerArgs;
  38. ["RD501_fortify_remove_ammo", {
  39. _player removeItem AMMOITEM;
  40. }, [_player]] call CBA_fnc_addEventHandlerArgs;
  41. // Register EventHandler for ACEX Fortify Events
  42. [macro_grp_fnc_name(fortify,deployHandler)] call acex_fortify_fnc_addDeployHandler;
  43. ["acex_fortify_objectPlaced", macro_grp_fnc_name(fortify,handleObjectPlaced)] call CBA_fnc_addEventHandler;
  44. ["acex_fortify_objectDeleted", macro_grp_fnc_name(fortify,handleObjectDeleted)] call CBA_fnc_addEventHandler;
  45. // Switch custom composition
  46. macro_grp_fnc_name(fortify,registerPreset) = {
  47. if (RD501_Fortify_usePreset) then
  48. {
  49. [west, 0, [
  50. ["Land_BagBunker_Small_F", 0],
  51. ["3as_Cover1", 0],
  52. ["3as_Cover2", 0],
  53. ["3as_Barricade_3_prop", 0]
  54. ]] call acex_fortify_fnc_registerObjects;
  55. } else
  56. {
  57. [west, 0, []] call acex_fortify_fnc_registerObjects;
  58. }
  59. };
  60. // Call preset switcher on mission start
  61. call macro_grp_fnc_name(fortify,registerPreset);
  62. // Add Settings to switch on/off
  63. private _item_name = (configFile >> "CfgWeapons" >> AMMOITEM >> "displayName") call BIS_fnc_getCfgData;
  64. [
  65. "RD501_Fortify_useAmmo",
  66. "CHECKBOX",
  67. ["Use item as Ammo", format["Additionally to Money, require 1 %1 to use the Fortify Tool",_item_name]],
  68. "ACEX Fortify",
  69. false
  70. ] call CBA_settings_fnc_init;
  71. [
  72. "RD501_Fortify_usePreset",
  73. "CHECKBOX",
  74. ["Use RD501 Fortify Preset", "If this box is checked, the RD501 Fortify Preset is loaded on mission start"],
  75. "ACEX Fortify",
  76. false,
  77. 1, // isGlobal
  78. macro_grp_fnc_name(fortify,registerPreset)
  79. ] call CBA_settings_fnc_init;