From a3bad47dcbdf34130d80a7ba6c5d6d5fe100e163 Mon Sep 17 00:00:00 2001 From: Salbei Date: Sun, 22 Oct 2023 18:13:06 +0200 Subject: [PATCH] more fixes, still not working --- addons/functions/functions/fnc_addDigger.sqf | 6 +++-- .../functions/fnc_continueDiggingTrench.sqf | 23 +++++++++++++++---- .../functions/functions/fnc_deleteTrench.sqf | 1 + .../functions/fnc_handleTrenchState.sqf | 1 + .../functions/functions/fnc_removeTrench.sqf | 15 ++++-------- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/addons/functions/functions/fnc_addDigger.sqf b/addons/functions/functions/fnc_addDigger.sqf index c5dc529c..c9b83312 100644 --- a/addons/functions/functions/fnc_addDigger.sqf +++ b/addons/functions/functions/fnc_addDigger.sqf @@ -27,6 +27,7 @@ if (_diggersCount < 1) exitWith { [QGVAR(handleDiggerToGVAR), [_trench, _unit, false]] call CBA_fnc_serverEvent; _unit setVariable [QGVAR(diggingTrench), true, true]; +_unit setVariable [QGVAR(helpingFunctionRunning), true]; private _diggingType = _trench getVariable QGVAR(diggingType); private _finishCondition = true; @@ -72,6 +73,7 @@ private _condition = if (!isNil "_diggingType" && {_diggingType == "DOWN"}) then [_handle] call CBA_fnc_removePerFrameHandler; [_trench, _unit, true] call FUNC(continueDiggingTrench); + _unit setVariable [QGVAR(helpingFunctionRunning), false]; }; if !(_unit getVariable [QGVAR(diggingTrench), false]) exitWith { @@ -83,8 +85,7 @@ private _condition = if (!isNil "_diggingType" && {_diggingType == "DOWN"}) then }; // Fatigue impact - ace_advanced_fatigue_anReserve = (ace_advanced_fatigue_anReserve - (2 * GVAR(buildFatigueFactor))) max 0; - ace_advanced_fatigue_anFatigue = (ace_advanced_fatigue_anFatigue + (GVAR(buildFatigueFactor) / 1000)) min 0.8; // 2 * GVAR(buildFatigueFactor) / 2000 + [QGVAR(applyFatigue), [_trench, _unit], _unit] call CBA_fnc_targetEvent; }, 0.1, [_unit, _trench, _condition] @@ -115,6 +116,7 @@ private _fnc_condition = { if (GVAR(stopBuildingAtFatigueMax) && {ace_advanced_fatigue_anReserve <= 0}) exitWith {false}; if !(_unit getVariable [QGVAR(diggingTrench), false]) exitWith {false}; if (count (_trench getVariable [QGVAR(diggers), []]) < 1) exitWith {false}; + if !(_unit getVariable [QGVAR(helpingFunctionRunning), false]) exitWith {false}; true }; diff --git a/addons/functions/functions/fnc_continueDiggingTrench.sqf b/addons/functions/functions/fnc_continueDiggingTrench.sqf index 39e767a4..c073dd9f 100644 --- a/addons/functions/functions/fnc_continueDiggingTrench.sqf +++ b/addons/functions/functions/fnc_continueDiggingTrench.sqf @@ -25,6 +25,7 @@ if (_actualProgress >= 1) exitWith {}; // Mark trench as being worked on +systemChat "Set in Continue line 28"; _trench setVariable ["ace_trenches_digging", true, true]; _trench setVariable [QGVAR(diggingType), "UP", true]; _unit setVariable [QGVAR(diggingTrench), true, true]; @@ -60,6 +61,7 @@ private _fnc_onFailure = { (_this select 0) params ["_unit", "_trench"]; systemChat "Stopped Continue Bar"; + diag_log "Stopped Continue Bar"; _unit setVariable [QGVAR(diggingTrench), false, true]; [QGVAR(handleDiggerToGVAR), [_trench, _unit, true]] call CBA_fnc_serverEvent; @@ -74,10 +76,18 @@ private _fnc_onFailure = { private _fnc_condition = { (_this select 0) params ["_unit", "_trench"]; - if !(_trench getVariable ["ace_trenches_digging", false]) exitWith {false}; - if !(_unit getVariable [QGVAR(diggingTrench), false]) exitWith {false}; - if (count (_trench getVariable [QGVAR(diggers),[]]) <= 0) exitWith {false}; - if (GVAR(stopBuildingAtFatigueMax) && (ace_advanced_fatigue_anReserve <= 0)) exitWith {false}; + if !(_trench getVariable ["ace_trenches_digging", false]) exitWith { + systemChat format ["Trench: %1",(_trench getVariable ["ace_trenches_digging", false])]; + false}; + if !(_unit getVariable [QGVAR(diggingTrench), false]) exitWith { + systemChat format ["Unit: %1", (_unit getVariable [QGVAR(diggingTrench), false])]; + false}; + if (count (_trench getVariable [QGVAR(diggers),[]]) <= 0) exitWith { + systemChat format ["Diggers: %1", (count (_trench getVariable [QGVAR(diggers),[]]))]; + false}; + if (GVAR(stopBuildingAtFatigueMax) && (ace_advanced_fatigue_anReserve <= 0)) exitWith { + systemChat format ["Stamina: %1", ace_advanced_fatigue_anReserve]; + false}; true }; @@ -113,7 +123,10 @@ if (_actualProgress == 0) then { systemChat "Stopped PFH continue 1"; [_handle] call CBA_fnc_removePerFrameHandler; - _trench setVariable ["ace_trenches_digging", false, true]; + if (_diggerCount < 1) then { + _trench setVariable ["ace_trenches_digging", false, true]; + }; + [QGVAR(handleDiggerToGVAR), [_trench, _unit, true]] call CBA_fnc_serverEvent; }; diff --git a/addons/functions/functions/fnc_deleteTrench.sqf b/addons/functions/functions/fnc_deleteTrench.sqf index ae1a4884..215a9e81 100644 --- a/addons/functions/functions/fnc_deleteTrench.sqf +++ b/addons/functions/functions/fnc_deleteTrench.sqf @@ -18,6 +18,7 @@ params ["_trench", ["_unit", objNull]]; +systemChat "Set in Delete line 21"; _trench setVariable ["ace_trenches_digging", false, true]; _trench setVariable [QGVAR(diggingType), nil, true]; [QGVAR(handleDiggerToGVAR), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; diff --git a/addons/functions/functions/fnc_handleTrenchState.sqf b/addons/functions/functions/fnc_handleTrenchState.sqf index f5b6358a..5d2f3065 100644 --- a/addons/functions/functions/fnc_handleTrenchState.sqf +++ b/addons/functions/functions/fnc_handleTrenchState.sqf @@ -20,5 +20,6 @@ params ["_trench"]; +systemChat "Set in Handle line 23"; _trench setVariable ["ace_trenches_digging", false, true]; _trench setVariable [QGVAR(diggingType), nil, true]; \ No newline at end of file diff --git a/addons/functions/functions/fnc_removeTrench.sqf b/addons/functions/functions/fnc_removeTrench.sqf index 74d77769..93edf92d 100644 --- a/addons/functions/functions/fnc_removeTrench.sqf +++ b/addons/functions/functions/fnc_removeTrench.sqf @@ -24,6 +24,7 @@ private _actualProgress = _trench getVariable ["ace_trenches_progress", 0]; if (_actualProgress <= 0) exitWith {}; // Mark trench as being worked on +systemChat "Set in Remove line 27"; _trench setVariable ["ace_trenches_digging", true, true]; _trench setVariable [QGVAR(diggingType), "DOWN", true]; _unit setVariable [QGVAR(diggingTrench), true, true]; @@ -102,7 +103,9 @@ private _fnc_condition = { systemChat "Stopped PFH remove 1"; [_handle] call CBA_fnc_removePerFrameHandler; - _trench setVariable ["ace_trenches_digging", false, true]; + if (_diggerCount < 1) then { + _trench setVariable ["ace_trenches_digging", false, true]; + }; [QGVAR(handleDiggerToGVAR), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; }; @@ -124,15 +127,7 @@ private _fnc_condition = { }; // Fatigue impact - ace_advanced_fatigue_anReserve = (ace_advanced_fatigue_anReserve - (2 * GVAR(buildFatigueFactor))) max 0; - ace_advanced_fatigue_anFatigue = (ace_advanced_fatigue_anFatigue + (GVAR(buildFatigueFactor) / 1000)) min 1; // 2 * GVAR(buildFatigueFactor) / 2000 - - if (GVAR(stopBuildingAtFatigueMax) && {ace_advanced_fatigue_anReserve <= 0}) exitWith { - [_handle] call CBA_fnc_removePerFrameHandler; - _trench setVariable ["ace_trenches_digging", false, true]; - [QGVAR(handleDiggerToGVAR), [_trench, _unit, true]] call CBA_fnc_serverEvent; - _unit setVariable [QGVAR(diggingTrench), false]; - }; + [QGVAR(applyFatigue), [_trench, _unit], _unit] call CBA_fnc_targetEvent; }, 1, [_trench, _unit, _removeTime]] call CBA_fnc_addPerFrameHandler; // Play animation