ACE3/addons/dragging/functions/fnc_setCarryable.sqf

53 lines
1.9 KiB
Plaintext
Raw Normal View History

2015-03-17 14:42:25 +00:00
/*
* Author: commy2
* Enable the object to be carried.
*
2016-06-18 09:50:41 +00:00
* Arguments:
2015-08-09 12:53:13 +00:00
* 0: Any object <OBJECT>
* 1: true to enable carrying, false to disable <BOOL>
* 2: Position offset for attachTo command <ARRAY> (default: [0,1,1])
* 3: Direction in degree to rotate the object after attachTo <NUMBER> (default: 0)
2015-03-17 14:42:25 +00:00
*
2015-08-09 12:53:13 +00:00
* Return Value:
* None
*
2016-01-28 18:52:53 +00:00
* Example:
* [object, true, [0,1,1], 0] call ace_dragging_fnc_setCarryable;
*
2015-08-09 12:53:13 +00:00
* Public: Yes
2015-03-17 14:42:25 +00:00
*/
#include "script_component.hpp"
2015-08-09 12:53:13 +00:00
params ["_object", "_enableCarry", "_position", "_direction"];
2015-03-17 14:42:25 +00:00
if (isNil "_position") then {
2015-03-17 14:45:34 +00:00
_position = _object getVariable [QGVAR(carryPosition), [0,1,1]];
2015-03-17 14:42:25 +00:00
};
if (isNil "_direction") then {
_direction = _object getVariable [QGVAR(carryDirection), 0];
};
// update variables
_object setVariable [QGVAR(canCarry), _enableCarry];
_object setVariable [QGVAR(carryPosition), _position];
_object setVariable [QGVAR(carryDirection), _direction];
// add action to class if it is not already present
2016-01-28 18:52:53 +00:00
private _type = typeOf _object;
private _initializedClasses = GETGVAR(initializedClasses_carry,[]);
2015-03-17 14:42:25 +00:00
// do nothing if the class is already initialized
if (_type in _initializedClasses) exitWith {};
_initializedClasses pushBack _type;
GVAR(initializedClasses_carry) = _initializedClasses;
2016-05-07 20:23:38 +00:00
private _icon = [QUOTE(PATHTOF(UI\icons\box_carry.paa)), QUOTE(PATHTOF(UI\icons\person_carry.paa))] select (_object isKindOf "Man");
private _carryAction = [QGVAR(carry), localize LSTRING(Carry), _icon, {[_player, _target] call FUNC(startCarry)}, {[_player, _target] call FUNC(canCarry)}] call EFUNC(interact_menu,createAction);
2016-01-28 18:52:53 +00:00
private _dropAction = [QGVAR(drop_carry), localize LSTRING(Drop), "", {[_player, _target] call FUNC(dropObject_carry)}, {[_player, _target] call FUNC(canDrop_carry)}] call EFUNC(interact_menu,createAction);
[_type, 0, ["ACE_MainActions"], _carryAction] call EFUNC(interact_menu,addActionToClass);
2015-03-22 15:38:21 +00:00
[_type, 0, [], _dropAction] call EFUNC(interact_menu,addActionToClass);