mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
53 lines
1.6 KiB
Plaintext
53 lines
1.6 KiB
Plaintext
|
/*
|
||
|
* Author: Jonpas
|
||
|
* Picks up a throwable from the ground.
|
||
|
*
|
||
|
* Arguments:
|
||
|
* 0: Pick Up Helper <OBJECT>
|
||
|
* 1: Unit <OBJECT>
|
||
|
*
|
||
|
* Return Value:
|
||
|
* None
|
||
|
*
|
||
|
* Example:
|
||
|
* [helper, player] call ace_advancedthrowing_fnc_pickUp
|
||
|
*
|
||
|
* Public: No
|
||
|
*/
|
||
|
#include "script_component.hpp"
|
||
|
|
||
|
params ["_helper", "_unit"];
|
||
|
TRACE_2("params",_helper,_unit);
|
||
|
|
||
|
private _activeThrowable = _helper getVariable [QGVAR(throwable), objNull];
|
||
|
|
||
|
if (isNull _activeThrowable) exitWith {TRACE_2("throwable is null",_helper,_activeThrowable);};
|
||
|
|
||
|
// Detach if attached (to vehicle for example or another player)
|
||
|
private _attachedTo = attachedTo _activeThrowable;
|
||
|
if (!isNull _attachedTo) then {
|
||
|
private _attachedList = _attachedTo getVariable [QEGVAR(attach,attached), []];
|
||
|
{
|
||
|
_x params ["_xObject"];
|
||
|
if (_activeThrowable == _xObject) exitWith {
|
||
|
TRACE_2("removing from ace_attach",_attachedTo,_attachedList);
|
||
|
_attachedList deleteAt _forEachIndex;
|
||
|
_attachedTo setVariable [QEGVAR(attach,attached), _attachedList, true];
|
||
|
};
|
||
|
} forEach _attachedList;
|
||
|
detach _activeThrowable;
|
||
|
};
|
||
|
|
||
|
// Change locality for manipulation (some commands require local object, such as setVelocity)
|
||
|
if (!local _activeThrowable) then {
|
||
|
["ace_setOwner", [_activeThrowable, CBA_clientID]] call CBA_fnc_serverEvent;
|
||
|
};
|
||
|
|
||
|
// Invoke listenable event
|
||
|
["ace_throwablePickedUp", [_activeThrowable, _unit, _attachedTo]] call CBA_fnc_localEvent;
|
||
|
|
||
|
_unit setVariable [QGVAR(primed), true];
|
||
|
_unit setVariable [QGVAR(activeThrowable), _activeThrowable];
|
||
|
|
||
|
_unit call FUNC(prepare);
|