diff --git a/addons/towing/functions/fnc_startTow.sqf b/addons/towing/functions/fnc_startTow.sqf index d216576499..fb0755285c 100644 --- a/addons/towing/functions/fnc_startTow.sqf +++ b/addons/towing/functions/fnc_startTow.sqf @@ -28,6 +28,7 @@ if (_ropeLength == 0) then { _unit removeItem _ropeClass; +GVAR(cancel) = false; GVAR(canAttach) = false; [LINKFUNC(towStateMachinePFH), 0, [TOW_STATE_ATTACH_PARENT, _unit, _target, objNull, _ropeLength, _ropeClass]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/towing/functions/fnc_towStateMachinePFH.sqf b/addons/towing/functions/fnc_towStateMachinePFH.sqf index 326a9aeee5..7981329d9f 100644 --- a/addons/towing/functions/fnc_towStateMachinePFH.sqf +++ b/addons/towing/functions/fnc_towStateMachinePFH.sqf @@ -25,10 +25,11 @@ private _exitCondition = !( { "" isEqualTo currentWeapon _unit || { _unit call EFUNC(common,isSwimming) }} && { [_unit, objNull, [INTERACTION_EXCEPTIONS]] call EFUNC(common,canInteractWith) } && { "unconscious" isNotEqualTo toLower animationState _unit } && - { !(_unit getVariable ["ACE_isUnconscious", false]) } + { !(_unit getVariable ["ACE_isUnconscious", false]) } && + { ACE_player == _unit } ); -if (_exitCondition) then { +if (_exitCondition && {_state < TOW_STATE_CANCEL}) then { _state = TOW_STATE_CANCEL; }; @@ -45,8 +46,9 @@ switch (_state) do { _args set [3, _rope]; }; - if (GVAR(mouseRight)) then { + if (GVAR(mouseRight) || GVAR(cancel)) then { _args set [0, TOW_STATE_CANCEL]; + GVAR(cancel) = false; }; }; case TOW_STATE_ATTACH_CHILD: { @@ -74,6 +76,11 @@ switch (_state) do { ERROR_MSG("_child isEqualTo _parent"); }; + if (GVAR(cancel)) exitWith { + _args set [0, TOW_STATE_CANCEL]; + GVAR(cancel) = false; + }; + [QGVAR(setTowParent), [_parent, _child], _parent] call CBA_fnc_targetEvent; GVAR(attachHelper) ropeDetach _rope; @@ -127,9 +134,12 @@ switch (_state) do { }; case TOW_STATE_CANCEL: { TRACE_1("state cancel",_rope); - ropeDestroy _rope; + if !(isNull _rope) then { + ropeDestroy _rope; + }; [_unit, _ropeClass, true] call CBA_fnc_addItem; _args set [0, TOW_STATE_CLEANUP]; + GVAR(cancel) = false; (localize LSTRING(canceled)) call CBA_fnc_notify; }; diff --git a/addons/towing/script_component.hpp b/addons/towing/script_component.hpp index d3c12463c9..2d9790ac20 100644 --- a/addons/towing/script_component.hpp +++ b/addons/towing/script_component.hpp @@ -17,7 +17,7 @@ #include "\z\ace\addons\main\script_macros.hpp" #define TOW_ACTION_DISTANCE 3 -#define INTERACTION_EXCEPTIONS "isNotInside", "isNotOnLadder", "isNotSwimming" +#define INTERACTION_EXCEPTIONS "isNotOnLadder", "isNotSwimming" #define TOW_STATE_ATTACH_PARENT 0 #define TOW_STATE_ATTACH_CHILD 1