From 643f4d36dc1115ea7737c123454505381a788c65 Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 28 Oct 2015 08:01:25 +0100 Subject: [PATCH] add FUNC(hasHatch) --- addons/common/XEH_preInit.sqf | 1 + addons/common/functions/fnc_hasHatch.sqf | 35 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 addons/common/functions/fnc_hasHatch.sqf diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index e1cc807bdc..a9b10c4896 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -223,6 +223,7 @@ PREP(getTurretCopilot); PREP(getDoorTurrets); PREP(getTurretsFFV); PREP(getTurretsOther); +PREP(hasHatch); // missing inventory commands PREP(binocularMagazine); diff --git a/addons/common/functions/fnc_hasHatch.sqf b/addons/common/functions/fnc_hasHatch.sqf new file mode 100644 index 0000000000..59da0938bd --- /dev/null +++ b/addons/common/functions/fnc_hasHatch.sqf @@ -0,0 +1,35 @@ +/* + * Author: commy2 + * Check if unit has a hatch and can turn out. + * + * Arguments: + * 0: Unit + * + * Return Value: + * Unit has a hatch? + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_unit"]; + +local _vehicle = vehicle _unit; + +if (_unit == _vehicle) exitWith {false}; + +local _config = configFile >> "CfgVehicles" >> typeOf _vehicle; + +if (getNumber (_config >> "hideProxyInCombat") != 1) exitWith {false}; + +if (_unit == driver _vehicle) exitWith { + getNumber (_config >> "forceHideDriver") == 0; // return +}; + +local _turret = [_unit] call FUNC(getTurretIndex); + +if (_turret isEqualTo []) exitWith {false}; + +local _turretConfig = [_config, _turret] call FUNC(getTurretConfigPath); + +getNumber (_turretConfig >> "forceHideGunner") == 0; // return