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
|
|
|
|
*
|
2016-01-28 18:52:53 +00:00
|
|
|
* Example:
|
|
|
|
* [player, cursorTarget] call ace_dragging_fnc_dragObject;
|
|
|
|
*
|
2015-08-09 12:53:13 +00:00
|
|
|
* Public: No
|
2015-03-16 18:25:29 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-09 12:53:13 +00:00
|
|
|
params ["_unit", "_target"];
|
2016-01-28 18:52:53 +00:00
|
|
|
TRACE_2("params",_unit,_target);
|
2015-09-26 01:16:55 +00:00
|
|
|
|
2015-03-16 18:25:29 +00:00
|
|
|
// get attachTo offset and direction.
|
2016-01-28 18:52:53 +00:00
|
|
|
private _position = _target getVariable [QGVAR(dragPosition), [0, 0, 0]];
|
|
|
|
private _direction = _target getVariable [QGVAR(dragDirection), 0];
|
2015-03-16 18:25:29 +00:00
|
|
|
|
|
|
|
// add height offset of model
|
2016-01-28 18:52:53 +00:00
|
|
|
private _offset = (_target modelToWorldVisual [0, 0, 0] select 2) - (_unit modelToWorldVisual [0, 0, 0] select 2);
|
2016-01-28 23:11:05 +00:00
|
|
|
if (_target isKindOf "CAManBase") then {
|
|
|
|
_offset = 0;
|
|
|
|
};
|
2015-03-16 18:25:29 +00:00
|
|
|
_position = _position vectorAdd [0, 0, _offset];
|
|
|
|
|
|
|
|
// attach object
|
2016-01-28 23:11:05 +00:00
|
|
|
TRACE_3("attaching",_position,_offset,_direction);
|
2015-03-16 18:25:29 +00:00
|
|
|
_target attachTo [_unit, _position];
|
2016-06-04 10:12:56 +00:00
|
|
|
[QEGVAR(common,setDir), [_target, _direction], _target] call CBA_fnc_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-09-26 01:16:55 +00:00
|
|
|
// add drop action
|
|
|
|
_unit setVariable [QGVAR(ReleaseActionID), [
|
|
|
|
_unit, "DefaultAction",
|
|
|
|
{!isNull ((_this select 0) getVariable [QGVAR(draggedObject), objNull])},
|
|
|
|
{[_this select 0, (_this select 0) getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject)}
|
|
|
|
] call EFUNC(common,addActionEventHandler)];
|
2015-03-16 18:25:29 +00:00
|
|
|
|
2016-08-03 20:26:36 +00:00
|
|
|
// add anim changed EH
|
|
|
|
[_unit, "AnimChanged", FUNC(handleAnimChanged), [_unit]] call CBA_fnc_addBISEventHandler;
|
|
|
|
|
2015-09-26 01:16:55 +00:00
|
|
|
// show mouse hint
|
|
|
|
[localize LSTRING(Drop), ""] call EFUNC(interaction,showMouseHint);
|
2015-03-16 18:25:29 +00:00
|
|
|
|
|
|
|
// check everything
|
2016-03-02 10:01:39 +00:00
|
|
|
[FUNC(dragObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
|
2015-03-16 18:25:29 +00:00
|
|
|
|
|
|
|
// reset current dragging height.
|
|
|
|
GVAR(currentHeightChange) = 0;
|
2015-09-26 01:16:55 +00:00
|
|
|
|
|
|
|
// prevent UAVs from firing
|
2016-01-28 18:52:53 +00:00
|
|
|
private _UAVCrew = _target call EFUNC(common,getVehicleUAVCrew);
|
2015-09-26 01:16:55 +00:00
|
|
|
|
|
|
|
if !(_UAVCrew isEqualTo []) then {
|
|
|
|
{_target deleteVehicleCrew _x} count _UAVCrew;
|
|
|
|
_target setVariable [QGVAR(isUAV), true, true];
|
|
|
|
};
|