fortify_tool.sqf 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 Settings to switch on/off
  46. private _item_name = (configFile >> "CfgWeapons" >> AMMOITEM >> "displayName") call BIS_fnc_getCfgData;
  47. [
  48. "RD501_Fortify_useAmmo",
  49. "CHECKBOX",
  50. ["Use item as Ammo", format["Additionally to Money, require 1 %1 to use the Fortify Tool",_item_name]],
  51. "ACEX Fortify",
  52. false
  53. ] call CBA_settings_fnc_init;