Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AdlerSalbei committed Dec 10, 2018
1 parent 95bc511 commit f33224a
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 154 deletions.
33 changes: 14 additions & 19 deletions addons/trenches/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CfgVehicles {
exceptions[] = {"notOnMap", "isNotInside", "isNotSitting"};
class GVAR(digEnvelopeShort) {
displayName = CSTRING(DigEnvelopeShort);
condition = QUOTE(GVAR(allowDigging) && ([ARR_2(_target,_player)] call FUNC(canContinueDiggingTrench)) && GVAR(allowShortEnvelope));
condition = QUOTE(GVAR(allowDigging) && (_this call FUNC(canContinueDiggingTrench)) && GVAR(allowShortEnvelope));
//wait a frame to handle "Do When releasing action menu key" option
statement = QUOTE([ARR_2({_this call FUNC(placeTrench)},[ARR_2(_this select 0,'ACE_envelope_short')])] call CBA_fnc_execNextFrame);
exceptions[] = {};
Expand All @@ -25,24 +25,24 @@ class CfgVehicles {
};
class GVAR(digEnvelopeSmall): GVAR(digEnvelopeShort) {
displayName = CSTRING(DigEnvelopeSmall);
condition = QUOTE(GVAR(allowDigging) && ([ARR_2(_target,_player)] call FUNC(canContinueDiggingTrench)) && GVAR(allowSmallEnvelope));
condition = QUOTE(GVAR(allowDigging) && (_this call FUNC(canContinueDiggingTrench)) && GVAR(allowSmallEnvelope));
//wait a frame to handle "Do When releasing action menu key" option
statement = QUOTE([ARR_2({_this call FUNC(placeTrench)},[ARR_2(_this select 0,'ACE_envelope_small')])] call CBA_fnc_execNextFrame);
};
class GVAR(digEnvelopeBig): GVAR(digEnvelopeShort) {
displayName = CSTRING(DigEnvelopeBig);
condition = QUOTE(GVAR(allowDigging) && ([ARR_2(_target,_player)] call FUNC(canContinueDiggingTrench)) && GVAR(allowBigEnvelope));
condition = QUOTE(GVAR(allowDigging) && (_this call FUNC(canContinueDiggingTrench)) && GVAR(allowBigEnvelope));
//wait a frame to handle "Do When releasing action menu key" option
statement = QUOTE([ARR_2({_this call FUNC(placeTrench)},[ARR_2(_this select 0,'ACE_envelope_big')])] call CBA_fnc_execNextFrame);
};
class GVAR(DigEnvelopeGiant): GVAR(digEnvelopeShort) {
displayName = CSTRING(DigEnvelopeGiant);
condition = QUOTE(_player call FUNC(canDigTrench) && ([ARR_2(_target,_player)] call FUNC(canContinueDiggingTrench)) && GVAR(allowGiantEnvelope));
condition = QUOTE(_player call FUNC(canDigTrench) && (_this call FUNC(canContinueDiggingTrench)) && GVAR(allowGiantEnvelope));
statement = QUOTE([ARR_2({_this call FUNC(placeTrench)},[ARR_2(_this select 0,'ACE_envelope_giant')])] call CBA_fnc_execNextFrame);
};
class GVAR(DigEnvelopeVehicle): GVAR(digEnvelopeShort) {
displayName = CSTRING(DigEnvelopeVehicle);
condition = QUOTE(_player call FUNC(canDigTrench) && ([ARR_2(_target,_player)] call FUNC(canContinueDiggingTrench)) && GVAR(allowVehicleEnvelope));
condition = QUOTE(_player call FUNC(canDigTrench) && (_this call FUNC(canContinueDiggingTrench)) && GVAR(allowVehicleEnvelope));
statement = QUOTE([ARR_2({_this call FUNC(placeTrench)},[ARR_2(_this select 0,'ACE_envelope_vehicle')])] call CBA_fnc_execNextFrame);
};
};
Expand Down Expand Up @@ -82,33 +82,28 @@ class CfgVehicles {
condition = QUOTE(true);
class GVAR(continueDigging) {
displayName = CSTRING(continueDiggingTrench);
condition = QUOTE([ARR_2(_target,_player)] call FUNC(canContinueDiggingTrench));
statement = QUOTE([ARR_2(_target,_player)] call FUNC(continueDiggingTrench););
priority = -1;
condition = QUOTE(_this call FUNC(canContinueDiggingTrench));
statement = QUOTE(_this call FUNC(continueDiggingTrench););
};
class GVAR(helpDigging) {
displayName = CSTRING(HelpDigging); \
condition = QUOTE([ARR_2(_target,_player)] call FUNC(canHelpDiggingTrench));
statement = QUOTE([ARR_2(_target,_player)] call FUNC(addDigger));
priority = -1;
condition = QUOTE(_this call FUNC(canHelpDiggingTrench));
statement = QUOTE(_this call FUNC(addDigger));
};
class GVAR(remove) {
displayName = CSTRING(removeEnvelope);
condition = QUOTE([ARR_2(_target,_player)] call FUNC(canRemoveTrench));
statement = QUOTE([ARR_2(_target,_player)] call FUNC(removeTrench););
priority = -1;
condition = QUOTE(_this call FUNC(canRemoveTrench));
statement = QUOTE(_this call FUNC(removeTrench););
};
class GVAR(placeCamouflage) {
displayName = CSTRING(placeCamouflage);
condition = QUOTE([ARR_2(_target,_player)] call FUNC(canPlaceCamouflage));
statement = QUOTE([ARR_2(_target,_player)] call FUNC(placeCamouflage));
priority = -1;
condition = QUOTE(_this call FUNC(canPlaceCamouflage));
statement = QUOTE(_this call FUNC(placeCamouflage));
};
class GVAR(removeCamouflage) {
displayName = CSTRING(removeCamouflage);
condition = QUOTE([_target] call FUNC(canRemoveCamouflage));
statement = QUOTE([ARR_2(_target,_player)] call FUNC(removeCamouflage));
priority = -1;
statement = QUOTE(_this call FUNC(removeCamouflage));
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion addons/trenches/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ if ("surfaceTexture" in (uiNamespace getVariable ["Intercept_cba_capabilities",[
#endif
} else {
PREP(getSurfaceTexturePath);
}
};
4 changes: 3 additions & 1 deletion addons/trenches/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class CfgPatches {
author = ECSTRING(common,ACETeam);
authors[] = {"Grey", "esteldunedain", "chris579", "Salbei"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
version = "3.12.5.40";
versionStr = "3.12.5.40";
versionAr[] = {3,12,5,40};
};
};

Expand Down
4 changes: 2 additions & 2 deletions addons/trenches/functions/fnc_automaticFilePath.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
if ((isText (configFile >> "CfgWorlds" >> worldName >> "surfaceTextureBasePath")) || ("surfaceTexture" in (uiNamespace getVariable ["Intercept_cba_capabilities",[]]))) exitWith {};
private _config = configfile >> "CfgWorlds" >> worldName >> "OutsideTerrain" >> "Layers" >> "Layer0" >> "texture";
if !(isText (_config)) exitWith {
diag_log format ["GRAD Trenches: Found no OutsideTerrain texture for Map %1, automatic file path not possible!", worldName];
LOG("GRAD Trenches: Found no OutsideTerrain texture for Map %1, automatic file path not possible!");
};
private _path = getText (_config);
if (_path find"A3\Map_Data\" >= -1) exitWith {
diag_log format ["GRAD Trenches: Found OutsideTerrain texture not matching path for Map %1, automatic file path not possible!", worldName];
LOG("GRAD Trenches: Found OutsideTerrain texture not matching path for Map %1, automatic file path not possible!");
};

private _split = _path splitString "\";
Expand Down
122 changes: 61 additions & 61 deletions addons/trenches/functions/fnc_continueDiggingTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,27 @@ if (isNil "_vecDirAndUp") then {

// Create progress bar
private _fnc_onFinish = {
(_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
_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];
// 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"];
Expand All @@ -79,55 +79,55 @@ private _fnc_condition = {
[[_unit, _trench], _fnc_onFinish, _fnc_onFailure, localize LSTRING(DiggingTrench), _fnc_condition] call FUNC(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 = _trench getVariable [QGVAR(diggerCount), 0];

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(diggerCount), ((_diggerCount -1) max 0), true];
};

private _boundingBox = 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), true];

if (GVAR(stopBuildingAtFatigueMax) && EGVAR(advanced_fatigue,anReserve) <= 0) exitWith {
[_handle] call CBA_fnc_removePerFrameHandler;
_trench setVariable [QGVAR(digging), false, true];
_trench setVariable [QGVAR(diggerCount), (_diggerCount -1) max 0, true];
};
params ["_args", "_handle"];
_args params ["_trench", "_unit", "_digTime", "_vecDirAndUp"];
private _actualProgress = _trench getVariable [QGVAR(progress), 0];
private _diggerCount = _trench getVariable [QGVAR(diggerCount), 0];

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(diggerCount), ((_diggerCount -1) max 0), true];
};

private _boundingBox = 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), true];

if (GVAR(stopBuildingAtFatigueMax) && EGVAR(advanced_fatigue,anReserve) <= 0) exitWith {
[_handle] call CBA_fnc_removePerFrameHandler;
_trench setVariable [QGVAR(digging), false, true];
_trench setVariable [QGVAR(diggerCount), (_diggerCount -1) max 0, 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_placeTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ GVAR(digPFH) = [{
};

if !(_checkVar) exitWith {
[_unit] call ace_trenches_fnc_placeCancel;
[_unit] call FUNC(placeCancel);
};

// Update trench position
Expand Down
96 changes: 48 additions & 48 deletions addons/trenches/functions/fnc_removeTrench.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ private _fnc_onFinish = {
(_this select 0) params ["_unit", "_trench"];
_trench setVariable [QGVAR(diggingType), nil, true];

// 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"];
Expand All @@ -78,50 +78,50 @@ private _fnc_condition = {
[[_unit, _trench, false], _fnc_onFinish, _fnc_onFailure, localize LSTRING(RemovingTrench), _fnc_condition] call FUNC(progressBar);

[{
params ["_args", "_handle"];
_args params ["_trench", "_unit", "_removeTime", "_vecDirAndUp"];
private _actualProgress = _trench getVariable [QGVAR(progress), 0];
private _diggerCount = _trench getVariable [QGVAR(diggerCount), 0];

if (_actualProgress <= 0) exitWith {
[_handle] call CBA_fnc_removePerFrameHandler;
_trench setVariable [QGVAR(digging), false, true];
_trench setVariable [QGVAR(diggerCount), 0, 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(diggerCount), ((_diggerCount -1) max 0), true];
};

private _boundingBox = 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(diggerCount), ((_diggerCount -1) max 0), true];
};
params ["_args", "_handle"];
_args params ["_trench", "_unit", "_removeTime", "_vecDirAndUp"];
private _actualProgress = _trench getVariable [QGVAR(progress), 0];
private _diggerCount = _trench getVariable [QGVAR(diggerCount), 0];

if (_actualProgress <= 0) exitWith {
[_handle] call CBA_fnc_removePerFrameHandler;
_trench setVariable [QGVAR(digging), false, true];
_trench setVariable [QGVAR(diggerCount), 0, 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(diggerCount), ((_diggerCount -1) max 0), true];
};

private _boundingBox = 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(diggerCount), ((_diggerCount -1) max 0), true];
};
},0.1,[_trench, _unit, _removeTime, _vecDirAndUp]] call CBA_fnc_addPerFrameHandler;

// Play animation
Expand Down
2 changes: 1 addition & 1 deletion addons/trenches/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
#define DEFAULT_TEXTURE QPATHTOEF(apl,data\zr_plevel_co.paa)
#define CAMOUFLAGE_DURATION 5
#define CAMOUFLAGE_3DEN_ATTRIBUTE QGVAR(camouflageTrench)
#define IS_TRENCH(OBJ) ((!isNull OBJ) && {isArray (configFile >> "CfgVehicles" >> typeOf OBJ >> QGVAR(camouflagePositions))})
#define IS_TRENCH(OBJ) isArray (configFile >> "CfgVehicles" >> typeOf OBJ >> QGVAR(camouflagePositions))

#include "\z\ace\addons\main\script_macros.hpp"
Loading

0 comments on commit f33224a

Please sign in to comment.