Skip to content

Commit

Permalink
Attach - Added attached/detaching events (#8193)
Browse files Browse the repository at this point in the history
* Added ace_attach attached/detach events

* Apply suggestions from code review

Co-authored-by: Jo David <github@jonathandavid.de>

* Apply suggestions from code review

Co-authored-by: jonpas <jonpas33@gmail.com>

Co-authored-by: Jo David <github@jonathandavid.de>
Co-authored-by: jonpas <jonpas33@gmail.com>
  • Loading branch information
3 people authored Apr 26, 2021
1 parent f96b410 commit d505156
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions addons/attach/functions/fnc_attach.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions addons/attach/functions/fnc_detach.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ if (!([_unit, _itemName] call CBA_fnc_canAddItem) && {!_isChemlight}) exitWith {
[LELSTRING(common,Inventory_Full)] call EFUNC(common,displayTextStructured);
};

[QGVAR(detaching), [_attachedObject, _itemName]] call CBA_fnc_localEvent;

// Add item to inventory (unless it's a chemlight)
if (!_isChemlight) then {
_unit addItem _itemName;
Expand Down
3 changes: 2 additions & 1 deletion addons/attach/functions/fnc_placeApprove.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
8 changes: 8 additions & 0 deletions docs/wiki/framework/events-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 an item was attached to 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.

Expand Down

0 comments on commit d505156

Please sign in to comment.