mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Towing - Add conditions to cancel towing in exceptional scenarios (#8612)
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
2441ef493e
commit
fc6b1b7fa1
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user