2015-03-16 18:25:29 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
*
|
|
|
|
* Drag an object. Called from ace_dragging_fnc_startDrag
|
|
|
|
*
|
2015-08-09 12:53:13 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Unit that should do the dragging <OBJECT>
|
|
|
|
* 1: Object to drag <OBJECT>
|
2015-03-16 18:25:29 +00:00
|
|
|
*
|
2015-08-09 12:53:13 +00:00
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-03-16 18:25:29 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-09 12:53:13 +00:00
|
|
|
private ["_position", "_direction", "_offset", "_actionID"];
|
|
|
|
params ["_unit", "_target"];
|
2015-03-16 18:25:29 +00:00
|
|
|
|
|
|
|
// get attachTo offset and direction.
|
|
|
|
_position = _target getVariable [QGVAR(dragPosition), [0, 0, 0]];
|
|
|
|
_direction = _target getVariable [QGVAR(dragDirection), 0];
|
|
|
|
|
|
|
|
// add height offset of model
|
2015-04-03 22:26:27 +00:00
|
|
|
_offset = (_target modelToWorldVisual [0, 0, 0] select 2) - (_unit modelToWorldVisual [0, 0, 0] select 2);
|
2015-03-16 18:25:29 +00:00
|
|
|
|
|
|
|
_position = _position vectorAdd [0, 0, _offset];
|
|
|
|
|
|
|
|
// attach object
|
|
|
|
_target attachTo [_unit, _position];
|
2015-03-25 19:45:47 +00:00
|
|
|
["setDir", _target, [_target, _direction]] call EFUNC(common,targetEvent);
|
2015-03-16 18:25:29 +00:00
|
|
|
|
2015-03-24 18:07:39 +00:00
|
|
|
if (_target isKindOf "CAManBase") then {
|
|
|
|
[_target, "AinjPpneMrunSnonWnonDb_still", 0, true] call EFUNC(common,doAnimation);
|
|
|
|
};
|
|
|
|
|
2015-03-16 19:09:54 +00:00
|
|
|
_unit setVariable [QGVAR(isDragging), true, true];
|
|
|
|
_unit setVariable [QGVAR(draggedObject), _target, true];
|
|
|
|
|
2015-03-16 18:25:29 +00:00
|
|
|
// add scrollwheel action to release object
|
2015-03-16 19:09:54 +00:00
|
|
|
_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
|
2015-03-16 18:25:29 +00:00
|
|
|
|
2015-03-16 19:09:54 +00:00
|
|
|
if (_actionID != -1) then {
|
|
|
|
_unit removeAction _actionID;
|
|
|
|
};
|
2015-03-16 18:25:29 +00:00
|
|
|
|
2015-03-16 19:09:54 +00:00
|
|
|
_actionID = _unit addAction [
|
2015-05-28 19:59:04 +00:00
|
|
|
format ["<t color='#FF0000'>%1</t>", localize LSTRING(Drop)],
|
2015-08-26 08:13:30 +00:00
|
|
|
QUOTE([ARR_2(_this select 0, (_this select 0) getVariable [ARR_2(QUOTE(QGVAR(draggedObject)),objNull)])] call FUNC(dropObject)),
|
2015-03-16 19:09:54 +00:00
|
|
|
nil,
|
|
|
|
20,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
"",
|
|
|
|
QUOTE(!isNull (_this getVariable [ARR_2(QUOTE(QGVAR(draggedObject)),objNull)]))
|
|
|
|
];
|
2015-03-16 18:25:29 +00:00
|
|
|
|
2015-03-16 19:09:54 +00:00
|
|
|
_unit setVariable [QGVAR(ReleaseActionID), _actionID];
|
2015-03-16 18:25:29 +00:00
|
|
|
|
|
|
|
// check everything
|
2015-03-25 19:18:23 +00:00
|
|
|
[FUNC(dragObjectPFH), 0.5, [_unit, _target]] call CBA_fnc_addPerFrameHandler;
|
2015-03-16 18:25:29 +00:00
|
|
|
|
|
|
|
// reset current dragging height.
|
|
|
|
GVAR(currentHeightChange) = 0;
|