Skip to content

Commit

Permalink
at long last it's fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
AdlerSalbei committed Oct 22, 2023
1 parent a3bad47 commit 0d5d7ed
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 51 deletions.
22 changes: 9 additions & 13 deletions addons/functions/functions/fnc_addDigger.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,30 @@ private _condition = if (!isNil "_diggingType" && {_diggingType == "DOWN"}) then
[
{
params ["_args", "_handle"];
_args params ["_unit", "_trench", "_condition"];

systemChat "Helping";
_args params ["_unit", "_trench", "_condition","_finishCondition"];

if (isNull _trench || {[_trench] call _condition} || {!alive _unit}) exitWith {

systemChat "Stopped PFH Help 1";

[_handle] call CBA_fnc_removePerFrameHandler;
_unit setVariable [QGVAR(diggingTrench), false, true];
[QGVAR(handleDiggerToGVAR), [_trench, _unit, true]] call CBA_fnc_serverEvent;
};

if (_unit getVariable [QGVAR(diggingTrench), false] && {((_trench getVariable [QGVAR(diggers), []]) select 0) isEqualTo ([] call CBA_fnc_currentUnit)}) exitWith {

systemChat "Stopped PFH Help 2";

[_handle] call CBA_fnc_removePerFrameHandler;
[_trench, _unit, true] call FUNC(continueDiggingTrench);

if (_finishCondition) then {
[{_this call FUNC(continueDiggingTrench);}, [_trench, _unit, true]] call CBA_fnc_ExecNextFrame;
} else {
[{_this call FUNC(continueDiggingTrench);}, [_trench, _unit, true]] call CBA_fnc_ExecNextFrame;
};

_unit setVariable [QGVAR(helpingFunctionRunning), false];
};

if !(_unit getVariable [QGVAR(diggingTrench), false]) exitWith {

systemChat "Stopped PFH Help 3";

[_handle] call CBA_fnc_removePerFrameHandler;
[QGVAR(handleDiggerToGVAR), [_trench, _unit, true]] call CBA_fnc_serverEvent;
};
Expand All @@ -88,7 +86,7 @@ private _condition = if (!isNil "_diggingType" && {_diggingType == "DOWN"}) then
[QGVAR(applyFatigue), [_trench, _unit], _unit] call CBA_fnc_targetEvent;
},
0.1,
[_unit, _trench, _condition]
[_unit, _trench, _condition, _finishCondition]
] call CBA_fnc_addPerFrameHandler;

// Create progress bar
Expand All @@ -104,8 +102,6 @@ private _fnc_onFinish = {
private _fnc_onFailure = {
(_this select 0) params ["_unit", "_trench", ""];

systemChat "Stopped Help Bar";

// Reset animation
[_unit, "", 1] call ace_common_fnc_doAnimation;
};
Expand Down
29 changes: 4 additions & 25 deletions addons/functions/functions/fnc_continueDiggingTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ 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];
Expand All @@ -45,8 +44,6 @@ private _digTime = missionNamespace getVariable [getText (configOf _trench >> "a
private _fnc_onFinish = {
(_this select 0) params ["_unit", "_trench"];

systemChat "Done";

_unit setVariable [QGVAR(diggingTrench), false, true];
[QGVAR(handleTrenchState), [_trench]] call CBA_fnc_serverEvent;
[QGVAR(handleDiggerToGVAR), [_trench, _unit, false, true]] call CBA_fnc_serverEvent;
Expand All @@ -60,9 +57,6 @@ private _fnc_onFinish = {
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;

Expand All @@ -76,18 +70,10 @@ private _fnc_onFailure = {
private _fnc_condition = {
(_this select 0) params ["_unit", "_trench"];

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};
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};

true
};
Expand All @@ -109,8 +95,6 @@ if (_actualProgress == 0) then {
params ["_args", "_handle"];
_args params ["_trench", "_unit", "_digTime"];

systemChat "UP";

private _actualProgress = _trench getVariable ["ace_trenches_progress", 0];
private _diggerCount = count (_trench getVariable [QGVAR(diggers), []]);

Expand All @@ -120,8 +104,6 @@ if (_actualProgress == 0) then {
{_diggerCount <= 0}
) exitWith {

systemChat "Stopped PFH continue 1";

[_handle] call CBA_fnc_removePerFrameHandler;
if (_diggerCount < 1) then {
_trench setVariable ["ace_trenches_digging", false, true];
Expand All @@ -131,9 +113,6 @@ if (_actualProgress == 0) then {
};

if (_actualProgress >= 1) exitWith {

systemChat "Stopped PFH continue 2";

[_handle] call CBA_fnc_removePerFrameHandler;
};

Expand Down
1 change: 0 additions & 1 deletion addons/functions/functions/fnc_deleteTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

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;
Expand Down
1 change: 0 additions & 1 deletion addons/functions/functions/fnc_handleTrenchState.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@

params ["_trench"];

systemChat "Set in Handle line 23";
_trench setVariable ["ace_trenches_digging", false, true];
_trench setVariable [QGVAR(diggingType), nil, true];
11 changes: 0 additions & 11 deletions addons/functions/functions/fnc_removeTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ 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];
Expand All @@ -47,8 +46,6 @@ _trench setVariable [QGVAR(diggers), [_unit], true];
private _fnc_onFinish = {
(_this select 0) params ["_unit", "_trench"];

systemChat "Deleted";

[_trench, _unit] call FUNC(deleteTrench);

// Reset animation
Expand All @@ -57,8 +54,6 @@ private _fnc_onFinish = {
private _fnc_onFailure = {
(_this select 0) params ["_unit", "_trench"];

systemChat "Stopped";

_unit setVariable [QGVAR(diggingTrench), false, true];
[QGVAR(handleDiggerToGVAR), [_trench, _unit, true]] call CBA_fnc_serverEvent;

Expand Down Expand Up @@ -89,8 +84,6 @@ private _fnc_condition = {
params ["_args", "_handle"];
_args params ["_trench", "_unit", "_removeTime"];

systemChat "Down";

private _actualProgress = _trench getVariable ["ace_trenches_progress", 0];
private _diggerCount = count (_trench getVariable [QGVAR(diggers), []]);

Expand All @@ -100,8 +93,6 @@ private _fnc_condition = {
{_diggerCount <= 0}
) exitWith {

systemChat "Stopped PFH remove 1";

[_handle] call CBA_fnc_removePerFrameHandler;
if (_diggerCount < 1) then {
_trench setVariable ["ace_trenches_digging", false, true];
Expand All @@ -110,8 +101,6 @@ private _fnc_condition = {
};

if (_actualProgress <= 0) exitWith {

systemChat "Stopped PFH remove 2";
[_handle] call CBA_fnc_removePerFrameHandler;
};

Expand Down

0 comments on commit 0d5d7ed

Please sign in to comment.