2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-03-24 20:37:27 +00:00
|
|
|
/*
|
2019-01-20 16:23:24 +00:00
|
|
|
* Author: commy2, PiZZADOX
|
2023-07-23 23:07:37 +00:00
|
|
|
* Starts the carrying process.
|
2015-03-24 20:37:27 +00:00
|
|
|
*
|
2015-08-09 12:53:13 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Unit that should do the carrying <OBJECT>
|
|
|
|
* 1: Object to carry <OBJECT>
|
2015-03-24 20:37:27 +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_startCarry;
|
|
|
|
*
|
2015-08-09 12:53:13 +00:00
|
|
|
* Public: No
|
2015-03-24 20:37:27 +00:00
|
|
|
*/
|
|
|
|
|
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-03-24 20:37:27 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Exempt from weight check if object has override variable set
|
2023-07-22 03:30:40 +00:00
|
|
|
private _weight = 0;
|
2023-07-23 23:07:37 +00:00
|
|
|
|
2023-07-22 03:30:40 +00:00
|
|
|
if !(_target getVariable [QGVAR(ignoreWeightCarry), false]) then {
|
2023-07-23 23:07:37 +00:00
|
|
|
_weight = _target call FUNC(getWeight);
|
2023-07-22 03:30:40 +00:00
|
|
|
};
|
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Exit if object weight is over global var value
|
2023-07-22 03:30:40 +00:00
|
|
|
if (_weight > GETMVAR(ACE_maxWeightCarry,1E11)) exitWith {
|
2023-07-23 23:07:37 +00:00
|
|
|
[LLSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
|
2015-03-24 20:37:27 +00:00
|
|
|
};
|
|
|
|
|
2016-03-02 10:01:39 +00:00
|
|
|
private _timer = CBA_missionTime + 5;
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Handle objects vs. persons
|
2015-03-25 12:32:59 +00:00
|
|
|
if (_target isKindOf "CAManBase") then {
|
2023-07-23 23:07:37 +00:00
|
|
|
private _primaryWeapon = primaryWeapon _unit;
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Add a primary weapon if the unit has none
|
|
|
|
if (_primaryWeapon == "") then {
|
2015-03-25 12:32:59 +00:00
|
|
|
_unit addWeapon "ACE_FakePrimaryWeapon";
|
2023-07-23 23:07:37 +00:00
|
|
|
_primaryWeapon = "ACE_FakePrimaryWeapon";
|
2015-03-25 12:32:59 +00:00
|
|
|
};
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Select primary, otherwise the drag animation actions don't work
|
|
|
|
_unit selectWeapon _primaryWeapon;
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Move a bit closer and adjust direction when trying to pick up a person
|
|
|
|
[QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent;
|
2015-05-31 16:34:48 +00:00
|
|
|
_target setPosASL (getPosASL _unit vectorAdd (vectorDir _unit));
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2021-08-03 18:06:12 +00:00
|
|
|
[_unit, "AcinPknlMstpSnonWnonDnon_AcinPercMrunSnonWnonDnon", 2] call EFUNC(common,doAnimation);
|
|
|
|
[_target, "AinjPfalMstpSnonWrflDnon_carried_Up", 2] call EFUNC(common,doAnimation);
|
2015-03-24 20:37:27 +00:00
|
|
|
|
2019-10-05 20:32:38 +00:00
|
|
|
_timer = CBA_missionTime + 10;
|
2015-03-25 12:32:59 +00:00
|
|
|
} else {
|
2023-07-23 23:07:37 +00:00
|
|
|
// Select no weapon and stop sprinting
|
2023-02-14 04:01:51 +00:00
|
|
|
private _previousWeaponIndex = [_unit] call EFUNC(common,getFiremodeIndex);
|
|
|
|
_unit setVariable [QGVAR(previousWeapon), _previousWeaponIndex, true];
|
2023-07-23 23:07:37 +00:00
|
|
|
|
2017-05-12 18:12:39 +00:00
|
|
|
_unit action ["SwitchWeapon", _unit, _unit, 299];
|
2023-07-23 23:07:37 +00:00
|
|
|
|
2015-03-25 12:32:59 +00:00
|
|
|
[_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation);
|
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
private _canRun = _weight call FUNC(canRun_carry);
|
|
|
|
|
|
|
|
// Only force walking if we're overweight
|
2023-07-22 03:30:40 +00:00
|
|
|
[_unit, "forceWalk", QUOTE(ADDON), !_canRun] call EFUNC(common,statusEffect_set);
|
|
|
|
[_unit, "blockSprint", QUOTE(ADDON), _canRun] call EFUNC(common,statusEffect_set);
|
2015-03-24 20:37:27 +00:00
|
|
|
};
|
|
|
|
|
2023-07-22 03:30:40 +00:00
|
|
|
[_unit, "blockThrow", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
2017-12-07 17:26:21 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Prevent multiple players from accessing the same object
|
2015-04-03 19:37:04 +00:00
|
|
|
[_unit, _target, true] call EFUNC(common,claim);
|
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Prevents dragging and carrying at the same time
|
2015-03-24 20:37:27 +00:00
|
|
|
_unit setVariable [QGVAR(isCarrying), true, true];
|
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Required for aborting animation
|
2015-03-25 12:32:59 +00:00
|
|
|
_unit setVariable [QGVAR(carriedObject), _target, true];
|
|
|
|
|
|
|
|
[FUNC(startCarryPFH), 0.2, [_unit, _target, _timer]] call CBA_fnc_addPerFrameHandler;
|
2019-03-24 08:26:00 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Disable collisions by setting the PhysX mass to almost zero
|
2019-03-24 08:26:00 +00:00
|
|
|
private _mass = getMass _target;
|
|
|
|
|
|
|
|
if (_mass > 1) then {
|
|
|
|
_target setVariable [QGVAR(originalMass), _mass, true];
|
2023-07-23 23:07:37 +00:00
|
|
|
[QEGVAR(common,setMass), [_target, 1e-12]] call CBA_fnc_globalEvent; // Force global sync
|
2019-03-24 08:26:00 +00:00
|
|
|
};
|