diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 3f6f264699..b4e5f26986 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -13,6 +13,7 @@ PREP(ASLToPosition); PREP(binarizeNumber); PREP(blurScreen); PREP(cachedCall); +PREP(canDig); PREP(canGetInPosition); PREP(canInteractWith); PREP(changeProjectileDirection); diff --git a/addons/common/functions/fnc_canDig.sqf b/addons/common/functions/fnc_canDig.sqf new file mode 100644 index 0000000000..b3cdfd8405 --- /dev/null +++ b/addons/common/functions/fnc_canDig.sqf @@ -0,0 +1,31 @@ +/* + * Author: Ruthberg, commy2 + * Checks if the player can dig on the surface below (enough dust). + * + * Arguments: + * 0: Unit + * + * Return Value: + * Can Dig + * + * Example: + * [ACE_player] call ace_common_fnc_canDig + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit"]; + +private _posASL = getPosASL _unit; + +if ((getPosATL _unit) select 2 > 0.05 || // Walking on objects, such as buildings, pavements, etc. + {surfaceIsWater _posASL} // posATL in low water (not as low to allow awalking) is negative +) exitWith {false}; + +private _surfaceClass = (surfaceType _posASL) select [1]; +private _surfaceType = getText (configFile >> "CfgSurfaces" >> _surfaceClass >> "soundEnviron"); +private _surfaceDust = getNumber (configFile >> "CfgSurfaces" >> _surfaceClass >> "dust"); +TRACE_2("Surface",_surfaceType,_surfaceDust); + +!(_surfaceType in DIG_SURFACE_BLACKLIST) && {_surfaceDust >= 0.1} diff --git a/addons/common/script_component.hpp b/addons/common/script_component.hpp index af8e0a5229..66f7ac63bf 100644 --- a/addons/common/script_component.hpp +++ b/addons/common/script_component.hpp @@ -19,3 +19,16 @@ #define VERSION_CONFIG_COMMON VERSION_CONFIG;\ versionDesc = "ACE 3";\ versionAct = QUOTE(call COMPILE_FILE(init_versionTooltip)) + + +#define DIG_SURFACE_BLACKLIST [ \ + "concrete", "concrete_exp", "concrete_int", "int_concrete", "int_concrete_exp", \ + "pavement_exp", "int_pavement_exp", \ + "tiling", "tiles_int", "int_tiles", \ + "roof_tin", "roof_tiles", "rooftiles_exp", \ + "tarmac", "asphalt_exp", \ + "stones_exp", "rock", "stony", \ + "metal", "gridmetal_exp", "metalplate_exp", "int_metalplate_exp", "metal_int", "wavymetal", "wavymetal_exp", "int_metal", "steel_exp", \ + "lino_exp", "int_lino_exp", "int_mat_exp", \ + "wood", "wood_int", "int_wood", "softwood_exp", "int_softwood_exp", "int_solidwood_exp" \ +] diff --git a/addons/sandbag/functions/fnc_canDeploy.sqf b/addons/sandbag/functions/fnc_canDeploy.sqf index b9bd025dff..426dde56f2 100644 --- a/addons/sandbag/functions/fnc_canDeploy.sqf +++ b/addons/sandbag/functions/fnc_canDeploy.sqf @@ -1,9 +1,9 @@ /* * Author: Ruthberg, commy2 - * Checks if the player can deploy a sandbag + * Checks if the player can deploy a sandbag. * * Arguments: - * None + * 0: Unit * * Return Value: * Can deploy @@ -15,15 +15,8 @@ */ #include "script_component.hpp" -#define SURFACE_BLACKLIST ["water", "concrete", "tarmac", "wood", "metal", "roof_tin", "roof_tiles", "wood_int", "concrete_int", "tiles_int", "metal_int", "stony", "rock", "int_concrete", "int_tiles", "int_wood", "tiling", "wavymetal", "int_metal"] - params ["_unit"]; if !("ACE_Sandbag_empty" in items _unit) exitWith {false}; -private ["_surfaceClass", "_surfaceType"]; - -_surfaceClass = (surfaceType getPosASL _unit) select [1]; -_surfaceType = getText (configFile >> "CfgSurfaces" >> _surfaceClass >> "soundEnviron"); - -!(_surfaceType in SURFACE_BLACKLIST) +_unit call EFUNC(common,canDig) diff --git a/addons/sandbag/functions/fnc_deployConfirm.sqf b/addons/sandbag/functions/fnc_deployConfirm.sqf index 47b74533a1..68328cca67 100644 --- a/addons/sandbag/functions/fnc_deployConfirm.sqf +++ b/addons/sandbag/functions/fnc_deployConfirm.sqf @@ -29,14 +29,12 @@ _unit removeItem "ACE_Sandbag_empty"; params ["_unit"]; - private ["_position", "_direction", "_sandBag"]; - - _position = getPosASL GVAR(sandBag); - _direction = getDir GVAR(sandBag); + private _position = getPosASL GVAR(sandBag); + private _direction = getDir GVAR(sandBag); deleteVehicle GVAR(sandBag); - _sandBag = createVehicle ["ACE_SandbagObject", [0, 0, 0], [], 0, "NONE"]; + private _sandBag = createVehicle ["ACE_SandbagObject", [0, 0, 0], [], 0, "NONE"]; _sandBag setPosASL _position; _sandBag setDir _direction; diff --git a/addons/trenches/functions/fnc_canDigTrench.sqf b/addons/trenches/functions/fnc_canDigTrench.sqf index 0cbed2d9b7..a99c5c6b60 100644 --- a/addons/trenches/functions/fnc_canDigTrench.sqf +++ b/addons/trenches/functions/fnc_canDigTrench.sqf @@ -1,6 +1,6 @@ /* * Author: Ruthberg, commy2, esteldunedain - * Checks if a unit can dig a trench + * Checks if a unit can dig a trench. * * Arguments: * 0: Unit @@ -15,17 +15,8 @@ */ #include "script_component.hpp" -#define SURFACE_BLACKLIST ["water", "concrete", "tarmac", "wood", "metal", "roof_tin", "roof_tiles", "wood_int", "concrete_int", "tiles_int", "metal_int", "stony", "rock", "int_concrete", "int_tiles", "int_wood", "tiling", "wavymetal", "int_metal"] - params ["_unit"]; if !("ACE_EntrenchingTool" in items _unit) exitWith {false}; -// Can't dig trench if above ground level -if ((getPosATL _unit) select 2 > 0.05) exitWith {false}; - -private _surfaceClass = (surfaceType getPosASL _unit) select [1]; -private _surfaceType = getText (configFile >> "CfgSurfaces" >> _surfaceClass >> "soundEnviron"); -TRACE_1("",_surfaceType); - -!(_surfaceType in SURFACE_BLACKLIST) +_unit call EFUNC(common,canDig)