From 9628d43b3300956957787ff39eedb4946bec2a1d Mon Sep 17 00:00:00 2001 From: Salbei Date: Mon, 3 Jun 2019 12:25:54 +0200 Subject: [PATCH] fixed spacing --- addons/trenches/functions/fnc_addDigger.sqf | 44 +++--- .../fnc_applyCamouflageAttribute.sqf | 4 +- .../functions/fnc_automaticFilePath.sqf | 17 +- .../functions/fnc_canPlaceCamouflage.sqf | 4 +- .../functions/fnc_continueDiggingTrench.sqf | 145 +++++++++--------- .../functions/fnc_getSurfaceTexturePath.sqf | 2 +- .../functions/fnc_handleDiggingServer.sqf | 60 ++++---- addons/trenches/functions/fnc_initTrench.sqf | 13 +- .../functions/fnc_placeCamouflage.sqf | 2 - .../trenches/functions/fnc_removeTrench.sqf | 140 ++++++++--------- 10 files changed, 215 insertions(+), 216 deletions(-) diff --git a/addons/trenches/functions/fnc_addDigger.sqf b/addons/trenches/functions/fnc_addDigger.sqf index c119e81505a..b57184c2dae 100644 --- a/addons/trenches/functions/fnc_addDigger.sqf +++ b/addons/trenches/functions/fnc_addDigger.sqf @@ -21,9 +21,9 @@ params ["_trench", "_unit"]; private _diggingPlayers = _trench getVariable [QGVAR(diggingPlayers), []]; if ( - (count _diggingPlayers) < 1 + (count _diggingPlayers) < 1 ) exitWith { - [_trench, _unit] call FUNC(continueDiggingTrench); + [_trench, _unit] call FUNC(continueDiggingTrench); }; _trench setVariable [QGVAR(diggingPlayers), _diggingPlayers pushBackUnique ACE_player, true]; @@ -31,28 +31,28 @@ _trench setVariable [QGVAR(diggingPlayers), _diggingPlayers pushBackUnique ACE_p private _finishCondition = {false}; private _digTime = 0; switch (_trench getVariable [QGVAR(diggingType), nil]) do { - case "UP" : { - _finishCondition = ((_trench getVariable [QGVAR(progress), 0]) >= 1); - _digTime = missionNamespace getVariable [getText (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(diggingDuration)), 20]; - }; - case "Down" : { - _finishCondition = ((_trench getVariable [QGVAR(progress), 1]) <= 0); - _digTime = missionNamespace getVariable [getText (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(removalDuration)), 20]; - }; - default {ERROR(format ["No value for _type, %1!", _type]);}; + case "UP" : { + _finishCondition = ((_trench getVariable [QGVAR(progress), 0]) >= 1); + _digTime = missionNamespace getVariable [getText (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(diggingDuration)), 20]; + }; + case "Down" : { + _finishCondition = ((_trench getVariable [QGVAR(progress), 1]) <= 0); + _digTime = missionNamespace getVariable [getText (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(removalDuration)), 20]; + }; + default {ERROR(format ["No value for _type, %1!", _type]);}; }; private _handle = [{ - params ["_args", "_handle"]; + params ["_args", "_handle"]; _args params ["_trench", "_unit"]; if ( - (_trench getVariable [QGVAR(nextDigger), ACE_player]) == ACE_player && - count (_trench getVariable [QGVAR(diggingPlayers), []]) < 1 || - !(_trench getVariable [QGVAR(digging), false]) + (_trench getVariable [QGVAR(nextDigger), ACE_player]) == ACE_player && + {count (_trench getVariable [QGVAR(diggingPlayers), []]) < 1} || + {!(_trench getVariable [QGVAR(digging), false])} ) exitWith { - [_handle] call CBA_fnc_removePerFrameHandler; - }; + [_handle] call CBA_fnc_removePerFrameHandler; + }; },0.1, [_trench, _unit]] call CBA_fnc_addPerFrameHandler; @@ -73,12 +73,12 @@ private _fnc_onFailure = { [_unit, "", 1] call EFUNC(common,doAnimation); }; private _fnc_condition = { - (_this select 0) params ["", "_trench", "_handle"]; + (_this select 0) params ["", "_trench", "_handle"]; - if (count (_trench getVariable [QGVAR(diggingPlayers),[]]) <= 1) exitWith {false}; - if (isNil "_handle") exitWith {false}; - if (GVAR(stopBuildingAtFatigueMax) && (QEGVAR(advanced_fatigue,anReserve) <= 0)) exitWith {false}; - true + if (count (_trench getVariable [QGVAR(diggingPlayers),[]]) <= 1) exitWith {false}; + if (isNil "_handle") exitWith {false}; + if (GVAR(stopBuildingAtFatigueMax) && (QEGVAR(advanced_fatigue,anReserve) <= 0)) exitWith {false}; + true }; [_digTime, [_unit, _trench, _handle], _fnc_onFinish, _fnc_onFailure, localize LSTRING(DiggingTrench), _fnc_condition, [], _finishCondition] call EFUNC(common,progressBar); diff --git a/addons/trenches/functions/fnc_applyCamouflageAttribute.sqf b/addons/trenches/functions/fnc_applyCamouflageAttribute.sqf index 182f0838a30..fd16b30ecb1 100644 --- a/addons/trenches/functions/fnc_applyCamouflageAttribute.sqf +++ b/addons/trenches/functions/fnc_applyCamouflageAttribute.sqf @@ -19,7 +19,7 @@ params ["_object", "_value"]; if (_value isEqualTo 1) then { - [_object] call FUNC(placeCamouflage); + [_object] call FUNC(placeCamouflage); } else { - [_object] call FUNC(deleteCamouflage); + [_object] call FUNC(deleteCamouflage); }; diff --git a/addons/trenches/functions/fnc_automaticFilePath.sqf b/addons/trenches/functions/fnc_automaticFilePath.sqf index 7703d4eb42d..76da10e47b8 100644 --- a/addons/trenches/functions/fnc_automaticFilePath.sqf +++ b/addons/trenches/functions/fnc_automaticFilePath.sqf @@ -16,16 +16,19 @@ */ // Check if there is a config entry for the map -if ((isText (configFile >> "CfgWorldTexture" >> worldName >> "surfaceTextureBasePath")) || ("surfaceTexture" in (uiNamespace getVariable ["Intercept_cba_capabilities",[]]))) exitWith {}; +if ( + (isText (configFile >> "CfgWorldTexture" >> worldName >> "surfaceTextureBasePath")) || + {"surfaceTexture" in (uiNamespace getVariable ["Intercept_cba_capabilities",[]])} + ) exitWith {}; private _config = configfile >> "CfgWorldTexture" >> worldName >> "OutsideTerrain" >> "Layers" >> "Layer0" >> "texture"; if !(isText (_config)) exitWith { - LOG("GRAD Trenches: Found no OutsideTerrain texture for Map %1, automatic file path not possible!"); + LOG("GRAD Trenches: Found no OutsideTerrain texture for Map %1, automatic file path not possible!"); }; // Check if the path leads to A3 files private _path = getText (_config); -if (_path find"A3\Map_Data\" >= -1) exitWith { - LOG("GRAD Trenches: Found OutsideTerrain texture not matching path for Map %1, automatic file path not possible!"); +if (_path find "A3\Map_Data\" >= -1) exitWith { + LOG("GRAD Trenches: Found OutsideTerrain texture not matching path for Map %1, automatic file path not possible!"); }; // Split the path and remove the texture @@ -38,9 +41,9 @@ _path = _split joinString "\"; // Check the path for the right ending private _suffix = ".paa"; -if ((_texture find "co.paa" >= -1)|| _texture find "ca.paa" >= -1) then { - _split = _texture splitString "_"; - _suffix = _split select ((count _split) -1); +if ((_texture find "co.paa" >= -1)|| {_texture find "ca.paa" >= -1}) then { + _split = _texture splitString "_"; + _suffix = _split select ((count _split) -1); }; // Setup the GVAR diff --git a/addons/trenches/functions/fnc_canPlaceCamouflage.sqf b/addons/trenches/functions/fnc_canPlaceCamouflage.sqf index c3bf89b78ee..bd0bfd04eec 100644 --- a/addons/trenches/functions/fnc_canPlaceCamouflage.sqf +++ b/addons/trenches/functions/fnc_canPlaceCamouflage.sqf @@ -22,9 +22,9 @@ private _statusNumber = _trench getVariable [QGVAR(trenchCamouflageStatus), 0]; private _statusString = ""; if (_statusNumber < 10) then { - _statusString = ("CamouflagePositions0" + str(_statusNumber +1)); + _statusString = ("CamouflagePositions0" + str(_statusNumber +1)); } else { - _statusString = ("CamouflagePositions" + str(_statusNumber +1)); + _statusString = ("CamouflagePositions" + str(_statusNumber +1)); }; if !(GVAR(allowCamouflage)) exitWith {false}; diff --git a/addons/trenches/functions/fnc_continueDiggingTrench.sqf b/addons/trenches/functions/fnc_continueDiggingTrench.sqf index eae851a7a7d..36f8c81b1bb 100644 --- a/addons/trenches/functions/fnc_continueDiggingTrench.sqf +++ b/addons/trenches/functions/fnc_continueDiggingTrench.sqf @@ -29,11 +29,11 @@ _trench setVariable [QGVAR(diggingType), "UP", true]; private _diggerCount = count (_trench getVariable [QGVAR(diggingPlayers), []]); if (_diggerCount > 0) then { - if !(_switchingDigger) then { - [_trench, _unit] call FUNC(addDigger); - }; + if !(_switchingDigger) then { + [_trench, _unit] call FUNC(addDigger); + }; } else { - _trench setVariable [QGVAR(diggingPlayers), [ACE_player],true]; + _trench setVariable [QGVAR(diggingPlayers), [ACE_player],true]; }; private _digTime = missionNamespace getVariable [getText (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(diggingDuration)), 20]; @@ -41,98 +41,97 @@ private _placeData = _trench getVariable [QGVAR(placeData), [[], []]]; _placeData params ["", "_vecDirAndUp"]; if (isNil "_vecDirAndUp") then { - _vecDirAndUp = [vectorDir _trench, vectorUp _trench]; + _vecDirAndUp = [vectorDir _trench, vectorUp _trench]; }; [QGVAR(handleDiggingServer), [_trench, _unit, true, true]] call CBA_fnc_serverEvent; // Create progress bar private _fnc_onFinish = { - (_this select 0) params ["_unit", "_trench"]; - _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingType), nil, true]; - [QGVAR(handleDiggingServer), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; + (_this select 0) params ["_unit", "_trench"]; + _trench setVariable [QGVAR(digging), false, true]; + _trench setVariable [QGVAR(diggingType), nil, true]; + [QGVAR(handleDiggingServer), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; - // Save progress global - _trench setVariable [QGVAR(progress), 1, true]; + // Save progress global + _trench setVariable [QGVAR(progress), 1, true]; - // Reset animation - [_unit, "", 1] call EFUNC(common,doAnimation); + // Reset animation + [_unit, "", 1] call EFUNC(common,doAnimation); }; private _fnc_onFailure = { - (_this select 0) params ["_unit", "_trench"]; - _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingType), nil, true]; + (_this select 0) params ["_unit", "_trench"]; + _trench setVariable [QGVAR(digging), false, true]; + _trench setVariable [QGVAR(diggingType), nil, true]; - // Save progress global - private _progress = _trench getVariable [QGVAR(progress), 0]; - _trench setVariable [QGVAR(progress), _progress, true]; - [QGVAR(handleDiggingServer), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; + // Save progress global + private _progress = _trench getVariable [QGVAR(progress), 0]; + _trench setVariable [QGVAR(progress), _progress, true]; + [QGVAR(handleDiggingServer), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; - // Reset animation - [_unit, "", 1] call EFUNC(common,doAnimation); + // Reset animation + [_unit, "", 1] call EFUNC(common,doAnimation); }; private _fnc_condition = { - (_this select 0) params ["", "_trench"]; + (_this select 0) params ["", "_trench"]; - if !(_trench getVariable [QGVAR(digging), false]) exitWith {false}; - if (count (_trench getVariable [QGVAR(diggingPlayers),[]]) <= 0) exitWith {false}; - if (GVAR(stopBuildingAtFatigueMax) && (EGVAR(advanced_fatigue,anReserve) <= 0)) exitWith {false}; - true + if !(_trench getVariable [QGVAR(digging), false]) exitWith {false}; + if (count (_trench getVariable [QGVAR(diggingPlayers),[]]) <= 0) exitWith {false}; + if (GVAR(stopBuildingAtFatigueMax) && {EGVAR(advanced_fatigue,anReserve) <= 0}) exitWith {false}; + true }; [_digTime, [_unit, _trench], _fnc_onFinish, _fnc_onFailure, localize LSTRING(DiggingTrench), _fnc_condition, [], ((_trench getVariable [QGVAR(progress), 0]) >= 1)] call EFUNC(common,progressBar); if (_actualProgress == 0) then { - //Remove grass - { - private _trenchGrassCutter = createVehicle ["Land_ClutterCutter_medium_F", [0, 0, 0], [], 0, "NONE"]; - private _cutterPos = AGLToASL (_trench modelToWorld _x); - _cutterPos set [2, getTerrainHeightASL _cutterPos]; - _trenchGrassCutter setPosASL _cutterPos; - deleteVehicle _trenchGrassCutter; - } forEach getArray (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(grassCuttingPoints)); + //Remove grass + { + private _trenchGrassCutter = createVehicle ["Land_ClutterCutter_medium_F", [0, 0, 0], [], 0, "NONE"]; + private _cutterPos = AGLToASL (_trench modelToWorld _x); + _cutterPos set [2, getTerrainHeightASL _cutterPos]; + _trenchGrassCutter setPosASL _cutterPos; + deleteVehicle _trenchGrassCutter; + } forEach getArray (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(grassCuttingPoints)); }; [{ - params ["_args", "_handle"]; - _args params ["_trench", "_unit", "_digTime", "_vecDirAndUp"]; - private _actualProgress = _trench getVariable [QGVAR(progress), 0]; - private _diggerCount =count (_trench getVariable [QGVAR(diggingPlayers), []]); - systemChat str(_actualProgress); - if ( - !(_trench getVariable [QGVAR(digging), false]) || - (_diggerCount <= 0) || - (_actualProgress >= 1) - ) exitWith { - [_handle] call CBA_fnc_removePerFrameHandler; - _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers),[]] - [_unit], true]; - }; - - private _boundingBox = 0 boundingBoxReal _trench; - _boundingBox params ["_lbfc"]; //_lbfc(Left Bottom Front Corner) _rtbc (Right Top Back Corner) - _lbfc params ["", "", "_lbfcZ"]; - - private _pos = getPosWorld _trench; - private _posDiff = ((abs((_trench getVariable [QGVAR(diggingSteps), 0]) + _lbfcZ)) * _diggerCount)/(_digTime*5); - _pos set [2,(_pos select 2) + _posDiff]; - - _trench setPosWorld _pos; - _trench setVectorDirAndUp _vecDirAndUp; - - //Fatigue impact - EGVAR(advanced_fatigue,anReserve) = EGVAR(advanced_fatigue,anReserve) - ((_digTime /12) * GVAR(buildFatigueFactor)) max 0; - EGVAR(advanced_fatigue,anFatigue) = EGVAR(advanced_fatigue,anFatigue) + (((_digTime/12) * GVAR(buildFatigueFactor))/1200) min 1; - - // Save progress - _trench setVariable [QGVAR(progress), _actualProgress + ((1/(_digTime *10)) * _diggerCount)]; - - if (GVAR(stopBuildingAtFatigueMax) && EGVAR(advanced_fatigue,anReserve) <= 0) exitWith { - [_handle] call CBA_fnc_removePerFrameHandler; - _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers), []] - [_unit], true]; - }; + params ["_args", "_handle"]; + _args params ["_trench", "_unit", "_digTime", "_vecDirAndUp"]; + private _actualProgress = _trench getVariable [QGVAR(progress), 0]; + private _diggerCount =count (_trench getVariable [QGVAR(diggingPlayers), []]); + if ( + !(_trench getVariable [QGVAR(digging), false]) || + {_diggerCount <= 0} || + {_actualProgress >= 1} + ) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + _trench setVariable [QGVAR(digging), false, true]; + _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers),[]] - [_unit], true]; + }; + + private _boundingBox = 0 boundingBoxReal _trench; + _boundingBox params ["_lbfc"]; //_lbfc(Left Bottom Front Corner) _rtbc (Right Top Back Corner) + _lbfc params ["", "", "_lbfcZ"]; + + private _pos = getPosWorld _trench; + private _posDiff = ((abs((_trench getVariable [QGVAR(diggingSteps), 0]) + _lbfcZ)) * _diggerCount)/(_digTime*5); + _pos set [2,(_pos select 2) + _posDiff]; + + _trench setPosWorld _pos; + _trench setVectorDirAndUp _vecDirAndUp; + + //Fatigue impact + EGVAR(advanced_fatigue,anReserve) = EGVAR(advanced_fatigue,anReserve) - ((_digTime /12) * GVAR(buildFatigueFactor)) max 0; + EGVAR(advanced_fatigue,anFatigue) = EGVAR(advanced_fatigue,anFatigue) + (((_digTime/12) * GVAR(buildFatigueFactor))/1200) min 1; + + // Save progress + _trench setVariable [QGVAR(progress), _actualProgress + ((1/(_digTime *10)) * _diggerCount)]; + + if (GVAR(stopBuildingAtFatigueMax) && {EGVAR(advanced_fatigue,anReserve) <= 0}) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + _trench setVariable [QGVAR(digging), false, true]; + _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers), []] - [_unit], true]; + }; },0.1,[_trench, _unit, _digTime, _vecDirAndUp]] call CBA_fnc_addPerFrameHandler; // Play animation diff --git a/addons/trenches/functions/fnc_getSurfaceTexturePath.sqf b/addons/trenches/functions/fnc_getSurfaceTexturePath.sqf index db83f82d5cc..89e9d3069e5 100644 --- a/addons/trenches/functions/fnc_getSurfaceTexturePath.sqf +++ b/addons/trenches/functions/fnc_getSurfaceTexturePath.sqf @@ -22,7 +22,7 @@ params [ diag_log format ["ACE_TRENCHES Object: %1", _object]; if (isNull _object) exitWith {}; -if !((isNil QGVAR(automaticFileSetup)) && (isText (configFile >> "CfgWorldTexture" >> worldName >> "surfaceTextureBasePath"))) exitWith {DEFAULT_TEXTURE}; +if !((isNil QGVAR(automaticFileSetup)) && {isText (configFile >> "CfgWorldTexture" >> worldName >> "surfaceTextureBasePath")}) exitWith {DEFAULT_TEXTURE}; private _surfaceType = surfaceType (position _object); diff --git a/addons/trenches/functions/fnc_handleDiggingServer.sqf b/addons/trenches/functions/fnc_handleDiggingServer.sqf index 5eb1cd9e15d..0dd4658c2bf 100644 --- a/addons/trenches/functions/fnc_handleDiggingServer.sqf +++ b/addons/trenches/functions/fnc_handleDiggingServer.sqf @@ -23,42 +23,42 @@ if !(isServer) exitWith {}; params ["_trench", "_unit", ["_state", false], ["_initiator", false]]; if (_initiator) then { - if (_state) then { + if (_state) then { - private _handle = [ - { - params ["_args", "_handle"]; - _args params ["_trench", "_digTime"]; + private _handle = [ + { + params ["_args", "_handle"]; + _args params ["_trench", "_digTime"]; - private _diggingPlayers = _trench getVariable [QGVAR(diggingPlayers), []]; - _diggingPlayers = _diggingPlayers - [objNull]; + private _diggingPlayers = _trench getVariable [QGVAR(diggingPlayers), []]; + _diggingPlayers = _diggingPlayers - [objNull]; - if !(_diggingPlayers isEqualTo (_trench getVariable [QGVAR(diggingPlayers), []])) then { - _trench setVariable [QGVAR(diggingPlayers), _diggingPlayers, true]; - }; + if !(_diggingPlayers isEqualTo (_trench getVariable [QGVAR(diggingPlayers), []])) then { + _trench setVariable [QGVAR(diggingPlayers), _diggingPlayers, true]; + }; - if ( - !(_trench getVariable [QGVAR(digging), false]) - || ((count _diggingPlayers) < 1) - ) exitWith { - [_handle] call CBA_fnc_removePerFrameHandler; - }; + if ( + !(_trench getVariable [QGVAR(digging), false]) + || ((count _diggingPlayers) < 1) + ) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + }; - _trench setVariable [QGVAR(progress), (_trench getVariable [QGVAR(progress), 0]) + ((1/(_digTime *10)) * count _diggingPlayers)]; - }, - 0.1, - [ - _trench, - missionNamespace getVariable [getText (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(diggingDuration)), 20] - ] - ] call CBA_fnc_addPerFrameHandler; + _trench setVariable [QGVAR(progress), (_trench getVariable [QGVAR(progress), 0]) + ((1/(_digTime *10)) * count _diggingPlayers)]; + }, + 0.1, + [ + _trench, + missionNamespace getVariable [getText (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(diggingDuration)), 20] + ] + ] call CBA_fnc_addPerFrameHandler; - _trench setVariable [QGVAR(pfh), _handle]; - }else{ - [_trench getVariable QGVAR(pfh)] call CBA_fnc_removePerFrameHandler; - }; + _trench setVariable [QGVAR(pfh), _handle]; + }else{ + [_trench getVariable QGVAR(pfh)] call CBA_fnc_removePerFrameHandler; + }; } else { - if (isNull (_trench getVariable [QGVAR(mainDigger), objNull])) exitWith {}; + if (isNull (_trench getVariable [QGVAR(mainDigger), objNull])) exitWith {}; - [_trench, _unit, _trench getVariable [QGVAR(progress), 0]] remoteExecCall [FUNC(addDigger), _unit, false]; + [_trench, _unit, _trench getVariable [QGVAR(progress), 0]] remoteExecCall [FUNC(addDigger), _unit, false]; }; diff --git a/addons/trenches/functions/fnc_initTrench.sqf b/addons/trenches/functions/fnc_initTrench.sqf index acc2ddd6f5f..9651da8ee60 100644 --- a/addons/trenches/functions/fnc_initTrench.sqf +++ b/addons/trenches/functions/fnc_initTrench.sqf @@ -27,11 +27,10 @@ if (is3DEN) exitWith { }; if (local _object) then { - // Has to be delayed to ensure MP compatibility (vehicle spawned in same frame as texture is applied) - [{ - private _obj = if (_this isEqualType []) then {_this select 0} else {_this}; - diag_log format ["InitTrench: %1", _obj]; - private _texture = [_obj] call FUNC(getSurfaceTexturePath); - _obj setObjectTextureGlobal [0, _texture]; - }, _this] call CBA_fnc_execNextFrame; + // Has to be delayed to ensure MP compatibility (vehicle spawned in same frame as texture is applied) + [{ + private _obj = if (_this isEqualType []) then {_this select 0} else {_this}; + private _texture = [_obj] call FUNC(getSurfaceTexturePath); + _obj setObjectTextureGlobal [0, _texture]; + }, _this] call CBA_fnc_execNextFrame; }; diff --git a/addons/trenches/functions/fnc_placeCamouflage.sqf b/addons/trenches/functions/fnc_placeCamouflage.sqf index 759700cebe6..4fb31e559d7 100644 --- a/addons/trenches/functions/fnc_placeCamouflage.sqf +++ b/addons/trenches/functions/fnc_placeCamouflage.sqf @@ -37,7 +37,6 @@ private _fnc_onFinish = { _statusString = str(_statusNumber); }; - private _placedObjects = []; private _camouflageObjectsArray = _trench getVariable [QGVAR(camouflageObjects), []]; @@ -56,7 +55,6 @@ private _fnc_onFinish = { _camouflageObjectsArray pushBack _placedObjects; reverse _camouflageObjectsArray; - _trench setVariable [QGVAR(camouflageObjects), _camouflageObjectsArray, true]; _trench setVariable [QGVAR(trenchCamouflageStatus), _statusNumber]; diff --git a/addons/trenches/functions/fnc_removeTrench.sqf b/addons/trenches/functions/fnc_removeTrench.sqf index 8b324248e0d..9f7534a8b50 100644 --- a/addons/trenches/functions/fnc_removeTrench.sqf +++ b/addons/trenches/functions/fnc_removeTrench.sqf @@ -28,11 +28,11 @@ _trench setVariable [QGVAR(diggingType), "DOWN", true]; private _diggerCount = count (_trench getVariable [QGVAR(diggingPlayers), []]); if (_diggerCount > 0) then { - if !(_switchingDigger) then { - [_trench, _unit] call FUNC(addDigger); - }; + if !(_switchingDigger) then { + [_trench, _unit] call FUNC(addDigger); + }; } else { - _trench setVariable [QGVAR(diggingPlayers), [ACE_player],true]; + _trench setVariable [QGVAR(diggingPlayers), [ACE_player],true]; }; private _removeTime = missionNamespace getVariable [getText (configFile >> "CfgVehicles" >> (typeOf _trench) >> QGVAR(removalDuration)), 20]; @@ -41,91 +41,91 @@ private _placeData = _trench getVariable [QGVAR(placeData), [[], []]]; _placeData params ["", "_vecDirAndUp"]; if (isNil "_vecDirAndUp") then { - _vecDirAndUp = [vectorDir _trench, vectorUp _trench]; + _vecDirAndUp = [vectorDir _trench, vectorUp _trench]; }; [QGVAR(handleDiggingServer), [_trench, _unit, true, true]] call CBA_fnc_serverEvent; // Create progress bar private _fnc_onFinish = { - (_this select 0) params ["_unit", "_trench"]; - _trench setVariable [QGVAR(diggingType), nil, true]; - [QGVAR(handleDiggingServer), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; + (_this select 0) params ["_unit", "_trench"]; + _trench setVariable [QGVAR(diggingType), nil, true]; + [QGVAR(handleDiggingServer), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; - // Remove trench - deleteVehicle _trench; + // Remove trench + deleteVehicle _trench; - // Reset animation - [_unit, "", 1] call EFUNC(common,doAnimation); + // Reset animation + [_unit, "", 1] call EFUNC(common,doAnimation); }; private _fnc_onFailure = { - (_this select 0) params ["_unit", "_trench"]; - _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingType), nil, true]; - [QGVAR(handleDiggingServer), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; + (_this select 0) params ["_unit", "_trench"]; + _trench setVariable [QGVAR(digging), false, true]; + _trench setVariable [QGVAR(diggingType), nil, true]; + [QGVAR(handleDiggingServer), [_trench, _unit, false, true]] call CBA_fnc_serverEvent; - // Save progress global - private _progress = _trench getVariable [QGVAR(progress), 0]; - _trench setVariable [QGVAR(progress), _progress, true]; + // Save progress global + private _progress = _trench getVariable [QGVAR(progress), 0]; + _trench setVariable [QGVAR(progress), _progress, true]; - // Reset animation - [_unit, "", 1] call EFUNC(common,doAnimation); + // Reset animation + [_unit, "", 1] call EFUNC(common,doAnimation); }; private _fnc_condition = { - (_this select 0) params ["", "_trench"]; + (_this select 0) params ["", "_trench"]; - if !(_trench getVariable [QGVAR(digging), false]) exitWith {false}; - if (count (_trench getVariable [QGVAR(diggingPlayers), []]) <= 0) exitWith {false}; - if (GVAR(stopBuildingAtFatigueMax) && (EGVAR(advanced_fatigue,anReserve) <= 0)) exitWith {false}; - true + if !(_trench getVariable [QGVAR(digging), false]) exitWith {false}; + if (count (_trench getVariable [QGVAR(diggingPlayers), []]) <= 0) exitWith {false}; + if (GVAR(stopBuildingAtFatigueMax) && {EGVAR(advanced_fatigue,anReserve) <= 0}) exitWith {false}; + true }; [[_unit, _trench], _fnc_onFinish, _fnc_onFailure, localize LSTRING(RemovingTrench), _fnc_condition, [], ((_trench getVariable [QGVAR(progress), 1]) <= 0)] call EFUNC(common,progressBar); [{ - params ["_args", "_handle"]; - _args params ["_trench", "_unit", "_removeTime", "_vecDirAndUp"]; - private _actualProgress = _trench getVariable [QGVAR(progress), 0]; - private _diggerCount = count (_trench getVariable [QGVAR(diggingPlayers), []]); - - if (_actualProgress <= 0) exitWith { - [_handle] call CBA_fnc_removePerFrameHandler; - _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingPlayers), [], true]; - deleteVehicle _trench; - }; - - if ( - !(_trench getVariable [QGVAR(digging), false]) || - (_diggerCount <= 0) - ) exitWith { - [_handle] call CBA_fnc_removePerFrameHandler; - _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers), []] - [_unit], true]; - }; - - private _boundingBox = 0 boundingBoxReal _trench; - _boundingBox params ["_lbfc"]; //_lbfc(Left Bottom Front Corner) _rtbc (Right Top Back Corner) - _lbfc params ["", "", "_lbfcZ"]; - - private _pos = getPosWorld _trench; - private _posDiff = (abs(((_trench getVariable [QGVAR(diggingSteps), 0]) * _diggerCount) + _lbfcZ))/(_removeTime*5); - _pos set [2,((_pos select 2) - _posDiff)]; - - _trench setPosWorld _pos; - _trench setVectorDirAndUp _vecDirAndUp; - - //Fatigue impact - EGVAR(advanced_fatigue,anReserve) = (EGVAR(advanced_fatigue,anReserve) - ((_removeTime /12) * GVAR(buildFatigueFactor))) max 0; - EGVAR(advanced_fatigue,anFatigue) = (EGVAR(advanced_fatigue,anFatigue) + (((_removeTime /12) * GVAR(buildFatigueFactor))/1200)) min 1; - - // Save progress - _trench setVariable [QGVAR(progress), (_actualProgress - ((1/(_removeTime *10)) * _diggerCount)), true]; - - if (GVAR(stopBuildingAtFatigueMax) && (EGVAR(advanced_fatigue,anReserve) <= 0)) exitWith { - [_handle] call CBA_fnc_removePerFrameHandler; - _trench setVariable [QGVAR(digging), false, true]; - _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers), []] - [_unit], true]; - }; + params ["_args", "_handle"]; + _args params ["_trench", "_unit", "_removeTime", "_vecDirAndUp"]; + private _actualProgress = _trench getVariable [QGVAR(progress), 0]; + private _diggerCount = count (_trench getVariable [QGVAR(diggingPlayers), []]); + + if (_actualProgress <= 0) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + _trench setVariable [QGVAR(digging), false, true]; + _trench setVariable [QGVAR(diggingPlayers), [], true]; + deleteVehicle _trench; + }; + + if ( + !(_trench getVariable [QGVAR(digging), false]) || + {_diggerCount <= 0} + ) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + _trench setVariable [QGVAR(digging), false, true]; + _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers), []] - [_unit], true]; + }; + + private _boundingBox = 0 boundingBoxReal _trench; + _boundingBox params ["_lbfc"]; //_lbfc(Left Bottom Front Corner) _rtbc (Right Top Back Corner) + _lbfc params ["", "", "_lbfcZ"]; + + private _pos = getPosWorld _trench; + private _posDiff = (abs(((_trench getVariable [QGVAR(diggingSteps), 0]) * _diggerCount) + _lbfcZ))/(_removeTime*5); + _pos set [2,((_pos select 2) - _posDiff)]; + + _trench setPosWorld _pos; + _trench setVectorDirAndUp _vecDirAndUp; + + //Fatigue impact + EGVAR(advanced_fatigue,anReserve) = (EGVAR(advanced_fatigue,anReserve) - ((_removeTime /12) * GVAR(buildFatigueFactor))) max 0; + EGVAR(advanced_fatigue,anFatigue) = (EGVAR(advanced_fatigue,anFatigue) + (((_removeTime /12) * GVAR(buildFatigueFactor))/1200)) min 1; + + // Save progress + _trench setVariable [QGVAR(progress), (_actualProgress - ((1/(_removeTime *10)) * _diggerCount)), true]; + + if (GVAR(stopBuildingAtFatigueMax) && {EGVAR(advanced_fatigue,anReserve) <= 0}) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + _trench setVariable [QGVAR(digging), false, true]; + _trench setVariable [QGVAR(diggingPlayers), _trench getVariable [QGVAR(diggingPlayers), []] - [_unit], true]; + }; },0.1,[_trench, _unit, _removeTime, _vecDirAndUp]] call CBA_fnc_addPerFrameHandler; // Play animation