From 3634eaf568af0c33d961e778dfa2382e6901c3da Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 25 Mar 2015 20:18:23 +0100 Subject: [PATCH] tweak carry stance req., timeout certain PFH, exit PFH, debug --- addons/dragging/functions/fnc_carryObject.sqf | 2 +- .../dragging/functions/fnc_carryObjectPFH.sqf | 8 +++++ addons/dragging/functions/fnc_dragObject.sqf | 2 +- .../dragging/functions/fnc_dragObjectPFH.sqf | 8 +++++ addons/dragging/functions/fnc_startCarry.sqf | 2 +- .../dragging/functions/fnc_startCarryPFH.sqf | 33 +++++++++++++++---- .../dragging/functions/fnc_startDragPFH.sqf | 5 ++- addons/dragging/script_component.hpp | 2 ++ 8 files changed, 52 insertions(+), 10 deletions(-) diff --git a/addons/dragging/functions/fnc_carryObject.sqf b/addons/dragging/functions/fnc_carryObject.sqf index 5d8be3af9b..338782351f 100644 --- a/addons/dragging/functions/fnc_carryObject.sqf +++ b/addons/dragging/functions/fnc_carryObject.sqf @@ -71,7 +71,7 @@ _actionID = _unit addAction [ _unit setVariable [QGVAR(ReleaseActionID), _actionID]; // check everything -[FUNC(carryObjectPFH), 0, [_unit, _target]] call CBA_fnc_addPerFrameHandler; +[FUNC(carryObjectPFH), 0.5, [_unit, _target]] call CBA_fnc_addPerFrameHandler; // reset current dragging height. GVAR(currentHeightChange) = 0; diff --git a/addons/dragging/functions/fnc_carryObjectPFH.sqf b/addons/dragging/functions/fnc_carryObjectPFH.sqf index 81b2369624..8afa0f541a 100644 --- a/addons/dragging/functions/fnc_carryObjectPFH.sqf +++ b/addons/dragging/functions/fnc_carryObjectPFH.sqf @@ -1,11 +1,19 @@ // by commy2 #include "script_component.hpp" +#ifdef DEBUG_ENABLED_DRAGGING + systemChat format ["%1 carryObjectPFH running", time]; +#endif + private ["_unit", "_target"]; _unit = _this select 0 select 0; _target = _this select 0 select 1; +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 { [_unit, _target] call FUNC(dropObject_carry); diff --git a/addons/dragging/functions/fnc_dragObject.sqf b/addons/dragging/functions/fnc_dragObject.sqf index bd27524fc6..9707eef64d 100644 --- a/addons/dragging/functions/fnc_dragObject.sqf +++ b/addons/dragging/functions/fnc_dragObject.sqf @@ -62,7 +62,7 @@ _actionID = _unit addAction [ _unit setVariable [QGVAR(ReleaseActionID), _actionID]; // check everything -[FUNC(dragObjectPFH), 0, [_unit, _target]] call CBA_fnc_addPerFrameHandler; +[FUNC(dragObjectPFH), 0.5, [_unit, _target]] call CBA_fnc_addPerFrameHandler; // reset current dragging height. GVAR(currentHeightChange) = 0; diff --git a/addons/dragging/functions/fnc_dragObjectPFH.sqf b/addons/dragging/functions/fnc_dragObjectPFH.sqf index e741b01f17..2290c65e9d 100644 --- a/addons/dragging/functions/fnc_dragObjectPFH.sqf +++ b/addons/dragging/functions/fnc_dragObjectPFH.sqf @@ -1,11 +1,19 @@ // by commy2 #include "script_component.hpp" +#ifdef DEBUG_ENABLED_DRAGGING + systemChat format ["%1 dragObjectPFH running", time]; +#endif + private ["_unit", "_target"]; _unit = _this select 0 select 0; _target = _this select 0 select 1; +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 { [_unit, _target] call FUNC(dropObject); diff --git a/addons/dragging/functions/fnc_startCarry.sqf b/addons/dragging/functions/fnc_startCarry.sqf index c9f6cbd718..9f1c0bca23 100644 --- a/addons/dragging/functions/fnc_startCarry.sqf +++ b/addons/dragging/functions/fnc_startCarry.sqf @@ -26,7 +26,7 @@ if (_weight > GETMVAR(ACE_maxWeightCarry,1E11)) exitWith { }; private "_timer"; -_timer = time + 2; +_timer = time + 5; // handle objects vs persons if (_target isKindOf "CAManBase") then { diff --git a/addons/dragging/functions/fnc_startCarryPFH.sqf b/addons/dragging/functions/fnc_startCarryPFH.sqf index a49d879631..a932d4e189 100644 --- a/addons/dragging/functions/fnc_startCarryPFH.sqf +++ b/addons/dragging/functions/fnc_startCarryPFH.sqf @@ -1,6 +1,10 @@ // by commy2 #include "script_component.hpp" +#ifdef DEBUG_ENABLED_DRAGGING + systemChat format ["%1 startCarryPFH running", time]; +#endif + private ["_unit", "_target", "_timeOut"]; _unit = _this select 0 select 0; @@ -18,11 +22,28 @@ if !([_target] call EFUNC(common,isAlive)) then { [_this select 1] call CBA_fnc_removePerFrameHandler; }; -// timeout. Done with lifting object. Start carrying process. -if (time > _timeOut) exitWith { - [_unit, _target] call FUNC(carryObject); +// handle persons vs objects +if (_target isKindOf "CAManBase") then { + if (time > _timeOut) exitWith { + [_unit, _target] call FUNC(carryObject); + + [_this select 1] call CBA_fnc_removePerFrameHandler; + }; +} else { + if (time > _timeOut) exitWith { + [_this select 1] call CBA_fnc_removePerFrameHandler; + + // drop if in timeout + private "_draggedObject"; + _draggedObject = _unit getVariable [QGVAR(draggedObject), objNull]; + [_unit, _draggedObject] call FUNC(dropObject); + }; + + // wait for the unit to stand up + if (stance _unit == "STAND") exitWith { + [_unit, _target] call FUNC(carryObject); + + [_this select 1] call CBA_fnc_removePerFrameHandler; + }; - [_this select 1] call CBA_fnc_removePerFrameHandler; }; - -// @todo, wait for stance _unit == "STAND" diff --git a/addons/dragging/functions/fnc_startDragPFH.sqf b/addons/dragging/functions/fnc_startDragPFH.sqf index 87c82f3e18..10d9d896a8 100644 --- a/addons/dragging/functions/fnc_startDragPFH.sqf +++ b/addons/dragging/functions/fnc_startDragPFH.sqf @@ -1,6 +1,10 @@ // by commy2 #include "script_component.hpp" +#ifdef DEBUG_ENABLED_DRAGGING + systemChat format ["%1 startDragPFH running", time]; +#endif + private ["_unit", "_target", "_timeOut"]; _unit = _this select 0 select 0; @@ -25,7 +29,6 @@ if (time > _timeOut) exitWith { // drop if in timeout private "_draggedObject"; _draggedObject = _unit getVariable [QGVAR(draggedObject), objNull]; - [_unit, _draggedObject] call FUNC(dropObject); }; diff --git a/addons/dragging/script_component.hpp b/addons/dragging/script_component.hpp index 7ba0013309..2427f89739 100644 --- a/addons/dragging/script_component.hpp +++ b/addons/dragging/script_component.hpp @@ -1,6 +1,8 @@ #define COMPONENT dragging #include "\z\ace\addons\main\script_mod.hpp" +//#define DEBUG_ENABLED_DRAGGING + #ifdef DEBUG_ENABLED_DRAGGING #define DEBUG_MODE_FULL #endif