From 8b94d765aad52a61020a3bc194ffcae6ad9439c9 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Wed, 28 Jun 2023 14:43:10 +0300 Subject: [PATCH] Dragging - Allow run when carrying light-weight objects (#8338) * Allow run when carrying light-weight objects * Use global var instead of macro * Update addons/common/XEH_postInit.sqf --------- Co-authored-by: jonpas --- addons/common/XEH_postInit.sqf | 2 +- addons/dragging/XEH_postInit.sqf | 3 +++ addons/dragging/functions/fnc_dropObject_carry.sqf | 1 + addons/dragging/functions/fnc_startCarry.sqf | 13 +++++++++++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 09e0cf309d..00d1a4406b 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -20,7 +20,7 @@ //Status Effect EHs: [QGVAR(setStatusEffect), {_this call FUNC(statusEffect_set)}] call CBA_fnc_addEventHandler; ["forceWalk", false, ["ace_advanced_fatigue", "ACE_SwitchUnits", "ACE_Attach", "ACE_dragging", "ACE_Explosives", "ACE_Ladder", "ACE_Sandbag", "ACE_refuel", "ACE_rearm", "ACE_Trenches", "ace_medical_fracture"]] call FUNC(statusEffect_addType); -["blockSprint", false, ["ace_advanced_fatigue", "ace_medical_fracture"]] call FUNC(statusEffect_addType); +["blockSprint", false, ["ace_advanced_fatigue", "ace_dragging", "ace_medical_fracture"]] call FUNC(statusEffect_addType); ["setCaptive", true, [QEGVAR(captives,Handcuffed), QEGVAR(captives,Surrendered)]] call FUNC(statusEffect_addType); ["blockDamage", false, ["fixCollision", "ACE_cargo"]] call FUNC(statusEffect_addType); ["blockEngine", false, ["ACE_Refuel"]] call FUNC(statusEffect_addType); diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index e151eb6db6..41b0cf0754 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -15,6 +15,9 @@ if (isNil "ACE_maxWeightDrag") then { if (isNil "ACE_maxWeightCarry") then { ACE_maxWeightCarry = 600; }; +if (isNil QGVAR(maxWeightCarryRun)) then { + GVAR(maxWeightCarryRun) = 50; +}; ["isNotDragging", {!((_this select 0) getVariable [QGVAR(isDragging), false])}] call EFUNC(common,addCanInteractWithCondition); ["isNotCarrying", {!((_this select 0) getVariable [QGVAR(isCarrying), false])}] call EFUNC(common,addCanInteractWithCondition); diff --git a/addons/dragging/functions/fnc_dropObject_carry.sqf b/addons/dragging/functions/fnc_dropObject_carry.sqf index c81fb2247b..606e85a090 100644 --- a/addons/dragging/functions/fnc_dropObject_carry.sqf +++ b/addons/dragging/functions/fnc_dropObject_carry.sqf @@ -56,6 +56,7 @@ if (_previousWeaponIndex != -1) then { }; [_unit, "forceWalk", "ACE_dragging", false] call EFUNC(common,statusEffect_set); +[_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 diff --git a/addons/dragging/functions/fnc_startCarry.sqf b/addons/dragging/functions/fnc_startCarry.sqf index 9b1dfaa068..ded6df45d3 100644 --- a/addons/dragging/functions/fnc_startCarry.sqf +++ b/addons/dragging/functions/fnc_startCarry.sqf @@ -19,9 +19,10 @@ params ["_unit", "_target"]; TRACE_2("params",_unit,_target); +private _weight = [_target] call FUNC(getWeight); + // exempt from weight check if object has override variable set if (!GETVAR(_target,GVAR(ignoreWeightCarry),false) && { - private _weight = [_target] call FUNC(getWeight); _weight > GETMVAR(ACE_maxWeightCarry,1E11) }) exitWith { // exit if object weight is over global var value @@ -57,7 +58,15 @@ if (_target isKindOf "CAManBase") then { _unit action ["SwitchWeapon", _unit, _unit, 299]; [_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation); - [_unit, "forceWalk", "ACE_dragging", true] call EFUNC(common,statusEffect_set); + // objects other than containers have calculated weight == 0 so we use getMass + if (-1 == ["ReammoBox_F", "WeaponHolder", "WeaponHolderSimulated"] findIf {_target isKindOf _x}) then { + _weight = getMass _target; + }; + if (_weight > GVAR(maxWeightCarryRun)) then { + [_unit, "forceWalk", "ACE_dragging", true] call EFUNC(common,statusEffect_set); + } else { + [_unit, "blockSprint", "ACE_dragging", true] call EFUNC(common,statusEffect_set); + }; }; [_unit, "blockThrow", "ACE_dragging", true] call EFUNC(common,statusEffect_set);