diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp index 73971e09707..927d54f72c8 100644 --- a/addons/main/script_mod.hpp +++ b/addons/main/script_mod.hpp @@ -11,7 +11,7 @@ // MINIMAL required version for the Mod. Components can specify others.. #define REQUIRED_VERSION 1.96 -#define REQUIRED_CBA_VERSION {3,14,0} +#define REQUIRED_CBA_VERSION {3,15,0} #ifdef COMPONENT_BEAUTIFIED #define COMPONENT_NAME QUOTE(ACE3 - COMPONENT_BEAUTIFIED) diff --git a/addons/map/XEH_PREP.hpp b/addons/map/XEH_PREP.hpp index af6e815fd74..8e2094c29b2 100644 --- a/addons/map/XEH_PREP.hpp +++ b/addons/map/XEH_PREP.hpp @@ -13,3 +13,4 @@ PREP(simulateMapLight); PREP(switchFlashlight); PREP(updateMapEffects); PREP(initMainMap); +PREP(isFlashlight); diff --git a/addons/map/XEH_postInitClient.sqf b/addons/map/XEH_postInitClient.sqf index 6cf08cc7f3d..a30da81a40d 100644 --- a/addons/map/XEH_postInitClient.sqf +++ b/addons/map/XEH_postInitClient.sqf @@ -8,6 +8,8 @@ LOG(MSG_INIT); // Calculate the maximum zoom allowed for this map call FUNC(determineZoom); +GVAR(flashlights) = [] call CBA_fnc_createNamespace; + ["ace_settingsInitialized", { if (isMultiplayer && {GVAR(DefaultChannel) != -1}) then { //Set the chat channel once the map has finished loading diff --git a/addons/map/functions/fnc_getUnitFlashlights.sqf b/addons/map/functions/fnc_getUnitFlashlights.sqf index d8f537380df..f1c72e74c55 100644 --- a/addons/map/functions/fnc_getUnitFlashlights.sqf +++ b/addons/map/functions/fnc_getUnitFlashlights.sqf @@ -17,22 +17,4 @@ params ["_unit"]; -private _flashlights = []; -private _cfgWeapons = configFile >> "CfgWeapons"; - -{ - private _weaponConfig = _cfgWeapons >> _x; - if ( - -1 < [ - _weaponConfig >> "ItemInfo" >> "FlashLight", - _weaponConfig >> "FlashLight" - ] findIf { - isText (_x >> "ACE_Flashlight_Colour") - || {!(getArray (_x >> "ambient") in [[], [0,0,0]])} - } - ) then { - _flashlights pushBack _x; - }; -} forEach ([_unit, true] call CBA_fnc_uniqueUnitItems); - -_flashlights +([_unit, true] call CBA_fnc_uniqueUnitItems) select {_x call FUNC(isFlashlight)} // return diff --git a/addons/map/functions/fnc_isFlashlight.sqf b/addons/map/functions/fnc_isFlashlight.sqf new file mode 100644 index 00000000000..3d75803fc39 --- /dev/null +++ b/addons/map/functions/fnc_isFlashlight.sqf @@ -0,0 +1,43 @@ +#include "script_component.hpp" +/* + * Author: veteran29 + * Checks if the given item is a flashlight. + * + * Arguments: + * 0: Item Classname + * + * Return Value: + * Is flashlight + * + * Example: + * ["acc_flashlight"] call ace_map_fnc_isFlashlight + * + * Public: No + */ + +params [["_class", "", [""]]]; + +private _isFlashlight = GVAR(flashlights) getVariable _class; + +if (isNil "_isFlashlight") then { + private _items = ([_class] + (_class call CBA_fnc_switchableAttachments)); + private _cfgWeapons = configFile >> "CfgWeapons"; + + // if this item or any of the switchable items is a flashlight + _isFlashlight = _items findIf { + private _weaponConfig = _cfgWeapons >> _x; + + [ + _weaponConfig >> "ItemInfo" >> "FlashLight", + _weaponConfig >> "FlashLight" + ] findIf { + isText (_x >> "ACE_Flashlight_Colour") + || {!(getArray (_x >> "ambient") in [[], [0,0,0]])} + } != -1 // return + } != -1; + + // cache value + GVAR(flashlights) setVariable [_class, _isFlashlight]; +}; + +_isFlashlight // return