From ab46d7c0c8aae3dc407d2430663fa9fc15c324e1 Mon Sep 17 00:00:00 2001 From: jaynus Date: Sun, 11 Jan 2015 10:33:44 -0800 Subject: [PATCH] attach post CBAify. StackedEventHandlers needs converting to cba_fnc_addPerFrameHandler. --- addons/Attach/config.cpp | 26 ++++++++++----------- addons/Attach/functions/fn_attach.sqf | 4 ++-- addons/Attach/functions/fn_canAttach.sqf | 2 +- addons/Attach/functions/fn_canDetach.sqf | 2 +- addons/Attach/functions/fn_detach.sqf | 10 ++++---- addons/Attach/functions/fn_openAttachUI.sqf | 2 +- addons/attach/$PBOPREFIX$ | 1 + addons/attach/script_component.hpp | 12 ++++++++++ 8 files changed, 36 insertions(+), 23 deletions(-) create mode 100644 addons/attach/$PBOPREFIX$ create mode 100644 addons/attach/script_component.hpp diff --git a/addons/Attach/config.cpp b/addons/Attach/config.cpp index 8902471b70..7d13b8e3ef 100644 --- a/addons/Attach/config.cpp +++ b/addons/Attach/config.cpp @@ -1,5 +1,5 @@ class CfgPatches { - class AGM_Attach { + class ADDON { units[] = {}; weapons[] = {"AGM_IR_Strobe_Item"}; requiredVersion = 0.60; @@ -13,9 +13,9 @@ class CfgPatches { }; class CfgFunctions { - class AGM_Attach { - class AGM_Attach { - file = "AGM_Attach\functions"; + class ADDON { + class ADDON { + file = PATHTOF(functions); class attach; class canAttach; class canDetach; @@ -35,24 +35,24 @@ class CfgVehicles { class CAManBase: Man { class AGM_SelfActions { class AGM_Equipment { - class AGM_Attach { + class ADDON { displayName = "$STR_AGM_Attach_AttachDetach"; - condition = "[_player, ''] call AGM_Attach_fnc_canAttach"; - statement = "[_player] call AGM_Attach_fnc_openAttachUI;"; + condition = QUOTE( [_player, ''] call FUNC(canAttach) ); + statement = QUOTE( [_player] call FUNC(openAttachUI); ); exceptions[] = {"AGM_Drag_isNotDragging"}; showDisabled = 0; priority = 5; - icon = "\AGM_Attach\UI\attach_ca.paa"; + icon = PATHTOF(UI\attach_ca.paa); hotkey = "T"; }; - class AGM_Attach_Detach { + class GVAR(Detach) { displayName = "$STR_AGM_Attach_Detach"; - condition = "[_player] call AGM_Attach_fnc_canDetach"; - statement = "[_player] call AGM_Attach_fnc_detach"; + condition = QUOTE( [_player] call FUNC(canDetach ); + statement = QUOTE( [_player] call FUNC(detach) ); exceptions[] = {"AGM_Drag_isNotDragging"}; showDisabled = 0; priority = 5; - icon = "\AGM_Attach\UI\detach_ca.paa"; + icon = PATHTOF(UI\detach_ca.paa); hotkey = "T"; }; }; @@ -138,7 +138,7 @@ class CfgWeapons { displayName = "$STR_AGM_IrStrobe_Name"; descriptionShort = "$STR_AGM_IrStrobe_Description"; model = "\A3\weapons_F\ammo\mag_univ.p3d"; - picture = "\AGM_Attach\UI\irstrobe_item.paa"; + picture = PATHTOF(UI\irstrobe_item.paa); scope = 2; AGM_attachable = 1; class ItemInfo: InventoryItem_Base_F { diff --git a/addons/Attach/functions/fn_attach.sqf b/addons/Attach/functions/fn_attach.sqf index c82e4a2d2c..18c1af6fd3 100644 --- a/addons/Attach/functions/fn_attach.sqf +++ b/addons/Attach/functions/fn_attach.sqf @@ -17,7 +17,7 @@ _unit = _this select 0; _itemName = _this select 1; // Check if unit has an attached item -if (_unit getVariable ["AGM_AttachedItemName", ""] != "") exitWith {}; +if (_unit getVariable [QGVAR(ItemName), ""] != "") exitWith {}; // Check if the unit still has the item if !((_itemName in items _unit) or (_itemName in magazines _unit)) exitWith {}; @@ -56,5 +56,5 @@ switch true do { // Remove item _unit removeItem _itemName; -_unit setVariable ["AGM_AttachedItemName", _itemName, true]; +_unit setVariable [QGVAR(ItemName), _itemName, true]; _unit setVariable ["AGM_AttachedItem", _attachedItem, true]; diff --git a/addons/Attach/functions/fn_canAttach.sqf b/addons/Attach/functions/fn_canAttach.sqf index 0401f9d21f..93aa3dd3d8 100644 --- a/addons/Attach/functions/fn_canAttach.sqf +++ b/addons/Attach/functions/fn_canAttach.sqf @@ -16,4 +16,4 @@ private ["_unit", "_item"]; _unit = _this select 0; _item = _this select 1; -canStand _unit && {_unit getVariable ["AGM_AttachedItemName", ""] == ""} && {_item in (magazines _unit + items _unit + [""])} +canStand _unit && {_unit getVariable [QGVAR(ItemName), ""] == ""} && {_item in (magazines _unit + items _unit + [""])} diff --git a/addons/Attach/functions/fn_canDetach.sqf b/addons/Attach/functions/fn_canDetach.sqf index fcda3cbdd3..fd093c329e 100644 --- a/addons/Attach/functions/fn_canDetach.sqf +++ b/addons/Attach/functions/fn_canDetach.sqf @@ -14,4 +14,4 @@ private "_unit"; _unit = _this select 0; -canStand _unit && {_unit getVariable ["AGM_AttachedItemName", ""] != ""} +canStand _unit && {_unit getVariable [QGVAR(ItemName), ""] != ""} diff --git a/addons/Attach/functions/fn_detach.sqf b/addons/Attach/functions/fn_detach.sqf index f84bb163cd..ad934e51ab 100644 --- a/addons/Attach/functions/fn_detach.sqf +++ b/addons/Attach/functions/fn_detach.sqf @@ -13,7 +13,7 @@ none private ["_unit", "_itemName", "_count", "_attachedItem"]; _unit = _this select 0; -_itemName = _unit getVariable ["AGM_AttachedItemName", ""]; +_itemName = _unit getVariable [QGVAR(ItemName), ""]; // Check if unit has an attached item if (_itemName == "") exitWith {}; @@ -27,7 +27,7 @@ if ((count items _unit) + (count magazines _unit) <= _count) exitWith { if (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") then { // Hack for dealing with X_IR_Grenade effect not dissapearing on deleteVehicle - [_unit getVariable "AGM_AttachedItem", _unit] spawn { + [_unit getVariable QGVAR(Item), _unit] spawn { _attachedItem = _this select 0; _unit = _this select 1; detach _attachedItem; @@ -39,12 +39,12 @@ if (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == " else { // Delete attached item - deleteVehicle (_unit getVariable "AGM_AttachedItem"); + deleteVehicle (_unit getVariable QGVAR(Item)); }; // Reset unit variables -_unit setVariable ["AGM_AttachedItemName","", true]; -_unit setVariable ["AGM_AttachedItem",nil, true]; +_unit setVariable [QGVAR(ItemName),"", true]; +_unit setVariable [QGVAR(Item),nil, true]; // Display message switch true do { diff --git a/addons/Attach/functions/fn_openAttachUI.sqf b/addons/Attach/functions/fn_openAttachUI.sqf index 2a1f0cf784..dac3785227 100644 --- a/addons/Attach/functions/fn_openAttachUI.sqf +++ b/addons/Attach/functions/fn_openAttachUI.sqf @@ -53,7 +53,7 @@ _attachables = items _unit; [ _actions, { - [AGM_player, _this] call AGM_Attach_fnc_attach; + [AGM_player, _this] call FUNC(attach); call AGM_Interaction_fnc_hideMenu; }, { diff --git a/addons/attach/$PBOPREFIX$ b/addons/attach/$PBOPREFIX$ new file mode 100644 index 0000000000..1e4e48a4ca --- /dev/null +++ b/addons/attach/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\Addons\laser \ No newline at end of file diff --git a/addons/attach/script_component.hpp b/addons/attach/script_component.hpp new file mode 100644 index 0000000000..f4b58802e3 --- /dev/null +++ b/addons/attach/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT attach +#include "\z\ace\Addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_ATTACH + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_ATTACH + #define DEBUG_SETTINGS DEBUG_SETTINGS_ATTACH +#endif + +#include "\z\ace\Addons\main\script_macros.hpp" \ No newline at end of file