From c5b78ef7d188f4dd2ca0c06eada5291c65aa6eca Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Sat, 3 Apr 2021 12:49:33 +0200 Subject: [PATCH 1/3] Added ace_attach attached/detach events --- addons/attach/functions/fnc_attach.sqf | 1 + addons/attach/functions/fnc_detach.sqf | 2 ++ addons/attach/functions/fnc_placeApprove.sqf | 3 ++- docs/wiki/framework/events-framework.md | 8 ++++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/attach/functions/fnc_attach.sqf b/addons/attach/functions/fnc_attach.sqf index 0a13ed9afb5..f26e39f222c 100644 --- a/addons/attach/functions/fnc_attach.sqf +++ b/addons/attach/functions/fnc_attach.sqf @@ -44,6 +44,7 @@ if (_unit == _attachToVehicle) then { //Self Attachment [_onAttachText, 2] call EFUNC(common,displayTextStructured); }; _unit setVariable [QGVAR(attached), [[_attachedItem, _itemClassname]], true]; + [QGVAR(attached), [_attachedItem, _itemClassname]] call CBA_fnc_localEvent; } else { GVAR(placeAction) = PLACE_WAITING; diff --git a/addons/attach/functions/fnc_detach.sqf b/addons/attach/functions/fnc_detach.sqf index 7c68831f36a..f4358371f64 100644 --- a/addons/attach/functions/fnc_detach.sqf +++ b/addons/attach/functions/fnc_detach.sqf @@ -50,6 +50,8 @@ if (!([_unit, _itemName] call CBA_fnc_canAddItem) && {!_isChemlight}) exitWith { [LELSTRING(common,Inventory_Full)] call EFUNC(common,displayTextStructured); }; +[QGVAR(detach), [_attachedObject, _itemName]] call CBA_fnc_localEvent; + // Add item to inventory (unless it's a chemlight) if (!_isChemlight) then { _unit addItem _itemName; diff --git a/addons/attach/functions/fnc_placeApprove.sqf b/addons/attach/functions/fnc_placeApprove.sqf index 2ae6f84b748..f0c051d1688 100644 --- a/addons/attach/functions/fnc_placeApprove.sqf +++ b/addons/attach/functions/fnc_placeApprove.sqf @@ -4,7 +4,7 @@ * Approves placement of the lightObject, scans for an appropriate location and attaches * A player can release the attachObject with it floating in mid-air. * This will use lineIntersectsSurfaces to scan towards the center of the vehicle to find a collision - * ArmA's collision detection is of couse terrible and often misses collisions (difference between what we see and collision LOD) + * Arma's collision detection is of couse terrible and often misses collisions (difference between what we see and collision LOD) * So it does multiple scans at slighly different angles * This is VERY computationaly intensive, but doesn't happen that often. * @@ -100,5 +100,6 @@ _unit removeItem _itemClassname; private _attachList = _attachToVehicle getVariable [QGVAR(attached), []]; _attachList pushBack [_attachedObject, _itemClassname]; _attachToVehicle setVariable [QGVAR(attached), _attachList, true]; +[QGVAR(attached), [_attachedObject, _itemClassname]] call CBA_fnc_localEvent; [_onAttachText, 2] call EFUNC(common,displayTextStructured); diff --git a/docs/wiki/framework/events-framework.md b/docs/wiki/framework/events-framework.md index d1cc6d01d09..d228afbd07f 100644 --- a/docs/wiki/framework/events-framework.md +++ b/docs/wiki/framework/events-framework.md @@ -106,6 +106,14 @@ MenuType: 0 = Interaction, 1 = Self Interaction |`ace_cookoff_cookOffBox` | _box | Global | Listen | Ammo box cook off has started |`ace_cookoff_engineFire` | _vehicle | Global | Listen | Engine fire has started + +### 2.11 Attach (`ace_attach`) + +| Event Key | Parameters | Locality | Type | Description | +|----------|---------|---------|---------|---------|---------| +|`ace_attach_attached` | [_attachedObject, _itemClassname] | Local | Listen | After a item was attached to Unit/Vehicle +|`ace_attach_detach` | [_attachedObject, _itemName] | Local | Listen | Just before a item gets detached/removed from Unit/Vehicle + ## 3. Usage Also Reference [CBA Events System](https://github.com/CBATeam/CBA_A3/wiki/Custom-Events-System){:target="_blank"} documentation. From ae503d4d0e222fe345738035856269d5dbb9a934 Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Sun, 4 Apr 2021 02:16:56 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Jo David --- docs/wiki/framework/events-framework.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/wiki/framework/events-framework.md b/docs/wiki/framework/events-framework.md index d228afbd07f..659ff4c8ee6 100644 --- a/docs/wiki/framework/events-framework.md +++ b/docs/wiki/framework/events-framework.md @@ -111,8 +111,8 @@ MenuType: 0 = Interaction, 1 = Self Interaction | Event Key | Parameters | Locality | Type | Description | |----------|---------|---------|---------|---------|---------| -|`ace_attach_attached` | [_attachedObject, _itemClassname] | Local | Listen | After a item was attached to Unit/Vehicle -|`ace_attach_detach` | [_attachedObject, _itemName] | Local | Listen | Just before a item gets detached/removed from Unit/Vehicle +|`ace_attach_attached` | [_attachedObject, _itemClassname] | Local | Listen | After an item was attached to a unit/vehicle +|`ace_attach_detach` | [_attachedObject, _itemName] | Local | Listen | Just before an item gets detached/removed from a unit/vehicle ## 3. Usage Also Reference [CBA Events System](https://github.com/CBATeam/CBA_A3/wiki/Custom-Events-System){:target="_blank"} documentation. From 55a1268a6f7e01954a727fb567d370c4581b7d61 Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Fri, 23 Apr 2021 12:53:08 +0200 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: jonpas --- addons/attach/functions/fnc_detach.sqf | 2 +- docs/wiki/framework/events-framework.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/attach/functions/fnc_detach.sqf b/addons/attach/functions/fnc_detach.sqf index f4358371f64..0d315fb9b83 100644 --- a/addons/attach/functions/fnc_detach.sqf +++ b/addons/attach/functions/fnc_detach.sqf @@ -50,7 +50,7 @@ if (!([_unit, _itemName] call CBA_fnc_canAddItem) && {!_isChemlight}) exitWith { [LELSTRING(common,Inventory_Full)] call EFUNC(common,displayTextStructured); }; -[QGVAR(detach), [_attachedObject, _itemName]] call CBA_fnc_localEvent; +[QGVAR(detaching), [_attachedObject, _itemName]] call CBA_fnc_localEvent; // Add item to inventory (unless it's a chemlight) if (!_isChemlight) then { diff --git a/docs/wiki/framework/events-framework.md b/docs/wiki/framework/events-framework.md index 659ff4c8ee6..3fd2e797ce8 100644 --- a/docs/wiki/framework/events-framework.md +++ b/docs/wiki/framework/events-framework.md @@ -112,7 +112,7 @@ MenuType: 0 = Interaction, 1 = Self Interaction | Event Key | Parameters | Locality | Type | Description | |----------|---------|---------|---------|---------|---------| |`ace_attach_attached` | [_attachedObject, _itemClassname] | Local | Listen | After an item was attached to a unit/vehicle -|`ace_attach_detach` | [_attachedObject, _itemName] | Local | Listen | Just before an item gets detached/removed from a unit/vehicle +|`ace_attach_detaching` | [_attachedObject, _itemName] | Local | Listen | Just before an item gets detached/removed from a unit/vehicle ## 3. Usage Also Reference [CBA Events System](https://github.com/CBATeam/CBA_A3/wiki/Custom-Events-System){:target="_blank"} documentation.