2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-08-09 12:53:13 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
2023-07-23 23:07:37 +00:00
|
|
|
* Handle the animation for a unit for the dragging module.
|
2015-08-09 12:53:13 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
2023-07-23 23:07:37 +00:00
|
|
|
* 1: Animaion <STRING>
|
2015-08-09 12:53:13 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2023-07-23 23:07:37 +00:00
|
|
|
* [player, "amovpercmstpsnonwnondnon"] call ace_dragging_fnc_handleAnimChanged;
|
2015-08-09 12:53:13 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-03-18 14:42:33 +00:00
|
|
|
|
2016-01-28 18:52:53 +00:00
|
|
|
params ["_unit", "_anim"];
|
2016-08-03 20:26:36 +00:00
|
|
|
_thisArgs params ["_realUnit"];
|
|
|
|
TRACE_4("params",_unit,_anim,_realUnit,_thisID);
|
|
|
|
|
|
|
|
if (_unit != _realUnit) exitWith {
|
|
|
|
TRACE_2("respawn (unit changed) - remove EH",_unit,_realUnit);
|
|
|
|
_unit removeEventHandler ["AnimChanged", _thisID];
|
|
|
|
};
|
2015-03-18 14:42:33 +00:00
|
|
|
|
|
|
|
if (_unit getVariable [QGVAR(isDragging), false]) then {
|
2023-07-23 23:07:37 +00:00
|
|
|
// Drop dragged object when not in valid animation
|
2017-10-01 18:38:11 +00:00
|
|
|
if (!(_anim in DRAG_ANIMATIONS) && {!(_unit call EFUNC(common,isSwimming))}) then {
|
2016-01-28 18:52:53 +00:00
|
|
|
private _draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
|
2015-03-18 14:42:33 +00:00
|
|
|
|
2015-03-22 16:12:14 +00:00
|
|
|
if (!isNull _draggedObject) then {
|
2016-08-03 20:26:36 +00:00
|
|
|
TRACE_2("stop drag",_unit,_draggedObject);
|
2015-03-22 16:12:14 +00:00
|
|
|
[_unit, _draggedObject] call FUNC(dropObject);
|
|
|
|
};
|
2015-03-18 14:42:33 +00:00
|
|
|
};
|
2016-08-03 20:26:36 +00:00
|
|
|
} else {
|
|
|
|
if (_unit getVariable [QGVAR(isCarrying), false]) then {
|
2023-07-23 23:07:37 +00:00
|
|
|
// Drop carried object when not standing; also some exceptions when picking up crate
|
2016-08-03 20:26:36 +00:00
|
|
|
if (stance _unit != "STAND" && {_anim != "amovpercmstpsnonwnondnon"}) then {
|
|
|
|
private _carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
|
2015-03-18 14:42:33 +00:00
|
|
|
|
2016-08-03 20:26:36 +00:00
|
|
|
if (!isNull _carriedObject) then {
|
|
|
|
TRACE_2("stop carry",_unit,_carriedObject);
|
|
|
|
[_unit, _carriedObject] call FUNC(dropObject_carry);
|
|
|
|
};
|
2015-03-22 16:12:14 +00:00
|
|
|
};
|
2016-08-03 20:26:36 +00:00
|
|
|
} else {
|
|
|
|
TRACE_1("not drag/carry - remove EH",_unit);
|
|
|
|
_unit removeEventHandler ["AnimChanged", _thisID];
|
2015-03-18 14:42:33 +00:00
|
|
|
};
|
|
|
|
};
|