Skip to content

Commit

Permalink
Captives - Add caller to captiveStatusChanged event (#8360)
Browse files Browse the repository at this point in the history
* Add caller to ace_captiveStatusChanged event

* missing bracket

* Spaces, default value for _caller in setHandcuffed

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* use default value in SetSurrendered

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* update function example in doRemoveHandcuffs

* fix undefined variable

a lesson in not copy-pasting code

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* ditto last commit

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
  • Loading branch information
3 people authored Sep 3, 2021
1 parent f712638 commit be8a50c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion addons/captives/functions/fnc_doApplyHandcuffs.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ params ["_unit", "_target"];

playSound3D [QUOTE(PATHTO_R(sounds\cable_tie_zipping.ogg)), objNull, false, (getPosASL _target), 1, 1, 10];

[QGVAR(setHandcuffed), [_target, true], [_target]] call CBA_fnc_targetEvent;
[QGVAR(setHandcuffed), [_target, true, _unit], [_target]] call CBA_fnc_targetEvent;

_unit removeItem "ACE_CableTie";
7 changes: 4 additions & 3 deletions addons/captives/functions/fnc_doRemoveHandcuffs.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
* Remove handcuffs from a target
*
* Arguments:
* 0: target <OBJECT>
* 0: Caller <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* The return value <BOOL>
*
* Example:
* [bob, false] call ACE_captives_fnc_doRemoveHandcuffs
* [bob, bill] call ACE_captives_fnc_doRemoveHandcuffs
*
* Public: No
*/

params ["_unit", "_target"];

[QGVAR(setHandcuffed), [_target, false], [_target]] call CBA_fnc_targetEvent;
[QGVAR(setHandcuffed), [_target, false, _unit], [_target]] call CBA_fnc_targetEvent;
9 changes: 5 additions & 4 deletions addons/captives/functions/fnc_setHandcuffed.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
* Arguments:
* 0: Unit <OBJECT>
* 1: True to take captive, false to release captive <BOOL>
* 2: Caller <OBJECT>
*
* Return Value:
* None
*
* Example:
* [bob, true] call ACE_captives_fnc_setHandcuffed;
* [bob, true, dave] call ACE_captives_fnc_setHandcuffed;
*
* Public: No
*/

params ["_unit","_state"];
TRACE_2("params",_unit,_state);
params ["_unit", "_state", ["_caller", objNull]];
TRACE_3("params",_unit,_state,_caller);

if (!local _unit) exitWith {
WARNING("running setHandcuffed on remote unit");
Expand Down Expand Up @@ -103,4 +104,4 @@ if (_state) then {
};

//Global Event after changes:
["ace_captiveStatusChanged", [_unit, _state, "SetHandcuffed"]] call CBA_fnc_globalEvent;
["ace_captiveStatusChanged", [_unit, _state, "SetHandcuffed", _caller]] call CBA_fnc_globalEvent;
2 changes: 1 addition & 1 deletion docs/wiki/framework/events-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ MenuType: 0 = Interaction, 1 = Self Interaction

| Event Key | Parameters | Locality | Type | Description |
|----------|---------|---------|---------|---------|---------|
|`ace_captiveStatusChanged` | [_unit, _state(BOOL), _reason ("SetHandcuffed" or "SetSurrendered")] | Global | Listen | Unit's captivity state changed
|`ace_captiveStatusChanged` | [_unit, _state(BOOL), _reason ("SetHandcuffed" or "SetSurrendered"), _caller] | Global | Listen | Unit's captivity state changed
|`ace_captives_setSurrendered` | [_unit, _state(BOOL)] | Target | Callable | Sets a unit to either start or stop surrendering
|`ace_captives_setHandcuffed` | [_unit, _state(BOOL)] | Target | Callable | Sets a unit to either start or stop being handcuffed

Expand Down

0 comments on commit be8a50c

Please sign in to comment.