Skip to content

Commit

Permalink
more fixes, still not working
Browse files Browse the repository at this point in the history
  • Loading branch information
AdlerSalbei committed Oct 22, 2023
1 parent e7857d0 commit a3bad47
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
6 changes: 4 additions & 2 deletions addons/functions/functions/fnc_addDigger.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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]
Expand Down Expand Up @@ -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
};
Expand Down
23 changes: 18 additions & 5 deletions addons/functions/functions/fnc_continueDiggingTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand All @@ -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
};
Expand Down Expand Up @@ -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;
};

Expand Down
1 change: 1 addition & 0 deletions addons/functions/functions/fnc_deleteTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions addons/functions/functions/fnc_handleTrenchState.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
15 changes: 5 additions & 10 deletions addons/functions/functions/fnc_removeTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
};

Expand All @@ -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
Expand Down

0 comments on commit a3bad47

Please sign in to comment.