2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-03-17 14:42:25 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
2023-07-23 23:07:37 +00:00
|
|
|
* Handles attaching and setting up a carried object. Called from ace_dragging_fnc_startCarryPFH.
|
2015-03-17 14:42:25 +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-17 14:42:25 +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_carryObject;
|
|
|
|
*
|
2015-08-09 12:53:13 +00:00
|
|
|
* Public: No
|
2015-03-17 14:42:25 +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-17 14:42:25 +00:00
|
|
|
|
2024-07-20 06:26:53 +00:00
|
|
|
// If in ViV cargo, unload it first
|
|
|
|
// Warn user if it failed to unload (shouldn't happen)
|
|
|
|
if (!isNull isVehicleCargo _target && {!(objNull setVehicleCargo _target)}) then {
|
|
|
|
WARNING_1("ViV Unload Failed %1",_target);
|
|
|
|
};
|
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Get attachTo offset and direction
|
2016-01-28 18:52:53 +00:00
|
|
|
private _position = _target getVariable [QGVAR(carryPosition), [0, 0, 0]];
|
|
|
|
private _direction = _target getVariable [QGVAR(carryDirection), 0];
|
2015-03-18 13:14:16 +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 {
|
2021-08-03 18:06:12 +00:00
|
|
|
[_unit, "AcinPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation);
|
|
|
|
[_target, "AinjPfalMstpSnonWnonDf_carried_dead", 2] call EFUNC(common,doAnimation);
|
2015-03-17 14:42:25 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Attach person
|
2015-03-25 12:32:59 +00:00
|
|
|
_target attachTo [_unit, _position, "LeftShoulder"];
|
|
|
|
} else {
|
2023-07-23 23:07:37 +00:00
|
|
|
// Add height offset of model
|
|
|
|
private _offset = ((_target modelToWorldVisual [0, 0, 0]) select 2) - ((_unit modelToWorldVisual [0, 0, 0]) select 2);
|
2015-03-17 14:42:25 +00:00
|
|
|
|
2015-03-25 12:32:59 +00:00
|
|
|
_position = _position vectorAdd [0, 0, _offset];
|
2015-03-18 12:36:22 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Attach object
|
2015-03-25 12:32:59 +00:00
|
|
|
_target attachTo [_unit, _position];
|
|
|
|
};
|
2023-07-23 23:07:37 +00:00
|
|
|
|
2016-06-04 10:12:56 +00:00
|
|
|
[QEGVAR(common,setDir), [_target, _direction], _target] call CBA_fnc_targetEvent;
|
2015-03-17 14:42:25 +00:00
|
|
|
|
|
|
|
_unit setVariable [QGVAR(isCarrying), true, true];
|
|
|
|
_unit setVariable [QGVAR(carriedObject), _target, true];
|
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Add drop action
|
|
|
|
_unit setVariable [QGVAR(releaseActionID), [
|
2015-09-26 01:16:55 +00:00
|
|
|
_unit, "DefaultAction",
|
|
|
|
{!isNull ((_this select 0) getVariable [QGVAR(carriedObject), objNull])},
|
2023-06-23 12:11:16 +00:00
|
|
|
{[_this select 0, (_this select 0) getVariable [QGVAR(carriedObject), objNull], true] call FUNC(dropObject_carry)}
|
2015-09-26 01:16:55 +00:00
|
|
|
] call EFUNC(common,addActionEventHandler)];
|
2015-03-17 14:42:25 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Add anim changed EH
|
2024-03-28 18:57:23 +00:00
|
|
|
[_unit, "AnimChanged", LINKFUNC(handleAnimChanged), [_unit]] call CBA_fnc_addBISEventHandler;
|
2016-08-03 20:26:36 +00:00
|
|
|
|
2023-07-23 23:07:37 +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
|
|
|
|
2021-02-27 17:05:05 +00:00
|
|
|
if (_UAVCrew isNotEqualTo []) then {
|
2023-07-23 23:07:37 +00:00
|
|
|
{
|
2024-07-22 06:38:39 +00:00
|
|
|
[_x, true] call EFUNC(common,disableAiUAV);
|
2023-07-23 23:07:37 +00:00
|
|
|
} forEach _UAVCrew;
|
|
|
|
|
2024-07-22 06:38:39 +00:00
|
|
|
_target setVariable [QGVAR(isUAV), _UAVCrew, true];
|
2015-09-26 01:16:55 +00:00
|
|
|
};
|
2023-10-23 17:21:50 +00:00
|
|
|
|
|
|
|
// Check everything
|
2024-03-28 18:57:23 +00:00
|
|
|
[LINKFUNC(carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
|