fortify_tool.sqf 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. // Add custom composition
  46. [west, 5000, [
  47. ["Land_BagFence_Long_F", 5],
  48. ["Land_BagBunker_Small_F", 50],
  49. [macro_quote(macro_new_vehicle(bacta,healing)), 0],
  50. [macro_quote(macro_new_vehicle(laat,Mk1_lights)), 0]
  51. ]] call acex_fortify_fnc_registerObjects;
  52. // Add Settings to switch on/off
  53. private _item_name = (configFile >> "CfgWeapons" >> AMMOITEM >> "displayName") call BIS_fnc_getCfgData;
  54. [
  55. "RD501_Fortify_useAmmo",
  56. "CHECKBOX",
  57. ["Use item as Ammo", format["Additionally to Money, require 1 %1 to use the Fortify Tool",_item_name]],
  58. "ACEX Fortify",
  59. false
  60. ] call CBA_settings_fnc_init;