ACE3/addons/dragging/functions/fnc_handleAnimChanged.sqf
jonpas 711e1fc026 Fix Underwater interactions (magrepack, loading, refuel, medical legs, dragging) (#5521)
* Fix Magazine Repack underwater - fix #5513
Also prevent common goKneeling function underwater

* Fix loading patients underwater - fix #5515

* Fix load object underwater

* Fix take nozzle on jerry can underwater

* Fix refuel underwater conditions further

* Use isTouchingGround, Make refuel semi-compatible
 reports false if head is out of the water, we want true even if we are not diving

* Less interact exceptions duplication

* Use animationState to determine if unit is swimming, create common function and use it instead of isTouchingGround

* Fix condition

* Support dragging underwater
No carrying due to animation timing issues and other misc things

* Allow Medical Legs SelfActions underwater

* Fix fixPosition function underwater (use getPosATL instead of getPos)

* Fix fixPosition's slope adjustment for non-gravity objects, Do the same for objects without simulation as well
2017-10-01 13:38:11 -05:00

59 lines
1.8 KiB
Plaintext

/*
* Author: commy2
* Handle the animaion for a Unit for Dragging Module
*
* Arguments:
* 0: Unit <OBJECT>
* 1: animaion <STRING>
*
* Return Value:
* None
*
* Example:
* [_unit, "amovpercmstpsnonwnondnon"] call ace_dragging_fnc_handleAnimChanged;
*
* Public: No
*/
#include "script_component.hpp"
//IGNORE_PRIVATE_WARNING ["_thisArgs", "_thisID"]; // From CBA_fnc_addBISEventHandler;
params ["_unit", "_anim"];
_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];
};
if (_unit getVariable [QGVAR(isDragging), false]) then {
// drop dragged object when not in valid animation
if (!(_anim in DRAG_ANIMATIONS) && {!(_unit call EFUNC(common,isSwimming))}) then {
private _draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
if (!isNull _draggedObject) then {
TRACE_2("stop drag",_unit,_draggedObject);
[_unit, _draggedObject] call FUNC(dropObject);
};
};
} else {
if (_unit getVariable [QGVAR(isCarrying), false]) then {
// drop carried object when not standing; also some exceptions when picking up crate
if (stance _unit != "STAND" && {_anim != "amovpercmstpsnonwnondnon"}) then {
private _carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
if (!isNull _carriedObject) then {
TRACE_2("stop carry",_unit,_carriedObject);
[_unit, _carriedObject] call FUNC(dropObject_carry);
};
};
} else {
TRACE_1("not drag/carry - remove EH",_unit);
_unit removeEventHandler ["AnimChanged", _thisID];
};
};