ACE3/addons/common/functions/fnc_canDig.sqf
PabstMirror cac223c6ec
Common - Use hashmap variable for canDig surfaces (#9147)
* Common - Use hashmap variable for canDig surfaces

* Update XEH_preInit.sqf

* Update fnc_canDig.sqf

* Update fnc_canDig.sqf
2023-02-09 13:16:42 -06:00

40 lines
1.2 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: Ruthberg, commy2
* Checks if the player can dig on the surface below (enough dust).
*
* Arguments:
* 0: Unit or Position (2d/3d) <OBJECT><ARRAY>
*
* Return Value:
* Can Dig <BOOL>
*
* Example:
* [ACE_player] call ace_common_fnc_canDig
* [[1000,2000]] call ace_common_fnc_canDig
*
* Public: No
*/
params ["_input"];
private _posASL = _input;
if ((_input isEqualType objNull) && {
_posASL = getPosASL _input;
(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 _config = configFile >> "CfgSurfaces" >> _surfaceClass;
TRACE_3("",_surfaceClass,getText (_config >> "soundEnviron"),getNumber (_config >> "dust"));
if (isNumber (_config >> "ACE_canDig")) then {
(getNumber (_config >> "ACE_canDig")) == 1 // return
} else {
private _surfaceType = getText (_config >> "soundEnviron");
GVAR(canDigSurfaces) getOrDefault [_surfaceType, getNumber (_config >> "dust") >= 0.1, true] // return
};