2015-03-24 20:37:27 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
*
|
|
|
|
* Start the carrying process.
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: Unit that should do the carrying (Object)
|
|
|
|
* 1: Object to carry (Object)
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* NONE.
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
private ["_unit", "_target"];
|
|
|
|
|
|
|
|
_unit = _this select 0;
|
|
|
|
_target = _this select 1;
|
|
|
|
|
|
|
|
// check weight
|
|
|
|
private "_weight";
|
|
|
|
_weight = [_target] call FUNC(getWeight);
|
|
|
|
|
|
|
|
if (_weight > GETMVAR(ACE_maxWeightCarry,1E11)) exitWith {
|
2015-05-27 17:04:25 +00:00
|
|
|
[localize STRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
|
2015-03-24 20:37:27 +00:00
|
|
|
};
|
|
|
|
|
2015-03-25 12:32:59 +00:00
|
|
|
private "_timer";
|
2015-05-21 16:42:44 +00:00
|
|
|
_timer = ACE_time + 5;
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2015-03-25 12:32:59 +00:00
|
|
|
// handle objects vs persons
|
|
|
|
if (_target isKindOf "CAManBase") then {
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2015-03-25 12:32:59 +00:00
|
|
|
// add a primary weapon if the unit has none.
|
|
|
|
if (primaryWeapon _unit == "") then {
|
|
|
|
_unit addWeapon "ACE_FakePrimaryWeapon";
|
|
|
|
};
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2015-03-25 12:32:59 +00:00
|
|
|
// select primary, otherwise the drag animation actions don't work.
|
|
|
|
_unit selectWeapon primaryWeapon _unit;
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2015-03-25 12:32:59 +00:00
|
|
|
// move a bit closer and adjust direction when trying to pick up a person
|
2015-03-24 20:37:27 +00:00
|
|
|
_target setDir (getDir _unit + 180);
|
2015-03-25 12:32:59 +00:00
|
|
|
_target setPos (getPos _unit vectorAdd vectorDir _unit);
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2015-03-25 12:32:59 +00:00
|
|
|
[_unit, "AcinPknlMstpSnonWnonDnon_AcinPercMrunSnonWnonDnon", 2, true] call EFUNC(common,doAnimation);
|
|
|
|
[_target, "AinjPfalMstpSnonWrflDnon_carried_Up", 2, true] call EFUNC(common,doAnimation);
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2015-05-21 16:42:44 +00:00
|
|
|
_timer = ACE_time + 15;
|
2015-03-25 12:32:59 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// select no weapon and stop sprinting
|
|
|
|
_unit action ["SwitchWeapon", _unit, _unit, 99];
|
|
|
|
[_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation);
|
|
|
|
|
|
|
|
[_unit, "isDragging", true] call EFUNC(common,setforceWalkStatus);
|
|
|
|
|
2015-03-24 20:37:27 +00:00
|
|
|
};
|
|
|
|
|
2015-04-03 19:37:04 +00:00
|
|
|
// prevent multiple players from accessing the same object
|
|
|
|
[_unit, _target, true] call EFUNC(common,claim);
|
|
|
|
|
|
|
|
|
2015-05-21 16:42:44 +00:00
|
|
|
// prevents draging and carrying at the same ACE_time
|
2015-03-24 20:37:27 +00:00
|
|
|
_unit setVariable [QGVAR(isCarrying), true, true];
|
|
|
|
|
2015-03-25 12:32:59 +00:00
|
|
|
// required for aborting animation
|
|
|
|
_unit setVariable [QGVAR(carriedObject), _target, true];
|
|
|
|
|
|
|
|
[FUNC(startCarryPFH), 0.2, [_unit, _target, _timer]] call CBA_fnc_addPerFrameHandler;
|