Skip to content

Commit

Permalink
fixed spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
AdlerSalbei committed Jun 3, 2019
1 parent 1606749 commit 9628d43
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 216 deletions.
44 changes: 22 additions & 22 deletions addons/trenches/functions/fnc_addDigger.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,38 @@ 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];

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;

Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions addons/trenches/functions/fnc_applyCamouflageAttribute.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
17 changes: 10 additions & 7 deletions addons/trenches/functions/fnc_automaticFilePath.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions addons/trenches/functions/fnc_canPlaceCamouflage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
145 changes: 72 additions & 73 deletions addons/trenches/functions/fnc_continueDiggingTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,110 +29,109 @@ _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];
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
Expand Down
2 changes: 1 addition & 1 deletion addons/trenches/functions/fnc_getSurfaceTexturePath.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
60 changes: 30 additions & 30 deletions addons/trenches/functions/fnc_handleDiggingServer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};
Loading

0 comments on commit 9628d43

Please sign in to comment.