2015-03-16 18:25:29 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
*
|
|
|
|
* Start the dragging process.
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: Unit that should do the dragging (Object)
|
|
|
|
* 1: Object to drag (Object)
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* NONE.
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
2015-03-16 13:31:16 +00:00
|
|
|
|
2015-03-16 18:25:29 +00:00
|
|
|
private ["_unit", "_target"];
|
|
|
|
|
|
|
|
_unit = _this select 0;
|
|
|
|
_target = _this select 1;
|
|
|
|
|
2015-03-18 13:14:16 +00:00
|
|
|
// check weight
|
|
|
|
private "_weight";
|
|
|
|
_weight = [_target] call FUNC(getWeight);
|
|
|
|
|
|
|
|
if (_weight > GETMVAR(ACE_maxWeightDrag,1E11)) exitWith {
|
|
|
|
[localize "STR_ACE_Dragging_UnableToDrag"] call EFUNC(common,displayTextStructured);
|
|
|
|
};
|
2015-03-16 18:25:29 +00:00
|
|
|
|
|
|
|
// add a primary weapon if the unit has none.
|
|
|
|
// @todo prevent opening inventory when equipped with a fake weapon
|
|
|
|
if (primaryWeapon _unit == "") then {
|
|
|
|
_unit addWeapon "ACE_FakePrimaryWeapon";
|
|
|
|
};
|
|
|
|
|
|
|
|
// select primary, otherwise the drag animation actions don't work.
|
|
|
|
_unit selectWeapon primaryWeapon _unit;
|
|
|
|
|
|
|
|
// prevent multiple players from accessing the same object
|
|
|
|
[_unit, _target, true] call EFUNC(common,claim);
|
|
|
|
|
2015-03-18 15:55:57 +00:00
|
|
|
// can't play action that depends on weapon if it was added the same frame
|
|
|
|
[{_this playActionNow "grabDrag";}, _unit] call EFUNC(common,execNextFrame);
|
2015-03-16 18:25:29 +00:00
|
|
|
|
2015-03-24 18:07:39 +00:00
|
|
|
// move a bit closer and adjust direction when trying to pick up a person
|
|
|
|
if (_target isKindOf "CAManBase") then {
|
|
|
|
_target setDir (getDir _unit + 180);
|
|
|
|
_target setPos (getPos _unit vectorAdd (vectorDir _unit vectorMultiply 1.5));
|
2015-03-25 12:32:59 +00:00
|
|
|
|
|
|
|
[_target, "AinjPpneMrunSnonWnonDb_grab", 2, true] call EFUNC(common,doAnimation);
|
2015-03-24 18:07:39 +00:00
|
|
|
};
|
|
|
|
|
2015-03-22 16:12:14 +00:00
|
|
|
// prevents draging and carrying at the same time
|
|
|
|
_unit setVariable [QGVAR(isDragging), true, true];
|
|
|
|
|
2015-03-16 18:25:29 +00:00
|
|
|
[FUNC(startDragPFH), 0.2, [_unit, _target, time + 5]] call CBA_fnc_addPerFrameHandler;
|