From 146812b5e6f38889c7307f8f946f1903d24beb8c Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 30 Mar 2015 21:51:11 -0500 Subject: [PATCH] Dragging - Detect static weapon disassembled Static weapons can still be disassembled at any time during dragging. This just adds a simple distance check and drops if object moves away from player. --- addons/dragging/functions/fnc_carryObjectPFH.sqf | 4 ++-- addons/dragging/functions/fnc_dragObjectPFH.sqf | 4 ++-- addons/dragging/functions/fnc_startCarryPFH.sqf | 4 ++-- addons/dragging/functions/fnc_startDragPFH.sqf | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/dragging/functions/fnc_carryObjectPFH.sqf b/addons/dragging/functions/fnc_carryObjectPFH.sqf index 8afa0f541a..f3a9329d35 100644 --- a/addons/dragging/functions/fnc_carryObjectPFH.sqf +++ b/addons/dragging/functions/fnc_carryObjectPFH.sqf @@ -14,8 +14,8 @@ if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; }; -// drop if the crate is destroyed -if !([_target] call EFUNC(common,isAlive)) then { +// drop if the crate is destroyed OR (target moved away from carrier (weapon disasembled)) +if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then { [_unit, _target] call FUNC(dropObject_carry); [_this select 1] call CBA_fnc_removePerFrameHandler; }; diff --git a/addons/dragging/functions/fnc_dragObjectPFH.sqf b/addons/dragging/functions/fnc_dragObjectPFH.sqf index 2290c65e9d..8af8e62b90 100644 --- a/addons/dragging/functions/fnc_dragObjectPFH.sqf +++ b/addons/dragging/functions/fnc_dragObjectPFH.sqf @@ -14,8 +14,8 @@ if !(_unit getVariable [QGVAR(isDragging), false]) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; }; -// drop if the crate is destroyed -if !([_target] call EFUNC(common,isAlive)) then { +// drop if the crate is destroyed OR (target moved away from carrier (weapon disasembled)) +if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then { [_unit, _target] call FUNC(dropObject); [_this select 1] call CBA_fnc_removePerFrameHandler; }; diff --git a/addons/dragging/functions/fnc_startCarryPFH.sqf b/addons/dragging/functions/fnc_startCarryPFH.sqf index a932d4e189..d98522c5f2 100644 --- a/addons/dragging/functions/fnc_startCarryPFH.sqf +++ b/addons/dragging/functions/fnc_startCarryPFH.sqf @@ -16,8 +16,8 @@ if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; }; -// same as dragObjectPFH, checks if object is deleted or dead. -if !([_target] call EFUNC(common,isAlive)) then { +// same as dragObjectPFH, checks if object is deleted or dead OR (target moved away from carrier (weapon disasembled)) +if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then { [_unit, _target] call FUNC(dropObject); [_this select 1] call CBA_fnc_removePerFrameHandler; }; diff --git a/addons/dragging/functions/fnc_startDragPFH.sqf b/addons/dragging/functions/fnc_startDragPFH.sqf index 10d9d896a8..d77a23457e 100644 --- a/addons/dragging/functions/fnc_startDragPFH.sqf +++ b/addons/dragging/functions/fnc_startDragPFH.sqf @@ -16,8 +16,8 @@ if !(_unit getVariable [QGVAR(isDragging), false]) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; }; -// same as dragObjectPFH, checks if object is deleted or dead. -if !([_target] call EFUNC(common,isAlive)) then { +// same as dragObjectPFH, checks if object is deleted or dead OR (target moved away from carrier (weapon disasembled)) +if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then { [_unit, _target] call FUNC(dropObject); [_this select 1] call CBA_fnc_removePerFrameHandler; };