From 48cba357f651ec05e0e897101f78b2d573a982d5 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Mon, 9 Oct 2023 17:50:08 -0400 Subject: [PATCH 01/15] attach to selection --- .../attached_objects/functions/fnc_attach.sqf | 45 ++++++++++++++++--- .../functions/fnc_attachToSelection.sqf | 45 +++++++++++++++++++ .../functions/fnc_handleObjectEdited.sqf | 8 +++- .../functions/script_component.hpp | 2 + 4 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 addons/attached_objects/functions/fnc_attachToSelection.sqf diff --git a/addons/attached_objects/functions/fnc_attach.sqf b/addons/attached_objects/functions/fnc_attach.sqf index c80a2227a..81bbf15a1 100644 --- a/addons/attached_objects/functions/fnc_attach.sqf +++ b/addons/attached_objects/functions/fnc_attach.sqf @@ -32,12 +32,45 @@ _objects deleteAt _index; - { - _x attachTo [_entity]; + if (isNil QGVAR(modelSelections)) then { + GVAR(modelSelections) = createHashMap; + }; + + private _selections = GVAR(modelSelections) getOrDefaultCall [getText (configOf _entity >> "model"), { + [""] + (_entity selectionNames LOD_MEMORY select { + _entity selectionVectorDirAndUp [_x, LOD_MEMORY] isNotEqualTo [[0,0,0], [0,0,0]] + }) + }, true]; + + [LSTRING(AttachTo), [ + [ + "COMBO", + "Selection", + [_selections, _selections, _selections find _selection] + ], + [ + "TOOLBOX", + ["Orientation", "Selection: match selection orientation (i.e. along gun barrel). Relative: maintain current orientation relative to selection."], + [true, 1, 2, ["Selection", "Relative"]], + true + ] + ], { + params ["_values", "_args"]; + _values params ["_selection", "_isRelative"]; + _args params ["_objects", "_entity"]; + + { + if (_selection == "") then { + private _dirAndUp = [_entity vectorWorldToModel vectorDir _x, _entity vectorWorldToModel vectorUp _x]; + _x attachTo [_entity]; + [QEGVAR(common,setVectorDirAndUp), [_x, _dirAndUp], _x] call CBA_fnc_targetEvent; + } else { + systemChat str [_x, _entity, _selection, _isRelative]; + [_x, _entity, _selection, _isRelative] call FUNC(attachToSelection); + }; + } forEach _objects; - private _dirAndUp = [_entity vectorWorldToModel vectorDir _x, _entity vectorWorldToModel vectorUp _x]; - [QEGVAR(common,setVectorDirAndUp), [_x, _dirAndUp], _x] call CBA_fnc_targetEvent; - } forEach _objects; + [LSTRING(ObjectsAttached), count _objects] call EFUNC(common,showMessage); + }, {}, [_objects, _entity]] call EFUNC(dialog,create); - [LSTRING(ObjectsAttached), count _objects] call EFUNC(common,showMessage); }, [], LSTRING(AttachTo)] call EFUNC(common,selectPosition); diff --git a/addons/attached_objects/functions/fnc_attachToSelection.sqf b/addons/attached_objects/functions/fnc_attachToSelection.sqf new file mode 100644 index 000000000..a1bc9895c --- /dev/null +++ b/addons/attached_objects/functions/fnc_attachToSelection.sqf @@ -0,0 +1,45 @@ +#include "script_component.hpp" +/* + * Author: Ampersand + * Attaches the child object to a selection on a parent object. + * + * Arguments: + * 0: Child + * 1: Parent + * 2: Selection + * 3: Relative True to maintain current relative orientation, false to match selection orientation + * + * Return Value: + * None + * + * Example: + * [_child] call zen_attached_objects_fnc_attachToSelection + * + * Public: No + */ + +params ["_child", "_parent", "_selection", ["_isRelative", true]]; + +if (!isNull attachedTo _child) then {detach _child;}; + +private _childPos = _parent worldToModel ASLToAGL getPosWorldVisual _child; +private _childY = _parent vectorWorldToModelVisual vectorDirVisual _child; +private _childZ = _parent vectorWorldToModelVisual vectorUpVisual _child; +private _childX = _childY vectorCrossProduct _childZ; + +private _selectionPos = _parent selectionPosition [_selection, LOD_MEMORY]; +private _offset = _childPos vectorDiff _selectionPos; +_parent selectionVectorDirAndUp [_selection, LOD_MEMORY] params ["_selectionY", "_selectionZ"]; +private _selectionX = _selectionY vectorCrossProduct _selectionZ; + +private _m = matrixTranspose [_selectionX, _selectionY, _selectionZ]; +private _pos = flatten ([_offset] matrixMultiply _m); +_child attachTo [_parent, _pos, _selection, true]; + +_child setVariable [QGVAR(attachedToSelection), _selection, true]; + +if (_isRelative) then { + _m matrixMultiply [_childX, _childY, _childZ] params ["", "_vY", "_vZ"]; + _object setVectorDirAndUp _dirAndUp; + [QEGVAR(common,setVectorDirAndUp), [_child, [_vY, _vZ]], _child] call CBA_fnc_targetEvent; +}; diff --git a/addons/attached_objects/functions/fnc_handleObjectEdited.sqf b/addons/attached_objects/functions/fnc_handleObjectEdited.sqf index f7a6697b4..c157b5c3b 100644 --- a/addons/attached_objects/functions/fnc_handleObjectEdited.sqf +++ b/addons/attached_objects/functions/fnc_handleObjectEdited.sqf @@ -21,7 +21,11 @@ params ["", "_object"]; // Update the position of attached objects relative to their parent object private _parentObject = attachedTo _object; -if (!isNull _parentObject && {isVehicleCargo _object != _parentObject}) then { +if (isNull _parentObject || {isVehicleCargo _object == _parentObject}) exitWith {}; + +private _selection = _object getVariable [QGVAR(attachedToSelection), ""]; + +if (_selection == "") then { private _offset = _parentObject worldToModel ASLtoAGL getPosWorld _object; private _dirAndUp = [vectorDir _object, vectorUp _object] apply {_parentObject vectorWorldToModel _x}; @@ -31,4 +35,6 @@ if (!isNull _parentObject && {isVehicleCargo _object != _parentObject}) then { _object attachTo [_parentObject, _offset]; [QEGVAR(common,setVectorDirAndUp), [_object, _dirAndUp], _object] call CBA_fnc_targetEvent; +} else { + [_object, _parentObject, _selection, true] call FUNC(attachToSelection); }; diff --git a/addons/attached_objects/functions/script_component.hpp b/addons/attached_objects/functions/script_component.hpp index 24f0d1da1..31cca736a 100644 --- a/addons/attached_objects/functions/script_component.hpp +++ b/addons/attached_objects/functions/script_component.hpp @@ -1 +1,3 @@ #include "\x\zen\addons\attached_objects\script_component.hpp" + +#define LOD_MEMORY 1e15 From 4ca8c4a47a458fc2d37bfac8f2dbe344a2888c6d Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Mon, 9 Oct 2023 17:50:19 -0400 Subject: [PATCH 02/15] Update XEH_PREP.hpp --- addons/attached_objects/XEH_PREP.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/attached_objects/XEH_PREP.hpp b/addons/attached_objects/XEH_PREP.hpp index 4e7ef7ea5..876dec563 100644 --- a/addons/attached_objects/XEH_PREP.hpp +++ b/addons/attached_objects/XEH_PREP.hpp @@ -1,4 +1,5 @@ PREP(attach); +PREP(attachToSelection); PREP(detach); PREP(handleObjectEdited); PREP(module); From 0f764aaa2a4705e436c4779333eea2b8140da4c6 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Mon, 9 Oct 2023 23:29:05 -0400 Subject: [PATCH 03/15] fix orientation --- addons/attached_objects/functions/fnc_attachToSelection.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/attached_objects/functions/fnc_attachToSelection.sqf b/addons/attached_objects/functions/fnc_attachToSelection.sqf index a1bc9895c..df4f0172e 100644 --- a/addons/attached_objects/functions/fnc_attachToSelection.sqf +++ b/addons/attached_objects/functions/fnc_attachToSelection.sqf @@ -39,7 +39,7 @@ _child attachTo [_parent, _pos, _selection, true]; _child setVariable [QGVAR(attachedToSelection), _selection, true]; if (_isRelative) then { - _m matrixMultiply [_childX, _childY, _childZ] params ["", "_vY", "_vZ"]; - _object setVectorDirAndUp _dirAndUp; + [_childX, _childY, _childZ] matrixMultiply _m params ["", "_vY", "_vZ"]; + _child setVectorDirAndUp [_vY, _vZ]; [QEGVAR(common,setVectorDirAndUp), [_child, [_vY, _vZ]], _child] call CBA_fnc_targetEvent; }; From b2a72496d3b1892571724c377ab42a138e21ecb1 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Mon, 9 Oct 2023 23:33:00 -0400 Subject: [PATCH 04/15] remove chat --- addons/attached_objects/functions/fnc_attach.sqf | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/attached_objects/functions/fnc_attach.sqf b/addons/attached_objects/functions/fnc_attach.sqf index 81bbf15a1..d8538a5a0 100644 --- a/addons/attached_objects/functions/fnc_attach.sqf +++ b/addons/attached_objects/functions/fnc_attach.sqf @@ -65,7 +65,6 @@ _x attachTo [_entity]; [QEGVAR(common,setVectorDirAndUp), [_x, _dirAndUp], _x] call CBA_fnc_targetEvent; } else { - systemChat str [_x, _entity, _selection, _isRelative]; [_x, _entity, _selection, _isRelative] call FUNC(attachToSelection); }; } forEach _objects; From 04da2c155340c18f3dd57622a4e365258f8932b2 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Tue, 10 Oct 2023 17:02:44 -0400 Subject: [PATCH 05/15] separate keybind from regular attach --- addons/attached_objects/XEH_PREP.hpp | 1 + .../attached_objects/functions/fnc_attach.sqf | 44 ++--------- .../functions/fnc_attachBone.sqf | 76 +++++++++++++++++++ addons/attached_objects/initKeybinds.sqf | 7 ++ addons/attached_objects/stringtable.xml | 6 ++ 5 files changed, 96 insertions(+), 38 deletions(-) create mode 100644 addons/attached_objects/functions/fnc_attachBone.sqf diff --git a/addons/attached_objects/XEH_PREP.hpp b/addons/attached_objects/XEH_PREP.hpp index 876dec563..5ffaa9674 100644 --- a/addons/attached_objects/XEH_PREP.hpp +++ b/addons/attached_objects/XEH_PREP.hpp @@ -1,4 +1,5 @@ PREP(attach); +PREP(attachBone); PREP(attachToSelection); PREP(detach); PREP(handleObjectEdited); diff --git a/addons/attached_objects/functions/fnc_attach.sqf b/addons/attached_objects/functions/fnc_attach.sqf index d8538a5a0..c80a2227a 100644 --- a/addons/attached_objects/functions/fnc_attach.sqf +++ b/addons/attached_objects/functions/fnc_attach.sqf @@ -32,44 +32,12 @@ _objects deleteAt _index; - if (isNil QGVAR(modelSelections)) then { - GVAR(modelSelections) = createHashMap; - }; - - private _selections = GVAR(modelSelections) getOrDefaultCall [getText (configOf _entity >> "model"), { - [""] + (_entity selectionNames LOD_MEMORY select { - _entity selectionVectorDirAndUp [_x, LOD_MEMORY] isNotEqualTo [[0,0,0], [0,0,0]] - }) - }, true]; - - [LSTRING(AttachTo), [ - [ - "COMBO", - "Selection", - [_selections, _selections, _selections find _selection] - ], - [ - "TOOLBOX", - ["Orientation", "Selection: match selection orientation (i.e. along gun barrel). Relative: maintain current orientation relative to selection."], - [true, 1, 2, ["Selection", "Relative"]], - true - ] - ], { - params ["_values", "_args"]; - _values params ["_selection", "_isRelative"]; - _args params ["_objects", "_entity"]; - - { - if (_selection == "") then { - private _dirAndUp = [_entity vectorWorldToModel vectorDir _x, _entity vectorWorldToModel vectorUp _x]; - _x attachTo [_entity]; - [QEGVAR(common,setVectorDirAndUp), [_x, _dirAndUp], _x] call CBA_fnc_targetEvent; - } else { - [_x, _entity, _selection, _isRelative] call FUNC(attachToSelection); - }; - } forEach _objects; + { + _x attachTo [_entity]; - [LSTRING(ObjectsAttached), count _objects] call EFUNC(common,showMessage); - }, {}, [_objects, _entity]] call EFUNC(dialog,create); + private _dirAndUp = [_entity vectorWorldToModel vectorDir _x, _entity vectorWorldToModel vectorUp _x]; + [QEGVAR(common,setVectorDirAndUp), [_x, _dirAndUp], _x] call CBA_fnc_targetEvent; + } forEach _objects; + [LSTRING(ObjectsAttached), count _objects] call EFUNC(common,showMessage); }, [], LSTRING(AttachTo)] call EFUNC(common,selectPosition); diff --git a/addons/attached_objects/functions/fnc_attachBone.sqf b/addons/attached_objects/functions/fnc_attachBone.sqf new file mode 100644 index 000000000..4fa2f5e44 --- /dev/null +++ b/addons/attached_objects/functions/fnc_attachBone.sqf @@ -0,0 +1,76 @@ +#include "script_component.hpp" +/* + * Author: Ampersand + * Attaches the given objects to a parent object selected by Zeus. + * + * Arguments: + * 0: Objects + * 1: Is Bone + * + * Return Value: + * None + * + * Example: + * [_object] call zen_attached_objects_fnc_attachBone + * + * Public: No + */ + +[_this, { + params ["_successful", "_objects"]; + + if (!_successful) exitWith {}; + + curatorMouseOver params ["_type", "_entity"]; + if (_type != "OBJECT") exitWith {}; + + // Prevent attaching object to itself + private _index = _objects find _entity; + + if (_index != -1 && {count _objects == 1}) exitWith { + [LSTRING(CannotAttachToSelf)] call EFUNC(common,showMessage); + }; + + _objects deleteAt _index; + + if (isNil QGVAR(modelSelections)) then { + GVAR(modelSelections) = createHashMap; + }; + + private _selections = GVAR(modelSelections) getOrDefaultCall [getText (configOf _entity >> "model"), { + [""] + (_entity selectionNames LOD_MEMORY select { + _entity selectionVectorDirAndUp [_x, LOD_MEMORY] isNotEqualTo [[0,0,0], [0,0,0]] + }) + }, true]; + + [LSTRING(AttachTo), [ + [ + "COMBO", + "Selection", + [_selections, _selections, _selections find _selection] + ], + [ + "TOOLBOX", + ["Orientation", "Selection: match selection orientation (i.e. along gun barrel). Relative: maintain current orientation relative to selection."], + [true, 1, 2, ["Selection", "Relative"]], + true + ] + ], { + params ["_values", "_args"]; + _values params ["_selection", "_isRelative"]; + _args params ["_objects", "_entity"]; + + { + if (_selection == "") then { + private _dirAndUp = [_entity vectorWorldToModel vectorDir _x, _entity vectorWorldToModel vectorUp _x]; + _x attachTo [_entity]; + [QEGVAR(common,setVectorDirAndUp), [_x, _dirAndUp], _x] call CBA_fnc_targetEvent; + } else { + [_x, _entity, _selection, _isRelative] call FUNC(attachToSelection); + }; + } forEach _objects; + + [LSTRING(ObjectsAttached), count _objects] call EFUNC(common,showMessage); + }, {}, [_objects, _entity]] call EFUNC(dialog,create); + +}, [], LSTRING(AttachTo)] call EFUNC(common,selectPosition); diff --git a/addons/attached_objects/initKeybinds.sqf b/addons/attached_objects/initKeybinds.sqf index abadcb817..9c72d89a8 100644 --- a/addons/attached_objects/initKeybinds.sqf +++ b/addons/attached_objects/initKeybinds.sqf @@ -5,6 +5,13 @@ }; }, {}, [DIK_A, [true, true, false]]] call CBA_fnc_addKeybind; // Default: CTRL + SHIFT + A +[[ELSTRING(main,DisplayName), LSTRING(DisplayName)], QGVAR(attachBone), [LSTRING(AttachBone), LSTRING(AttachBone_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + SELECTED_OBJECTS call FUNC(attachBone); + true // handled + }; +}, {}, [DIK_A, [true, false, true]]] call CBA_fnc_addKeybind; // Default: ALT + SHIFT + A + [[ELSTRING(main,DisplayName), LSTRING(DisplayName)], QGVAR(detach), [LSTRING(Detach), LSTRING(Detach_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { SELECTED_OBJECTS call FUNC(detach); diff --git a/addons/attached_objects/stringtable.xml b/addons/attached_objects/stringtable.xml index a5b116256..09c9c6167 100644 --- a/addons/attached_objects/stringtable.xml +++ b/addons/attached_objects/stringtable.xml @@ -10,6 +10,12 @@ Attaches all selected objects to the specified parent object. + + Attach Objects to Bone + + + Attaches all selected objects to a bone on the specified parent object. + Detach Objects From 06f0b2f18bcc92d269d854402025193414594a71 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Tue, 10 Oct 2023 17:26:52 -0400 Subject: [PATCH 06/15] unbound by default alt + shift is move very fast in zeus --- addons/attached_objects/initKeybinds.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/attached_objects/initKeybinds.sqf b/addons/attached_objects/initKeybinds.sqf index 9c72d89a8..e329c6046 100644 --- a/addons/attached_objects/initKeybinds.sqf +++ b/addons/attached_objects/initKeybinds.sqf @@ -10,7 +10,7 @@ SELECTED_OBJECTS call FUNC(attachBone); true // handled }; -}, {}, [DIK_A, [true, false, true]]] call CBA_fnc_addKeybind; // Default: ALT + SHIFT + A +}, {}, []] call CBA_fnc_addKeybind; // Default: Unbound [[ELSTRING(main,DisplayName), LSTRING(DisplayName)], QGVAR(detach), [LSTRING(Detach), LSTRING(Detach_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { From 30f62b15f1bbc6946c49600017815d44636423b3 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Tue, 10 Oct 2023 17:27:06 -0400 Subject: [PATCH 07/15] add hint to show bone --- addons/attached_objects/functions/fnc_attachBone.sqf | 9 ++++++++- .../attached_objects/functions/fnc_attachToSelection.sqf | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/attached_objects/functions/fnc_attachBone.sqf b/addons/attached_objects/functions/fnc_attachBone.sqf index 4fa2f5e44..84c5abc2f 100644 --- a/addons/attached_objects/functions/fnc_attachBone.sqf +++ b/addons/attached_objects/functions/fnc_attachBone.sqf @@ -68,7 +68,14 @@ } else { [_x, _entity, _selection, _isRelative] call FUNC(attachToSelection); }; - } forEach _objects; + } forEach _objects params ["_selectionPos", "_selectionY", "_selectionZ"]; + + private _hintPos = _entity modelToWorldVisual _selectionPos; + [[ + ["ICON", [_hintPos, "\a3\ui_f\data\IGUI\Cfg\Targeting\LaserTarget_ca.paa"]], + ["LINE", [_hintPos, _entity vectorModelToWorldVisual _selectionY vectorMultiply 2 vectorAdd _hintPos, [0, 1, 0, 1]]], + ["LINE", [_hintPos, _entity vectorModelToWorldVisual _selectionZ vectorAdd _hintPos, [0, 0, 1, 1]]] + ], 3, _entity] call EFUNC(common,drawHint); [LSTRING(ObjectsAttached), count _objects] call EFUNC(common,showMessage); }, {}, [_objects, _entity]] call EFUNC(dialog,create); diff --git a/addons/attached_objects/functions/fnc_attachToSelection.sqf b/addons/attached_objects/functions/fnc_attachToSelection.sqf index df4f0172e..5d4d42569 100644 --- a/addons/attached_objects/functions/fnc_attachToSelection.sqf +++ b/addons/attached_objects/functions/fnc_attachToSelection.sqf @@ -10,7 +10,7 @@ * 3: Relative True to maintain current relative orientation, false to match selection orientation * * Return Value: - * None + * 0: Selection Position and Orientation For drawing hints * * Example: * [_child] call zen_attached_objects_fnc_attachToSelection @@ -43,3 +43,5 @@ if (_isRelative) then { _child setVectorDirAndUp [_vY, _vZ]; [QEGVAR(common,setVectorDirAndUp), [_child, [_vY, _vZ]], _child] call CBA_fnc_targetEvent; }; + +[_selectionPos, _selectionY, _selectionZ] From 344cc003c8e56cb89dd5268ba0184369b2e4a3a7 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Tue, 10 Oct 2023 19:39:42 -0400 Subject: [PATCH 08/15] fix hint --- addons/attached_objects/functions/fnc_attachBone.sqf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/attached_objects/functions/fnc_attachBone.sqf b/addons/attached_objects/functions/fnc_attachBone.sqf index 84c5abc2f..89ecdf20a 100644 --- a/addons/attached_objects/functions/fnc_attachBone.sqf +++ b/addons/attached_objects/functions/fnc_attachBone.sqf @@ -68,9 +68,10 @@ } else { [_x, _entity, _selection, _isRelative] call FUNC(attachToSelection); }; - } forEach _objects params ["_selectionPos", "_selectionY", "_selectionZ"]; + } forEach _objects; - private _hintPos = _entity modelToWorldVisual _selectionPos; + private _hintPos = _entity modelToWorldVisual (_entity selectionPosition [_selection, LOD_MEMORY]); + _entity selectionVectorDirAndUp [_selection, LOD_MEMORY] params ["_selectionY", "_selectionZ"]; [[ ["ICON", [_hintPos, "\a3\ui_f\data\IGUI\Cfg\Targeting\LaserTarget_ca.paa"]], ["LINE", [_hintPos, _entity vectorModelToWorldVisual _selectionY vectorMultiply 2 vectorAdd _hintPos, [0, 1, 0, 1]]], From a1d3005eaf5ed29e76577e526064588df7805ab5 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Tue, 10 Oct 2023 19:47:11 -0400 Subject: [PATCH 09/15] check _selection first, instead of forEach _objects --- .../functions/fnc_attachBone.sqf | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/addons/attached_objects/functions/fnc_attachBone.sqf b/addons/attached_objects/functions/fnc_attachBone.sqf index 89ecdf20a..9bed8def4 100644 --- a/addons/attached_objects/functions/fnc_attachBone.sqf +++ b/addons/attached_objects/functions/fnc_attachBone.sqf @@ -60,23 +60,25 @@ _values params ["_selection", "_isRelative"]; _args params ["_objects", "_entity"]; - { - if (_selection == "") then { + if (_selection isEqualTo "") then { + { private _dirAndUp = [_entity vectorWorldToModel vectorDir _x, _entity vectorWorldToModel vectorUp _x]; _x attachTo [_entity]; [QEGVAR(common,setVectorDirAndUp), [_x, _dirAndUp], _x] call CBA_fnc_targetEvent; - } else { + } forEach _objects; + } else { + { [_x, _entity, _selection, _isRelative] call FUNC(attachToSelection); - }; - } forEach _objects; + } forEach _objects; - private _hintPos = _entity modelToWorldVisual (_entity selectionPosition [_selection, LOD_MEMORY]); - _entity selectionVectorDirAndUp [_selection, LOD_MEMORY] params ["_selectionY", "_selectionZ"]; - [[ - ["ICON", [_hintPos, "\a3\ui_f\data\IGUI\Cfg\Targeting\LaserTarget_ca.paa"]], - ["LINE", [_hintPos, _entity vectorModelToWorldVisual _selectionY vectorMultiply 2 vectorAdd _hintPos, [0, 1, 0, 1]]], - ["LINE", [_hintPos, _entity vectorModelToWorldVisual _selectionZ vectorAdd _hintPos, [0, 0, 1, 1]]] - ], 3, _entity] call EFUNC(common,drawHint); + private _hintPos = _entity modelToWorldVisual (_entity selectionPosition [_selection, LOD_MEMORY]); + _entity selectionVectorDirAndUp [_selection, LOD_MEMORY] params ["_selectionY", "_selectionZ"]; + [[ + ["ICON", [_hintPos, "\a3\ui_f\data\IGUI\Cfg\Targeting\LaserTarget_ca.paa"]], + ["LINE", [_hintPos, _entity vectorModelToWorldVisual _selectionY vectorMultiply 2 vectorAdd _hintPos, [0, 1, 0, 1]]], + ["LINE", [_hintPos, _entity vectorModelToWorldVisual _selectionZ vectorAdd _hintPos, [0, 0, 1, 1]]] + ], 3, _entity] call EFUNC(common,drawHint); + }; [LSTRING(ObjectsAttached), count _objects] call EFUNC(common,showMessage); }, {}, [_objects, _entity]] call EFUNC(dialog,create); From d1ff2c80e8cd3206f421d3185479f79455d54a63 Mon Sep 17 00:00:00 2001 From: Ampersand Date: Wed, 11 Oct 2023 09:21:31 -0400 Subject: [PATCH 10/15] Update addons/attached_objects/functions/fnc_attachBone.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- addons/attached_objects/functions/fnc_attachBone.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/attached_objects/functions/fnc_attachBone.sqf b/addons/attached_objects/functions/fnc_attachBone.sqf index 9bed8def4..fe7c7d082 100644 --- a/addons/attached_objects/functions/fnc_attachBone.sqf +++ b/addons/attached_objects/functions/fnc_attachBone.sqf @@ -22,7 +22,7 @@ if (!_successful) exitWith {}; curatorMouseOver params ["_type", "_entity"]; - if (_type != "OBJECT") exitWith {}; + if (_type isEqualTo "OBJECT") exitWith {}; // Prevent attaching object to itself private _index = _objects find _entity; From 74fb4a12e27e2811c5fe9143a0823db207df3fdd Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Wed, 11 Oct 2023 12:14:21 -0400 Subject: [PATCH 11/15] isNotEqualTo --- addons/attached_objects/functions/fnc_attachBone.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/attached_objects/functions/fnc_attachBone.sqf b/addons/attached_objects/functions/fnc_attachBone.sqf index fe7c7d082..2b0e89b45 100644 --- a/addons/attached_objects/functions/fnc_attachBone.sqf +++ b/addons/attached_objects/functions/fnc_attachBone.sqf @@ -22,7 +22,7 @@ if (!_successful) exitWith {}; curatorMouseOver params ["_type", "_entity"]; - if (_type isEqualTo "OBJECT") exitWith {}; + if (_type isNotEqualTo "OBJECT") exitWith {}; // Prevent attaching object to itself private _index = _objects find _entity; From b4d68949da08e9dbdff7b0b982f708f6b5d1717b Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Wed, 11 Oct 2023 12:14:30 -0400 Subject: [PATCH 12/15] stringtable --- addons/attached_objects/functions/fnc_attachBone.sqf | 6 +++--- addons/attached_objects/stringtable.xml | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/addons/attached_objects/functions/fnc_attachBone.sqf b/addons/attached_objects/functions/fnc_attachBone.sqf index 2b0e89b45..828e4d4df 100644 --- a/addons/attached_objects/functions/fnc_attachBone.sqf +++ b/addons/attached_objects/functions/fnc_attachBone.sqf @@ -46,13 +46,13 @@ [LSTRING(AttachTo), [ [ "COMBO", - "Selection", + LSTRING(Bone), [_selections, _selections, _selections find _selection] ], [ "TOOLBOX", - ["Orientation", "Selection: match selection orientation (i.e. along gun barrel). Relative: maintain current orientation relative to selection."], - [true, 1, 2, ["Selection", "Relative"]], + [LSTRING(Orientation), LSTRING(Orientation_Description)], + [true, 1, 2, [LSTRING(Bone), LSTRING(Relative)]], true ] ], { diff --git a/addons/attached_objects/stringtable.xml b/addons/attached_objects/stringtable.xml index 09c9c6167..d4d0ade3b 100644 --- a/addons/attached_objects/stringtable.xml +++ b/addons/attached_objects/stringtable.xml @@ -10,12 +10,24 @@ Attaches all selected objects to the specified parent object. + + Bone + + + Relative + Attach Objects to Bone Attaches all selected objects to a bone on the specified parent object. + + Orientation + + + Bone: match bone orientation (i.e. along gun barrel). Relative: maintain current orientation relative to bone. + Detach Objects From 9dfd0aa02a2b55e00eae46ea7b6b912cb55431b9 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Wed, 11 Oct 2023 12:14:52 -0400 Subject: [PATCH 13/15] improve Rotate module handling of attached objects --- addons/modules/XEH_postInit.sqf | 7 +------ addons/modules/functions/fnc_moduleRotateObject.sqf | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/addons/modules/XEH_postInit.sqf b/addons/modules/XEH_postInit.sqf index 679f88cf6..8f55d4f32 100644 --- a/addons/modules/XEH_postInit.sqf +++ b/addons/modules/XEH_postInit.sqf @@ -115,12 +115,7 @@ if (isServer) then { }, _this] call CBA_fnc_execNextFrame; }] call CBA_fnc_addEventHandler; -[QGVAR(setRotation), { - params ["_object", "_pitch", "_roll", "_yaw"]; - - _object setDir _yaw; - [_object, _pitch, _roll] call BIS_fnc_setPitchBank; -}] call CBA_fnc_addEventHandler; +[QGVAR(setRotation), BIS_fnc_setObjectRotation] call CBA_fnc_addEventHandler; [QGVAR(moveToGunner), { params ["_unit", "_vehicle"]; diff --git a/addons/modules/functions/fnc_moduleRotateObject.sqf b/addons/modules/functions/fnc_moduleRotateObject.sqf index 04e2be298..2c3f4384f 100644 --- a/addons/modules/functions/fnc_moduleRotateObject.sqf +++ b/addons/modules/functions/fnc_moduleRotateObject.sqf @@ -35,5 +35,5 @@ private _yaw = [getDir _object] call CBA_fnc_simplifyAngle180; params ["_values", "_object"]; _values params ["_pitch", "_roll", "_yaw"]; - [QGVAR(setRotation), [_object, _pitch, _roll, _yaw], _object] call CBA_fnc_targetEvent; + [QGVAR(setRotation), [_object, [_yaw, _pitch, _roll]], _object] call CBA_fnc_targetEvent; }, {}, _object] call EFUNC(dialog,create); From f62101a7f24a7bf572017861a8102105eaa2d828 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Fri, 17 Nov 2023 16:39:50 -0500 Subject: [PATCH 14/15] module use dialog --- addons/attached_objects/functions/fnc_module.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/attached_objects/functions/fnc_module.sqf b/addons/attached_objects/functions/fnc_module.sqf index b8a4d971d..f081b6a05 100644 --- a/addons/attached_objects/functions/fnc_module.sqf +++ b/addons/attached_objects/functions/fnc_module.sqf @@ -26,7 +26,7 @@ if (isNull _object) exitWith { // Start attaching if not already attached, otherwise detach if (isNull attachedTo _object) then { - [_object] call FUNC(attach); + [_object] call FUNC(attachBone); } else { [_object] call FUNC(detach); }; From 4a533bf703b7a48015b7411216165101bbf84f97 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Fri, 17 Nov 2023 16:40:08 -0500 Subject: [PATCH 15/15] put turrets first and translate selections --- addons/attached_objects/XEH_PREP.hpp | 1 + .../functions/fnc_attachBone.sqf | 15 ++-- .../functions/fnc_parseSelectionName.sqf | 49 ++++++++++ addons/attached_objects/stringtable.xml | 90 +++++++++++++++++++ 4 files changed, 150 insertions(+), 5 deletions(-) create mode 100644 addons/attached_objects/functions/fnc_parseSelectionName.sqf diff --git a/addons/attached_objects/XEH_PREP.hpp b/addons/attached_objects/XEH_PREP.hpp index 5ffaa9674..f29deb750 100644 --- a/addons/attached_objects/XEH_PREP.hpp +++ b/addons/attached_objects/XEH_PREP.hpp @@ -3,4 +3,5 @@ PREP(attachBone); PREP(attachToSelection); PREP(detach); PREP(handleObjectEdited); +PREP(parseSelectionName); PREP(module); diff --git a/addons/attached_objects/functions/fnc_attachBone.sqf b/addons/attached_objects/functions/fnc_attachBone.sqf index 828e4d4df..062e323d5 100644 --- a/addons/attached_objects/functions/fnc_attachBone.sqf +++ b/addons/attached_objects/functions/fnc_attachBone.sqf @@ -37,17 +37,22 @@ GVAR(modelSelections) = createHashMap; }; - private _selections = GVAR(modelSelections) getOrDefaultCall [getText (configOf _entity >> "model"), { - [""] + (_entity selectionNames LOD_MEMORY select { - _entity selectionVectorDirAndUp [_x, LOD_MEMORY] isNotEqualTo [[0,0,0], [0,0,0]] - }) + private _entries = GVAR(modelSelections) getOrDefaultCall [getText (configOf _entity >> "model"), { + private _turretsCfg = allTurrets _entity apply {[_entity, _x] call CBA_fnc_getTurret}; + private _selections = _entity selectionNames LOD_MEMORY select { + _entity selectionVectorDirAndUp [_x, LOD_MEMORY] isNotEqualTo [[0,0,0], [0,0,0]] + }; + [ + [""] + (_turretsCfg apply {getText (_x >> "memoryPointGunnerOptics")}) + _selections, + [""] + (_turretsCfg apply {configName _x}) + _selections apply {[_x] call FUNC(parseSelectionName)} + ] }, true]; [LSTRING(AttachTo), [ [ "COMBO", LSTRING(Bone), - [_selections, _selections, _selections find _selection] + _entries ], [ "TOOLBOX", diff --git a/addons/attached_objects/functions/fnc_parseSelectionName.sqf b/addons/attached_objects/functions/fnc_parseSelectionName.sqf new file mode 100644 index 000000000..d9957be66 --- /dev/null +++ b/addons/attached_objects/functions/fnc_parseSelectionName.sqf @@ -0,0 +1,49 @@ +#include "script_component.hpp" +/* + * Author: Ampersand + * Attempt to translate Czech selection names. + * + * Arguments: + * 0: Selection Name + * + * Return Value: + * 0: Translated Name + * + * Example: + * [_selection] call zen_attached_objects_fnc_parseSelectionName + * + * Public: No + */ + +params ["_selection"]; + +{ + _selection = _selection regexReplace [_x, localize (LSTRING(Czech) + _x) + " "]; +} forEach [ + "hlavne", + "hlaven", + "kola", + "konec", + "leveho", + "leve", + "nabojnice", + "optika", + "osa", + "otoc", + "poklop", + "praveho", + "prave", + "predniho", + "raketa", + "slapek", + "slapky", + "smerovky", + "svetlo", + "vejskovky", + "velitele", + "veze", + "vez", + "vrtule" +]; + +(_selection splitString " _") joinString " " diff --git a/addons/attached_objects/stringtable.xml b/addons/attached_objects/stringtable.xml index d4d0ade3b..79285b137 100644 --- a/addons/attached_objects/stringtable.xml +++ b/addons/attached_objects/stringtable.xml @@ -65,5 +65,95 @@ 無法將物體附加到物體自己身上 Impossibile collegare l'oggetto a se stesso + + Barrel + + + Barrel + + + Wheel + + + End + + + Left + + + Left + + + Cartridge Case + + + Optics + + + Axis + + + Turn + + + Hatch + + + Right + + + Right + + + Nose + + + Pedals + + + Pedal + + + Rudder + + + Spike + + + Mark + + + Light + + + Elevator + + + Commander + + + Main + + + Turret + + + Turret + + + Rocket + + + Rotor + + + Muzzle + + + Aim Point + + + Rest +