From b00977eda04b38d01bc0024f8ec6845fddd8c11b Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sun, 4 Oct 2020 22:39:52 +0200 Subject: [PATCH 1/7] Create clones for corpse carrying/dragging --- addons/dragging/CfgVehicles.hpp | 3 +++ addons/dragging/XEH_PREP.hpp | 2 ++ addons/dragging/XEH_postInit.sqf | 8 ++++++ addons/dragging/functions/fnc_canCarry.sqf | 2 +- addons/dragging/functions/fnc_canDrag.sqf | 2 +- addons/dragging/functions/fnc_carryObject.sqf | 3 +++ addons/dragging/functions/fnc_createClone.sqf | 26 +++++++++++++++++++ addons/dragging/functions/fnc_dropClone.sqf | 26 +++++++++++++++++++ addons/dragging/functions/fnc_dropObject.sqf | 5 ++++ .../functions/fnc_dropObject_carry.sqf | 5 ++++ addons/dragging/functions/fnc_startCarry.sqf | 4 +++ addons/dragging/functions/fnc_startDrag.sqf | 5 ++++ 12 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 addons/dragging/functions/fnc_createClone.sqf create mode 100644 addons/dragging/functions/fnc_dropClone.sqf diff --git a/addons/dragging/CfgVehicles.hpp b/addons/dragging/CfgVehicles.hpp index 4c43dd814ea..d83fca3389c 100644 --- a/addons/dragging/CfgVehicles.hpp +++ b/addons/dragging/CfgVehicles.hpp @@ -2,6 +2,9 @@ class CBA_Extended_EventHandlers; class CfgVehicles { + class C_man_1; + class GVAR(clone): C_man_1 {}; + // Static weapons class LandVehicle; class StaticWeapon: LandVehicle { diff --git a/addons/dragging/XEH_PREP.hpp b/addons/dragging/XEH_PREP.hpp index b04c15e7ec3..f9fbd4529c7 100644 --- a/addons/dragging/XEH_PREP.hpp +++ b/addons/dragging/XEH_PREP.hpp @@ -5,8 +5,10 @@ PREP(canDrop); PREP(canDrop_carry); PREP(carryObject); PREP(carryObjectPFH); +PREP(createClone); PREP(dragObject); PREP(dragObjectPFH); +PREP(dropClone); PREP(dropObject); PREP(dropObject_carry); PREP(getWeight); diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index dd782eddb2f..7828d441b60 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -27,6 +27,14 @@ if (isNil "ACE_maxWeightCarry") then { // handle waking up dragged unit and falling unconscious while dragging ["ace_unconscious", {_this call FUNC(handleUnconscious)}] call CBA_fnc_addEventHandler; +// handle local effect commands for clones +[QGVAR(cloneCreated), { + params ["_unit", "_clone"]; + + _clone setFace face _unit; + _clone setMimic "unconscious"; +}] call CBA_fnc_addEventHandler; + // display event handler ["MouseZChanged", {_this select 1 call FUNC(handleScrollWheel)}] call CBA_fnc_addDisplayHandler; diff --git a/addons/dragging/functions/fnc_canCarry.sqf b/addons/dragging/functions/fnc_canCarry.sqf index b5edbd800c5..1bb10f93773 100644 --- a/addons/dragging/functions/fnc_canCarry.sqf +++ b/addons/dragging/functions/fnc_canCarry.sqf @@ -27,4 +27,4 @@ if ((_unit getHitPointDamage "HitLegs") >= 0.5) exitWith {false}; // a static weapon has to be empty for dragging (ignore UAV AI) if (((typeOf _target) isKindOf "StaticWeapon") && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false}; -alive _target && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})} +(alive _target || {_target isKindOf "CAManBase"}) && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious", "deadstate"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})} diff --git a/addons/dragging/functions/fnc_canDrag.sqf b/addons/dragging/functions/fnc_canDrag.sqf index dbae83521b3..b43f5e71c78 100644 --- a/addons/dragging/functions/fnc_canDrag.sqf +++ b/addons/dragging/functions/fnc_canDrag.sqf @@ -23,4 +23,4 @@ if !([_unit, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)) exi // a static weapon has to be empty for dragging (ignore UAV AI) if ((typeOf _target) isKindOf "StaticWeapon" && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false}; -alive _target && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})} +(alive _target || {_target isKindOf "CAManBase"}) && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious", "deadstate"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})} diff --git a/addons/dragging/functions/fnc_carryObject.sqf b/addons/dragging/functions/fnc_carryObject.sqf index e3f8c2b61ec..121b673cf99 100644 --- a/addons/dragging/functions/fnc_carryObject.sqf +++ b/addons/dragging/functions/fnc_carryObject.sqf @@ -26,6 +26,9 @@ private _direction = _target getVariable [QGVAR(carryDirection), 0]; // handle objects vs persons if (_target isKindOf "CAManBase") then { + if (!alive _target) then { + _target = [_target] call FUNC(createClone); + }; [_unit, "AcinPercMstpSnonWnonDnon", 2, true] call EFUNC(common,doAnimation); [_target, "AinjPfalMstpSnonWnonDf_carried_dead", 2, true] call EFUNC(common,doAnimation); diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf new file mode 100644 index 00000000000..bf38fa42e1d --- /dev/null +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -0,0 +1,26 @@ +#include "script_component.hpp" +/* + * Author: BaerMitUmlaut + * Creates a draggable / carryable clone of a dead unit. + * + * Arguments: + * 0: Dead unit + * + * Return Value: + * Cloned unit. + * + * Example: + * [player] call ace_dragging_fnc_createClone; + * + * Public: No + */ +params ["_unit"]; + +private _clone = QGVAR(clone) createVehicle [0, 0, 0]; +_clone setUnitLoadout getUnitLoadout _unit; +_clone setVariable [QGVAR(original), _unit]; +_unit hideObjectGlobal true; + +[QGVAR(cloneCreated), [_unit, _clone]] call CBA_fnc_globalEvent; + +_clone diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf new file mode 100644 index 00000000000..5438a512907 --- /dev/null +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -0,0 +1,26 @@ +#include "script_component.hpp" +/* + * Author: BaerMitUmlaut + * Drops a draggable / carryable clone of a dead unit. + * + * Arguments: + * 0: Clone + * + * Return Value: + * Original unit. + * + * Example: + * [player] call ace_dragging_fnc_createClone; + * + * Public: No + */ +params ["_clone"]; + +private _unit = _clone getVariable [QGVAR(original), objNull]; +_unit setPosASL getPosASL _clone; +_unit hideObjectGlobal false; + +detach _clone; +deleteVehicle _clone; + +_unit diff --git a/addons/dragging/functions/fnc_dropObject.sqf b/addons/dragging/functions/fnc_dropObject.sqf index 4ecc876afd9..18ec97fe481 100644 --- a/addons/dragging/functions/fnc_dropObject.sqf +++ b/addons/dragging/functions/fnc_dropObject.sqf @@ -24,6 +24,11 @@ TRACE_2("params",_unit,_target); private _inBuilding = [_unit] call FUNC(isObjectOnObject); +// drop cloned dead units +if (_target isKindOf QGVAR(clone)) then { + _target = [_target] call FUNC(dropClone); +}; + if !(_unit getVariable ["ACE_isUnconscious", false]) then { // play release animation [_unit, "released"] call EFUNC(common,doGesture); diff --git a/addons/dragging/functions/fnc_dropObject_carry.sqf b/addons/dragging/functions/fnc_dropObject_carry.sqf index 5235b7e66df..66880cd0ddd 100644 --- a/addons/dragging/functions/fnc_dropObject_carry.sqf +++ b/addons/dragging/functions/fnc_dropObject_carry.sqf @@ -24,6 +24,11 @@ TRACE_1("params",_this); private _inBuilding = [_unit] call FUNC(isObjectOnObject); +// drop cloned dead units +if (_target isKindOf QGVAR(clone)) then { + _target = [_target] call FUNC(dropClone); +}; + // prevent collision damage [QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent; [QEGVAR(common,fixCollision), _target, _target] call CBA_fnc_targetEvent; diff --git a/addons/dragging/functions/fnc_startCarry.sqf b/addons/dragging/functions/fnc_startCarry.sqf index a52afd1c27e..b184a1e7bb9 100644 --- a/addons/dragging/functions/fnc_startCarry.sqf +++ b/addons/dragging/functions/fnc_startCarry.sqf @@ -32,6 +32,10 @@ private _timer = CBA_missionTime + 5; // handle objects vs persons if (_target isKindOf "CAManBase") then { + // create clone for dead units + if (!alive _target) then { + _target = [_target] call FUNC(createClone); + }; // add a primary weapon if the unit has none. if (primaryWeapon _unit isEqualto "") then { diff --git a/addons/dragging/functions/fnc_startDrag.sqf b/addons/dragging/functions/fnc_startDrag.sqf index 7a4c8908d33..c09d921a837 100644 --- a/addons/dragging/functions/fnc_startDrag.sqf +++ b/addons/dragging/functions/fnc_startDrag.sqf @@ -28,6 +28,11 @@ if (!GETVAR(_target,GVAR(ignoreWeightDrag),false) && { [localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); }; +// create clone for dead units +if (!alive _target) then { + _target = [_target] call FUNC(createClone); +}; + // add a primary weapon if the unit has none. // @todo prevent opening inventory when equipped with a fake weapon if (primaryWeapon _unit isEqualto "") then { From 905e8cae82939c30bb0e28503b23edf5e6188196 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Mon, 5 Oct 2020 10:35:44 +0200 Subject: [PATCH 2/7] Fix doccomment for dropClone Co-authored-by: Dystopian --- addons/dragging/functions/fnc_dropClone.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index 5438a512907..97cdebf334d 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -10,7 +10,7 @@ * Original unit. * * Example: - * [player] call ace_dragging_fnc_createClone; + * [player] call ace_dragging_fnc_dropClone; * * Public: No */ From 3fa5b6958c8a36efab5f08344c26f18db3bc285f Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Mon, 5 Oct 2020 10:36:49 +0200 Subject: [PATCH 3/7] Remove duplicate clone Co-authored-by: Dystopian --- addons/dragging/functions/fnc_carryObject.sqf | 3 --- 1 file changed, 3 deletions(-) diff --git a/addons/dragging/functions/fnc_carryObject.sqf b/addons/dragging/functions/fnc_carryObject.sqf index 121b673cf99..e3f8c2b61ec 100644 --- a/addons/dragging/functions/fnc_carryObject.sqf +++ b/addons/dragging/functions/fnc_carryObject.sqf @@ -26,9 +26,6 @@ private _direction = _target getVariable [QGVAR(carryDirection), 0]; // handle objects vs persons if (_target isKindOf "CAManBase") then { - if (!alive _target) then { - _target = [_target] call FUNC(createClone); - }; [_unit, "AcinPercMstpSnonWnonDnon", 2, true] call EFUNC(common,doAnimation); [_target, "AinjPfalMstpSnonWnonDf_carried_dead", 2, true] call EFUNC(common,doAnimation); From 28e0491d3e6ef43e36cf42d3f8b8be7ec2acf6fb Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sun, 11 Oct 2020 20:37:59 +0200 Subject: [PATCH 4/7] Add comment with reasoning for detach before delete --- addons/dragging/functions/fnc_dropClone.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index 97cdebf334d..83817babb26 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -20,6 +20,7 @@ private _unit = _clone getVariable [QGVAR(original), objNull]; _unit setPosASL getPosASL _clone; _unit hideObjectGlobal false; +// Detach first to prevent objNull in attachedObjects detach _clone; deleteVehicle _clone; From efd71c617965e2b668cfed36faf997720a6fc72f Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sun, 11 Oct 2020 20:42:34 +0200 Subject: [PATCH 5/7] Bury corpse to prevent desecration --- addons/dragging/functions/fnc_createClone.sqf | 2 +- addons/dragging/functions/fnc_dropClone.sqf | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index bf38fa42e1d..c42b17e5868 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -19,7 +19,7 @@ params ["_unit"]; private _clone = QGVAR(clone) createVehicle [0, 0, 0]; _clone setUnitLoadout getUnitLoadout _unit; _clone setVariable [QGVAR(original), _unit]; -_unit hideObjectGlobal true; +_unit setPosATL [0, 0, -10]; [QGVAR(cloneCreated), [_unit, _clone]] call CBA_fnc_globalEvent; diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index 83817babb26..d0eeb71d2c7 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -18,7 +18,6 @@ params ["_clone"]; private _unit = _clone getVariable [QGVAR(original), objNull]; _unit setPosASL getPosASL _clone; -_unit hideObjectGlobal false; // Detach first to prevent objNull in attachedObjects detach _clone; From 2d30be436c68ad491bf665a18e35b908bea9dced Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sun, 11 Oct 2020 20:44:35 +0200 Subject: [PATCH 6/7] Prevent screams of agony from dragged corpse --- addons/dragging/functions/fnc_createClone.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index c42b17e5868..eca1c2025de 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -18,6 +18,7 @@ params ["_unit"]; private _clone = QGVAR(clone) createVehicle [0, 0, 0]; _clone setUnitLoadout getUnitLoadout _unit; +_clone allowDamage false; _clone setVariable [QGVAR(original), _unit]; _unit setPosATL [0, 0, -10]; From 5f96644422e89adc1a2a223ac40d66d99b23133b Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Wed, 19 Jul 2023 17:47:18 +0200 Subject: [PATCH 7/7] Corpse carrying continued --- addons/common/XEH_postInit.sqf | 5 ++ addons/dragging/CfgEventHandlers.hpp | 15 +++-- addons/dragging/CfgVehicles.hpp | 23 ++++--- addons/dragging/XEH_PREP.hpp | 1 - addons/dragging/XEH_postInit.sqf | 42 ++++++++----- addons/dragging/config.cpp | 2 +- addons/dragging/functions/fnc_canCarry.sqf | 18 +++--- addons/dragging/functions/fnc_canDrag.sqf | 14 ++--- addons/dragging/functions/fnc_canDrop.sqf | 8 +-- .../dragging/functions/fnc_canDrop_carry.sqf | 8 +-- addons/dragging/functions/fnc_carryObject.sqf | 39 ++++++------ .../dragging/functions/fnc_carryObjectPFH.sqf | 49 +++++++++------ addons/dragging/functions/fnc_createClone.sqf | 26 ++++++-- addons/dragging/functions/fnc_dragObject.sqf | 37 ++++++----- .../dragging/functions/fnc_dragObjectPFH.sqf | 25 ++++---- addons/dragging/functions/fnc_dropClone.sqf | 35 ++++++++--- addons/dragging/functions/fnc_dropObject.sqf | 41 ++++++------ .../functions/fnc_dropObject_carry.sqf | 63 ++++++++++--------- addons/dragging/functions/fnc_getWeight.sqf | 4 +- .../functions/fnc_handleAnimChanged.sqf | 15 ++--- .../dragging/functions/fnc_handleKilled.sqf | 4 +- .../functions/fnc_handlePlayerChanged.sqf | 2 +- .../fnc_handlePlayerWeaponChanged.sqf | 15 ++--- .../functions/fnc_handleScrollWheel.sqf | 17 +++-- .../functions/fnc_handleUnconscious.sqf | 14 ++--- addons/dragging/functions/fnc_initObject.sqf | 6 +- addons/dragging/functions/fnc_initPerson.sqf | 6 +- .../functions/fnc_isObjectOnObject.sqf | 6 +- .../dragging/functions/fnc_setCarryable.sqf | 27 ++++---- .../dragging/functions/fnc_setDraggable.sqf | 23 ++++--- addons/dragging/functions/fnc_startCarry.sqf | 62 ++++++++++-------- .../dragging/functions/fnc_startCarryPFH.sqf | 31 ++++----- addons/dragging/functions/fnc_startDrag.sqf | 54 ++++++++-------- .../dragging/functions/fnc_startDragPFH.sqf | 29 ++++----- addons/dragging/initSettings.sqf | 5 +- 35 files changed, 420 insertions(+), 351 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 00d1a4406b6..8e55a44595b 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -120,6 +120,11 @@ _object setMass _mass; }] call CBA_fnc_addEventHandler; +[QGVAR(awake), { + params ["_object", "_awake"]; + _object awake _awake; +}] call CBA_fnc_addEventHandler; + //Add a fix for BIS's zeus remoteControl module not reseting variables on DC when RC a unit //This variable is used for isPlayer checks if (isServer) then { diff --git a/addons/dragging/CfgEventHandlers.hpp b/addons/dragging/CfgEventHandlers.hpp index 8903f2ded8f..94ebf2cda64 100644 --- a/addons/dragging/CfgEventHandlers.hpp +++ b/addons/dragging/CfgEventHandlers.hpp @@ -1,4 +1,3 @@ - class Extended_PreStart_EventHandlers { class ADDON { init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); @@ -20,34 +19,34 @@ class Extended_PostInit_EventHandlers { class Extended_Init_EventHandlers { class CAManBase { class ADDON { - init = QUOTE(_this call DFUNC(initPerson)); + init = QUOTE(_this call FUNC(initPerson)); exclude[] = {"VirtualMan_F"}; }; }; class StaticWeapon { class ADDON { - init = QUOTE(_this call DFUNC(initObject)); + init = QUOTE(_this call FUNC(initObject)); }; }; class Thing { class ADDON { - init = QUOTE(_this call DFUNC(initObject)); + init = QUOTE(_this call FUNC(initObject)); exclude[] = {"ModuleEmpty_F", "ThingEffect", "Wreck"}; }; }; class NonStrategic { class ADDON { - init = QUOTE(_this call DFUNC(initObject)); + init = QUOTE(_this call FUNC(initObject)); }; }; class WeaponHolder { class ADDON { - init = QUOTE(_this call DFUNC(initObject)); + init = QUOTE(_this call FUNC(initObject)); }; }; class Land_Camping_Light_F { class ADDON { - init = QUOTE(_this call DFUNC(initObject)); + init = QUOTE(_this call FUNC(initObject)); }; }; }; @@ -55,7 +54,7 @@ class Extended_Init_EventHandlers { class Extended_Killed_EventHandlers { class CAManBase { class ADDON { - killed = QUOTE(_this call DFUNC(handleKilled)); + killed = QUOTE(_this call FUNC(handleKilled)); }; }; }; diff --git a/addons/dragging/CfgVehicles.hpp b/addons/dragging/CfgVehicles.hpp index 0e83e3eaea3..bd9758447bf 100644 --- a/addons/dragging/CfgVehicles.hpp +++ b/addons/dragging/CfgVehicles.hpp @@ -75,7 +75,7 @@ class CfgVehicles { GVAR(canDrag) = 0; }; - // ammo boxes + // Ammo boxes class ThingX; class Items_base_F; class ReammoBox_F: ThingX { @@ -89,7 +89,7 @@ class CfgVehicles { GVAR(canCarry) = 0; GVAR(canDrag) = 0; }; - //remove actions from Taru Pods + // Remove actions from Taru Pods class Pod_Heli_Transport_04_base_F: Slingload_base_F { GVAR(canCarry) = 0; GVAR(canDrag) = 0; @@ -163,7 +163,7 @@ class CfgVehicles { GVAR(canDrag) = 0; }; - //Plastic and metal case + // Plastic and metal case class PlasticCase_01_base_F: Items_base_F { GVAR(canCarry) = 1; GVAR(carryDirection) = 270; @@ -229,22 +229,22 @@ class CfgVehicles { GVAR(canCarry) = 1; }; - // weapons dropped from dead body + // Weapons dropped from dead body class WeaponHolderSimulated: ThingX { GVAR(canCarry) = 1; GVAR(carryPosition[]) = {0,0.5,1.3}; GVAR(carryDirection) = 0; - // z-position floats from -1.2 to >0 - // it's OK for carrying but odd for dragging - // needs workaround to drag correctly. Disabled ATM + // z-position floats from -1.2 to > 0 + // It's OK for carrying but odd for dragging + // Needs workaround to drag correctly. Disabled ATM GVAR(canDrag) = 0; GVAR(dragPosition[]) = {0,1,0}; GVAR(dragDirection) = 0; }; class ReammoBox; - // dropped weapons/gear + // Dropped weapons/gear class WeaponHolder: ReammoBox { GVAR(canCarry) = 1; GVAR(carryPosition[]) = {0,0.5,1}; @@ -268,7 +268,7 @@ class CfgVehicles { class FloatingStructure_F; class Land_Camping_Light_F: FloatingStructure_F { GVAR(canCarry) = 1; - // if y < 0.9 player gets damage + // If y < 0.9 player gets damaged GVAR(carryPosition)[] = {0,0.9,1}; GVAR(canDrag) = 1; @@ -291,8 +291,7 @@ class CfgVehicles { GVAR(dragPosition)[] = {0,1,0}; }; - // some terrain objects - + // Some terrain objects class Land_CampingTable_F: ThingX { EGVAR(interaction,replaceTerrainObject) = 1; GVAR(canCarry) = 1; @@ -403,8 +402,8 @@ class CfgVehicles { GVAR(canDrag) = 1; }; - // static classes need XEH + // Static classes need XEH class NonStrategic; class Land_Pallets_F: NonStrategic { XEH_INHERITED; diff --git a/addons/dragging/XEH_PREP.hpp b/addons/dragging/XEH_PREP.hpp index f9fbd4529c7..cbb927494db 100644 --- a/addons/dragging/XEH_PREP.hpp +++ b/addons/dragging/XEH_PREP.hpp @@ -1,4 +1,3 @@ - PREP(canCarry); PREP(canDrag); PREP(canDrop); diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index 9e487fd6a5b..ffd8542c6a6 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -1,9 +1,14 @@ // by PabstMirror, commy2 #include "script_component.hpp" +// Release object on disconnection. Function is identical to killed if (isServer) then { - // release object on hard disconnection. Function is identical to killed - addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleKilled)}]; + // 'HandleDisconnect' EH triggers too late + addMissionEventHandler ["PlayerDisconnected", { + private _unit = (getUserInfo (_this select 5)) select 10; + + _unit call FUNC(handleKilled); + }]; }; if (!hasInterface) exitWith {}; @@ -15,6 +20,7 @@ if (isNil "ACE_maxWeightDrag") then { if (isNil "ACE_maxWeightCarry") then { ACE_maxWeightCarry = 600; }; + if (isNil QGVAR(maxWeightCarryRun)) then { GVAR(maxWeightCarryRun) = 50; }; @@ -22,15 +28,15 @@ if (isNil QGVAR(maxWeightCarryRun)) then { ["isNotDragging", {!((_this select 0) getVariable [QGVAR(isDragging), false])}] call EFUNC(common,addCanInteractWithCondition); ["isNotCarrying", {!((_this select 0) getVariable [QGVAR(isCarrying), false])}] call EFUNC(common,addCanInteractWithCondition); -// release object on player change. This does work when returning to lobby, but not when hard disconnecting. -["unit", FUNC(handlePlayerChanged)] call CBA_fnc_addPlayerEventHandler; +// Release object on player change. This does work when returning to lobby, but not when hard disconnecting. +["unit", LINKFUNC(handlePlayerChanged)] call CBA_fnc_addPlayerEventHandler; ["vehicle", {[ACE_player, objNull] call FUNC(handlePlayerChanged)}] call CBA_fnc_addPlayerEventHandler; -["weapon", FUNC(handlePlayerWeaponChanged)] call CBA_fnc_addPlayerEventHandler; +["weapon", LINKFUNC(handlePlayerWeaponChanged)] call CBA_fnc_addPlayerEventHandler; -// handle waking up dragged unit and falling unconscious while dragging -["ace_unconscious", {_this call FUNC(handleUnconscious)}] call CBA_fnc_addEventHandler; +// Handle waking up dragged unit and falling unconscious while dragging +["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler; -// handle local effect commands for clones +// Handle local effect commands for clones [QGVAR(cloneCreated), { params ["_unit", "_clone"]; @@ -38,13 +44,13 @@ if (isNil QGVAR(maxWeightCarryRun)) then { _clone setMimic "unconscious"; }] call CBA_fnc_addEventHandler; -// display event handler -["MouseZChanged", {_this select 1 call FUNC(handleScrollWheel)}] call CBA_fnc_addDisplayHandler; +// Display event handler +["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}] call CBA_fnc_addDisplayHandler; //@todo Captivity? -//Add Keybind: -["ACE3 Common", QGVAR(drag), (localize LSTRING(DragKeybind)), { +// Add Keybind: +["ACE3 Common", QGVAR(drag), LLSTRING(DragKeybind), { if (!alive ACE_player) exitWith {false}; if !([ACE_player, objNull, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {false}; @@ -53,20 +59,23 @@ if (isNil QGVAR(maxWeightCarryRun)) then { [ACE_player, ACE_player getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject); false }; + if (ACE_player getVariable [QGVAR(isCarrying), false]) exitWith { [ACE_player, ACE_player getVariable [QGVAR(carriedObject), objNull]] call FUNC(dropObject_carry); false }; private _cursor = cursorObject; + if ((isNull _cursor) || {(_cursor distance ACE_player) > 2.6}) exitWith {false}; - if (!([ACE_player, _cursor] call FUNC(canDrag))) exitWith {false}; + if !([ACE_player, _cursor] call FUNC(canDrag)) exitWith {false}; [ACE_player, _cursor] call FUNC(startDrag); + false }, {}, [-1, [false, false, false]]] call CBA_fnc_addKeybind; // UNBOUND -["ACE3 Common", QGVAR(carry), (localize LSTRING(CarryKeybind)), { +["ACE3 Common", QGVAR(carry), LLSTRING(CarryKeybind), { if (!alive ACE_player) exitWith {false}; if !([ACE_player, objNull, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {false}; @@ -75,15 +84,18 @@ if (isNil QGVAR(maxWeightCarryRun)) then { [ACE_player, ACE_player getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject); false }; + if (ACE_player getVariable [QGVAR(isCarrying), false]) exitWith { [ACE_player, ACE_player getVariable [QGVAR(carriedObject), objNull], true] call FUNC(dropObject_carry); false }; private _cursor = cursorObject; + if ((isNull _cursor) || {(_cursor distance ACE_player) > 2.6}) exitWith {false}; - if (!([ACE_player, _cursor] call FUNC(canCarry))) exitWith {false}; + if !([ACE_player, _cursor] call FUNC(canCarry)) exitWith {false}; [ACE_player, _cursor] call FUNC(startCarry); + false }, {}, [-1, [false, false, false]]] call CBA_fnc_addKeybind; // UNBOUND diff --git a/addons/dragging/config.cpp b/addons/dragging/config.cpp index 26e5e2c88fb..770a9e958c2 100644 --- a/addons/dragging/config.cpp +++ b/addons/dragging/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_interaction"}; + requiredAddons[] = {"ace_interaction","ace_cargo"}; author = ECSTRING(common,ACETeam); authors[] = {"Garth 'L-H' de Wet", "commy2", "PiZZADOX", "Malbryn"}; url = ECSTRING(main,URL); diff --git a/addons/dragging/functions/fnc_canCarry.sqf b/addons/dragging/functions/fnc_canCarry.sqf index 8254f412979..bb4f0b2eec3 100644 --- a/addons/dragging/functions/fnc_canCarry.sqf +++ b/addons/dragging/functions/fnc_canCarry.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2, Dystopian - * Check if unit can carry the object. Doesn't check weight. + * Checks if unit can carry the object. Doesn't check weight. * * Arguments: * 0: Unit that should do the carrying @@ -11,31 +11,31 @@ * Can the unit carry the object? * * Example: - * [player, cursorTarget] call ace_dragging_fnc_canCarry + * [player, cursorObject] call ace_dragging_fnc_canCarry * * Public: No */ params ["_unit", "_target"]; -if !(alive _target && {_target getVariable [QGVAR(canCarry), false]} && {isNull objectParent _target}) exitWith {false}; +if !((alive _target || {_target isKindOf "CAManBase"}) && {_target getVariable [QGVAR(canCarry), false]} && {isNull objectParent _target}) exitWith {false}; if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false}; -//#2644 - Units with injured legs cannot bear the extra weight of carrying an object -//The fireman carry animation does not slow down for injured legs, so you could carry and run +// #2644 - Units with injured legs cannot bear the extra weight of carrying an object +// The fireman carry animation does not slow down for injured legs, so you could carry and run if ((_unit getHitPointDamage "HitLegs") >= 0.5) exitWith {false}; // Static weapons need to be empty for carrying (ignore UAV AI) if (_target isKindOf "StaticWeapon") exitWith { - crew _target findIf {getText (configOf _x >> "simulation") != "UAVPilot"} == -1 + (crew _target) findIf {getText (configOf _x >> "simulation") != "UAVPilot"} == -1 }; // Units need to be unconscious or limping if (_target isKindOf "CAManBase") exitWith { - lifeState _target isEqualTo "INCAPACITATED" || + lifeState _target == "INCAPACITATED" || {_target getHitPointDamage "HitLegs" >= 0.5} || - {animationState _target in ["", "unconscious", "deadstate"]} // Look at again + {(animationState _target) in ["", "unconscious", "deadstate"]} }; // Check max items for WeaponHolders @@ -43,4 +43,4 @@ if (["WeaponHolder", "WeaponHolderSimulated"] findIf {_target isKindOf _x} != -1 (count (weaponCargo _target + magazineCargo _target + itemCargo _target)) <= MAX_DRAGGED_ITEMS }; -true // return +true // Return diff --git a/addons/dragging/functions/fnc_canDrag.sqf b/addons/dragging/functions/fnc_canDrag.sqf index 4d68730acdd..33e5bffd5a0 100644 --- a/addons/dragging/functions/fnc_canDrag.sqf +++ b/addons/dragging/functions/fnc_canDrag.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2, Dystopian - * Check if unit can drag the object. Doesn't check weight. + * Checks if unit can drag the object. Doesn't check weight. * * Arguments: * 0: Unit that should do the dragging @@ -11,27 +11,27 @@ * Can the unit drag the object? * * Example: - * [player, cursorTarget] call ace_dragging_fnc_canDrag + * [player, cursorObject] call ace_dragging_fnc_canDrag * * Public: No */ params ["_unit", "_target"]; -if !(alive _target && {_target getVariable [QGVAR(canDrag), false]} && {isNull objectParent _target}) exitWith {false}; +if !((alive _target || {_target isKindOf "CAManBase"}) && {_target getVariable [QGVAR(canDrag), false]} && {isNull objectParent _target}) exitWith {false}; if !([_unit, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Static weapons need to be empty for dragging (ignore UAV AI) if (_target isKindOf "StaticWeapon") exitWith { - crew _target findIf {getText (configOf _x >> "simulation") != "UAVPilot"} == -1 + (crew _target) findIf {getText (configOf _x >> "simulation") != "UAVPilot"} == -1 }; // Units need to be unconscious or limping if (_target isKindOf "CAManBase") exitWith { - lifeState _target isEqualTo "INCAPACITATED" || + lifeState _target == "INCAPACITATED" || {_target getHitPointDamage "HitLegs" >= 0.5} || - {animationState _target in ["", "unconscious", "deadstate"]} + {(animationState _target) in ["", "unconscious", "deadstate"]} }; // Check max items for WeaponHolders @@ -39,4 +39,4 @@ if (["WeaponHolder", "WeaponHolderSimulated"] findIf {_target isKindOf _x} != -1 (count (weaponCargo _target + magazineCargo _target + itemCargo _target)) <= MAX_DRAGGED_ITEMS }; -true // return +true // Return diff --git a/addons/dragging/functions/fnc_canDrop.sqf b/addons/dragging/functions/fnc_canDrop.sqf index 2d42ae6244e..b3adc104954 100644 --- a/addons/dragging/functions/fnc_canDrop.sqf +++ b/addons/dragging/functions/fnc_canDrop.sqf @@ -1,17 +1,17 @@ #include "script_component.hpp" /* * Author: commy2 - * Check if unit can drop the object. + * Checks if unit can drop the dragged object. * * Arguments: - * 0: Unit that currently drags a object - * 1: Object that is dragged + * 0: Unit that is currently dragging an object + * 1: Object being dragged * * Return Value: * Can the unit drop the object? * * Example: - * [player, cursorTarget] call ace_dragging_fnc_canDrop; + * [player, cursorObject] call ace_dragging_fnc_canDrop; * * Public: No */ diff --git a/addons/dragging/functions/fnc_canDrop_carry.sqf b/addons/dragging/functions/fnc_canDrop_carry.sqf index 89be866ea61..c775def69b9 100644 --- a/addons/dragging/functions/fnc_canDrop_carry.sqf +++ b/addons/dragging/functions/fnc_canDrop_carry.sqf @@ -1,17 +1,17 @@ #include "script_component.hpp" /* * Author: commy2 - * Check if unit can drop the carried object. + * Checks if unit can drop the carried object. * * Arguments: - * 0: Unit that currently carries a object - * 1: Object that is carried + * 0: Unit that is currently carrying an object + * 1: Object being carried * * Return Value: * Can the unit drop the object? * * Example: - * [player, cursorTarget] call ace_dragging_fnc_canDrop_carry; + * [player, cursorObject] call ace_dragging_fnc_canDrop_carry; * * Public: No */ diff --git a/addons/dragging/functions/fnc_carryObject.sqf b/addons/dragging/functions/fnc_carryObject.sqf index 7e783bd0c51..d294ba0e00b 100644 --- a/addons/dragging/functions/fnc_carryObject.sqf +++ b/addons/dragging/functions/fnc_carryObject.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2 - * Carry an object. + * Carries an object. * * Arguments: * 0: Unit that should do the carrying @@ -11,7 +11,7 @@ * None * * Example: - * [player, cursorTarget] call ace_dragging_fnc_carryObject; + * [player, cursorObject] call ace_dragging_fnc_carryObject; * * Public: No */ @@ -19,56 +19,55 @@ params ["_unit", "_target"]; TRACE_2("params",_unit,_target); -// get attachTo offset and direction. - +// Get attachTo offset and direction private _position = _target getVariable [QGVAR(carryPosition), [0, 0, 0]]; private _direction = _target getVariable [QGVAR(carryDirection), 0]; -// handle objects vs persons +// Handle objects vs. persons if (_target isKindOf "CAManBase") then { - [_unit, "AcinPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); [_target, "AinjPfalMstpSnonWnonDf_carried_dead", 2] call EFUNC(common,doAnimation); - // attach person + // Attach person _target attachTo [_unit, _position, "LeftShoulder"]; - } else { - - // add height offset of model - private _offset = (_target modelToWorldVisual [0, 0, 0] select 2) - (_unit modelToWorldVisual [0, 0, 0] select 2); + // Add height offset of model + private _offset = ((_target modelToWorldVisual [0, 0, 0]) select 2) - ((_unit modelToWorldVisual [0, 0, 0]) select 2); _position = _position vectorAdd [0, 0, _offset]; - // attach object + // Attach object _target attachTo [_unit, _position]; - }; + [QEGVAR(common,setDir), [_target, _direction], _target] call CBA_fnc_targetEvent; _unit setVariable [QGVAR(isCarrying), true, true]; _unit setVariable [QGVAR(carriedObject), _target, true]; -// add drop action -_unit setVariable [QGVAR(ReleaseActionID), [ +// Add drop action +_unit setVariable [QGVAR(releaseActionID), [ _unit, "DefaultAction", {!isNull ((_this select 0) getVariable [QGVAR(carriedObject), objNull])}, {[_this select 0, (_this select 0) getVariable [QGVAR(carriedObject), objNull], true] call FUNC(dropObject_carry)} ] call EFUNC(common,addActionEventHandler)]; -// add anim changed EH +// Add anim changed EH [_unit, "AnimChanged", FUNC(handleAnimChanged), [_unit]] call CBA_fnc_addBISEventHandler; -// check everything +// Check everything [FUNC(carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler; -// reset current dragging height. +// Reset current dragging height GVAR(currentHeightChange) = 0; -// prevent UAVs from firing +// Prevent UAVs from firing private _UAVCrew = _target call EFUNC(common,getVehicleUAVCrew); if (_UAVCrew isNotEqualTo []) then { - {_target deleteVehicleCrew _x} count _UAVCrew; + { + _target deleteVehicleCrew _x; + } forEach _UAVCrew; + _target setVariable [QGVAR(isUAV), true, true]; }; diff --git a/addons/dragging/functions/fnc_carryObjectPFH.sqf b/addons/dragging/functions/fnc_carryObjectPFH.sqf index 072b688b9d0..8614e74c886 100644 --- a/addons/dragging/functions/fnc_carryObjectPFH.sqf +++ b/addons/dragging/functions/fnc_carryObjectPFH.sqf @@ -1,20 +1,20 @@ #include "script_component.hpp" /* * Author: commy2 - * PFH for Carry Object + * PFH for carrying an object. * * Arguments: - * 0: ARGS - * 0: Unit - * 1: Target - * 2: Start time + * 0: Arguments + * 0.0: Unit + * 0.1: Target + * 0.2: Start time * 1: PFEH Id * * Return Value: * None * * Example: - * [[player, target], 20] call ace_dragging_fnc_carryObjectPFH; + * [[player, cursorObject, CBA_missionTime], _idPFH] call ace_dragging_fnc_carryObjectPFH; * * Public: No */ @@ -28,33 +28,40 @@ _args params ["_unit", "_target", "_startTime"]; if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith { TRACE_2("carry false",_unit,_target); + _unit setVariable [QGVAR(hint), nil]; - [] call EFUNC(interaction,hideMouseHint); - [_idPFH] call CBA_fnc_removePerFrameHandler; + call EFUNC(interaction,hideMouseHint); + + _idPFH call CBA_fnc_removePerFrameHandler; }; -// drop if the crate is destroyed OR target moved away from carrier (weapon disassembled) OR carrier starts limping +// Drop if the crate is destroyed OR target moved away from carrier (weapon disassembled) OR carrier starts limping if !(alive _target && {_unit distance _target <= 10} && {_unit getHitPointDamage "HitLegs" < 0.5}) exitWith { TRACE_2("dead/distance",_unit,_target); + if ((_unit distance _target > 10) && {(CBA_missionTime - _startTime) < 1}) exitWith { - //attachTo seems to have some kind of network delay and target can return an odd position during the first few frames, - //so wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos) + // attachTo seems to have some kind of network delay and target can return an odd position during the first few frames, + // So wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos) TRACE_3("ignoring bad distance at start",_unit distance _target,_startTime,CBA_missionTime); }; + [_unit, _target] call FUNC(dropObject_carry); + _unit setVariable [QGVAR(hint), nil]; - [] call EFUNC(interaction,hideMouseHint); - [_idPFH] call CBA_fnc_removePerFrameHandler; + call EFUNC(interaction,hideMouseHint); + + _idPFH call CBA_fnc_removePerFrameHandler; }; // Mouse hint -private _hintLMB = localize LSTRING(Drop); +private _hintLMB = LLSTRING(Drop); getCursorObjectParams params ["_cursorObject", "", "_distance"]; + if ( - !isNull _cursorObject - && {_distance < MAX_LOAD_DISTANCE} - && {([_unit, _cursorObject, ["isNotCarrying"]] call EFUNC(common,canInteractWith))} - && { + !isNull _cursorObject && + {_distance < MAX_LOAD_DISTANCE} && + {[_unit, _cursorObject, ["isNotCarrying"]] call EFUNC(common,canInteractWith)} && + { if (_target isKindOf "CAManBase") then { [_cursorObject, 0, true] call EFUNC(common,nearestVehiclesFreeSeat) isNotEqualTo [] } else { @@ -62,15 +69,17 @@ if ( } } ) then { - _hintLMB = localize ELSTRING(Cargo,loadObject); + _hintLMB = LELSTRING(cargo,loadObject); }; -private _hintMMB = localize LSTRING(RaiseLowerRotate); +private _hintMMB = LLSTRING(RaiseLowerRotate); + if (_target isKindOf "CAManBase") then { _hintMMB = ""; }; private _hint = [_hintLMB, "", _hintMMB]; + if (_hint isNotEqualTo (_unit getVariable [QGVAR(hint), []])) then { _unit setVariable [QGVAR(hint), _hint]; _hint call EFUNC(interaction,showMouseHint); diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index eca1c2025de..c3bee5fcee1 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -1,6 +1,6 @@ #include "script_component.hpp" /* - * Author: BaerMitUmlaut + * Author: BaerMitUmlaut, johnb43 * Creates a draggable / carryable clone of a dead unit. * * Arguments: @@ -14,14 +14,28 @@ * * Public: No */ -params ["_unit"]; +params ["_target"]; private _clone = QGVAR(clone) createVehicle [0, 0, 0]; -_clone setUnitLoadout getUnitLoadout _unit; + +// Clone loadout +_clone setUnitLoadout getUnitLoadout _target; +[_clone, _target call BIS_fnc_getUnitInsignia] call BIS_fnc_setUnitInsignia; + +// Disable all damage _clone allowDamage false; -_clone setVariable [QGVAR(original), _unit]; -_unit setPosATL [0, 0, -10]; +_clone setVariable [QGVAR(original), _target]; + +// Turn on PhysX so that unit is not desync when moving with 'setPos' commands +[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; + +// Move unit below terrain in order to hide it +_target setPosATL [0, 0, -10]; + +// Turn off PhysX +[QEGVAR(common,awake), [_target, false]] call CBA_fnc_globalEvent; -[QGVAR(cloneCreated), [_unit, _clone]] call CBA_fnc_globalEvent; +// Sets the facial expression +[[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP; _clone diff --git a/addons/dragging/functions/fnc_dragObject.sqf b/addons/dragging/functions/fnc_dragObject.sqf index 499bcc8b36c..7661d4817cc 100644 --- a/addons/dragging/functions/fnc_dragObject.sqf +++ b/addons/dragging/functions/fnc_dragObject.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2, Malbryn - * Drag an object. Called from ace_dragging_fnc_startDrag + * Drags an object. Called from ace_dragging_fnc_startDrag * * Arguments: * 0: Unit that should do the dragging @@ -19,20 +19,24 @@ params ["_unit", "_target"]; TRACE_2("params",_unit,_target); -// get attachTo offset and direction. +// Get attachTo offset and direction. private _position = _target getVariable [QGVAR(dragPosition), [0, 0, 0]]; private _direction = _target getVariable [QGVAR(dragDirection), 0]; -// add height offset of model -private _offset = (_target modelToWorldVisual [0, 0, 0] select 2) - (_unit modelToWorldVisual [0, 0, 0] select 2); +// Add height offset of model +private _offset = ((_target modelToWorldVisual [0, 0, 0]) select 2) - ((_unit modelToWorldVisual [0, 0, 0]) select 2); + if (_target isKindOf "CAManBase") then { _offset = 0; }; + _position = _position vectorAdd [0, 0, _offset]; -// attach object +// Attach object TRACE_3("attaching",_position,_offset,_direction); + _target attachTo [_unit, _position]; + [QEGVAR(common,setDir), [_target, _direction], _target] call CBA_fnc_targetEvent; if (_target isKindOf "CAManBase") then { @@ -42,17 +46,17 @@ if (_target isKindOf "CAManBase") then { _unit setVariable [QGVAR(isDragging), true, true]; _unit setVariable [QGVAR(draggedObject), _target, true]; -// add drop action +// Add drop action GVAR(unit) = _unit; GVAR(releaseActionID) = [0xF1, [false, false, false], { [GVAR(unit), GVAR(unit) getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject); }, "keydown", "", false, 0] call CBA_fnc_addKeyHandler; -// show mouse hint -["", localize LSTRING(Drop)] call EFUNC(interaction,showMouseHint); +// Show mouse hint +["", LLSTRING(Drop)] call EFUNC(interaction,showMouseHint); -// block firing +// Block firing if !(GVAR(dragAndFire)) then { _unit setVariable [QGVAR(blockFire), [ _unit, "DefaultAction", @@ -61,22 +65,25 @@ if !(GVAR(dragAndFire)) then { ] call EFUNC(common,addActionEventHandler)]; }; -// add anim changed EH +// Add anim changed EH [_unit, "AnimChanged", FUNC(handleAnimChanged), [_unit]] call CBA_fnc_addBISEventHandler; -// check everything +// Check everything [FUNC(dragObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler; -// reset current dragging height. +// Reset current dragging height. GVAR(currentHeightChange) = 0; -// prevent UAVs from firing +// Prevent UAVs from firing private _UAVCrew = _target call EFUNC(common,getVehicleUAVCrew); -// fixes not being able to move when in combat pace +// Fixes not being able to move when in combat pace [_unit, "forceWalk", "ACE_dragging", true] call EFUNC(common,statusEffect_set); if (_UAVCrew isNotEqualTo []) then { - {_target deleteVehicleCrew _x} count _UAVCrew; + { + _target deleteVehicleCrew _x; + } forEach _UAVCrew; + _target setVariable [QGVAR(isUAV), true, true]; }; diff --git a/addons/dragging/functions/fnc_dragObjectPFH.sqf b/addons/dragging/functions/fnc_dragObjectPFH.sqf index a45a26ae89e..9e3f45ee5f2 100644 --- a/addons/dragging/functions/fnc_dragObjectPFH.sqf +++ b/addons/dragging/functions/fnc_dragObjectPFH.sqf @@ -1,20 +1,20 @@ #include "script_component.hpp" /* * Author: commy2 - * PFH for Drag Object + * PFH for dragging an object. * * Arguments: - * 0: ARGS - * 0: Unit - * 1: Target - * 2: Start time + * 0: Arguments + * 0.0: Unit + * 0.1: Target + * 0.2: Start time * 1: PFEH Id * * Return Value: * None * * Example: - * [[player, target], 20] call ace_dragging_fnc_dragObjectPFH; + * [[player, cursorObject, CBA_missionTime], _idPFH] call ace_dragging_fnc_dragObjectPFH; * * Public: No */ @@ -28,17 +28,20 @@ _args params ["_unit", "_target", "_startTime"]; if !(_unit getVariable [QGVAR(isDragging), false]) exitWith { TRACE_2("drag false",_unit,_target); - [_idPFH] call CBA_fnc_removePerFrameHandler; + _idPFH call CBA_fnc_removePerFrameHandler; }; -// drop if the crate is destroyed OR (target moved away from carrier (weapon disasembled)) +// Drop if the crate is destroyed OR (target moved away from carrier (weapon disasembled)) if (!alive _target || {_unit distance _target > 10}) then { TRACE_2("dead/distance",_unit,_target); + if ((_unit distance _target > 10) && {(CBA_missionTime - _startTime) < 1}) exitWith { - //attachTo seems to have some kind of network delay and target can return an odd position during the first few frames, - //so wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos) + // attachTo seems to have some kind of network delay and target can return an odd position during the first few frames, + // So wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos) TRACE_3("ignoring bad distance at start",_unit distance _target,_startTime,CBA_missionTime); }; + [_unit, _target] call FUNC(dropObject); - [_idPFH] call CBA_fnc_removePerFrameHandler; + + _idPFH call CBA_fnc_removePerFrameHandler; }; diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index d0eeb71d2c7..43995c1804d 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -1,26 +1,47 @@ #include "script_component.hpp" /* - * Author: BaerMitUmlaut + * Author: BaerMitUmlaut, johnb43 * Drops a draggable / carryable clone of a dead unit. * * Arguments: - * 0: Clone + * 0: Unit dragging / carrying + * 1: Clone + * 2: If unit is in building * * Return Value: * Original unit. * * Example: - * [player] call ace_dragging_fnc_dropClone; + * [player, cursorObject, false] call ace_dragging_fnc_dropClone; * * Public: No */ -params ["_clone"]; +params ["_unit", "_clone", "_inBuilding"]; -private _unit = _clone getVariable [QGVAR(original), objNull]; -_unit setPosASL getPosASL _clone; +private _target = _clone getVariable [QGVAR(original), objNull]; + +if (isNull _target) exitWith {objNull}; + +// Turn on PhysX so that unit is not desync when moving +[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent; + +private _posASL = getPosASL _clone; + +if (_inBuilding) then { + _posASL = _posASL vectorAdd [0, 0, 0.05]; +}; + +// Bring unit back to clone's position +_target setPosASL _posASL; + +// Set the unit's direction +[QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent; + +// Turn off PhysX +[QEGVAR(common,awake), [_target, false]] call CBA_fnc_globalEvent; // Detach first to prevent objNull in attachedObjects detach _clone; deleteVehicle _clone; -_unit +_target diff --git a/addons/dragging/functions/fnc_dropObject.sqf b/addons/dragging/functions/fnc_dropObject.sqf index 895717d1fa6..ac594c90e10 100644 --- a/addons/dragging/functions/fnc_dropObject.sqf +++ b/addons/dragging/functions/fnc_dropObject.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2, Malbryn - * Drop a dragged object. + * Drops a dragged object. * * Arguments: * 0: Unit that drags the other object @@ -11,7 +11,7 @@ * None * * Example: - * [player, cursorTarget] call ace_dragging_fnc_dropObject; + * [player, cursorObject] call ace_dragging_fnc_dropObject; * * Public: No */ @@ -19,31 +19,32 @@ params ["_unit", "_target"]; TRACE_2("params",_unit,_target); -// remove drop action +// Remove drop action [GVAR(releaseActionID), "keydown"] call CBA_fnc_removeKeyHandler; -// stop blocking +// Stop blocking if !(GVAR(dragAndFire)) then { [_unit, "DefaultAction", _unit getVariable [QGVAR(blockFire), -1]] call EFUNC(common,removeActionEventHandler); }; -private _inBuilding = [_unit] call FUNC(isObjectOnObject); +private _inBuilding = _unit call FUNC(isObjectOnObject); +private _isClone = _target isKindOf QGVAR(clone); -// drop cloned dead units -if (_target isKindOf QGVAR(clone)) then { - _target = [_target] call FUNC(dropClone); +// Drop cloned dead units +if (_isClone) then { + _target = [_unit, _target, _inBuilding] call FUNC(dropClone); }; +// Play release animation if !(_unit getVariable ["ACE_isUnconscious", false]) then { - // play release animation [_unit, "released"] call EFUNC(common,doGesture); }; -// prevent collision damage +// Prevent collision damage [QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent; [QEGVAR(common,fixCollision), _target, _target] call CBA_fnc_targetEvent; -// release object +// Release object detach _target; if (_target isKindOf "CAManBase") then { @@ -58,19 +59,19 @@ _unit removeWeapon "ACE_FakePrimaryWeapon"; [_unit, "blockThrow", "ACE_dragging", false] call EFUNC(common,statusEffect_set); -// prevent object from flipping inside buildings -if (_inBuilding) then { +// Prevent object from flipping inside buildings +if (_inBuilding && {!_isClone}) then { _target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]); TRACE_2("setPos",getPosASL _unit,getPosASL _target); }; -// hide mouse hint -[] call EFUNC(interaction,hideMouseHint); +// Hide mouse hint +call EFUNC(interaction,hideMouseHint); _unit setVariable [QGVAR(isDragging), false, true]; _unit setVariable [QGVAR(draggedObject), objNull, true]; -// make object accessible for other units +// Make object accessible for other units [objNull, _target, true] call EFUNC(common,claim); if !(_target isKindOf "CAManBase") then { @@ -82,17 +83,17 @@ if (_unit getVariable ["ACE_isUnconscious", false]) then { [_unit, "unconscious", 2] call EFUNC(common,doAnimation); }; -// recreate UAV crew +// Recreate UAV crew if (_target getVariable [QGVAR(isUAV), false]) then { createVehicleCrew _target; }; -// fixes not being able to move when in combat pace +// Fixes not being able to move when in combat pace [_unit, "forceWalk", "ACE_dragging", false] call EFUNC(common,statusEffect_set); -// reset mass +// Reset mass private _mass = _target getVariable [QGVAR(originalMass), 0]; if (_mass != 0) then { - [QEGVAR(common,setMass), [_target, _mass]] call CBA_fnc_globalEvent; // force global sync + [QEGVAR(common,setMass), [_target, _mass]] call CBA_fnc_globalEvent; // Force global sync }; diff --git a/addons/dragging/functions/fnc_dropObject_carry.sqf b/addons/dragging/functions/fnc_dropObject_carry.sqf index 1c2dd69cdcc..c6aefcbd73e 100644 --- a/addons/dragging/functions/fnc_dropObject_carry.sqf +++ b/addons/dragging/functions/fnc_dropObject_carry.sqf @@ -1,17 +1,18 @@ #include "script_component.hpp" /* * Author: commy2 - * Drop a carried object. + * Drops a carried object. * * Arguments: * 0: Unit that carries the other object * 1: Carried object to drop + * 2: Try loading object into vehicle (default: false) * * Return Value: * None * * Example: - * [player, cursorTarget] call ace_dragging_fnc_dropObject_carry; + * [player, cursorObject] call ace_dragging_fnc_dropObject_carry; * * Public: No */ @@ -19,24 +20,25 @@ params ["_unit", "_target", ["_tryLoad", false]]; TRACE_1("params",_this); -// remove drop action -[_unit, "DefaultAction", _unit getVariable [QGVAR(ReleaseActionID), -1]] call EFUNC(common,removeActionEventHandler); +// Remove drop action +[_unit, "DefaultAction", _unit getVariable [QGVAR(releaseActionID), -1]] call EFUNC(common,removeActionEventHandler); -private _inBuilding = [_unit] call FUNC(isObjectOnObject); +private _inBuilding = _unit call FUNC(isObjectOnObject); +private _isClone = _target isKindOf QGVAR(clone); -// drop cloned dead units -if (_target isKindOf QGVAR(clone)) then { - _target = [_target] call FUNC(dropClone); +// Drop cloned dead units +if (_isClone) then { + _target = [_unit, _target, _inBuilding] call FUNC(dropClone); }; -// prevent collision damage +// Prevent collision damage [QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent; [QEGVAR(common,fixCollision), _target, _target] call CBA_fnc_targetEvent; -// release object +// Release object detach _target; -// fix anim when aborting carrying persons +// Fix anim when aborting carrying persons if (_target isKindOf "CAManBase" || {animationState _unit in CARRY_ANIMATIONS}) then { if (vehicle _unit == _unit && {!(_unit getVariable ["ACE_isUnconscious", false])}) then { [_unit, "", 2] call EFUNC(common,doAnimation); @@ -49,10 +51,10 @@ if (_target isKindOf "CAManBase" || {animationState _unit in CARRY_ANIMATIONS}) }; }; -// properly remove fake weapon +// Properly remove fake weapon _unit removeWeapon "ACE_FakePrimaryWeapon"; -// reselect weapon and re-enable sprint +// Reselect weapon and re-enable sprint private _previousWeaponIndex = _unit getVariable [QGVAR(previousWeapon), -1]; _unit setVariable [QGVAR(previousWeapon), nil, true]; @@ -64,15 +66,15 @@ if (_previousWeaponIndex != -1) then { [_unit, "blockSprint", "ACE_dragging", false] call EFUNC(common,statusEffect_set); [_unit, "blockThrow", "ACE_dragging", false] call EFUNC(common,statusEffect_set); -// prevent object from flipping inside buildings -if (_inBuilding) then { +// Prevent object from flipping inside buildings +if (_inBuilding && {!_isClone}) then { _target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]); }; _unit setVariable [QGVAR(isCarrying), false, true]; _unit setVariable [QGVAR(carriedObject), objNull, true]; -// make object accesable for other units +// Make object accessible for other units [objNull, _target, true] call EFUNC(common,claim); if !(_target isKindOf "CAManBase") then { @@ -80,35 +82,38 @@ if !(_target isKindOf "CAManBase") then { [QEGVAR(common,fixFloating), _target, _target] call CBA_fnc_targetEvent; }; -// recreate UAV crew +// Recreate UAV crew if (_target getVariable [QGVAR(isUAV), false]) then { createVehicleCrew _target; }; -// reset mass +// Reset mass private _mass = _target getVariable [QGVAR(originalMass), 0]; if (_mass != 0) then { - [QEGVAR(common,setMass), [_target, _mass]] call CBA_fnc_globalEvent; // force global sync + [QEGVAR(common,setMass), [_target, _mass]] call CBA_fnc_globalEvent; // Force global sync }; -// reset temp direction +// Reset temp direction _target setVariable [QGVAR(carryDirection_temp), nil]; -// try loading into vehicle -if (_tryLoad && {!isNull cursorObject} && {([ACE_player, cursorObject, []] call EFUNC(common,canInteractWith))}) then { +private _cursorObject = cursorObject; + +// Try loading into vehicle +if (_tryLoad && {!isNull _cursorObject} && {[_unit, _cursorObject, []] call EFUNC(common,canInteractWith)}) then { if (_target isKindOf "CAManBase") then { - private _vehicles = [cursorObject, 0, true] call EFUNC(common,nearestVehiclesFreeSeat); - if ([cursorObject] isEqualTo _vehicles) then { - if (["ACE_Medical"] call EFUNC(common,isModLoaded)) then { - [_unit, _target, cursorObject] call EFUNC(medical_treatment,loadUnit); + private _vehicles = [_cursorObject, 0, true] call EFUNC(common,nearestVehiclesFreeSeat); + + if ([_cursorObject] isEqualTo _vehicles) then { + if (["ace_medical"] call EFUNC(common,isModLoaded)) then { + [_unit, _target, _cursorObject] call EFUNC(medical_treatment,loadUnit); } else { - [_unit, _target, cursorObject] call EFUNC(common,loadPerson); + [_unit, _target, _cursorObject] call EFUNC(common,loadPerson); }; }; } else { - if ([_target, cursorObject] call EFUNC(cargo,canLoadItemIn)) then { - [player, _target, cursorObject] call EFUNC(cargo,startLoadIn); + if ([_target, _cursorObject] call EFUNC(cargo,canLoadItemIn)) then { + [player, _target, _cursorObject] call EFUNC(cargo,startLoadIn); }; }; }; diff --git a/addons/dragging/functions/fnc_getWeight.sqf b/addons/dragging/functions/fnc_getWeight.sqf index ad816617480..4bbd20b37f0 100644 --- a/addons/dragging/functions/fnc_getWeight.sqf +++ b/addons/dragging/functions/fnc_getWeight.sqf @@ -11,7 +11,7 @@ * Weight * * Example: - * [_object] call ace_dragging_fnc_getWeight + * [cursorObject] call ace_dragging_fnc_getWeight * * Public: No */ @@ -33,4 +33,4 @@ _weight = _weight + getNumber (configOf _object >> "mass"); // Mass in Arma isn't an exact amount but rather a volume/weight value // This attempts to work around that by making it a usable value (sort of) -_weight * 0.5; +_weight * 0.5 diff --git a/addons/dragging/functions/fnc_handleAnimChanged.sqf b/addons/dragging/functions/fnc_handleAnimChanged.sqf index 7fa242ae16f..489744bbb72 100644 --- a/addons/dragging/functions/fnc_handleAnimChanged.sqf +++ b/addons/dragging/functions/fnc_handleAnimChanged.sqf @@ -1,23 +1,21 @@ #include "script_component.hpp" /* * Author: commy2 - * Handle the animaion for a Unit for Dragging Module + * Handle the animaion for a unit for the dragging module. * * Arguments: * 0: Unit - * 1: animaion + * 1: Animaion * * Return Value: * None * * Example: - * [_unit, "amovpercmstpsnonwnondnon"] call ace_dragging_fnc_handleAnimChanged; + * [player, "amovpercmstpsnonwnondnon"] call ace_dragging_fnc_handleAnimChanged; * * Public: No */ -//IGNORE_PRIVATE_WARNING ["_thisArgs", "_thisID"]; // From CBA_fnc_addBISEventHandler; - params ["_unit", "_anim"]; _thisArgs params ["_realUnit"]; TRACE_4("params",_unit,_anim,_realUnit,_thisID); @@ -28,8 +26,7 @@ if (_unit != _realUnit) exitWith { }; if (_unit getVariable [QGVAR(isDragging), false]) then { - - // drop dragged object when not in valid animation + // 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]; @@ -39,10 +36,8 @@ if (_unit getVariable [QGVAR(isDragging), false]) then { }; }; } else { - if (_unit getVariable [QGVAR(isCarrying), false]) then { - - // drop carried object when not standing; also some exceptions when picking up crate + // 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]; diff --git a/addons/dragging/functions/fnc_handleKilled.sqf b/addons/dragging/functions/fnc_handleKilled.sqf index 672869d3c9a..858a319f707 100644 --- a/addons/dragging/functions/fnc_handleKilled.sqf +++ b/addons/dragging/functions/fnc_handleKilled.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2 - * Handle death of the dragger + * Handle death of the dragger/carrier. * * Arguments: * 0: Unit @@ -10,7 +10,7 @@ * None * * Example: - * [_unit] call ace_dragging_fnc_handleKilled; + * [player] call ace_dragging_fnc_handleKilled; * * Public: No */ diff --git a/addons/dragging/functions/fnc_handlePlayerChanged.sqf b/addons/dragging/functions/fnc_handlePlayerChanged.sqf index a4046601066..593208b1d98 100644 --- a/addons/dragging/functions/fnc_handlePlayerChanged.sqf +++ b/addons/dragging/functions/fnc_handlePlayerChanged.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2 - * Handle player changes. + * Handles player changes. * * Arguments: * 0: New Player Unit diff --git a/addons/dragging/functions/fnc_handlePlayerWeaponChanged.sqf b/addons/dragging/functions/fnc_handlePlayerWeaponChanged.sqf index beaed397e72..57c5545e67c 100644 --- a/addons/dragging/functions/fnc_handlePlayerWeaponChanged.sqf +++ b/addons/dragging/functions/fnc_handlePlayerWeaponChanged.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2 - * Handle the Weapon Changed Event + * Handles the weapon changed event. * * Arguments: * 0: Unit @@ -11,7 +11,7 @@ * None * * Example: - * [_unit, "gun"] call ace_dragging_fnc_handlePlayerWeaponChanged; + * [player, primaryWeapon player] call ace_dragging_fnc_handlePlayerWeaponChanged; * * Public: No */ @@ -20,32 +20,25 @@ params ["_unit", "_weapon"]; TRACE_2("params",_unit,_weapon); if (_unit getVariable [QGVAR(isDragging), false]) then { - - // drop dragged object when changing weapon + // Drop dragged object when changing weapon if (_weapon != _unit getVariable [QGVAR(currentWeapon), ""]) then { private _draggedObject = _unit getVariable [QGVAR(draggedObject), objNull]; [_unit, _draggedObject] call FUNC(dropObject); }; - }; if (_unit getVariable [QGVAR(isCarrying), false]) then { - private _carriedObject = _unit getVariable [QGVAR(carriedObject), objNull]; if (_carriedObject isKindOf "CAManBase") then { - if (_weapon != primaryWeapon _unit) then { [_unit, _carriedObject] call FUNC(dropObject_carry); }; - } else { - - // drop carried object when selecting any weapon + // Drop carried object when selecting any weapon if (_weapon != "") then { [_unit, _carriedObject] call FUNC(dropObject_carry); }; - }; }; diff --git a/addons/dragging/functions/fnc_handleScrollWheel.sqf b/addons/dragging/functions/fnc_handleScrollWheel.sqf index 04c2542b2fd..663b9086b64 100644 --- a/addons/dragging/functions/fnc_handleScrollWheel.sqf +++ b/addons/dragging/functions/fnc_handleScrollWheel.sqf @@ -24,13 +24,12 @@ if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {false}; private _carriedItem = _unit getVariable [QGVAR(carriedObject), objNull]; -//disabled for persons +// Disabled for persons if (_carriedItem isKindOf "CAManBase") exitWith {false}; -if !(cba_events_control) then { - // raise/lower - - // move carried item 15 cm per scroll interval +if !(CBA_events_control) then { + // Raise/lower + // Move carried item 15 cm per scroll interval _scrollAmount = _scrollAmount * 0.15; private _position = getPosASL _carriedItem; @@ -38,7 +37,7 @@ if !(cba_events_control) then { _position set [2, ((_position select 2) + _scrollAmount min (_maxHeight + 1.5)) max _maxHeight]; - // move up/down object and reattach at current position + // Move up/down object and reattach at current position detach _carriedItem; // Uses this method of selecting position because setPosATL did not have immediate effect @@ -47,15 +46,15 @@ if !(cba_events_control) then { _selectionPosition = _selectionPosition vectorAdd _positionChange; _carriedItem attachTo [_unit, _selectionPosition]; - //reset the carry direction + // Reset the carry direction private _direction = _carriedItem getVariable [QGVAR(carryDirection_temp), _carriedItem getVariable [QGVAR(carryDirection), 0]]; [QEGVAR(common,setDir), [_carriedItem, _direction], _carriedItem] call CBA_fnc_targetEvent; } else { - // rotate - + // Rotate private _direction = _carriedItem getVariable [QGVAR(carryDirection_temp), _carriedItem getVariable [QGVAR(carryDirection), 0]]; _scrollAmount = _scrollAmount * 10; _direction = _direction + _scrollAmount; + [QEGVAR(common,setDir), [_carriedItem, _direction], _carriedItem] call CBA_fnc_targetEvent; _carriedItem setVariable [QGVAR(carryDirection_temp), _direction]; }; diff --git a/addons/dragging/functions/fnc_handleUnconscious.sqf b/addons/dragging/functions/fnc_handleUnconscious.sqf index fd3f95f95d2..98bd883174a 100644 --- a/addons/dragging/functions/fnc_handleUnconscious.sqf +++ b/addons/dragging/functions/fnc_handleUnconscious.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2 - * Handle the Unconscious of a Unit while Dragging + * Handles consciousness change of a unit while dragging / carrying. * * Arguments: * 0: Unit @@ -10,7 +10,7 @@ * None * * Example: - * [_unit] call ace_dragging_fnc_handleUnconscious; + * [player] call ace_dragging_fnc_handleUnconscious; * * Public: No */ @@ -20,30 +20,28 @@ params ["_unit"]; private _player = ACE_player; if (_player getVariable [QGVAR(isDragging), false]) then { - private _draggedObject = _player getVariable [QGVAR(draggedObject), objNull]; - // handle falling unconscious + // Handle falling unconscious if (_unit == _player) then { [_unit, _draggedObject] call FUNC(dropObject); }; - // handle waking up dragged unit + // Handle waking up dragged unit if (_unit == _draggedObject) then { [_player, _draggedObject] call FUNC(dropObject); }; }; if (_player getVariable [QGVAR(isCarrying), false]) then { - private _carriedObject = _player getVariable [QGVAR(carriedObject), objNull]; - // handle falling unconscious + // Handle falling unconscious if (_unit == _player) then { [_unit, _carriedObject] call FUNC(dropObject_carry); }; - // handle waking up dragged unit + // Handle waking up dragged unit if (_unit == _carriedObject) then { [_player, _carriedObject] call FUNC(dropObject_carry); }; diff --git a/addons/dragging/functions/fnc_initObject.sqf b/addons/dragging/functions/fnc_initObject.sqf index 054f016a673..8942f5c5671 100644 --- a/addons/dragging/functions/fnc_initObject.sqf +++ b/addons/dragging/functions/fnc_initObject.sqf @@ -1,16 +1,16 @@ #include "script_component.hpp" /* * Author: commy2 - * Initialize variables for drag or carryable objects. Called from init EH. + * Initializes variables for draggable / carryable objects. Called from init EH. * * Arguments: - * 0: Any object + * 0: Object * * Return Value: * None * * Example: - * [box] call ace_dragging_fnc_initObject; + * [cursorObject] call ace_dragging_fnc_initObject; * * Public: No */ diff --git a/addons/dragging/functions/fnc_initPerson.sqf b/addons/dragging/functions/fnc_initPerson.sqf index c9365710dd6..5e3b24c5efc 100644 --- a/addons/dragging/functions/fnc_initPerson.sqf +++ b/addons/dragging/functions/fnc_initPerson.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2 - * Initialize variables for drag or carryable persons. Called from init EH. + * Initialize variables for draggable / carryable persons. Called from init EH. * * Arguments: * 0: Unit @@ -17,5 +17,5 @@ params ["_unit"]; -[_unit, true, [0,1.1,0.092], 180] call FUNC(setDraggable); -[_unit, true, [0.4,-0.1,-1.25], 195] call FUNC(setCarryable); // hard-coded selection: "LeftShoulder" +[_unit, true, [0, 1.1, 0.092], 180] call FUNC(setDraggable); +[_unit, true, [0.4, -0.1, -1.25], 195] call FUNC(setCarryable); // Hard-coded selection: "LeftShoulder" diff --git a/addons/dragging/functions/fnc_isObjectOnObject.sqf b/addons/dragging/functions/fnc_isObjectOnObject.sqf index 00c2823e4a3..16f169b8fee 100644 --- a/addons/dragging/functions/fnc_isObjectOnObject.sqf +++ b/addons/dragging/functions/fnc_isObjectOnObject.sqf @@ -1,15 +1,15 @@ /* * Author: commy2 - * Check if Object is Overlapping + * Checks if an object is overlapping another object. * * Arguments: * 0: Object * * Return Value: - * Boolean + * If object is overlapping another * * Example: - * [player] call ace_dragging_fnc_isObjectOnObject + * [player] call ace_dragging_fnc_isObjectOnObject; * * Public: No */ diff --git a/addons/dragging/functions/fnc_setCarryable.sqf b/addons/dragging/functions/fnc_setCarryable.sqf index 6ec0abb4661..62237e10edf 100644 --- a/addons/dragging/functions/fnc_setCarryable.sqf +++ b/addons/dragging/functions/fnc_setCarryable.sqf @@ -1,46 +1,45 @@ #include "script_component.hpp" /* * Author: commy2, PiZZADOX - * Enable the object to be carried. + * Enables the object to be carried. * * Arguments: - * 0: Any object - * 1: true to enable carrying, false to disable - * 2: Position offset for attachTo command (default: [0,1,1]) - * 3: Direction in degree to rotate the object after attachTo (default: 0) - * 4: Override weight limit (optional; default: false) + * 0: Object + * 1: True to enable carrying, false to disable + * 2: Position offset for attachTo command (default: [0, 1, 1]) + * 3: Direction in degrees to rotate the object after attachTo (default: 0) + * 4: Override weight limit (default: false) * * Return Value: * None * * Example: - * [object, true, [0,1,1], 0, false] call ace_dragging_fnc_setCarryable; + * [cursorObject, true, [0, 1, 1], 0, false] call ace_dragging_fnc_setCarryable; * * Public: Yes */ -//IGNORE_PRIVATE_WARNING ["_player", "_target"]; params ["_object", "_enableCarry", "_position", "_direction", ["_ignoreWeightCarry", false, [false]]]; if (isNil "_position") then { - _position = _object getVariable [QGVAR(carryPosition), [0,1,1]]; + _position = _object getVariable [QGVAR(carryPosition), [0, 1, 1]]; }; if (isNil "_direction") then { _direction = _object getVariable [QGVAR(carryDirection), 0]; }; -// update variables +// Update variables _object setVariable [QGVAR(canCarry), _enableCarry]; _object setVariable [QGVAR(carryPosition), _position]; _object setVariable [QGVAR(carryDirection), _direction]; _object setVariable [QGVAR(ignoreWeightCarry), _ignoreWeightCarry]; -// add action to class if it is not already present +// Add action to class if it is not already present private _type = typeOf _object; private _initializedClasses = GETGVAR(initializedClasses_carry,[]); -// do nothing if the class is already initialized +// Do nothing if the class is already initialized if (_type in _initializedClasses) exitWith {}; _initializedClasses pushBack _type; @@ -48,8 +47,8 @@ GVAR(initializedClasses_carry) = _initializedClasses; private _icon = [QUOTE(PATHTOF(UI\icons\box_carry.paa)), QUOTE(PATHTOF(UI\icons\person_carry.paa))] select (_object isKindOf "Man"); -private _carryAction = [QGVAR(carry), localize LSTRING(Carry), _icon, {[_player, _target] call FUNC(startCarry)}, {[_player, _target] call FUNC(canCarry)}] call EFUNC(interact_menu,createAction); -private _dropAction = [QGVAR(drop_carry), localize LSTRING(Drop), "", {[_player, _target] call FUNC(dropObject_carry)}, {[_player, _target] call FUNC(canDrop_carry)}] call EFUNC(interact_menu,createAction); +private _carryAction = [QGVAR(carry), LLSTRING(Carry), _icon, {[_player, _target] call FUNC(startCarry)}, {[_player, _target] call FUNC(canCarry)}] call EFUNC(interact_menu,createAction); +private _dropAction = [QGVAR(drop_carry), LLSTRING(Drop), "", {[_player, _target] call FUNC(dropObject_carry)}, {[_player, _target] call FUNC(canDrop_carry)}] call EFUNC(interact_menu,createAction); [_type, 0, ["ACE_MainActions"], _carryAction] call EFUNC(interact_menu,addActionToClass); [_type, 0, [], _dropAction] call EFUNC(interact_menu,addActionToClass); diff --git a/addons/dragging/functions/fnc_setDraggable.sqf b/addons/dragging/functions/fnc_setDraggable.sqf index 99729ebd636..dfc44f199e0 100644 --- a/addons/dragging/functions/fnc_setDraggable.sqf +++ b/addons/dragging/functions/fnc_setDraggable.sqf @@ -1,25 +1,24 @@ #include "script_component.hpp" /* * Author: commy2, PiZZADOX - * Enable the object to be dragged. + * Enables the object to be dragged. * * Arguments: - * 0: Any object - * 1: true to enable dragging, false to disable + * 0: Object + * 1: True to enable dragging, false to disable * 2: Position offset for attachTo command (optional; default: [0, 1.5, 0]) - * 3: Direction in degree to rotate the object after attachTo (optional; default: 0) - * 4: Override weight limit (optional; default: false) + * 3: Direction in degrees to rotate the object after attachTo (optional; default: 0) + * 4: Override weight limit (default: false) * * Return Value: * None * * Example: - * [object, true, [0,0,0], 0, false] call ace_dragging_fnc_setDraggable; + * [cursorObject, true, [0, 0, 0], 0, false] call ace_dragging_fnc_setDraggable; * * Public: Yes */ -//IGNORE_PRIVATE_WARNING ["_player", "_target"]; params ["_object", "_enableDrag", "_position", "_direction", ["_ignoreWeightDrag", false, [false]]]; if (isNil "_position") then { @@ -30,17 +29,17 @@ if (isNil "_direction") then { _direction = _object getVariable [QGVAR(dragDirection), 0]; }; -// update variables +// Update variables _object setVariable [QGVAR(canDrag), _enableDrag]; _object setVariable [QGVAR(dragPosition), _position]; _object setVariable [QGVAR(dragDirection), _direction]; _object setVariable [QGVAR(ignoreWeightDrag), _ignoreWeightDrag]; -// add action to class if it is not already present +// Add action to class if it is not already present private _type = typeOf _object; private _initializedClasses = GETGVAR(initializedClasses,[]); -// do nothing if the class is already initialized +// Do nothing if the class is already initialized if (_type in _initializedClasses) exitWith {}; _initializedClasses pushBack _type; @@ -48,8 +47,8 @@ GVAR(initializedClasses) = _initializedClasses; private _icon = [QUOTE(PATHTOF(UI\icons\box_drag.paa)), QUOTE(PATHTOF(UI\icons\person_drag.paa))] select (_object isKindOf "Man"); -private _dragAction = [QGVAR(drag), localize LSTRING(Drag), _icon, {[_player, _target] call FUNC(startDrag)}, {[_player, _target] call FUNC(canDrag)}] call EFUNC(interact_menu,createAction); -private _dropAction = [QGVAR(drop), localize LSTRING(Drop), "", {[_player, _target] call FUNC(dropObject)}, {[_player, _target] call FUNC(canDrop)}] call EFUNC(interact_menu,createAction); +private _dragAction = [QGVAR(drag), LLSTRING(Drag), _icon, {[_player, _target] call FUNC(startDrag)}, {[_player, _target] call FUNC(canDrag)}] call EFUNC(interact_menu,createAction); +private _dropAction = [QGVAR(drop), LLSTRING(Drop), "", {[_player, _target] call FUNC(dropObject)}, {[_player, _target] call FUNC(canDrop)}] call EFUNC(interact_menu,createAction); [_type, 0, ["ACE_MainActions"], _dragAction] call EFUNC(interact_menu,addActionToClass); [_type, 0, [], _dropAction] call EFUNC(interact_menu,addActionToClass); diff --git a/addons/dragging/functions/fnc_startCarry.sqf b/addons/dragging/functions/fnc_startCarry.sqf index 194175799e6..849b24e475f 100644 --- a/addons/dragging/functions/fnc_startCarry.sqf +++ b/addons/dragging/functions/fnc_startCarry.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2, PiZZADOX - * Start the carrying process. + * Starts the carrying process. * * Arguments: * 0: Unit that should do the carrying @@ -11,7 +11,7 @@ * None * * Example: - * [player, cursorTarget] call ace_dragging_fnc_startCarry; + * [player, cursorObject] call ace_dragging_fnc_startCarry; * * Public: No */ @@ -19,53 +19,62 @@ params ["_unit", "_target"]; TRACE_2("params",_unit,_target); -private _weight = [_target] call FUNC(getWeight); +private _weight = _target call FUNC(getWeight); -// exempt from weight check if object has override variable set -if (!GETVAR(_target,GVAR(ignoreWeightCarry),false) && { +// Exempt from weight check if object has override variable set +if (!(_target getVariable [QGVAR(ignoreWeightCarry), false]) && { _weight > GETMVAR(ACE_maxWeightCarry,1E11) }) exitWith { - // exit if object weight is over global var value - [localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); + // Exit if object weight is over global var value + [LLSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); }; private _timer = CBA_missionTime + 5; -// handle objects vs persons +// Handle objects vs persons if (_target isKindOf "CAManBase") then { - // create clone for dead units + // Create clone for dead units if (!alive _target) then { - _target = [_target] call FUNC(createClone); + _target = _target call FUNC(createClone); }; - // add a primary weapon if the unit has none. - if (primaryWeapon _unit isEqualto "") then { + private _primaryWeapon = primaryWeapon _unit; + + // Add a primary weapon if the unit has none + if (_primaryWeapon isEqualto "") then { _unit addWeapon "ACE_FakePrimaryWeapon"; + _primaryWeapon = "ACE_FakePrimaryWeapon"; }; - // select primary, otherwise the drag animation actions don't work. - _unit selectWeapon primaryWeapon _unit; + // Select primary, otherwise the drag animation actions don't work + _unit selectWeapon _primaryWeapon; - // move a bit closer and adjust direction when trying to pick up a person - _target setDir (getDir _unit + 180); + // Move a bit closer and adjust direction when trying to pick up a person + [QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent; _target setPosASL (getPosASL _unit vectorAdd (vectorDir _unit)); [_unit, "AcinPknlMstpSnonWnonDnon_AcinPercMrunSnonWnonDnon", 2] call EFUNC(common,doAnimation); [_target, "AinjPfalMstpSnonWrflDnon_carried_Up", 2] call EFUNC(common,doAnimation); _timer = CBA_missionTime + 10; - } else { - // select no weapon and stop sprinting + // Select no weapon and stop sprinting private _previousWeaponIndex = [_unit] call EFUNC(common,getFiremodeIndex); _unit setVariable [QGVAR(previousWeapon), _previousWeaponIndex, true]; - _unit action ["SwitchWeapon", _unit, _unit, 299]; + + // Get last weapon index from unit + private _lastWeaponIndex = ((_unit weaponsInfo [""]) apply {_x select 0}) select -1; + + // Select a weapon index that is not used by any weapons + _unit action ["SwitchWeapon", _unit, _unit, _lastWeaponIndex + 1]; + [_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation); - // objects other than containers have calculated weight == 0 so we use getMass - if (-1 == ["ReammoBox_F", "WeaponHolder", "WeaponHolderSimulated"] findIf {_target isKindOf _x}) then { + // Objects other than containers have calculated weight == 0 so we use getMass + if (["ReammoBox_F", "WeaponHolder", "WeaponHolderSimulated"] findIf {_target isKindOf _x} == -1) then { _weight = getMass _target; }; + if (_weight > GVAR(maxWeightCarryRun)) then { [_unit, "forceWalk", "ACE_dragging", true] call EFUNC(common,statusEffect_set); } else { @@ -75,22 +84,21 @@ if (_target isKindOf "CAManBase") then { [_unit, "blockThrow", "ACE_dragging", true] call EFUNC(common,statusEffect_set); -// prevent multiple players from accessing the same object +// Prevent multiple players from accessing the same object [_unit, _target, true] call EFUNC(common,claim); - -// prevents draging and carrying at the same time +// Prevents draging and carrying at the same time _unit setVariable [QGVAR(isCarrying), true, true]; -// required for aborting animation +// Required for aborting animation _unit setVariable [QGVAR(carriedObject), _target, true]; [FUNC(startCarryPFH), 0.2, [_unit, _target, _timer]] call CBA_fnc_addPerFrameHandler; -// disable collisions by setting the physx mass to almost zero +// Disable collisions by setting the PhysX mass to almost zero private _mass = getMass _target; if (_mass > 1) then { _target setVariable [QGVAR(originalMass), _mass, true]; - [QEGVAR(common,setMass), [_target, 1e-12]] call CBA_fnc_globalEvent; // force global sync + [QEGVAR(common,setMass), [_target, 1e-12]] call CBA_fnc_globalEvent; // Force global sync }; diff --git a/addons/dragging/functions/fnc_startCarryPFH.sqf b/addons/dragging/functions/fnc_startCarryPFH.sqf index f2c5cfb5d26..8ca965838d4 100644 --- a/addons/dragging/functions/fnc_startCarryPFH.sqf +++ b/addons/dragging/functions/fnc_startCarryPFH.sqf @@ -4,17 +4,17 @@ * Carry PFH * * Arguments: - * 0: ARGS - * 0: Unit - * 1: Target - * 2: Timeout + * 0: Arguments + * 0.0: Unit + * 0.1: Target + * 0.2: Timeout * 1: PFEH Id * * Return Value: * None * * Example: - * [[player, target, 100], 20] call ace_dragging_fnc_startCarryPFH; + * [[player, cursorObject, 10], _idPFH] call ace_dragging_fnc_startCarryPFH; * * Public: No */ @@ -26,42 +26,43 @@ params ["_args", "_idPFH"]; _args params ["_unit", "_target", "_timeOut"]; -// handle aborting carry +// Handle aborting carry if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith { TRACE_4("carry false",_unit,_target,_timeOut,CBA_missionTime); - [_idPFH] call CBA_fnc_removePerFrameHandler; + _idPFH call CBA_fnc_removePerFrameHandler; }; -// same as dragObjectPFH, checks if object is deleted or dead OR (target moved away from carrier (weapon disasembled)) +// Same as dragObjectPFH, checks if object is deleted or dead OR (target moved away from carrier (weapon disasembled)) if (!alive _target || {_unit distance _target > 10}) then { TRACE_4("dead/distance",_unit,_target,_timeOut,CBA_missionTime); [_unit, _target] call FUNC(dropObject_carry); - [_idPFH] call CBA_fnc_removePerFrameHandler; + + _idPFH call CBA_fnc_removePerFrameHandler; }; -// handle persons vs objects +// Handle persons vs objects if (_target isKindOf "CAManBase") then { if (CBA_missionTime > _timeOut) exitWith { TRACE_4("Start carry person",_unit,_target,_timeOut,CBA_missionTime); [_unit, _target] call FUNC(carryObject); - [_idPFH] call CBA_fnc_removePerFrameHandler; + _idPFH call CBA_fnc_removePerFrameHandler; }; } else { if (CBA_missionTime > _timeOut) exitWith { TRACE_4("timeout",_unit,_target,_timeOut,CBA_missionTime); - [_idPFH] call CBA_fnc_removePerFrameHandler; + _idPFH call CBA_fnc_removePerFrameHandler; - // drop if in timeout + // Drop if in timeout private _draggedObject = _unit getVariable [QGVAR(draggedObject), objNull]; [_unit, _draggedObject] call FUNC(dropObject_carry); }; - // wait for the unit to stand up + // Wait for the unit to stand up if (stance _unit isEqualto "STAND") exitWith { TRACE_4("Start carry object",_unit,_target,_timeOut,CBA_missionTime); [_unit, _target] call FUNC(carryObject); - [_idPFH] call CBA_fnc_removePerFrameHandler; + _idPFH call CBA_fnc_removePerFrameHandler; }; }; diff --git a/addons/dragging/functions/fnc_startDrag.sqf b/addons/dragging/functions/fnc_startDrag.sqf index 41c5a61dd6a..6cf9e68d8bf 100644 --- a/addons/dragging/functions/fnc_startDrag.sqf +++ b/addons/dragging/functions/fnc_startDrag.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: commy2, PiZZADOX, Malbryn - * Start the dragging process. + * Starts the dragging process. * * Arguments: * 0: Unit that should do the dragging @@ -11,7 +11,7 @@ * None * * Example: - * [player, cursorTarget] call ace_dragging_fnc_startDrag; + * [player, cursorObject] call ace_dragging_fnc_startDrag; * * Public: No */ @@ -19,41 +19,45 @@ params ["_unit", "_target"]; TRACE_2("params",_unit,_target); -// exempt from weight check if object has override variable set -if (!GETVAR(_target,GVAR(ignoreWeightDrag),false) && { - private _weight = [_target] call FUNC(getWeight); +// Exempt from weight check if object has override variable set +if (!(_target getVariable [QGVAR(ignoreWeightDrag), false]) && { + private _weight = _target call FUNC(getWeight); _weight > GETMVAR(ACE_maxWeightDrag,1E11) }) exitWith { - // exit if object weight is over global var value - [localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); + // Exit if object weight is over global var value + [LLSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); }; // Create clone for dead units if (!alive _target) then { - _target = [_target] call FUNC(createClone); + _target = _target call FUNC(createClone); }; +private _primaryWeapon = primaryWeapon _unit; + // Add a primary weapon if the unit has none if !(GVAR(dragAndFire)) then { - if (primaryWeapon _unit isEqualto "") then { + if (_primaryWeapon isEqualto "") then { _unit addWeapon "ACE_FakePrimaryWeapon"; - _unit selectWeapon primaryWeapon _unit; - } else { - _unit selectWeapon primaryWeapon _unit; + _primaryWeapon = "ACE_FakePrimaryWeapon"; }; + + _unit selectWeapon _primaryWeapon; } else { // Making sure the unit is holding a primary weapon or handgun - if !(currentWeapon _unit in [primaryWeapon _unit, handgunWeapon _unit]) then { - if (primaryWeapon _unit != "") then { + private _handgunWeapon = handgunWeapon _unit; + + if !(currentWeapon _unit in [_primaryWeapon, _handgunWeapon]) then { + if (_primaryWeapon != "") then { // Use primary if possible - _unit selectWeapon primaryWeapon _unit; + _unit selectWeapon _primaryWeapon; } else { - if (handgunWeapon _unit != "") then { + if (_handgunWeapon != "") then { // Use pistol if unit has no primary - _unit selectWeapon handgunWeapon _unit; + _unit selectWeapon _handgunWeapon; } else { // Add fake weapon if no weapons besides launcher are available _unit addWeapon "ACE_FakePrimaryWeapon"; - _unit selectWeapon primaryWeapon _unit; + _unit selectWeapon "ACE_FakePrimaryWeapon"; }; }; }; @@ -64,10 +68,10 @@ _unit setVariable [QGVAR(currentWeapon), currentWeapon _unit]; [_unit, "blockThrow", "ACE_dragging", true] call EFUNC(common,statusEffect_set); -// prevent multiple players from accessing the same object +// Prevent multiple players from accessing the same object [_unit, _target, true] call EFUNC(common,claim); -// can't play action that depends on weapon if it was added the same frame +// Can't play action that depends on weapon if it was added the same frame if !(_unit call EFUNC(common,isSwimming)) then { [{ private _unitWeapon = _this getVariable [QGVAR(currentWeapon), ""]; @@ -80,23 +84,23 @@ if !(_unit call EFUNC(common,isSwimming)) then { }, _unit] call CBA_fnc_execNextFrame; }; -// move a bit closer and adjust direction when trying to pick up a person +// Move a bit closer and adjust direction when trying to pick up a person if (_target isKindOf "CAManBase") then { - _target setDir (getDir _unit + 180); + [QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent; _target setPosASL (getPosASL _unit vectorAdd (vectorDir _unit vectorMultiply 1.5)); [_target, "AinjPpneMrunSnonWnonDb_grab", 2] call EFUNC(common,doAnimation); }; -// prevents draging and carrying at the same time +// Prevents dragging and carrying at the same time _unit setVariable [QGVAR(isDragging), true, true]; [FUNC(startDragPFH), 0.2, [_unit, _target, CBA_missionTime + 5]] call CBA_fnc_addPerFrameHandler; -// disable collisions by setting the physx mass to almost zero +// Disable collisions by setting the physx mass to almost zero private _mass = getMass _target; if (_mass > 1) then { _target setVariable [QGVAR(originalMass), _mass, true]; - [QEGVAR(common,setMass), [_target, 1e-12]] call CBA_fnc_globalEvent; // force global sync + [QEGVAR(common,setMass), [_target, 1e-12]] call CBA_fnc_globalEvent; // Force global sync }; diff --git a/addons/dragging/functions/fnc_startDragPFH.sqf b/addons/dragging/functions/fnc_startDragPFH.sqf index 614b6a87413..d96b0bddb4b 100644 --- a/addons/dragging/functions/fnc_startDragPFH.sqf +++ b/addons/dragging/functions/fnc_startDragPFH.sqf @@ -4,17 +4,17 @@ * Drag PFH * * Arguments: - * 0: ARGS - * 0: Unit - * 1: Target - * 2: Timeout + * 0: Arguments + * 0.0: Unit + * 0.1: Target + * 0.2: Timeout * 1: PFEH Id * * Return Value: * None * * Example: - * [[player, target, 100], 20] call ace_dragging_fnc_startDragPFH; + * [[player, cursorObject, 10], _idPFH] call ace_dragging_fnc_startDragPFH; * * Public: No */ @@ -26,33 +26,34 @@ params ["_args", "_idPFH"]; _args params ["_unit", "_target", "_timeOut"]; -// handle aborting drag +// Handle aborting drag if !(_unit getVariable [QGVAR(isDragging), false]) exitWith { TRACE_4("drag false",_unit,_target,_timeOut,CBA_missionTime); - [_idPFH] call CBA_fnc_removePerFrameHandler; + _idPFH call CBA_fnc_removePerFrameHandler; }; -// same as dragObjectPFH, checks if object is deleted or dead OR (target moved away from carrier (weapon disasembled)) +// Same as dragObjectPFH, checks if object is deleted, dead or target moved away from carrier (e.g. weapon disassembled) if (!alive _target || {_unit distance _target > 10}) then { TRACE_4("dead/distance",_unit,_target,_timeOut,CBA_missionTime); [_unit, _target] call FUNC(dropObject); - [_idPFH] call CBA_fnc_removePerFrameHandler; + + _idPFH call CBA_fnc_removePerFrameHandler; }; -// timeout. Do nothing. Quit. CBA_missionTime, because anim length is linked to ingame time. +// Timeout: Do nothing, quit. CBA_missionTime, because anim length is linked to ingame time if (CBA_missionTime > _timeOut) exitWith { TRACE_4("timeout",_unit,_target,_timeOut,CBA_missionTime); - [_idPFH] call CBA_fnc_removePerFrameHandler; + _idPFH call CBA_fnc_removePerFrameHandler; - // drop if in timeout + // Drop if in timeout private _draggedObject = _unit getVariable [QGVAR(draggedObject), objNull]; [_unit, _draggedObject] call FUNC(dropObject); }; -// unit is ready to start dragging +// Unit is ready to start dragging if (animationState _unit in DRAG_ANIMATIONS || {_unit call EFUNC(common,isSwimming)}) exitWith { TRACE_4("Start Dragging",_unit,_target,_timeOut,CBA_missionTime); [_unit, _target] call FUNC(dragObject); - [_idPFH] call CBA_fnc_removePerFrameHandler; + _idPFH call CBA_fnc_removePerFrameHandler; }; diff --git a/addons/dragging/initSettings.sqf b/addons/dragging/initSettings.sqf index b33dbab3f76..185eabcc43e 100644 --- a/addons/dragging/initSettings.sqf +++ b/addons/dragging/initSettings.sqf @@ -2,7 +2,6 @@ QGVAR(dragAndFire), "CHECKBOX", [LSTRING(DragAndFire_DisplayName), LSTRING(DragAndFire_Description)], - localize LSTRING(SettingsName), - true, - false + LLSTRING(SettingsName), + true ] call CBA_fnc_addSetting;